Skip to content

Commit 6d1028f

Browse files
cyrilbur-ibmstewartsmith
authored andcommitted
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>
1 parent 23fe769 commit 6d1028f

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

hw/ast-bmc/ast-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
#include <skiboot.h>
8989
#include <lpc.h>
9090
#include <lock.h>
91+
#include <device.h>
9192

9293
#include "ast.h"
9394

@@ -388,6 +389,11 @@ void ast_io_init(void)
388389
ast_setup_sio_irq_polarity();
389390
}
390391

392+
bool ast_is_mbox_pnor(void)
393+
{
394+
return dt_find_compatible_node(dt_root, NULL, "mbox");
395+
}
396+
391397
bool ast_is_ahb_lpc_pnor(void)
392398
{
393399
uint8_t boot_version;

include/ast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int ast_copy_from_ahb(void *dst, uint32_t reg, uint32_t len);
7474

7575
void ast_io_init(void);
7676
bool ast_is_ahb_lpc_pnor(void);
77+
bool ast_is_mbox_pnor(void);
7778

7879
/* UART configuration */
7980

platforms/astbmc/pnor.c

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <device.h>
1919
#include <console.h>
2020
#include <opal.h>
21+
#include <libflash/mbox-flash.h>
2122
#include <libflash/libflash.h>
2223
#include <libflash/libffs.h>
2324
#include <libflash/blocklevel.h>
@@ -27,26 +28,35 @@
2728

2829
int pnor_init(void)
2930
{
30-
struct spi_flash_ctrl *pnor_ctrl;
31+
struct spi_flash_ctrl *pnor_ctrl = NULL;
3132
struct blocklevel_device *bl = NULL;
3233
int rc;
34+
bool do_mbox;
3335

34-
/* Open controller and flash. If the LPC->AHB doesn't point to
35-
* the PNOR flash base we assume we're booting from BMC system
36-
* memory (or some other place setup by the BMC to support LPC
37-
* FW reads & writes). */
38-
if (ast_is_ahb_lpc_pnor())
39-
rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl);
40-
else {
41-
printf("PLAT: Memboot detected\n");
42-
rc = ast_sf_open(AST_SF_TYPE_MEM, &pnor_ctrl);
43-
}
44-
if (rc) {
45-
prerror("PLAT: Failed to open PNOR flash controller\n");
46-
goto fail;
36+
do_mbox = ast_is_mbox_pnor();
37+
if (do_mbox) {
38+
rc = mbox_flash_init(&bl);
39+
} else {
40+
/* Open controller and flash. If the LPC->AHB doesn't point to
41+
* the PNOR flash base we assume we're booting from BMC system
42+
* memory (or some other place setup by the BMC to support LPC
43+
* FW reads & writes).
44+
*/
45+
46+
if (ast_is_ahb_lpc_pnor())
47+
rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl);
48+
else {
49+
printf("PLAT: Memboot detected\n");
50+
rc = ast_sf_open(AST_SF_TYPE_MEM, &pnor_ctrl);
51+
}
52+
if (rc) {
53+
prerror("PLAT: Failed to open PNOR flash controller\n");
54+
goto fail;
55+
}
56+
57+
rc = flash_init(pnor_ctrl, &bl, NULL);
4758
}
4859

49-
rc = flash_init(pnor_ctrl, &bl, NULL);
5060
if (rc) {
5161
prerror("PLAT: Failed to open init PNOR driver\n");
5262
goto fail;
@@ -57,8 +67,12 @@ int pnor_init(void)
5767
return 0;
5868

5969
fail:
60-
if (bl)
61-
flash_exit(bl);
70+
if (bl) {
71+
if (do_mbox)
72+
mbox_flash_exit(bl);
73+
else
74+
flash_exit(bl);
75+
}
6276
if (pnor_ctrl)
6377
ast_sf_close(pnor_ctrl);
6478

0 commit comments

Comments
 (0)