aboutsummaryrefslogtreecommitdiff
path: root/libflash
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2015-08-26 16:02:33 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-08-28 15:24:04 +1000
commitaa0f5f4cb904faeff3ae53e35d16e5e12191de4e (patch)
tree1105c46990c0bf85833023ae9d1d073698f83665 /libflash
parent315acaa5d6a271d2dd6516a358a38c51c10667fa (diff)
downloadskiboot-aa0f5f4cb904faeff3ae53e35d16e5e12191de4e.zip
skiboot-aa0f5f4cb904faeff3ae53e35d16e5e12191de4e.tar.gz
skiboot-aa0f5f4cb904faeff3ae53e35d16e5e12191de4e.tar.bz2
external/common: Create common code for initialising libflash components
In order to access the flash on ARM (presumably code running on a BMC), the hardware is involved. In order to access the flash on POWER (presumably code running on a host), opal calls through the Linux MTD driver are involved. In order to access the flash on x86 (presumably on a developer/admin system), you can't but it would be nice to be able to manipulate data which has come from the flash or will go onto the flash. The pflash and the gard tool both can read and write to the 'flash' and with the introduction of the blocklevel interface the details of how the flash is read from and written to is sufficiently abstracted that these tools don't need to know what they're running on. What does differ is the setup, and not by too much either. This common code pulls out the setup of the flash hardware on ARM, the searching for the appropriate MTD device on power and generic blocklevel device init for all three architectures. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r--libflash/libflash.c8
-rw-r--r--libflash/libflash.h5
2 files changed, 13 insertions, 0 deletions
diff --git a/libflash/libflash.c b/libflash/libflash.c
index 831bdd4..4b9948b 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -856,3 +856,11 @@ void flash_exit(struct blocklevel_device *bl)
free(container_of(bl, struct flash_chip, bl));
}
+void flash_exit_close(struct blocklevel_device *bl, void (*close)(struct spi_flash_ctrl *ctrl))
+{
+ if (bl) {
+ struct flash_chip *c = container_of(bl, struct flash_chip, bl);
+ close(c->ctrl);
+ free(c);
+ }
+}
diff --git a/libflash/libflash.h b/libflash/libflash.h
index fa5143a..3fdd00b 100644
--- a/libflash/libflash.h
+++ b/libflash/libflash.h
@@ -49,6 +49,11 @@ int flash_init(struct spi_flash_ctrl *ctrl, struct blocklevel_device **bl,
struct flash_chip **flash_chip);
void flash_exit(struct blocklevel_device *bl);
+/*
+ * Function which till call close on the underlying struct spi_flash_ctrl
+ */
+void flash_exit_close(struct blocklevel_device *bl, void (*close)(struct spi_flash_ctrl *ctrl));
+
/* libflash sets the 4b mode automatically based on the flash
* size and controller capabilities but it can be overriden
*/