Skip to contentSkip to conversation

add sunxi machine type

PATCH Superseded liguang 3 participants 11 messages Nov 27, 2013 – Dec 2, 2013 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore

liguang

author
#0 lore raw

v6 cover add sunxi machine type

this patch-set implemented a device-reduced
machine type for Allwinner's sunxi series SoC,
like sunxi-4i/5i/7i ...

now, It can support sunxi-4i with a cortex-a8 processor. and will support more later, like sunxi-7i with cortex-a7, and will add more devices.

v2: split timer and interrupt controller emulation into
their corresponding files.

v3:
1. change loader_start address
2. add 64-bit counter
3. fixup fail to clear interrup status issue

v4:
1. add VMSD
2. use defines of magic number for readability
3. code cleanup

v5:
1. add VMSTATE_PTIMER_ARRAY
2. code cleanup

v6:
1. fix a fiq lost issue pointed out by Peter Crosthwaite
2. code cleanup

TODO:
1. add BROM support
2. add more devices
3. add sunxi-7i support

test:
can boot-up officially released linux kernel.

reference:
http://linux-sunxi.org/Main_Page

Li Guang (5)
hw/ptimer: add VMSTATE_PTIMER_ARRAY hw/timer: add sunxi timer device hw/intc: add sunxi interrupt controller device hw/arm: add sunxi machine type
MAINTAINERS: add myself to maintain sunxi machine

MAINTAINERS                     |   9 +++++++++
default-configs/arm-softmmu.mak |   3 +
hw/arm/Makefile.objs            |   1 +
hw/arm/sunxi-soc.c              |  98 ++++++++++++++++++++++++++++++++++++++++++++++++++
hw/intc/Makefile.objs           |   1 +
hw/intc/sunxi-pic.c             | 244 +++++++++++++++++++++++++++++++++++++++
hw/timer/Makefile.objs          |   1 +
hw/timer/sunxi-pit.c            | 276 +++++++++++++++++++++++++++++++++++++++
include/hw/intc/sunxi-pic.h     |  20 +++
include/hw/ptimer.h             |   3 +++
include/hw/timer/sunxi-pit.h    |  37 +++++
11 files changed, 693 insertions(+), 0 deletions(-)
 create mode 100644 hw/timer/sunxi-pit.c
 create mode 100644 include/hw/timer/sunxi-pit.h
 create mode 100644 hw/intc/sunxi-pic.c
 create mode 100644 include/hw/intc/sunxi-pic.h
 create mode 100644 hw/arm/sunxi-soc.c
author
#1 lore raw

PATCH v6 1/5 hw/ptimer: add VMSTATE_PTIMER_ARRAY

---
 include/hw/ptimer.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/hw/ptimer.h +3 -0
index 28fcaf1..a9b8f1d 100644
@@ -27,6 +27,9 @@ void ptimer_stop(ptimer_state *s);
 
 extern const VMStateDescription vmstate_ptimer;
 
+#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
+    VMSTATE_STRUCT_ARRAY(_f, _s, _n, 0, vmstate_ptimer, ptimer_state*)
+
 #define VMSTATE_PTIMER(_field, _state) {                             \
     .name       = (stringify(_field)),                               \
     .version_id = (1),                                               \
Signature · 1 line
1.7.2.5
#2 lore raw

Re: [Qemu-devel] [PATCH v6 1/5] hw/ptimer: add VMSTATE_PTIMER_ARRAY

Quoted 10 lines · liguang
---
 include/hw/ptimer.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/hw/ptimer.h +0 -0
index 28fcaf1..a9b8f1d 100644

include/hw/ptimer.h void ptimer_stop(ptimer_state *s); · line 31

Quoted 5 lines
include/hw/ptimer.h +2 -0
@@ -27,6 +27,9 @@ void ptimer_stop(ptimer_state *s);
 
 extern const VMStateDescription vmstate_ptimer;
 
+#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
+    VMSTATE_STRUCT_ARRAY(_f, _s, _n, 0, vmstate_ptimer, ptimer_state*)

The final parameter here should just be the struct type ("ptimer_state"), not a pointer-to-it.

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH v6 1/5] hw/ptimer: add VMSTATE_PTIMER_ARRAY

Quoted 12 lines · Peter Maydell
Quoted 11 lines · liguang
---
 include/hw/ptimer.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/hw/ptimer.h +0 -0
index 28fcaf1..a9b8f1d 100644
@@ -27,6 +27,9 @@ void ptimer_stop(ptimer_state *s);
 
Quoted 7 lines

include/hw/ptimer.h void ptimer_stop(ptimer_state *s); · line 31

