Skip to contentSkip to conversation

ppc/e500: Add support for two types of flash, cleanup

PATCH Superseded Philippe Mathieu-Daudé 2 participants 18 messages Oct 31, 2022 – Nov 1, 2022

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover ppc/e500: Add support for two types of flash, cleanup

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:
https://lore.kernel.org/qemu-devel/[email protected]/

Only tested with the ppce500 machine (no further regression testing).

Since v4:
- Do not rename ESDHC_* definitions to USDHC_*
- Do not modify SDHCIState structure

Bernhard Beschow (4):
hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power
of two
docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s) hw/ppc/e500: Implement pflash handling
hw/ppc/e500: Add Freescale eSDHC to e500plat

Philippe Mathieu-Daudé (2):
hw/sd/sdhci: MMIO region is implemented in 32-bit accesses hw/sd/sdhci: Map host controller interface in host endianess

 docs/system/ppc/ppce500.rst |  38 +++++++++--
 hw/block/pflash_cfi01.c     |   8 ++-
 hw/block/pflash_cfi02.c     |   5 ++
 hw/ppc/Kconfig              |   3 +
 hw/ppc/e500.c               | 127 +++++++++++++++++++++++++++++++++++-
 hw/ppc/e500.h               |   1 +
 hw/ppc/e500plat.c           |   1 +
 hw/sd/sdhci.c               |   6 +-
 8 files changed, 180 insertions(+), 9 deletions(-)
Signature · 1 line
2.37.3
#1 lore raw

PATCH v5 1/6 hw/sd/sdhci: MMIO region is implemented in 32-bit accesses

---
 hw/sd/sdhci.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/sd/sdhci.c +4 -0
index 0e5e988927..f9c5b58e6d 100644
@@ -1332,6 +1332,10 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 static const MemoryRegionOps sdhci_mmio_ops = {
     .read = sdhci_read,
     .write = sdhci_write,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
     .valid = {
         .min_access_size = 1,
         .max_access_size = 4,
Signature · 1 line
2.37.3
Reviewed-by on v5 1/6
#2 lore raw

Re: [PATCH v5 1/6] hw/sd/sdhci: MMIO region is implemented in 32-bit accesses

Am 31. Oktober 2022 11:53:57 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 1 line

Indeed there is offset & ~0x3 in both sdhci_{read,write}, so:

Quoted 19 lines

---
hw/sd/sdhci.c | 4 ++++

1 file changed, 4 insertions(+)
hw/sd/sdhci.c +4 -0
index 0e5e988927..f9c5b58e6d 100644
@@ -1332,6 +1332,10 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 static const MemoryRegionOps sdhci_mmio_ops = {
    .read = sdhci_read,
    .write = sdhci_write,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
    .valid = {
        .min_access_size = 1,
        .max_access_size = 4,
#3 lore raw

RFC PATCH v5 2/6 hw/sd/sdhci: Map host controller interface in host endianess

In reply to Philippe Mathieu-Daudé
---
 hw/sd/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
index f9c5b58e6d..40f37694d5 100644
@@ -1341,7 +1341,7 @@ static const MemoryRegionOps sdhci_mmio_ops = {
         .max_access_size = 4,
         .unaligned = false
     },
-    .endianness = DEVICE_LITTLE_ENDIAN,
+    .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
 static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp)
Signature · 1 line
2.37.3
#4 lore raw

Re: [RFC PATCH v5 2/6] hw/sd/sdhci: Map host controller interface in host endianess

Quoted 10 lines · Philippe Mathieu-Daudé
---
  hw/sd/sdhci.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +0 -0
index f9c5b58e6d..40f37694d5 100644

hw/sd/sdhci.c static const MemoryRegionOps sdhci_mmio_ops = { · line 1345

Quoted 6 lines
hw/sd/sdhci.c +1 -1
@@ -1341,7 +1341,7 @@ static const MemoryRegionOps sdhci_mmio_ops = {
          .max_access_size = 4,
          .unaligned = false
      },
-    .endianness = DEVICE_LITTLE_ENDIAN,
+    .endianness = DEVICE_NATIVE_ENDIAN,
  };

RFC because I was focusing on the SDHCI device and wanted some code Bernhard could test. I expect something in the CCSR block doing the endianness swapping.

#5 lore raw

PATCH v5 3/6 hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power of two

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

According to the JEDEC standard the device length is communicated to an OS as an exponent (power of two).

Message-Id: <[email protected]>

---
 hw/block/pflash_cfi01.c | 8 ++++++--
 hw/block/pflash_cfi02.c | 5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)
hw/block/pflash_cfi01.c +6 -2
index 0cbc2fb4cb..9c235bf66e 100644
@@ -690,7 +690,7 @@ static const MemoryRegionOps pflash_cfi01_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl)
+static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl, Error **errp)
 {
     uint64_t blocks_per_device, sector_len_per_device, device_len;
     int num_devices;
@@ -708,6 +708,10 @@ static void pflash_cfi01_fill_cfi_table(PFlashCFI01 *pfl)
         sector_len_per_device = pfl->sector_len / num_devices;
     }
     device_len = sector_len_per_device * blocks_per_device;
