Skip to contentSkip to conversation

ARM: Samsung Exynos4210-based boards support.

PATCH Superseded Evgeny Voevodin 2 participants 17 messages Dec 9, 2011

Subsystems (2)

v2 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v2 cover ARM: Samsung Exynos4210-based boards support.

Second version of patches: add support for Samsung Exynos4210-based boards NURI and SMDKC210.
Tested on Linux kernel v3.x series. Usage of "-smp 2" option is reuired for now.

Evgeny Voevodin (9):
hw/sysbus.h: Increase maximum number of device IRQs.
ARM: exynos4210: IRQ subsystem support.
ARM: exynos4210: PWM support.
hw/arm_boot.c: Add new secondary CPU bootloader. hw/arm_gic.c: lower IRQ only on changing of enable bit.
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 (3):
ARM: Samsung exynos4210-based boards emulation
ARM: exynos4210: CMU support
ARM: exynos4210: UART support

Mitsyanko Igor (3):
hw/sd.c, hw/sd.h: add receive ready query routine to SD/MMC API
ARM: exynos4210: added SD/MMC host controller
ARM: exynos4210: added display controller implementation

 Makefile.target          |    3 +
 hw/arm-misc.h            |    1 +
 hw/arm_boot.c            |   22 +-
 hw/arm_gic.c             |   20 +-
 hw/devices.h             |    2 +-
 hw/exynos4210.c          |  547 +++++++++++++++
 hw/exynos4210.h          |  106 +++
 hw/exynos4210_cmu.c      | 1146 ++++++++++++++++++++++++++++++
 hw/exynos4210_combiner.c |  385 ++++++++++
 hw/exynos4210_fimd.c     | 1737 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/exynos4210_gic.c      |  415 +++++++++++
 hw/exynos4210_mct.c      | 1486 +++++++++++++++++++++++++++++++++++++++
 hw/exynos4210_pwm.c      |  433 ++++++++++++
 hw/exynos4210_sdhc.c     | 1666 ++++++++++++++++++++++++++++++++++++++++++++
 hw/exynos4210_uart.c     |  674 ++++++++++++++++++
 hw/lan9118.c             |  115 +++-
 hw/sd.c                  |    5 +
 hw/sd.h                  |    1 +
 hw/sysbus.h              |    2 +-
 19 files changed, 8749 insertions(+), 17 deletions(-)
 create mode 100644 hw/exynos4210.c
 create mode 100644 hw/exynos4210.h
 create mode 100644 hw/exynos4210_cmu.c
 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_sdhc.c
 create mode 100644 hw/exynos4210_uart.c
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH v2 1/15 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 |  224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/exynos4210.h |   34 ++++++++
 3 files changed, 259 insertions(+), 0 deletions(-)
 create mode 100644 hw/exynos4210.c
 create mode 100644 hw/exynos4210.h
Makefile.target +1 -0
index a111521..624a142 100644
@@ -344,6 +344,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 += exynos4210.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c new file +224 -0

224 lines not on this page · raw message

hw/exynos4210.h new file +34 -0
new file mode 100644
index 0000000..7137630
@@ -0,0 +1,34 @@
+/*
+ *  Samsung exynos4210-based boards emulation
+ *
+ *  Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *    Maksim Kozlov <[email protected]>
+ *    Evgeny Voevodin <[email protected]>
+ *    Igor Mitsyanko <[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 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, write to the Free Software Foundation, Inc., 51
+ *  Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef EXYNOS4210_H_
+#define EXYNOS4210_H_
+
+#include "qemu-common.h"
+
+#define EXYNOS4210_MAX_CPUS                2
+
+#endif /* EXYNOS4210_H_ */
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 2/15 ARM: exynos4210: CMU support

In reply to Evgeny Voevodin

From: Maksim Kozlov <[email protected]>

Add exynos4210 Clock Management Units emulation

