summaryrefslogtreecommitdiffstats
path: root/platforms/astbmc
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-02-19 06:34:53 +0800
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-02-19 10:49:08 +1100
commit348d5c4875ec46792d1749a88ec7457c62650e08 (patch)
tree9daa0bc9004320f8b3ab2e152f89d271ed3e1a62 /platforms/astbmc
parent73b262e768529f152ec64b4418b0c31691bc15c3 (diff)
downloadtalos-skiboot-348d5c4875ec46792d1749a88ec7457c62650e08.tar.gz
talos-skiboot-348d5c4875ec46792d1749a88ec7457c62650e08.zip
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/astbmc')
-rw-r--r--platforms/astbmc/pnor.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
index e5bc269a..c64f41e8 100644
--- a/platforms/astbmc/pnor.c
+++ b/platforms/astbmc/pnor.c
@@ -24,16 +24,13 @@
#include "astbmc.h"
-static struct spi_flash_ctrl *pnor_ctrl;
-static struct flash_chip *pnor_chip;
-static struct ffs_handle *pnor_ffs;
-
int 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 */
+ /* Open controller and flash */
rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl);
if (rc) {
prerror("PLAT: Failed to open PNOR flash controller\n");
@@ -44,42 +41,16 @@ int 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)
ast_sf_close(pnor_ctrl);
- pnor_ctrl = NULL;
return rc;
}
OpenPOWER on IntegriCloud