Patchwork [V2,4/4] imx.31 and KZM board support: Makefile and board

login
register
mail settings
Submitter Peter Chubb
Date Nov. 22, 2011, 4:34 a.m.
Message ID <w41ut0bwr3.wl%peter@chubb.wattle.id.au>
Download mbox | patch
Permalink /patch/126999/
State New
Headers show

Comments

Peter Chubb - Nov. 22, 2011, 4:34 a.m.
Board support for Kyoto Micro's KZM-ARM11-01, an evaluation board built
around the FreeScale i.MX31.

Signed-off-by: Hans Jang <hsjang@ok-labs.com>
Signed-off-by: Adam Clench <adamc@ok-labs.com>
Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
---
 Makefile.target |    2 
 hw/kzm.c        |  155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 157 insertions(+)
 create mode 100644 hw/kzm.c


--
Dr Peter Chubb  http://www.gelato.unsw.edu.au  peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au           ERTOS within National ICT Australia
Peter Maydell - Nov. 24, 2011, 7:41 p.m.
On 22 November 2011 04:34, Peter Chubb <peter.chubb@nicta.com.au> wrote:
> Board support for Kyoto Micro's KZM-ARM11-01, an evaluation board built
> around the FreeScale i.MX31.

This patch mostly looks OK to me.

> +obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
> +obj-arm-y += kzm.o

It would be better to add the devices to the makefile in their
corresponding patches, I think. (Don't feel too strongly about that
though so somebody might overrule me.)

-- PMM
Andreas Färber - Nov. 24, 2011, 8:19 p.m.
Am 24.11.2011 20:41, schrieb Peter Maydell:
> On 22 November 2011 04:34, Peter Chubb <peter.chubb@nicta.com.au> wrote:
>> +obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
>> +obj-arm-y += kzm.o
> 
> It would be better to add the devices to the makefile in their
> corresponding patches, I think. (Don't feel too strongly about that
> though so somebody might overrule me.)

Well, I do: Without adding them to the Makefile they don't get
compile-tested. (I prefer convincing over ruling though.)

Andreas
Peter Maydell - Nov. 24, 2011, 9:31 p.m.
On 24 November 2011 20:19, Andreas Färber <afaerber@suse.de> wrote:
> Am 24.11.2011 20:41, schrieb Peter Maydell:
>> On 22 November 2011 04:34, Peter Chubb <peter.chubb@nicta.com.au> wrote:
>>> +obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
>>> +obj-arm-y += kzm.o
>>
>> It would be better to add the devices to the makefile in their
>> corresponding patches, I think. (Don't feel too strongly about that
>> though so somebody might overrule me.)
>
> Well, I do: Without adding them to the Makefile they don't get
> compile-tested. (I prefer convincing over ruling though.)

Er, which way are you arguing? If patch 1 adds hw/foo.c and also
adds foo.o to the makefile rune then it gets compile tested...

-- PMM
Andreas Färber - Nov. 24, 2011, 9:46 p.m.
Am 24.11.2011 22:31, schrieb Peter Maydell:
> On 24 November 2011 20:19, Andreas Färber <afaerber@suse.de> wrote:
>> Am 24.11.2011 20:41, schrieb Peter Maydell:
>>> On 22 November 2011 04:34, Peter Chubb <peter.chubb@nicta.com.au> wrote:
>>>> +obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
>>>> +obj-arm-y += kzm.o
>>>
>>> It would be better to add the devices to the makefile in their
>>> corresponding patches, I think. (Don't feel too strongly about that
>>> though so somebody might overrule me.)
>>
>> Well, I do: Without adding them to the Makefile they don't get
>> compile-tested. (I prefer convincing over ruling though.)
> 
> Er, which way are you arguing? If patch 1 adds hw/foo.c and also
> adds foo.o to the makefile rune then it gets compile tested...

I'm asking for Peter C. to revise the series, please.

Andreas
Peter Maydell - Nov. 24, 2011, 9:52 p.m.
On 24 November 2011 21:46, Andreas Färber <afaerber@suse.de> wrote:
> Am 24.11.2011 22:31, schrieb Peter Maydell:
>> On 24 November 2011 20:19, Andreas Färber <afaerber@suse.de> wrote:
>>> Am 24.11.2011 20:41, schrieb Peter Maydell:
>>>> On 22 November 2011 04:34, Peter Chubb <peter.chubb@nicta.com.au> wrote:
>>>>> +obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
>>>>> +obj-arm-y += kzm.o
>>>>
>>>> It would be better to add the devices to the makefile in their
>>>> corresponding patches, I think. (Don't feel too strongly about that
>>>> though so somebody might overrule me.)
>>>
>>> Well, I do: Without adding them to the Makefile they don't get
>>> compile-tested. (I prefer convincing over ruling though.)
>>
>> Er, which way are you arguing? If patch 1 adds hw/foo.c and also
>> adds foo.o to the makefile rune then it gets compile tested...
>
> I'm asking for Peter C. to revise the series, please.