---
 Makefile.target     |    2 +-
 hw/exynos4210.c     |    7 +
 hw/exynos4210.h     |   22 +
 hw/exynos4210_cmu.c | 1146 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1176 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_cmu.c
Makefile.target +1 -1
index 624a142..ce4f1f8 100644
@@ -344,7 +344,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 += exynos4210.o
+obj-arm-y += exynos4210.o exynos4210_cmu.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +7 -0
index 1550016..1a6e353 100644
@@ -60,6 +60,10 @@
 
 #define EXYNOS4210_BASE_BOOT_ADDR           EXYNOS4210_DRAM0_BASE_ADDR
 
+/* SFR Base Address for CMUs */
+#define EXYNOS4210_CMU_BASE_ADDR            0x10030000
+
+
 static struct arm_boot_info exynos4210_binfo = {
         .loader_start     = EXYNOS4210_BASE_BOOT_ADDR,
 };
@@ -172,6 +176,9 @@ static void exynos4210_init(ram_addr_t ram_size,
     memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
             dram0_mem);
 
+    /* CMU */
+    sysbus_create_simple("exynos4210.cmu", EXYNOS4210_CMU_BASE_ADDR, NULL);
+
     /*** Load kernel ***/
 
     exynos4210_binfo.ram_size = ram_size;
hw/exynos4210.h +22 -0
index 7137630..683a4a6 100644
@@ -31,4 +31,26 @@
 
 #define EXYNOS4210_MAX_CPUS                2
 
+/*
+ * Interface for exynos4210 Clock Management Units (CMUs)
+ */
+
+typedef enum {
+    XXTI,
+    XUSBXTI,
+    APLL,
+    MPLL,
+    SCLK_APLL,
+    SCLK_MPLL,
+    ACLK_100,
+    SCLK_UART0,
+    SCLK_UART1,
+    SCLK_UART2,
+    SCLK_UART3,
+    SCLK_UART4,
+    CLOCKS_NUMBER
+} Exynos4210CmuClock;
+
+uint64_t exynos4210_cmu_get_rate(Exynos4210CmuClock clock);
+
 #endif /* EXYNOS4210_H_ */
hw/exynos4210_cmu.c new file +1146 -0

1,146 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#3 lore raw

PATCH v2 3/15 ARM: exynos4210: UART support

In reply to Evgeny Voevodin

From: Maksim Kozlov <[email protected]>

Add basic support of exynos4210 UART

Conflicts:

Makefile.target

---
 Makefile.target      |    2 +-
 hw/exynos4210.c      |   51 ++++
 hw/exynos4210.h      |    9 +
 hw/exynos4210_uart.c |  674 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 735 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_uart.c
Makefile.target +1 -1
index ce4f1f8..4c706b1 100644
@@ -344,7 +344,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 += exynos4210.o exynos4210_cmu.o
+obj-arm-y += exynos4210.o exynos4210_cmu.o exynos4210_uart.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +51 -0

63 lines not on this page · raw message

