All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé via" <qemu-devel@nongnu.org>
To: Bernhard Beschow <shentey@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, qemu-block@nongnu.org,
	Hanna Reitz <hreitz@redhat.com>,
	Bin Meng <bin.meng@windriver.com>, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [PATCH v2 12/13] hw/sd/sdhci: Implement Freescale eSDHC device model
Date: Mon, 3 Oct 2022 23:11:23 +0200	[thread overview]
Message-ID: <aa253d5e-a2e3-e7b2-dace-87f21e64dc93@amsat.org> (raw)
In-Reply-To: <20221003203142.24355-13-shentey@gmail.com>

On 3/10/22 22:31, Bernhard Beschow wrote:
> Will allow e500 boards to access SD cards using just their own devices.
> 
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
>   hw/sd/sdhci.c         | 147 +++++++++++++++++++++++++++++++++++++++++-
>   include/hw/sd/sdhci.h |   3 +
>   2 files changed, 149 insertions(+), 1 deletion(-)

> +/* --- qdev Freescale eSDHC --- */
> +
> +/* Watermark Level Register */
> +#define ESDHC_WML                    0x44
> +
> +/* Host Controller Capabilities Register 2 */
> +#define ESDHC_CAPABILITIES_1        0x114

Not used?

> +
> +/* Control Register for DMA transfer */
> +#define ESDHC_DMA_SYSCTL            0x40c
> +
> +#define ESDHC_REGISTERS_MAP_SIZE    0x410
> +
> +static uint64_t esdhci_read(void *opaque, hwaddr offset, unsigned size)
> +{
> +    uint64_t ret;
> +
> +    if (size != 4) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC rd_%ub @0x%02" HWADDR_PRIx
> +                      " wrong size\n", size, offset);
> +        return 0;
> +    }
> +
> +    if (offset & 0x3) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC rd_%ub @0x%02" HWADDR_PRIx
> +                      " unaligned\n", size, offset);
> +        return 0;

Isn't it already enforced by esdhc_mmio_ops.valid.unaligned = false?

> +    }
> +
> +    switch (offset) {
> +    case SDHC_SYSAD:
> +    case SDHC_BLKSIZE:
> +    case SDHC_ARGUMENT:
> +    case SDHC_TRNMOD:
> +    case SDHC_RSPREG0:
> +    case SDHC_RSPREG1:
> +    case SDHC_RSPREG2:
> +    case SDHC_RSPREG3:
> +    case SDHC_BDATA:
> +    case SDHC_PRNSTS:
> +    case SDHC_HOSTCTL:
> +    case SDHC_CLKCON:
> +    case SDHC_NORINTSTS:
> +    case SDHC_NORINTSTSEN:
> +    case SDHC_NORINTSIGEN:
> +    case SDHC_ACMD12ERRSTS:
> +    case SDHC_CAPAB:
> +    case SDHC_SLOT_INT_STATUS:
> +        ret = sdhci_read(opaque, offset, size);
> +        break;
> +
> +    case ESDHC_WML:
> +    case ESDHC_DMA_SYSCTL:
> +        ret = 0;
> +        qemu_log_mask(LOG_UNIMP, "ESDHC rd_%ub @0x%02" HWADDR_PRIx
> +                      " not implemented\n", size, offset);
> +        break;
> +
> +    default:
> +        ret = 0;
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC rd_%ub @0x%02" HWADDR_PRIx
> +                      " unknown offset\n", size, offset);
> +        break;
> +    }
> +
> +    return ret;
> +}
> +
> +static void esdhci_write(void *opaque, hwaddr offset, uint64_t val,
> +                         unsigned size)
> +{
> +    if (size != 4) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC wr_%ub @0x%02" HWADDR_PRIx
> +                      " <- 0x%08lx wrong size\n", size, offset, val);
> +        return;
> +    }
> +
> +    if (offset & 0x3) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC wr_%ub @0x%02" HWADDR_PRIx
> +                      " <- 0x%08lx unaligned\n", size, offset, val);
> +        return;
> +    }
> +
> +    switch (offset) {
> +    case SDHC_SYSAD:
> +    case SDHC_BLKSIZE:
> +    case SDHC_ARGUMENT:
> +    case SDHC_TRNMOD:
> +    case SDHC_BDATA:
> +    case SDHC_HOSTCTL:
> +    case SDHC_CLKCON:
> +    case SDHC_NORINTSTS:
> +    case SDHC_NORINTSTSEN:
> +    case SDHC_NORINTSIGEN:
> +    case SDHC_FEAER:
> +        sdhci_write(opaque, offset, val, size);
> +        break;
> +
> +    case ESDHC_WML:
> +    case ESDHC_DMA_SYSCTL:
> +        qemu_log_mask(LOG_UNIMP, "ESDHC wr_%ub @0x%02" HWADDR_PRIx " <- 0x%08lx "
> +                      "not implemented\n", size, offset, val);
> +        break;
> +
> +    default:
> +        qemu_log_mask(LOG_GUEST_ERROR, "ESDHC wr_%ub @0x%02" HWADDR_PRIx
> +                      " <- 0x%08lx unknown offset\n", size, offset, val);
> +        break;
> +    }
> +}
> +
> +static const MemoryRegionOps esdhc_mmio_ops = {
> +    .read = esdhci_read,
> +    .write = esdhci_write,
> +    .valid = {
> +        .min_access_size = 1,
> +        .max_access_size = 4,
> +        .unaligned = false
> +    },
> +    .endianness = DEVICE_BIG_ENDIAN,
> +};


  reply	other threads:[~2022-10-03 22:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 20:31 [PATCH v2 00/13] ppc/e500: Add support for two types of flash, cleanup Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 01/13] hw/ppc/meson: Allow e500 boards to be enabled separately Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 02/13] hw/gpio/meson: Introduce dedicated config switch for hw/gpio/mpc8xxx Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 03/13] docs/system/ppc/ppce500: Add heading for networking chapter Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 04/13] hw/ppc/e500: Reduce usage of sysbus API Bernhard Beschow
