omap_i2c: convert to memory API
Signed-off-by: Benoît Canet <benoit.canet@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
30af1ec729
commit
7487813909
@ -771,8 +771,11 @@ void omap_mmc_enable(struct omap_mmc_s *s, int enable);
|
|||||||
|
|
||||||
/* omap_i2c.c */
|
/* omap_i2c.c */
|
||||||
struct omap_i2c_s;
|
struct omap_i2c_s;
|
||||||
struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
|
struct omap_i2c_s *omap_i2c_init(MemoryRegion *sysmem,
|
||||||
qemu_irq irq, qemu_irq *dma, omap_clk clk);
|
target_phys_addr_t base,
|
||||||
|
qemu_irq irq,
|
||||||
|
qemu_irq *dma,
|
||||||
|
omap_clk clk);
|
||||||
struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
|
struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
|
||||||
qemu_irq irq, qemu_irq *dma, omap_clk fclk, omap_clk iclk);
|
qemu_irq irq, qemu_irq *dma, omap_clk fclk, omap_clk iclk);
|
||||||
void omap_i2c_reset(struct omap_i2c_s *s);
|
void omap_i2c_reset(struct omap_i2c_s *s);
|
||||||
|
@ -3964,7 +3964,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
|
|||||||
omap_pwl_init(system_memory, 0xfffb5800, s, omap_findclk(s, "armxor_ck"));
|
omap_pwl_init(system_memory, 0xfffb5800, s, omap_findclk(s, "armxor_ck"));
|
||||||
omap_pwt_init(system_memory, 0xfffb6000, s, omap_findclk(s, "armxor_ck"));
|
omap_pwt_init(system_memory, 0xfffb6000, s, omap_findclk(s, "armxor_ck"));
|
||||||
|
|
||||||
s->i2c[0] = omap_i2c_init(0xfffb3800,
|
s->i2c[0] = omap_i2c_init(system_memory, 0xfffb3800,
|
||||||
qdev_get_gpio_in(s->ih[1], OMAP_INT_I2C),
|
qdev_get_gpio_in(s->ih[1], OMAP_INT_I2C),
|
||||||
&s->drq[OMAP_DMA_I2C_RX], omap_findclk(s, "mpuper_ck"));
|
&s->drq[OMAP_DMA_I2C_RX], omap_findclk(s, "mpuper_ck"));
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "omap.h"
|
#include "omap.h"
|
||||||
|
|
||||||
struct omap_i2c_s {
|
struct omap_i2c_s {
|
||||||
|
MemoryRegion iomem;
|
||||||
qemu_irq irq;
|
qemu_irq irq;
|
||||||
qemu_irq drq[2];
|
qemu_irq drq[2];
|
||||||
i2c_bus *bus;
|
i2c_bus *bus;
|
||||||
@ -409,22 +410,28 @@ static void omap_i2c_writeb(void *opaque, target_phys_addr_t addr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const omap_i2c_readfn[] = {
|
static const MemoryRegionOps omap_i2c_ops = {
|
||||||
omap_badwidth_read16,
|
.old_mmio = {
|
||||||
omap_i2c_read,
|
.read = {
|
||||||
omap_badwidth_read16,
|
omap_badwidth_read16,
|
||||||
|
omap_i2c_read,
|
||||||
|
omap_badwidth_read16,
|
||||||
|
},
|
||||||
|
.write = {
|
||||||
|
omap_i2c_writeb, /* Only the last fifo write can be 8 bit. */
|
||||||
|
omap_i2c_write,
|
||||||
|
omap_badwidth_write16,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
static CPUWriteMemoryFunc * const omap_i2c_writefn[] = {
|
struct omap_i2c_s *omap_i2c_init(MemoryRegion *sysmem,
|
||||||
omap_i2c_writeb, /* Only the last fifo write can be 8 bit. */
|
target_phys_addr_t base,
|
||||||
omap_i2c_write,
|
qemu_irq irq,
|
||||||
omap_badwidth_write16,
|
qemu_irq *dma,
|
||||||
};
|
omap_clk clk)
|
||||||
|
|
||||||
struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
|
|
||||||
qemu_irq irq, qemu_irq *dma, omap_clk clk)
|
|
||||||
{
|
{
|
||||||
int iomemtype;
|
|
||||||
struct omap_i2c_s *s = (struct omap_i2c_s *)
|
struct omap_i2c_s *s = (struct omap_i2c_s *)
|
||||||
g_malloc0(sizeof(struct omap_i2c_s));
|
g_malloc0(sizeof(struct omap_i2c_s));
|
||||||
|
|
||||||
@ -436,9 +443,8 @@ struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
|
|||||||
s->bus = i2c_init_bus(NULL, "i2c");
|
s->bus = i2c_init_bus(NULL, "i2c");
|
||||||
omap_i2c_reset(s);
|
omap_i2c_reset(s);
|
||||||
|
|
||||||
iomemtype = cpu_register_io_memory(omap_i2c_readfn,
|
memory_region_init_io(&s->iomem, &omap_i2c_ops, s, "omap.i2c", 0x800);
|
||||||
omap_i2c_writefn, s, DEVICE_NATIVE_ENDIAN);
|
memory_region_add_subregion(sysmem, base, &s->iomem);
|
||||||
cpu_register_physical_memory(base, 0x800, iomemtype);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -446,7 +452,6 @@ struct omap_i2c_s *omap_i2c_init(target_phys_addr_t base,
|
|||||||
struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
|
struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
|
||||||
qemu_irq irq, qemu_irq *dma, omap_clk fclk, omap_clk iclk)
|
qemu_irq irq, qemu_irq *dma, omap_clk fclk, omap_clk iclk)
|
||||||
{
|
{
|
||||||
int iomemtype;
|
|
||||||
struct omap_i2c_s *s = (struct omap_i2c_s *)
|
struct omap_i2c_s *s = (struct omap_i2c_s *)
|
||||||
g_malloc0(sizeof(struct omap_i2c_s));
|
g_malloc0(sizeof(struct omap_i2c_s));
|
||||||
|
|
||||||
@ -457,9 +462,9 @@ struct omap_i2c_s *omap2_i2c_init(struct omap_target_agent_s *ta,
|
|||||||
s->bus = i2c_init_bus(NULL, "i2c");
|
s->bus = i2c_init_bus(NULL, "i2c");
|
||||||
omap_i2c_reset(s);
|
omap_i2c_reset(s);
|
||||||
|
|
||||||
iomemtype = cpu_register_io_memory(omap_i2c_readfn,
|
memory_region_init_io(&s->iomem, &omap_i2c_ops, s, "omap2.i2c",
|
||||||
omap_i2c_writefn, s, DEVICE_NATIVE_ENDIAN);
|
omap_l4_region_size(ta, 0));
|
||||||
omap_l4_attach(ta, 0, iomemtype);
|
omap_l4_attach_region(ta, 0, &s->iomem);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user