qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] integrator/cp: Wire up MMC card detection
@ 2015-01-30 20:19 Jan Kiszka
  2015-02-03 18:03 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2015-01-30 20:19 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel

This allows to use MMC emulation with the Integrator/CP model. Well,
mostly. There seems to be timing issues with Linux so that the card is
not always detected (but most of the time).

Note that the read-only pin is intentionally left unconnected because
the PIC model could deliver it incorrectly as interrupt to the guest
while the spec says that this pin is just for status reading.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/arm/integratorcp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 8c48b68..0efadc4 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -477,7 +477,7 @@ static void integratorcp_init(MachineState *machine)
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
     qemu_irq pic[32];
-    DeviceState *dev;
+    DeviceState *dev, *sic;
     int i;
     Error *err = NULL;
 
@@ -535,7 +535,7 @@ static void integratorcp_init(MachineState *machine)
     for (i = 0; i < 32; i++) {
         pic[i] = qdev_get_gpio_in(dev, i);
     }
-    sysbus_create_simple(TYPE_INTEGRATOR_PIC, 0xca000000, pic[26]);
+    sic = sysbus_create_simple(TYPE_INTEGRATOR_PIC, 0xca000000, pic[26]);
     sysbus_create_varargs("integrator_pit", 0x13000000,
                           pic[5], pic[6], pic[7], NULL);
     sysbus_create_simple("pl031", 0x15000000, pic[8]);
@@ -545,7 +545,10 @@ static void integratorcp_init(MachineState *machine)
     sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]);
     sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]);
     sysbus_create_simple(TYPE_INTEGRATOR_DEBUG, 0x1a000000, 0);
-    sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
+    dev = sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
+    /* Wire up MMC card detect */
+    qdev_connect_gpio_out(dev, 1, qdev_get_gpio_in(sic, 3));
+
     if (nd_table[0].used)
         smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] integrator/cp: Wire up MMC card detection
  2015-01-30 20:19 [Qemu-devel] [PATCH] integrator/cp: Wire up MMC card detection Jan Kiszka
@ 2015-02-03 18:03 ` Peter Maydell
  2015-02-03 20:21   ` Jan Kiszka
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2015-02-03 18:03 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

On 30 January 2015 at 20:19, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> This allows to use MMC emulation with the Integrator/CP model. Well,
> mostly. There seems to be timing issues with Linux so that the card is
> not always detected (but most of the time).
>
> Note that the read-only pin is intentionally left unconnected because
> the PIC model could deliver it incorrectly as interrupt to the guest
> while the spec says that this pin is just for status reading.

I'm not sure what you mean here. The WPROT signal isn't wired
up to the SIC at all as far as I can see -- it's just a read-only
bit in the CP_INTREG register in what we model as "icp_control".

Your patch doesn't seem to do anything with the icp_control at all,
which doesn't look right, because the docs say that to clear the
'card insert' interrupt reported by the SIC you need to write
to the CP_INTREG register.

The gpio out line from the PL181 is just a status line (high when
a card is present, low if not); there needs to be a latch somewhere
in here that gets reset by the CP_INTREG write, the PL181 line
isn't just wired directly to the SIC.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] integrator/cp: Wire up MMC card detection
  2015-02-03 18:03 ` Peter Maydell
@ 2015-02-03 20:21   ` Jan Kiszka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2015-02-03 20:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]

On 2015-02-03 19:03, Peter Maydell wrote:
> On 30 January 2015 at 20:19, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> This allows to use MMC emulation with the Integrator/CP model. Well,
>> mostly. There seems to be timing issues with Linux so that the card is
>> not always detected (but most of the time).
>>
>> Note that the read-only pin is intentionally left unconnected because
>> the PIC model could deliver it incorrectly as interrupt to the guest
>> while the spec says that this pin is just for status reading.
> 
> I'm not sure what you mean here. The WPROT signal isn't wired
> up to the SIC at all as far as I can see -- it's just a read-only
> bit in the CP_INTREG register in what we model as "icp_control".
> 
> Your patch doesn't seem to do anything with the icp_control at all,
> which doesn't look right, because the docs say that to clear the
> 'card insert' interrupt reported by the SIC you need to write
> to the CP_INTREG register.
> 
> The gpio out line from the PL181 is just a status line (high when
> a card is present, low if not); there needs to be a latch somewhere
> in here that gets reset by the CP_INTREG write, the PL181 line
> isn't just wired directly to the SIC.

Indeed, read this too quickly. Let's see if modeling this more correctly
will also improve the detection reliability.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-03 20:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 20:19 [Qemu-devel] [PATCH] integrator/cp: Wire up MMC card detection Jan Kiszka
2015-02-03 18:03 ` Peter Maydell
2015-02-03 20:21   ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).