Quoted 4 lines
include/hw/ptimer.h +2 -0
 extern const VMStateDescription vmstate_ptimer;
 
+#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
+    VMSTATE_STRUCT_ARRAY(_f, _s, _n, 0, vmstate_ptimer, ptimer_state*)

The final parameter here should just be the struct type ("ptimer_state"), not a pointer-to-it.

Actually, looking at the patch where you've used this, you do actually want to deal with an array-of-pointers-to-ptimers. For that you need

#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_ptimer, ptimer_state *)

(compare VMSTATE_TIMER_ARRAY in vmstate.h)

thanks
-- PMM

author
#4 lore raw

Re: [Qemu-devel] [PATCH v6 1/5] hw/ptimer: add VMSTATE_PTIMER_ARRAY

Quoted 23 lines · Peter Maydell
Quoted 13 lines · Peter Maydell
Quoted 11 lines · liguang
---
  include/hw/ptimer.h |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
include/hw/ptimer.h +0 -0
index 28fcaf1..a9b8f1d 100644
@@ -27,6 +27,9 @@ void ptimer_stop(ptimer_state *s);
 
Quoted 8 lines

include/hw/ptimer.h void ptimer_stop(ptimer_state *s);

Quoted 5 lines
include/hw/ptimer.h +2 -0
  extern const VMStateDescription vmstate_ptimer;
 
+#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
+    VMSTATE_STRUCT_ARRAY(_f, _s, _n, 0, vmstate_ptimer, ptimer_state*)
 

The final parameter here should just be the struct type ("ptimer_state"), not a pointer-to-it.

Quoted 11 lines

Actually, looking at the patch where you've used this, you do actually want to deal with an array-of-pointers-to-ptimers. For that you need

#define VMSTATE_PTIMER_ARRAY(_f, _s, _n) \
VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_ptimer, ptimer_state *)

(compare VMSTATE_TIMER_ARRAY in vmstate.h)

OK, thanks!

author
#5 lore raw

PATCH v6 2/5 hw/timer: add sunxi timer device

In reply to liguang
---
 default-configs/arm-softmmu.mak |    2 +
 hw/timer/Makefile.objs          |    1 +
 hw/timer/sunxi-pit.c            |  252 +++++++++++++++++++++++++++++++++++++++
 include/hw/timer/sunxi-pit.h    |   56 +++++++++
 4 files changed, 311 insertions(+), 0 deletions(-)
 create mode 100644 hw/timer/sunxi-pit.c
 create mode 100644 include/hw/timer/sunxi-pit.h
default-configs/arm-softmmu.mak +2 -0
index a555eef..7bf5ad0 100644
@@ -81,3 +81,5 @@ CONFIG_VERSATILE_I2C=y
 
 CONFIG_SDHCI=y
 CONFIG_INTEGRATOR_DEBUG=y
+
+CONFIG_SUNXI_PIT=y
hw/timer/Makefile.objs +1 -0
index eca5905..f7888e9 100644
@@ -27,3 +27,4 @@ obj-$(CONFIG_SH4) += sh_timer.o
 obj-$(CONFIG_TUSB6010) += tusb6010.o
 
 obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
+obj-$(CONFIG_SUNXI_PIT) += sunxi-pit.o
hw/timer/sunxi-pit.c new file +252 -0

252 lines not on this page · raw message

include/hw/timer/sunxi-pit.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.2.5
author
#6 lore raw

PATCH v6 3/5 hw/intc: add sunxi interrupt controller device

In reply to liguang
---
 default-configs/arm-softmmu.mak |    1 +
 hw/intc/Makefile.objs           |    1 +
 hw/intc/sunxi-pic.c             |  218 +++++++++++++++++++++++++++++++++++++++
 include/hw/intc/sunxi-pic.h     |   40 +++++++
 4 files changed, 260 insertions(+), 0 deletions(-)
 create mode 100644 hw/intc/sunxi-pic.c
 create mode 100644 include/hw/intc/sunxi-pic.h
default-configs/arm-softmmu.mak +1 -0
index 7bf5ad0..bbe00e4 100644
@@ -83,3 +83,4 @@ CONFIG_SDHCI=y
 CONFIG_INTEGRATOR_DEBUG=y
 
 CONFIG_SUNXI_PIT=y
+CONFIG_SUNXI_PIC=y
hw/intc/Makefile.objs +1 -0
index 47ac442..dad8c43 100644
@@ -12,6 +12,7 @@ common-obj-$(CONFIG_IOAPIC) += ioapic_common.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gic_common.o
 common-obj-$(CONFIG_ARM_GIC) += arm_gic.o
 common-obj-$(CONFIG_OPENPIC) += openpic.o
