Lines Matching +full:firmware +full:- +full:initialized

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2006-2010 Freescale Semiconductor, Inc. All rights reserved.
50 static phys_addr_t qebase = -1;
72 if (qebase != -1) in get_qe_base()
113 iowrite32be((u32)(cmd | QE_CR_FLG), &qe_immr->cp.cecr); in qe_issue_cmd()
116 /* Here device is the SNUM, not sub-block */ in qe_issue_cmd()
130 iowrite32be(cmd_input, &qe_immr->cp.cecdr); in qe_issue_cmd()
132 &qe_immr->cp.cecr); in qe_issue_cmd()
136 ret = readx_poll_timeout_atomic(ioread32be, &qe_immr->cp.cecr, val, in qe_issue_cmd()
138 /* On timeout, ret is -ETIMEDOUT, otherwise it will be 0. */ in qe_issue_cmd()
152 * Baud rate clocks are zero-based in the driver code (as that maps
153 * to port numbers). Documentation uses 1-based numbering.
173 if (!of_property_read_u32(qe, "brg-frequency", &brg)) in qe_get_brg_clk()
182 brg_clk -= mod; in qe_get_brg_clk()
183 else if (mod > (CLK_GRAN - CLK_GRAN_LIMIT)) in qe_get_brg_clk()
184 brg_clk += CLK_GRAN - mod; in qe_get_brg_clk()
204 * @brg: the BRG, QE_BRG1 - QE_BRG16
216 return -EINVAL; in qe_setbrg()
226 that the BRG divisor must be even if you're not using divide-by-16 in qe_setbrg()
232 tempval = ((divisor - 1) << QE_BRGC_DIVISOR_SHIFT) | in qe_setbrg()
235 iowrite32be(tempval, &qe_immr->brg.brgc[brg - QE_BRG1]); in qe_setbrg()
262 return (QE_BRG1 - 1) + i; in qe_clock_source()
270 return (QE_CLK1 - 1) + i; in qe_clock_source()
312 i = of_property_read_variable_u8_array(qe, "fsl,qe-snums", in qe_snums_init()
321 * fsl,qe-num-snums to choose one of the static arrays in qe_snums_init()
324 of_property_read_u32(qe, "fsl,qe-num-snums", &qe_num_of_snum); in qe_snums_init()
333 pr_err("QE: unsupported value of fsl,qe-num-snums: %u\n", qe_num_of_snum); in qe_snums_init()
342 int snum = -EBUSY; in qe_get_snum()
362 clear_bit(p - snums, snum_state); in qe_put_snum()
368 struct sdma __iomem *sdma = &qe_immr->sdma; in qe_sdma_init()
369 static s32 sdma_buf_offset = -ENOMEM; in qe_sdma_init()
376 return -ENOMEM; in qe_sdma_init()
380 &sdma->sdebcr); in qe_sdma_init()
382 &sdma->sdmr); in qe_sdma_init()
390 /* Firmware information stored here for qe_get_firmware_info() */
394 * Set to 1 if QE firmware has been uploaded, and therefore
408 const __be32 *code = base + be32_to_cpu(ucode->code_offset); in qe_upload_microcode()
411 if (ucode->major || ucode->minor || ucode->revision) in qe_upload_microcode()
412 printk(KERN_INFO "qe-firmware: " in qe_upload_microcode()
414 ucode->id, ucode->major, ucode->minor, ucode->revision); in qe_upload_microcode()
416 printk(KERN_INFO "qe-firmware: " in qe_upload_microcode()
417 "uploading microcode '%s'\n", ucode->id); in qe_upload_microcode()
419 /* Use auto-increment */ in qe_upload_microcode()
420 iowrite32be(be32_to_cpu(ucode->iram_offset) | QE_IRAM_IADD_AIE | QE_IRAM_IADD_BADDR, in qe_upload_microcode()
421 &qe_immr->iram.iadd); in qe_upload_microcode()
423 for (i = 0; i < be32_to_cpu(ucode->count); i++) in qe_upload_microcode()
424 iowrite32be(be32_to_cpu(code[i]), &qe_immr->iram.idata); in qe_upload_microcode()
426 /* Set I-RAM Ready Register */ in qe_upload_microcode()
427 iowrite32be(QE_IRAM_READY, &qe_immr->iram.iready); in qe_upload_microcode()
431 * Upload a microcode to the I-RAM at a specific address.
442 * 'calc_size' is the calculated size, in bytes, of the firmware structure and
447 int qe_upload_firmware(const struct qe_firmware *firmware) in qe_upload_firmware() argument
456 if (!firmware) { in qe_upload_firmware()
457 printk(KERN_ERR "qe-firmware: invalid pointer\n"); in qe_upload_firmware()
458 return -EINVAL; in qe_upload_firmware()
461 hdr = &firmware->header; in qe_upload_firmware()
462 length = be32_to_cpu(hdr->length); in qe_upload_firmware()
465 if ((hdr->magic[0] != 'Q') || (hdr->magic[1] != 'E') || in qe_upload_firmware()
466 (hdr->magic[2] != 'F')) { in qe_upload_firmware()
467 printk(KERN_ERR "qe-firmware: not a microcode\n"); in qe_upload_firmware()
468 return -EPERM; in qe_upload_firmware()
472 if (hdr->version != 1) { in qe_upload_firmware()
473 printk(KERN_ERR "qe-firmware: unsupported version\n"); in qe_upload_firmware()
474 return -EPERM; in qe_upload_firmware()
478 if ((firmware->count < 1) || (firmware->count > MAX_QE_RISC)) { in qe_upload_firmware()
479 printk(KERN_ERR "qe-firmware: invalid data\n"); in qe_upload_firmware()
480 return -EINVAL; in qe_upload_firmware()
484 calc_size = struct_size(firmware, microcode, firmware->count); in qe_upload_firmware()
486 for (i = 0; i < firmware->count; i++) in qe_upload_firmware()
493 be32_to_cpu(firmware->microcode[i].count); in qe_upload_firmware()
497 printk(KERN_ERR "qe-firmware: invalid length\n"); in qe_upload_firmware()
498 return -EPERM; in qe_upload_firmware()
502 crc = be32_to_cpu(*(__be32 *)((void *)firmware + calc_size)); in qe_upload_firmware()
503 if (crc != crc32(0, firmware, calc_size)) { in qe_upload_firmware()
504 printk(KERN_ERR "qe-firmware: firmware CRC is invalid\n"); in qe_upload_firmware()
505 return -EIO; in qe_upload_firmware()
509 * If the microcode calls for it, split the I-RAM. in qe_upload_firmware()
511 if (!firmware->split) in qe_upload_firmware()
512 qe_setbits_be16(&qe_immr->cp.cercr, QE_CP_CERCR_CIR); in qe_upload_firmware()
514 if (firmware->soc.model) in qe_upload_firmware()
516 "qe-firmware: firmware '%s' for %u V%u.%u\n", in qe_upload_firmware()
517 firmware->id, be16_to_cpu(firmware->soc.model), in qe_upload_firmware()
518 firmware->soc.major, firmware->soc.minor); in qe_upload_firmware()
520 printk(KERN_INFO "qe-firmware: firmware '%s'\n", in qe_upload_firmware()
521 firmware->id); in qe_upload_firmware()
528 strscpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id)); in qe_upload_firmware()
529 qe_firmware_info.extended_modes = be64_to_cpu(firmware->extended_modes); in qe_upload_firmware()
530 memcpy(qe_firmware_info.vtraps, firmware->vtraps, in qe_upload_firmware()
531 sizeof(firmware->vtraps)); in qe_upload_firmware()
534 for (i = 0; i < firmware->count; i++) { in qe_upload_firmware()
535 const struct qe_microcode *ucode = &firmware->microcode[i]; in qe_upload_firmware()
538 if (ucode->code_offset) in qe_upload_firmware()
539 qe_upload_microcode(firmware, ucode); in qe_upload_firmware()
543 u32 trap = be32_to_cpu(ucode->traps[j]); in qe_upload_firmware()
547 &qe_immr->rsp[i].tibcr[j]); in qe_upload_firmware()
551 iowrite32be(be32_to_cpu(ucode->eccr), in qe_upload_firmware()
552 &qe_immr->rsp[i].eccr); in qe_upload_firmware()
562 * Get info on the currently-loaded firmware
565 * uploaded a firmware already.
569 static int initialized; in qe_get_firmware_info() local
575 * If we haven't checked yet, and a driver hasn't uploaded a firmware in qe_get_firmware_info()
581 if (initialized) in qe_get_firmware_info()
584 initialized = 1; in qe_get_firmware_info()
590 /* Find the 'firmware' child node */ in qe_get_firmware_info()
591 fw = of_get_child_by_name(qe, "firmware"); in qe_get_firmware_info()
594 /* Did we find the 'firmware' node? */ in qe_get_firmware_info()
606 of_property_read_u64(fw, "extended-modes", in qe_get_firmware_info()
609 of_property_read_u32_array(fw, "virtual-traps", qe_firmware_info.vtraps, in qe_get_firmware_info()
627 of_property_read_u32(qe, "fsl,qe-num-riscs", &num_of_risc); in qe_get_num_of_risc()
647 return -ENODEV; in qe_init()
674 .name = "fsl-qe",