[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/6] hw/sd/milkymist-memcard: expose
From: |
Alistair Francis |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [PATCH 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it |
Date: |
Mon, 8 Jan 2018 13:36:23 -0800 |
On Wed, Jan 3, 2018 at 8:23 AM, Philippe Mathieu-Daudé <address@hidden> wrote:
> using the sdbus_*() API.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Alistair
> ---
> hw/sd/milkymist-memcard.c | 34 +++++++++++++++++++++-------------
> 1 file changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
> index 5df3a0f815..9f4c7dad63 100644
> --- a/hw/sd/milkymist-memcard.c
> +++ b/hw/sd/milkymist-memcard.c
> @@ -68,7 +68,7 @@ struct MilkymistMemcardState {
> SysBusDevice parent_obj;
>
> MemoryRegion regs_region;
> - SDState *card;
> + SDBus sdbus;
>
> int command_write_ptr;
> int response_read_ptr;
> @@ -104,7 +104,7 @@ static void memcard_sd_command(MilkymistMemcardState *s)
> req.crc = s->command[5];
>
> s->response[0] = req.cmd;
> - s->response_len = sd_do_command(s->card, &req, s->response+1);
> + s->response_len = sdbus_do_command(&s->sdbus, &req, s->response + 1);
> s->response_read_ptr = 0;
>
> if (s->response_len == 16) {
> @@ -149,10 +149,10 @@ static uint64_t memcard_read(void *opaque, hwaddr addr,
> r = 0xffffffff;
> } else {
> r = 0;
> - r |= sd_read_data(s->card) << 24;
> - r |= sd_read_data(s->card) << 16;
> - r |= sd_read_data(s->card) << 8;
> - r |= sd_read_data(s->card);
> + r |= sdbus_read_data(&s->sdbus) << 24;
> + r |= sdbus_read_data(&s->sdbus) << 16;
> + r |= sdbus_read_data(&s->sdbus) << 8;
> + r |= sdbus_read_data(&s->sdbus);
> }
> break;
> case R_CLK2XDIV:
> @@ -206,10 +206,10 @@ static void memcard_write(void *opaque, hwaddr addr,
> uint64_t value,
> if (!s->enabled) {
> break;
> }
> - sd_write_data(s->card, (value >> 24) & 0xff);
> - sd_write_data(s->card, (value >> 16) & 0xff);
> - sd_write_data(s->card, (value >> 8) & 0xff);
> - sd_write_data(s->card, value & 0xff);
> + sdbus_write_data(&s->sdbus, (value >> 24) & 0xff);
> + sdbus_write_data(&s->sdbus, (value >> 16) & 0xff);
> + sdbus_write_data(&s->sdbus, (value >> 8) & 0xff);
> + sdbus_write_data(&s->sdbus, value & 0xff);
> break;
> case R_ENABLE:
> s->regs[addr] = value;
> @@ -266,15 +266,23 @@ static int milkymist_memcard_init(SysBusDevice *dev)
> static void milkymist_memcard_realize(DeviceState *dev, Error **errp)
> {
> MilkymistMemcardState *s = MILKYMIST_MEMCARD(dev);
> + DeviceState *carddev;
> BlockBackend *blk;
> DriveInfo *dinfo;
> + Error *err = NULL;
>
> + qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
> + dev, "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);
> blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
> - s->card = sd_init(blk, false);
> - if (s->card == NULL) {
> - error_setg(errp, "failed to init SD card");
> + carddev = qdev_create(&s->sdbus.qbus, TYPE_SD_CARD);
> + qdev_prop_set_drive(carddev, "drive", blk, &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;
> }
> s->enabled = blk && blk_is_inserted(blk);
> --
> 2.15.1
>
>
- [Qemu-arm] [PATCH 0/6] SDHCI: convert legacy devices to the SDBus API, Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2018/01/03
- Re: [Qemu-arm] [Qemu-devel] [PATCH 3/6] hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it,
Alistair Francis <=
- [Qemu-arm] [PATCH 4/6] hw/sd/pl181: expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 6/6] hw/sd: move sdcard legacy API to "hw/sd/sdcard_legacy.h", Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 1/6] hw/sd/milkymist-memcard: use qemu_log_mask(), Philippe Mathieu-Daudé, 2018/01/03
- [Qemu-arm] [PATCH 2/6] hw/sd/milkymist-memcard: split realize() out of SysBusDevice init(), Philippe Mathieu-Daudé, 2018/01/03