[Skiboot] [RFC PATCH 6/6] astbmc: Prefer ipmi-flash for PNOR access
Andrew Jeffery
andrew at aj.id.au
Thu Sep 6 16:40:15 AEST 2018
If the IPMI command is not available, fall back to the mailbox
interface.
Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
---
hw/ast-bmc/ast-io.c | 10 +++++++---
include/ast.h | 11 +++++++++--
platforms/astbmc/common.c | 8 ++++++--
platforms/astbmc/pnor.c | 35 +++++++++++++++++++++++++----------
4 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/hw/ast-bmc/ast-io.c b/hw/ast-bmc/ast-io.c
index a6ae85a4d24f..e8258b4cfc02 100644
--- a/hw/ast-bmc/ast-io.c
+++ b/hw/ast-bmc/ast-io.c
@@ -426,12 +426,16 @@ bool ast_io_init(void)
return ast_io_is_rw();
}
-bool ast_lpc_fw_is_mbox(void)
+bool ast_lpc_fw_needs_hiomap(void)
{
- return dt_find_compatible_node(dt_root, NULL, "mbox");
+ struct dt_node *n;
+
+ n = dt_find_compatible_node(dt_root, NULL, "mbox");
+
+ return n != NULL;
}
-bool ast_lpc_fw_is_flash(void)
+bool ast_lpc_fw_maps_flash(void)
{
uint8_t boot_version;
uint8_t boot_flags;
diff --git a/include/ast.h b/include/ast.h
index b30f7bf27737..831fae340348 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -86,10 +86,17 @@ bool ast_can_isolate_sp(void);
bool ast_sio_disable(void);
bool ast_io_init(void);
bool ast_io_is_rw(void);
-bool ast_lpc_fw_is_flash(void);
-bool ast_lpc_fw_is_mbox(void);
+bool ast_lpc_fw_maps_flash(void);
+bool ast_lpc_fw_needs_hiomap(void);
bool ast_scratch_reg_is_mbox(void);
+enum ast_flash_style {
+ raw_flash,
+ raw_mem,
+ hiomap_ipmi,
+ hiomap_mbox,
+};
+
/* UART configuration */
bool ast_is_vuart1_enabled(void);
diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c
index 23550ef37a67..ced38bc3374f 100644
--- a/platforms/astbmc/common.c
+++ b/platforms/astbmc/common.c
@@ -120,11 +120,15 @@ static int astbmc_fru_init(void)
void astbmc_init(void)
{
+ /* Register the BT interface with the IPMI layer
+ *
+ * Initialise this first to enable PNOR access
+ */
+ bt_init();
+
/* Initialize PNOR/NVRAM */
pnor_init();
- /* Register the BT interface with the IPMI layer */
- bt_init();
/* Initialize elog */
elog_init();
ipmi_sel_init();
diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c
index 55784ee4594f..9241dde94a2d 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/ipmi-flash.h>
#include <libflash/mbox-flash.h>
#include <libflash/libflash.h>
#include <libflash/libffs.h>
@@ -30,12 +31,16 @@ int pnor_init(void)
{
struct spi_flash_ctrl *pnor_ctrl = NULL;
struct blocklevel_device *bl = NULL;
+ enum ast_flash_style style;
int rc;
- bool do_mbox;
- do_mbox = ast_lpc_fw_is_mbox();
- if (do_mbox) {
- rc = mbox_flash_init(&bl);
+ if (ast_lpc_fw_needs_hiomap()) {
+ style = hiomap_ipmi;
+ rc = ipmi_flash_init(&bl);
+ if (rc) {
+ style = hiomap_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
@@ -43,10 +48,12 @@ int pnor_init(void)
* FW reads & writes).
*/
- if (ast_lpc_fw_is_flash())
+ if (ast_lpc_fw_maps_flash()) {
+ style = raw_flash;
rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl);
- else {
+ } else {
printf("PLAT: Memboot detected\n");
+ style = raw_mem;
rc = ast_sf_open(AST_SF_TYPE_MEM, &pnor_ctrl);
}
if (rc) {
@@ -66,12 +73,20 @@ int pnor_init(void)
if (!rc)
return 0;
- fail:
+fail:
if (bl) {
- if (do_mbox)
- mbox_flash_exit(bl);
- else
+ switch (style) {
+ case raw_flash:
+ case raw_mem:
flash_exit(bl);
+ break;
+ case hiomap_ipmi:
+ ipmi_flash_exit(bl);
+ break;
+ case hiomap_mbox:
+ mbox_flash_exit(bl);
+ break;
+ }
}
if (pnor_ctrl)
ast_sf_close(pnor_ctrl);
--
2.17.1
More information about the Skiboot
mailing list