From a56e423c7c39af0fa1515d575fddfda032a02916 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 23 Nov 2011 14:58:10 +0200 Subject: omap: eliminate l4_register_io_memory This is a trivial wrapper around cpu_register_io_memory(), adding no value. Inline it into all callers. Reviewed-by: Peter Maydell Signed-off-by: Avi Kivity --- hw/omap_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/omap_spi.c') diff --git a/hw/omap_spi.c b/hw/omap_spi.c index 6030ad9551..c20f425776 100644 --- a/hw/omap_spi.c +++ b/hw/omap_spi.c @@ -327,8 +327,8 @@ struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, } omap_mcspi_reset(s); - iomemtype = l4_register_io_memory(omap_mcspi_readfn, - omap_mcspi_writefn, s); + iomemtype = cpu_register_io_memory(omap_mcspi_readfn, + omap_mcspi_writefn, s, DEVICE_NATIVE_ENDIAN); omap_l4_attach(ta, 0, iomemtype); return s; -- cgit 1.4.1 From 1a0726900e4f472cdb389fd249bfdfa0e30f21e7 Mon Sep 17 00:00:00 2001 From: Benoît Canet Date: Mon, 28 Nov 2011 13:53:35 +0100 Subject: omap_spi: convert to memory API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Benoît Canet Signed-off-by: Avi Kivity --- hw/omap_spi.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'hw/omap_spi.c') diff --git a/hw/omap_spi.c b/hw/omap_spi.c index c20f425776..4823bd0cdf 100644 --- a/hw/omap_spi.c +++ b/hw/omap_spi.c @@ -24,6 +24,7 @@ /* Multichannel SPI */ struct omap_mcspi_s { + MemoryRegion iomem; qemu_irq irq; int chnum; @@ -129,12 +130,17 @@ void omap_mcspi_reset(struct omap_mcspi_s *s) omap_mcspi_interrupt_update(s); } -static uint32_t omap_mcspi_read(void *opaque, target_phys_addr_t addr) +static uint64_t omap_mcspi_read(void *opaque, target_phys_addr_t addr, + unsigned size) { struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; int ch = 0; uint32_t ret; + if (size != 4) { + return omap_badwidth_read32(opaque, addr); + } + switch (addr) { case 0x00: /* MCSPI_REVISION */ return 0x91; @@ -199,11 +205,15 @@ static uint32_t omap_mcspi_read(void *opaque, target_phys_addr_t addr) } static void omap_mcspi_write(void *opaque, target_phys_addr_t addr, - uint32_t value) + uint64_t value, unsigned size) { struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; int ch = 0; + if (size != 4) { + return omap_badwidth_write32(opaque, addr, value); + } + switch (addr) { case 0x00: /* MCSPI_REVISION */ case 0x14: /* MCSPI_SYSSTATUS */ @@ -267,7 +277,7 @@ static void omap_mcspi_write(void *opaque, target_phys_addr_t addr, if (((value >> 12) & 3) == 3) /* TRM */ fprintf(stderr, "%s: invalid TRM value (3)\n", __FUNCTION__); if (((value >> 7) & 0x1f) < 3) /* WL */ - fprintf(stderr, "%s: invalid WL value (%i)\n", + fprintf(stderr, "%s: invalid WL value (%" PRIx64 ")\n", __FUNCTION__, (value >> 7) & 0x1f); s->ch[ch].config = value & 0x7fffff; break; @@ -298,22 +308,15 @@ static void omap_mcspi_write(void *opaque, target_phys_addr_t addr, } } -static CPUReadMemoryFunc * const omap_mcspi_readfn[] = { - omap_badwidth_read32, - omap_badwidth_read32, - omap_mcspi_read, -}; - -static CPUWriteMemoryFunc * const omap_mcspi_writefn[] = { - omap_badwidth_write32, - omap_badwidth_write32, - omap_mcspi_write, +static const MemoryRegionOps omap_mcspi_ops = { + .read = omap_mcspi_read, + .write = omap_mcspi_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, qemu_irq irq, qemu_irq *drq, omap_clk fclk, omap_clk iclk) { - int iomemtype; struct omap_mcspi_s *s = (struct omap_mcspi_s *) g_malloc0(sizeof(struct omap_mcspi_s)); struct omap_mcspi_ch_s *ch = s->ch; @@ -327,9 +330,9 @@ struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, } omap_mcspi_reset(s); - iomemtype = cpu_register_io_memory(omap_mcspi_readfn, - omap_mcspi_writefn, s, DEVICE_NATIVE_ENDIAN); - omap_l4_attach(ta, 0, iomemtype); + memory_region_init_io(&s->iomem, &omap_mcspi_ops, s, "omap.mcspi", + omap_l4_region_size(ta, 0)); + omap_l4_attach_region(ta, 0, &s->iomem); return s; } -- cgit 1.4.1 From f44336c594c7e7887ee43ece3b53ba68b827fd1d Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 28 Nov 2011 15:40:49 +0200 Subject: omap_l4: rename omap_l4_attach_region() to omap_l4_attach() Signed-off-by: Avi Kivity --- hw/omap.h | 2 +- hw/omap2.c | 10 +++++----- hw/omap_dss.c | 8 ++++---- hw/omap_gptimer.c | 2 +- hw/omap_i2c.c | 2 +- hw/omap_l4.c | 4 ++-- hw/omap_mmc.c | 2 +- hw/omap_spi.c | 2 +- hw/omap_synctimer.c | 2 +- hw/omap_tap.c | 2 +- hw/omap_uart.c | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) (limited to 'hw/omap_spi.c') diff --git a/hw/omap.h b/hw/omap.h index 656251d34e..42eb361b21 100644 --- a/hw/omap.h +++ b/hw/omap.h @@ -94,7 +94,7 @@ struct omap_target_agent_s *omap_l4ta_get( const struct omap_l4_region_s *regions, const struct omap_l4_agent_info_s *agents, int cs); -target_phys_addr_t omap_l4_attach_region(struct omap_target_agent_s *ta, +target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region, MemoryRegion *mr); target_phys_addr_t omap_l4_region_base(struct omap_target_agent_s *ta, int region); diff --git a/hw/omap2.c b/hw/omap2.c index 676e5d58ee..91577ae128 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -605,7 +605,7 @@ static struct omap_eac_s *omap_eac_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_eac_ops, s, "omap.eac", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } @@ -793,7 +793,7 @@ static struct omap_sti_s *omap_sti_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_sti_ops, s, "omap.sti", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); memory_region_init_io(&s->iomem_fifo, &omap_sti_fifo_ops, s, "omap.sti.fifo", 0x10000); @@ -1813,8 +1813,8 @@ static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta, omap_l4_region_size(ta, 0)); memory_region_init_io(&s->iomem1, &omap_prcm_ops, s, "omap.pcrm1", omap_l4_region_size(ta, 1)); - omap_l4_attach_region(ta, 0, &s->iomem0); - omap_l4_attach_region(ta, 1, &s->iomem1); + omap_l4_attach(ta, 0, &s->iomem0); + omap_l4_attach(ta, 1, &s->iomem1); return s; } @@ -2187,7 +2187,7 @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_sysctl_ops, s, "omap.sysctl", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } diff --git a/hw/omap_dss.c b/hw/omap_dss.c index 9e592ce316..ede640b92e 100644 --- a/hw/omap_dss.c +++ b/hw/omap_dss.c @@ -1064,10 +1064,10 @@ struct omap_dss_s *omap_dss_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem_im3, &omap_im3_ops, s, "omap.im3", 0x1000); - omap_l4_attach_region(ta, 0, &s->iomem_diss1); - omap_l4_attach_region(ta, 1, &s->iomem_disc1); - omap_l4_attach_region(ta, 2, &s->iomem_rfbi1); - omap_l4_attach_region(ta, 3, &s->iomem_venc1); + omap_l4_attach(ta, 0, &s->iomem_diss1); + omap_l4_attach(ta, 1, &s->iomem_disc1); + omap_l4_attach(ta, 2, &s->iomem_rfbi1); + omap_l4_attach(ta, 3, &s->iomem_venc1); memory_region_add_subregion(sysmem, l3_base, &s->iomem_im3); #if 0 diff --git a/hw/omap_gptimer.c b/hw/omap_gptimer.c index 414b98aa36..7a145198a4 100644 --- a/hw/omap_gptimer.c +++ b/hw/omap_gptimer.c @@ -482,7 +482,7 @@ struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_gp_timer_ops, s, "omap.gptimer", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } diff --git a/hw/omap_i2c.c b/hw/omap_i2c.c index ca875f6086..5ec422c566 100644 --- a/hw/omap_i2c.c +++ b/hw/omap_i2c.c @@ -464,7 +464,7 @@ struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_i2c_ops, s, "omap2.i2c", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } diff --git a/hw/omap_l4.c b/hw/omap_l4.c index 78f02d993e..dbad7f67a8 100644 --- a/hw/omap_l4.c +++ b/hw/omap_l4.c @@ -138,12 +138,12 @@ struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, memory_region_init_io(&ta->iomem, &omap_l4ta_ops, ta, "omap.l4ta", omap_l4_region_size(ta, info->ta_region)); - omap_l4_attach_region(ta, info->ta_region, &ta->iomem); + omap_l4_attach(ta, info->ta_region, &ta->iomem); return ta; } -target_phys_addr_t omap_l4_attach_region(struct omap_target_agent_s *ta, +target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region, MemoryRegion *mr) { target_phys_addr_t base; diff --git a/hw/omap_mmc.c b/hw/omap_mmc.c index ba960c1c08..aec0285675 100644 --- a/hw/omap_mmc.c +++ b/hw/omap_mmc.c @@ -614,7 +614,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta, memory_region_init_io(&s->iomem, &omap_mmc_ops, s, "omap.mmc", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); /* Instantiate the storage */ s->card = sd_init(bd, 0); diff --git a/hw/omap_spi.c b/hw/omap_spi.c index 4823bd0cdf..8f2b697d2d 100644 --- a/hw/omap_spi.c +++ b/hw/omap_spi.c @@ -332,7 +332,7 @@ struct omap_mcspi_s *omap_mcspi_init(struct omap_target_agent_s *ta, int chnum, memory_region_init_io(&s->iomem, &omap_mcspi_ops, s, "omap.mcspi", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c index cd1d7548d2..367f26e3a1 100644 --- a/hw/omap_synctimer.c +++ b/hw/omap_synctimer.c @@ -96,7 +96,7 @@ struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta, omap_synctimer_reset(s); memory_region_init_io(&s->iomem, &omap_synctimer_ops, s, "omap.synctimer", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &s->iomem); + omap_l4_attach(ta, 0, &s->iomem); return s; } diff --git a/hw/omap_tap.c b/hw/omap_tap.c index 1b4820cebe..0277c73652 100644 --- a/hw/omap_tap.c +++ b/hw/omap_tap.c @@ -112,5 +112,5 @@ void omap_tap_init(struct omap_target_agent_s *ta, { memory_region_init_io(&mpu->tap_iomem, &omap_tap_ops, mpu, "omap.tap", omap_l4_region_size(ta, 0)); - omap_l4_attach_region(ta, 0, &mpu->tap_iomem); + omap_l4_attach(ta, 0, &mpu->tap_iomem); } diff --git a/hw/omap_uart.c b/hw/omap_uart.c index 64fc9f5c92..167d5c4e50 100644 --- a/hw/omap_uart.c +++ b/hw/omap_uart.c @@ -165,7 +165,7 @@ struct omap_uart_s *omap2_uart_init(MemoryRegion *sysmem, qemu_irq txdma, qemu_irq rxdma, const char *label, CharDriverState *chr) { - target_phys_addr_t base = omap_l4_attach_region(ta, 0, NULL); + target_phys_addr_t base = omap_l4_attach(ta, 0, NULL); struct omap_uart_s *s = omap_uart_init(base, irq, fclk, iclk, txdma, rxdma, label, chr); -- cgit 1.4.1