+    if (!is_power_of_2(device_len)) {
+        error_setg(errp, "Device size must be a power of two.");
+        return;
+    }
 
     /* Hardcoded CFI table */
     /* Standard "QRY" string */
@@ -865,7 +869,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
      */
     pfl->cmd = 0x00;
     pfl->status = 0x80; /* WSM ready */
-    pflash_cfi01_fill_cfi_table(pfl);
+    pflash_cfi01_fill_cfi_table(pfl, errp);
 }
 
 static void pflash_cfi01_system_reset(DeviceState *dev)
hw/block/pflash_cfi02.c +5 -0
index 2a99b286b0..ff2fe154c1 100644
@@ -880,6 +880,11 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    if (!is_power_of_2(pfl->chip_len)) {
+        error_setg(errp, "Device size must be a power of two.");
+        return;
+    }
+
     memory_region_init_rom_device(&pfl->orig_mem, OBJECT(pfl),
                                   &pflash_cfi02_ops, pfl, pfl->name,
                                   pfl->chip_len, errp);
Signature · 1 line
2.37.3
#6 lore raw

PATCH v5 4/6 docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s)

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

The documentation suggests that there is a qemu-system-ppc32 binary while the 32 bit version is actually just named qemu-system-ppc. Settle on qemu-system-ppc64 which also works for 32 bit machines and causes less clutter in the documentation.

Message-Id: <[email protected]>

---
 docs/system/ppc/ppce500.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
docs/system/ppc/ppce500.rst +5 -5
index ba6bcb7314..7b5eb3c4ee 100644
@@ -113,7 +113,7 @@ To boot the 32-bit Linux kernel:
 
 .. code-block:: bash
 
-  $ qemu-system-ppc{64|32} -M ppce500 -cpu e500mc -smp 4 -m 2G \
+  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
       -display none -serial stdio \
       -kernel vmlinux \
       -initrd /path/to/rootfs.cpio \
@@ -154,10 +154,10 @@ interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:
 
 .. code-block:: bash
 
-  $ qemu-system-ppc -M ppce500 -smp 4 -m 2G \
-                    -display none -serial stdio \
-                    -bios u-boot \
-                    -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
+  $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \
+                      -display none -serial stdio \
+                      -bios u-boot \
+                      -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
 
 The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device
 if “-device eTSEC” is given to QEMU:
Signature · 1 line
2.37.3
#7 lore raw

PATCH v5 5/6 hw/ppc/e500: Implement pflash handling

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Allows e500 boards to have their root file system reside on flash using only builtin devices located in the eLBC memory region.

Note that the flash memory area is only created when a -pflash argument is given, and that the size is determined by the given file. The idea is to put users into control.

Message-Id: <[email protected]>

[PMD: Use memory_region_size()]
---
 docs/system/ppc/ppce500.rst | 16 ++++++++
 hw/ppc/Kconfig              |  1 +
 hw/ppc/e500.c               | 79 +++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)
