ARM: Samsung Exynos4210-based boards support.
Subsystems (2)
v5 cover ARM: Samsung Exynos4210-based boards support.
This set of patches adds support for Samsung S5PC210-based boards NURI and SMDKC210. Tested on Linux kernel v3.x series. Usage of "-smp 2" option is required for now.
Changelog:
v4->v5
- hw/exynos4210_gic.c: Use memory aliases for CPU interface and Distributer. Excessive RW functions are removed.
- hw/exynos4210_pwm.c and hw/exynos4210_mct.c: Saving of timers added.
- hw/exynos4210_uart.c: VMSTATE version_id fixed.
v3->v4
- Split Exynos SOC and boards.
- Temporary removed SD and CMU support to post later.
- Lan9118 remarks took into account.
- Secondary CPU bootloader remarks took into account.
- PWM remarks took into account.
- UART remarks took into account.
v2->v3
- Reverted hw/arm_gic.c modification
- Added IRQ Gate to Exynos4210 board.
Evgeny Voevodin (8):
hw/sysbus.h: Increase maximum number of device IRQs.
ARM: exynos4210: IRQ subsystem support.
ARM: exynos4210: PWM support. hw/arm_boot.c: Extend secondary CPU bootloader.
ARM: exynos4210: MCT support. hw/exynos4210.c: Boot secondary CPU. hw/lan9118: Add basic 16-bit mode support. hw/exynos4210.c: Add LAN support for SMDKC210.
Evgeny Voevodin (8):
hw/sysbus.h: Increase maximum number of device IRQs.
ARM: exynos4210: IRQ subsystem support.
ARM: exynos4210: PWM support. hw/arm_boot.c: Extend secondary CPU bootloader.
ARM: exynos4210: MCT support. hw/exynos4210.c: Boot secondary CPU. hw/lan9118: Add basic 16-bit mode support. hw/exynos4210.c: Add LAN support for SMDKC210.
Maksim Kozlov (2):
ARM: Samsung exynos4210-based boards emulation
ARM: exynos4210: UART support
Mitsyanko Igor (1):
Exynos4210: added display controller implementation
Makefile.target | 3 + hw/arm-misc.h | 1 + hw/arm_boot.c | 23 +- hw/exynos4210.c | 352 +++++++++ hw/exynos4210.h | 123 ++++ hw/exynos4210_combiner.c | 384 ++++++++++ hw/exynos4210_fimd.c | 1783 ++++++++++++++++++++++++++++++++++++++++++++++ hw/exynos4210_gic.c | 437 ++++++++++++ hw/exynos4210_mct.c | 1494 ++++++++++++++++++++++++++++++++++++++ hw/exynos4210_pwm.c | 416 +++++++++++ hw/exynos4210_uart.c | 670 +++++++++++++++++ hw/exynos4_boards.c | 167 +++++ hw/lan9118.c | 115 +++- hw/sysbus.h | 2 +- 14 files changed, 5956 insertions(+), 14 deletions(-) create mode 100644 hw/exynos4210.c create mode 100644 hw/exynos4210.h create mode 100644 hw/exynos4210_combiner.c create mode 100644 hw/exynos4210_fimd.c create mode 100644 hw/exynos4210_gic.c create mode 100644 hw/exynos4210_mct.c create mode 100644 hw/exynos4210_pwm.c create mode 100644 hw/exynos4210_uart.c create mode 100644 hw/exynos4_boards.c
Signature · 1 line
1.7.4.1
PATCH v5 1/11 ARM: Samsung exynos4210-based boards emulation
From: Maksim Kozlov <[email protected]>
Add initial code for support of NURI and SMDKC210 boards
--- Makefile.target | 1 + hw/exynos4210.c | 103 +++++++++++++++++++++++++++++++++++++++ hw/exynos4210.h | 63 ++++++++++++++++++++++++ hw/exynos4_boards.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 300 insertions(+), 0 deletions(-) create mode 100644 hw/exynos4210.c create mode 100644 hw/exynos4210.h create mode 100644 hw/exynos4_boards.c
Makefile.target +1 -0
@@ -336,6 +336,7 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o +obj-arm-y += exynos4_boards.o exynos4210.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c new file +103 -0
103 lines not on this page · raw message
hw/exynos4210.h new file +63 -0
63 lines not on this page · raw message
hw/exynos4_boards.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v5 2/11 ARM: exynos4210: UART support
In reply to Evgeny VoevodinFrom: Maksim Kozlov <[email protected]>
Add basic support of exynos4210 UART
--- Makefile.target | 2 +- hw/exynos4210.c | 24 ++ hw/exynos4210.h | 9 + hw/exynos4210_uart.c | 670 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 704 insertions(+), 1 deletions(-) create mode 100644 hw/exynos4210_uart.c
Makefile.target +1 -1
@@ -336,7 +336,7 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o -obj-arm-y += exynos4_boards.o exynos4210.o +obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c +24 -0
@@ -26,8 +26,19 @@#include "arm-misc.h" #include "exynos4210.h" +#define EXYNOS4210_CHIPID_ADDR 0x10000000 +/* UART's definitions */ +#define EXYNOS4210_UART0_BASE_ADDR 0x13800000 +#define EXYNOS4210_UART1_BASE_ADDR 0x13810000 +#define EXYNOS4210_UART2_BASE_ADDR 0x13820000 +#define EXYNOS4210_UART3_BASE_ADDR 0x13830000 +#define EXYNOS4210_UART0_FIFO_SIZE 256 +#define EXYNOS4210_UART1_FIFO_SIZE 64 +#define EXYNOS4210_UART2_FIFO_SIZE 16 +#define EXYNOS4210_UART3_FIFO_SIZE 16 +static uint8_t chipid_and_omr[] = {0x11 ,0x02 ,0x21 ,0x43 ,0x09 ,0x00 ,0x00 ,0x00 };
@@ -99,5 +110,18 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,memory_region_add_subregion (system_mem,EXYNOS4210_DRAM0_BASE_ADDR , &s->dram0_mem); +/*** UARTs ***/ +exynos4210_uart_create (EXYNOS4210_UART0_BASE_ADDR , +EXYNOS4210_UART0_FIFO_SIZE ,0 ,NULL ,NULL ); + +exynos4210_uart_create (EXYNOS4210_UART1_BASE_ADDR , +EXYNOS4210_UART1_FIFO_SIZE ,1 ,NULL ,NULL ); + +exynos4210_uart_create (EXYNOS4210_UART2_BASE_ADDR , +EXYNOS4210_UART2_FIFO_SIZE ,2 ,NULL ,NULL ); + +exynos4210_uart_create (EXYNOS4210_UART3_BASE_ADDR , +EXYNOS4210_UART3_FIFO_SIZE ,3 ,NULL ,NULL ); +return s; }
hw/exynos4210.h +9 -0
@@ -60,4 +60,13 @@ typedef struct Exynos4210State {Exynos4210State *exynos4210_init (MemoryRegion *system_mem,unsigned long ram_size); +/* +* exynos4210 UART +*/ +DeviceState *exynos4210_uart_create (target_phys_addr_t addr, +int fifo_size, +int channel, +CharDriverState *chr, +qemu_irq irq); +#endif /* EXYNOS4210_H_ */
hw/exynos4210_uart.c new file +670 -0
670 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 02/11] ARM: exynos4210: UART support
Quoted 31 lines · Evgeny Voevodin
From: Maksim Kozlov <[email protected]>
Add basic support of exynos4210 UART
Signed-off-by Evgeny Voevodin <[email protected]>---
Makefile.target | 2 +- hw/exynos4210.c | 24 ++ hw/exynos4210.h | 9 + hw/exynos4210_uart.c | 670 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 704 insertions(+), 1 deletions(-)create mode 100644
hw/exynos4210_uart.cMakefile.target +0
-0@@ -336,7 +336,7 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.oobj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o
obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.oMakefile.target +1
-1-obj-arm-y += exynos4_boards.o exynos4210.o +obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.oobj-arm-y += arm_mptimer.o
obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.ohw/exynos4210.c +0
-0
hw/exynos4210.c line 29
Quoted 4 lines
hw/exynos4210.c +1
-0@@ -26,8 +26,19 @@ #include "arm-misc.h" #include "exynos4210.h" +
stray blank line
hw/exynos4210.c line 34
Quoted 5 lines
hw/exynos4210.c +5
-0+ +#ifdef DEBUG_UART +/* The only meaning of life - debugging. This functions should be only used +* inside PRINT_DEBUG_... macroses +*/
"macros"
hw/exynos4210.c line 37
Quoted 3 lines
hw/exynos4210.c +3
-0+ default: + level = 0; + PRINT_ERROR("Wrong UART chennel number: %d\n", s->channel);
"channel"
hw/exynos4210.c line 41
Quoted 4 lines
hw/exynos4210.c +4
-0+ +#ifdef DEBUG_IRQ + fprintf(stderr, "UART%d: IRQ have been raised: %08x\n", + s->channel, s->reg[I_(UINTP)]);
"has been"
hw/exynos4210.c line 44
Quoted 3 lines
hw/exynos4210.c +3
-0+ case UINTP: + s->reg[I_(UINTP)] &= ~val; + /* XXX: It's the assumption that it works in this way */
Can you expand this comment a little to clarify exactly what the assumption you're making is?
-- PMM
Re: [Qemu-devel] [PATCH v5 02/11] ARM: exynos4210: UART support
Quoted 5 lines · Peter Maydell
hw/exynos4210_uart.c line 409
Quoted 3 lines
hw/exynos4210_uart.c new file +3
-0+case UINTP : + s->reg[I_ (UINTP )]&= ~val; +/* XXX: It's the assumption that it works in this way */ Can you expand this comment a little to clarify exactly what the assumption you're making is?
It was not clear from documentation if UINTSP register bits should be cleared inside this "case" too. Practise has showed that should. I think, this comment message could be removed.
Signature · 5 lines
Kind regards, Evgeny Voevodin, Leading Software Engineer, ASWG, Moscow R&D center, Samsung Electronics e-mail: [email protected]
PATCH v5 3/11 hw/sysbus.h: Increase maximum number of device IRQs.
In reply to Evgeny VoevodinSamsung exynos4210 Interrupt Combiner needs 512 IRQ sources.
--- hw/sysbus.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/sysbus.h +1 -1
@@ -8,7 +8,7 @@#define QDEV_MAX_MMIO 32#define QDEV_MAX_PIO 32 -#define QDEV_MAX_IRQ 256 +#define QDEV_MAX_IRQ 512typedef struct SysBusDevice SysBusDevice ;
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 03/11] hw/sysbus.h: Increase maximum number of device IRQs.
Quoted 3 lines · Evgeny Voevodin
Samsung exynos4210 Interrupt Combiner needs 512 IRQ sources.
Signed-off-by Evgeny Voevodin <[email protected]>
PATCH v5 4/11 ARM: exynos4210: IRQ subsystem support.
In reply to Evgeny Voevodin--- Makefile.target | 3 +- hw/exynos4210.c | 179 ++++++++++++++++++- hw/exynos4210.h | 46 +++++ hw/exynos4210_combiner.c | 384 ++++++++++++++++++++++++++++++++++++++++ hw/exynos4210_gic.c | 437 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1044 insertions(+), 5 deletions(-) create mode 100644 hw/exynos4210_combiner.c create mode 100644 hw/exynos4210_gic.c
Makefile.target +2 -1
@@ -336,7 +336,8 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o -obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o +obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o exynos4210_gic.o \ + exynos4210_combiner.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c +175 -4
221 lines not on this page · raw message
hw/exynos4210.h +46 -0
60 lines not on this page · raw message
hw/exynos4210_combiner.c new file +384 -0
384 lines not on this page · raw message
hw/exynos4210_gic.c new file +437 -0
437 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 04/11] ARM: exynos4210: IRQ subsystem support.
Quoted 20 lines · Evgeny Voevodin
Signed-off-by Evgeny Voevodin <[email protected]>---
Makefile.target | 3 +- hw/exynos4210.c | 179 ++++++++++++++++++- hw/exynos4210.h | 46 +++++ hw/exynos4210_combiner.c | 384 ++++++++++++++++++++++++++++++++++++++++ hw/exynos4210_gic.c | 437 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1044 insertions(+), 5 deletions(-)create mode 100644
hw/exynos4210_combiner.c
create mode 100644hw/exynos4210_gic.cMakefile.target +0
-0@@ -336,7 +336,8 @@ obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.oobj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o
obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
Makefile.target obj-arm-y = integratorcp.o versatilepb.o arm_pic.o arm_timer.o · line 340
Quoted 3 lines
Makefile.target +2
-1-obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o +obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o exynos4210_gic.o \ + exynos4210_combiner.o
Don't use the '\' line continuation, just start a new obj-arm-y += line.
Makefile.target
Quoted 6 lines
+ for (n = 0; n < max; n++) {
Makefile.target +5
-0+ + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); + + switch (n) { + /* MDNIE_LCD1 INTG1*/
Space before the "*/", please.
Quoted 6 lines
+ case
EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0)...
+EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3):
+ irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n),
+ irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]);
+ continue;
+ break;
The 'break' here is unreachable, right?
Also the indentation is off: the irq[n] line should start 4 chars in from the 'case', not 8, and the 'continue' or 'break' should too.
Makefile.target Exynos4210State *exynos4210_init(MemoryRegion *system_mem, · line 283
Quoted 7 lines
Makefile.target +2
-1@@ -112,16 +279,20 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, /*** UARTs ***/ exynos4210_uart_create(EXYNOS4210_UART0_BASE_ADDR, - EXYNOS4210_UART0_FIFO_SIZE, 0, NULL, NULL); + EXYNOS4210_UART0_FIFO_SIZE, 0, NULL, + irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 0)]);
Having to modify the UART creation to add the IRQ line later suggests this patch series isn't in quite the right order. My suggestion:
1. hw/sysbus.h: Increase maximum number of device IRQs
2. hw/arm_boot.c: Extend secondary CPU bootloader.
3. ARM: exynos4210: IRQ subsystem support.
4. ARM: Samsung exynos4210-based boards emulation [fold hw/exynos4210.c: Boot secondary CPU. into this patch]
5. ARM: exynos4210: UART support
6. ARM: exynos4210: PWM support.
7. hw/lan9118: Add basic 16-bit mode support.
8. hw/exynos4210.c: Add LAN support for SMDKC210.
9. Exynos4210: added display controller implementation
Quoted 13 lines
Makefile.target +12
-0+++ b/hw/exynos4210_combiner.c@@ -0,0 +1,384 @@ +/* + * Samsung exynos4210 Interrupt Combiner + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. + * All rights reserved. + * + * Evgeny Voevodin <[email protected]> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your
Makefile.target line 21
Quoted 10 lines
Makefile.target +10
-0+ * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see <http://www.gnu.org/licenses/>. + */
I think it would be good to have a paragraph here explaining what a combiner actually is, for the benefit of people not familiar with the SoC.
Makefile.target line 26
Quoted 5 lines
Makefile.target +5
-0+static const MemoryRegionOps exynos4210_combiner_ops = { + .read = exynos4210_combiner_read, + .write = exynos4210_combiner_write, + .endianness = DEVICE_NATIVE_ENDIAN, +};
Indentation is wrong here.
Quoted 14 lines
Makefile.target +14
-0+ +/* + * Internal Combiner initialization. + */ +static int exynos4210_combiner_init(SysBusDevice *dev) +{ + unsigned int i; + struct Exynos4210CombinerState *s = + FROM_SYSBUS(struct Exynos4210CombinerState, dev); + + /* Allocate general purpose input signals and connect a handler to each of + * them */ + qdev_init_gpio_in(&s->busdev.qdev, exynos4210_combiner_handler, IIC_NIRQ); +
Makefile.target line 50
Quoted 10 lines
Makefile.target +10
-0+ /* Connect SysBusDev irqs to device specific irqs */ + for (i = 0; i < IIC_NIRQ; i++) { + sysbus_init_irq(dev, &s->output_irq[i]); + } + + memory_region_init_io(&s->iomem, &exynos4210_combiner_ops, s, + "exynos4210-combiner", IIC_REGION_SIZE); + sysbus_init_mmio(dev, &s->iomem); + + exynos4210_combiner_reset((DeviceState *)s);
You don't need to explicitly reset in the qdev init function if you've registered the reset function as qdev.reset (as you have).
Quoted 7 lines
Makefile.target +7
-0+ return 0; +} + +static SysBusDeviceInfo exynos4210_combiner_info = { + .qdev.name = "exynos4210.combiner", + .qdev.size = sizeof(struct Exynos4210CombinerState), + .qdev.reset = exynos4210_combiner_reset,
Makefile.target line 67
Quoted 10 lines
Makefile.target +10
-0+ .qdev.vmsd = &VMState_Exynos4210Combiner, + .init = exynos4210_combiner_init, + .qdev.props = (Property[]) { + DEFINE_PROP_UINT32("external", + struct Exynos4210CombinerState, + external, + 0), + DEFINE_PROP_END_OF_LIST(), + } +};
More dodgy indentation -- can you go through and do a general check, please?
Makefile.target line 71
Quoted 4 lines
Makefile.target +4
-0+ memory_region_add_subregion(&s->cpu_container, + EXYNOS4210_EXT_GIC_CPU_GET_OFFSET(i), &s->cpu_alias[i]); + + /* Map Distributer per SMP Core */
"Distributor".
-- PMM
PATCH v5 5/11 ARM: exynos4210: PWM support.
In reply to Evgeny Voevodin--- Makefile.target | 2 +- hw/exynos4210.c | 12 ++ hw/exynos4210_pwm.c | 416 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 429 insertions(+), 1 deletions(-) create mode 100644 hw/exynos4210_pwm.c
Makefile.target +1 -1
@@ -337,7 +337,7 @@ obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o exynos4210_gic.o \ - exynos4210_combiner.o + exynos4210_combiner.o exynos4210_pwm.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c +12 -0
@@ -30,6 +30,9 @@#define EXYNOS4210_CHIPID_ADDR 0x10000000 +/* PWM */ +#define EXYNOS4210_PWM_BASE_ADDR 0x139D0000 +/* UART's definitions */ #define EXYNOS4210_UART0_BASE_ADDR 0x13800000#define EXYNOS4210_UART1_BASE_ADDR 0x13810000
@@ -277,6 +280,15 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,memory_region_add_subregion (system_mem,EXYNOS4210_DRAM0_BASE_ADDR , &s->dram0_mem); +/* PWM */ +sysbus_create_varargs ("exynos4210.pwm" ,EXYNOS4210_PWM_BASE_ADDR , + irq_table[exynos4210_get_irq (22 ,0 )], + irq_table[exynos4210_get_irq (22 ,1 )], + irq_table[exynos4210_get_irq (22 ,2 )], + irq_table[exynos4210_get_irq (22 ,3 )], + irq_table[exynos4210_get_irq (22 ,4 )], +NULL ); +/*** UARTs ***/ exynos4210_uart_create(EXYNOS4210_UART0_BASE_ADDR, EXYNOS4210_UART0_FIFO_SIZE, 0, NULL,
hw/exynos4210_pwm.c new file +416 -0
416 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 05/11] ARM: exynos4210: PWM support.
hw/exynos4210_pwm.c line 67
Quoted 7 lines · Evgeny Voevodin
hw/exynos4210_pwm.c new file +7
-0+ +#define TCNTB(x) (0xC*x) +#define TCMPB(x) (0xC*x+1) +#define TCNTO(x) (0xC*x+2) + +#define GET_PRESCALER(reg, x) ((reg&(0xFF<<(8*x)))>>8*x) +#define GET_DIVIDER(reg, x) (1<<((0xF<<(4*x))>>(4*x)))
These macros (and the ones below) brackets around arguments (ie "(x)") to avoid operator precedence issues.
Quoted 9 lines
+static SysBusDeviceInfo
exynos4210_pwm_info= {
+ .qdev.name = "exynos4210.pwm",
+ .qdev.size = sizeof(struct Exynos4210PWMState),
+ .qdev.reset =exynos4210_pwm_reset,
+ .qdev.vmsd =&VMState_Exynos4210PWMState,
+ .init =exynos4210_pwm_init,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_END_OF_LIST(),
+ }
If you don't have any properties, you don't need to set .qdev.props at all -- there's no need to explicitly write out an empty list like this.
-- PMM
Re: [Qemu-devel] [PATCH v5 05/11] ARM: exynos4210: PWM support.
Am 10.01.2012 13:40, schrieb Peter Maydell:
Quoted 11 lines · Evgeny Voevodin
hw/exynos4210_pwm.c line 67
Quoted 7 lines
hw/exynos4210_pwm.c new file +7
-0+ +#define TCNTB (x) (0xC*x) +#define TCMPB (x) (0xC*x+1) +#define TCNTO (x) (0xC*x+2) + +#define GET_PRESCALER (reg, x) ((reg&(0xFF<<(8*x)))>>8*x) +#define GET_DIVIDER (reg, x) (1<<((0xF<<(4*x))>>(4*x)))These macros (and the ones below) brackets around arguments (ie "(x)") to avoid operator precedence issues.
And add the usual spaces around operators for readability, please.
Quoted 10 lines
hw/exynos4210_pwm.c line 408
Quoted 9 lines
hw/exynos4210_pwm.c new file +9
-0+static SysBusDeviceInfo exynos4210_pwm_info = { + .qdev.name ="exynos4210.pwm" , + .qdev.size =sizeof (struct Exynos4210PWMState ), + .qdev.reset = exynos4210_pwm_reset, + .qdev.vmsd = &VMState_Exynos4210PWMState, + .init = exynos4210_pwm_init, + .qdev.props = (Property []) { +DEFINE_PROP_END_OF_LIST (), + }
Quoted 2 lines
If you don't have any properties, you don't need to set .qdev.props at all -- there's no need to explicitly write out an empty list like this.
For qdev, that's a matter of taste (I usually add empty lists myself). With QOM that leads to a named static array with one NULL entry that can be avoided by following Peter's suggestion.
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
PATCH v5 6/11 hw/arm_boot.c: Extend secondary CPU bootloader.
In reply to Evgeny VoevodinSecondary CPU bootloader enables interrupt and issues wfi until start address is written to system controller. The position where to find this start address is hardcoded to 0x10000030. This commit extends bootloader for secondary CPU to allow a target board to cpecify a position where to find start address. If target board doesn't specify start address then default 0x10000030 is used.
--- hw/arm-misc.h | 1 + hw/arm_boot.c | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
hw/arm-misc.h +1 -0
@@ -31,6 +31,7 @@ struct arm_boot_info {const char *initrd_filename;target_phys_addr_t loader_start;target_phys_addr_t smp_loader_start; +target_phys_addr_t smp_bootreg_addr;target_phys_addr_t smp_priv_base;int nb_cpus;int board_id;
hw/arm_boot.c +15 -8
@@ -31,17 +31,17 @@ static uint32_t bootloader[] = {/* Entry point for secondary CPUs. Enable interrupt controller and Issue WFI until start address is written to system controller. */ static uint32_t smpboot[] = { -0xe59f0020 ,/* ldr r0, privbase */ -0xe3a01001 ,/* mov r1, #1 */ -0xe5801100 ,/* str r1, [r0, #0x100] */ -0xe3a00201 ,/* mov r0, #0x10000000 */ -0xe3800030 ,/* orr r0, #0x30 */ +0xe59f201c ,/* ldr r2, privbase */ +0xe59f001c ,/* ldr r0, startaddr */ +0xe3a01001 ,/* mov r1, #1 */ +0xe5821100 ,/* str r1, [r2, #256] */ 0xe320f003 ,/* wfi */ 0xe5901000 ,/* ldr r1, [r0] */ 0xe1110001 ,/* tst r1, r1 */ 0x0afffffb ,/* beq <wfi> */ 0xe12fff11 ,/* bx r1 */ -0 /* privbase: Private memory region base address. */ +0 ,/* privbase: Private memory region base address. */ +0 /* bootreg: Boot register address is held here */ };#define WRITE_WORD (p, value) do { \
@@ -179,6 +179,8 @@ static void do_cpu_reset(void *opaque) {CPUState *env = opaque;const struct arm_boot_info *info = env->boot_info; +uint32_t smp_bootreg_addr =0 ; +target_phys_addr_t p = info->smp_bootreg_addr;cpu_reset (env);if (info) {
@@ -197,6 +199,7 @@ static void do_cpu_reset(void *opaque) info->loader_start); } }else { +WRITE_WORD (p, smp_bootreg_addr); env->regs[15 ] = info->smp_loader_start; } }
@@ -272,8 +275,12 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)rom_add_blob_fixed ("bootloader" , bootloader,sizeof (bootloader), info->loader_start);if (info->nb_cpus >1 ) { - smpboot[10 ] = info->smp_priv_base; -for (n =0 ; n <sizeof (smpboot) /4 ; n++) { +if (!info->smp_bootreg_addr) { + info->smp_bootreg_addr =0x10000030 ; + } + smpboot[ARRAY_SIZE (smpboot) -1 ] = info->smp_bootreg_addr; + smpboot[ARRAY_SIZE (smpboot) -2 ] = info->smp_priv_base; +for (n =0 ; n <ARRAY_SIZE (smpboot); n++) { smpboot[n] =tswap32 (smpboot[n]); } rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot),
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 06/11] hw/arm_boot.c: Extend secondary CPU bootloader.
Quoted 6 lines · Evgeny Voevodin
Secondary CPU bootloader enables interrupt and issues wfi until start address is written to system controller. The position where to find this start address is hardcoded to
0x10000030. This commit extends bootloader for secondary CPU to allow a target board to cpecify a position where to find start address. If target board doesn't specify start address then default0x10000030is used.
I think this commit message could be slightly clearer: I suggest:
hw/arm_boot.c: Make SMP boards specify address to poll in bootup loop
The secondary CPU bootloader in arm_boot.c holds secondary CPUs in a pen until the primary CPU releases them. Make boards specify the address to be polled to determine whether to leave the pen (it was previously hardcoded to 0x10000030, which is a Versatile Express/ Realview specific system register address).
[see below for why I say "Make" rather than "Allow".]
hw/arm_boot.c static void do_cpu_reset(void *opaque) · line 186
Quoted 9 lines
hw/arm_boot.c +2
-0@@ -179,6 +179,8 @@ static void do_cpu_reset(void *opaque) { CPUState *env = opaque; const struct arm_boot_info *info = env->boot_info; + uint32_t smp_bootreg_addr = 0; + target_phys_addr_t p = info->smp_bootreg_addr; cpu_reset(env); if (info) {
This is wrong because we dereference info before we check whether it is NULL.
I apologise for not spotting earlier that WRITE_WORD() modifies its first argument, or I wouldn't have suggested it.
Let's just do
stl_phys_notdirty(info->smp_bootreg_addr, 0);
in the else clause below; then we can drop both the local vars here.
Quoted 9 lines
hw/arm_boot.c +1
-0@@ -197,6 +199,7 @@ static void do_cpu_reset(void *opaque) info->loader_start); } } else { + WRITE_WORD(p, smp_bootreg_addr); env->regs[15] = info->smp_loader_start; } }
hw/arm_boot.c void arm_load_kernel(CPUState *env, struct arm_boot_info *info) · line 280
Quoted 8 lines
hw/arm_boot.c +3
-2@@ -272,8 +275,12 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info) rom_add_blob_fixed("bootloader", bootloader, sizeof(bootloader), info->loader_start); if (info->nb_cpus > 1) { - smpboot[10] = info->smp_priv_base; - for (n = 0; n < sizeof(smpboot) / 4; n++) { + if (!info->smp_bootreg_addr) { + info->smp_bootreg_addr = 0x10000030; + }
I think we should just mandate that boards which set info->nb_cpus to something > 1 must also set info->smp_bootreg_addr. 0x10000030 is realview/vexpress/etc specific (it's the address of one of the flag registers in the sysregs).
There are only two boards which this affects:
hw/realview.c
hw/vexpress.c
(all the other ARM boards are single core).
So it's not a huge effort to update those two boards and it means we don't need this bit of backcompat code.
Otherwise OK.
-- PMM
PATCH v5 7/11 ARM: exynos4210: MCT support.
In reply to Evgeny Voevodin--- Makefile.target | 2 +- hw/exynos4210.c | 19 + hw/exynos4210_mct.c | 1494 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1514 insertions(+), 1 deletions(-) create mode 100644 hw/exynos4210_mct.c
Makefile.target +1 -1
@@ -337,7 +337,7 @@ obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o exynos4210_gic.o \ - exynos4210_combiner.o exynos4210_pwm.o + exynos4210_combiner.o exynos4210_pwm.o exynos4210_mct.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c +19 -0
@@ -33,6 +33,9 @@/* PWM */ #define EXYNOS4210_PWM_BASE_ADDR 0x139D0000 +/* MCT */ +#define EXYNOS4210_MCT_BASE_ADDR 0x10050000 +/* UART's definitions */ #define EXYNOS4210_UART0_BASE_ADDR 0x13800000#define EXYNOS4210_UART1_BASE_ADDR 0x13810000
@@ -289,6 +292,22 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, irq_table[exynos4210_get_irq (22 ,4 )], NULL); +/* Multi Core Timer */ + dev =qdev_create (NULL ,"exynos4210.mct" ); +qdev_init_nofail (dev); + busdev =sysbus_from_qdev (dev); +for (n =0 ; n <4 ; n++) { +/* Connect global timer interrupts to Combiner gpio_in */ +sysbus_connect_irq (busdev, n, + irq_table[exynos4210_get_irq (1 ,4 + n)]); + } +/* Connect local timer interrupts to Combiner gpio_in */ +sysbus_connect_irq (busdev,4 , + irq_table[exynos4210_get_irq (51 ,0 )]); +sysbus_connect_irq (busdev,5 , + irq_table[exynos4210_get_irq (35 ,3 )]); +sysbus_mmio_map (busdev,0 ,EXYNOS4210_MCT_BASE_ADDR ); +/*** UARTs ***/ exynos4210_uart_create(EXYNOS4210_UART0_BASE_ADDR, EXYNOS4210_UART0_FIFO_SIZE, 0, NULL,
hw/exynos4210_mct.c new file +1494 -0
1,494 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 07/11] ARM: exynos4210: MCT support.
hw/exynos4210_mct.c line 113
Quoted 2 lines · Evgeny Voevodin
hw/exynos4210_mct.c new file +2
-0+#define MCT_CFG_GET_PRESCALER (x) (x&0xFF) +#define MCT_CFG_GET_DIVIDER (x) (1<<(x>>8 & 7))
The macros in this file have the same bracket and spacing issues as for the other patch.
Quoted 2 lines
+ case
L0_TCON: caseL1_TCON:
+ lt_i = ((offset&0xF00) - L0_TCNTB)/0x100;
More spaces in this kind of expression would be nice.
hw/exynos4210_mct.c line 1487
Quoted 10 lines
hw/exynos4210_mct.c new file +10
-0+static SysBusDeviceInfo exynos4210_mct_info = { + .qdev.name = "exynos4210.mct", + .qdev.size = sizeof(struct Exynos4210MCTState), + .qdev.reset = exynos4210_mct_reset, + .qdev.vmsd = &VMState_Exynos4210MCTState, + .init = exynos4210_mct_init, + .qdev.props = (Property[]) { + DEFINE_PROP_END_OF_LIST(), + } +};
Unnecessary empty property list again.
Otherwise looks OK.
-- PMM
PATCH v5 8/11 hw/exynos4210.c: Boot secondary CPU.
In reply to Evgeny Voevodin--- hw/exynos4210.c | 14 ++++++++++++++ hw/exynos4210.h | 7 ++++++- hw/exynos4_boards.c | 9 +++++++++ 3 files changed, 29 insertions(+), 1 deletions(-)
hw/exynos4210.c +14 -0
@@ -283,6 +283,20 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,memory_region_add_subregion (system_mem,EXYNOS4210_DRAM0_BASE_ADDR , &s->dram0_mem); +/* +* Secondary CPU startup code will be placed here. +*/ +memory_region_init_ram (&s->hack_mem,NULL ,"exynos4210.hack" ,0x1000 ); +memory_region_add_subregion (system_mem,EXYNOS4210_SMP_BOOT_ADDR , + &s->hack_mem); + +/* +* Hack: Map SECOND_CPU_BOOTREG, because it is in PMU USER5 register. +*/ +memory_region_init_ram (&s->bootreg_mem,NULL ,"exynos4210.bootreg" ,0x4 ); +memory_region_add_subregion (system_mem,EXYNOS4210_SECOND_CPU_BOOTREG , + &s->bootreg_mem); +/* PWM */ sysbus_create_varargs("exynos4210.pwm", EXYNOS4210_PWM_BASE_ADDR, irq_table[exynos4210_get_irq(22, 0)],
hw/exynos4210.h +6 -1
@@ -43,7 +43,11 @@#define EXYNOS4210_IRAM_BASE_ADDR 0x02020000#define EXYNOS4210_IRAM_SIZE 0x00020000/* 128 KB */ +/* Secondary CPU startup code is in IROM memory */ +#define EXYNOS4210_SMP_BOOT_ADDR EXYNOS4210_IROM_BASE_ADDR#define EXYNOS4210_BASE_BOOT_ADDR EXYNOS4210_DRAM0_BASE_ADDR +/* Secondary CPU polling address to get loader start from */ +#define EXYNOS4210_SECOND_CPU_BOOTREG 0x10020814#define EXYNOS4210_SMP_PRIVATE_BASE_ADDR 0x10500000
@@ -87,7 +91,8 @@ typedef struct Exynos4210State {MemoryRegion irom_alias_mem;MemoryRegion dram0_mem;MemoryRegion dram1_mem; - +MemoryRegion hack_mem; +MemoryRegion bootreg_mem; } Exynos4210State; Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
hw/exynos4_boards.c +9 -0
@@ -52,6 +52,11 @@ static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { [EXYNOS4_BOARD_SMDKC210] = 0xB16, }; +static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS ] = { + [EXYNOS4_BOARD_NURI ] =EXYNOS4210_SECOND_CPU_BOOTREG , + [EXYNOS4_BOARD_SMDKC210 ] =EXYNOS4210_SECOND_CPU_BOOTREG , +}; +static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS ] = { [EXYNOS4_BOARD_NURI ] =0x40000000 , [EXYNOS4_BOARD_SMDKC210 ] =0x40000000 ,
@@ -59,6 +64,7 @@ static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {static struct arm_boot_info exynos4_board_binfo = { .loader_start =EXYNOS4210_BASE_BOOT_ADDR , + .smp_loader_start =EXYNOS4210_SMP_BOOT_ADDR , }; static Exynos4210State *exynos4_boards_init_common(
@@ -69,10 +75,13 @@ static Exynos4210State *exynos4_boards_init_common( { exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; exynos4_board_binfo.board_id = exynos4_board_id[board_type]; + exynos4_board_binfo.smp_bootreg_addr = + exynos4_board_smp_bootreg_addr[board_type]; exynos4_board_binfo.nb_cpus = smp_cpus; exynos4_board_binfo.kernel_filename = kernel_filename; exynos4_board_binfo.initrd_filename = initrd_filename; exynos4_board_binfo.kernel_cmdline = kernel_cmdline; + exynos4_board_binfo.smp_priv_base =EXYNOS4210_SMP_PRIVATE_BASE_ADDR ;PRINT_DEBUG ("\n ram_size: %luMiB [0x%08lx]\n" " kernel_filename: %s\n"
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 08/11] hw/exynos4210.c: Boot secondary CPU.
Quoted 3 lines · Evgeny Voevodin
+ /*
+ * Hack: MapSECOND_CPU_BOOTREG, because it is in PMU USER5 register.
+ */
Shouldn't we be modelling the PMU then?
hw/exynos4_boards.c static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { · line 58
Quoted 10 lines
+ memory_region_init_ram(&s->bootreg_mem, NULL, "exynos4210.bootreg",
0x4);
+ memory_region_add_subregion(system_mem,EXYNOS4210_SECOND_CPU_BOOTREG,
+ &s->bootreg_mem);hw/exynos4_boards.c +5
-0+ +static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS ] = { + [EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG, + [EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG, +};
Is this actually likely to differ between boards, or is it really a property of the SoC itself?
See also note in other patch about reordering and merging this patch with an earlier one.
-- PMM
Re: [Qemu-devel] [PATCH v5 08/11] hw/exynos4210.c: Boot secondary CPU.
Quoted 6 lines · Peter Maydell
hw/exynos4210.c Exynos4210State *exynos4210_init(MemoryRegion *system_mem, · line 295
Quoted 3 lines · Evgeny Voevodin
hw/exynos4210.c +3
-0+/* +* Hack: Map SECOND_CPU_BOOTREG, because it is in PMU USER5 register. +*/ Shouldn't we be modelling the PMU then?
Power Management Unit (PMU) is quite tricky and not critical for emulation. At this time PMU emulation is paused. It just represents about 16K registers array. I don't think that it is a good idea to include such a device into mainline code in order to provide one of it's register for secondary CPU boot-up.
Quoted 5 lines
Quoted 4 lines
hw/exynos4210.c +4
-0+memory_region_init_ram (&s->bootreg_mem,NULL ,"exynos4210.bootreg" ,0x4 ); +memory_region_add_subregion (system_mem,EXYNOS4210_SECOND_CPU_BOOTREG , +&s->bootreg_mem); +
Quoted 7 lines
hw/exynos4_boards.c static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { · line 58
Quoted 4 lines
hw/exynos4_boards.c +4
-0+static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS ] = { + [EXYNOS4_BOARD_NURI ] =EXYNOS4210_SECOND_CPU_BOOTREG , + [EXYNOS4_BOARD_SMDKC210 ] =EXYNOS4210_SECOND_CPU_BOOTREG , +};Is this actually likely to differ between boards, or is it really a property of the SoC itself?
Yes, it is specific to a board. There are different boards on exynos4210 SOC which have different bootreg addresses. At this time we don't emulate them.
Signature · 5 lines
Kind regards, Evgeny Voevodin, Leading Software Engineer, ASWG, Moscow R&D center, Samsung Electronics e-mail: [email protected]
PATCH v5 9/11 hw/lan9118: Add basic 16-bit mode support.
In reply to Evgeny Voevodin--- hw/lan9118.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 110 insertions(+), 5 deletions(-)
hw/lan9118.c +110 -5
@@ -212,6 +212,17 @@ typedef struct {int rxp_offset;int rxp_size;int rxp_pad; + +uint32_t write_word_prev_offset; +uint32_t write_word_n; +uint16_t write_word_l; +uint16_t write_word_h; +uint32_t read_word_prev_offset; +uint32_t read_word_n; +uint32_t read_long; + +uint32_t mode_16bit; + } lan9118_state;static void lan9118_update (lan9118_state *s)
@@ -306,7 +317,7 @@ static void lan9118_reset(DeviceState *d) s->fifo_int =0x48000000 ; s->rx_cfg =0 ; s->tx_cfg =0 ; - s->hw_cfg =0x00050000 ; + s->hw_cfg = s->mode_16bit ?0x00050000 :0x00050004 ; s->pmt_ctrl &=0x45 ; s->gpio_cfg =0 ; s->txp->fifo_used =0 ;
@@ -345,6 +356,9 @@ static void lan9118_reset(DeviceState *d) s->mac_mii_data =0 ; s->mac_flow =0 ; + s->read_word_n =0 ; + s->write_word_n =0 ; +phy_reset (s); s->eeprom_writable =0 ;
@@ -900,7 +914,7 @@ static void lan9118_writel(void *opaque, target_phys_addr_t offset, {lan9118_state *s = (lan9118_state *)opaque; offset &=0xff ; - +//DPRINTF("Write reg 0x%02x = 0x%08x\n", (int)offset, val); if (offset >=0x20 && offset <0x40 ) {/* TX FIFO */
@@ -950,7 +964,7 @@ static void lan9118_writel(void *opaque, target_phys_addr_t offset,/* SRST */ lan9118_reset (&s->busdev.qdev); }else { - s->hw_cfg = val &0x003f300 ; + s->hw_cfg = (val &0x003f300 ) | (s->hw_cfg &0x4 ); }break ;case CSR_RX_DP_CTRL :
@@ -1029,6 +1043,46 @@ static void lan9118_writel(void *opaque, target_phys_addr_t offset,lan9118_update (s); } +static void lan9118_writew (void *opaque,target_phys_addr_t offset, +uint32_t val) +{ +lan9118_state *s = (lan9118_state *)opaque; + offset &=0xff ; + +if (s->write_word_prev_offset != (offset & ~0x3 )) { +/* New offset, reset word counter */ + s->write_word_n =0 ; + s->write_word_prev_offset = offset & ~0x3 ; + } + +if (offset &0x2 ) { + s->write_word_h = val; + }else { + s->write_word_l = val; + } + +//DPRINTF("Writew reg 0x%02x = 0x%08x\n", (int)offset, val); + s->write_word_n++; +if (s->write_word_n ==2 ) { + s->write_word_n =0 ; +lan9118_writel (s, offset & ~3 , s->write_word_l + + (s->write_word_h <<16 ),4 ); + } +} + +static void lan9118_16bit_mode_write (void *opaque,target_phys_addr_t offset, +uint64_t val,unsigned size) +{ +switch (size) { +case 2 : +return lan9118_writew (opaque, offset, (uint32_t )val); +case 4 : +return lan9118_writel (opaque, offset, val, size); + } + +hw_error ("lan9118_write: Bad size 0x%x\n" , size); +} +static uint64_t lan9118_readl (void *opaque,target_phys_addr_t offset,unsigned size) {
@@ -1065,7 +1119,7 @@ static uint64_t lan9118_readl(void *opaque, target_phys_addr_t offset,case CSR_TX_CFG :return s->tx_cfg;case CSR_HW_CFG : -return s->hw_cfg |0x4 ; +return s->hw_cfg;case CSR_RX_DP_CTRL :return 0 ;case CSR_RX_FIFO_INF :
@@ -1103,12 +1157,60 @@ static uint64_t lan9118_readl(void *opaque, target_phys_addr_t offset,return 0 ; } +static uint32_t lan9118_readw (void *opaque,target_phys_addr_t offset) +{ +lan9118_state *s = (lan9118_state *)opaque; +uint32_t val; + +if (s->read_word_prev_offset != (offset & ~0x3 )) { +/* New offset, reset word counter */ + s->read_word_n =0 ; + s->read_word_prev_offset = offset & ~0x3 ; + } + + s->read_word_n++; +if (s->read_word_n ==1 ) { + s->read_long =lan9118_readl (s, offset & ~3 ,4 ); + }else { + s->read_word_n =0 ; + } + +if (offset &2 ) { + val = s->read_long >>16 ; + }else { + val = s->read_long &0xFFFF ; + } + +//DPRINTF("Readw reg 0x%02x, val 0x%x\n", (int)offset, val); +return val; +} + +static uint64_t lan9118_16bit_mode_read (void *opaque,target_phys_addr_t offset, +unsigned size) +{ +switch (size) { +case 2 : +return lan9118_readw (opaque, offset); +case 4 : +return lan9118_readl (opaque, offset, size); + } + +hw_error ("lan9118_read: Bad size 0x%x\n" , size); +return 0 ; +} +static const MemoryRegionOps lan9118_mem_ops = { .read = lan9118_readl, .write = lan9118_writel, .endianness =DEVICE_NATIVE_ENDIAN , }; +static const MemoryRegionOps lan9118_16bit_mem_ops = { + .read = lan9118_16bit_mode_read, + .write = lan9118_16bit_mode_write, + .endianness =DEVICE_NATIVE_ENDIAN , +}; +static void lan9118_cleanup (VLANClientState *nc) {lan9118_state *s =DO_UPCAST (NICState, nc, nc)->opaque;
@@ -1130,8 +1232,10 @@ static int lan9118_init1(SysBusDevice *dev)lan9118_state *s =FROM_SYSBUS (lan9118_state, dev);QEMUBH *bh;int i; +const MemoryRegionOps *mem_ops = + s->mode_16bit ? &lan9118_16bit_mem_ops : &lan9118_mem_ops; -memory_region_init_io (&s->mmio, &lan9118_mem_ops, s,"lan9118-mmio" ,0x100 ); +memory_region_init_io (&s->mmio, mem_ops, s,"lan9118-mmio" ,0x100 );sysbus_init_mmio (dev, &s->mmio);sysbus_init_irq (dev, &s->irq);qemu_macaddr_default_if_unset (&s->conf.macaddr);
@@ -1162,6 +1266,7 @@ static SysBusDeviceInfo lan9118_info = { .qdev.reset = lan9118_reset, .qdev.props = (Property []) {DEFINE_NIC_PROPERTIES (lan9118_state, conf), +DEFINE_PROP_UINT32 ("mode_16bit" , lan9118_state, mode_16bit,0 ),DEFINE_PROP_END_OF_LIST (), } };
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 09/11] hw/lan9118: Add basic 16-bit mode support.
Quoted 2 lines · Evgeny Voevodin
Signed-off-by Evgeny Voevodin <[email protected]>
with the caveat that my patch
http://patchwork.ozlabs.org/patch/132321/
adding save/load support is likely to land first, in which case you'll need to (a) rebase and (b) add your new state fields to the vmstate.
-- PMM
PATCH v5 10/11 hw/exynos4210.c: Add LAN support for SMDKC210.
In reply to Evgeny VoevodinSMDKC210 uses lan9215 chip, but lan9118 in 16-bit mode seems to be enough.
--- hw/exynos4_boards.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-)
hw/exynos4_boards.c +26 -1
@@ -22,6 +22,8 @@*/ #include "sysemu.h" +#include "sysbus.h" +#include "net.h" #include "arm-misc.h" #include "exec-memory.h" #include "exynos4210.h"
@@ -41,6 +43,8 @@ #define PRINT_DEBUG(fmt, args...) do {} while (0)#endif +#define SMDK_LAN9118_BASE_ADDR 0x05000000 + typedef enum exynos4_board_type { EXYNOS4_BOARD_NURI, EXYNOS4_BOARD_SMDKC210,
@@ -67,6 +71,24 @@ static struct arm_boot_info exynos4_board_binfo = { .smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR, }; +static void lan9215_init (uint32_t base,qemu_irq irq) +{ +DeviceState *dev; +SysBusDevice *s; + +/* This should be a 9215 but the 9118 is close enough */ +if (nd_table[0 ].vlan) { +qemu_check_nic_model (&nd_table[0 ],"lan9118" ); + dev =qdev_create (NULL ,"lan9118" ); +qdev_set_nic_properties (dev, &nd_table[0 ]); +qdev_prop_set_uint32 (dev,"mode_16bit" ,1 ); +qdev_init_nofail (dev); + s =sysbus_from_qdev (dev); +sysbus_mmio_map (s,0 , base); +sysbus_connect_irq (s,0 , irq); + } +} + static Exynos4210State *exynos4_boards_init_common( const char *kernel_filename, const char *kernel_cmdline,
@@ -113,9 +135,12 @@ static void smdkc210_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 , + Exynos4210State *s = exynos4_boards_init_common(kernel_filename, kernel_cmdline, initrd_filename,EXYNOS4_BOARD_SMDKC210 ); +lan9215_init (SMDK_LAN9118_BASE_ADDR , +qemu_irq_invert (s->irq_table[exynos4210_get_irq (37 ,1 )])); +arm_load_kernel (first_cpu, &exynos4_board_binfo); }
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 10/11] hw/exynos4210.c: Add LAN support for SMDKC210.
Quoted 4 lines · Evgeny Voevodin
SMDKC210 uses lan9215 chip, but lan9118 in 16-bit mode seems to be enough.
Signed-off-by Evgeny Voevodin <[email protected]>
PATCH v5 11/11 Exynos4210: added display controller implementation
In reply to Evgeny VoevodinFrom: Mitsyanko Igor <[email protected]>
Exynos4210 display controller (FIMD) has 5 hardware windows with alpha and chroma key blending functions.
--- Makefile.target | 3 +- hw/exynos4210.c | 9 + hw/exynos4210_fimd.c | 1783 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1794 insertions(+), 1 deletions(-) create mode 100644 hw/exynos4210_fimd.c
Makefile.target +2 -1
@@ -337,7 +337,8 @@ obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o obj-arm-y += versatile_pci.o obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o obj-arm-y += exynos4_boards.o exynos4210.o exynos4210_uart.o exynos4210_gic.o \ - exynos4210_combiner.o exynos4210_pwm.o exynos4210_mct.o + exynos4210_combiner.o exynos4210_pwm.o exynos4210_mct.o \ + exynos4210_fimd.o obj-arm-y += arm_mptimer.o obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o obj-arm-y += pl061.o
hw/exynos4210.c +9 -0
@@ -56,6 +56,9 @@#define EXYNOS4210_EXT_COMBINER_BASE_ADDR 0x10440000#define EXYNOS4210_INT_COMBINER_BASE_ADDR 0x10448000 +/* Display controllers (FIMD) */ +#define EXYNOS4210_FIMD0_BASE_ADDR 0x11C00000 +static uint8_t chipid_and_omr[] = {0x11 ,0x02 ,0x21 ,0x43 ,0x09 ,0x00 ,0x00 ,0x00 };
@@ -339,5 +342,11 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,EXYNOS4210_UART3_FIFO_SIZE ,3 ,NULL , irq_table[exynos4210_get_irq(EXYNOS4210_UART_INT_GRP, 3)]); +/*** Display controller (FIMD) ***/ +sysbus_create_varargs ("exynos4210.fimd" ,EXYNOS4210_FIMD0_BASE_ADDR , + irq_table[exynos4210_get_irq (11 ,0 )], + irq_table[exynos4210_get_irq (11 ,1 )], + irq_table[exynos4210_get_irq (11 ,2 )], +NULL );return s; }
hw/exynos4210_fimd.c new file +1783 -0
1,783 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [Qemu-devel] [PATCH v5 11/11] Exynos4210: added display controller implementation
Quoted 26 lines · Evgeny Voevodin
hw/exynos4210_fimd.c new file +26
-0+/* Perform byte/halfword/word swap of data according to WINCON */ +static inline void fimd_swap_data (unsigned int swap_ctl,uint64_t *data) +{ + int i; + uint64_t res; + uint64_t x = *data; + + if (swap_ctl & FIMD_WINCON_SWAP_BITS) { + res = 0; + for (i = 0; i < 64; i++) { + if (x & (1ULL << (64 - i))) { + res |= (1ULL << i); + } + } + x = res; + } + if (swap_ctl & FIMD_WINCON_SWAP_BYTE) { + x = ((x & 0x00000000000000FFULL) << 56) | + ((x & 0x000000000000FF00ULL) << 40) | + ((x & 0x0000000000FF0000ULL) << 24) | + ((x & 0x00000000FF000000ULL) << 8) | + ((x & 0x000000FF00000000ULL) >> 8) | + ((x & 0x0000FF0000000000ULL) >> 24) | + ((x & 0x00FF000000000000ULL) >> 40) | + ((x & 0xFF00000000000000ULL) >> 56); + }
hw/exynos4210_fimd.c line 354
Quoted 10 lines
hw/exynos4210_fimd.c new file +10
-0+ if (swap_ctl & FIMD_WINCON_SWAP_HWORD) { + x = ((x & 0x000000000000FFFFULL) << 48) | + ((x & 0x00000000FFFF0000ULL) << 16) | + ((x & 0x0000FFFF00000000ULL) >> 16) | + ((x & 0xFFFF000000000000ULL) >> 48); + } + if (swap_ctl & FIMD_WINCON_SWAP_WORD) { + x = ((x & 0x00000000FFFFFFFFULL) << 32) | + ((x & 0xFFFFFFFF00000000ULL) >> 32); + }
bswap.h provides bswap_64() which you can use for the first of these.
hw/exynos4210_fimd.c line 773
Quoted 4 lines
hw/exynos4210_fimd.c new file +4
-0+/* Draw line with index in palette table in RAM frame buffer data */ +#define DEF_DRAW_LINE_PALLETE (N ) \ +static void glue(draw_line_palette_, N)(Exynos4210fimdWindow *w, uint8_t *src, \ + uint8_t *dst, bool blend) \
The comment and the parameter are correct about the spelling of 'palette'; please fix the macro name.
exynos4210_fimd_get_bppmode() has the same typo -- global search-n-replace seems like a good idea.
Quoted 8 lines
hw/exynos4210_fimd.c new file +8
-0+static void exynos4210_fimd_write (void *opaque,target_phys_addr_t offset, + uint64_t val, unsigned size) +{ + Exynos4210fimdState *s = (Exynos4210fimdState *)opaque; + int w, i; + + DPRINT_L2("write offset 0x%08x, value=%ld(0x%08lx)\n", offset, val, val); +
hw/exynos4210_fimd.c line 1328
Quoted 10 lines
hw/exynos4210_fimd.c new file +10
-0+ if (offset == FIMD_VIDCON0) { + if ((val & FIMD_VIDCON0_ENVID_MASK) == FIMD_VIDCON0_ENVID_MASK) { + exynos4210_fimd_enable(s, true); + } else { + if ((val & FIMD_VIDCON0_ENVID) == 0) { + exynos4210_fimd_enable(s, false); + } + } + s->vidcon[0] = val; + } else if (offset == FIMD_VIDCON1) {
is using an if-else ladder here rather than a switch statement a deliberate decision ?
Otherwise looks OK I guess, though I've only scanned it rather superficially.
-- PMM