diff mbox

[3/3] arm: add EFM32GG-DK3750 support

Message ID 1399218747-22204-3-git-send-email-rabin@rab.in
State New
Headers show

Commit Message

Rabin Vincent May 4, 2014, 3:52 p.m. UTC
Add support for the EFM32GG990 MCU and its development board
EFM32GG-DK3750.  This is a Cortex-M3 platform supported
by mainline Linux.

Signed-off-by: Rabin Vincent <rabin@rab.in>
---
 default-configs/arm-softmmu.mak |  1 +
 hw/arm/Makefile.objs            |  1 +
 hw/arm/efm32.c                  | 71 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 hw/arm/efm32.c

Comments

Andreas Färber May 4, 2014, 10:01 p.m. UTC | #1
Hi,

Am 04.05.2014 17:52, schrieb Rabin Vincent:
> Add support for the EFM32GG990 MCU and its development board
> EFM32GG-DK3750.  This is a Cortex-M3 platform supported
> by mainline Linux.
> 
> Signed-off-by: Rabin Vincent <rabin@rab.in>
> ---
>  default-configs/arm-softmmu.mak |  1 +
>  hw/arm/Makefile.objs            |  1 +
>  hw/arm/efm32.c                  | 71 +++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 73 insertions(+)
>  create mode 100644 hw/arm/efm32.c

Apart from a missing cover letter to reply to, the preceding two devices
look good to me - this machine however is copying the wrong code. For
one, no semicolon after machine_init() please ;) and more importantly
please follow the example set by Canon A1000 and Allwinner A10 for SoC
vs. machine modeling. Not only does it help clarify what is actually on
the board and what on the chip and facilitates reuse by future EFM32
based boards, it also helps with the technical conversion to QOM realize
and the QOM composition tree.

Thanks,
Andreas
diff mbox

Patch

diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index f3513fa..d151f27 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -57,6 +57,7 @@  CONFIG_PL310=y
 CONFIG_PL330=y
 CONFIG_CADENCE=y
 CONFIG_XGMAC=y
+CONFIG_EFM32=y
 CONFIG_EXYNOS4=y
 CONFIG_PXA2XX=y
 CONFIG_BITBANG_I2C=y
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index 6088e53..7030a82 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -6,5 +6,6 @@  obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
 
 obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
 obj-$(CONFIG_DIGIC) += digic.o
+obj-$(CONFIG_EFM32) += efm32.o
 obj-y += omap1.o omap2.o strongarm.o
 obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o
diff --git a/hw/arm/efm32.c b/hw/arm/efm32.c
new file mode 100644
index 0000000..201f921
--- /dev/null
+++ b/hw/arm/efm32.c
@@ -0,0 +1,71 @@ 
+/*
+ * EFM32GG
+ *
+ * Copyright (C) 2014 Rabin Vincent <rabin@rab.in>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/sysbus.h"
+#include "hw/arm/arm.h"
+#include "hw/devices.h"
+#include "hw/boards.h"
+#include "hw/block/flash.h"
+#include "exec/address-spaces.h"
+
+static void efm32_init(QEMUMachineInitArgs *args)
+{
+    static const int timer_irq[] = {2, 12, 13, 14};
+    const char *cpu_model = args->cpu_model;
+    const char *kernel_filename = args->kernel_filename;
+    MemoryRegion *address_space_mem = get_system_memory();
+    qemu_irq *pic;
+    int i;
+    MemoryRegion *nor = g_new(MemoryRegion, 1);
+    MemoryRegion *psram = g_new(MemoryRegion, 1);
+    DriveInfo *dinfo;
+    uint32_t flashsize = 16 * 1024 * 1024;
+
+    pic = armv7m_init(address_space_mem, 1024, 128, kernel_filename, cpu_model);
+
+    memory_region_init_ram(psram, NULL, "psram", 4 * 1024 * 1024);
+    vmstate_register_ram_global(psram);
+    memory_region_add_subregion(address_space_mem, 0x88000000, psram);
+
+    memory_region_init_ram(nor, NULL, "flash", flashsize);
+    vmstate_register_ram_global(nor);
+    memory_region_add_subregion(address_space_mem, 0x8C000000, nor);
+    memory_region_set_readonly(nor, true);
+
+    sysbus_create_varargs("efm32-uart", 0x4000e400, pic[22], pic[23], NULL);
+    for (i = 0; i < 4; i++) {
+        sysbus_create_simple("efm32-timer", 0x40010000 + i * 0x400,
+                             pic[timer_irq[i]]);
+    }
+
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (dinfo) {
+        int sector_len = 128 * 1024;
+        if (!pflash_cfi01_register(0x8c000000, NULL, "dk.flash", flashsize,
+                                   dinfo ? dinfo->bdrv : NULL,
+                                   sector_len, flashsize / sector_len,
+                                   2, 0, 0, 0, 0, 0)) {
+            fprintf(stderr, "qemu: Error registering flash memory.\n");
+            exit(1);
+        }
+    }
+}
+
+static QEMUMachine efm32ggdk3750_machine = {
+    .name = "efm32ggdk3750",
+    .desc = "EnergyMicro Giant Gecko Development Kit",
+    .init = efm32_init,
+};
+
+static void efm32_machine_init(void)
+{
+    qemu_register_machine(&efm32ggdk3750_machine);
+}
+
+machine_init(efm32_machine_init);