hw/exynos4210.h +9 -0
index 683a4a6..3df7322 100644
@@ -53,4 +53,13 @@ typedef enum {
 
 uint64_t exynos4210_cmu_get_rate(Exynos4210CmuClock clock);
 
+/*
+ * 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 +674 -0

674 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#4 lore raw

PATCH v2 4/15 hw/sysbus.h: Increase maximum number of device IRQs.

In reply to Evgeny Voevodin

Samsung exynos4210 Interrupt Combiner needs 512 IRQ sources.

---
 hw/sysbus.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/sysbus.h +1 -1
index 9bac582..4ef0c3c 100644
@@ -8,7 +8,7 @@
 
 #define QDEV_MAX_MMIO 32
 #define QDEV_MAX_PIO 32
-#define QDEV_MAX_IRQ 256
+#define QDEV_MAX_IRQ 512
 
 typedef struct SysBusDevice SysBusDevice;
 typedef void (*mmio_mapfunc)(SysBusDevice *dev, target_phys_addr_t addr);
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH v2 5/15 ARM: exynos4210: IRQ subsystem support.

In reply to Evgeny Voevodin
---
 Makefile.target          |    3 +-
 hw/exynos4210.c          |  161 ++++++++++++++++++-
 hw/exynos4210.h          |   41 +++++
 hw/exynos4210_combiner.c |  385 ++++++++++++++++++++++++++++++++++++++++++
 hw/exynos4210_gic.c      |  415 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 1003 insertions(+), 2 deletions(-)
 create mode 100644 hw/exynos4210_combiner.c
 create mode 100644 hw/exynos4210_gic.c
Makefile.target +2 -1
index 4c706b1..779c9d4 100644
@@ -344,7 +344,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 += exynos4210.o exynos4210_cmu.o exynos4210_uart.o
+obj-arm-y += exynos4210.o exynos4210_cmu.o exynos4210_uart.o exynos4210_gic.o \
+             exynos4210_combiner.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +160 -1

206 lines not on this page · raw message

hw/exynos4210.h +41 -0

47 lines not on this page · raw message

hw/exynos4210_combiner.c new file +385 -0

385 lines not on this page · raw message

hw/exynos4210_gic.c new file +415 -0

415 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#6 lore raw

PATCH v2 6/15 ARM: exynos4210: PWM support.

In reply to Evgeny Voevodin
---
 Makefile.target     |    2 +-
 hw/exynos4210.c     |   12 ++
 hw/exynos4210_pwm.c |  433 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 446 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_pwm.c
Makefile.target +1 -1
index 779c9d4..709e9e2 100644
@@ -345,7 +345,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 += exynos4210.o exynos4210_cmu.o exynos4210_uart.o exynos4210_gic.o \
-             exynos4210_combiner.o
+             exynos4210_combiner.o exynos4210_pwm.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +12 -0
index a936dcf..361cdfb 100644
@@ -65,6 +65,9 @@
 /* SFR Base Address for CMUs */
 #define EXYNOS4210_CMU_BASE_ADDR            0x10030000
 
+/* PWM */
+#define EXYNOS4210_PWM_BASE_ADDR            0x139D0000
+
 /* UART's definitions */
 #define EXYNOS4210_UART_BASE_ADDR           0x13800000
 #define EXYNOS4210_UART_SHIFT               0x00010000
@@ -350,6 +353,15 @@ static void exynos4210_init(ram_addr_t ram_size,
     /* CMU */
     sysbus_create_simple("exynos4210.cmu", EXYNOS4210_CMU_BASE_ADDR, NULL);
 
+    /* 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 ***/
     for (n = 0; n < EXYNOS4210_UARTS_NUMBER; n++) {
 
hw/exynos4210_pwm.c new file +433 -0

433 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#7 lore raw

PATCH v2 7/15 hw/arm_boot.c: Add new secondary CPU bootloader.

In reply to 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 adds new bootloader for secondary CPU which allows 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 |   22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)
hw/arm-misc.h +1 -0
index af403a1..6e8ae6b 100644
@@ -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 -7
index 215d5de..ecaac22 100644
@@ -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 hold here */
 };
 
 #define WRITE_WORD(p, value) do { \
@@ -179,6 +179,7 @@ static void do_cpu_reset(void *opaque)
 {
     CPUState *env = opaque;
     const struct arm_boot_info *info = env->boot_info;
+    uint8_t smp_bootreg_addr[4] = {0};
 
     cpu_reset(env);
     if (info) {
@@ -197,6 +198,8 @@ static void do_cpu_reset(void *opaque)
                                     info->loader_start);
                 }
             } else {
+                cpu_physical_memory_rw(info->smp_bootreg_addr, smp_bootreg_addr,
+                        sizeof(smp_bootreg_addr), 1);
                 env->regs[15] = info->smp_loader_start;
             }
         }
