1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
4 * Copyright 2017-2018 NXP
14 #include <linux/bug.h>
16 #include <linux/delay.h>
17 #include <linux/libfdt.h>
19 #include <fdt_support.h>
20 #include <fsl-mc/fsl_mc.h>
21 #include <fsl-mc/fsl_mc_sys.h>
22 #include <fsl-mc/fsl_mc_private.h>
23 #include <fsl-mc/fsl_dpmng.h>
24 #include <fsl-mc/fsl_dprc.h>
25 #include <fsl-mc/fsl_dpio.h>
26 #include <fsl-mc/fsl_dpni.h>
27 #include <fsl-mc/fsl_dpsparser.h>
28 #include <fsl-mc/fsl_qbman_portal.h>
29 #include <fsl-mc/ldpaa_wriop.h>
31 #define MC_RAM_BASE_ADDR_ALIGNMENT (512UL * 1024 * 1024)
32 #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK (~(MC_RAM_BASE_ADDR_ALIGNMENT - 1))
33 #define MC_RAM_SIZE_ALIGNMENT (256UL * 1024 * 1024)
35 #define MC_MEM_SIZE_ENV_VAR "mcmemsize"
36 #define MC_BOOT_TIMEOUT_ENV_VAR "mcboottimeout"
37 #define MC_BOOT_ENV_VAR "mcinitcmd"
38 #define MC_DRAM_BLOCK_DEFAULT_SIZE (512UL * 1024 * 1024)
40 DECLARE_GLOBAL_DATA_PTR;
41 static int mc_memset_resv_ram;
42 static struct mc_version mc_ver_info;
43 static int mc_boot_status = -1;
44 static int mc_dpl_applied = -1;
45 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
46 static int mc_aiop_applied = -1;
48 struct fsl_mc_io *root_mc_io = NULL;
49 struct fsl_mc_io *dflt_mc_io = NULL; /* child container */
50 uint16_t root_dprc_handle = 0;
51 uint16_t dflt_dprc_handle = 0;
53 struct fsl_dpbp_obj *dflt_dpbp = NULL;
54 struct fsl_dpio_obj *dflt_dpio = NULL;
55 struct fsl_dpni_obj *dflt_dpni = NULL;
56 static u64 mc_lazy_dpl_addr;
57 static u32 dpsparser_obj_id;
58 static u16 dpsparser_handle;
59 static char *mc_err_msg_apply_spb[] = MC_ERROR_MSG_APPLY_SPB;
62 void dump_ram_words(const char *title, void *addr)
65 uint32_t *words = addr;
67 printf("Dumping beginning of %s (%p):\n", title, addr);
68 for (i = 0; i < 16; i++)
69 printf("%#x ", words[i]);
74 void dump_mc_ccsr_regs(struct mc_ccsr_registers __iomem *mc_ccsr_regs)
76 printf("MC CCSR registers:\n"
86 mc_ccsr_regs->reg_gcr1,
87 mc_ccsr_regs->reg_gsr,
88 mc_ccsr_regs->reg_sicbalr,
89 mc_ccsr_regs->reg_sicbahr,
90 mc_ccsr_regs->reg_sicapr,
91 mc_ccsr_regs->reg_mcfbalr,
92 mc_ccsr_regs->reg_mcfbahr,
93 mc_ccsr_regs->reg_mcfapr,
94 mc_ccsr_regs->reg_psr);
98 #define dump_ram_words(title, addr)
99 #define dump_mc_ccsr_regs(mc_ccsr_regs)
104 * Copying MC firmware or DPL image to DDR
106 static int mc_copy_image(const char *title,
107 u64 image_addr, u32 image_size, u64 mc_ram_addr)
109 debug("%s copied to address %p\n", title, (void *)mc_ram_addr);
110 memcpy((void *)mc_ram_addr, (void *)image_addr, image_size);
111 flush_dcache_range(mc_ram_addr, mc_ram_addr + image_size);
115 #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
117 * MC firmware FIT image parser checks if the image is in FIT
118 * format, verifies integrity of the image and calculates
119 * raw image address and size values.
120 * Returns 0 on success and a negative errno on error.
123 int parse_mc_firmware_fit_image(u64 mc_fw_addr,
124 const void **raw_image_addr,
125 size_t *raw_image_size)
132 const char *uname = "firmware";
134 fit_hdr = (void *)mc_fw_addr;
136 /* Check if Image is in FIT format */
137 format = genimg_get_format(fit_hdr);
139 if (format != IMAGE_FORMAT_FIT) {
140 printf("fsl-mc: ERR: Bad firmware image (not a FIT image)\n");
144 if (!fit_check_format(fit_hdr)) {
145 printf("fsl-mc: ERR: Bad firmware image (bad FIT header)\n");
149 node_offset = fit_image_get_node(fit_hdr, uname);
151 if (node_offset < 0) {
152 printf("fsl-mc: ERR: Bad firmware image (missing subimage)\n");
156 /* Verify MC firmware image */
157 if (!(fit_image_verify(fit_hdr, node_offset))) {
158 printf("fsl-mc: ERR: Bad firmware image (bad CRC)\n");
162 /* Get address and size of raw image */
163 fit_image_get_data(fit_hdr, node_offset, &data, &size);
165 *raw_image_addr = data;
166 *raw_image_size = size;
172 #define MC_DT_INCREASE_SIZE 64
179 static int mc_fixup_mac_addr(void *blob, int nodeoffset,
181 const char *propname, struct udevice *eth_dev,
183 const char *propname, struct eth_device *eth_dev,
185 enum mc_fixup_type type)
188 struct eth_pdata *plat = dev_get_platdata(eth_dev);
189 unsigned char *enetaddr = plat->enetaddr;
190 int eth_index = eth_dev->seq;
192 unsigned char *enetaddr = eth_dev->enetaddr;
193 int eth_index = eth_dev->index;
195 int err = 0, len = 0, size, i;
196 unsigned char env_enetaddr[ARP_HLEN];
197 unsigned int enetaddr_32[ARP_HLEN];
202 /* DPL likes its addresses on 32 * ARP_HLEN bits */
203 for (i = 0; i < ARP_HLEN; i++)
204 enetaddr_32[i] = cpu_to_fdt32(enetaddr[i]);
206 len = sizeof(enetaddr_32);
214 /* MAC address property present */
215 if (fdt_get_property(blob, nodeoffset, propname, NULL)) {
216 /* u-boot MAC addr randomly assigned - leave the present one */
217 if (!eth_env_get_enetaddr_by_index("eth", eth_index,
221 size = MC_DT_INCREASE_SIZE + strlen(propname) + len;
222 /* make room for mac address property */
223 err = fdt_increase_size(blob, size);
225 printf("fdt_increase_size: err=%s\n",
231 err = fdt_setprop(blob, nodeoffset, propname, val, len);
233 printf("fdt_setprop: err=%s\n", fdt_strerror(err));
240 #define is_dpni(s) (s != NULL ? !strncmp(s, "dpni@", 5) : 0)
242 const char *dpl_get_connection_endpoint(void *blob, char *endpoint)
244 int connoffset = fdt_path_offset(blob, "/connections"), off;
247 for (off = fdt_first_subnode(blob, connoffset);
249 off = fdt_next_subnode(blob, off)) {
250 s1 = fdt_stringlist_get(blob, off, "endpoint1", 0, NULL);
251 s2 = fdt_stringlist_get(blob, off, "endpoint2", 0, NULL);
256 if (strcmp(endpoint, s1) == 0)
259 if (strcmp(endpoint, s2) == 0)
266 static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id,
268 struct udevice *eth_dev)
270 struct eth_device *eth_dev)
273 int objoff = fdt_path_offset(blob, "/objects");
274 int dpmacoff = -1, dpnioff = -1;
275 const char *endpoint;
279 sprintf(mac_name, "dpmac@%d", dpmac_id);
280 dpmacoff = fdt_subnode_offset(blob, objoff, mac_name);
282 /* dpmac not defined in DPL, so skip it. */
285 err = mc_fixup_mac_addr(blob, dpmacoff, "mac_addr", eth_dev,
288 printf("Error fixing up dpmac mac_addr in DPL\n");
292 /* now we need to figure out if there is any
293 * DPNI connected to this MAC, so we walk the
296 endpoint = dpl_get_connection_endpoint(blob, mac_name);
297 if (!is_dpni(endpoint))
300 /* let's see if we can fixup the DPNI as well */
301 dpnioff = fdt_subnode_offset(blob, objoff, endpoint);
303 /* DPNI not defined in DPL in the objects area */
306 return mc_fixup_mac_addr(blob, dpnioff, "mac_addr", eth_dev,
310 void fdt_fixup_mc_ddr(u64 *base, u64 *size)
312 u64 mc_size = mc_get_dram_block_size();
314 if (mc_size < MC_DRAM_BLOCK_DEFAULT_SIZE) {
315 *base = mc_get_dram_addr() + mc_size;
316 *size = MC_DRAM_BLOCK_DEFAULT_SIZE - mc_size;
320 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
327 /* find fsl-mc node */
328 offset = fdt_path_offset(blob, "/soc/fsl-mc");
330 offset = fdt_path_offset(blob, "/fsl-mc");
332 printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n",
337 prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp);
339 debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n",
344 iommu_map[0] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
345 iommu_map[1] = *++prop;
346 iommu_map[2] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
347 iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END -
348 FSL_DPAA2_STREAM_ID_START + 1);
350 fdt_setprop_inplace(blob, offset, "iommu-map",
351 iommu_map, sizeof(iommu_map));
354 static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
356 struct udevice *eth_dev)
358 struct eth_device *eth_dev)
361 int nodeoffset = fdt_path_offset(blob, "/board_info/ports"), noff;
364 const char link_type_mode[] = "MAC_LINK_TYPE_FIXED";
366 sprintf(mac_name, "mac@%d", dpmac_id);
368 /* node not found - create it */
369 noff = fdt_subnode_offset(blob, nodeoffset, (const char *)mac_name);
371 err = fdt_increase_size(blob, 200);
373 printf("fdt_increase_size: err=%s\n",
378 noff = fdt_add_subnode(blob, nodeoffset, mac_name);
380 printf("fdt_add_subnode: err=%s\n",
385 /* add default property of fixed link */
386 err = fdt_appendprop_string(blob, noff,
387 "link_type", link_type_mode);
389 printf("fdt_appendprop_string: err=%s\n",
395 return mc_fixup_mac_addr(blob, noff, "port_mac_address", eth_dev,
399 static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)
401 int i, err = 0, ret = 0;
403 #define ETH_NAME_LEN 20
404 struct udevice *eth_dev;
406 struct eth_device *eth_dev;
408 char ethname[ETH_NAME_LEN];
410 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
411 /* port not enabled */
412 if (wriop_is_enabled_dpmac(i) != 1)
415 snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i,
416 phy_interface_strings[wriop_get_enet_if(i)]);
418 eth_dev = eth_get_dev_by_name(ethname);
424 err = mc_fixup_dpl_mac_addr(blob, i, eth_dev);
427 err = mc_fixup_dpc_mac_addr(blob, i, eth_dev);
434 printf("fsl-mc: ERROR fixing mac address for %s\n",
442 static int mc_fixup_dpc(u64 dpc_addr)
444 void *blob = (void *)dpc_addr;
445 int nodeoffset, err = 0;
447 /* delete any existing ICID pools */
448 nodeoffset = fdt_path_offset(blob, "/resources/icid_pools");
449 if (fdt_del_node(blob, nodeoffset) < 0)
450 printf("\nfsl-mc: WARNING: could not delete ICID pool\n");
453 nodeoffset = fdt_path_offset(blob, "/resources");
454 if (nodeoffset < 0) {
455 printf("\nfsl-mc: ERROR: DPC is missing /resources\n");
458 nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pools");
459 nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pool@0");
460 do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0",
461 "base_icid", FSL_DPAA2_STREAM_ID_START, 1);
462 do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0",
464 FSL_DPAA2_STREAM_ID_END -
465 FSL_DPAA2_STREAM_ID_START + 1, 1);
467 /* fixup MAC addresses for dpmac ports */
468 nodeoffset = fdt_path_offset(blob, "/board_info/ports");
472 err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPC);
475 flush_dcache_range(dpc_addr, dpc_addr + fdt_totalsize(blob));
480 static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr)
483 #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR
489 #ifdef CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET
490 BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET & 0x3) != 0 ||
491 CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET > 0xffffffff);
493 mc_dpc_offset = CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET;
495 #error "CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET not defined"
499 * Load the MC DPC blob in the MC private DRAM block:
501 #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR
502 printf("MC DPC is preloaded to %#llx\n", mc_ram_addr + mc_dpc_offset);
505 * Get address and size of the DPC blob stored in flash:
507 dpc_fdt_hdr = (void *)mc_dpc_addr;
509 error = fdt_check_header(dpc_fdt_hdr);
512 * Don't return with error here, since the MC firmware can
513 * still boot without a DPC
515 printf("\nfsl-mc: WARNING: No DPC image found");
519 dpc_size = fdt_totalsize(dpc_fdt_hdr);
520 if (dpc_size > CONFIG_SYS_LS_MC_DPC_MAX_LENGTH) {
521 printf("\nfsl-mc: ERROR: Bad DPC image (too large: %d)\n",
526 mc_copy_image("MC DPC blob",
527 (u64)dpc_fdt_hdr, dpc_size, mc_ram_addr + mc_dpc_offset);
528 #endif /* not defined CONFIG_SYS_LS_MC_DPC_IN_DDR */
530 if (mc_fixup_dpc(mc_ram_addr + mc_dpc_offset))
533 dump_ram_words("DPC", (void *)(mc_ram_addr + mc_dpc_offset));
538 static int mc_fixup_dpl(u64 dpl_addr)
540 void *blob = (void *)dpl_addr;
541 u32 ver = fdt_getprop_u32_default(blob, "/", "dpl-version", 0);
544 /* The DPL fixup for mac addresses is only relevant
550 err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPL);
551 flush_dcache_range(dpl_addr, dpl_addr + fdt_totalsize(blob));
556 static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr)
559 #ifndef CONFIG_SYS_LS_MC_DPL_IN_DDR
565 #ifdef CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET
566 BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET & 0x3) != 0 ||
567 CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET > 0xffffffff);
569 mc_dpl_offset = CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET;
571 #error "CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET not defined"
575 * Load the MC DPL blob in the MC private DRAM block:
577 #ifdef CONFIG_SYS_LS_MC_DPL_IN_DDR
578 printf("MC DPL is preloaded to %#llx\n", mc_ram_addr + mc_dpl_offset);
581 * Get address and size of the DPL blob stored in flash:
583 dpl_fdt_hdr = (void *)mc_dpl_addr;
585 error = fdt_check_header(dpl_fdt_hdr);
587 printf("\nfsl-mc: ERROR: Bad DPL image (bad header)\n");
591 dpl_size = fdt_totalsize(dpl_fdt_hdr);
592 if (dpl_size > CONFIG_SYS_LS_MC_DPL_MAX_LENGTH) {
593 printf("\nfsl-mc: ERROR: Bad DPL image (too large: %d)\n",
598 mc_copy_image("MC DPL blob",
599 (u64)dpl_fdt_hdr, dpl_size, mc_ram_addr + mc_dpl_offset);
600 #endif /* not defined CONFIG_SYS_LS_MC_DPL_IN_DDR */
602 if (mc_fixup_dpl(mc_ram_addr + mc_dpl_offset))
604 dump_ram_words("DPL", (void *)(mc_ram_addr + mc_dpl_offset));
609 * Return the MC boot timeout value in milliseconds
611 static unsigned long get_mc_boot_timeout_ms(void)
613 unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
615 char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR);
617 if (timeout_ms_env_var) {
618 timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10);
619 if (timeout_ms == 0) {
620 printf("fsl-mc: WARNING: Invalid value for \'"
621 MC_BOOT_TIMEOUT_ENV_VAR
622 "\' environment variable: %lu\n",
625 timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
632 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
634 __weak bool soc_has_aiop(void)
639 static int load_mc_aiop_img(u64 aiop_fw_addr)
641 u64 mc_ram_addr = mc_get_dram_addr();
642 #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR
646 /* Check if AIOP is available */
650 * Load the MC AIOP image in the MC private DRAM block:
653 #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR
654 printf("MC AIOP is preloaded to %#llx\n", mc_ram_addr +
655 CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET);
657 aiop_img = (void *)aiop_fw_addr;
658 mc_copy_image("MC AIOP image",
659 (u64)aiop_img, CONFIG_SYS_LS_MC_AIOP_IMG_MAX_LENGTH,
660 mc_ram_addr + CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET);
668 static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr)
671 u32 mc_fw_boot_status;
672 unsigned long timeout_ms = get_mc_boot_timeout_ms();
673 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
676 assert(timeout_ms > 0);
678 udelay(1000); /* throttle polling */
679 reg_gsr = in_le32(&mc_ccsr_regs->reg_gsr);
680 mc_fw_boot_status = (reg_gsr & GSR_FS_MASK);
681 if (mc_fw_boot_status & 0x1)
689 if (timeout_ms == 0) {
690 printf("ERROR: timeout\n");
692 /* TODO: Get an error status from an MC CCSR register */
696 if (mc_fw_boot_status != 0x1) {
698 * TODO: Identify critical errors from the GSR register's FS
699 * field and for those errors, set error to -ENODEV or other
700 * appropriate errno, so that the status property is set to
701 * failure in the fsl,dprc device tree node.
703 printf("WARNING: Firmware returned an error (GSR: %#x)\n",
710 *final_reg_gsr = reg_gsr;
714 int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
718 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
719 u64 mc_ram_addr = mc_get_dram_addr();
722 #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
723 const void *raw_image_addr;
724 size_t raw_image_size = 0;
726 u8 mc_ram_num_256mb_blocks;
727 size_t mc_ram_size = mc_get_dram_block_size();
729 mc_ram_num_256mb_blocks = mc_ram_size / MC_RAM_SIZE_ALIGNMENT;
731 if (mc_ram_num_256mb_blocks >= 0xff) {
733 printf("fsl-mc: ERROR: invalid MC private RAM size (%lu)\n",
739 * To support 128 MB DDR Size for MC
741 if (mc_ram_num_256mb_blocks == 0)
742 mc_ram_num_256mb_blocks = 0xFF;
745 * Management Complex cores should be held at reset out of POR.
746 * U-Boot should be the first software to touch MC. To be safe,
747 * we reset all cores again by setting GCR1 to 0. It doesn't do
748 * anything if they are held at reset. After we setup the firmware
749 * we kick off MC by deasserting the reset bit for core 0, and
750 * deasserting the reset bits for Command Portal Managers.
751 * The stop bits are not touched here. They are used to stop the
752 * cores when they are active. Setting stop bits doesn't stop the
753 * cores from fetching instructions when they are released from
756 out_le32(&mc_ccsr_regs->reg_gcr1, 0);
759 #ifdef CONFIG_SYS_LS_MC_FW_IN_DDR
760 printf("MC firmware is preloaded to %#llx\n", mc_ram_addr);
762 error = parse_mc_firmware_fit_image(mc_fw_addr, &raw_image_addr,
767 * Load the MC FW at the beginning of the MC private DRAM block:
769 mc_copy_image("MC Firmware",
770 (u64)raw_image_addr, raw_image_size, mc_ram_addr);
772 dump_ram_words("firmware", (void *)mc_ram_addr);
774 error = load_mc_dpc(mc_ram_addr, mc_ram_size, mc_dpc_addr);
778 debug("mc_ccsr_regs %p\n", mc_ccsr_regs);
779 dump_mc_ccsr_regs(mc_ccsr_regs);
782 * Tell MC what is the address range of the DRAM block assigned to it:
784 if (mc_ram_num_256mb_blocks < 0xFF) {
785 reg_mcfbalr = (u32)mc_ram_addr |
786 (mc_ram_num_256mb_blocks - 1);
788 reg_mcfbalr = (u32)mc_ram_addr |
789 (mc_ram_num_256mb_blocks);
792 out_le32(&mc_ccsr_regs->reg_mcfbalr, reg_mcfbalr);
793 out_le32(&mc_ccsr_regs->reg_mcfbahr,
794 (u32)(mc_ram_addr >> 32));
795 out_le32(&mc_ccsr_regs->reg_mcfapr, FSL_BYPASS_AMQ);
798 * Tell the MC that we want delayed DPL deployment.
800 out_le32(&mc_ccsr_regs->reg_gsr, 0xDD00);
802 printf("\nfsl-mc: Booting Management Complex ... ");
805 * Deassert reset and release MC core 0 to run
807 out_le32(&mc_ccsr_regs->reg_gcr1, GCR1_P1_DE_RST | GCR1_M_ALL_DE_RST);
808 error = wait_for_mc(true, ®_gsr);
813 * TODO: need to obtain the portal_id for the root container from the
819 * Initialize the global default MC portal
820 * And check that the MC firmware is responding portal commands:
822 root_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
824 printf(" No memory: calloc() failed\n");
828 root_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(portal_id);
829 debug("Checking access to MC portal of root DPRC container (portal_id %d, portal physical addr %p)\n",
830 portal_id, root_mc_io->mmio_regs);
832 error = mc_get_version(root_mc_io, MC_CMD_NO_FLAGS, &mc_ver_info);
834 printf("fsl-mc: ERROR: Firmware version check failed (error: %d)\n",
839 printf("fsl-mc: Management Complex booted (version: %d.%d.%d, boot status: %#x)\n",
840 mc_ver_info.major, mc_ver_info.minor, mc_ver_info.revision,
841 reg_gsr & GSR_FS_MASK);
845 mc_boot_status = error;
852 int mc_apply_dpl(u64 mc_dpl_addr)
854 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
857 u64 mc_ram_addr = mc_get_dram_addr();
858 size_t mc_ram_size = mc_get_dram_block_size();
863 error = load_mc_dpl(mc_ram_addr, mc_ram_size, mc_dpl_addr);
868 * Tell the MC to deploy the DPL:
870 out_le32(&mc_ccsr_regs->reg_gsr, 0x0);
871 printf("fsl-mc: Deploying data path layout ... ");
872 error = wait_for_mc(false, ®_gsr);
880 int get_mc_boot_status(void)
882 return mc_boot_status;
885 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
886 int get_aiop_apply_status(void)
888 return mc_aiop_applied;
892 int get_dpl_apply_status(void)
894 return mc_dpl_applied;
897 int is_lazy_dpl_addr_valid(void)
899 return !!mc_lazy_dpl_addr;
903 * Return the MC address of private DRAM block.
904 * As per MC design document, MC initial base address
905 * should be least significant 512MB address of MC private
906 * memory, i.e. address should point to end address masked
907 * with 512MB offset in private DRAM block.
909 u64 mc_get_dram_addr(void)
911 size_t mc_ram_size = mc_get_dram_block_size();
913 if (!mc_memset_resv_ram || (get_mc_boot_status() < 0)) {
914 mc_memset_resv_ram = 1;
915 memset((void *)gd->arch.resv_ram, 0, mc_ram_size);
918 return (gd->arch.resv_ram + mc_ram_size - 1) &
919 MC_RAM_BASE_ADDR_ALIGNMENT_MASK;
923 * Return the actual size of the MC private DRAM block.
925 unsigned long mc_get_dram_block_size(void)
927 unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE;
929 char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR);
931 if (dram_block_size_env_var) {
932 dram_block_size = simple_strtoul(dram_block_size_env_var, NULL,
935 if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) {
936 printf("fsl-mc: WARNING: Invalid value for \'"
938 "\' environment variable: %lu\n",
941 dram_block_size = MC_DRAM_BLOCK_DEFAULT_SIZE;
945 return dram_block_size;
948 int fsl_mc_ldpaa_init(bd_t *bis)
952 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++)
953 if (wriop_is_enabled_dpmac(i) == 1)
954 ldpaa_eth_init(i, wriop_get_enet_if(i));
958 static int dprc_version_check(struct fsl_mc_io *mc_io, uint16_t handle)
961 uint16_t major_ver, minor_ver;
963 error = dprc_get_api_version(mc_io, 0,
967 printf("dprc_get_api_version() failed: %d\n", error);
971 if (major_ver < DPRC_VER_MAJOR || (major_ver == DPRC_VER_MAJOR &&
972 minor_ver < DPRC_VER_MINOR)) {
973 printf("DPRC version mismatch found %u.%u,",
974 major_ver, minor_ver);
975 printf("supported version is %u.%u\n",
976 DPRC_VER_MAJOR, DPRC_VER_MINOR);
982 static int dpio_init(void)
984 struct qbman_swp_desc p_des;
985 struct dpio_attr attr;
986 struct dpio_cfg dpio_cfg;
988 uint16_t major_ver, minor_ver;
990 dflt_dpio = (struct fsl_dpio_obj *)calloc(
991 sizeof(struct fsl_dpio_obj), 1);
993 printf("No memory: calloc() failed\n");
997 dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL;
998 dpio_cfg.num_priorities = 8;
1000 err = dpio_create(dflt_mc_io,
1004 &dflt_dpio->dpio_id);
1006 printf("dpio_create() failed: %d\n", err);
1011 err = dpio_get_api_version(dflt_mc_io, 0,
1015 printf("dpio_get_api_version() failed: %d\n", err);
1016 goto err_get_api_ver;
1019 if (major_ver < DPIO_VER_MAJOR || (major_ver == DPIO_VER_MAJOR &&
1020 minor_ver < DPIO_VER_MINOR)) {
1021 printf("DPRC version mismatch found %u.%u,",
1026 err = dpio_open(dflt_mc_io,
1029 &dflt_dpio->dpio_handle);
1031 printf("dpio_open() failed\n");
1035 memset(&attr, 0, sizeof(struct dpio_attr));
1036 err = dpio_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1037 dflt_dpio->dpio_handle, &attr);
1039 printf("dpio_get_attributes() failed: %d\n", err);
1043 if (dflt_dpio->dpio_id != attr.id) {
1044 printf("dnpi object id and attribute id are not same\n");
1045 goto err_attr_not_same;
1049 printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
1051 err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1053 printf("dpio_enable() failed %d\n", err);
1054 goto err_get_enable;
1056 debug("ce_offset=0x%llx, ci_offset=0x%llx, portalid=%d, prios=%d\n",
1057 attr.qbman_portal_ce_offset,
1058 attr.qbman_portal_ci_offset,
1059 attr.qbman_portal_id,
1060 attr.num_priorities);
1062 p_des.cena_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR
1063 + attr.qbman_portal_ce_offset);
1064 p_des.cinh_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR
1065 + attr.qbman_portal_ci_offset);
1067 dflt_dpio->sw_portal = qbman_swp_init(&p_des);
1068 if (dflt_dpio->sw_portal == NULL) {
1069 printf("qbman_swp_init() failed\n");
1070 goto err_get_swp_init;
1075 dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1079 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1082 dpio_destroy(dflt_mc_io,
1085 dflt_dpio->dpio_id);
1092 static int dpio_exit(void)
1096 err = dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1098 printf("dpio_disable() failed: %d\n", err);
1102 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1104 printf("dpio_close() failed: %d\n", err);
1108 err = dpio_destroy(dflt_mc_io,
1111 dflt_dpio->dpio_id);
1113 printf("dpio_destroy() failed: %d\n", err);
1118 printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id);
1129 static int dprc_init(void)
1131 int err, child_portal_id, container_id;
1132 struct dprc_cfg cfg;
1133 uint64_t mc_portal_offset;
1135 /* Open root container */
1136 err = dprc_get_container_id(root_mc_io, MC_CMD_NO_FLAGS, &container_id);
1138 printf("dprc_get_container_id(): Root failed: %d\n", err);
1139 goto err_root_container_id;
1143 printf("Root container id = %d\n", container_id);
1145 err = dprc_open(root_mc_io, MC_CMD_NO_FLAGS, container_id,
1148 printf("dprc_open(): Root Container failed: %d\n", err);
1152 if (!root_dprc_handle) {
1153 printf("dprc_open(): Root Container Handle is not valid\n");
1157 err = dprc_version_check(root_mc_io, root_dprc_handle);
1159 printf("dprc_version_check() failed: %d\n", err);
1163 memset(&cfg, 0, sizeof(struct dprc_cfg));
1164 cfg.options = DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED |
1165 DPRC_CFG_OPT_OBJ_CREATE_ALLOWED |
1166 DPRC_CFG_OPT_ALLOC_ALLOWED;
1167 cfg.icid = DPRC_GET_ICID_FROM_POOL;
1168 cfg.portal_id = DPRC_GET_PORTAL_ID_FROM_POOL;
1169 err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS,
1175 printf("dprc_create_container() failed: %d\n", err);
1179 dflt_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
1182 printf(" No memory: calloc() failed\n");
1186 child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset);
1187 dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id);
1190 printf("MC portal of child DPRC container: %d, physical addr %p)\n",
1191 child_dprc_id, dflt_mc_io->mmio_regs);
1194 err = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, child_dprc_id,
1197 printf("dprc_open(): Child container failed: %d\n", err);
1198 goto err_child_open;
1201 if (!dflt_dprc_handle) {
1202 printf("dprc_open(): Child container Handle is not valid\n");
1203 goto err_child_open;
1210 dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS,
1211 root_dprc_handle, child_dprc_id);
1213 dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle);
1215 err_root_container_id:
1219 static int dprc_exit(void)
1223 err = dprc_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dprc_handle);
1225 printf("dprc_close(): Child failed: %d\n", err);
1229 err = dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS,
1230 root_dprc_handle, child_dprc_id);
1232 printf("dprc_destroy_container() failed: %d\n", err);
1236 err = dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle);
1238 printf("dprc_close(): Root failed: %d\n", err);
1254 static int dpbp_init(void)
1257 struct dpbp_attr dpbp_attr;
1258 struct dpbp_cfg dpbp_cfg;
1259 uint16_t major_ver, minor_ver;
1261 dflt_dpbp = (struct fsl_dpbp_obj *)calloc(
1262 sizeof(struct fsl_dpbp_obj), 1);
1264 printf("No memory: calloc() failed\n");
1269 dpbp_cfg.options = 512;
1271 err = dpbp_create(dflt_mc_io,
1275 &dflt_dpbp->dpbp_id);
1279 printf("dpbp_create() failed: %d\n", err);
1283 err = dpbp_get_api_version(dflt_mc_io, 0,
1287 printf("dpbp_get_api_version() failed: %d\n", err);
1288 goto err_get_api_ver;
1291 if (major_ver < DPBP_VER_MAJOR || (major_ver == DPBP_VER_MAJOR &&
1292 minor_ver < DPBP_VER_MINOR)) {
1293 printf("DPBP version mismatch found %u.%u,",
1294 major_ver, minor_ver);
1295 printf("supported version is %u.%u\n",
1296 DPBP_VER_MAJOR, DPBP_VER_MINOR);
1299 err = dpbp_open(dflt_mc_io,
1302 &dflt_dpbp->dpbp_handle);
1304 printf("dpbp_open() failed\n");
1308 memset(&dpbp_attr, 0, sizeof(struct dpbp_attr));
1309 err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1310 dflt_dpbp->dpbp_handle,
1313 printf("dpbp_get_attributes() failed: %d\n", err);
1317 if (dflt_dpbp->dpbp_id != dpbp_attr.id) {
1318 printf("dpbp object id and attribute id are not same\n");
1319 goto err_attr_not_same;
1323 printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id);
1326 err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1328 printf("dpbp_close() failed: %d\n", err);
1336 dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1337 dpbp_destroy(dflt_mc_io,
1340 dflt_dpbp->dpbp_id);
1350 static int dpbp_exit(void)
1354 err = dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
1355 dflt_dpbp->dpbp_id);
1357 printf("dpbp_destroy() failed: %d\n", err);
1362 printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
1373 static int dpni_init(void)
1376 uint8_t cfg_buf[256] = {0};
1377 struct dpni_cfg dpni_cfg;
1378 uint16_t major_ver, minor_ver;
1380 dflt_dpni = (struct fsl_dpni_obj *)calloc(
1381 sizeof(struct fsl_dpni_obj), 1);
1383 printf("No memory: calloc() failed\n");
1388 memset(&dpni_cfg, 0, sizeof(dpni_cfg));
1389 err = dpni_prepare_cfg(&dpni_cfg, &cfg_buf[0]);
1392 printf("dpni_prepare_cfg() failed: %d\n", err);
1393 goto err_prepare_cfg;
1396 err = dpni_create(dflt_mc_io,
1400 &dflt_dpni->dpni_id);
1403 printf("dpni create() failed: %d\n", err);
1407 err = dpni_get_api_version(dflt_mc_io, 0,
1411 printf("dpni_get_api_version() failed: %d\n", err);
1412 goto err_get_version;
1415 if (major_ver < DPNI_VER_MAJOR || (major_ver == DPNI_VER_MAJOR &&
1416 minor_ver < DPNI_VER_MINOR)) {
1417 printf("DPNI version mismatch found %u.%u,",
1418 major_ver, minor_ver);
1419 printf("supported version is %u.%u\n",
1420 DPNI_VER_MAJOR, DPNI_VER_MINOR);
1423 err = dpni_open(dflt_mc_io,
1426 &dflt_dpni->dpni_handle);
1428 printf("dpni_open() failed\n");
1433 printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
1435 err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1437 printf("dpni_close() failed: %d\n", err);
1444 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1447 dpni_destroy(dflt_mc_io,
1450 dflt_dpni->dpni_id);
1458 static int dpni_exit(void)
1462 err = dpni_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
1463 dflt_dpni->dpni_id);
1465 printf("dpni_destroy() failed: %d\n", err);
1470 printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id);
1481 static bool is_dpsparser_supported(void)
1483 /* dpsparser support was first introduced in MC version: 10.12.0 */
1484 if (mc_ver_info.major < 10)
1486 if (mc_ver_info.major == 10)
1487 return (mc_ver_info.minor >= 12);
1491 static int dpsparser_version_check(struct fsl_mc_io *mc_io)
1494 u16 major_ver, minor_ver;
1496 if (!is_dpsparser_supported())
1499 error = dpsparser_get_api_version(mc_io, 0,
1503 printf("dpsparser_get_api_version() failed: %d\n", error);
1507 if (major_ver < DPSPARSER_VER_MAJOR || (major_ver ==
1508 DPSPARSER_VER_MAJOR && minor_ver < DPSPARSER_VER_MINOR)) {
1509 printf("DPSPARSER version mismatch found %u.%u,",
1510 major_ver, minor_ver);
1511 printf("supported version is %u.%u\n",
1512 DPSPARSER_VER_MAJOR, DPSPARSER_VER_MINOR);
1518 static int dpsparser_init(void)
1522 if (!is_dpsparser_supported())
1525 err = dpsparser_create(dflt_mc_io,
1530 printf("dpsparser_create() failed\n");
1532 err = dpsparser_version_check(dflt_mc_io);
1534 printf("dpsparser_version_check() failed: %d\n", err);
1535 goto err_version_check;
1538 err = dpsparser_open(dflt_mc_io,
1542 printf("dpsparser_open() failed: %d\n", err);
1550 dpsparser_destroy(dflt_mc_io,
1552 MC_CMD_NO_FLAGS, dpsparser_obj_id);
1557 #ifdef DPSPARSER_DESTROY
1558 /* TODO: refactoring needed in the future to allow DPSPARSER object destroy
1559 * Workaround: DO NOT destroy DPSPARSER object because it needs to be available
1562 static int dpsparser_exit(void)
1566 if (!is_dpsparser_supported())
1569 dpsparser_close(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle);
1571 printf("dpsparser_close() failed: %d\n", err);
1575 err = dpsparser_destroy(dflt_mc_io, dflt_dprc_handle,
1576 MC_CMD_NO_FLAGS, dpsparser_obj_id);
1578 printf("dpsparser_destroy() failed: %d\n", err);
1588 int mc_apply_spb(u64 mc_spb_addr)
1591 u16 error, err_arr_size;
1594 struct sp_blob_header *sp_blob;
1595 u64 mc_ram_addr = mc_get_dram_addr();
1597 if (!is_dpsparser_supported())
1601 printf("fsl-mc: Invalid Blob address\n");
1605 #ifdef CONFIG_MC_DRAM_SPB_OFFSET
1606 mc_spb_offset = CONFIG_MC_DRAM_SPB_OFFSET;
1608 #error "CONFIG_MC_DRAM_SPB_OFFSET not defined"
1611 // Read blob header and get size of SPB blob
1612 sp_blob = (struct sp_blob_header *)mc_spb_addr;
1613 spb_size = le32_to_cpu(sp_blob->length);
1614 if (spb_size > CONFIG_MC_SPB_MAX_SIZE) {
1615 printf("\nfsl-mc: ERROR: Bad SPB image (too large: %d)\n",
1620 mc_copy_image("MC SP Blob", mc_spb_addr, spb_size,
1621 mc_ram_addr + mc_spb_offset);
1623 //Invoke MC command to apply SPB blob
1624 printf("fsl-mc: Applying soft parser blob... ");
1625 err = dpsparser_apply_spb(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle,
1626 mc_spb_offset, &error);
1631 printf("SUCCESS\n");
1633 printf("FAILED with error code = %d:\n", error);
1634 err_arr_size = (u16)ARRAY_SIZE(mc_err_msg_apply_spb);
1636 if (error > 0 && error < err_arr_size)
1637 printf(mc_err_msg_apply_spb[error]);
1639 printf(MC_ERROR_MSG_SPB_UNKNOWN);
1645 static int mc_init_object(void)
1651 printf("dprc_init() failed: %d\n", err);
1657 printf("dpbp_init() failed: %d\n", err);
1663 printf("dpio_init() failed: %d\n", err);
1669 printf("dpni_init() failed: %d\n", err);
1673 err = dpsparser_init();
1675 printf("dpsparser_init() failed: %d\n", err);
1684 int fsl_mc_ldpaa_exit(bd_t *bd)
1687 bool is_dpl_apply_status = false;
1688 bool mc_boot_status = false;
1690 if (bd && mc_lazy_dpl_addr && !fsl_mc_ldpaa_exit(NULL)) {
1691 err = mc_apply_dpl(mc_lazy_dpl_addr);
1693 fdt_fixup_board_enet(working_fdt);
1694 mc_lazy_dpl_addr = 0;
1697 if (!get_mc_boot_status())
1698 mc_boot_status = true;
1700 /* MC is not loaded intentionally, So return success. */
1701 if (bd && !mc_boot_status)
1704 /* If DPL is deployed, set is_dpl_apply_status as TRUE. */
1705 if (!get_dpl_apply_status())
1706 is_dpl_apply_status = true;
1709 * For case MC is loaded but DPL is not deployed, return success and
1710 * print message on console. Else FDT fix-up code execution hanged.
1712 if (bd && mc_boot_status && !is_dpl_apply_status) {
1713 printf("fsl-mc: DPL not deployed, DPAA2 ethernet not work\n");
1714 goto mc_obj_cleanup;
1717 if (bd && mc_boot_status && is_dpl_apply_status)
1723 printf("dpbp_exit() failed: %d\n", err);
1729 printf("dpio_exit() failed: %d\n", err);
1735 printf("dpni_exit() failed: %d\n", err);
1741 printf("dprc_exit() failed: %d\n", err);
1750 static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
1757 switch (argv[1][0]) {
1760 u64 mc_fw_addr, mc_dpc_addr;
1761 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
1765 sub_cmd = argv[2][0];
1772 if (get_mc_boot_status() == 0) {
1773 printf("fsl-mc: MC is already booted");
1777 mc_fw_addr = simple_strtoull(argv[3], NULL, 16);
1778 mc_dpc_addr = simple_strtoull(argv[4], NULL,
1781 if (!mc_init(mc_fw_addr, mc_dpc_addr))
1782 err = mc_init_object();
1785 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
1789 if (get_aiop_apply_status() == 0) {
1790 printf("fsl-mc: AIOP FW is already");
1791 printf(" applied\n");
1795 aiop_fw_addr = simple_strtoull(argv[3], NULL,
1798 /* if SoC doesn't have AIOP, err = -ENODEV */
1799 err = load_mc_aiop_img(aiop_fw_addr);
1801 printf("fsl-mc: AIOP FW applied\n");
1805 printf("Invalid option: %s\n", argv[2]);
1820 if (get_dpl_apply_status() == 0) {
1821 printf("fsl-mc: DPL already applied\n");
1825 mc_dpl_addr = simple_strtoull(argv[3], NULL, 16);
1827 if (get_mc_boot_status() != 0) {
1828 printf("fsl-mc: Deploying data path layout ..");
1829 printf("ERROR (MC is not booted)\n");
1834 * We will do the actual dpaa exit and dpl apply
1835 * later from announce_and_cleanup().
1837 mc_lazy_dpl_addr = mc_dpl_addr;
1849 sub_cmd = argv[2][0];
1854 if (get_dpl_apply_status() == 0) {
1855 printf("fsl-mc: DPL already applied\n");
1858 if (get_mc_boot_status() != 0) {
1859 printf("fsl-mc: Deploying data path layout ..");
1860 printf("ERROR (MC is not booted)\n");
1864 mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
1866 /* The user wants DPL applied now */
1867 if (!fsl_mc_ldpaa_exit(NULL))
1868 err = mc_apply_dpl(mc_apply_addr);
1872 if (!is_dpsparser_supported()) {
1873 printf("fsl-mc: apply spb command .. ");
1874 printf("ERROR: requires at least MC 10.12.0\n");
1877 if (get_mc_boot_status() != 0) {
1878 printf("fsl-mc: Deploying Soft Parser Blob...");
1879 printf("ERROR (MC is not booted)\n");
1883 mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
1885 /* Apply spb (Soft Parser Blob) */
1886 err = mc_apply_spb(mc_apply_addr);
1890 printf("Invalid option: %s\n", argv[2]);
1896 printf("Invalid option: %s\n", argv[1]);
1902 return CMD_RET_USAGE;
1906 fsl_mc, CONFIG_SYS_MAXARGS, 1, do_fsl_mc,
1907 "DPAA2 command to manage Management Complex (MC)",
1908 "start mc [FW_addr] [DPC_addr] - Start Management Complex\n"
1909 "fsl_mc apply DPL [DPL_addr] - Apply DPL file\n"
1910 "fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
1911 "fsl_mc apply spb [spb_addr] - Apply SPB Soft Parser Blob\n"
1912 "fsl_mc start aiop [FW_addr] - Start AIOP\n"
1915 void mc_env_boot(void)
1917 #if defined(CONFIG_FSL_MC_ENET)
1918 char *mc_boot_env_var;
1919 /* The MC may only be initialized in the reset PHY function
1920 * because otherwise U-Boot has not yet set up all the MAC
1921 * address info properly. Without MAC addresses, the MC code
1922 * can not properly initialize the DPC.
1924 mc_boot_env_var = env_get(MC_BOOT_ENV_VAR);
1925 if (mc_boot_env_var)
1926 run_command_list(mc_boot_env_var, -1, 0);
1927 #endif /* CONFIG_FSL_MC_ENET */