aspeed/smc: small fixes
cover aspeed/smc: small fixes
Hello,
Here is a short series of cleanups and fixes for issues in the Aspeed SMC controller model discovered when experimenting with the MMIO exec feature and also from tests under a QEMU PowerNV machine.
Indeed, the OPAL/skiboot firmware accesses the Aspeed SoC address space using the iLPC->AHB bridge of the SuperIO controller and drives the SPI controller to access the PNOR.
Thanks,
C.
Cédric Le Goater (3):
aspeed/smc: fix dummy cycles count when in dual IO mode aspeed/smc: fix HW strapping
aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup()
hw/ssi/aspeed_smc.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/3 aspeed/smc: fix dummy cycles count when in dual IO mode
When configured in dual I/O mode, address and data are sent in dual mode, including the dummy byte cycles in between. Adapt the count to the IO setting.
--- hw/ssi/aspeed_smc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ssi/aspeed_smc.c +8 -1
@@ -66,6 +66,8 @@/* CEx Control Register */ #define R_CTRL0 (0x10 / 4) +#define CTRL_IO_DUAL_DATA (1 << 29) +#define CTRL_IO_DUAL_ADDR_DATA (1 << 28)/* Includes dummies */ #define CTRL_CMD_SHIFT 16#define CTRL_CMD_MASK 0xff#define CTRL_DUMMY_HIGH_SHIFT 14
@@ -492,8 +494,13 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)uint32_t r_ctrl0 = s->regs[s->r_ctrl0 + fl->id];uint32_t dummy_high = (r_ctrl0 >>CTRL_DUMMY_HIGH_SHIFT ) &0x1 ;uint32_t dummy_low = (r_ctrl0 >>CTRL_DUMMY_LOW_SHIFT ) &0x3 ; +uint32_t dummies = ((dummy_high <<2 ) | dummy_low) *8 ; -return ((dummy_high <<2 ) | dummy_low) *8 ; +if (r_ctrl0 &CTRL_IO_DUAL_ADDR_DATA ) { + dummies /=2 ; + } + +return dummies; }static void aspeed_smc_flash_send_addr (AspeedSMCFlash *fl,uint32_t addr)
Signature · 1 line
2.13.6
Re: [Qemu-arm] [PATCH 1/3] aspeed/smc: fix dummy cycles count when in dual IO mode
Quoted 5 lines · Cédric Le Goater
When configured in dual I/O mode, address and data are sent in dual mode, including the dummy byte cycles in between. Adapt the count to the IO setting.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 37 lines
--- hw/ssi/aspeed_smc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)hw/ssi/aspeed_smc.c +8
-1@@ -66,6 +66,8 @@/* CEx Control Register */ #define R_CTRL0 (0x10 / 4) +#define CTRL_IO_DUAL_DATA (1 << 29) +#define CTRL_IO_DUAL_ADDR_DATA (1 << 28)/* Includes dummies */ #define CTRL_CMD_SHIFT 16#define CTRL_CMD_MASK 0xff#define CTRL_DUMMY_HIGH_SHIFT 14@@ -492,8 +494,13 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)uint32_t r_ctrl0 = s->regs[s->r_ctrl0 + fl->id];uint32_t dummy_high = (r_ctrl0 >>CTRL_DUMMY_HIGH_SHIFT ) &0x1 ;uint32_t dummy_low = (r_ctrl0 >>CTRL_DUMMY_LOW_SHIFT ) &0x3 ; +uint32_t dummies = ((dummy_high <<2 ) | dummy_low) *8 ; -return ((dummy_high <<2 ) | dummy_low) *8 ; +if (r_ctrl0 &CTRL_IO_DUAL_ADDR_DATA ) { + dummies /=2 ; + } + +return dummies; }static void
aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr)Signature · 1 line
2.13.6
PATCH 2/3 aspeed/smc: fix HW strapping
In reply to Cédric Le GoaterOnly the flash type is strapped by HW. The 4BYTE mode is set by firmware when the flash device is detected.
--- hw/ssi/aspeed_smc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
hw/ssi/aspeed_smc.c +1 -7
@@ -639,23 +639,17 @@ static void aspeed_smc_reset(DeviceState *d)aspeed_smc_segment_to_reg (&s->ctrl->segments[i]); } -/* HW strapping for AST2500 FMC controllers */ +/* HW strapping flash type for FMC controllers */ if (s->ctrl->segments == aspeed_segments_ast2500_fmc) {/* flash type is fixed to SPI for CE0 and CE1 */ s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE1 ); - -/* 4BYTE mode is autodetected for CE0. Let's force it to 1 for -* now */ - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); }/* HW strapping for AST2400 FMC controllers (SCU70). Let's use the * configuration of the palmetto-bmc machine */ if (s->ctrl->segments == aspeed_segments_fmc) { s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); - - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); } }
Signature · 1 line
2.13.6
Re: [Qemu-arm] [Qemu-devel] [PATCH 2/3] aspeed/smc: fix HW strapping
Quoted 4 lines · Cédric Le Goater
Only the flash type is strapped by HW. The 4BYTE mode is set by firmware when the flash device is detected.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 37 lines
--- hw/ssi/aspeed_smc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)hw/ssi/aspeed_smc.c +1
-7@@ -639,23 +639,17 @@ static void aspeed_smc_reset(DeviceState *d)aspeed_smc_segment_to_reg (&s->ctrl->segments[i]); } -/* HW strapping for AST2500 FMC controllers */ +/* HW strapping flash type for FMC controllers */ if (s->ctrl->segments == aspeed_segments_ast2500_fmc) {/* flash type is fixed to SPI for CE0 and CE1 */ s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE1 ); - -/* 4BYTE mode is autodetected for CE0. Let's force it to 1 for -* now */ - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); }/* HW strapping for AST2400 FMC controllers (SCU70). Let's use the * configuration of the palmetto-bmc machine */ if (s->ctrl->segments == aspeed_segments_fmc) { s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); - - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); } }Signature · 1 line
2.13.6
PATCH 3/3 aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup()
In reply to Cédric Le GoaterAlso handle the fake transfers for dummy bytes in this setup routine. It will be useful when we activate MMIO execution.
--- hw/ssi/aspeed_smc.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
hw/ssi/aspeed_smc.c +16 -15
@@ -503,10 +503,11 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)return dummies; } -static void aspeed_smc_flash_send_addr (AspeedSMCFlash *fl,uint32_t addr) +static void aspeed_smc_flash_setup (AspeedSMCFlash *fl,uint32_t addr) {const AspeedSMCState *s = fl->controller;uint8_t cmd =aspeed_smc_flash_cmd (fl); +int i;/* Flash access can not exceed CS segment */ addr =aspeed_smc_check_segment_addr (fl, addr);
@@ -519,6 +520,18 @@ static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr)ssi_transfer (s->spi, (addr >>16 ) &0xff );ssi_transfer (s->spi, (addr >>8 ) &0xff );ssi_transfer (s->spi, (addr &0xff )); + +/* +* Use fake transfers to model dummy bytes. The value should +* be configured to some non-zero value in fast read mode and +* zero in read mode. But, as the HW allows inconsistent +* settings, let's check for fast read mode. +*/ +if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { +for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { +ssi_transfer (fl->controller->spi,0xFF ); + } + } }static uint64_t aspeed_smc_flash_read (void *opaque,hwaddr addr,unsigned size)
@@ -537,19 +550,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)case CTRL_READMODE :case CTRL_FREADMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); - -/* -* Use fake transfers to model dummy bytes. The value should -* be configured to some non-zero value in fast read mode and -* zero in read mode. But, as the HW allows inconsistent -* settings, let's check for fast read mode. -*/ -if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { -for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { -ssi_transfer (fl->controller->spi,0xFF ); - } - } +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) { ret |=ssi_transfer (s->spi,0x0 ) << (8 * i);
@@ -586,7 +587,7 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data,break ;case CTRL_WRITEMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) {ssi_transfer (s->spi, (data >> (8 * i)) &0xff );
Signature · 1 line
2.13.6
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/3] aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup()
Quoted 4 lines · Cédric Le Goater
Also handle the fake transfers for dummy bytes in this setup routine. It will be useful when we activate MMIO execution.
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 79 lines
--- hw/ssi/aspeed_smc.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)hw/ssi/aspeed_smc.c +2
-1@@ -503,10 +503,11 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)return dummies; } -static void aspeed_smc_flash_send_addr (AspeedSMCFlash *fl,uint32_t addr) +static void aspeed_smc_flash_setup (AspeedSMCFlash *fl,uint32_t addr) {const AspeedSMCState *s = fl->controller;uint8_t cmd =aspeed_smc_flash_cmd (fl); +int i;/* Flash access can not exceed CS segment */ addr = aspeed_smc_check_segment_addr(fl, addr);hw/ssi/aspeed_smc.c +12
-0@@ -519,6 +520,18 @@ static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr)ssi_transfer (s->spi, (addr >>16 ) &0xff );ssi_transfer (s->spi, (addr >>8 ) &0xff );ssi_transfer (s->spi, (addr &0xff )); + +/* +* Use fake transfers to model dummy bytes. The value should +* be configured to some non-zero value in fast read mode and +* zero in read mode. But, as the HW allows inconsistent +* settings, let's check for fast read mode. +*/ +if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { +for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { +ssi_transfer (fl->controller->spi,0xFF ); + } + } }static
uint64_taspeed_smc_flash_read(void *opaque, hwaddr addr,
unsigned size)hw/ssi/aspeed_smc.c +1
-13@@ -537,19 +550,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)case CTRL_READMODE :case CTRL_FREADMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); - -/* -* Use fake transfers to model dummy bytes. The value should -* be configured to some non-zero value in fast read mode and -* zero in read mode. But, as the HW allows inconsistent -* settings, let's check for fast read mode. -*/ -if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { -for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { -ssi_transfer (fl->controller->spi,0xFF ); - } - } +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) {ret |= ssi_transfer(s->spi, 0x0) << (8 * i);hw/ssi/aspeed_smc.c +1
-1@@ -586,7 +587,7 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data, break;case CTRL_WRITEMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) {ssi_transfer(s->spi, (data >> (8 * i)) & 0xff);Signature · 1 line
2.13.6
Quoted 9 lines · Cédric Le Goater
Hello,
Here is a short series of cleanups and fixes for issues in the Aspeed SMC controller model discovered when experimenting with the MMIO exec feature and also from tests under a QEMU PowerNV machine.
Indeed, the OPAL/skiboot firmware accesses the Aspeed SoC address space using the
iLPC->AHBbridge of the SuperIO controller and drives the SPI controller to access the PNOR.
Is there anybody familiar with the aspeed SoC who'd like to review? The patches don't look particularly wrong, but I'm not really in a position to be able to review...
thanks
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Cédric Le Goater
Hello,
Here is a short series of cleanups and fixes for issues in the Aspeed SMC controller model discovered when experimenting with the MMIO exec feature and also from tests under a QEMU PowerNV machine.
Quoted 7 lines
Quoted 3 lines
Indeed, the OPAL/skiboot firmware accesses the Aspeed SoC address space using the
iLPC->AHBbridge of the SuperIO controller and drives the SPI controller to access the PNOR.Is there anybody familiar with the aspeed SoC who'd like to review? The patches don't look particularly wrong, but I'm not really in a position to be able to review...
Adding Andrew and Joel as I should have.
Thanks,
C.
Peter Maydell
AppliedQuoted 10 lines · Cédric Le Goater
Hello,
Here is a short series of cleanups and fixes for issues in the Aspeed SMC controller model discovered when experimenting with the MMIO exec feature and also from tests under a QEMU PowerNV machine.
Indeed, the OPAL/skiboot firmware accesses the Aspeed SoC address space using the
iLPC->AHBbridge of the SuperIO controller and drives the SPI controller to access the PNOR.
Quoted 8 lines
Thanks,
C.
Cédric Le Goater (3):
aspeed/smc: fix dummy cycles count when in dual IO mode aspeed/smc: fix HW strapping
aspeed/smc: renameaspeed_smc_flash_send_addr()toaspeed_smc_flash_setup()
Applied to target-arm.next, thanks.
-- PMM