docs/system/ppc/ppce500.rst +16 -0
index 7b5eb3c4ee..38f8ceb0cf 100644
@@ -165,3 +165,19 @@ if “-device eTSEC” is given to QEMU:
 .. code-block:: bash
 
   -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0
+
+Root file system on flash drive
+-------------------------------
+
+Rather than using a root file system on ram disk, it is possible to have it on
+CFI flash. Given an ext2 image whose size must be a power of two, it can be used
+as follows:
+
+.. code-block:: bash
+
+  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
+      -display none -serial stdio \
+      -kernel vmlinux \
+      -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \
+      -append "rootwait root=/dev/mtdblock0"
+
hw/ppc/Kconfig +1 -0
index 791fe78a50..769a1ead1c 100644
@@ -126,6 +126,7 @@ config E500
     select ETSEC
     select GPIO_MPC8XXX
     select OPENPIC
+    select PFLASH_CFI01
     select PLATFORM_BUS
     select PPCE500_PCI
     select SERIAL
hw/ppc/e500.c +79 -0

117 lines not on this page · raw message

Signature · 1 line
2.37.3
#8 lore raw

PATCH v5 6/6 hw/ppc/e500: Add Freescale eSDHC to e500plat

In reply to Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Adds missing functionality to e500plat machine which increases the chance of given "real" firmware images to access SD cards.

Message-Id: <[email protected]>

[PMD: Simplify using create_unimplemented_device("esdhc")]
---
 docs/system/ppc/ppce500.rst | 12 ++++++++++
 hw/ppc/Kconfig              |  2 ++
 hw/ppc/e500.c               | 48 ++++++++++++++++++++++++++++++++++++-
 hw/ppc/e500.h               |  1 +
 hw/ppc/e500plat.c           |  1 +
 5 files changed, 63 insertions(+), 1 deletion(-)
docs/system/ppc/ppce500.rst +12 -0
index 38f8ceb0cf..c9fe0915dc 100644
@@ -19,6 +19,7 @@ The ``ppce500`` machine supports the following devices:
 * Power-off functionality via one GPIO pin
 * 1 Freescale MPC8xxx PCI host controller
 * VirtIO devices via PCI bus
+* 1 Freescale Enhanced Secure Digital Host controller (eSDHC)
 * 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC)
 
 Hardware configuration information
@@ -181,3 +182,14 @@ as follows:
       -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \
       -append "rootwait root=/dev/mtdblock0"
 
+Alternatively, the root file system can also reside on an emulated SD card
+whose size must again be a power of two:
+
+.. code-block:: bash
+
+  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
+      -display none -serial stdio \
+      -kernel vmlinux \
+      -device sd-card,drive=mydrive \
+      -drive id=mydrive,if=none,file=/path/to/rootfs.ext2,format=raw \
+      -append "rootwait root=/dev/mmcblk0"
hw/ppc/Kconfig +2 -0
index 769a1ead1c..c48aaaa9dc 100644
@@ -129,10 +129,12 @@ config E500
     select PFLASH_CFI01
     select PLATFORM_BUS
     select PPCE500_PCI
+    select SDHCI
     select SERIAL
     select MPC_I2C
     select FDT_PPC
     select DS1338
+    select UNIMP
 
 config E500PLAT
     bool
hw/ppc/e500.c +47 -1

89 lines not on this page · raw message