2022-10-03 21:22   ` Philippe Mathieu-Daudé via
2022-10-09  2:18   ` Bin Meng
2022-10-03 20:31 ` [PATCH v2 05/13] hw/ppc/mpc8544ds: Rename wrongly named method Bernhard Beschow
2022-10-03 20:56   ` Philippe Mathieu-Daudé via
2022-10-09  2:21   ` Bin Meng
2022-10-03 20:31 ` [PATCH v2 06/13] hw/ppc/mpc8544ds: Add platform bus Bernhard Beschow
2022-10-09  3:21   ` Bin Meng
2022-10-03 20:31 ` [PATCH v2 07/13] hw/ppc/e500: Remove if statement which is now always true Bernhard Beschow
2022-10-03 21:36   ` Philippe Mathieu-Daudé via
2022-10-03 20:31 ` [PATCH v2 08/13] hw/block/pflash_cfi01: Error out if device length isn't a power of two Bernhard Beschow
2022-10-03 20:58   ` Philippe Mathieu-Daudé via
2022-10-03 20:31 ` [PATCH v2 09/13] hw/ppc/e500: Implement pflash handling Bernhard Beschow
2022-10-03 21:21   ` Philippe Mathieu-Daudé via
2022-10-04 22:21     ` Bernhard Beschow
2022-10-09  3:39   ` Bin Meng
2022-10-03 20:31 ` [PATCH v2 10/13] hw/sd/sdhci-internal: Unexport ESDHC defines Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 11/13] hw/sd/sdhci: Rename ESDHC_* defines to USDHC_* Bernhard Beschow
2022-10-03 20:31 ` [PATCH v2 12/13] hw/sd/sdhci: Implement Freescale eSDHC device model Bernhard Beschow
2022-10-03 21:11   ` Philippe Mathieu-Daudé via [this message]
2022-10-03 20:31 ` [PATCH v2 13/13] hw/ppc/e500: Add Freescale eSDHC to e500 boards Bernhard Beschow
2022-10-03 21:06   ` Philippe Mathieu-Daudé via
2022-10-04 22:51     ` Bernhard Beschow
2022-10-16 12:04     ` Bernhard Beschow
2022-10-03 21:27 ` [PATCH v2 00/13] ppc/e500: Add support for two types of flash, cleanup Philippe Mathieu-Daudé via
2022-10-04 12:43   ` Daniel Henrique Barboza
2022-10-08 16:11     ` Bernhard Beschow
2022-10-09  3:30       ` Bin Meng
2022-10-09 21:22         ` Daniel Henrique Barboza

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=aa253d5e-a2e3-e7b2-dace-87f21e64dc93@amsat.org \
    --to=qemu-devel@nongnu.org \
    --cc=bin.meng@windriver.com \
    --cc=f4bug@amsat.org \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=shentey@gmail.com \
    /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.