All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Niek Linnenbank <nieklinnenbank@gmail.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, jasowang@redhat.com,
	b.galvani@gmail.com, qemu-arm@nongnu.org, imammedo@redhat.com,
	alex.bennee@linaro.org
Subject: Re: [PATCH v8 08/18] hw/arm/allwinner: add SD/MMC host controller
Date: Thu, 16 Jul 2020 15:38:01 +0200	[thread overview]
Message-ID: <fb2469a5-6146-de4e-b07a-1c95e8d7e7c0@amsat.org> (raw)
In-Reply-To: <20200311221854.30370-9-nieklinnenbank@gmail.com>

On 3/11/20 11:18 PM, Niek Linnenbank wrote:
> The Allwinner System on Chip families sun4i and above contain
> an integrated storage controller for Secure Digital (SD) and
> Multi Media Card (MMC) interfaces. This commit adds support
> for the Allwinner SD/MMC storage controller with the following
> emulated features:
> 
>  * DMA transfers
>  * Direct FIFO I/O
>  * Short/Long format command responses
>  * Auto-Stop command (CMD12)
>  * Insert & remove card detection
> 
> The following boards are extended with the SD host controller:
> 
>  * Cubieboard (hw/arm/cubieboard.c)
>  * Orange Pi PC (hw/arm/orangepi.c)
> 
> Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/hw/arm/allwinner-a10.h   |   2 +
>  include/hw/arm/allwinner-h3.h    |   3 +
>  include/hw/sd/allwinner-sdhost.h | 135 +++++
>  hw/arm/allwinner-a10.c           |  11 +
>  hw/arm/allwinner-h3.c            |  15 +-
>  hw/arm/cubieboard.c              |  15 +
>  hw/arm/orangepi.c                |  16 +
>  hw/sd/allwinner-sdhost.c         | 854 +++++++++++++++++++++++++++++++
>  hw/arm/Kconfig                   |   1 +
>  hw/sd/Makefile.objs              |   1 +
>  hw/sd/trace-events               |   7 +
>  11 files changed, 1059 insertions(+), 1 deletion(-)
>  create mode 100644 include/hw/sd/allwinner-sdhost.h
>  create mode 100644 hw/sd/allwinner-sdhost.c
...

