Commit b4496b13bb51884681656c3470ba778c7e888c2b

Authored by Paul Brook
1 parent 82634c2d

PL080 qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
hw/pl080.c
... ... @@ -7,8 +7,7 @@
7 7 * This code is licenced under the GPL.
8 8 */
9 9  
10   -#include "hw.h"
11   -#include "primecell.h"
  10 +#include "sysbus.h"
12 11  
13 12 #define PL080_MAX_CHANNELS 8
14 13 #define PL080_CONF_E 0x1
... ... @@ -37,6 +36,7 @@ typedef struct {
37 36 } pl080_channel;
38 37  
39 38 typedef struct {
  39 + SysBusDevice busdev;
40 40 uint8_t tc_int;
41 41 uint8_t tc_mask;
42 42 uint8_t err_int;
... ... @@ -319,19 +319,35 @@ static CPUWriteMemoryFunc *pl080_writefn[] = {
319 319 pl080_write
320 320 };
321 321  
322   -/* The PL080 and PL081 are the same except for the number of channels
323   - they implement (8 and 2 respectively). */
324   -void *pl080_init(uint32_t base, qemu_irq irq, int nchannels)
  322 +static void pl08x_init(SysBusDevice *dev, int nchannels)
325 323 {
326 324 int iomemtype;
327   - pl080_state *s;
  325 + pl080_state *s = FROM_SYSBUS(pl080_state, dev);
328 326  
329   - s = (pl080_state *)qemu_mallocz(sizeof(pl080_state));
330 327 iomemtype = cpu_register_io_memory(0, pl080_readfn,
331 328 pl080_writefn, s);
332   - cpu_register_physical_memory(base, 0x00001000, iomemtype);
333   - s->irq = irq;
  329 + sysbus_init_mmio(dev, 0x1000, iomemtype);
  330 + sysbus_init_irq(dev, &s->irq);
334 331 s->nchannels = nchannels;
335 332 /* ??? Save/restore. */
336   - return s;
337 333 }
  334 +
  335 +static void pl080_init(SysBusDevice *dev)
  336 +{
  337 + pl08x_init(dev, 8);
  338 +}
  339 +
  340 +static void pl081_init(SysBusDevice *dev)
  341 +{
  342 + pl08x_init(dev, 2);
  343 +}
  344 +
  345 +/* The PL080 and PL081 are the same except for the number of channels
  346 + they implement (8 and 2 respectively). */
  347 +static void pl080_register_devices(void)
  348 +{
  349 + sysbus_register_dev("pl080", sizeof(pl080_state), pl080_init);
  350 + sysbus_register_dev("pl081", sizeof(pl080_state), pl081_init);
  351 +}
  352 +
  353 +device_init(pl080_register_devices)
... ...
hw/realview.c
... ... @@ -89,7 +89,7 @@ static void realview_init(ram_addr_t ram_size,
89 89 sysbus_create_simple("pl011", 0x1000c000, pic[15]);
90 90  
91 91 /* DMA controller is optional, apparently. */
92   - pl080_init(0x10030000, pic[24], 2);
  92 + sysbus_create_simple("pl081", 0x10030000, pic[24]);
93 93  
94 94 sysbus_create_simple("sp804", 0x10011000, pic[4]);
95 95 sysbus_create_simple("sp804", 0x10012000, pic[5]);
... ...
hw/versatilepb.c
... ... @@ -226,7 +226,7 @@ static void versatile_init(ram_addr_t ram_size,
226 226 sysbus_create_simple("pl011", 0x101f3000, pic[14]);
227 227 sysbus_create_simple("pl011", 0x10009000, sic[6]);
228 228  
229   - pl080_init(0x10130000, pic[17], 8);
  229 + sysbus_create_simple("pl080", 0x10130000, pic[17]);
230 230 sysbus_create_simple("sp804", 0x101e2000, pic[4]);
231 231 sysbus_create_simple("sp804", 0x101e3000, pic[5]);
232 232  
... ...