diff mbox

[3/5] milkymist-minimac2: Just expose buffers as a sysbus mmio region

Message ID 1360928706-13041-4-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell Feb. 15, 2013, 11:45 a.m. UTC
Just expose the register buffers memory as a standard sysbus mmio
region which the creator of the device can map, rather than
providing a qdev property which the creator has to set to the
base address and then doing the mapping in the device's own
init function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/milkymist-hw.h       |    2 +-
 hw/milkymist-minimac2.c |    5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

Comments

Andreas Färber Feb. 15, 2013, 1:17 p.m. UTC | #1
Am 15.02.2013 12:45, schrieb Peter Maydell:
> Just expose the register buffers memory as a standard sysbus mmio
> region which the creator of the device can map, rather than
> providing a qdev property which the creator has to set to the
> base address and then doing the mapping in the device's own
> init function.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas
Michael Walle Feb. 17, 2013, 10:12 p.m. UTC | #2
Am Freitag 15 Februar 2013, 12:45:04 schrieb Peter Maydell:
> Just expose the register buffers memory as a standard sysbus mmio
> region which the creator of the device can map, rather than
> providing a qdev property which the creator has to set to the
> base address and then doing the mapping in the device's own
> init function.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Acked-by: Michael Walle <michael@walle.cc>

> ---
>  hw/milkymist-hw.h       |    2 +-
>  hw/milkymist-minimac2.c |    5 +----
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h
> index c8bd7e9..21e202b 100644
> --- a/hw/milkymist-hw.h
> +++ b/hw/milkymist-hw.h
> @@ -193,10 +193,10 @@ static inline DeviceState
> *milkymist_minimac2_create(hwaddr base,
> 
>      qemu_check_nic_model(&nd_table[0], "minimac2");
>      dev = qdev_create(NULL, "milkymist-minimac2");
> -    qdev_prop_set_taddr(dev, "buffers_base", buffers_base);
>      qdev_set_nic_properties(dev, &nd_table[0]);
>      qdev_init_nofail(dev);
>      sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, buffers_base);
>      sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, rx_irq);
>      sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, tx_irq);
> 
> diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c
> index 9992dcc..b462e90 100644
> --- a/hw/milkymist-minimac2.c
> +++ b/hw/milkymist-minimac2.c
> @@ -96,7 +96,6 @@ struct MilkymistMinimac2State {
>      NICState *nic;
>      NICConf conf;
>      char *phy_model;
> -    hwaddr buffers_base;
>      MemoryRegion buffers;
>      MemoryRegion regs_region;
> 
> @@ -475,7 +474,7 @@ static int milkymist_minimac2_init(SysBusDevice *dev)
>      s->rx1_buf = s->rx0_buf + MINIMAC2_BUFFER_SIZE;
>      s->tx_buf = s->rx1_buf + MINIMAC2_BUFFER_SIZE;
> 
> -    sysbus_add_memory(dev, s->buffers_base, &s->buffers);
> +    sysbus_init_mmio(dev, &s->buffers);
> 
>      qemu_macaddr_default_if_unset(&s->conf.macaddr);
>      s->nic = qemu_new_nic(&net_milkymist_minimac2_info, &s->conf,
> @@ -517,8 +516,6 @@ static const VMStateDescription
> vmstate_milkymist_minimac2 = { };
> 
>  static Property milkymist_minimac2_properties[] = {
> -    DEFINE_PROP_TADDR("buffers_base", MilkymistMinimac2State,
> -    buffers_base, 0),
>      DEFINE_NIC_PROPERTIES(MilkymistMinimac2State, conf),
>      DEFINE_PROP_STRING("phy_model", MilkymistMinimac2State, phy_model),
>      DEFINE_PROP_END_OF_LIST(),
diff mbox

Patch

diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h
index c8bd7e9..21e202b 100644
--- a/hw/milkymist-hw.h
+++ b/hw/milkymist-hw.h
@@ -193,10 +193,10 @@  static inline DeviceState *milkymist_minimac2_create(hwaddr base,
 
     qemu_check_nic_model(&nd_table[0], "minimac2");
     dev = qdev_create(NULL, "milkymist-minimac2");
-    qdev_prop_set_taddr(dev, "buffers_base", buffers_base);
     qdev_set_nic_properties(dev, &nd_table[0]);
     qdev_init_nofail(dev);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, buffers_base);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, rx_irq);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 1, tx_irq);
 
diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c
index 9992dcc..b462e90 100644
--- a/hw/milkymist-minimac2.c
+++ b/hw/milkymist-minimac2.c
@@ -96,7 +96,6 @@  struct MilkymistMinimac2State {
     NICState *nic;
     NICConf conf;
     char *phy_model;
-    hwaddr buffers_base;
     MemoryRegion buffers;
     MemoryRegion regs_region;
 
@@ -475,7 +474,7 @@  static int milkymist_minimac2_init(SysBusDevice *dev)
     s->rx1_buf = s->rx0_buf + MINIMAC2_BUFFER_SIZE;
     s->tx_buf = s->rx1_buf + MINIMAC2_BUFFER_SIZE;
 
-    sysbus_add_memory(dev, s->buffers_base, &s->buffers);
+    sysbus_init_mmio(dev, &s->buffers);
 
     qemu_macaddr_default_if_unset(&s->conf.macaddr);
     s->nic = qemu_new_nic(&net_milkymist_minimac2_info, &s->conf,
@@ -517,8 +516,6 @@  static const VMStateDescription vmstate_milkymist_minimac2 = {
 };
 
 static Property milkymist_minimac2_properties[] = {
-    DEFINE_PROP_TADDR("buffers_base", MilkymistMinimac2State,
-    buffers_base, 0),
     DEFINE_NIC_PROPERTIES(MilkymistMinimac2State, conf),
     DEFINE_PROP_STRING("phy_model", MilkymistMinimac2State, phy_model),
     DEFINE_PROP_END_OF_LIST(),