aboutsummaryrefslogtreecommitdiff
path: root/core/flash.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-02-27 17:11:06 +0800
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-03-04 13:06:11 +1100
commit22af0b68fb2890c3d74eca06661d131bf94cce55 (patch)
tree408d00b5bfd6e880d0722d8f4562a855ddb7b6fb /core/flash.c
parenta6d1a207db2967d43d4c286726ea3b843e3746ab (diff)
downloadskiboot-22af0b68fb2890c3d74eca06661d131bf94cce55.zip
skiboot-22af0b68fb2890c3d74eca06661d131bf94cce55.tar.gz
skiboot-22af0b68fb2890c3d74eca06661d131bf94cce55.tar.bz2
core/flash: add /chosen/ibm, system-flash property to indicate system PNOR
This change adds a property in /chosen: /chosen/ibm,system-flash Containing the path to the system flash device. We move the system-flash-specific setup to a new function to contain it in the one place. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/flash.c')
-rw-r--r--core/flash.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/core/flash.c b/core/flash.c
index bf6f587..2bb04f5 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -148,7 +148,7 @@ static void flash_add_dt_partition_node(struct dt_node *flash_node, char *name,
dt_add_property_strings(part_node, "label", name);
}
-static void flash_add_dt_node(struct flash *flash, int id,
+static struct dt_node *flash_add_dt_node(struct flash *flash, int id,
struct ffs_handle *ffs)
{
struct dt_node *flash_node;
@@ -166,7 +166,7 @@ static void flash_add_dt_node(struct flash *flash, int id,
dt_add_property_cells(flash_node, "#size-cells", 1);
if (!ffs)
- return;
+ return flash_node;
for (i = 0; ; i++) {
uint32_t start, size;
@@ -179,12 +179,38 @@ static void flash_add_dt_node(struct flash *flash, int id,
flash_add_dt_partition_node(flash_node, name, start, size);
}
+
+ return flash_node;
+}
+
+static void setup_system_flash(struct flash *flash, struct dt_node *node,
+ const char *name, struct ffs_handle *ffs)
+{
+ if (system_flash) {
+ prlog(PR_WARNING, "FLASH: attempted to register a second "
+ "system flash device %s\n", name);
+ return;
+ }
+
+ if (!ffs) {
+ prlog(PR_WARNING, "FLASH: attempted to register system flash "
+ "%s, wwhich has no partition info\n", name);
+ return;
+ }
+
+ system_flash = flash;
+ dt_add_property_string(dt_chosen, "ibm,system-flash", node->name);
+
+ prlog(PR_INFO, "FLASH: registered system flash device %s\n", name);
+
+ flash_nvram_probe(flash, ffs);
}
int flash_register(struct flash_chip *chip, bool is_system_flash)
{
uint32_t size, block_size;
struct ffs_handle *ffs;
+ struct dt_node *node;
struct flash *flash;
const char *name;
unsigned int i;
@@ -224,14 +250,13 @@ int flash_register(struct flash_chip *chip, bool is_system_flash)
ffs = NULL;
}
- flash_add_dt_node(flash, i, ffs);
+ node = flash_add_dt_node(flash, i, ffs);
- if (is_system_flash && !system_flash) {
- system_flash = flash;
- flash_nvram_probe(flash, ffs);
- }
+ if (is_system_flash)
+ setup_system_flash(flash, node, name, ffs);
- ffs_close(ffs);
+ if (ffs)
+ ffs_close(ffs);
unlock(&flash_lock);