qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alistair Francis <alistair.francis@xilinx.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Michael Walle <michael@walle.cc>,
	"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	Stefan Weil <sw@weilnetz.de>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 5/6] hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus
Date: Wed, 31 Jan 2018 08:42:59 -0800	[thread overview]
Message-ID: <CAKmqyKONWkSrxLm_mXmVvaMNJ-rdQDNfpQGPgY7US-oyqH8x1Q@mail.gmail.com> (raw)
In-Reply-To: <20180123035837.16578-6-f4bug@amsat.org>

On Mon, Jan 22, 2018 at 7:58 PM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On reset the bus will reset the card,
> we can now drop the device_reset() call.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>

Alistair

> ---
>  hw/sd/ssi-sd.c | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
> index f88f509e0a..ae04b6641b 100644
> --- a/hw/sd/ssi-sd.c
> +++ b/hw/sd/ssi-sd.c
> @@ -47,7 +47,7 @@ typedef struct {
>      int32_t arglen;
>      int32_t response_pos;
>      int32_t stopping;
> -    SDState *sd;
> +    SDBus sdbus;
>  } ssi_sd_state;
>
>  #define TYPE_SSI_SD "ssi-sd"
> @@ -100,7 +100,7 @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val)
>              request.arg = (s->cmdarg[0] << 24) | (s->cmdarg[1] << 16)
>                             | (s->cmdarg[2] << 8) | s->cmdarg[3];
>              DPRINTF("CMD%d arg 0x%08x\n", s->cmd, request.arg);
> -            s->arglen = sd_do_command(s->sd, &request, longresp);
> +            s->arglen = sdbus_do_command(&s->sdbus, &request, longresp);
>              if (s->arglen <= 0) {
>                  s->arglen = 1;
>                  s->response[0] = 4;
> @@ -177,7 +177,7 @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val)
>              DPRINTF("Response 0x%02x\n", s->response[s->response_pos]);
>              return s->response[s->response_pos++];
>          }
> -        if (sd_data_ready(s->sd)) {
> +        if (sdbus_data_ready(&s->sdbus)) {
>              DPRINTF("Data read\n");
>              s->mode = SSI_SD_DATA_START;
>          } else {
> @@ -190,8 +190,8 @@ static uint32_t ssi_sd_transfer(SSISlave *dev, uint32_t val)
>          s->mode = SSI_SD_DATA_READ;
>          return 0xfe;
>      case SSI_SD_DATA_READ:
> -        val = sd_read_data(s->sd);
> -        if (!sd_data_ready(s->sd)) {
> +        val = sdbus_read_data(&s->sdbus);
> +        if (!sdbus_data_ready(&s->sdbus)) {
>              DPRINTF("Data read end\n");
>              s->mode = SSI_SD_CMD;
>          }
> @@ -242,13 +242,24 @@ static const VMStateDescription vmstate_ssi_sd = {
>  static void ssi_sd_realize(SSISlave *d, Error **errp)
>  {
>      ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d);
> +    DeviceState *carddev;
>      DriveInfo *dinfo;
> +    Error *err = NULL;
>
> +    qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
> +                        DEVICE(d), "sd-bus");
> +
> +    /* Create and plug in the sd card */
>      /* FIXME use a qdev drive property instead of drive_get_next() */
>      dinfo = drive_get_next(IF_SD);
> -    s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true);
> -    if (s->sd == NULL) {
> -        error_setg(errp, "Device initialization failed.");
> +    carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD);
> +    if (dinfo) {
> +        qdev_prop_set_drive(carddev, "drive", blk_by_legacy_dinfo(dinfo), &err);
> +    }
> +    object_property_set_bool(OBJECT(carddev), true, "spi", &err);
> +    object_property_set_bool(OBJECT(carddev), true, "realized", &err);
> +    if (err) {
> +        error_setg(errp, "failed to init SD card: %s", error_get_pretty(err));
>          return;
>      }
>  }
> @@ -264,11 +275,6 @@ static void ssi_sd_reset(DeviceState *dev)
>      s->arglen = 0;
>      s->response_pos = 0;
>      s->stopping = 0;
> -
> -    /* Since we're still using the legacy SD API the card is not plugged
> -     * into any bus, and we must reset it manually.
> -     */
> -    device_reset(DEVICE(s->sd));
>  }
>
>  static void ssi_sd_class_init(ObjectClass *klass, void *data)
> --
> 2.15.1
>
>

  reply	other threads:[~2018-01-31 16:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23  3:58 [Qemu-devel] [PATCH v2 0/6] SDHCI: convert legacy devices to the SDBus API (part 6) Philippe Mathieu-Daudé
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 1/6] hw/sd/milkymist-memcard: use qemu_log_mask() Philippe Mathieu-Daudé
2018-01-31 16:29   ` Alistair Francis
2018-02-01  9:07   ` Michael Walle
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 2/6] hw/sd/milkymist-memcard: split realize() out of SysBusDevice init() Philippe Mathieu-Daudé
2018-01-31 16:30   ` Alistair Francis
2018-02-01  9:07   ` Michael Walle
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it Philippe Mathieu-Daudé
2018-01-31 16:31   ` Alistair Francis
2018-02-01  9:08   ` Michael Walle
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 4/6] hw/sd/pl181: " Philippe Mathieu-Daudé
2018-01-31 16:41   ` Alistair Francis
2018-02-06 12:43     ` Philippe Mathieu-Daudé
2018-02-06 13:06       ` Peter Maydell
2018-02-06 13:53         ` Philippe Mathieu-Daudé
2018-02-06 13:59           ` Peter Maydell
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 5/6] hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus Philippe Mathieu-Daudé
2018-01-31 16:42   ` Alistair Francis [this message]
2018-01-23  3:58 ` [Qemu-devel] [PATCH v2 6/6] hw/sd: move sdcard legacy API to "hw/sd/sdcard_legacy.h" Philippe Mathieu-Daudé
2018-01-31 16:43   ` Alistair Francis
2018-01-31 14:05 ` [Qemu-devel] [PATCH v2 0/6] SDHCI: convert legacy devices to the SDBus API (part 6) Philippe Mathieu-Daudé

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=CAKmqyKONWkSrxLm_mXmVvaMNJ-rdQDNfpQGPgY7US-oyqH8x1Q@mail.gmail.com \
    --to=alistair.francis@xilinx.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=f4bug@amsat.org \
    --cc=michael@walle.cc \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).