diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-02-19 06:34:53 +0800 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-02-19 10:49:08 +1100 |
commit | 348d5c4875ec46792d1749a88ec7457c62650e08 (patch) | |
tree | 9daa0bc9004320f8b3ab2e152f89d271ed3e1a62 /platforms/rhesus/rhesus.c | |
parent | 73b262e768529f152ec64b4418b0c31691bc15c3 (diff) | |
download | skiboot-348d5c4875ec46792d1749a88ec7457c62650e08.zip skiboot-348d5c4875ec46792d1749a88ec7457c62650e08.tar.gz skiboot-348d5c4875ec46792d1749a88ec7457c62650e08.tar.bz2 |
core/flash: Move flash NVRAM handling to new flash module
Since we want to prevent conflicts between PNOR and NVRAM, this change
moves the flash-nvram handling out of flash-nvram.c and into the generic
flash module. This way, the OPAL_FLASH_{READ,WRITE,ERASE} API won't
conflict with the OPAL_*_NVRAM api.
To do this, we use the flash_register function to look for an "NVRAM"
partition. If one is found, it is automatically registered as the system
NVRAM backend.
We also change the rhesus and astmbc platforms to use the common flash
code.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'platforms/rhesus/rhesus.c')
-rw-r--r-- | platforms/rhesus/rhesus.c | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/platforms/rhesus/rhesus.c b/platforms/rhesus/rhesus.c index 8385a0c..50769cf 100644 --- a/platforms/rhesus/rhesus.c +++ b/platforms/rhesus/rhesus.c @@ -38,10 +38,6 @@ #define RHESUS_BOARD_REVISION3 EC_GPIO_PORT_E, 4 #define RHESUS_BOARD_REVISION4 EC_GPIO_PORT_E, 1 -static struct spi_flash_ctrl *pnor_ctrl; -static struct flash_chip *pnor_chip; -static struct ffs_handle *pnor_ffs; - /* * IO accessors for the EC driver @@ -121,7 +117,8 @@ static int64_t rhesus_power_down(uint64_t request __unused) static int rhesus_pnor_init(void) { - uint32_t nv_part, nv_start, nv_size; + struct spi_flash_ctrl *pnor_ctrl; + struct flash_chip *pnor_chip; int rc; /* Open controller, flash and ffs */ @@ -135,42 +132,16 @@ static int rhesus_pnor_init(void) prerror("PLAT: Failed to open init PNOR driver\n"); goto fail; } - rc = ffs_open_flash(pnor_chip, 0, 0, &pnor_ffs); - if (rc) { - prerror("PLAT: Failed to parse FFS partition map\n"); - goto fail; - } - /* - * Grab NVRAM and initialize the flash_nvram module - * - * Note: Ignore actual size for now ... some images have - * it setup incorrectly. - */ - rc = ffs_lookup_part(pnor_ffs, "NVRAM", &nv_part); - if (rc) { - prerror("PLAT: No NVRAM partition in PNOR\n"); - return OPAL_HARDWARE; - } - rc = ffs_part_info(pnor_ffs, nv_part, NULL, - &nv_start, &nv_size, NULL); - if (rc) { - prerror("PLAT: Failed to get NVRAM partition info\n"); - return OPAL_HARDWARE; - } - flash_nvram_init(pnor_chip, nv_start, nv_size); + rc = flash_register(pnor_chip, true); + if (!rc) + return 0; - return 0; fail: - if (pnor_ffs) - ffs_close(pnor_ffs); - pnor_ffs = NULL; if (pnor_chip) flash_exit(pnor_chip); - pnor_chip = NULL; if (pnor_ctrl) sfc_close(pnor_ctrl); - pnor_ctrl = NULL; return rc; } |