int fsl_mc_ldpaa_init(bd_t *bis) { int i, error = 0; int dprc_opened = 0, container_id; int num_child_objects = 0; error = mc_init(); if (error < 0) goto error; error = dprc_get_container_id(dflt_mc_io, MC_CMD_NO_FLAGS, &container_id); if (error < 0) { printf("dprc_get_container_id() failed: %d\n", error); goto error; } debug("fsl-mc: Container id=0x%x\n", container_id); error = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, container_id, &dflt_dprc_handle); if (error < 0) { printf("dprc_open() failed: %d\n", error); goto error; } dprc_opened = true; error = dprc_get_obj_count(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dprc_handle, &num_child_objects); if (error < 0) { printf("dprc_get_obj_count() failed: %d\n", error); goto error; } debug("Total child in container %d = %d\n", container_id, num_child_objects); if (num_child_objects != 0) { /* * Discover objects currently in the DPRC container in the MC: */ for (i = 0; i < num_child_objects; i++) error = dprc_scan_container_obj(dflt_dprc_handle, "dpbp", i); for (i = 0; i < num_child_objects; i++) error = dprc_scan_container_obj(dflt_dprc_handle, "dpio", i); for (i = 0; i < num_child_objects; i++) error = dprc_scan_container_obj(dflt_dprc_handle, "dpni", i); } error: if (dprc_opened) dprc_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dprc_handle); return error; }
static int dprc_init(void) { int err, child_portal_id, container_id; struct dprc_cfg cfg; uint64_t mc_portal_offset; /* Open root container */ err = dprc_get_container_id(root_mc_io, MC_CMD_NO_FLAGS, &container_id); if (err < 0) { printf("dprc_get_container_id(): Root failed: %d\n", err); goto err_root_container_id; } #ifdef DEBUG printf("Root container id = %d\n", container_id); #endif err = dprc_open(root_mc_io, MC_CMD_NO_FLAGS, container_id, &root_dprc_handle); if (err < 0) { printf("dprc_open(): Root Container failed: %d\n", err); goto err_root_open; } if (!root_dprc_handle) { printf("dprc_open(): Root Container Handle is not valid\n"); goto err_root_open; } cfg.options = DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED | DPRC_CFG_OPT_OBJ_CREATE_ALLOWED | DPRC_CFG_OPT_ALLOC_ALLOWED; cfg.icid = DPRC_GET_ICID_FROM_POOL; cfg.portal_id = 250; err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle, &cfg, &child_dprc_id, &mc_portal_offset); if (err < 0) { printf("dprc_create_container() failed: %d\n", err); goto err_create; } dflt_mc_io = (struct fsl_mc_io *)malloc(sizeof(struct fsl_mc_io)); if (!dflt_mc_io) { err = -ENOMEM; printf(" No memory: malloc() failed\n"); goto err_malloc; } child_portal_id = MC_PORTAL_OFFSET_TO_PORTAL_ID(mc_portal_offset); dflt_mc_io->mmio_regs = SOC_MC_PORTAL_ADDR(child_portal_id); #ifdef DEBUG printf("MC portal of child DPRC container: %d, physical addr %p)\n", child_dprc_id, dflt_mc_io->mmio_regs); #endif err = dprc_open(dflt_mc_io, MC_CMD_NO_FLAGS, child_dprc_id, &dflt_dprc_handle); if (err < 0) { printf("dprc_open(): Child container failed: %d\n", err); goto err_child_open; } if (!dflt_dprc_handle) { printf("dprc_open(): Child container Handle is not valid\n"); goto err_child_open; } return 0; err_child_open: free(dflt_mc_io); err_malloc: dprc_destroy_container(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle, child_dprc_id); err_create: dprc_close(root_mc_io, MC_CMD_NO_FLAGS, root_dprc_handle); err_root_open: err_root_container_id: return err; }