+common-obj-$(CONFIG_SUNXI_PIC) += sunxi-pic.o
 
 obj-$(CONFIG_APIC) += apic.o apic_common.o
 obj-$(CONFIG_ARM_GIC_KVM) += arm_gic_kvm.o
hw/intc/sunxi-pic.c new file +218 -0

218 lines not on this page · raw message

include/hw/intc/sunxi-pic.h new file +40 -0
new file mode 100644
index 0000000..6c32382
@@ -0,0 +1,40 @@
+#ifndef SUNXI_PIC_H
+#define SUNXI_PIC_H
+
+#define TYPE_SUNXI_PIC  "sunxi-pic"
+#define SUNXI_PIC(obj) OBJECT_CHECK(SunxiPICState, (obj), TYPE_SUNXI_PIC)
+
+#define SUNXI_PIC_VECTOR 	0
+#define SUNXI_PIC_BASE_ADDR 	4
+#define SUNXI_PIC_PROTECT 	8
+#define SUNXI_PIC_NMI		0xc
+#define SUNXI_PIC_IRQ_PENDING	0x10
+#define SUNXI_PIC_FIQ_PENDING	0x20
+#define SUNXI_PIC_SELECT	0x30
+#define SUNXI_PIC_ENABLE	0x40
+#define SUNXI_PIC_MASK		0x50
+
+#define SUNXI_PIC_INT_NR	95
+#define SUNXI_PIC_REG_NUM	DIV_ROUND_UP(SUNXI_PIC_INT_NR, 32)
+
+typedef struct SunxiPICState {
+    /*< private >*/
+    SysBusDevice parent_obj;
+    /*< public >*/
+    MemoryRegion iomem;
+    qemu_irq parent_fiq;
+    qemu_irq parent_irq;
+
+    uint32_t vector;
+    uint32_t base_addr;
+    uint32_t protect;
+    uint32_t nmi;
+    uint32_t irq_pending[SUNXI_PIC_REG_NUM];
+    uint32_t fiq_pending[SUNXI_PIC_REG_NUM];
+    uint32_t select[SUNXI_PIC_REG_NUM];
+    uint32_t enable[SUNXI_PIC_REG_NUM];
+    uint32_t mask[SUNXI_PIC_REG_NUM];
+    /*priority setting here*/
+} SunxiPICState;
+
+#endif
Signature · 1 line
1.7.2.5
author
#7 lore raw

PATCH v6 4/5 hw/arm: add sunxi machine type

In reply to liguang
---
 hw/arm/Makefile.objs |    1 +
 hw/arm/sunxi-soc.c   |   98 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 hw/arm/sunxi-soc.c
hw/arm/Makefile.objs +1 -0
index 3671b42..f9f3071 100644
@@ -5,3 +5,4 @@ obj-y += tosa.o versatilepb.o vexpress.o xilinx_zynq.o z2.o
 
 obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
 obj-y += omap1.o omap2.o strongarm.o
+obj-y += sunxi-soc.o
hw/arm/sunxi-soc.c new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
1.7.2.5
author
#8 lore raw

PATCH v6 5/5 MAINTAINERS: add myself to maintain sunxi machine

In reply to liguang
---
 MAINTAINERS |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
