1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
4 * Copyright 2017-2018 NXP
13 #include <linux/bug.h>
15 #include <linux/libfdt.h>
17 #include <fdt_support.h>
18 #include <fsl-mc/fsl_mc.h>
19 #include <fsl-mc/fsl_mc_sys.h>
20 #include <fsl-mc/fsl_mc_private.h>
21 #include <fsl-mc/fsl_dpmng.h>
22 #include <fsl-mc/fsl_dprc.h>
23 #include <fsl-mc/fsl_dpio.h>
24 #include <fsl-mc/fsl_dpni.h>
25 #include <fsl-mc/fsl_dpsparser.h>
26 #include <fsl-mc/fsl_qbman_portal.h>
27 #include <fsl-mc/ldpaa_wriop.h>
29 #define MC_RAM_BASE_ADDR_ALIGNMENT (512UL * 1024 * 1024)
30 #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK (~(MC_RAM_BASE_ADDR_ALIGNMENT - 1))
31 #define MC_RAM_SIZE_ALIGNMENT (256UL * 1024 * 1024)
33 #define MC_MEM_SIZE_ENV_VAR "mcmemsize"
34 #define MC_BOOT_TIMEOUT_ENV_VAR "mcboottimeout"
35 #define MC_BOOT_ENV_VAR "mcinitcmd"
36 #define MC_DRAM_BLOCK_DEFAULT_SIZE (512UL * 1024 * 1024)
38 DECLARE_GLOBAL_DATA_PTR;
39 static int mc_memset_resv_ram;
40 static struct mc_version mc_ver_info;
41 static int mc_boot_status = -1;
42 static int mc_dpl_applied = -1;
43 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
44 static int mc_aiop_applied = -1;
46 struct fsl_mc_io *root_mc_io = NULL;
47 struct fsl_mc_io *dflt_mc_io = NULL; /* child container */
48 uint16_t root_dprc_handle = 0;
49 uint16_t dflt_dprc_handle = 0;
51 struct fsl_dpbp_obj *dflt_dpbp = NULL;
52 struct fsl_dpio_obj *dflt_dpio = NULL;
53 struct fsl_dpni_obj *dflt_dpni = NULL;
54 static u64 mc_lazy_dpl_addr;
55 static u32 dpsparser_obj_id;
56 static u16 dpsparser_handle;
57 static char *mc_err_msg_apply_spb[] = MC_ERROR_MSG_APPLY_SPB;
60 void dump_ram_words(const char *title, void *addr)
63 uint32_t *words = addr;
65 printf("Dumping beginning of %s (%p):\n", title, addr);
66 for (i = 0; i < 16; i++)
67 printf("%#x ", words[i]);
72 void dump_mc_ccsr_regs(struct mc_ccsr_registers __iomem *mc_ccsr_regs)
74 printf("MC CCSR registers:\n"
84 mc_ccsr_regs->reg_gcr1,
85 mc_ccsr_regs->reg_gsr,
86 mc_ccsr_regs->reg_sicbalr,
87 mc_ccsr_regs->reg_sicbahr,
88 mc_ccsr_regs->reg_sicapr,
89 mc_ccsr_regs->reg_mcfbalr,
90 mc_ccsr_regs->reg_mcfbahr,
91 mc_ccsr_regs->reg_mcfapr,
92 mc_ccsr_regs->reg_psr);
96 #define dump_ram_words(title, addr)
97 #define dump_mc_ccsr_regs(mc_ccsr_regs)
102 * Copying MC firmware or DPL image to DDR
104 static int mc_copy_image(const char *title,
105 u64 image_addr, u32 image_size, u64 mc_ram_addr)
107 debug("%s copied to address %p\n", title, (void *)mc_ram_addr);
108 memcpy((void *)mc_ram_addr, (void *)image_addr, image_size);
109 flush_dcache_range(mc_ram_addr, mc_ram_addr + image_size);
113 #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
115 * MC firmware FIT image parser checks if the image is in FIT
116 * format, verifies integrity of the image and calculates
117 * raw image address and size values.
118 * Returns 0 on success and a negative errno on error.
121 int parse_mc_firmware_fit_image(u64 mc_fw_addr,
122 const void **raw_image_addr,
123 size_t *raw_image_size)
130 const char *uname = "firmware";
132 fit_hdr = (void *)mc_fw_addr;
134 /* Check if Image is in FIT format */
135 format = genimg_get_format(fit_hdr);
137 if (format != IMAGE_FORMAT_FIT) {
138 printf("fsl-mc: ERR: Bad firmware image (not a FIT image)\n");
142 if (!fit_check_format(fit_hdr)) {
143 printf("fsl-mc: ERR: Bad firmware image (bad FIT header)\n");
147 node_offset = fit_image_get_node(fit_hdr, uname);
149 if (node_offset < 0) {
150 printf("fsl-mc: ERR: Bad firmware image (missing subimage)\n");
154 /* Verify MC firmware image */
155 if (!(fit_image_verify(fit_hdr, node_offset))) {
156 printf("fsl-mc: ERR: Bad firmware image (bad CRC)\n");
160 /* Get address and size of raw image */
161 fit_image_get_data(fit_hdr, node_offset, &data, &size);
163 *raw_image_addr = data;
164 *raw_image_size = size;
170 #define MC_DT_INCREASE_SIZE 64
177 static int mc_fixup_mac_addr(void *blob, int nodeoffset,
179 const char *propname, struct udevice *eth_dev,
181 const char *propname, struct eth_device *eth_dev,
183 enum mc_fixup_type type)
186 struct eth_pdata *plat = dev_get_platdata(eth_dev);
187 unsigned char *enetaddr = plat->enetaddr;
188 int eth_index = eth_dev->seq;
190 unsigned char *enetaddr = eth_dev->enetaddr;
191 int eth_index = eth_dev->index;
193 int err = 0, len = 0, size, i;
194 unsigned char env_enetaddr[ARP_HLEN];
195 unsigned int enetaddr_32[ARP_HLEN];
200 /* DPL likes its addresses on 32 * ARP_HLEN bits */
201 for (i = 0; i < ARP_HLEN; i++)
202 enetaddr_32[i] = cpu_to_fdt32(enetaddr[i]);
204 len = sizeof(enetaddr_32);
212 /* MAC address property present */
213 if (fdt_get_property(blob, nodeoffset, propname, NULL)) {
214 /* u-boot MAC addr randomly assigned - leave the present one */
215 if (!eth_env_get_enetaddr_by_index("eth", eth_index,
219 size = MC_DT_INCREASE_SIZE + strlen(propname) + len;
220 /* make room for mac address property */
221 err = fdt_increase_size(blob, size);
223 printf("fdt_increase_size: err=%s\n",
229 err = fdt_setprop(blob, nodeoffset, propname, val, len);
231 printf("fdt_setprop: err=%s\n", fdt_strerror(err));
238 #define is_dpni(s) (s != NULL ? !strncmp(s, "dpni@", 5) : 0)
240 const char *dpl_get_connection_endpoint(void *blob, char *endpoint)
242 int connoffset = fdt_path_offset(blob, "/connections"), off;
245 for (off = fdt_first_subnode(blob, connoffset);
247 off = fdt_next_subnode(blob, off)) {
248 s1 = fdt_stringlist_get(blob, off, "endpoint1", 0, NULL);
249 s2 = fdt_stringlist_get(blob, off, "endpoint2", 0, NULL);
254 if (strcmp(endpoint, s1) == 0)
257 if (strcmp(endpoint, s2) == 0)
264 static int mc_fixup_dpl_mac_addr(void *blob, int dpmac_id,
266 struct udevice *eth_dev)
268 struct eth_device *eth_dev)
271 int objoff = fdt_path_offset(blob, "/objects");
272 int dpmacoff = -1, dpnioff = -1;
273 const char *endpoint;
277 sprintf(mac_name, "dpmac@%d", dpmac_id);
278 dpmacoff = fdt_subnode_offset(blob, objoff, mac_name);
280 /* dpmac not defined in DPL, so skip it. */
283 err = mc_fixup_mac_addr(blob, dpmacoff, "mac_addr", eth_dev,
286 printf("Error fixing up dpmac mac_addr in DPL\n");
290 /* now we need to figure out if there is any
291 * DPNI connected to this MAC, so we walk the
294 endpoint = dpl_get_connection_endpoint(blob, mac_name);
295 if (!is_dpni(endpoint))
298 /* let's see if we can fixup the DPNI as well */
299 dpnioff = fdt_subnode_offset(blob, objoff, endpoint);
301 /* DPNI not defined in DPL in the objects area */
304 return mc_fixup_mac_addr(blob, dpnioff, "mac_addr", eth_dev,
308 void fdt_fixup_mc_ddr(u64 *base, u64 *size)
310 u64 mc_size = mc_get_dram_block_size();
312 if (mc_size < MC_DRAM_BLOCK_DEFAULT_SIZE) {
313 *base = mc_get_dram_addr() + mc_size;
314 *size = MC_DRAM_BLOCK_DEFAULT_SIZE - mc_size;
318 void fdt_fsl_mc_fixup_iommu_map_entry(void *blob)
325 /* find fsl-mc node */
326 offset = fdt_path_offset(blob, "/soc/fsl-mc");
328 offset = fdt_path_offset(blob, "/fsl-mc");
330 printf("%s: fsl-mc: ERR: fsl-mc node not found in DT, err %d\n",
335 prop = fdt_getprop_w(blob, offset, "iommu-map", &lenp);
337 debug("%s: fsl-mc: ERR: missing iommu-map in fsl-mc bus node\n",
342 iommu_map[0] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
343 iommu_map[1] = *++prop;
344 iommu_map[2] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_START);
345 iommu_map[3] = cpu_to_fdt32(FSL_DPAA2_STREAM_ID_END -
346 FSL_DPAA2_STREAM_ID_START + 1);
348 fdt_setprop_inplace(blob, offset, "iommu-map",
349 iommu_map, sizeof(iommu_map));
352 static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
354 struct udevice *eth_dev)
356 struct eth_device *eth_dev)
359 int nodeoffset = fdt_path_offset(blob, "/board_info/ports"), noff;
362 const char link_type_mode[] = "MAC_LINK_TYPE_FIXED";
364 sprintf(mac_name, "mac@%d", dpmac_id);
366 /* node not found - create it */
367 noff = fdt_subnode_offset(blob, nodeoffset, (const char *)mac_name);
369 err = fdt_increase_size(blob, 200);
371 printf("fdt_increase_size: err=%s\n",
376 noff = fdt_add_subnode(blob, nodeoffset, mac_name);
378 printf("fdt_add_subnode: err=%s\n",
383 /* add default property of fixed link */
384 err = fdt_appendprop_string(blob, noff,
385 "link_type", link_type_mode);
387 printf("fdt_appendprop_string: err=%s\n",
393 return mc_fixup_mac_addr(blob, noff, "port_mac_address", eth_dev,
397 static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)
399 int i, err = 0, ret = 0;
401 #define ETH_NAME_LEN 20
402 struct udevice *eth_dev;
404 struct eth_device *eth_dev;
406 char ethname[ETH_NAME_LEN];
408 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
409 /* port not enabled */
410 if (wriop_is_enabled_dpmac(i) != 1)
413 snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i,
414 phy_interface_strings[wriop_get_enet_if(i)]);
416 eth_dev = eth_get_dev_by_name(ethname);
422 err = mc_fixup_dpl_mac_addr(blob, i, eth_dev);
425 err = mc_fixup_dpc_mac_addr(blob, i, eth_dev);
432 printf("fsl-mc: ERROR fixing mac address for %s\n",
440 static int mc_fixup_dpc(u64 dpc_addr)
442 void *blob = (void *)dpc_addr;
443 int nodeoffset, err = 0;
445 /* delete any existing ICID pools */
446 nodeoffset = fdt_path_offset(blob, "/resources/icid_pools");
447 if (fdt_del_node(blob, nodeoffset) < 0)
448 printf("\nfsl-mc: WARNING: could not delete ICID pool\n");
451 nodeoffset = fdt_path_offset(blob, "/resources");
452 if (nodeoffset < 0) {
453 printf("\nfsl-mc: ERROR: DPC is missing /resources\n");
456 nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pools");
457 nodeoffset = fdt_add_subnode(blob, nodeoffset, "icid_pool@0");
458 do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0",
459 "base_icid", FSL_DPAA2_STREAM_ID_START, 1);
460 do_fixup_by_path_u32(blob, "/resources/icid_pools/icid_pool@0",
462 FSL_DPAA2_STREAM_ID_END -
463 FSL_DPAA2_STREAM_ID_START + 1, 1);
465 /* fixup MAC addresses for dpmac ports */
466 nodeoffset = fdt_path_offset(blob, "/board_info/ports");
470 err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPC);
473 flush_dcache_range(dpc_addr, dpc_addr + fdt_totalsize(blob));
478 static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr)
481 #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR
487 #ifdef CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET
488 BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET & 0x3) != 0 ||
489 CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET > 0xffffffff);
491 mc_dpc_offset = CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET;
493 #error "CONFIG_SYS_LS_MC_DRAM_DPC_OFFSET not defined"
497 * Load the MC DPC blob in the MC private DRAM block:
499 #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR
500 printf("MC DPC is preloaded to %#llx\n", mc_ram_addr + mc_dpc_offset);
503 * Get address and size of the DPC blob stored in flash:
505 dpc_fdt_hdr = (void *)mc_dpc_addr;
507 error = fdt_check_header(dpc_fdt_hdr);
510 * Don't return with error here, since the MC firmware can
511 * still boot without a DPC
513 printf("\nfsl-mc: WARNING: No DPC image found");
517 dpc_size = fdt_totalsize(dpc_fdt_hdr);
518 if (dpc_size > CONFIG_SYS_LS_MC_DPC_MAX_LENGTH) {
519 printf("\nfsl-mc: ERROR: Bad DPC image (too large: %d)\n",
524 mc_copy_image("MC DPC blob",
525 (u64)dpc_fdt_hdr, dpc_size, mc_ram_addr + mc_dpc_offset);
526 #endif /* not defined CONFIG_SYS_LS_MC_DPC_IN_DDR */
528 if (mc_fixup_dpc(mc_ram_addr + mc_dpc_offset))
531 dump_ram_words("DPC", (void *)(mc_ram_addr + mc_dpc_offset));
536 static int mc_fixup_dpl(u64 dpl_addr)
538 void *blob = (void *)dpl_addr;
539 u32 ver = fdt_getprop_u32_default(blob, "/", "dpl-version", 0);
542 /* The DPL fixup for mac addresses is only relevant
548 err = mc_fixup_mac_addrs(blob, MC_FIXUP_DPL);
549 flush_dcache_range(dpl_addr, dpl_addr + fdt_totalsize(blob));
554 static int load_mc_dpl(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpl_addr)
557 #ifndef CONFIG_SYS_LS_MC_DPL_IN_DDR
563 #ifdef CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET
564 BUILD_BUG_ON((CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET & 0x3) != 0 ||
565 CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET > 0xffffffff);
567 mc_dpl_offset = CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET;
569 #error "CONFIG_SYS_LS_MC_DRAM_DPL_OFFSET not defined"
573 * Load the MC DPL blob in the MC private DRAM block:
575 #ifdef CONFIG_SYS_LS_MC_DPL_IN_DDR
576 printf("MC DPL is preloaded to %#llx\n", mc_ram_addr + mc_dpl_offset);
579 * Get address and size of the DPL blob stored in flash:
581 dpl_fdt_hdr = (void *)mc_dpl_addr;
583 error = fdt_check_header(dpl_fdt_hdr);
585 printf("\nfsl-mc: ERROR: Bad DPL image (bad header)\n");
589 dpl_size = fdt_totalsize(dpl_fdt_hdr);
590 if (dpl_size > CONFIG_SYS_LS_MC_DPL_MAX_LENGTH) {
591 printf("\nfsl-mc: ERROR: Bad DPL image (too large: %d)\n",
596 mc_copy_image("MC DPL blob",
597 (u64)dpl_fdt_hdr, dpl_size, mc_ram_addr + mc_dpl_offset);
598 #endif /* not defined CONFIG_SYS_LS_MC_DPL_IN_DDR */
600 if (mc_fixup_dpl(mc_ram_addr + mc_dpl_offset))
602 dump_ram_words("DPL", (void *)(mc_ram_addr + mc_dpl_offset));
607 * Return the MC boot timeout value in milliseconds
609 static unsigned long get_mc_boot_timeout_ms(void)
611 unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
613 char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR);
615 if (timeout_ms_env_var) {
616 timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10);
617 if (timeout_ms == 0) {
618 printf("fsl-mc: WARNING: Invalid value for \'"
619 MC_BOOT_TIMEOUT_ENV_VAR
620 "\' environment variable: %lu\n",
623 timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
630 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
632 __weak bool soc_has_aiop(void)
637 static int load_mc_aiop_img(u64 aiop_fw_addr)
639 u64 mc_ram_addr = mc_get_dram_addr();
640 #ifndef CONFIG_SYS_LS_MC_DPC_IN_DDR
644 /* Check if AIOP is available */
648 * Load the MC AIOP image in the MC private DRAM block:
651 #ifdef CONFIG_SYS_LS_MC_DPC_IN_DDR
652 printf("MC AIOP is preloaded to %#llx\n", mc_ram_addr +
653 CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET);
655 aiop_img = (void *)aiop_fw_addr;
656 mc_copy_image("MC AIOP image",
657 (u64)aiop_img, CONFIG_SYS_LS_MC_AIOP_IMG_MAX_LENGTH,
658 mc_ram_addr + CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET);
666 static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr)
669 u32 mc_fw_boot_status;
670 unsigned long timeout_ms = get_mc_boot_timeout_ms();
671 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
674 assert(timeout_ms > 0);
676 udelay(1000); /* throttle polling */
677 reg_gsr = in_le32(&mc_ccsr_regs->reg_gsr);
678 mc_fw_boot_status = (reg_gsr & GSR_FS_MASK);
679 if (mc_fw_boot_status & 0x1)
687 if (timeout_ms == 0) {
688 printf("ERROR: timeout\n");
690 /* TODO: Get an error status from an MC CCSR register */
694 if (mc_fw_boot_status != 0x1) {
696 * TODO: Identify critical errors from the GSR register's FS
697 * field and for those errors, set error to -ENODEV or other
698 * appropriate errno, so that the status property is set to
699 * failure in the fsl,dprc device tree node.
701 printf("WARNING: Firmware returned an error (GSR: %#x)\n",
708 *final_reg_gsr = reg_gsr;
712 int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
716 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
717 u64 mc_ram_addr = mc_get_dram_addr();
720 #ifndef CONFIG_SYS_LS_MC_FW_IN_DDR
721 const void *raw_image_addr;
722 size_t raw_image_size = 0;
724 u8 mc_ram_num_256mb_blocks;
725 size_t mc_ram_size = mc_get_dram_block_size();
727 mc_ram_num_256mb_blocks = mc_ram_size / MC_RAM_SIZE_ALIGNMENT;
729 if (mc_ram_num_256mb_blocks >= 0xff) {
731 printf("fsl-mc: ERROR: invalid MC private RAM size (%lu)\n",
737 * To support 128 MB DDR Size for MC
739 if (mc_ram_num_256mb_blocks == 0)
740 mc_ram_num_256mb_blocks = 0xFF;
743 * Management Complex cores should be held at reset out of POR.
744 * U-Boot should be the first software to touch MC. To be safe,
745 * we reset all cores again by setting GCR1 to 0. It doesn't do
746 * anything if they are held at reset. After we setup the firmware
747 * we kick off MC by deasserting the reset bit for core 0, and
748 * deasserting the reset bits for Command Portal Managers.
749 * The stop bits are not touched here. They are used to stop the
750 * cores when they are active. Setting stop bits doesn't stop the
751 * cores from fetching instructions when they are released from
754 out_le32(&mc_ccsr_regs->reg_gcr1, 0);
757 #ifdef CONFIG_SYS_LS_MC_FW_IN_DDR
758 printf("MC firmware is preloaded to %#llx\n", mc_ram_addr);
760 error = parse_mc_firmware_fit_image(mc_fw_addr, &raw_image_addr,
765 * Load the MC FW at the beginning of the MC private DRAM block:
767 mc_copy_image("MC Firmware",
768 (u64)raw_image_addr, raw_image_size, mc_ram_addr);
770 dump_ram_words("firmware", (void *)mc_ram_addr);
772 error = load_mc_dpc(mc_ram_addr, mc_ram_size, mc_dpc_addr);
776 debug("mc_ccsr_regs %p\n", mc_ccsr_regs);
777 dump_mc_ccsr_regs(mc_ccsr_regs);
780 * Tell MC what is the address range of the DRAM block assigned to it:
782 if (mc_ram_num_256mb_blocks < 0xFF) {
783 reg_mcfbalr = (u32)mc_ram_addr |
784 (mc_ram_num_256mb_blocks - 1);
786 reg_mcfbalr = (u32)mc_ram_addr |
787 (mc_ram_num_256mb_blocks);
790 out_le32(&mc_ccsr_regs->reg_mcfbalr, reg_mcfbalr);
791 out_le32(&mc_ccsr_regs->reg_mcfbahr,
792 (u32)(mc_ram_addr >> 32));
793 out_le32(&mc_ccsr_regs->reg_mcfapr, FSL_BYPASS_AMQ);
796 * Tell the MC that we want delayed DPL deployment.
798 out_le32(&mc_ccsr_regs->reg_gsr, 0xDD00);
800 printf("\nfsl-mc: Booting Management Complex ... ");
803 * Deassert reset and release MC core 0 to run
805 out_le32(&mc_ccsr_regs->reg_gcr1, GCR1_P1_DE_RST | GCR1_M_ALL_DE_RST);
806 error = wait_for_mc(true, ®_gsr);
811 * TODO: need to obtain the portal_id for the root container from the
817 * Initialize the global default MC portal
818 * And check that the MC firmware is responding portal commands:
820 root_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
822 printf(" No memory: calloc() failed\n");
826 root_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(portal_id);
827 debug("Checking access to MC portal of root DPRC container (portal_id %d, portal physical addr %p)\n",
828 portal_id, root_mc_io->mmio_regs);
830 error = mc_get_version(root_mc_io, MC_CMD_NO_FLAGS, &mc_ver_info);
832 printf("fsl-mc: ERROR: Firmware version check failed (error: %d)\n",
837 printf("fsl-mc: Management Complex booted (version: %d.%d.%d, boot status: %#x)\n",
838 mc_ver_info.major, mc_ver_info.minor, mc_ver_info.revision,
839 reg_gsr & GSR_FS_MASK);
843 mc_boot_status = error;
850 int mc_apply_dpl(u64 mc_dpl_addr)
852 struct mc_ccsr_registers __iomem *mc_ccsr_regs = MC_CCSR_BASE_ADDR;
855 u64 mc_ram_addr = mc_get_dram_addr();
856 size_t mc_ram_size = mc_get_dram_block_size();
861 error = load_mc_dpl(mc_ram_addr, mc_ram_size, mc_dpl_addr);
866 * Tell the MC to deploy the DPL:
868 out_le32(&mc_ccsr_regs->reg_gsr, 0x0);
869 printf("fsl-mc: Deploying data path layout ... ");
870 error = wait_for_mc(false, ®_gsr);
878 int get_mc_boot_status(void)
880 return mc_boot_status;
883 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
884 int get_aiop_apply_status(void)
886 return mc_aiop_applied;
890 int get_dpl_apply_status(void)
892 return mc_dpl_applied;
895 int is_lazy_dpl_addr_valid(void)
897 return !!mc_lazy_dpl_addr;
901 * Return the MC address of private DRAM block.
902 * As per MC design document, MC initial base address
903 * should be least significant 512MB address of MC private
904 * memory, i.e. address should point to end address masked
905 * with 512MB offset in private DRAM block.
907 u64 mc_get_dram_addr(void)
909 size_t mc_ram_size = mc_get_dram_block_size();
911 if (!mc_memset_resv_ram || (get_mc_boot_status() < 0)) {
912 mc_memset_resv_ram = 1;
913 memset((void *)gd->arch.resv_ram, 0, mc_ram_size);
916 return (gd->arch.resv_ram + mc_ram_size - 1) &
917 MC_RAM_BASE_ADDR_ALIGNMENT_MASK;
921 * Return the actual size of the MC private DRAM block.
923 unsigned long mc_get_dram_block_size(void)
925 unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE;
927 char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR);
929 if (dram_block_size_env_var) {
930 dram_block_size = simple_strtoul(dram_block_size_env_var, NULL,
933 if (dram_block_size < CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE) {
934 printf("fsl-mc: WARNING: Invalid value for \'"
936 "\' environment variable: %lu\n",
939 dram_block_size = MC_DRAM_BLOCK_DEFAULT_SIZE;
943 return dram_block_size;
946 int fsl_mc_ldpaa_init(bd_t *bis)
950 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++)
951 if (wriop_is_enabled_dpmac(i) == 1)
952 ldpaa_eth_init(i, wriop_get_enet_if(i));
956 static int dprc_version_check(struct fsl_mc_io *mc_io, uint16_t handle)
959 uint16_t major_ver, minor_ver;
961 error = dprc_get_api_version(mc_io, 0,
965 printf("dprc_get_api_version() failed: %d\n", error);
969 if (major_ver < DPRC_VER_MAJOR || (major_ver == DPRC_VER_MAJOR &&
970 minor_ver < DPRC_VER_MINOR)) {
971 printf("DPRC version mismatch found %u.%u,",
972 major_ver, minor_ver);
973 printf("supported version is %u.%u\n",
974 DPRC_VER_MAJOR, DPRC_VER_MINOR);
980 static int dpio_init(void)
982 struct qbman_swp_desc p_des;
983 struct dpio_attr attr;
984 struct dpio_cfg dpio_cfg;
986 uint16_t major_ver, minor_ver;
988 dflt_dpio = (struct fsl_dpio_obj *)calloc(
989 sizeof(struct fsl_dpio_obj), 1);
991 printf("No memory: calloc() failed\n");
995 dpio_cfg.channel_mode = DPIO_LOCAL_CHANNEL;
996 dpio_cfg.num_priorities = 8;
998 err = dpio_create(dflt_mc_io,
1002 &dflt_dpio->dpio_id);
1004 printf("dpio_create() failed: %d\n", err);
1009 err = dpio_get_api_version(dflt_mc_io, 0,
1013 printf("dpio_get_api_version() failed: %d\n", err);
1014 goto err_get_api_ver;
1017 if (major_ver < DPIO_VER_MAJOR || (major_ver == DPIO_VER_MAJOR &&
1018 minor_ver < DPIO_VER_MINOR)) {
1019 printf("DPRC version mismatch found %u.%u,",
1024 err = dpio_open(dflt_mc_io,
1027 &dflt_dpio->dpio_handle);
1029 printf("dpio_open() failed\n");
1033 memset(&attr, 0, sizeof(struct dpio_attr));
1034 err = dpio_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1035 dflt_dpio->dpio_handle, &attr);
1037 printf("dpio_get_attributes() failed: %d\n", err);
1041 if (dflt_dpio->dpio_id != attr.id) {
1042 printf("dnpi object id and attribute id are not same\n");
1043 goto err_attr_not_same;
1047 printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
1049 err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1051 printf("dpio_enable() failed %d\n", err);
1052 goto err_get_enable;
1054 debug("ce_offset=0x%llx, ci_offset=0x%llx, portalid=%d, prios=%d\n",
1055 attr.qbman_portal_ce_offset,
1056 attr.qbman_portal_ci_offset,
1057 attr.qbman_portal_id,
1058 attr.num_priorities);
1060 p_des.cena_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR
1061 + attr.qbman_portal_ce_offset);
1062 p_des.cinh_bar = (void *)(SOC_QBMAN_PORTALS_BASE_ADDR
1063 + attr.qbman_portal_ci_offset);
1065 dflt_dpio->sw_portal = qbman_swp_init(&p_des);
1066 if (dflt_dpio->sw_portal == NULL) {
1067 printf("qbman_swp_init() failed\n");
1068 goto err_get_swp_init;
1073 dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1077 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1080 dpio_destroy(dflt_mc_io,
1083 dflt_dpio->dpio_id);
1090 static int dpio_exit(void)
1094 err = dpio_disable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1096 printf("dpio_disable() failed: %d\n", err);
1100 dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
1102 printf("dpio_close() failed: %d\n", err);
1106 err = dpio_destroy(dflt_mc_io,
1109 dflt_dpio->dpio_id);
1111 printf("dpio_destroy() failed: %d\n", err);
1116 printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id);
1127 static int dprc_init(void)
1129 int err, child_portal_id, container_id;
1130 struct dprc_cfg cfg;
1131 uint64_t mc_portal_offset;
1133 /* Open root container */
1134 err = dprc_get_container_id(root_mc_io, MC_CMD_NO_FLAGS, &container_id);
1136 printf("dprc_get_container_id(): Root failed: %d\n", err);
1137 goto err_root_container_id;
1141 printf("Root container id = %d\n", container_id);
1143 err = dprc_open(root_mc_io, MC_CMD_NO_FLAGS, container_id,
1146 printf("dprc_open(): Root Container failed: %d\n", err);
1150 if (!root_dprc_handle) {
1151 printf("dprc_open(): Root Container Handle is not valid\n");
1155 err = dprc_version_check(root_mc_io, root_dprc_handle);
1157 printf("dprc_version_check() failed: %d\n", err);
1161 memset(&cfg, 0, sizeof(struct dprc_cfg));
1162 cfg.options = DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED |
1163 DPRC_CFG_OPT_OBJ_CREATE_ALLOWED |
1164 DPRC_CFG_OPT_ALLOC_ALLOWED;
1165 cfg.icid = DPRC_GET_ICID_FROM_POOL;
1166 cfg.portal_id = DPRC_GET_PORTAL_ID_FROM_POOL;
1167 err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS,
1173 printf("dprc_create_container() failed: %d\n", err);
1177 dflt_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
1180 printf(" No memory: calloc() failed\n");
1184 child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset);
1185 dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id);
1188 printf("MC portal of child DPRC container: %d, physical addr %p)\n",
1189 child_dprc_id, dflt_mc_io->mmio_regs);
1192 err = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, child_dprc_id,
1195 printf("dprc_open(): Child container failed: %d\n", err);
1196 goto err_child_open;
1199 if (!dflt_dprc_handle) {
1200 printf("dprc_open(): Child container Handle is not valid\n");
1201 goto err_child_open;
1208 dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS,
1209 root_dprc_handle, child_dprc_id);
1211 dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle);
1213 err_root_container_id:
1217 static int dprc_exit(void)
1221 err = dprc_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dprc_handle);
1223 printf("dprc_close(): Child failed: %d\n", err);
1227 err = dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS,
1228 root_dprc_handle, child_dprc_id);
1230 printf("dprc_destroy_container() failed: %d\n", err);
1234 err = dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle);
1236 printf("dprc_close(): Root failed: %d\n", err);
1252 static int dpbp_init(void)
1255 struct dpbp_attr dpbp_attr;
1256 struct dpbp_cfg dpbp_cfg;
1257 uint16_t major_ver, minor_ver;
1259 dflt_dpbp = (struct fsl_dpbp_obj *)calloc(
1260 sizeof(struct fsl_dpbp_obj), 1);
1262 printf("No memory: calloc() failed\n");
1267 dpbp_cfg.options = 512;
1269 err = dpbp_create(dflt_mc_io,
1273 &dflt_dpbp->dpbp_id);
1277 printf("dpbp_create() failed: %d\n", err);
1281 err = dpbp_get_api_version(dflt_mc_io, 0,
1285 printf("dpbp_get_api_version() failed: %d\n", err);
1286 goto err_get_api_ver;
1289 if (major_ver < DPBP_VER_MAJOR || (major_ver == DPBP_VER_MAJOR &&
1290 minor_ver < DPBP_VER_MINOR)) {
1291 printf("DPBP version mismatch found %u.%u,",
1292 major_ver, minor_ver);
1293 printf("supported version is %u.%u\n",
1294 DPBP_VER_MAJOR, DPBP_VER_MINOR);
1297 err = dpbp_open(dflt_mc_io,
1300 &dflt_dpbp->dpbp_handle);
1302 printf("dpbp_open() failed\n");
1306 memset(&dpbp_attr, 0, sizeof(struct dpbp_attr));
1307 err = dpbp_get_attributes(dflt_mc_io, MC_CMD_NO_FLAGS,
1308 dflt_dpbp->dpbp_handle,
1311 printf("dpbp_get_attributes() failed: %d\n", err);
1315 if (dflt_dpbp->dpbp_id != dpbp_attr.id) {
1316 printf("dpbp object id and attribute id are not same\n");
1317 goto err_attr_not_same;
1321 printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id);
1324 err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1326 printf("dpbp_close() failed: %d\n", err);
1334 dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
1335 dpbp_destroy(dflt_mc_io,
1338 dflt_dpbp->dpbp_id);
1348 static int dpbp_exit(void)
1352 err = dpbp_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
1353 dflt_dpbp->dpbp_id);
1355 printf("dpbp_destroy() failed: %d\n", err);
1360 printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
1371 static int dpni_init(void)
1374 uint8_t cfg_buf[256] = {0};
1375 struct dpni_cfg dpni_cfg;
1376 uint16_t major_ver, minor_ver;
1378 dflt_dpni = (struct fsl_dpni_obj *)calloc(
1379 sizeof(struct fsl_dpni_obj), 1);
1381 printf("No memory: calloc() failed\n");
1386 memset(&dpni_cfg, 0, sizeof(dpni_cfg));
1387 err = dpni_prepare_cfg(&dpni_cfg, &cfg_buf[0]);
1390 printf("dpni_prepare_cfg() failed: %d\n", err);
1391 goto err_prepare_cfg;
1394 err = dpni_create(dflt_mc_io,
1398 &dflt_dpni->dpni_id);
1401 printf("dpni create() failed: %d\n", err);
1405 err = dpni_get_api_version(dflt_mc_io, 0,
1409 printf("dpni_get_api_version() failed: %d\n", err);
1410 goto err_get_version;
1413 if (major_ver < DPNI_VER_MAJOR || (major_ver == DPNI_VER_MAJOR &&
1414 minor_ver < DPNI_VER_MINOR)) {
1415 printf("DPNI version mismatch found %u.%u,",
1416 major_ver, minor_ver);
1417 printf("supported version is %u.%u\n",
1418 DPNI_VER_MAJOR, DPNI_VER_MINOR);
1421 err = dpni_open(dflt_mc_io,
1424 &dflt_dpni->dpni_handle);
1426 printf("dpni_open() failed\n");
1431 printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
1433 err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1435 printf("dpni_close() failed: %d\n", err);
1442 dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
1445 dpni_destroy(dflt_mc_io,
1448 dflt_dpni->dpni_id);
1456 static int dpni_exit(void)
1460 err = dpni_destroy(dflt_mc_io, dflt_dprc_handle, MC_CMD_NO_FLAGS,
1461 dflt_dpni->dpni_id);
1463 printf("dpni_destroy() failed: %d\n", err);
1468 printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id);
1479 static bool is_dpsparser_supported(void)
1481 /* dpsparser support was first introduced in MC version: 10.12.0 */
1482 if (mc_ver_info.major < 10)
1484 if (mc_ver_info.major == 10)
1485 return (mc_ver_info.minor >= 12);
1489 static int dpsparser_version_check(struct fsl_mc_io *mc_io)
1492 u16 major_ver, minor_ver;
1494 if (!is_dpsparser_supported())
1497 error = dpsparser_get_api_version(mc_io, 0,
1501 printf("dpsparser_get_api_version() failed: %d\n", error);
1505 if (major_ver < DPSPARSER_VER_MAJOR || (major_ver ==
1506 DPSPARSER_VER_MAJOR && minor_ver < DPSPARSER_VER_MINOR)) {
1507 printf("DPSPARSER version mismatch found %u.%u,",
1508 major_ver, minor_ver);
1509 printf("supported version is %u.%u\n",
1510 DPSPARSER_VER_MAJOR, DPSPARSER_VER_MINOR);
1516 static int dpsparser_init(void)
1520 if (!is_dpsparser_supported())
1523 err = dpsparser_create(dflt_mc_io,
1528 printf("dpsparser_create() failed\n");
1530 err = dpsparser_version_check(dflt_mc_io);
1532 printf("dpsparser_version_check() failed: %d\n", err);
1533 goto err_version_check;
1536 err = dpsparser_open(dflt_mc_io,
1540 printf("dpsparser_open() failed: %d\n", err);
1548 dpsparser_destroy(dflt_mc_io,
1550 MC_CMD_NO_FLAGS, dpsparser_obj_id);
1555 #ifdef DPSPARSER_DESTROY
1556 /* TODO: refactoring needed in the future to allow DPSPARSER object destroy
1557 * Workaround: DO NOT destroy DPSPARSER object because it needs to be available
1560 static int dpsparser_exit(void)
1564 if (!is_dpsparser_supported())
1567 dpsparser_close(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle);
1569 printf("dpsparser_close() failed: %d\n", err);
1573 err = dpsparser_destroy(dflt_mc_io, dflt_dprc_handle,
1574 MC_CMD_NO_FLAGS, dpsparser_obj_id);
1576 printf("dpsparser_destroy() failed: %d\n", err);
1586 int mc_apply_spb(u64 mc_spb_addr)
1589 u16 error, err_arr_size;
1592 struct sp_blob_header *sp_blob;
1593 u64 mc_ram_addr = mc_get_dram_addr();
1595 if (!is_dpsparser_supported())
1599 printf("fsl-mc: Invalid Blob address\n");
1603 #ifdef CONFIG_MC_DRAM_SPB_OFFSET
1604 mc_spb_offset = CONFIG_MC_DRAM_SPB_OFFSET;
1606 #error "CONFIG_MC_DRAM_SPB_OFFSET not defined"
1609 // Read blob header and get size of SPB blob
1610 sp_blob = (struct sp_blob_header *)mc_spb_addr;
1611 spb_size = le32_to_cpu(sp_blob->length);
1612 if (spb_size > CONFIG_MC_SPB_MAX_SIZE) {
1613 printf("\nfsl-mc: ERROR: Bad SPB image (too large: %d)\n",
1618 mc_copy_image("MC SP Blob", mc_spb_addr, spb_size,
1619 mc_ram_addr + mc_spb_offset);
1621 //Invoke MC command to apply SPB blob
1622 printf("fsl-mc: Applying soft parser blob... ");
1623 err = dpsparser_apply_spb(dflt_mc_io, MC_CMD_NO_FLAGS, dpsparser_handle,
1624 mc_spb_offset, &error);
1629 printf("SUCCESS\n");
1631 printf("FAILED with error code = %d:\n", error);
1632 err_arr_size = (u16)ARRAY_SIZE(mc_err_msg_apply_spb);
1634 if (error > 0 && error < err_arr_size)
1635 printf(mc_err_msg_apply_spb[error]);
1637 printf(MC_ERROR_MSG_SPB_UNKNOWN);
1643 static int mc_init_object(void)
1649 printf("dprc_init() failed: %d\n", err);
1655 printf("dpbp_init() failed: %d\n", err);
1661 printf("dpio_init() failed: %d\n", err);
1667 printf("dpni_init() failed: %d\n", err);
1671 err = dpsparser_init();
1673 printf("dpsparser_init() failed: %d\n", err);
1682 int fsl_mc_ldpaa_exit(bd_t *bd)
1685 bool is_dpl_apply_status = false;
1686 bool mc_boot_status = false;
1688 if (bd && mc_lazy_dpl_addr && !fsl_mc_ldpaa_exit(NULL)) {
1689 err = mc_apply_dpl(mc_lazy_dpl_addr);
1691 fdt_fixup_board_enet(working_fdt);
1692 mc_lazy_dpl_addr = 0;
1695 if (!get_mc_boot_status())
1696 mc_boot_status = true;
1698 /* MC is not loaded intentionally, So return success. */
1699 if (bd && !mc_boot_status)
1702 /* If DPL is deployed, set is_dpl_apply_status as TRUE. */
1703 if (!get_dpl_apply_status())
1704 is_dpl_apply_status = true;
1707 * For case MC is loaded but DPL is not deployed, return success and
1708 * print message on console. Else FDT fix-up code execution hanged.
1710 if (bd && mc_boot_status && !is_dpl_apply_status) {
1711 printf("fsl-mc: DPL not deployed, DPAA2 ethernet not work\n");
1712 goto mc_obj_cleanup;
1715 if (bd && mc_boot_status && is_dpl_apply_status)
1721 printf("dpbp_exit() failed: %d\n", err);
1727 printf("dpio_exit() failed: %d\n", err);
1733 printf("dpni_exit() failed: %d\n", err);
1739 printf("dprc_exit() failed: %d\n", err);
1748 static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
1755 switch (argv[1][0]) {
1758 u64 mc_fw_addr, mc_dpc_addr;
1759 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
1763 sub_cmd = argv[2][0];
1770 if (get_mc_boot_status() == 0) {
1771 printf("fsl-mc: MC is already booted");
1775 mc_fw_addr = simple_strtoull(argv[3], NULL, 16);
1776 mc_dpc_addr = simple_strtoull(argv[4], NULL,
1779 if (!mc_init(mc_fw_addr, mc_dpc_addr))
1780 err = mc_init_object();
1783 #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
1787 if (get_aiop_apply_status() == 0) {
1788 printf("fsl-mc: AIOP FW is already");
1789 printf(" applied\n");
1793 aiop_fw_addr = simple_strtoull(argv[3], NULL,
1796 /* if SoC doesn't have AIOP, err = -ENODEV */
1797 err = load_mc_aiop_img(aiop_fw_addr);
1799 printf("fsl-mc: AIOP FW applied\n");
1803 printf("Invalid option: %s\n", argv[2]);
1818 if (get_dpl_apply_status() == 0) {
1819 printf("fsl-mc: DPL already applied\n");
1823 mc_dpl_addr = simple_strtoull(argv[3], NULL, 16);
1825 if (get_mc_boot_status() != 0) {
1826 printf("fsl-mc: Deploying data path layout ..");
1827 printf("ERROR (MC is not booted)\n");
1832 * We will do the actual dpaa exit and dpl apply
1833 * later from announce_and_cleanup().
1835 mc_lazy_dpl_addr = mc_dpl_addr;
1847 sub_cmd = argv[2][0];
1852 if (get_dpl_apply_status() == 0) {
1853 printf("fsl-mc: DPL already applied\n");
1856 if (get_mc_boot_status() != 0) {
1857 printf("fsl-mc: Deploying data path layout ..");
1858 printf("ERROR (MC is not booted)\n");
1862 mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
1864 /* The user wants DPL applied now */
1865 if (!fsl_mc_ldpaa_exit(NULL))
1866 err = mc_apply_dpl(mc_apply_addr);
1870 if (!is_dpsparser_supported()) {
1871 printf("fsl-mc: apply spb command .. ");
1872 printf("ERROR: requires at least MC 10.12.0\n");
1875 if (get_mc_boot_status() != 0) {
1876 printf("fsl-mc: Deploying Soft Parser Blob...");
1877 printf("ERROR (MC is not booted)\n");
1881 mc_apply_addr = simple_strtoull(argv[3], NULL, 16);
1883 /* Apply spb (Soft Parser Blob) */
1884 err = mc_apply_spb(mc_apply_addr);
1888 printf("Invalid option: %s\n", argv[2]);
1894 printf("Invalid option: %s\n", argv[1]);
1900 return CMD_RET_USAGE;
1904 fsl_mc, CONFIG_SYS_MAXARGS, 1, do_fsl_mc,
1905 "DPAA2 command to manage Management Complex (MC)",
1906 "start mc [FW_addr] [DPC_addr] - Start Management Complex\n"
1907 "fsl_mc apply DPL [DPL_addr] - Apply DPL file\n"
1908 "fsl_mc lazyapply DPL [DPL_addr] - Apply DPL file on exit\n"
1909 "fsl_mc apply spb [spb_addr] - Apply SPB Soft Parser Blob\n"
1910 "fsl_mc start aiop [FW_addr] - Start AIOP\n"
1913 void mc_env_boot(void)
1915 #if defined(CONFIG_FSL_MC_ENET)
1916 char *mc_boot_env_var;
1917 /* The MC may only be initialized in the reset PHY function
1918 * because otherwise U-Boot has not yet set up all the MAC
1919 * address info properly. Without MAC addresses, the MC code
1920 * can not properly initialize the DPC.
1922 mc_boot_env_var = env_get(MC_BOOT_ENV_VAR);
1923 if (mc_boot_env_var)
1924 run_command_list(mc_boot_env_var, -1, 0);
1925 #endif /* CONFIG_FSL_MC_ENET */