Lines Matching refs:mcode
123 static int cpt_load_microcode(struct cpt_device *cpt, struct microcode *mcode) in cpt_load_microcode() argument
129 if (!mcode || !mcode->code) { in cpt_load_microcode()
134 if (mcode->code_size == 0) { in cpt_load_microcode()
142 if (mcode->is_ae) { in cpt_load_microcode()
152 if (mcode->core_mask & (1 << shift)) { in cpt_load_microcode()
155 (u64)mcode->phys_base); in cpt_load_microcode()
161 static int do_cpt_init(struct cpt_device *cpt, struct microcode *mcode) in do_cpt_init() argument
171 if (mcode->is_ae) { in do_cpt_init()
172 if (mcode->num_cores > cpt->max_ae_cores) { in do_cpt_init()
183 mcode->group = cpt->next_group; in do_cpt_init()
185 mcode->core_mask = GENMASK(mcode->num_cores, 0); in do_cpt_init()
186 cpt_disable_cores(cpt, mcode->core_mask, AE_TYPES, in do_cpt_init()
187 mcode->group); in do_cpt_init()
189 ret = cpt_load_microcode(cpt, mcode); in do_cpt_init()
192 mcode->version); in do_cpt_init()
197 cpt_configure_group(cpt, mcode->group, mcode->core_mask, in do_cpt_init()
200 cpt_enable_cores(cpt, mcode->core_mask, AE_TYPES); in do_cpt_init()
202 if (mcode->num_cores > cpt->max_se_cores) { in do_cpt_init()
212 mcode->group = cpt->next_group; in do_cpt_init()
214 mcode->core_mask = GENMASK(mcode->num_cores, 0); in do_cpt_init()
215 cpt_disable_cores(cpt, mcode->core_mask, SE_TYPES, in do_cpt_init()
216 mcode->group); in do_cpt_init()
218 ret = cpt_load_microcode(cpt, mcode); in do_cpt_init()
221 mcode->version); in do_cpt_init()
226 cpt_configure_group(cpt, mcode->group, mcode->core_mask, in do_cpt_init()
229 cpt_enable_cores(cpt, mcode->core_mask, SE_TYPES); in do_cpt_init()
257 struct microcode *mcode; in cpt_ucode_load_fw() local
265 mcode = &cpt->mcode[cpt->next_mc_idx]; in cpt_ucode_load_fw()
266 memcpy(mcode->version, (u8 *)fw_entry->data, CPT_UCODE_VERSION_SZ); in cpt_ucode_load_fw()
267 mcode->code_size = ntohl(ucode->code_length) * 2; in cpt_ucode_load_fw()
268 if (!mcode->code_size) { in cpt_ucode_load_fw()
273 mcode->is_ae = is_ae; in cpt_ucode_load_fw()
274 mcode->core_mask = 0ULL; in cpt_ucode_load_fw()
275 mcode->num_cores = is_ae ? 6 : 10; in cpt_ucode_load_fw()
278 mcode->code = dma_alloc_coherent(&cpt->pdev->dev, mcode->code_size, in cpt_ucode_load_fw()
279 &mcode->phys_base, GFP_KERNEL); in cpt_ucode_load_fw()
280 if (!mcode->code) { in cpt_ucode_load_fw()
286 memcpy((void *)mcode->code, (void *)(fw_entry->data + sizeof(*ucode)), in cpt_ucode_load_fw()
287 mcode->code_size); in cpt_ucode_load_fw()
290 for (j = 0; j < (mcode->code_size / 8); j++) in cpt_ucode_load_fw()
291 ((u64 *)mcode->code)[j] = cpu_to_be64(((u64 *)mcode->code)[j]); in cpt_ucode_load_fw()
293 for (j = 0; j < (mcode->code_size / 2); j++) in cpt_ucode_load_fw()
294 ((u16 *)mcode->code)[j] = cpu_to_be16(((u16 *)mcode->code)[j]); in cpt_ucode_load_fw()
296 dev_dbg(dev, "mcode->code_size = %u\n", mcode->code_size); in cpt_ucode_load_fw()
297 dev_dbg(dev, "mcode->is_ae = %u\n", mcode->is_ae); in cpt_ucode_load_fw()
298 dev_dbg(dev, "mcode->num_cores = %u\n", mcode->num_cores); in cpt_ucode_load_fw()
299 dev_dbg(dev, "mcode->code = %llx\n", (u64)mcode->code); in cpt_ucode_load_fw()
300 dev_dbg(dev, "mcode->phys_base = %llx\n", mcode->phys_base); in cpt_ucode_load_fw()
302 ret = do_cpt_init(cpt, mcode); in cpt_ucode_load_fw()
308 dev_info(dev, "Microcode Loaded %s\n", mcode->version); in cpt_ucode_load_fw()
309 mcode->is_mc_valid = 1; in cpt_ucode_load_fw()
416 struct microcode *mcode = &cpt->mcode[grp]; in cpt_unload_microcode() local
418 if (cpt->mcode[grp].code) in cpt_unload_microcode()
419 dma_free_coherent(&cpt->pdev->dev, mcode->code_size, in cpt_unload_microcode()
420 mcode->code, mcode->phys_base); in cpt_unload_microcode()
421 mcode->code = NULL; in cpt_unload_microcode()