hw/ppc/e500.h +1 -0
index 68f754ce50..8c09ef92e4 100644
@@ -27,6 +27,7 @@ struct PPCE500MachineClass {
 
     int mpic_version;
     bool has_mpc8xxx_gpio;
+    bool has_esdhc;
     hwaddr platform_bus_base;
     hwaddr platform_bus_size;
     int platform_bus_first_irq;
hw/ppc/e500plat.c +1 -0
index 5bb1c603da..44bf874b0f 100644
@@ -86,6 +86,7 @@ static void e500plat_machine_class_init(ObjectClass *oc, void *data)
     pmc->fixup_devtree = e500plat_fixup_devtree;
     pmc->mpic_version = OPENPIC_MODEL_FSL_MPIC_42;
     pmc->has_mpc8xxx_gpio = true;
+    pmc->has_esdhc = true;
     pmc->platform_bus_base = 0xf00000000ULL;
     pmc->platform_bus_size = 128 * MiB;
     pmc->platform_bus_first_irq = 5;
Signature · 1 line
2.37.3
#9 lore raw

Re: [PATCH v5 6/6] hw/ppc/e500: Add Freescale eSDHC to e500plat

Quoted 31 lines · Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Adds missing functionality to e500plat machine which increases the chance of given "real" firmware images to access SD cards.

Message-Id: <[email protected]>

[PMD: Simplify using create_unimplemented_device("esdhc")]
---
  docs/system/ppc/ppce500.rst | 12 ++++++++++
  hw/ppc/Kconfig              |  2 ++
  hw/ppc/e500.c               | 48 ++++++++++++++++++++++++++++++++++++-
  hw/ppc/e500.h               |  1 +
  hw/ppc/e500plat.c           |  1 +
  5 files changed, 63 insertions(+), 1 deletion(-)
hw/ppc/e500.c +10 -0
@@ -992,6 +1018,26 @@ void ppce500_init(MachineState *machine)
      i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
      i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET);
 
+    /* eSDHC */
+    if (pmc->has_esdhc) {
+        uint64_t sdhci_regsize;
+
+        dev = qdev_new(TYPE_SYSBUS_SDHCI);
+        /*
+         * Compatible with:
+         * - SD Host Controller Specification Version 2.0 Part A2
+         */
+        qdev_prop_set_uint8(dev, "sd-spec-version", 2);

hw/ppc/e500.c void ppce500_init(MachineState *machine) · line 1040

Quoted 10 lines
hw/ppc/e500.c +10 -0
+        s = SYS_BUS_DEVICE(dev);
+        sysbus_realize_and_unref(s, &error_fatal);
+        sysbus_mmio_map(s, 0, pmc->ccsrbar_base + MPC85XX_ESDHC_REGS_OFFSET);
+        sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC85XX_ESDHC_IRQ));
+        sdhci_regsize = memory_region_size(sysbus_mmio_get_region(s, 0));
+        create_unimplemented_device("esdhc",
+                                    pmc->ccsrbar_base
+                                    + MPC85XX_ESDHC_REGS_OFFSET + sdhci_regsize,
+                                    MPC85XX_ESDHC_REGS_SIZE - sdhci_regsize);
+    }

Since the UNIMP device has lower priority, we can simplify as:

if (pmc->has_esdhc) {
    create_unimplemented_device("esdhc",
                                pmc->ccsrbar_base
                                + MPC85XX_ESDHC_REGS_OFFSET,
                                MPC85XX_ESDHC_REGS_SIZE);

    dev = qdev_new(TYPE_SYSBUS_SDHCI);
    /*
     * Compatible with:
     * - SD Host Controller Specification Version 2.0 Part A2
     */
    qdev_prop_set_uint8(dev, "sd-spec-version", 2);
    s = SYS_BUS_DEVICE(dev);
    sysbus_realize_and_unref(s, &error_fatal);
    sysbus_mmio_map(s, 0, pmc->ccsrbar_base + MPC85XX_ESDHC_REGS_OFFSET);
    sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, MPC85XX_ESDHC_IRQ));
}
#10 lore raw

Re: [PATCH v5 6/6] hw/ppc/e500: Add Freescale eSDHC to e500plat

Quoted 55 lines · Philippe Mathieu-Daudé
Quoted 43 lines · Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Adds missing functionality to e500plat machine which increases the chance of given "real" firmware images to access SD cards.

Message-Id: <[email protected]>

[PMD: Simplify using create_unimplemented_device("esdhc")]

---
  docs/system/ppc/ppce500.rst | 12 ++++++++++
  hw/ppc/Kconfig              |  2 ++
  hw/ppc/e500.c               | 48 ++++++++++++++++++++++++++++++++++++- hw/ppc/e500.h               |  1 +
  hw/ppc/e500plat.c           |  1 +

  5 files changed, 63 insertions(+), 1 deletion(-)
