Exynos: i2c, gpio and touchscreen support for NURI board
Subsystems (2)
cover Exynos: i2c, gpio and touchscreen support for NURI board
This patchset adds Exynos4210 i2c and GPIO implementation along with Atmel MXT touchscreen which is used for NURI board emulation.
For convenience, QOM @instance_size==0 related fix (which was posted on mailing list before and was reviewed by Paolo Bonzini) merged with this patchset because GPIO and MXT implementations depend on it.
Igor Mitsyanko (5):
qom: if @instance_size==0, assign size of object to parent object
size
qom/object.c: rename type_class_init() to type_initialize()
exynos4210: add Exynos4210 i2c implementation
exynos4210: add exynos4210 GPIO implementation
hw: add Atmel maxtouch touchscreen implementation
Makefile.target | 2 + hw/exynos4210.c | 72 ++++ hw/exynos4210.h | 67 +++ hw/exynos4210_gpio.c | 1117 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/exynos4210_i2c.c | 469 +++++++++++++++++++++ hw/exynos4_boards.c | 13 +- hw/maxtouch.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++++++ qom/object.c | 27 +- 8 files changed, 2836 insertions(+), 10 deletions(-) create mode 100644 hw/exynos4210_gpio.c create mode 100644 hw/exynos4210_i2c.c create mode 100644 hw/maxtouch.c
Signature · 1 line
1.7.4.1
PATCH 1/5 qom: if @instance_size==0, assign size of object to parent object size
QOM documentation states that for objects of type with @instance_size == 0 size will be assigned to match parent object's size. But currently this feauture is not implemented and qemu asserts during creation of object with zero instance_size.
Set appropriate value for type instance_size during type_class_init() call. object_initialize_with_type() must call type_class_init() before asserting type->instance_size, and object_new_with_type() must call type_class_init() before object allocation.
--- qom/object.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-)
qom/object.c +17 -2
@@ -177,6 +177,19 @@ static size_t type_class_get_size(TypeImpl *ti)return sizeof (ObjectClass); } +static size_t type_object_get_size (TypeImpl *ti) +{ +if (ti->instance_size) { +return ti->instance_size; + } + +if (type_has_parent (ti)) { +return type_object_get_size (type_get_parent (ti)); + } + +return 0 ; +} +static void type_class_interface_init (TypeImpl *ti,InterfaceImpl *iface) {TypeInfo info = {
@@ -203,6 +216,7 @@ static void type_class_init(TypeImpl *ti) } ti->class_size =type_class_get_size (ti); + ti->instance_size =type_object_get_size (ti); ti->class =g_malloc0 (ti->class_size); ti->class->type = ti;
@@ -264,9 +278,9 @@ void object_initialize_with_type(void *data, TypeImpl *type)Object *obj = data;g_assert (type !=NULL ); -g_assert (type->instance_size >=sizeof (Object)); -type_class_init (type); + +g_assert (type->instance_size >=sizeof (Object));g_assert (type->abstract == false);memset (obj,0 , type->instance_size);
@@ -356,6 +370,7 @@ Object *object_new_with_type(Type type)Object *obj;g_assert (type !=NULL ); +type_class_init (type); obj =g_malloc (type->instance_size);object_initialize_with_type (obj, type);
Signature · 1 line
1.7.4.1
PATCH 2/5 qom/object.c: rename type_class_init() to type_initialize()
In reply to Igor MitsyankoFunction name type_class_init() gave us a wrong impression of separation of type's "class" and "object" entities initialization. Name type_initialize() is more appropriate for type_class_init() function (considering what operations it performs).
--- qom/object.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
qom/object.c +6 -6
@@ -206,7 +206,7 @@ static void type_class_interface_init(TypeImpl *ti, InterfaceImpl *iface)g_free (name); } -static void type_class_init (TypeImpl *ti) +static void type_initialize (TypeImpl *ti) {size_t class_size =sizeof (ObjectClass);int i;
@@ -224,7 +224,7 @@ static void type_class_init(TypeImpl *ti)if (type_has_parent (ti)) {TypeImpl *parent =type_get_parent (ti); -type_class_init (parent); +type_initialize (parent); class_size = parent->class_size;g_assert (parent->class_size <= ti->class_size);
@@ -278,7 +278,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)Object *obj = data;g_assert (type !=NULL ); -type_class_init (type); +type_initialize (type);g_assert (type->instance_size >=sizeof (Object));g_assert (type->abstract == false);
@@ -370,7 +370,7 @@ Object *object_new_with_type(Type type)Object *obj;g_assert (type !=NULL ); -type_class_init (type); +type_initialize (type); obj =g_malloc (type->instance_size);object_initialize_with_type (obj, type);
@@ -543,7 +543,7 @@ ObjectClass *object_class_by_name(const char *typename)return NULL ; } -type_class_init (type); +type_initialize (type);return type->class; }
@@ -563,7 +563,7 @@ static void object_class_foreach_tramp(gpointer key, gpointer value,TypeImpl *type = value;ObjectClass *k; -type_class_init (type); +type_initialize (type); k = type->class;if (!data->include_abstract && type->abstract) {
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 2/5] qom/object.c: rename type_class_init() to type_initialize()
Quoted 7 lines · Igor Mitsyanko
Function name
type_class_init()gave us a wrong impression of separation of type's "class" and "object" entities initialization. Nametype_initialize()is more appropriate fortype_class_init()function (considering what operations it performs).Signed-off-by Igor Mitsyanko <[email protected]>Reviewed-by Paolo Bonzini <[email protected]>
The later patches in this series don't depend on this one, surely? Assuming that's correct, this patch should go in directly, not via arm-devs, and it shouldn't be in this series.
thanks
-- PMM
PATCH 3/5 exynos4210: add Exynos4210 i2c implementation
In reply to Igor MitsyankoCreate 9 exynos4210 i2c interfaces.
--- Makefile.target | 1 + hw/exynos4210.c | 26 +++ hw/exynos4210.h | 3 + hw/exynos4210_i2c.c | 469 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 499 insertions(+), 0 deletions(-) create mode 100644 hw/exynos4210_i2c.c
Makefile.target +1 -0
@@ -348,6 +348,7 @@ obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-arm-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-arm-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o +obj-arm-y += exynos4210_i2c.o obj-arm-y += arm_l2x0.o obj-arm-y += arm_mptimer.o a15mpcore.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
hw/exynos4210.c +26 -0
@@ -35,6 +35,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
@@ -242,6 +249,25 @@ 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; Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
hw/exynos4210_i2c.c new file +469 -0
469 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 3/5] exynos4210: add Exynos4210 i2c implementation
hw/exynos4210_i2c.c line 36
Quoted 8 lines · Igor Mitsyanko
Create 9 exynos4210 i2c interfaces.
Signed-off-by Igor Mitsyanko <[email protected]>hw/exynos4210_i2c.c new file +4
-0+#define EXYNOS4_I2C (obj) \ +OBJECT_CHECK(Exynos4210I2CState, (obj), TYPE_EXYNOS4_I2C) +#define EXYNOS4_I2C_SLAVE (obj) \ +OBJECT_CHECK(Exynos4210I2CSlave, (obj), TYPE_EXYNOS4_I2C_SLAVE)
Can you indent the second and subsequent lines of multi-line macro definitions, please?
hw/exynos4210_i2c.c line 108
Quoted 12 lines
hw/exynos4210_i2c.c new file +12
-0+enum { + idle, + start_bit_received, + sending_data, + receiving_data +}; + +struct Exynos4210I2CSlave { + I2CSlave i2c; + Exynos4210I2CState *host; + uint32_t status; +};
I'm confused about the purpose of this class. My (possibly naive) model of i2c is that there's a controller (in this case TYPE_EXYNOS4_I2C , with its state in the struct Exynos4210I2CState) which is a subclass of SysBus or whatever, and then there are i2c slaves, which are subclasses of TYPE_I2C_SLAVE and communicate with the controller strictly via the methods provided by the I2C_SLAVE class. But this seems to be an I2CSlave subclass which has a direct pointer to the internal state of the controller and very little state of its own. What's it for?
Quoted 5 lines
+static const VMStateDescription
exynos4210_i2c_vmstate= {
+ .name =TYPE_EXYNOS4_I2C,
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
Why the big space?
-- PMM
Re: [Qemu-devel] [PATCH 3/5] exynos4210: add Exynos4210 i2c implementation
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Igor Mitsyanko
Create 9 exynos4210 i2c interfaces.
Signed-off-by Igor Mitsyanko<[email protected]>
Quoted 7 lines
hw/exynos4210_i2c.c line 36
Quoted 4 lines
hw/exynos4210_i2c.c new file +4
-0+#define EXYNOS4_I2C (obj) \ +OBJECT_CHECK(Exynos4210I2CState, (obj), TYPE_EXYNOS4_I2C) +#define EXYNOS4_I2C_SLAVE (obj) \ +OBJECT_CHECK(Exynos4210I2CSlave, (obj), TYPE_EXYNOS4_I2C_SLAVE)Can you indent the second and subsequent lines of multi-line macro definitions, please?
OK
Quoted 14 lines
hw/exynos4210_i2c.c line 108
Quoted 12 lines
hw/exynos4210_i2c.c new file +12
-0+enum { + idle, + start_bit_received, + sending_data, + receiving_data +}; + +struct Exynos4210I2CSlave { +I2CSlave i2c; +Exynos4210I2CState *host; +uint32_t status; +};I'm confused about the purpose of this class. My (possibly naive)
Quoted 9 lines
model of i2c is that there's a controller (in this case
TYPE_EXYNOS4_I2C, with its state in the struct Exynos4210I2CState) which is a subclass of SysBus or whatever, and then there are i2c slaves, which are subclasses ofTYPE_I2C_SLAVEand communicate with the controller strictly via the methods provided by theI2C_SLAVEclass. But this seems to be an I2CSlave subclass which has a direct pointer to the internal state of the controller and very little state of its own. What's it for?
The reasoning behind this is that Exynos i2c controller can operate as i2c master or i2c slave (not simultaneously), so it must be a SysBusDevice and I2CSlave at the same time. There shouldn't be any communications of controller and some abstract I2C_SLAVE because controller is in fact I2C_SLAVE by itself, internal state of TYPE_EXYNOS4_I2C and TYPE_EXYNOS4_I2C_SLAVE is the same set of registers (hence the pointer). I took this approach from pxa2xx i2c implementation.
Quoted 8 lines
hw/exynos4210_i2c.c line 289
Quoted 5 lines
hw/exynos4210_i2c.c new file +5
-0+static const VMStateDescription exynos4210_i2c_vmstate = { + .name =TYPE_EXYNOS4_I2C , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) {Why the big space?
I don't know :)
Signature · 3 lines
Mitsyanko Igor ASWG, Moscow R&D center, Samsung Electronics email: [email protected]
PATCH 4/5 exynos4210: add exynos4210 GPIO implementation
In reply to Igor MitsyankoNow that we have GPIO emulation for exynos4210 SoC we can use it to properly hook up IRQ line to lan9215 controller on SMDK board.
--- Makefile.target | 2 +- hw/exynos4210.c | 46 ++ hw/exynos4210.h | 64 +++ hw/exynos4210_gpio.c | 1117 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/exynos4_boards.c | 2 +- 5 files changed, 1229 insertions(+), 2 deletions(-) create mode 100644 hw/exynos4210_gpio.c
Makefile.target +1 -1
@@ -348,7 +348,7 @@ obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-arm-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-arm-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o -obj-arm-y += exynos4210_i2c.o +obj-arm-y += exynos4210_i2c.o exynos4210_gpio.o obj-arm-y += arm_l2x0.o obj-arm-y += arm_mptimer.o a15mpcore.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
hw/exynos4210.c +46 -0
58 lines not on this page · raw message
hw/exynos4210.h +64 -0
76 lines not on this page · raw message
hw/exynos4210_gpio.c new file +1117 -0
1,117 lines not on this page · raw message
hw/exynos4_boards.c +1 -1
@@ -149,7 +149,7 @@ static void smdkc210_init(ram_addr_t ram_size, kernel_cmdline, initrd_filename, EXYNOS4_BOARD_SMDKC210);lan9215_init (SMDK_LAN9118_BASE_ADDR , -qemu_irq_invert (s->irq_table[exynos4210_get_irq (37 ,1 )])); +qdev_get_gpio_in (s->gpio2x,EXYNOS4210_GPIO2X_LINE (GPX0 ,5 )));arm_load_kernel (first_cpu, &exynos4_board_binfo); }
Signature · 1 line
1.7.4.1
PATCH 5/5 hw: add Atmel maxtouch touchscreen implementation
In reply to Igor MitsyankoAnd use it for exynos4210 NURI board emulation
--- Makefile.target | 1 + hw/exynos4_boards.c | 11 +- hw/maxtouch.c | 1079 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1088 insertions(+), 3 deletions(-) create mode 100644 hw/maxtouch.c
Makefile.target +1 -0
@@ -349,6 +349,7 @@ obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-arm-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-arm-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o obj-arm-y += exynos4210_i2c.o exynos4210_gpio.o +obj-arm-y += maxtouch.o obj-arm-y += arm_l2x0.o obj-arm-y += arm_mptimer.o a15mpcore.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
hw/exynos4_boards.c +8 -3
@@ -28,6 +28,7 @@#include "exec-memory.h" #include "exynos4210.h" #include "boards.h" +#include "i2c.h" #undef DEBUG
@@ -44,6 +45,7 @@#endif #define SMDK_LAN9118_BASE_ADDR 0x05000000 +#define MAXTOUCH_TS_I2C_ADDR 0x4a typedef enum Exynos4BoardType { EXYNOS4_BOARD_NURI,
@@ -134,9 +136,12 @@ static void nuri_init(ram_addr_t ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { -exynos4_boards_init_common (kernel_filename ,kernel_cmdline , -initrd_filename ,EXYNOS4_BOARD_NURI ); - + Exynos4210State *cpu = exynos4_boards_init_common(kernel_filename, + kernel_cmdline, initrd_filename,EXYNOS4_BOARD_NURI ); +DeviceState *dev = +i2c_create_slave (cpu->i2c_if[3 ],"maxtouch.var0" ,MAXTOUCH_TS_I2C_ADDR ); +qdev_connect_gpio_out (dev,0 ,qdev_get_gpio_in (cpu->gpio2x, +EXYNOS4210_GPIO2X_LINE (GPX0 ,4 )));arm_load_kernel (first_cpu, &exynos4_board_binfo); }
hw/maxtouch.c new file +1079 -0
1,079 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH 5/5] hw: add Atmel maxtouch touchscreen implementation
Hi Igor,
Am 02.03.2012 12:35, schrieb Igor Mitsyanko:
Makefile.target obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o · line 355
Quoted 12 lines
Makefile.target +1
-0@@ -349,6 +349,7 @@ obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-arm-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-arm-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o obj-arm-y += exynos4210_i2c.o exynos4210_gpio.o +obj-arm-y += maxtouch.o obj-arm-y += arm_l2x0.o obj-arm-y += arm_mptimer.o a15mpcore.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
I don't think this touchscreen device is really ARM-specific code-wise, is it? I would rather expect this to be hw-obj-$(CONFIG_MAXTOUCH) in Makefile.objs (so that it could be shared with, e.g., AVR). default-configs/arm-softmmu.mak would need CONFIG_MAXTOUCH=y then.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 5/5] hw: add Atmel maxtouch touchscreen implementation
Quoted 21 lines · Andreas Färber
Hi Igor,
Am 02.03.2012 12:35, schrieb Igor Mitsyanko:
Makefile.target obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o · line 355
Quoted 12 lines
Makefile.target +1
-0@@ -349,6 +349,7 @@ obj-arm-y += exynos4210_gic.o exynos4210_combiner.o exynos4210.o obj-arm-y += exynos4_boards.o exynos4210_uart.o exynos4210_pwm.o obj-arm-y += exynos4210_pmu.o exynos4210_mct.o exynos4210_fimd.o obj-arm-y += exynos4210_i2c.o exynos4210_gpio.o +obj-arm-y += maxtouch.o obj-arm-y += arm_l2x0.o obj-arm-y += arm_mptimer.o a15mpcore.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.oI don't think this touchscreen device is really ARM-specific code-wise, is it? I would rather expect this to be hw-obj-$(CONFIG_MAXTOUCH) in Makefile.objs (so that it could be shared with, e.g., AVR). default-configs/arm-softmmu.mak would need
CONFIG_MAXTOUCH=ythen.
Quoted 2 lines
Andreas
Sure, that makes a lot of sense.
Originally I was confused by framebuffer.o, bitbang_i2c.o (and a few other files) in arm-specific obj-arm-y. It gave me an impression that in case if only one target currently makes use of a certain hardware then corresponding hardware sources should be compiled only for this target.
Signature · 3 lines
Mitsyanko Igor ASWG, Moscow R&D center, Samsung Electronics email: [email protected]