static int do_fsl_mc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int err = 0; if (argc < 3) goto usage; switch (argv[1][0]) { case 's': { char sub_cmd; u64 mc_fw_addr, mc_dpc_addr; #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET u64 aiop_fw_addr; #endif sub_cmd = argv[2][0]; switch (sub_cmd) { case 'm': if (argc < 5) goto usage; if (get_mc_boot_status() == 0) { printf("fsl-mc: MC is already booted"); printf("\n"); return err; } mc_fw_addr = simple_strtoull(argv[3], NULL, 16); mc_dpc_addr = simple_strtoull(argv[4], NULL, 16); if (!mc_init(mc_fw_addr, mc_dpc_addr)) err = mc_init_object(); break; #ifdef CONFIG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET case 'a': if (argc < 4) goto usage; if (get_aiop_apply_status() == 0) { printf("fsl-mc: AIOP FW is already"); printf(" applied\n"); return err; } aiop_fw_addr = simple_strtoull(argv[3], NULL, 16); err = load_mc_aiop_img(aiop_fw_addr); if (!err) printf("fsl-mc: AIOP FW applied\n"); break; #endif default: printf("Invalid option: %s\n", argv[2]); goto usage; break; } } break; case 'a': { u64 mc_dpl_addr; if (argc < 4) goto usage; if (get_dpl_apply_status() == 0) { printf("fsl-mc: DPL already applied\n"); return err; } mc_dpl_addr = simple_strtoull(argv[3], NULL, 16); if (get_mc_boot_status() != 0) { printf("fsl-mc: Deploying data path layout .."); printf("ERROR (MC is not booted)\n"); return -ENODEV; } if (!fsl_mc_ldpaa_exit(NULL)) err = mc_apply_dpl(mc_dpl_addr); break; } default: printf("Invalid option: %s\n", argv[1]); goto usage; break; } return err; usage: return CMD_RET_USAGE; }
int fsl_mc_ldpaa_exit(bd_t *bd) { int err = 0; bool is_dpl_apply_status = false; bool mc_boot_status = false; if (bd && mc_lazy_dpl_addr && !fsl_mc_ldpaa_exit(NULL)) { err = mc_apply_dpl(mc_lazy_dpl_addr); if (!err) fdt_fixup_board_enet(working_fdt); mc_lazy_dpl_addr = 0; } if (!get_mc_boot_status()) mc_boot_status = true; /* MC is not loaded intentionally, So return success. */ if (bd && !mc_boot_status) return 0; /* If DPL is deployed, set is_dpl_apply_status as TRUE. */ if (!get_dpl_apply_status()) is_dpl_apply_status = true; /* * For case MC is loaded but DPL is not deployed, return success and * print message on console. Else FDT fix-up code execution hanged. */ if (bd && mc_boot_status && !is_dpl_apply_status) { printf("fsl-mc: DPL not deployed, DPAA2 ethernet not work\n"); goto mc_obj_cleanup; } if (bd && mc_boot_status && is_dpl_apply_status) return 0; mc_obj_cleanup: err = dpbp_exit(); if (err < 0) { printf("dpbp_exit() failed: %d\n", err); goto err; } err = dpio_exit(); if (err < 0) { printf("dpio_exit() failed: %d\n", err); goto err; } err = dpni_exit(); if (err < 0) { printf("dpni_exit() failed: %d\n", err); goto err; } err = dprc_exit(); if (err < 0) { printf("dprc_exit() failed: %d\n", err); goto err; } return 0; err: return err; }