hw/ppc/e500.c +19 -0
@@ -992,6 +1018,26 @@ void ppce500_init(MachineState *machine)
       i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
       i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET);
+    /* eSDHC */
+    if (pmc->has_esdhc) {
+        uint64_t sdhci_regsize;
+
+        dev = qdev_new(TYPE_SYSBUS_SDHCI);
+        /*
+         * Compatible with:
+         * - SD Host Controller Specification Version 2.0 Part A2
+         */
+        qdev_prop_set_uint8(dev, "sd-spec-version", 2);
+        s = SYS_BUS_DEVICE(dev);
+        sysbus_realize_and_unref(s, &error_fatal);
+        sysbus_mmio_map(s, 0, pmc->ccsrbar_base + 
 MPC85XX_ESDHC_REGS_OFFSET);
+        sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev, 
 MPC85XX_ESDHC_IRQ));
+        sdhci_regsize = memory_region_size(sysbus_mmio_get_region(s, 
 0));
+        create_unimplemented_device("esdhc",
+                                    pmc->ccsrbar_base
+                                    + MPC85XX_ESDHC_REGS_OFFSET + 
 sdhci_regsize,
+                                    MPC85XX_ESDHC_REGS_SIZE - 
Quoted 2 lines

sdhci_regsize);
+    }

Since the UNIMP device has lower priority, we can simplify as:

