diff options
author | hyokeun <hyokeun.jeon@samsung.com> | 2016-12-27 17:29:09 +0900 |
---|---|---|
committer | hyokeun <hyokeun.jeon@samsung.com> | 2016-12-27 17:29:09 +0900 |
commit | 2a84d37c88d606fda46a565bcc80e173b4d0a80a (patch) | |
tree | 8b755bb78271e76e13fb7db38b670dbc443479e7 /hw/gpio | |
parent | bd54c25035217800f3b1d39f6472d599cd602d5a (diff) | |
download | qemu-upstream.tar.gz qemu-upstream.tar.bz2 qemu-upstream.zip |
Imported Upstream version 2.6.1upstream/2.6.1upstream
Diffstat (limited to 'hw/gpio')
-rw-r--r-- | hw/gpio/gpio_key.c | 1 | ||||
-rw-r--r-- | hw/gpio/imx_gpio.c | 1 | ||||
-rw-r--r-- | hw/gpio/omap_gpio.c | 61 | ||||
-rw-r--r-- | hw/gpio/pl061.c | 25 | ||||
-rw-r--r-- | hw/gpio/zaurus.c | 14 |
5 files changed, 54 insertions, 48 deletions
diff --git a/hw/gpio/gpio_key.c b/hw/gpio/gpio_key.c index b34aa49df..ef287727b 100644 --- a/hw/gpio/gpio_key.c +++ b/hw/gpio/gpio_key.c @@ -24,7 +24,6 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "qemu/timer.h" #define TYPE_GPIOKEY "gpio-key" #define GPIOKEY(obj) OBJECT_CHECK(GPIOKEYState, (obj), TYPE_GPIOKEY) diff --git a/hw/gpio/imx_gpio.c b/hw/gpio/imx_gpio.c index f3574aa8f..ed7e247f5 100644 --- a/hw/gpio/imx_gpio.c +++ b/hw/gpio/imx_gpio.c @@ -19,7 +19,6 @@ #include "qemu/osdep.h" #include "hw/gpio/imx_gpio.h" -#include "qemu/log.h" #ifndef DEBUG_IMX_GPIO #define DEBUG_IMX_GPIO 0 diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c index dabef4a11..9b1b004fc 100644 --- a/hw/gpio/omap_gpio.c +++ b/hw/gpio/omap_gpio.c @@ -23,7 +23,6 @@ #include "hw/arm/omap.h" #include "hw/sysbus.h" #include "qemu/error-report.h" -#include "qapi/error.h" struct omap_gpio_s { qemu_irq irq; @@ -679,46 +678,48 @@ static const MemoryRegionOps omap2_gpif_top_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static void omap_gpio_init(Object *obj) +static int omap_gpio_init(SysBusDevice *sbd) { - DeviceState *dev = DEVICE(obj); - struct omap_gpif_s *s = OMAP1_GPIO(obj); - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + DeviceState *dev = DEVICE(sbd); + struct omap_gpif_s *s = OMAP1_GPIO(dev); + if (!s->clk) { + error_report("omap-gpio: clk not connected"); + return -1; + } qdev_init_gpio_in(dev, omap_gpio_set, 16); qdev_init_gpio_out(dev, s->omap1.handler, 16); sysbus_init_irq(sbd, &s->omap1.irq); - memory_region_init_io(&s->iomem, obj, &omap_gpio_ops, &s->omap1, + memory_region_init_io(&s->iomem, OBJECT(s), &omap_gpio_ops, &s->omap1, "omap.gpio", 0x1000); sysbus_init_mmio(sbd, &s->iomem); + return 0; } -static void omap_gpio_realize(DeviceState *dev, Error **errp) -{ - struct omap_gpif_s *s = OMAP1_GPIO(dev); - - if (!s->clk) { - error_setg(errp, "omap-gpio: clk not connected"); - } -} - -static void omap2_gpio_realize(DeviceState *dev, Error **errp) +static int omap2_gpio_init(SysBusDevice *sbd) { + DeviceState *dev = DEVICE(sbd); struct omap2_gpif_s *s = OMAP2_GPIO(dev); - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); int i; if (!s->iclk) { - error_setg(errp, "omap2-gpio: iclk not connected"); - return; + error_report("omap2-gpio: iclk not connected"); + return -1; } s->modulecount = s->mpu_model < omap2430 ? 4 - : s->mpu_model < omap3430 ? 5 - : 6; + : s->mpu_model < omap3430 ? 5 + : 6; + + for (i = 0; i < s->modulecount; i++) { + if (!s->fclk[i]) { + error_report("omap2-gpio: fclk%d not connected", i); + return -1; + } + } if (s->mpu_model < omap3430) { - memory_region_init_io(&s->iomem, OBJECT(dev), &omap2_gpif_top_ops, s, + memory_region_init_io(&s->iomem, OBJECT(s), &omap2_gpif_top_ops, s, "omap2.gpio", 0x1000); sysbus_init_mmio(sbd, &s->iomem); } @@ -731,20 +732,17 @@ static void omap2_gpio_realize(DeviceState *dev, Error **errp) for (i = 0; i < s->modulecount; i++) { struct omap2_gpio_s *m = &s->modules[i]; - if (!s->fclk[i]) { - error_setg(errp, "omap2-gpio: fclk%d not connected", i); - return; - } - m->revision = (s->mpu_model < omap3430) ? 0x18 : 0x25; m->handler = &s->handler[i * 32]; sysbus_init_irq(sbd, &m->irq[0]); /* mpu irq */ sysbus_init_irq(sbd, &m->irq[1]); /* dsp irq */ sysbus_init_irq(sbd, &m->wkup); - memory_region_init_io(&m->iomem, OBJECT(dev), &omap2_gpio_module_ops, m, + memory_region_init_io(&m->iomem, OBJECT(s), &omap2_gpio_module_ops, m, "omap.gpio-module", 0x1000); sysbus_init_mmio(sbd, &m->iomem); } + + return 0; } /* Using qdev pointer properties for the clocks is not ideal. @@ -768,8 +766,9 @@ static Property omap_gpio_properties[] = { static void omap_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - dc->realize = omap_gpio_realize; + k->init = omap_gpio_init; dc->reset = omap_gpif_reset; dc->props = omap_gpio_properties; /* Reason: pointer property "clk" */ @@ -780,7 +779,6 @@ static const TypeInfo omap_gpio_info = { .name = TYPE_OMAP1_GPIO, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(struct omap_gpif_s), - .instance_init = omap_gpio_init, .class_init = omap_gpio_class_init, }; @@ -799,8 +797,9 @@ static Property omap2_gpio_properties[] = { static void omap2_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - dc->realize = omap2_gpio_realize; + k->init = omap2_gpio_init; dc->reset = omap2_gpif_reset; dc->props = omap2_gpio_properties; /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */ diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c index 4ae2aa156..29dc7fc38 100644 --- a/hw/gpio/pl061.c +++ b/hw/gpio/pl061.c @@ -10,7 +10,6 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "qemu/log.h" //#define DEBUG_PL061 1 @@ -341,6 +340,20 @@ static const MemoryRegionOps pl061_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static int pl061_initfn(SysBusDevice *sbd) +{ + DeviceState *dev = DEVICE(sbd); + PL061State *s = PL061(dev); + + memory_region_init_io(&s->iomem, OBJECT(s), &pl061_ops, s, "pl061", 0x1000); + sysbus_init_mmio(sbd, &s->iomem); + sysbus_init_irq(sbd, &s->irq); + qdev_init_gpio_in(dev, pl061_set_irq, 8); + qdev_init_gpio_out(dev, s->out, 8); + + return 0; +} + static void pl061_luminary_init(Object *obj) { PL061State *s = PL061(obj); @@ -352,23 +365,17 @@ static void pl061_luminary_init(Object *obj) static void pl061_init(Object *obj) { PL061State *s = PL061(obj); - DeviceState *dev = DEVICE(obj); - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); s->id = pl061_id; s->rsvd_start = 0x424; - - memory_region_init_io(&s->iomem, obj, &pl061_ops, s, "pl061", 0x1000); - sysbus_init_mmio(sbd, &s->iomem); - sysbus_init_irq(sbd, &s->irq); - qdev_init_gpio_in(dev, pl061_set_irq, 8); - qdev_init_gpio_out(dev, s->out, 8); } static void pl061_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + k->init = pl061_initfn; dc->vmsd = &vmstate_pl061; dc->reset = &pl061_reset; } diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c index 15865e108..555da281c 100644 --- a/hw/gpio/zaurus.c +++ b/hw/gpio/zaurus.c @@ -167,18 +167,19 @@ static void scoop_gpio_set(void *opaque, int line, int level) s->gpio_level &= ~(1 << line); } -static void scoop_init(Object *obj) +static int scoop_init(SysBusDevice *sbd) { - DeviceState *dev = DEVICE(obj); - ScoopInfo *s = SCOOP(obj); - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + DeviceState *dev = DEVICE(sbd); + ScoopInfo *s = SCOOP(dev); s->status = 0x02; qdev_init_gpio_out(dev, s->handler, 16); qdev_init_gpio_in(dev, scoop_gpio_set, 16); - memory_region_init_io(&s->iomem, obj, &scoop_ops, s, "scoop", 0x1000); + memory_region_init_io(&s->iomem, OBJECT(s), &scoop_ops, s, "scoop", 0x1000); sysbus_init_mmio(sbd, &s->iomem); + + return 0; } static int scoop_post_load(void *opaque, int version_id) @@ -238,7 +239,9 @@ static const VMStateDescription vmstate_scoop_regs = { static void scoop_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); + k->init = scoop_init; dc->desc = "Scoop2 Sharp custom ASIC"; dc->vmsd = &vmstate_scoop_regs; } @@ -247,7 +250,6 @@ static const TypeInfo scoop_sysbus_info = { .name = TYPE_SCOOP, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ScoopInfo), - .instance_init = scoop_init, .class_init = scoop_sysbus_class_init, }; |