[PATCH qemu 15/38] aspeed/smc: handle SPI flash Command mode
Joel Stanley
joel at jms.id.au
Mon Nov 21 18:25:33 AEDT 2016
On Sat, Nov 19, 2016 at 12:51 AM, Cédric Le Goater <clg at kaod.org> wrote:
> The Aspeed SMC controllers have a mode (Command mode) in which
> accesses to the flash content are no different than doing MMIOs. The
> controller generates all the necessary commands to load (or store)
> data in memory.
>
> However, accesses are restricted to the segment window assigned the
> the flash module by the controller. This window is defined by the
> Segment Address Register.
>
> Signed-off-by: Cédric Le Goater <clg at kaod.org>
> ---
> hw/ssi/aspeed_smc.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 162 insertions(+), 12 deletions(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 72a44150b0a1..eec087199a22 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -357,6 +368,98 @@ static inline bool aspeed_smc_is_writable(const AspeedSMCFlash *fl)
> return s->regs[s->r_conf] & (1 << (s->conf_enable_w0 + fl->id));
> }
>
> +static inline int aspeed_smc_flash_cmd(const AspeedSMCFlash *fl)
> +{
> + AspeedSMCState *s = fl->controller;
> + int cmd = (s->regs[s->r_ctrl0 + fl->id] >> CTRL_CMD_SHIFT) & CTRL_CMD_MASK;
I would expect mask to be 0x00FF0000 and you to mask and then shift.
You appear to have the mask shifted down already, so the code is
correct, but it's unexpected.
> +
> + /* This is the default value for read mode. In other modes, the
> + * command should be defined */
> + if (aspeed_smc_flash_mode(fl) == CTRL_READMODE) {
> + cmd = SPI_OP_READ;
> + }
More information about the openbmc
mailing list