if (pmc->has_esdhc) {
    create_unimplemented_device("esdhc", pmc->ccsrbar_base
                                + MPC85XX_ESDHC_REGS_OFFSET, MPC85XX_ESDHC_REGS_SIZE);

Quoted 9 lines

    dev = qdev_new(TYPE_SYSBUS_SDHCI);
    /*
     * Compatible with:
     * - SD Host Controller Specification Version 2.0 Part A2 */
    qdev_prop_set_uint8(dev, "sd-spec-version", 2);
    s = SYS_BUS_DEVICE(dev);
    sysbus_realize_and_unref(s, &error_fatal); sysbus_mmio_map(s, 0, pmc->ccsrbar_base + MPC85XX_ESDHC_REGS_OFFSET);

So the SDHCI is mapped inside the CCSR block. Better would be to map it into ccsr_addr_space.

I presume the CCSR is the device responsible of endian swapping, but TBH I have no clue about this board.

#11 lore raw

Re: [PATCH v5 6/6] hw/ppc/e500: Add Freescale eSDHC to e500plat

Quoted 65 lines · Philippe Mathieu-Daudé
Quoted 49 lines · Philippe Mathieu-Daudé
Quoted 43 lines · Philippe Mathieu-Daudé

From: Bernhard Beschow <[email protected]>

Adds missing functionality to e500plat machine which increases the chance of given "real" firmware images to access SD cards.

Message-Id: <[email protected]>

[PMD: Simplify using create_unimplemented_device("esdhc")]
---
  docs/system/ppc/ppce500.rst | 12 ++++++++++
  hw/ppc/Kconfig              |  2 ++
  hw/ppc/e500.c               | 48 ++++++++++++++++++++++++++++++++++++-
  hw/ppc/e500.h               |  1 +
  hw/ppc/e500plat.c           |  1 +
  5 files changed, 63 insertions(+), 1 deletion(-)
hw/ppc/e500.c +19 -0
@@ -992,6 +1018,26 @@ void ppce500_init(MachineState *machine)
      i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
      i2c_slave_create_simple(i2c, "ds1338", RTC_REGS_OFFSET);
+    /* eSDHC */
+    if (pmc->has_esdhc) {
+        uint64_t sdhci_regsize;
+
+        dev = qdev_new(TYPE_SYSBUS_SDHCI);
+        /*
+         * Compatible with:
+         * - SD Host Controller Specification Version 2.0 Part A2
+         */
+        qdev_prop_set_uint8(dev, "sd-spec-version", 2);
+        s = SYS_BUS_DEVICE(dev);
+        sysbus_realize_and_unref(s, &error_fatal);
+        sysbus_mmio_map(s, 0, pmc->ccsrbar_base +
 MPC85XX_ESDHC_REGS_OFFSET);
+        sysbus_connect_irq(s, 0, qdev_get_gpio_in(mpicdev,
 MPC85XX_ESDHC_IRQ));
+        sdhci_regsize = memory_region_size(sysbus_mmio_get_region(s,
 0));
+        create_unimplemented_device("esdhc",
+                                    pmc->ccsrbar_base
+                                    + MPC85XX_ESDHC_REGS_OFFSET +
 sdhci_regsize,
+                                    MPC85XX_ESDHC_REGS_SIZE -
Quoted 2 lines

sdhci_regsize);
+ }

Since the UNIMP device has lower priority, we can simplify as:

Quoted 15 lines
if (pmc->has_esdhc) {
     create_unimplemented_device("esdhc",
                                 pmc->ccsrbar_base
                                 + MPC85XX_ESDHC_REGS_OFFSET,
                                 MPC85XX_ESDHC_REGS_SIZE);

     dev = qdev_new(TYPE_SYSBUS_SDHCI);
     /*
      * Compatible with:
      * - SD Host Controller Specification Version 2.0 Part A2
      */
     qdev_prop_set_uint8(dev, "sd-spec-version", 2);
     s = SYS_BUS_DEVICE(dev);
     sysbus_realize_and_unref(s, &error_fatal);
     sysbus_mmio_map(s, 0, pmc->ccsrbar_base +
Quoted 2 lines

MPC85XX_ESDHC_REGS_OFFSET);

memory_region_add_subregion(ccsr_addr_space, MPC85XX_ESDHC_REGS_OFFSET,

                              sysbus_mmio_get_region(s, 0));

seems to be equivalent, works as well and mimics other devices, e.g. i2c. So perhaps use that?

Quoted 4 lines

So the SDHCI is mapped inside the CCSR block. Better would be to map it into ccsr_addr_space.

Doesn't the above code map it into ccsr_addr_space?

Quoted 5 lines

I presume the CCSR is the device responsible of endian swapping, but TBH I have no clue about this board.

Tested-by on the v5 series
#12 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

https://lore.kernel.org/qemu-devel/[email protected]/

Only tested with the ppce500 machine (no further regression testing).

Since v4:
- Do not rename ESDHC_* definitions to USDHC_*
- Do not modify SDHCIState structure

Works beautifully, both for the buildroot load and for my proprietary load. So:

Quoted 26 lines

Bernhard Beschow (4):
hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power
of two
docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s) hw/ppc/e500: Implement pflash handling
hw/ppc/e500: Add Freescale eSDHC to e500plat

Philippe Mathieu-Daudé (2):
hw/sd/sdhci: MMIO region is implemented in 32-bit accesses hw/sd/sdhci: Map host controller interface in host endianess

 docs/system/ppc/ppce500.rst |  38 +++++++++--
 hw/block/pflash_cfi01.c     |   8 ++-
 hw/block/pflash_cfi02.c     |   5 ++
 hw/ppc/Kconfig              |   3 +
 hw/ppc/e500.c               | 127 +++++++++++++++++++++++++++++++++++-
 hw/ppc/e500.h               |   1 +
 hw/ppc/e500plat.c           |   1 +
 hw/sd/sdhci.c               |   6 +-
 8 files changed, 180 insertions(+), 9 deletions(-)

--
2.37.3

#13 lore raw

Am 1. November 2022 10:41:51 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 10 lines
Quoted 7 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

https://lore.kernel.org/qemu-devel/[email protected]/

Only tested with the ppce500 machine (no further regression testing).

Quoted 20 lines
Quoted 4 lines

Since v4:
- Do not rename ESDHC_* definitions to USDHC_*
- Do not modify SDHCIState structure

Works beautifully, both for the buildroot load and for my proprietary load. So:

Quoted 11 lines

Bernhard Beschow (4):
hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power
of two
docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s) hw/ppc/e500: Implement pflash handling
hw/ppc/e500: Add Freescale eSDHC to e500plat

Philippe Mathieu-Daudé (2):
hw/sd/sdhci: MMIO region is implemented in 32-bit accesses hw/sd/sdhci: Map host controller interface in host endianess

