Lines Matching +full:fsl +full:- +full:mc

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2017-2018 NXP
14 #include <fsl-mc/fsl_mc.h>
15 #include <fsl-mc/fsl_mc_sys.h>
16 #include <fsl-mc/fsl_mc_private.h>
17 #include <fsl-mc/fsl_dpmng.h>
18 #include <fsl-mc/fsl_dprc.h>
19 #include <fsl-mc/fsl_dpio.h>
20 #include <fsl-mc/fsl_dpni.h>
21 #include <fsl-mc/fsl_qbman_portal.h>
22 #include <fsl-mc/ldpaa_wriop.h>
25 #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK (~(MC_RAM_BASE_ADDR_ALIGNMENT - 1))
35 static int mc_boot_status = -1;
36 static int mc_dpl_applied = -1;
38 static int mc_aiop_applied = -1;
65 printf("MC CCSR registers:\n" in dump_mc_ccsr_regs()
75 mc_ccsr_regs->reg_gcr1, in dump_mc_ccsr_regs()
76 mc_ccsr_regs->reg_gsr, in dump_mc_ccsr_regs()
77 mc_ccsr_regs->reg_sicbalr, in dump_mc_ccsr_regs()
78 mc_ccsr_regs->reg_sicbahr, in dump_mc_ccsr_regs()
79 mc_ccsr_regs->reg_sicapr, in dump_mc_ccsr_regs()
80 mc_ccsr_regs->reg_mcfbalr, in dump_mc_ccsr_regs()
81 mc_ccsr_regs->reg_mcfbahr, in dump_mc_ccsr_regs()
82 mc_ccsr_regs->reg_mcfapr, in dump_mc_ccsr_regs()
83 mc_ccsr_regs->reg_psr); in dump_mc_ccsr_regs()
94 * Copying MC firmware or DPL image to DDR
106 * MC firmware FIT image parser checks if the image is in FIT
129 printf("fsl-mc: ERR: Bad firmware image (not a FIT image)\n"); in parse_mc_firmware_fit_image()
130 return -EINVAL; in parse_mc_firmware_fit_image()
134 printf("fsl-mc: ERR: Bad firmware image (bad FIT header)\n"); in parse_mc_firmware_fit_image()
135 return -EINVAL; in parse_mc_firmware_fit_image()
141 printf("fsl-mc: ERR: Bad firmware image (missing subimage)\n"); in parse_mc_firmware_fit_image()
142 return -ENOENT; in parse_mc_firmware_fit_image()
145 /* Verify MC firmware image */ in parse_mc_firmware_fit_image()
147 printf("fsl-mc: ERR: Bad firmware image (bad CRC)\n"); in parse_mc_firmware_fit_image()
148 return -EINVAL; in parse_mc_firmware_fit_image()
181 enetaddr_32[i] = cpu_to_fdt32(eth_dev->enetaddr[i]); in mc_fixup_mac_addr()
187 val = eth_dev->enetaddr; in mc_fixup_mac_addr()
194 /* u-boot MAC addr randomly assigned - leave the present one */ in mc_fixup_mac_addr()
195 if (!eth_env_get_enetaddr_by_index("eth", eth_dev->index, in mc_fixup_mac_addr()
248 int dpmacoff = -1, dpnioff = -1; in mc_fixup_dpl_mac_addr()
291 /* find fsl-mc node */ in fdt_fsl_mc_fixup_iommu_map_entry()
292 offset = fdt_path_offset(blob, "/soc/fsl-mc"); in fdt_fsl_mc_fixup_iommu_map_entry()
294 offset = fdt_path_offset(blob, "/fsl-mc"); in fdt_fsl_mc_fixup_iommu_map_entry()
296 printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n", in fdt_fsl_mc_fixup_iommu_map_entry()
301 prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp); in fdt_fsl_mc_fixup_iommu_map_entry()
303 debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n", in fdt_fsl_mc_fixup_iommu_map_entry()
311 iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END - in fdt_fsl_mc_fixup_iommu_map_entry()
314 fdt_setprop_inplace(blob, offset, "iommu-map", in fdt_fsl_mc_fixup_iommu_map_entry()
328 /* node not found - create it */ in mc_fixup_dpc_mac_addr()
389 printf("fsl-mc: ERROR fixing mac address for %s\n", in mc_fixup_mac_addrs()
405 printf("\nfsl-mc: WARNING: could not delete ICID pool\n"); in mc_fixup_dpc()
410 printf("\nfsl-mc: ERROR: DPC is missing /resources\n"); in mc_fixup_dpc()
411 return -EINVAL; in mc_fixup_dpc()
419 FSL_DPAA2_STREAM_ID_END - in mc_fixup_dpc()
454 * Load the MC DPC blob in the MC private DRAM block: in load_mc_dpc()
457 printf("MC DPC is preloaded to %#llx\n", mc_ram_addr + mc_dpc_offset); in load_mc_dpc()
467 * Don't return with error here, since the MC firmware can in load_mc_dpc()
470 printf("\nfsl-mc: WARNING: No DPC image found"); in load_mc_dpc()
476 printf("\nfsl-mc: ERROR: Bad DPC image (too large: %d)\n", in load_mc_dpc()
478 return -EINVAL; in load_mc_dpc()
481 mc_copy_image("MC DPC blob", in load_mc_dpc()
486 return -EINVAL; in load_mc_dpc()
496 u32 ver = fdt_getprop_u32_default(blob, "/", "dpl-version", 0); in mc_fixup_dpl()
500 * for old-style DPLs in mc_fixup_dpl()
530 * Load the MC DPL blob in the MC private DRAM block: in load_mc_dpl()
533 printf("MC DPL is preloaded to %#llx\n", mc_ram_addr + mc_dpl_offset); in load_mc_dpl()
542 printf("\nfsl-mc: ERROR: Bad DPL image (bad header)\n"); in load_mc_dpl()
548 printf("\nfsl-mc: ERROR: Bad DPL image (too large: %d)\n", in load_mc_dpl()
550 return -EINVAL; in load_mc_dpl()
553 mc_copy_image("MC DPL blob", in load_mc_dpl()
558 return -EINVAL; in load_mc_dpl()
564 * Return the MC boot timeout value in milliseconds
575 printf("fsl-mc: WARNING: Invalid value for \'" in get_mc_boot_timeout_ms()
603 return -ENODEV; in load_mc_aiop_img()
605 * Load the MC AIOP image in the MC private DRAM block: in load_mc_aiop_img()
609 printf("MC AIOP is preloaded to %#llx\n", mc_ram_addr + in load_mc_aiop_img()
613 mc_copy_image("MC AIOP image", in load_mc_aiop_img()
634 reg_gsr = in_le32(&mc_ccsr_regs->reg_gsr); in wait_for_mc()
639 timeout_ms--; in wait_for_mc()
647 /* TODO: Get an error status from an MC CCSR register */ in wait_for_mc()
648 return -ETIMEDOUT; in wait_for_mc()
654 * field and for those errors, set error to -ENODEV or other in wait_for_mc()
656 * failure in the fsl,dprc device tree node. in wait_for_mc()
688 error = -EINVAL; in mc_init()
689 printf("fsl-mc: ERROR: invalid MC private RAM size (%lu)\n", in mc_init()
695 * To support 128 MB DDR Size for MC in mc_init()
702 * U-Boot should be the first software to touch MC. To be safe, in mc_init()
705 * we kick off MC by deasserting the reset bit for core 0, and in mc_init()
712 out_le32(&mc_ccsr_regs->reg_gcr1, 0); in mc_init()
716 printf("MC firmware is preloaded to %#llx\n", mc_ram_addr); in mc_init()
723 * Load the MC FW at the beginning of the MC private DRAM block: in mc_init()
725 mc_copy_image("MC Firmware", in mc_init()
738 * Tell MC what is the address range of the DRAM block assigned to it: in mc_init()
742 (mc_ram_num_256mb_blocks - 1); in mc_init()
748 out_le32(&mc_ccsr_regs->reg_mcfbalr, reg_mcfbalr); in mc_init()
749 out_le32(&mc_ccsr_regs->reg_mcfbahr, in mc_init()
751 out_le32(&mc_ccsr_regs->reg_mcfapr, FSL_BYPASS_AMQ); in mc_init()
754 * Tell the MC that we want delayed DPL deployment. in mc_init()
756 out_le32(&mc_ccsr_regs->reg_gsr, 0xDD00); in mc_init()
758 printf("\nfsl-mc: Booting Management Complex ... "); in mc_init()
761 * Deassert reset and release MC core 0 to run in mc_init()
763 out_le32(&mc_ccsr_regs->reg_gcr1, GCR1_P1_DE_RST | GCR1_M_ALL_DE_RST); in mc_init()
775 * Initialize the global default MC portal in mc_init()
776 * And check that the MC firmware is responding portal commands: in mc_init()
781 return -ENOMEM; in mc_init()
784 root_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(portal_id); in mc_init()
785 …debug("Checking access to MC portal of root DPRC container (portal_id %d, portal physical addr %p)… in mc_init()
786 portal_id, root_mc_io->mmio_regs); in mc_init()
790 printf("fsl-mc: ERROR: Firmware version check failed (error: %d)\n", in mc_init()
795 printf("fsl-mc: Management Complex booted (version: %d.%d.%d, boot status: %#x)\n", in mc_init()
817 return -1; in mc_apply_dpl()
824 * Tell the MC to deploy the DPL: in mc_apply_dpl()
826 out_le32(&mc_ccsr_regs->reg_gsr, 0x0); in mc_apply_dpl()
827 printf("fsl-mc: Deploying data path layout ... "); in mc_apply_dpl()
859 * Return the MC address of private DRAM block.
860 * As per MC design document, MC initial base address
861 * should be least significant 512MB address of MC private
871 memset((void *)gd->arch.resv_ram, 0, mc_ram_size); in mc_get_dram_addr()
874 return (gd->arch.resv_ram + mc_ram_size - 1) & in mc_get_dram_addr()
879 * Return the actual size of the MC private DRAM block.
892 printf("fsl-mc: WARNING: Invalid value for \'" in mc_get_dram_block_size()
950 err = -ENOMEM; in dpio_init()
960 &dflt_dpio->dpio_id); in dpio_init()
963 err = -ENODEV; in dpio_init()
984 dflt_dpio->dpio_id, in dpio_init()
985 &dflt_dpio->dpio_handle); in dpio_init()
993 dflt_dpio->dpio_handle, &attr); in dpio_init()
999 if (dflt_dpio->dpio_id != attr.id) { in dpio_init()
1005 printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id); in dpio_init()
1007 err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); in dpio_init()
1023 dflt_dpio->sw_portal = qbman_swp_init(&p_des); in dpio_init()
1024 if (dflt_dpio->sw_portal == NULL) { in dpio_init()
1031 dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); in dpio_init()
1035 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); in dpio_init()
1041 dflt_dpio->dpio_id); in dpio_init()
1052 err = dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); in dpio_exit()
1058 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle); in dpio_exit()
1067 dflt_dpio->dpio_id); in dpio_exit()
1074 printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id); in dpio_exit()
1137 err = -ENOMEM; in dprc_init()
1143 dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id); in dprc_init()
1146 printf("MC portal of child DPRC container: %d, physical addr %p)\n", in dprc_init()
1147 child_dprc_id, dflt_mc_io->mmio_regs); in dprc_init()
1221 err = -ENOMEM; in dpbp_init()
1231 &dflt_dpbp->dpbp_id); in dpbp_init()
1234 err = -ENODEV; in dpbp_init()
1257 dflt_dpbp->dpbp_id, in dpbp_init()
1258 &dflt_dpbp->dpbp_handle); in dpbp_init()
1266 dflt_dpbp->dpbp_handle, in dpbp_init()
1273 if (dflt_dpbp->dpbp_id != dpbp_attr.id) { in dpbp_init()
1279 printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id); in dpbp_init()
1282 err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); in dpbp_init()
1292 dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle); in dpbp_init()
1296 dflt_dpbp->dpbp_id); in dpbp_init()
1311 dflt_dpbp->dpbp_id); in dpbp_exit()
1318 printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id); in dpbp_exit()
1340 err = -ENOMEM; in dpni_init()
1347 err = -ENODEV; in dpni_init()
1356 &dflt_dpni->dpni_id); in dpni_init()
1358 err = -ENODEV; in dpni_init()
1381 dflt_dpni->dpni_id, in dpni_init()
1382 &dflt_dpni->dpni_handle); in dpni_init()
1389 printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id); in dpni_init()
1391 err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); in dpni_init()
1400 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle); in dpni_init()
1406 dflt_dpni->dpni_id); in dpni_init()
1419 dflt_dpni->dpni_id); in dpni_exit()
1426 printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id); in dpni_exit()
1486 /* MC is not loaded intentionally, So return success. */ in fsl_mc_ldpaa_exit()
1495 * For case MC is loaded but DPL is not deployed, return success and in fsl_mc_ldpaa_exit()
1496 * print message on console. Else FDT fix-up code execution hanged. in fsl_mc_ldpaa_exit()
1499 printf("fsl-mc: DPL not deployed, DPAA2 ethernet not work\n"); in fsl_mc_ldpaa_exit()
1558 printf("fsl-mc: MC is already booted"); in do_fsl_mc()
1575 printf("fsl-mc: AIOP FW is already"); in do_fsl_mc()
1583 /* if SoC doesn't have AIOP, err = -ENODEV */ in do_fsl_mc()
1586 printf("fsl-mc: AIOP FW applied\n"); in do_fsl_mc()
1606 printf("fsl-mc: DPL already applied\n"); in do_fsl_mc()
1614 printf("fsl-mc: Deploying data path layout .."); in do_fsl_mc()
1615 printf("ERROR (MC is not booted)\n"); in do_fsl_mc()
1616 return -ENODEV; in do_fsl_mc()
1644 "DPAA2 command to manage Management Complex (MC)",
1645 "start mc [FW_addr] [DPC_addr] - Start Management Complex\n"
1646 "fsl_mc apply DPL [DPL_addr] - Apply DPL file\n"
1647 "fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
1648 "fsl_mc start aiop [FW_addr] - Start AIOP\n"
1655 /* The MC may only be initialized in the reset PHY function in mc_env_boot()
1656 * because otherwise U-Boot has not yet set up all the MAC in mc_env_boot()
1657 * address info properly. Without MAC addresses, the MC code in mc_env_boot()
1662 run_command_list(mc_boot_env_var, -1, 0); in mc_env_boot()