OK, in that case we agree.

-- PMM

Patch

Index: qemu-working/hw/kzm.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ qemu-working/hw/kzm.c	2011-11-22 14:47:11.358042471 +1100
@@ -0,0 +1,155 @@ 
+/*
+ * KZM Board System emulation.
+ *
+ * Copyright (c) 2008 OKL and 2011 NICTA
+ * Written by Hans
+ * Updated by Peter Chubb.
+ *
+ * This code is licenced under the GPL, version 2 or later.
+ *
+ * It (partially) emulates a Kyoto Microcomputer
+ * KZM-ARM11-01 evaluation board, with a FreeScale
+ * I.MX31 SoC
+ */
+
+#include "sysbus.h"
+#include "exec-memory.h"
+#include "hw.h"
+#include "arm-misc.h"
+#include "primecell.h"
+#include "devices.h"
+#include "pci.h"
+#include "net.h"
+#include "sysemu.h"
+#include "boards.h"
+#include "pc.h" /* for the FPGA UART that emulates a 16550 */
+
+    /* Memory map for Kzm Emulation Baseboard:
+     * 0x00000000-0x00003fff 16k secure ROM       IGNORED
+     * 0x00004000-0x00407fff Reserved             IGNORED
+     * 0x00404000-0x00407fff ROM                  IGNORED
+     * 0x00408000-0x0fffffff Reserved             IGNORED
+     * 0x10000000-0x1fffBfff RAM aliasing         IGNORED
+     * 0x1fffc000-0x1fffffff RAM                  EMULATED
+     * 0x20000000-0x2fffffff Reserved             IGNORED
+     * 0x30000000-0x7fffffff I.MX31 Internal Register Space
+     *   0x43f00000 IO_AREA0
+     *   0x43f90000 UART1                         EMULATED
+     *   0x43f94000 UART2                         EMULATED
+     *   0x68000000 PIC                           EMULATED
+     *   0x53f94000 PIT 1                         EMULATED
+     *   0x53f98000 PIT 2                         EMULATED
+     *   0x53f90000 GPT                           EMULATED
+     * 0x80000000-0x87ffffff RAM                  EMULATED
+     * 0x88000000-0x8fffffff RAM Aliasing         EMULATED
+     * 0xa0000000-0xafffffff NAND Flash           IGNORED
+     * 0xb0000000-0xb3ffffff Unavailable          IGNORED
+     * 0xb4000000-0xb4000fff 8-bit free space     IGNORED
+     * 0xb4001000-0xb400100f Board control        IGNORED
+     *  0xb4001003           DIP switch
+     * 0xb4001010-0xb400101f 7-segment LED        IGNORED
+     * 0xb4001020-0xb400102f LED                  IGNORED
+     * 0xb4001030-0xb400103f LED                  IGNORED
+     * 0xb4001040-0xb400104f FPGA, UART           EMULATED
+     * 0xb4001050-0xb400105f FPGA, UART           EMULATED
+     * 0xb4001060-0xb40fffff FPGA                 IGNORED
+     * 0xb6000000-0xb61fffff LAN controller       EMULATED
+     * 0xb6200000-0xb62fffff FPGA NAND Controller IGNORED
+     * 0xb6300000-0xb7ffffff Free                 IGNORED
+     * 0xb8000000-0xb8004fff Memory control registers IGNORED
+     * 0xc0000000-0xc3ffffff PCMCIA/CF            IGNORED
+     * 0xc4000000-0xffffffff Reserved             IGNORED
+     */
+
+#define KZM_RAMADDRESS (0x80000000)
+#define KZM_FPGA       (0xb4001040)
+
+static struct arm_boot_info kzm_binfo = {
+    .loader_start = KZM_RAMADDRESS,
+    .board_id = 1722,
+};
+
+static void kzm_init(ram_addr_t ram_size,
+                     const char *boot_device,
+                     const char *kernel_filename, const char *kernel_cmdline,
+                     const char *initrd_filename, const char *cpu_model)
+{
+    CPUState *env;
+    MemoryRegion *address_space_mem = get_system_memory();
+    MemoryRegion *ram = g_new(MemoryRegion, 1);
+    MemoryRegion *sram = g_new(MemoryRegion, 1);
+    MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
+    qemu_irq *cpu_pic;
+    DeviceState *dev;
+
+    if (!cpu_model) {
+        cpu_model = "arm1136";
+    }
+
+    env = cpu_init(cpu_model);
+    if (!env) {
+        fprintf(stderr, "Unable to find CPU definition\n");
+        exit(1);
+    }
+
+    /* On a real system, the first 16k is a `secure boot rom' */
+
+    memory_region_init_ram(ram, NULL, "kzm.ram", ram_size);
+    memory_region_add_subregion(address_space_mem, KZM_RAMADDRESS, ram);
+
+    memory_region_init_alias(ram_alias, "ram.alias", ram, 0, ram_size);
+    memory_region_add_subregion(address_space_mem, 0x88000000, ram_alias);
+
+    memory_region_init_ram(sram, NULL, "kzm.sram", 0x4000);
+    memory_region_add_subregion(address_space_mem, 0x1FFFC000, sram);
+
+
+    cpu_pic = arm_pic_init_cpu(env);
+    dev = sysbus_create_varargs("imx_int", 0x68000000,
+                               cpu_pic[ARM_PIC_CPU_IRQ],
+                               cpu_pic[ARM_PIC_CPU_FIQ], NULL);
+
+
+    sysbus_create_simple("imx_serial", 0x43f90000, qdev_get_gpio_in(dev, 45));
+    sysbus_create_simple("imx_serial", 0x43f94000, qdev_get_gpio_in(dev, 32));
+    sysbus_create_simple("imx_timerp", 0x53f94000, qdev_get_gpio_in(dev, 28));
+    sysbus_create_simple("imx_timerp", 0x53f98000, qdev_get_gpio_in(dev, 27));
+    sysbus_create_simple("imx_timerg", 0x53f90000, qdev_get_gpio_in(dev, 29));
+
+    if (nd_table[0].vlan) {
+        lan9118_init(&nd_table[0], 0xb6000000, qdev_get_gpio_in(dev, 51));
+    }
+
+    if (serial_hds[3]) {
+        serial_mm_init(address_space_mem, KZM_FPGA, 0,
+                       qdev_get_gpio_in(dev, 52),
+                       14745600, serial_hds[3],
+                       DEVICE_NATIVE_ENDIAN);
+    }
+    if (serial_hds[2]) { /* touchscreen */
+        serial_mm_init(address_space_mem, KZM_FPGA+0x10, 0,
+                       qdev_get_gpio_in(dev, 52),
+                       14745600, serial_hds[2],
+                       DEVICE_NATIVE_ENDIAN);
+    }
+
+    kzm_binfo.ram_size = ram_size;
+    kzm_binfo.kernel_filename = kernel_filename;
+    kzm_binfo.kernel_cmdline = kernel_cmdline;
+    kzm_binfo.initrd_filename = initrd_filename;
+    kzm_binfo.nb_cpus = 1;
+    arm_load_kernel(first_cpu, &kzm_binfo);
+}
+
+static QEMUMachine kzm_machine = {
+    .name = "kzm",
+    .desc = "ARM KZM Emulation Baseboard (ARM1136)",
+    .init = kzm_init,
+};
+
+static void kzm_machine_init(void)
+{
+    qemu_register_machine(&kzm_machine);
+}
+
+machine_init(kzm_machine_init);
Index: qemu-working/Makefile.target
===================================================================
--- qemu-working.orig/Makefile.target	2011-11-22 14:46:58.313978625 +1100
+++ qemu-working/Makefile.target	2011-11-22 14:47:11.358042471 +1100
@@ -361,20 +361,22 @@  obj-arm-y += mst_fpga.o mainstone.o
 obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
 obj-arm-y += syborg_virtio.o
 obj-arm-y += vexpress.o
 obj-arm-y += strongarm.o
 obj-arm-y += collie.o
 obj-arm-y += pl041.o lm4549.o
+obj-arm-y += imx_serial.o imx_timer.o imx_avic.o
+obj-arm-y += kzm.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
 obj-sh4-y += ide/mmio.o
 
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
 
 obj-s390x-y = s390-virtio-bus.o s390-virtio.o