Hi Phil,

Is there a chance to get this in for 7.2?

Best regards,
Bernhard

Quoted 15 lines
Quoted 15 lines
 docs/system/ppc/ppce500.rst |  38 +++++++++--
 hw/block/pflash_cfi01.c     |   8 ++-
 hw/block/pflash_cfi02.c     |   5 ++
 hw/ppc/Kconfig              |   3 +
 hw/ppc/e500.c               | 127 +++++++++++++++++++++++++++++++++++-
 hw/ppc/e500.h               |   1 +
 hw/ppc/e500plat.c           |   1 +
 hw/sd/sdhci.c               |   6 +-
 8 files changed, 180 insertions(+), 9 deletions(-)

--
2.37.3

#14 lore raw
Quoted 28 lines · Bernhard Beschow

Am 1. November 2022 10:41:51 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 27 lines
Quoted 11 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

https://lore.kernel.org/qemu-devel/[email protected]/

Only tested with the ppce500 machine (no further regression testing).

Since v4:
- Do not rename ESDHC_* definitions to USDHC_*
- Do not modify SDHCIState structure

Works beautifully, both for the buildroot load and for my proprietary load. So:

Quoted 8 lines

Bernhard Beschow (4):
hw/block/pflash_cfi0{1, 2}: Error out if device length isn't a power
of two
docs/system/ppc/ppce500: Use qemu-system-ppc64 across the board(s) hw/ppc/e500: Implement pflash handling
hw/ppc/e500: Add Freescale eSDHC to e500plat

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Philippe Mathieu-Daudé (2):
hw/sd/sdhci: MMIO region is implemented in 32-bit accesses hw/sd/sdhci: Map host controller interface in host endianess

Hi Phil,

Is there a chance to get this in for 7.2?

Well 1/ can you review patch #1 and 2/ we need to figure out what to do with patch #2 :) Can you point me to the CCSR datasheet?

#15 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Bernhard Beschow

Am 1. November 2022 10:41:51 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 6 lines
Quoted 3 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

https://lore.kernel.org/qemu-devel/[email protected]/

Hi Phil,

Is there a chance to get this in for 7.2?

Well 1/ can you review patch #1 and 2/ we need to figure out what to do with patch #2 :) Can you point me to the CCSR datasheet?

Maybe I found it, I'm looking at the "MPC8544E PowerQUICC III Integrated Host Processor Family Reference Manual, Rev. 1".

#16 lore raw
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Bernhard Beschow

Am 1. November 2022 10:41:51 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 7 lines
Quoted 4 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Hi Phil,

Is there a chance to get this in for 7.2?

Well 1/ can you review patch #1 and 2/ we need to figure out what to do with patch #2 :) Can you point me to the CCSR datasheet?

Maybe I found it, I'm looking at the "MPC8544E PowerQUICC III Integrated Host Processor Family Reference Manual, Rev. 1".

On "Table 2-11. CCSR Block Base Address Map" I see the 0x2_7000–0x3_0FFF region marked as 'Reserved'. How does the eSDHC end mapped there?

#17 lore raw
In reply to Philippe Mathieu-Daudé

Am 1. November 2022 17:43:46 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Bernhard Beschow
Quoted 8 lines

Am 1. November 2022 10:41:51 UTC schrieb Bernhard Beschow <[email protected]>:

Quoted 7 lines
Quoted 4 lines · Philippe Mathieu-Daudé

This is a respin of Bernhard's v4 with Freescale eSDHC implemented as an 'UNIMP' region. See v4 cover here:

https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Hi Phil,

Is there a chance to get this in for 7.2?

Well 1/ can you review patch #1 and 2/ we need to figure out what to do with patch #2 :) Can you point me to the CCSR datasheet?

Maybe I found it, I'm looking at the "MPC8544E PowerQUICC III Integrated Host Processor Family Reference Manual, Rev. 1".

This document looks similar to mine: https://www.nxp.com/docs/en/reference-manual/MPC8569ERM.pdf

Best regards,
Bernhard