All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: "Cédric Le Goater" <clg@kaod.org>, openbmc@lists.ozlabs.org
Subject: Re: [PATCH qemu 05/12] ast2400: handle SPI flash Command mode (read only)
Date: Tue, 07 Jun 2016 15:34:37 +0930	[thread overview]
Message-ID: <1465279477.16048.64.camel@aj.id.au> (raw)
In-Reply-To: <1464556805-4340-6-git-send-email-clg@kaod.org>

[-- Attachment #1: Type: text/plain, Size: 3286 bytes --]

On Sun, 2016-05-29 at 23:19 +0200, Cédric Le Goater wrote:
> We can now use directly the m25p80 flash storage to handle memory
> accesses when the SPI flash slave is configured in Command mode. Only
> read only accesses are handled. Command mode is only required by
> U-Boot, Linux does not use it yet.
> 
> Handling write accesses would demand more changes to the m25p80 flash
> model.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Assuming the m25p80_get_storage() is acceptable upstream,

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> ---
>  hw/ssi/aspeed_smc.c         | 18 +++++++++++++++---
>  include/hw/ssi/aspeed_smc.h |  2 ++
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index 4175356141e7..159ab691051d 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -28,6 +28,7 @@
>  #include "qemu/log.h"
>  #include "include/qemu/error-report.h"
>  #include "exec/address-spaces.h"
> +#include "hw/block/flash.h"
>  
>  #include "hw/ssi/aspeed_smc.h"
>  
> @@ -284,8 +285,9 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)
>              ret = (ret << 8) | ssi_transfer(s->spi, 0x0);
>          }
>      } else {
> -        error_report("%s: flash not in usermode", __func__);
> -        ret = -1;
> +        for (i = 0; i < size; i++) {
> +            ret = (ret << 8) | fl->storage[addr + i];
> +        }
>      }
>  
>      return ret;
> @@ -330,6 +332,11 @@ static void aspeed_smc_flash_reset(DeviceState *d)
>  
>  static int aspeed_smc_flash_init(SysBusDevice *sbd)
>  {
> +    DeviceState *dev = DEVICE(sbd);
> +    AspeedSMCFlashState *s = ASPEED_SMC_FLASH(dev);
> +
> +    s->size = 0;
> +    s->storage = NULL;
>      return 0;
>  }
>  
> @@ -422,8 +429,13 @@ void aspeed_smc_init_flashes(AspeedSMCState *s, const char *flashtype)
>          cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0);
>          sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
>  
> +        fl->storage = m25p80_get_storage(DEVICE(fl->flash), &fl->size);
> +        if (fl->size > aspeed_segments[s->smc_type][i].size) {
> +            fl->size = aspeed_segments[s->smc_type][i].size;
> +        }
> +
>          memory_region_init_io(&fl->mmio, new, &aspeed_smc_flash_ops, fl, name,
> -                              aspeed_segments[s->smc_type][i].size);
> +                              fl->size);
>          sysbus_init_mmio(SYS_BUS_DEVICE(new), &fl->mmio);
>  
>          sysbus_mmio_map(SYS_BUS_DEVICE(new), 0,
> diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
> index 1625dfb76a63..2615ce9fa8aa 100644
> --- a/include/hw/ssi/aspeed_smc.h
> +++ b/include/hw/ssi/aspeed_smc.h
> @@ -38,6 +38,8 @@ typedef struct AspeedSMCFlashState {
>  
>      MemoryRegion mmio;
>      int id;
> +    uint32_t size;
> +    uint8_t *storage;
>      struct AspeedSMCState *controller;
>      DeviceState *flash;
>  } AspeedSMCFlashState;

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-06-07  6:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-29 21:19 [PATCH qemu 00/12] SMC and network support Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 01/12] ast2400: add SMC controllers (FMC and SPI) Cédric Le Goater
2016-06-07  2:08   ` Andrew Jeffery
2016-06-08 11:53     ` Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 02/12] ast2400: add SPI flash slave object Cédric Le Goater
2016-06-07  5:34   ` Andrew Jeffery
2016-06-08 12:42     ` Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 03/12] ast2400: create SPI flash slaves Cédric Le Goater
2016-06-07  5:56   ` Andrew Jeffery
2016-06-08 12:46     ` Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 04/12] m25p80: add a get storage routine Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 05/12] ast2400: handle SPI flash Command mode (read only) Cédric Le Goater
2016-06-07  6:04   ` Andrew Jeffery [this message]
2016-05-29 21:19 ` [PATCH qemu 06/12] ast2400: use contents of first SPI flash as a rom Cédric Le Goater
2016-06-07  6:24   ` Andrew Jeffery
2016-06-09 10:42     ` Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 07/12] m25p80: add RDCR instruction for Macronix chip Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 08/12] m25p80: add mx25l25635f chip Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 09/12] ast2400: use a " Cédric Le Goater
2016-06-07  6:29   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 10/12] ast2400: add a BT device Cédric Le Goater
2016-06-07  7:15   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 11/12] net: add FTGMAC100 support Cédric Le Goater
2016-06-08  3:50   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 12/12] ast2400: add a FTGMAC100 nic Cédric Le Goater
2016-06-07  7:26   ` Andrew Jeffery
2016-06-23 17:00 ` [PATCH qemu 00/12] SMC and network support Cédric Le Goater
2016-06-24  7:06   ` Joel Stanley
2016-06-24  7:18     ` Cédric Le Goater
2016-06-27 16:09   ` Andrew Jeffery

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465279477.16048.64.camel@aj.id.au \
    --to=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=openbmc@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.