static int flash_access_setup_bmc(bool use_lpc, bool need_write) { int rc; printf("Setting up BMC flash\n"); /* Open and map devices */ open_devs(use_lpc, true); /* Create the AST flash controller */ rc = ast_sf_open(AST_SF_TYPE_BMC, &fl_ctrl); if(rc) { fprintf(stderr, "Failed to open controller\n"); return FLASH_SETUP_ERROR; } /* Open flash chip */ rc = flash_init(fl_ctrl, &fl_chip); if(rc) { fprintf(stderr, "Failed to open flash chip\n"); return FLASH_SETUP_ERROR; } /* Setup cleanup function */ atexit(flash_access_cleanup_bmc); return FLASH_OK; }
int pnor_init(void) { struct spi_flash_ctrl *pnor_ctrl; struct blocklevel_device *bl = NULL; int rc; /* Open controller and flash. If the LPC->AHB doesn't point to * the PNOR flash base we assume we're booting from BMC system * memory (or some other place setup by the BMC to support LPC * FW reads & writes). */ if (ast_is_ahb_lpc_pnor()) rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl); else { printf("PLAT: Memboot detected\n"); rc = ast_sf_open(AST_SF_TYPE_MEM, &pnor_ctrl); } if (rc) { prerror("PLAT: Failed to open PNOR flash controller\n"); goto fail; } rc = flash_init(pnor_ctrl, &bl, NULL); if (rc) { prerror("PLAT: Failed to open init PNOR driver\n"); goto fail; } rc = flash_register(bl); if (!rc) return 0; fail: if (bl) flash_exit(bl); if (pnor_ctrl) ast_sf_close(pnor_ctrl); return rc; }
static int flash_access_setup_pnor(bool use_lpc, bool use_sfc, bool need_write) { int rc; printf("Setting up BIOS flash\n"); /* Open and map devices */ open_devs(use_lpc, false); #ifdef __powerpc__ if(use_sfc) { /* Create the SFC flash controller */ rc = sfc_open(&fl_ctrl); if(rc) { fprintf(stderr, "Failed to open controller\n"); return FLASH_SETUP_ERROR; } using_sfc = true; } else { #endif /* Create the AST flash controller */ rc = ast_sf_open(AST_SF_TYPE_PNOR, &fl_ctrl); if(rc) { fprintf(stderr, "Failed to open controller\n"); return FLASH_SETUP_ERROR; } #ifdef __powerpc__ } #endif /* Open flash chip */ rc = flash_init(fl_ctrl, &fl_chip); if(rc) { fprintf(stderr, "Failed to open flash chip\n"); return FLASH_SETUP_ERROR; } /* Unlock flash (PNOR only) */ if(need_write) need_relock = set_wrprotect(false); /* Setup cleanup function */ atexit(flash_access_cleanup_pnor); return FLASH_OK; }