MAINTAINERS +9 -0
index 77edacf..232e1a1 100644
@@ -284,6 +284,15 @@ M: Peter Maydell <[email protected]>
 S: Maintained
 F: hw/*/stellaris*
 
+Sunxi
+M: Li Guang <[email protected]>
+S: Maintained
+F: hw/arm/sunxi-soc.c
+F: hw/intc/sunxi-pic.c
+F: hw/timer/sunxi-pit.c
+F: include/hw/intc/sunxi-pic.h
+F: include/hw/timer/sunxi-pit.h
+
 Versatile PB
 M: Peter Maydell <[email protected]>
 S: Maintained
Signature · 1 line
1.7.2.5
#9 lore raw
In reply to liguang

Hi Liguang,

Quoted 21 lines · liguang

this patch-set implemented a device-reduced
machine type for Allwinner's sunxi series SoC,
like sunxi-4i/5i/7i ...

now, It can support sunxi-4i with a cortex-a8 processor. and will support more later, like sunxi-7i with cortex-a7, and will add more devices.

v2: split timer and interrupt controller emulation into
their corresponding files.

v3:
1. change loader_start address
2. add 64-bit counter
3. fixup fail to clear interrup status issue

v4:
1. add VMSD
2. use defines of magic number for readability
3. code cleanup

Quoted 8 lines

v5:
1. add VMSTATE_PTIMER_ARRAY
2. code cleanup

v6:
1. fix a fiq lost issue pointed out by Peter Crosthwaite
2. code cleanup

These respins are getting pretty thick and fast. You should give the other maintainers at least overnight (if not a few days) to weigh in as well.

Regards,
Peter

Quoted 38 lines

TODO:
1. add BROM support
2. add more devices
3. add sunxi-7i support

test:
can boot-up officially released linux kernel.

reference:
http://linux-sunxi.org/Main_Page

Li Guang (5)
hw/ptimer: add VMSTATE_PTIMER_ARRAY hw/timer: add sunxi timer device hw/intc: add sunxi interrupt controller device hw/arm: add sunxi machine type
MAINTAINERS: add myself to maintain sunxi machine

MAINTAINERS                     |   9 +++++++++
default-configs/arm-softmmu.mak |   3 +
hw/arm/Makefile.objs            |   1 +
hw/arm/sunxi-soc.c              |  98 ++++++++++++++++++++++++++++++++++++++++++++++++++
hw/intc/Makefile.objs           |   1 +
hw/intc/sunxi-pic.c             | 244 +++++++++++++++++++++++++++++++++++++++
hw/timer/Makefile.objs          |   1 +
hw/timer/sunxi-pit.c            | 276 +++++++++++++++++++++++++++++++++++++++
include/hw/intc/sunxi-pic.h     |  20 +++
include/hw/ptimer.h             |   3 +++
include/hw/timer/sunxi-pit.h    |  37 +++++
11 files changed, 693 insertions(+), 0 deletions(-)
 create mode 100644 hw/timer/sunxi-pit.c
 create mode 100644 include/hw/timer/sunxi-pit.h
 create mode 100644 hw/intc/sunxi-pic.c
 create mode 100644 include/hw/intc/sunxi-pic.h
 create mode 100644 hw/arm/sunxi-soc.c
author
#10 lore raw
Quoted 29 lines · Peter Crosthwaite

Hi Liguang,

Quoted 25 lines · liguang

this patch-set implemented a device-reduced
machine type for Allwinner's sunxi series SoC,
like sunxi-4i/5i/7i ...

now, It can support sunxi-4i with a cortex-a8 processor. and will support more later, like sunxi-7i with cortex-a7, and will add more devices.

v2: split timer and interrupt controller emulation into
their corresponding files.

v3:
1. change loader_start address
2. add 64-bit counter
3. fixup fail to clear interrup status issue

v4:
1. add VMSD
2. use defines of magic number for readability
3. code cleanup

v5:
1. add VMSTATE_PTIMER_ARRAY
2. code cleanup

Quoted 11 lines
Quoted 5 lines

v6:
1. fix a fiq lost issue pointed out by Peter Crosthwaite
2. code cleanup

These respins are getting pretty thick and fast. You should give the other maintainers at least overnight (if not a few days) to weigh in as well.

OK, thanks!
just a little busy on other jobs, :-)

Quoted 41 lines
Quoted 40 lines

TODO:
1. add BROM support
2. add more devices
3. add sunxi-7i support

test:
can boot-up officially released linux kernel.

reference:
http://linux-sunxi.org/Main_Page

Li Guang (5)
hw/ptimer: add VMSTATE_PTIMER_ARRAY hw/timer: add sunxi timer device hw/intc: add sunxi interrupt controller device hw/arm: add sunxi machine type
MAINTAINERS: add myself to maintain sunxi machine

MAINTAINERS                     |   9 +++++++++
default-configs/arm-softmmu.mak |   3 +
hw/arm/Makefile.objs            |   1 +
hw/arm/sunxi-soc.c              |  98 ++++++++++++++++++++++++++++++++++++++++++++++++++
hw/intc/Makefile.objs           |   1 +
hw/intc/sunxi-pic.c             | 244 +++++++++++++++++++++++++++++++++++++++
hw/timer/Makefile.objs          |   1 +
hw/timer/sunxi-pit.c            | 276 +++++++++++++++++++++++++++++++++++++++
include/hw/intc/sunxi-pic.h     |  20 +++
include/hw/ptimer.h             |   3 +++
include/hw/timer/sunxi-pit.h    |  37 +++++
11 files changed, 693 insertions(+), 0 deletions(-)

create mode 100644 hw/timer/sunxi-pit.c
create mode 100644 include/hw/timer/sunxi-pit.h
create mode 100644 hw/intc/sunxi-pic.c
create mode 100644 include/hw/intc/sunxi-pic.h
create mode 100644 hw/arm/sunxi-soc.c