@@ -262,6 +265,7 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
         } else {
             initrd_size = 0;
         }
+
         bootloader[1] |= info->board_id & 0xff;
         bootloader[2] |= (info->board_id >> 8) & 0xff;
         bootloader[5] = info->loader_start + KERNEL_ARGS_ADDR;
@@ -272,7 +276,11 @@ 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;
+            if (!info->smp_bootreg_addr) {
+                info->smp_bootreg_addr = 0x10000030;
+            }
+            smpboot[(sizeof(smpboot) - 8)/4] = info->smp_priv_base;
+            smpboot[(sizeof(smpboot) - 4)/4] = info->smp_bootreg_addr;
             for (n = 0; n < sizeof(smpboot) / 4; n++) {
                 smpboot[n] = tswap32(smpboot[n]);
             }
Signature · 1 line
1.7.4.1
#8 lore raw

PATCH v2 8/15 hw/arm_gic.c: lower IRQ only on changing of enable bit.

In reply to Evgeny Voevodin

In previous version IRQ was lowered every time if enable bits were not set. If platform has splitted IRQ source to pass IRQ to two identical GICs simultaneously in first of which IRQ passing is enabled but in second is disabled, handling IRQ by second GIC would lower IRQ previously raised by first GIC.
Linux kernel v3.0 faces this problem.
The problem is avoided if IRQ is only lowered as result of transitioning enable bits to zeroes.

---
 hw/arm_gic.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
hw/arm_gic.c +19 -1
index 527c9ce..7e3db4f 100644
@@ -84,7 +84,9 @@ typedef struct gic_state
     SysBusDevice busdev;
     qemu_irq parent_irq[NCPU];
     int enabled;
+    int enabled_prev;
     int cpu_enabled[NCPU];
+    int cpu_enabled_prev[NCPU];
 
     gic_irq_state irq_state[GIC_NIRQ];
 #ifndef NVIC
@@ -116,12 +118,22 @@ static void gic_update(gic_state *s)
     int level;
     int cpu;
     int cm;
+    int enabled_prev;
+    int cpu_enabled_prev;
 
+    enabled_prev = s->enabled_prev;
+    s->enabled_prev = s->enabled;
     for (cpu = 0; cpu < NUM_CPU(s); cpu++) {
+        cpu_enabled_prev = s->cpu_enabled_prev[cpu];
+        s->cpu_enabled_prev[cpu] = s->cpu_enabled[cpu];
         cm = 1 << cpu;
         s->current_pending[cpu] = 1023;
         if (!s->enabled || !s->cpu_enabled[cpu]) {
-	    qemu_irq_lower(s->parent_irq[cpu]);
+            /* lower IRQ only if enable bit was changed */
+            if (enabled_prev != s->enabled
+                    || cpu_enabled_prev != s->cpu_enabled[cpu]) {
+                qemu_irq_lower(s->parent_irq[cpu]);
+            }
             return;
         }
         best_prio = 0x100;
@@ -650,6 +662,7 @@ static void gic_reset(gic_state *s)
 #else
         s->cpu_enabled[i] = 0;
 #endif
+        s->cpu_enabled_prev[i] = s->cpu_enabled[i];
     }
     for (i = 0; i < 16; i++) {
         GIC_SET_ENABLED(i, ALL_CPU_MASK);
@@ -661,6 +674,7 @@ static void gic_reset(gic_state *s)
 #else
     s->enabled = 0;
 #endif
+    s->enabled_prev = s->enabled;
 }
 
 static void gic_save(QEMUFile *f, void *opaque)
@@ -669,8 +683,10 @@ static void gic_save(QEMUFile *f, void *opaque)
     int i;
     int j;
 
