exynos4210: add Exynos4210 i2c implementation
PATCH v4 1/1 exynos4210: add Exynos4210 i2c implementation
Create 9 exynos4210 i2c interfaces.
---
Previous versions of this patch were sent to mailing list within a "Exynos: i2c, gpio and touchscreen support for NURI board" patchset some time ago. V4 is merely a rabased version of V3.
Change list:
v3->v4
- rebased to current master.
- "exynos4210_i2c_info" renamed to "exynos4210_i2c_type_info".
v2->v3
- static TypeInfos are made const.
- added spaces after "do {".
- "All rights reserved" sentence is droped from license.
- names are fixed according to conventions.
- introduced scl_free member of exynos4210 i2c state. As it turned out, real hardware generates level-triggered interrupt while scl line is kept low, scl_free member models this behaviour. This fixes a bug when i2c generates receiving of extra data byte.
- exynos4210 i2c slave device droped.
- added missing i2caddr in vmstate.
- timers are droped.
- debug array containing i2c registers names replaced with a function.
v1->v2
- Added indendations for second and subsequent lines of multiple-line macro definitions;
- Weird big spaces after .field members of VMStateDescriptions are replaced with single space;
hw/arm/Makefile.objs | 2 +- hw/exynos4210.c | 27 ++++ hw/exynos4210.h | 3 + hw/exynos4210_i2c.c | 334 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 365 insertions(+), 1 deletions(-) create mode 100644 hw/exynos4210_i2c.c
hw/arm/Makefile.objs +1 -1
@@ -11,7 +11,7 @@ obj-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o -obj-y += exynos4210_rtc.o +obj-y += exynos4210_rtc.o exynos4210_i2c.o obj-y += arm_l2x0.o obj-y += arm_mptimer.o a15mpcore.o obj-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
hw/exynos4210.c +27 -0
@@ -39,6 +39,13 @@/* MCT */ #define EXYNOS4210_MCT_BASE_ADDR 0x10050000 +/* I2C */ +#define EXYNOS4210_I2C_SHIFT 0x00010000 +#define EXYNOS4210_I2C_BASE_ADDR 0x13860000 +/* Interrupt Group of External Interrupt Combiner for I2C */ +#define EXYNOS4210_I2C_INTG 27 +#define EXYNOS4210_HDMI_INTG 16 +/* UART's definitions */ #define EXYNOS4210_UART0_BASE_ADDR 0x13800000#define EXYNOS4210_UART1_BASE_ADDR 0x13810000
@@ -283,6 +290,26 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, s->irq_table[exynos4210_get_irq(35, 3)]);sysbus_mmio_map (busdev,0 ,EXYNOS4210_MCT_BASE_ADDR ); +/*** I2C ***/ +for (n =0 ; n <EXYNOS4210_I2C_NUMBER ; n++) { +uint32_t addr =EXYNOS4210_I2C_BASE_ADDR +EXYNOS4210_I2C_SHIFT * n; +qemu_irq i2c_irq; + +if (n <8 ) { + i2c_irq = s->irq_table[exynos4210_get_irq (EXYNOS4210_I2C_INTG , n)]; + }else { + i2c_irq = s->irq_table[exynos4210_get_irq (EXYNOS4210_HDMI_INTG ,1 )]; + } + + dev =qdev_create (NULL ,"exynos4210.i2c" ); +qdev_init_nofail (dev); + busdev =sysbus_from_qdev (dev); +sysbus_connect_irq (busdev,0 , i2c_irq); +sysbus_mmio_map (busdev,0 , addr); + s->i2c_if[n] = (i2c_bus *)qdev_get_child_bus (dev,"i2c" ); + } + +/*** UARTs ***/ exynos4210_uart_create(EXYNOS4210_UART0_BASE_ADDR, EXYNOS4210_UART0_FIFO_SIZE, 0, NULL,
hw/exynos4210.h +3 -0
@@ -74,6 +74,8 @@#define EXYNOS4210_EXT_GIC_NIRQ (160-32)#define EXYNOS4210_INT_GIC_NIRQ 64 +#define EXYNOS4210_I2C_NUMBER 9 + typedef struct Exynos4210Irq { qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ];
@@ -95,6 +97,7 @@ typedef struct Exynos4210State {MemoryRegion dram1_mem;MemoryRegion boot_secondary;MemoryRegion bootreg_mem; +i2c_bus *i2c_if[EXYNOS4210_I2C_NUMBER ]; } Exynos4210State; void exynos4210_write_secondary(ARMCPU *cpu,
hw/exynos4210_i2c.c new file +334 -0
334 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Quoted 4 lines · Igor Mitsyanko
Create 9 exynos4210 i2c interfaces.
Signed-off-by Igor Mitsyanko <[email protected]>Reviewed-by Andreas Färber <[email protected]>
-- PMM