> +static uint64_t allwinner_sdhost_read(void *opaque, hwaddr offset,
> +                                      unsigned size)
> +{
> +    AwSdHostState *s = AW_SDHOST(opaque);
> +    uint32_t res = 0;
> +
> +    switch (offset) {
...

> +    case REG_SD_FIFO:      /* Read/Write FIFO */
> +        if (sdbus_data_ready(&s->sdbus)) {
> +            res = sdbus_read_data(&s->sdbus);
> +            res |= sdbus_read_data(&s->sdbus) << 8;
> +            res |= sdbus_read_data(&s->sdbus) << 16;
> +            res |= sdbus_read_data(&s->sdbus) << 24;

Also I'm a bit confused by the endianess here. Does the FIFO
uses a particular endianess?

> +            allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t));
> +            allwinner_sdhost_auto_stop(s);
> +            allwinner_sdhost_update_irq(s);
> +        } else {
> +            qemu_log_mask(LOG_GUEST_ERROR, "%s: no data ready on SD bus\n",
> +                          __func__);
> +        }
> +        break;
> +    default:
> +        qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset %"
> +                      HWADDR_PRIx"\n", __func__, offset);
> +        res = 0;
> +        break;
> +    }
> +
> +    trace_allwinner_sdhost_read(offset, res, size);
> +    return res;
> +}
> +
> +static void allwinner_sdhost_write(void *opaque, hwaddr offset,
> +                                   uint64_t value, unsigned size)
> +{
> +    AwSdHostState *s = AW_SDHOST(opaque);
> +
> +    trace_allwinner_sdhost_write(offset, value, size);
> +
> +    switch (offset) {
...

> +    case REG_SD_FIFO:      /* Read/Write FIFO */
> +        sdbus_write_data(&s->sdbus, value & 0xff);
> +        sdbus_write_data(&s->sdbus, (value >> 8) & 0xff);
> +        sdbus_write_data(&s->sdbus, (value >> 16) & 0xff);
> +        sdbus_write_data(&s->sdbus, (value >> 24) & 0xff);
> +        allwinner_sdhost_update_transfer_cnt(s, sizeof(uint32_t));
> +        allwinner_sdhost_auto_stop(s);
> +        allwinner_sdhost_update_irq(s);
> +        break;
> +    case REG_SD_RES_CRC:   /* Response CRC from card/eMMC */
> +    case REG_SD_DATA7_CRC: /* CRC Data 7 from card/eMMC */
> +    case REG_SD_DATA6_CRC: /* CRC Data 6 from card/eMMC */
> +    case REG_SD_DATA5_CRC: /* CRC Data 5 from card/eMMC */
> +    case REG_SD_DATA4_CRC: /* CRC Data 4 from card/eMMC */
> +    case REG_SD_DATA3_CRC: /* CRC Data 3 from card/eMMC */
> +    case REG_SD_DATA2_CRC: /* CRC Data 2 from card/eMMC */
> +    case REG_SD_DATA1_CRC: /* CRC Data 1 from card/eMMC */
> +    case REG_SD_DATA0_CRC: /* CRC Data 0 from card/eMMC */
> +    case REG_SD_CRC_STA:   /* CRC status from card/eMMC in write operation */
> +        break;
> +    default:
> +        qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset %"
> +                      HWADDR_PRIx"\n", __func__, offset);
> +        break;
> +    }
> +}
> +
> +static const MemoryRegionOps allwinner_sdhost_ops = {
> +    .read = allwinner_sdhost_read,
> +    .write = allwinner_sdhost_write,
> +    .endianness = DEVICE_NATIVE_ENDIAN,

Maybe this device is little endian only?

> +    .valid = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +    .impl.min_access_size = 4,
> +};


  parent reply	other threads:[~2020-07-16 13:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 22:18 [PATCH v8 00/18] Add Allwinner H3 SoC and Orange Pi PC Machine Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 01/18] hw/arm: add Allwinner H3 System-on-Chip Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 02/18] hw/arm: add Xunlong Orange Pi PC machine Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 03/18] hw/arm/allwinner-h3: add Clock Control Unit Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 04/18] hw/arm/allwinner-h3: add USB host controller Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 05/18] hw/arm/allwinner-h3: add System Control module Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 06/18] hw/arm/allwinner: add CPU Configuration module Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 07/18] hw/arm/allwinner: add Security Identifier device Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 08/18] hw/arm/allwinner: add SD/MMC host controller Niek Linnenbank
2020-07-16 13:22   ` Philippe Mathieu-Daudé
2020-07-16 13:38   ` Philippe Mathieu-Daudé [this message]
2020-03-11 22:18 ` [PATCH v8 09/18] hw/arm/allwinner-h3: add EMAC ethernet device Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 10/18] hw/arm/allwinner-h3: add Boot ROM support Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 11/18] hw/arm/allwinner-h3: add SDRAM controller device Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 12/18] hw/arm/allwinner: add RTC device support Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 13/18] tests/boot_linux_console: Add a quick test for the OrangePi PC board Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 14/18] tests/boot_linux_console: Add initrd test for the Orange Pi " Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 15/18] tests/boot_linux_console: Add a SD card test for the OrangePi " Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 16/18] tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 17/18] tests/boot_linux_console: Test booting NetBSD via U-Boot " Niek Linnenbank
2020-03-11 22:18 ` [PATCH v8 18/18] docs: add Orange Pi PC document Niek Linnenbank
2020-03-11 23:02 ` [PATCH v8 00/18] Add Allwinner H3 SoC and Orange Pi PC Machine no-reply
2020-03-12 16:22 ` Peter Maydell
2020-03-12 20:02   ` Niek Linnenbank

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=fb2469a5-6146-de4e-b07a-1c95e8d7e7c0@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alex.bennee@linaro.org \
    --cc=b.galvani@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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.