Skip to contentSkip to conversation

hw/arm/integratorcp: Map Audio controller and parallel flash

PATCH New Philippe Mathieu-Daudé 1 participant 3 messages Feb 23, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/arm/integratorcp: Map Audio controller and parallel flash

From: Philippe Mathieu-Daudé <[email protected]>

While looking whether Thomas's test patch [*] requires a respin or not, I noticed we could complete the integrator model. Thomas patch still applies properly ;)

[*] https://www.mail-archive.com/[email protected]/msg675828.html

Philippe Mathieu-Daudé (2):
hw/arm/integratorcp: Map the audio codec controller hw/arm/integratorcp: Map a CFI parallel flash

 hw/arm/integratorcp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Signature · 1 line
2.21.1
#1 lore raw

PATCH 1/2 hw/arm/integratorcp: Map the audio codec controller

From: Philippe Mathieu-Daudé <[email protected]>

The Linux kernel displays errors why trying to detect the PL041 audio interface:

Linux version 4.16.0 (linus@genomnajs) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #142 PREEMPT Wed May 9 13:24:55 CEST 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
OF: fdt: Machine model: ARM Integrator/CP
...
OF: amba_device_add() failed (-19) for /fpga/aaci@1d000000

Since we have it already modelled, simply plug it.

---
 hw/arm/integratorcp.c | 1 +
 1 file changed, 1 insertion(+)
hw/arm/integratorcp.c +1 -0
index 0cd94d9f09..59804140cd 100644
@@ -644,6 +644,7 @@ static void integratorcp_init(MachineState *machine)
                           qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_WPROT, 0));
     qdev_connect_gpio_out(dev, 1,
                           qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_CARDIN, 0));
+    sysbus_create_varargs("pl041", 0x1d000000, pic[25], NULL);
 
     if (nd_table[0].used)
         smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
Signature · 1 line
2.21.1
#2 lore raw

RFC PATCH 2/2 hw/arm/integratorcp: Map a CFI parallel flash

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

The Linux kernel displays errors why trying to detect the flash:

Linux version 4.16.0 (linus@genomnajs) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #142 PREEMPT Wed May 9 13:24:55 CEST 2018
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
OF: fdt: Machine model: ARM Integrator/CP
...
of-flash 24000000.flash: Integrator/CP flash protection
of-flash 24000000.flash: do_map_probe() failed for type cfi_probe
of-flash 24000000.flash: do_map_probe() failed

Since we have a CFI pflash model available, wire it. The kernel properly detects it:

of-flash 24000000.flash: Integrator/CP flash protection
24000000.flash: Found 1 x32 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000 Intel/Sharp Extended Query Table at 0x0031
Using buffer write method

---
RFC because I have no idea of the flash model, its ID code, and which default CFI family (1 or 2).

---
 hw/arm/integratorcp.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
hw/arm/integratorcp.c +11 -0
index 59804140cd..40cedfd55a 100644
@@ -8,6 +8,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -24,6 +25,7 @@
 #include "hw/char/pl011.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
+#include "hw/block/flash.h"
 
 #define TYPE_INTEGRATOR_CM "integrator_core"
 #define INTEGRATOR_CM(obj) \
@@ -589,6 +591,7 @@ static void integratorcp_init(MachineState *machine)
     MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
     qemu_irq pic[32];
     DeviceState *dev, *sic, *icp;
+    DriveInfo *dinfo;
     int i;
 
     cpuobj = object_new(machine->cpu_type);
@@ -646,6 +649,14 @@ static void integratorcp_init(MachineState *machine)
                           qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_CARDIN, 0));
     sysbus_create_varargs("pl041", 0x1d000000, pic[25], NULL);
 
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!pflash_cfi01_register(0x24000000, "pflash", 16 * MiB,
+                               dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                               64 * KiB, 4, 0, 0, 0, 0, 0)) {
+        error_report("Error registering flash memory");
+        exit(1);
+    }
+
     if (nd_table[0].used)
         smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
 
Signature · 1 line
2.21.1