+    qemu_put_be32(f, s->enabled_prev);
     qemu_put_be32(f, s->enabled);
     for (i = 0; i < NUM_CPU(s); i++) {
+        qemu_put_be32(f, s->cpu_enabled_prev[i]);
         qemu_put_be32(f, s->cpu_enabled[i]);
         for (j = 0; j < 32; j++)
             qemu_put_be32(f, s->priority1[j][i]);
@@ -706,8 +722,10 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id)
     if (version_id != 2)
         return -EINVAL;
 
+    s->enabled_prev = qemu_get_be32(f);
     s->enabled = qemu_get_be32(f);
     for (i = 0; i < NUM_CPU(s); i++) {
+        s->cpu_enabled_prev[i] = qemu_get_be32(f);
         s->cpu_enabled[i] = qemu_get_be32(f);
         for (j = 0; j < 32; j++)
             s->priority1[j][i] = qemu_get_be32(f);
Signature · 1 line
1.7.4.1
#9 lore raw

Re: [Qemu-devel] [PATCH 08/15] hw/arm_gic.c: lower IRQ only on changing of enable bit.

Quoted 8 lines

In previous version IRQ was lowered every time if enable bits were not set. If platform has splitted IRQ source to pass IRQ to two identical GICs simultaneously in first of which IRQ passing is enabled but in second is disabled, handling IRQ by second GIC would lower IRQ previously raised by first GIC.
Linux kernel v3.0 faces this problem.
The problem is avoided if IRQ is only lowered as result of transitioning enable bits to zeroes.

This is almost certainly wrong. IRQ lines are state based, not event based. Re-asserting an existing level should always be a no-op.

My guess is your real bug it that your IRQ wiring is broken, and you have multiple outputs connected to a single input. Don't do that. Ever. If you need to connent multiple output pins to a single input pin then you need an explicit device (e.g. an or gate) in between.

Paul

#10 lore raw

PATCH v2 9/15 ARM: exynos4210: MCT support.

In reply to Evgeny Voevodin
---
 Makefile.target     |    2 +-
 hw/exynos4210.c     |   19 +
 hw/exynos4210_mct.c | 1486 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1506 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_mct.c
Makefile.target +1 -1
index 709e9e2..691582b 100644
@@ -345,7 +345,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 += exynos4210.o exynos4210_cmu.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 += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +19 -0
index 361cdfb..f172346 100644
@@ -68,6 +68,9 @@
 /* PWM */
 #define EXYNOS4210_PWM_BASE_ADDR            0x139D0000
 
+/* MCT */
+#define EXYNOS4210_MCT_BASE_ADDR            0x10050000
+
 /* UART's definitions */
 #define EXYNOS4210_UART_BASE_ADDR           0x13800000
 #define EXYNOS4210_UART_SHIFT               0x00010000
@@ -362,6 +365,22 @@ static void exynos4210_init(ram_addr_t ram_size,
             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 ***/
     for (n = 0; n < EXYNOS4210_UARTS_NUMBER; n++) {
 
hw/exynos4210_mct.c new file +1486 -0

1,486 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#11 lore raw

PATCH v2 10/15 hw/exynos4210.c: Boot secondary CPU.

In reply to Evgeny Voevodin
---
 hw/exynos4210.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
hw/exynos4210.c +27 -1
index f172346..8d8a12c 100644
@@ -93,6 +93,12 @@
 #define EXYNOS4210_EXT_COMBINER_BASE_ADDR   0x10440000
 #define EXYNOS4210_INT_COMBINER_BASE_ADDR   0x10448000
 
+/* Secondary CPU polling address to get loader start from */
+#define EXYNOS4210_SECOND_CPU_BOOTREG       0x10020814
+
+/* Secondary CPU startup code is in IROM memory */
+#define EXYNOS4210_SMP_BOOT_ADDR            EXYNOS4210_IROM_BASE_ADDR
+
 static struct arm_boot_info exynos4210_binfo = {
         .loader_start     = EXYNOS4210_BASE_BOOT_ADDR,
 };
@@ -208,6 +214,8 @@ static void exynos4210_init(ram_addr_t ram_size,
     MemoryRegion *irom_alias_mem = g_new(MemoryRegion, 1);
     MemoryRegion *dram0_mem = g_new(MemoryRegion, 1);
     MemoryRegion *dram1_mem = NULL;
+    MemoryRegion *hack_mem = g_new(MemoryRegion, 1);
+    MemoryRegion *bootreg_mem = g_new(MemoryRegion, 1);
     Exynos4210Irq *irqs;
     qemu_irq *irq_table;
     qemu_irq *irqp;
@@ -219,10 +227,12 @@ static void exynos4210_init(ram_addr_t ram_size,
 
     switch (board_type) {
     case BOARD_EXYNOS4210_NURI:
-        exynos4210_binfo.board_id      = MACH_NURI_ID;
+        exynos4210_binfo.board_id = MACH_NURI_ID;
+        exynos4210_binfo.smp_bootreg_addr = EXYNOS4210_SECOND_CPU_BOOTREG;
     break;
     case BOARD_EXYNOS4210_SMDKC210:
         exynos4210_binfo.board_id = MACH_SMDKC210_ID;
+        exynos4210_binfo.smp_bootreg_addr = EXYNOS4210_SECOND_CPU_BOOTREG;
     break;
     default:
     break;
@@ -353,6 +363,21 @@ static void exynos4210_init(ram_addr_t ram_size,
     memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
             dram0_mem);
 
+    /*
+     * Secondary CPU startup code will be placed here.
+     */
+    memory_region_init_ram(hack_mem, NULL, "exynos4210.hack", 0x1000);
+    memory_region_add_subregion(system_mem, EXYNOS4210_SMP_BOOT_ADDR,
+            hack_mem);
+
+   /*
+    * Hack: Map SECOND_CPU_BOOTREG, because it is in PMU USER5 register.
+    */
+   memory_region_init_ram(bootreg_mem, NULL, "exynos4210.bootreg", 0x4);
+   memory_region_add_subregion(system_mem, EXYNOS4210_SECOND_CPU_BOOTREG,
+           bootreg_mem);
+
+
     /* CMU */
     sysbus_create_simple("exynos4210.cmu", EXYNOS4210_CMU_BASE_ADDR, NULL);
 
@@ -427,6 +452,7 @@ static void exynos4210_init(ram_addr_t ram_size,
     exynos4210_binfo.kernel_filename = kernel_filename;
     exynos4210_binfo.initrd_filename = initrd_filename;
     exynos4210_binfo.kernel_cmdline = kernel_cmdline;
+    exynos4210_binfo.smp_priv_base = EXYNOS4210_SMP_PRIVATE_BASE_ADDR;
 
     arm_load_kernel(first_cpu, &exynos4210_binfo);
 }
Signature · 1 line
1.7.4.1
#12 lore raw

PATCH v2 11/15 hw/lan9118: Add basic 16-bit mode support.

In reply to Evgeny Voevodin
---
 hw/devices.h |    2 +-
 hw/lan9118.c |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 109 insertions(+), 8 deletions(-)
hw/devices.h +1 -1
index 1a55c1e..24cae4c 100644
@@ -10,7 +10,7 @@ struct MemoryRegion;
 void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
 
 /* lan9118.c */
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
+DeviceState *lan9118_init(NICInfo *, uint32_t, qemu_irq);
 
 /* tsc210x.c */
 uWireSlave *tsc2102_init(qemu_irq pint);
hw/lan9118.c +108 -7

173 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#13 lore raw

PATCH v2 12/15 hw/exynos4210.c: Add LAN support for SMDKC210.

In reply to Evgeny Voevodin

SMDKC210 uses lan9215 chip, but lan9118 in 16-bit mode seems to be enough.

---
 hw/exynos4210.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
hw/exynos4210.c +18 -0
index 8d8a12c..5b18b68 100644
@@ -26,6 +26,8 @@
 #include "sysemu.h"
 #include "sysbus.h"
 #include "arm-misc.h"
+#include "net.h"
+#include "devices.h"
 #include "exec-memory.h"
 #include "exynos4210.h"
 
@@ -224,6 +226,8 @@ static void exynos4210_init(ram_addr_t ram_size,
     SysBusDevice *busdev;
     ram_addr_t mem_size;
     int n;
+    NICInfo *nd;
+    int done_nic = 0;
 
     switch (board_type) {
     case BOARD_EXYNOS4210_NURI:
@@ -444,6 +448,20 @@ static void exynos4210_init(ram_addr_t ram_size,
         exynos4210_uart_create(addr, fifo_size, channel, NULL, uart_irq);
     }
 
+    /*** LAN adapter: this should be a 9215 but the 9118 is close enough ***/
+    if (board_type == BOARD_EXYNOS4210_SMDKC210) {
+        for (n = 0; n < nb_nics; n++) {
+            nd = &nd_table[n];
+
+            if (!done_nic && (!nd->model ||
+                    strcmp(nd->model, "lan9118") == 0)) {
+                dev = lan9118_init(nd, 0x05000000,
+                        qemu_irq_invert(irq_table[exynos4210_get_irq(37, 1)]));
+                qdev_prop_set_uint32(dev, "mode_16bit", 1);
+                done_nic = 1;
+            }
+        }
+    }
 
     /*** Load kernel ***/
 
Signature · 1 line
1.7.4.1
#14 lore raw

PATCH v2 13/15 hw/sd.c, hw/sd.h: add receive ready query routine to SD/MMC API

In reply to Evgeny Voevodin

From: Mitsyanko Igor <[email protected]>

Data transfer direction between host controller and SD/MMC card is selected by host controller configuration registers, but whether we actually need or need not perform data transfer depends on type of last issued command. To avoid memorization of which type of command host controller issued the last time, we can use simple query procedures, to make sure that SD/MMC card is in the right state. The only query routine currently presented in SD/MMC card emulation is sd_data_ready(), this patch adds sd_receive_ready() routine.

---
 hw/sd.c |    5 +++++
 hw/sd.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)
hw/sd.c +5 -0
index 10e26ad..b0a8557 100644
@@ -1670,3 +1670,8 @@ void sd_enable(SDState *sd, int enable)
 {
     sd->enable = enable;
 }
+
+int sd_receive_ready(SDState *sd)
+{
+    return sd->state == sd_receivingdata_state;
+}
hw/sd.h +1 -0
index ac4b7c4..71ab781 100644
@@ -75,5 +75,6 @@ uint8_t sd_read_data(SDState *sd);
 void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert);
 int sd_data_ready(SDState *sd);
 void sd_enable(SDState *sd, int enable);
+int sd_receive_ready(SDState *sd);
 
 #endif	/* __hw_sd_h */
Signature · 1 line
1.7.4.1
#15 lore raw

PATCH v2 14/15 ARM: exynos4210: added SD/MMC host controller

In reply to Evgeny Voevodin

From: Mitsyanko Igor <[email protected]>

---
 Makefile.target      |    3 +-
 hw/exynos4210.c      |   20 +
 hw/exynos4210_sdhc.c | 1666 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1688 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_sdhc.c
Makefile.target +2 -1
index 691582b..a5d67c9 100644
@@ -345,7 +345,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 += exynos4210.o exynos4210_cmu.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_sdhc.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +20 -0
index 5b18b68..62c90e9 100644
@@ -95,6 +95,12 @@
 #define EXYNOS4210_EXT_COMBINER_BASE_ADDR   0x10440000
 #define EXYNOS4210_INT_COMBINER_BASE_ADDR   0x10448000
 
+/* SD/MMC host controllers SFR base addresses */
+#define EXYNOS4210_SDHC0_BASE_ADDR          0x12510000
+#define EXYNOS4210_SDHC1_BASE_ADDR          0x12520000
+#define EXYNOS4210_SDHC2_BASE_ADDR          0x12530000
+#define EXYNOS4210_SDHC3_BASE_ADDR          0x12540000
+
 /* Secondary CPU polling address to get loader start from */
 #define EXYNOS4210_SECOND_CPU_BOOTREG       0x10020814
 
@@ -448,6 +454,20 @@ static void exynos4210_init(ram_addr_t ram_size,
         exynos4210_uart_create(addr, fifo_size, channel, NULL, uart_irq);
     }
 
+    /*** SD/MMC host controllers ***/
+
+    sysbus_create_simple("exynos4210.sdhc", EXYNOS4210_SDHC0_BASE_ADDR,
+            irq_table[exynos4210_get_irq(29, 0)]);
+
+    sysbus_create_simple("exynos4210.sdhc", EXYNOS4210_SDHC1_BASE_ADDR,
+            irq_table[exynos4210_get_irq(29, 1)]);
+
+    sysbus_create_simple("exynos4210.sdhc", EXYNOS4210_SDHC2_BASE_ADDR,
+            irq_table[exynos4210_get_irq(29, 2)]);
+
+    sysbus_create_simple("exynos4210.sdhc", EXYNOS4210_SDHC3_BASE_ADDR,
+            irq_table[exynos4210_get_irq(29, 3)]);
+
     /*** LAN adapter: this should be a 9215 but the 9118 is close enough ***/
     if (board_type == BOARD_EXYNOS4210_SMDKC210) {
         for (n = 0; n < nb_nics; n++) {
hw/exynos4210_sdhc.c new file +1666 -0

1,666 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#16 lore raw

PATCH v2 15/15 ARM: exynos4210: added display controller implementation

In reply to Evgeny Voevodin

From: Mitsyanko Igor <[email protected]>

Exynos4210 display controller (FIMD) supports up to 5 hardware windows, along with alpha and chromakey blending capabilities.

---
 Makefile.target      |    2 +-
 hw/exynos4210.c      |   11 +
 hw/exynos4210_fimd.c | 1737 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1749 insertions(+), 1 deletions(-)
 create mode 100644 hw/exynos4210_fimd.c
Makefile.target +1 -1
index a5d67c9..b4cd185 100644
@@ -346,7 +346,7 @@ obj-arm-y += versatile_pci.o
 obj-arm-y += realview_gic.o realview.o arm_sysctl.o arm11mpcore.o a9mpcore.o
 obj-arm-y += exynos4210.o exynos4210_cmu.o exynos4210_uart.o exynos4210_gic.o \
              exynos4210_combiner.o exynos4210_pwm.o exynos4210_mct.o \
-             exynos4210_sdhc.o
+             exynos4210_sdhc.o exynos4210_fimd.o
 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
 obj-arm-y += pl061.o
 obj-arm-y += arm-semi.o
hw/exynos4210.c +11 -0
index 62c90e9..2f3a5be 100644
@@ -101,6 +101,10 @@
 #define EXYNOS4210_SDHC2_BASE_ADDR          0x12530000
 #define EXYNOS4210_SDHC3_BASE_ADDR          0x12540000
 
+/* Display controllers (FIMD) */
+#define EXYNOS4210_FIMD0_BASE_ADDR          0x11C00000
+#define EXYNOS4210_FIMD1_BASE_ADDR          0x12000000
+
 /* Secondary CPU polling address to get loader start from */
 #define EXYNOS4210_SECOND_CPU_BOOTREG       0x10020814
 
@@ -483,6 +487,13 @@ static void exynos4210_init(ram_addr_t ram_size,
         }
     }
 
+    /*** 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);
+
     /*** Load kernel ***/
 
     exynos4210_binfo.ram_size = ram_size;
hw/exynos4210_fimd.c new file +1737 -0

1,737 lines not on this page · raw message

Signature · 1 line
1.7.4.1