aboutsummaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-02-22 20:31:02 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-02-23 16:04:27 +1100
commit6d1028fe88572ab6fbcb08e16a9f1bf71b0de8df (patch)
treec8849bed0243ec0f2ee89ef480cbfc4204a34b7d /platforms
parent23fe769115c41e8859ce3d23dc75953bfb290f45 (diff)
downloadskiboot-6d1028fe88572ab6fbcb08e16a9f1bf71b0de8df.zip
skiboot-6d1028fe88572ab6fbcb08e16a9f1bf71b0de8df.tar.gz
skiboot-6d1028fe88572ab6fbcb08e16a9f1bf71b0de8df.tar.bz2
astbmc/pnor: Use mbox-flash for flash accesses
If the BMC is MBOX protocol aware, request flash reads/writes over the MBOX regs. This inits the blocklevel for pnor access with mbox-flash. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'platforms')
-rw-r--r--platforms/astbmc/pnor.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
index de4cafa..e663055 100644
--- a/platforms/astbmc/pnor.c
+++ b/platforms/astbmc/pnor.c
@@ -18,6 +18,7 @@
#include <device.h>
#include <console.h>
#include <opal.h>
+#include <libflash/mbox-flash.h>
#include <libflash/libflash.h>
#include <libflash/libffs.h>
#include <libflash/blocklevel.h>
@@ -27,26 +28,35 @@
int pnor_init(void)
{
- struct spi_flash_ctrl *pnor_ctrl;
+ struct spi_flash_ctrl *pnor_ctrl = NULL;
struct blocklevel_device *bl = NULL;
int rc;
+ bool do_mbox;
- /* 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;
+ do_mbox = ast_is_mbox_pnor();
+ if (do_mbox) {
+ rc = mbox_flash_init(&bl);
+ } else {
+ /* 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);
}
- rc = flash_init(pnor_ctrl, &bl, NULL);
if (rc) {
prerror("PLAT: Failed to open init PNOR driver\n");
goto fail;
@@ -57,8 +67,12 @@ int pnor_init(void)
return 0;
fail:
- if (bl)
- flash_exit(bl);
+ if (bl) {
+ if (do_mbox)
+ mbox_flash_exit(bl);
+ else
+ flash_exit(bl);
+ }
if (pnor_ctrl)
ast_sf_close(pnor_ctrl);