Skip to contentSkip to conversation

tusb6010: Convert to qdev

PATCH Applied Peter Maydell 2 participants 2 messages Aug 30, 2011 – Aug 31, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tusb6010: Convert to qdev

Convert the tusb6010 to qdev.

[Riku Voipio: Fixes and restructuring patchset]
[Peter Maydell: More fixes and cleanups for upstream submission]

---
The point of this patch (apart from qdevification being a general good thing) is that once all the usb-musb users are qdev devices there is some cleanup that can be done there. I have some patches for the usb-musb code which depend on this and which I'll submit when this goes in. (In particular, the slightly ugly allocation of an irq array in the tusb6010 init function can go away once usb-musb is qdev-aware.)

I have to admit that I wasn't able to find any n8x0 images which actively used the USB, but I have tested that this doesn't cause problems on init, at least.

 hw/nseries.c  |   31 ++++++---------
 hw/tusb6010.c |  115 ++++++++++++++++++++++++++++++++++++++++-----------------
 hw/tusb6010.h |   28 --------------
 3 files changed, 94 insertions(+), 80 deletions(-)
 delete mode 100644 hw/tusb6010.h
hw/nseries.c +13 -18
index f7ace99..af287dd 100644
@@ -32,7 +32,6 @@
 #include "bt.h"
 #include "loader.h"
 #include "blockdev.h"
-#include "tusb6010.h"
 #include "sysbus.h"
 
 /* Nokia N8x0 support */
@@ -50,7 +49,7 @@ struct n800_s {
     int keymap[0x80];
     DeviceState *kbd;
 
-    TUSBState *usb;
+    DeviceState *usb;
     void *retu;
     void *tahvo;
     DeviceState *nand;
@@ -765,25 +764,21 @@ static void n8x0_uart_setup(struct n800_s *s)
     omap_uart_attach(s->cpu->uart[BT_UART], radio);
 }
 
-static void n8x0_usb_power_cb(void *opaque, int line, int level)
-{
-    struct n800_s *s = opaque;
-
-    tusb6010_power(s->usb, level);
-}
-
 static void n8x0_usb_setup(struct n800_s *s)
 {
-    qemu_irq tusb_irq = qdev_get_gpio_in(s->cpu->gpio, N8X0_TUSB_INT_GPIO);
-    qemu_irq tusb_pwr = qemu_allocate_irqs(n8x0_usb_power_cb, s, 1)[0];
-    TUSBState *tusb = tusb6010_init(tusb_irq);
-
+    SysBusDevice *dev;
+    s->usb = qdev_create(NULL, "tusb6010");
+    dev = sysbus_from_qdev(s->usb);
+    qdev_init_nofail(s->usb);
+    sysbus_connect_irq(dev, 0,
+                       qdev_get_gpio_in(s->cpu->gpio, N8X0_TUSB_INT_GPIO));
     /* Using the NOR interface */
-    omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_ASYNC_CS, tusb6010_async_io(tusb));
-    omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_SYNC_CS, tusb6010_sync_io(tusb));
-
-    s->usb = tusb;
-    qdev_connect_gpio_out(s->cpu->gpio, N8X0_TUSB_ENABLE_GPIO, tusb_pwr);
+    omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_ASYNC_CS,
+                     sysbus_mmio_get_region(dev, 0));
+    omap_gpmc_attach(s->cpu->gpmc, N8X0_USB_SYNC_CS,
+                     sysbus_mmio_get_region(dev, 1));
+    qdev_connect_gpio_out(s->cpu->gpio, N8X0_TUSB_ENABLE_GPIO,
+                          qdev_get_gpio_in(s->usb, 0)); /* tusb_pwr */
 }
 
 /* Setup done before the main bootloader starts by some early setup code
hw/tusb6010.c +81 -34

150 lines not on this page · raw message

hw/tusb6010.h deleted +0 -28
deleted file mode 100644
index b85ee86..0000000
@@ -1,28 +0,0 @@
-/*
- * tusb6010 interfaces
- *
- * Copyright 2011 Red Hat, Inc. and/or its affiliates
- *
- * Authors:
- *  Avi Kivity <[email protected]>
- *
- * Derived from hw/devices.h.
- *
- * This work is licensed under the terms of the GNU GPL, version 2.  See
- * the COPYING file in the top-level directory.
- *
- */
-
-#ifndef TUSB6010_H
-#define TUSB6010_H
-
-#include "targphys.h"
-#include "memory.h"
-
-typedef struct TUSBState TUSBState;
-TUSBState *tusb6010_init(qemu_irq intr);
-MemoryRegion *tusb6010_sync_io(TUSBState *s);
-MemoryRegion *tusb6010_async_io(TUSBState *s);
-void tusb6010_power(TUSBState *s, int on);
-
-#endif
Signature · 1 line
1.7.1
#1 lore raw
Quoted 15 lines · Peter Maydell

Convert the tusb6010 to qdev.

[Riku Voipio: Fixes and restructuring patchset]
[Peter Maydell: More fixes and cleanups for upstream submission]

---
The point of this patch (apart from qdevification being a general good thing) is that once all the usb-musb users are qdev devices there is some cleanup that can be done there. I have some patches for the usb-musb code which depend on this and which I'll submit when this goes in. (In particular, the slightly ugly allocation of an irq array in the tusb6010 init function can go away once usb-musb is qdev-aware.)

Quoted 4 lines

I have to admit that I wasn't able to find any n8x0 images which actively used the USB, but I have tested that this doesn't cause problems on init, at least.

I've applied this. Thanks.

Cheers