Révision | 78a514d206e4e9fc1fbc245af46939c8ff5c5eb8 (tree) |
---|---|
l'heure | 2020-03-16 00:12:48 |
Auteur | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
hw/rx: RX Target hardware definition
rx62n - RX62N cpu.
rx-virt - RX QEMU virtual target.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20190616142836.10614-17-ysato@users.sourceforge.jp>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190607091116.49044-9-ysato@users.sourceforge.jp>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
[PMD: Use TYPE_RX62N_CPU, use #define for RX62N_NR_TMR/CMT/SCI,
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v23 changes.
Add missing includes.
v21 changes.
rx_load_image move to rx-virt.c
v19: Fixed typo (Peter Maydell)
@@ -0,0 +1,14 @@ | ||
1 | +config RX | |
2 | + bool | |
3 | + | |
4 | +config RX62N | |
5 | + bool | |
6 | + select RX | |
7 | + select RX_ICU | |
8 | + select RENESAS_TMR8 | |
9 | + select RENESAS_CMT | |
10 | + select RENESAS_SCI | |
11 | + | |
12 | +config RX_VIRT | |
13 | + bool | |
14 | + select RX62N |
@@ -0,0 +1,2 @@ | ||
1 | +obj-$(CONFIG_RX62N) += rx62n.o | |
2 | +obj-$(CONFIG_RX_VIRT) += rx-virt.o |
@@ -0,0 +1,142 @@ | ||
1 | +/* | |
2 | + * RX QEMU virtual platform | |
3 | + * | |
4 | + * Copyright (c) 2019 Yoshinori Sato | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify it | |
7 | + * under the terms and conditions of the GNU General Public License, | |
8 | + * version 2 or later, as published by the Free Software Foundation. | |
9 | + * | |
10 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | + * more details. | |
14 | + * | |
15 | + * You should have received a copy of the GNU General Public License along with | |
16 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | + */ | |
18 | + | |
19 | +#include "qemu/osdep.h" | |
20 | +#include "qapi/error.h" | |
21 | +#include "qemu-common.h" | |
22 | +#include "cpu.h" | |
23 | +#include "hw/hw.h" | |
24 | +#include "hw/sysbus.h" | |
25 | +#include "hw/loader.h" | |
26 | +#include "hw/rx/rx62n.h" | |
27 | +#include "sysemu/sysemu.h" | |
28 | +#include "sysemu/qtest.h" | |
29 | +#include "sysemu/device_tree.h" | |
30 | +#include "hw/boards.h" | |
31 | + | |
32 | +/* Same address of GDB integrated simulator */ | |
33 | +#define SDRAM_BASE 0x01000000 | |
34 | + | |
35 | +static void rx_load_image(RXCPU *cpu, const char *filename, | |
36 | + uint32_t start, uint32_t size) | |
37 | +{ | |
38 | + static uint32_t extable[32]; | |
39 | + long kernel_size; | |
40 | + int i; | |
41 | + | |
42 | + kernel_size = load_image_targphys(filename, start, size); | |
43 | + if (kernel_size < 0) { | |
44 | + fprintf(stderr, "qemu: could not load kernel '%s'\n", filename); | |
45 | + exit(1); | |
46 | + } | |
47 | + cpu->env.pc = start; | |
48 | + | |
49 | + /* setup exception trap trampoline */ | |
50 | + /* linux kernel only works little-endian mode */ | |
51 | + for (i = 0; i < ARRAY_SIZE(extable); i++) { | |
52 | + extable[i] = cpu_to_le32(0x10 + i * 4); | |
53 | + } | |
54 | + rom_add_blob_fixed("extable", extable, sizeof(extable), 0xffffff80); | |
55 | +} | |
56 | + | |
57 | +static void rxvirt_init(MachineState *machine) | |
58 | +{ | |
59 | + RX62NState *s = g_new(RX62NState, 1); | |
60 | + MemoryRegion *sysmem = get_system_memory(); | |
61 | + MemoryRegion *sdram = g_new(MemoryRegion, 1); | |
62 | + const char *kernel_filename = machine->kernel_filename; | |
63 | + const char *dtb_filename = machine->dtb; | |
64 | + void *dtb = NULL; | |
65 | + int dtb_size; | |
66 | + ram_addr_t kernel_offset; | |
67 | + ram_addr_t dtb_offset; | |
68 | + | |
69 | + if (machine->ram_size < mc->default_ram_size) { | |
70 | + error_report("Invalid RAM size, should be more than %" PRIi64 " Bytes", | |
71 | + mc->default_ram_size); | |
72 | + } | |
73 | + | |
74 | + /* Allocate memory space */ | |
75 | + memory_region_init_ram(sdram, NULL, "rx-virt.sdram", machine->ram_size, | |
76 | + &error_fatal); | |
77 | + memory_region_add_subregion(sysmem, SDRAM_BASE, sdram); | |
78 | + | |
79 | + /* Initialize MCU */ | |
80 | + object_initialize_child(OBJECT(machine), "mcu", s, | |
81 | + sizeof(RX62NState), TYPE_RX62N, | |
82 | + &error_fatal, NULL); | |
83 | + object_property_set_link(OBJECT(s), OBJECT(sysmem), | |
84 | + "memory", &error_abort); | |
85 | + object_property_set_bool(OBJECT(s), kernel_filename != NULL, | |
86 | + "load-kernel", &error_abort); | |
87 | + object_property_set_bool(OBJECT(s), true, "realized", &error_abort); | |
88 | + | |
89 | + /* Load kernel and dtb */ | |
90 | + if (kernel_filename) { | |
91 | + /* | |
92 | + * The kernel image is loaded into | |
93 | + * the latter half of the SDRAM space. | |
94 | + */ | |
95 | + kernel_offset = machine->ram_size / 2; | |
96 | + rx_load_image(RXCPU(first_cpu), kernel_filename, | |
97 | + SDRAM_BASE + kernel_offset, kernel_offset); | |
98 | + if (dtb_filename) { | |
99 | + dtb = load_device_tree(dtb_filename, &dtb_size); | |
100 | + if (dtb == NULL) { | |
101 | + error_report("Couldn't open dtb file %s", dtb_filename); | |
102 | + exit(1); | |
103 | + } | |
104 | + if (machine->kernel_cmdline && | |
105 | + qemu_fdt_setprop_string(dtb, "/chosen", "bootargs", | |
106 | + machine->kernel_cmdline) < 0) { | |
107 | + error_report("Couldn't set /chosen/bootargs"); | |
108 | + exit(1); | |
109 | + } | |
110 | + /* DTB is located at the end of SDRAM space. */ | |
111 | + dtb_offset = machine->ram_size - dtb_size; | |
112 | + rom_add_blob_fixed("dtb", dtb, dtb_size, | |
113 | + SDRAM_BASE + dtb_offset); | |
114 | + /* Set dtb address to R1 */ | |
115 | + RXCPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset; | |
116 | + } | |
117 | + } | |
118 | +} | |
119 | + | |
120 | +static void rxvirt_class_init(ObjectClass *oc, void *data) | |
121 | +{ | |
122 | + MachineClass *mc = MACHINE_CLASS(oc); | |
123 | + | |
124 | + mc->desc = "RX QEMU Virtual Target"; | |
125 | + mc->init = rxvirt_init; | |
126 | + mc->is_default = 1; | |
127 | + mc->default_cpu_type = TYPE_RX62N_CPU; | |
128 | + mc->default_ram_size = 16 * MiB; | |
129 | +} | |
130 | + | |
131 | +static const TypeInfo rxvirt_type = { | |
132 | + .name = MACHINE_TYPE_NAME("rx-virt"), | |
133 | + .parent = TYPE_MACHINE, | |
134 | + .class_init = rxvirt_class_init, | |
135 | +}; | |
136 | + | |
137 | +static void rxvirt_machine_init(void) | |
138 | +{ | |
139 | + type_register_static(&rxvirt_type); | |
140 | +} | |
141 | + | |
142 | +type_init(rxvirt_machine_init) |
@@ -0,0 +1,239 @@ | ||
1 | +/* | |
2 | + * RX62N Microcontroller | |
3 | + * | |
4 | + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware | |
5 | + * (Rev.1.40 R01UH0033EJ0140) | |
6 | + * | |
7 | + * Copyright (c) 2019 Yoshinori Sato | |
8 | + * | |
9 | + * This program is free software; you can redistribute it and/or modify it | |
10 | + * under the terms and conditions of the GNU General Public License, | |
11 | + * version 2 or later, as published by the Free Software Foundation. | |
12 | + * | |
13 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
14 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 | + * more details. | |
17 | + * | |
18 | + * You should have received a copy of the GNU General Public License along with | |
19 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | + */ | |
21 | + | |
22 | +#include "qemu/osdep.h" | |
23 | +#include "qapi/error.h" | |
24 | +#include "hw/hw.h" | |
25 | +#include "hw/rx/rx62n.h" | |
26 | +#include "hw/loader.h" | |
27 | +#include "hw/sysbus.h" | |
28 | +#include "hw/qdev-properties.h" | |
29 | +#include "sysemu/sysemu.h" | |
30 | +#include "cpu.h" | |
31 | + | |
32 | +/* | |
33 | + * IRQ -> IPR mapping table | |
34 | + * 0x00 - 0x91: IPR no (IPR00 to IPR91) | |
35 | + * 0xff: IPR not assigned | |
36 | + * See "11.3.1 Interrupt Vector Table" in hardware manual. | |
37 | + */ | |
38 | +static const int ipr_table[NR_IRQS] = { | |
39 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
40 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 15 */ | |
41 | + 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0x02, | |
42 | + 0xff, 0xff, 0xff, 0x03, 0x04, 0x05, 0x06, 0x07, /* 31 */ | |
43 | + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | |
44 | + 0x10, 0x11, 0x12, 0x13, 0x14, 0x14, 0x14, 0x14, /* 47 */ | |
45 | + 0x15, 0x15, 0x15, 0x15, 0xff, 0xff, 0xff, 0xff, | |
46 | + 0x18, 0x18, 0x18, 0x18, 0x18, 0x1d, 0x1e, 0x1f, /* 63 */ | |
47 | + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, | |
48 | + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 79 */ | |
49 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
50 | + 0xff, 0xff, 0x3a, 0x3b, 0x3c, 0xff, 0xff, 0xff, /* 95 */ | |
51 | + 0x40, 0xff, 0x44, 0x45, 0xff, 0xff, 0x48, 0xff, | |
52 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 111 */ | |
53 | + 0xff, 0xff, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, | |
54 | + 0x52, 0x53, 0x53, 0x54, 0x54, 0x55, 0x55, 0x56, /* 127 */ | |
55 | + 0x56, 0x57, 0x57, 0x57, 0x57, 0x58, 0x59, 0x59, | |
56 | + 0x59, 0x59, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5c, /* 143 */ | |
57 | + 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, | |
58 | + 0x5f, 0x60, 0x60, 0x61, 0x61, 0x62, 0x62, 0x62, /* 159 */ | |
59 | + 0x62, 0x63, 0x64, 0x64, 0x64, 0x64, 0x65, 0x66, | |
60 | + 0x66, 0x66, 0x67, 0x67, 0x67, 0x67, 0x68, 0x68, /* 175 */ | |
61 | + 0x68, 0x69, 0x69, 0x69, 0x6a, 0x6a, 0x6a, 0x6b, | |
62 | + 0x6b, 0x6b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 191 */ | |
63 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, 0x71, | |
64 | + 0x72, 0x73, 0x74, 0x75, 0xff, 0xff, 0xff, 0xff, /* 207 */ | |
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x80, | |
66 | + 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x82, 0x82, /* 223 */ | |
67 | + 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, 0xff, 0xff, | |
68 | + 0xff, 0xff, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, /* 239 */ | |
69 | + 0x86, 0x86, 0xff, 0xff, 0xff, 0xff, 0x88, 0x89, | |
70 | + 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, /* 255 */ | |
71 | +}; | |
72 | + | |
73 | +/* | |
74 | + * Level triggerd IRQ list | |
75 | + * Not listed IRQ is Edge trigger. | |
76 | + * See "11.3.1 Interrupt Vector Table" in hardware manual. | |
77 | + */ | |
78 | +static const uint32_t levelirq[] = { | |
79 | + 16, 21, 32, 44, 47, 48, 51, 64, 65, 66, | |
80 | + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, | |
81 | + 77, 78, 79, 90, 91, 170, 171, 172, 173, 214, | |
82 | + 217, 218, 221, 222, 225, 226, 229, 234, 237, 238, | |
83 | + 241, 246, 249, 250, 253, | |
84 | +}; | |
85 | + | |
86 | +static void register_icu(RX62NState *s) | |
87 | +{ | |
88 | + int i; | |
89 | + SysBusDevice *icu; | |
90 | + | |
91 | + object_initialize_child(OBJECT(s), "icu", &s->icu, sizeof(RXICUState), | |
92 | + TYPE_RXICU, &error_abort, NULL); | |
93 | + | |
94 | + icu = SYS_BUS_DEVICE(&s->icu); | |
95 | + sysbus_mmio_map(SYS_BUS_DEVICE(icu), 0, RX62N_ICUBASE); | |
96 | + qdev_prop_set_uint32(DEVICE(icu), "len-ipr-map", NR_IRQS); | |
97 | + for (i = 0; i < NR_IRQS; i++) { | |
98 | + char propname[32]; | |
99 | + snprintf(propname, sizeof(propname), "ipr-map[%d]", i); | |
100 | + qdev_prop_set_uint32(DEVICE(icu), propname, ipr_table[i]); | |
101 | + } | |
102 | + qdev_prop_set_uint32(DEVICE(icu), "len-trigger-level", | |
103 | + ARRAY_SIZE(levelirq)); | |
104 | + for (i = 0; i < ARRAY_SIZE(levelirq); i++) { | |
105 | + char propname[32]; | |
106 | + snprintf(propname, sizeof(propname), "trigger-level[%d]", i); | |
107 | + qdev_prop_set_uint32(DEVICE(icu), propname, levelirq[i]); | |
108 | + } | |
109 | + | |
110 | + for (i = 0; i < NR_IRQS; i++) { | |
111 | + s->irq[i] = qdev_get_gpio_in(DEVICE(icu), i); | |
112 | + } | |
113 | + | |
114 | + qdev_init_nofail(DEVICE(icu)); | |
115 | + sysbus_connect_irq(icu, 0, qdev_get_gpio_in(DEVICE(&s->cpu), RX_CPU_IRQ)); | |
116 | + sysbus_connect_irq(icu, 1, qdev_get_gpio_in(DEVICE(&s->cpu), RX_CPU_FIR)); | |
117 | + sysbus_connect_irq(icu, 2, s->irq[SWI]); | |
118 | + | |
119 | +} | |
120 | + | |
121 | +static void register_tmr(RX62NState *s, int unit) | |
122 | +{ | |
123 | + SysBusDevice *tmr; | |
124 | + int i, irqbase; | |
125 | + | |
126 | + object_initialize_child(OBJECT(s), "tmr[*]", &s->tmr[unit], | |
127 | + sizeof(RTMRState), TYPE_RENESAS_TMR, | |
128 | + &error_abort, NULL); | |
129 | + | |
130 | + tmr = SYS_BUS_DEVICE(&s->tmr[unit]); | |
131 | + sysbus_mmio_map(tmr, 0, RX62N_TMRBASE + unit * 0x10); | |
132 | + qdev_prop_set_uint64(DEVICE(tmr), "input-freq", RX62N_PCLK); | |
133 | + | |
134 | + qdev_init_nofail(DEVICE(tmr)); | |
135 | + irqbase = RX62N_TMR_IRQBASE + TMR_NR_IRQ * unit; | |
136 | + for (i = 0; i < TMR_NR_IRQ; i++) { | |
137 | + sysbus_connect_irq(tmr, i, s->irq[irqbase + i]); | |
138 | + } | |
139 | +} | |
140 | + | |
141 | +static void register_cmt(RX62NState *s, int unit) | |
142 | +{ | |
143 | + SysBusDevice *cmt; | |
144 | + int i, irqbase; | |
145 | + | |
146 | + object_initialize_child(OBJECT(s), "cmt[*]", &s->cmt[unit], | |
147 | + sizeof(RCMTState), TYPE_RENESAS_CMT, | |
148 | + &error_abort, NULL); | |
149 | + | |
150 | + cmt = SYS_BUS_DEVICE(&s->cmt[unit]); | |
151 | + sysbus_mmio_map(cmt, 0, RX62N_CMTBASE + unit * 0x10); | |
152 | + qdev_prop_set_uint64(DEVICE(cmt), "input-freq", RX62N_PCLK); | |
153 | + | |
154 | + qdev_init_nofail(DEVICE(cmt)); | |
155 | + irqbase = RX62N_CMT_IRQBASE + CMT_NR_IRQ * unit; | |
156 | + for (i = 0; i < CMT_NR_IRQ; i++) { | |
157 | + sysbus_connect_irq(cmt, i, s->irq[irqbase + i]); | |
158 | + } | |
159 | +} | |
160 | + | |
161 | +static void register_sci(RX62NState *s, int unit) | |
162 | +{ | |
163 | + SysBusDevice *sci; | |
164 | + int i, irqbase; | |
165 | + | |
166 | + object_initialize_child(OBJECT(s), "sci[*]", &s->sci[unit], | |
167 | + sizeof(RSCIState), TYPE_RENESAS_SCI, | |
168 | + &error_abort, NULL); | |
169 | + | |
170 | + sci = SYS_BUS_DEVICE(&s->sci[unit]); | |
171 | + sysbus_mmio_map(sci, 0, RX62N_SCIBASE + unit * 0x08); | |
172 | + qdev_prop_set_chr(DEVICE(sci), "chardev", serial_hd(unit)); | |
173 | + qdev_prop_set_uint64(DEVICE(sci), "input-freq", RX62N_PCLK); | |
174 | + | |
175 | + qdev_init_nofail(DEVICE(sci)); | |
176 | + irqbase = RX62N_SCI_IRQBASE + SCI_NR_IRQ * unit; | |
177 | + for (i = 0; i < SCI_NR_IRQ; i++) { | |
178 | + sysbus_connect_irq(sci, i, s->irq[irqbase + i]); | |
179 | + } | |
180 | +} | |
181 | + | |
182 | +static void rx62n_realize(DeviceState *dev, Error **errp) | |
183 | +{ | |
184 | + RX62NState *s = RX62N(dev); | |
185 | + | |
186 | + memory_region_init_ram(&s->iram, NULL, "iram", RX62N_IRAM_SIZE, errp); | |
187 | + memory_region_add_subregion(s->sysmem, RX62N_IRAM_BASE, &s->iram); | |
188 | + memory_region_init_rom(&s->d_flash, NULL, "dataflash", | |
189 | + RX62N_DFLASH_SIZE, errp); | |
190 | + memory_region_add_subregion(s->sysmem, RX62N_DFLASH_BASE, &s->d_flash); | |
191 | + memory_region_init_rom(&s->c_flash, NULL, "codeflash", | |
192 | + RX62N_CFLASH_SIZE, errp); | |
193 | + memory_region_add_subregion(s->sysmem, RX62N_CFLASH_BASE, &s->c_flash); | |
194 | + if (!s->kernel) { | |
195 | + rom_add_file_fixed(bios_name, RX62N_CFLASH_BASE, 0); | |
196 | + } | |
197 | + | |
198 | + /* Initialize CPU */ | |
199 | + object_initialize_child(OBJECT(s), "cpu", &s->cpu, sizeof(RXCPU), | |
200 | + TYPE_RX62N_CPU, errp, NULL); | |
201 | + object_property_set_bool(OBJECT(&s->cpu), true, "realized", errp); | |
202 | + | |
203 | + register_icu(s); | |
204 | + s->cpu.env.ack = qdev_get_gpio_in_named(DEVICE(&s->icu), "ack", 0); | |
205 | + register_tmr(s, 0); | |
206 | + register_tmr(s, 1); | |
207 | + register_cmt(s, 0); | |
208 | + register_cmt(s, 1); | |
209 | + register_sci(s, 0); | |
210 | +} | |
211 | + | |
212 | +static Property rx62n_properties[] = { | |
213 | + DEFINE_PROP_LINK("memory", RX62NState, sysmem, TYPE_MEMORY_REGION, | |
214 | + MemoryRegion *), | |
215 | + DEFINE_PROP_BOOL("load-kernel", RX62NState, kernel, false), | |
216 | + DEFINE_PROP_END_OF_LIST(), | |
217 | +}; | |
218 | + | |
219 | +static void rx62n_class_init(ObjectClass *klass, void *data) | |
220 | +{ | |
221 | + DeviceClass *dc = DEVICE_CLASS(klass); | |
222 | + | |
223 | + dc->realize = rx62n_realize; | |
224 | + device_class_set_props(dc, rx62n_properties); | |
225 | +} | |
226 | + | |
227 | +static const TypeInfo rx62n_info = { | |
228 | + .name = TYPE_RX62N, | |
229 | + .parent = TYPE_SYS_BUS_DEVICE, | |
230 | + .instance_size = sizeof(RX62NState), | |
231 | + .class_init = rx62n_class_init, | |
232 | +}; | |
233 | + | |
234 | +static void rx62n_register_types(void) | |
235 | +{ | |
236 | + type_register_static(&rx62n_info); | |
237 | +} | |
238 | + | |
239 | +type_init(rx62n_register_types) |
@@ -0,0 +1,7 @@ | ||
1 | +#ifndef QEMU_RX_H | |
2 | +#define QEMU_RX_H | |
3 | +/* Definitions for RX board emulation. */ | |
4 | + | |
5 | +#include "target/rx/cpu-qom.h" | |
6 | + | |
7 | +#endif |
@@ -0,0 +1,91 @@ | ||
1 | +/* | |
2 | + * RX62N MCU Object | |
3 | + * | |
4 | + * Datasheet: RX62N Group, RX621 Group User's Manual: Hardware | |
5 | + * (Rev.1.40 R01UH0033EJ0140) | |
6 | + * | |
7 | + * Copyright (c) 2019 Yoshinori Sato | |
8 | + * | |
9 | + * This program is free software; you can redistribute it and/or modify it | |
10 | + * under the terms and conditions of the GNU General Public License, | |
11 | + * version 2 or later, as published by the Free Software Foundation. | |
12 | + * | |
13 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
14 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
16 | + * more details. | |
17 | + * | |
18 | + * You should have received a copy of the GNU General Public License along with | |
19 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | + */ | |
21 | + | |
22 | +#ifndef HW_RX_RX62N_H | |
23 | +#define HW_RX_RX62N_H | |
24 | + | |
25 | +#include "hw/sysbus.h" | |
26 | +#include "hw/intc/rx_icu.h" | |
27 | +#include "hw/timer/renesas_tmr.h" | |
28 | +#include "hw/timer/renesas_cmt.h" | |
29 | +#include "hw/char/renesas_sci.h" | |
30 | +#include "target/rx/cpu.h" | |
31 | +#include "qemu/units.h" | |
32 | + | |
33 | +#define TYPE_RX62N "rx62n" | |
34 | +#define RX62N(obj) OBJECT_CHECK(RX62NState, (obj), TYPE_RX62N) | |
35 | + | |
36 | +#define RX62N_NR_TMR 2 | |
37 | +#define RX62N_NR_CMT 2 | |
38 | +#define RX62N_NR_SCI 6 | |
39 | + | |
40 | +typedef struct RX62NState { | |
41 | + SysBusDevice parent_obj; | |
42 | + | |
43 | + RXCPU cpu; | |
44 | + RXICUState icu; | |
45 | + RTMRState tmr[RX62N_NR_TMR]; | |
46 | + RCMTState cmt[RX62N_NR_CMT]; | |
47 | + RSCIState sci[RX62N_NR_SCI]; | |
48 | + | |
49 | + MemoryRegion *sysmem; | |
50 | + bool kernel; | |
51 | + | |
52 | + MemoryRegion iram; | |
53 | + MemoryRegion iomem1; | |
54 | + MemoryRegion d_flash; | |
55 | + MemoryRegion iomem2; | |
56 | + MemoryRegion iomem3; | |
57 | + MemoryRegion c_flash; | |
58 | + qemu_irq irq[NR_IRQS]; | |
59 | +} RX62NState; | |
60 | + | |
61 | +/* | |
62 | + * RX62N Peripheral Address | |
63 | + * See users manual section 5 | |
64 | + */ | |
65 | +#define RX62N_ICUBASE 0x00087000 | |
66 | +#define RX62N_TMRBASE 0x00088200 | |
67 | +#define RX62N_CMTBASE 0x00088000 | |
68 | +#define RX62N_SCIBASE 0x00088240 | |
69 | + | |
70 | +/* | |
71 | + * RX62N Peripheral IRQ | |
72 | + * See users manual section 11 | |
73 | + */ | |
74 | +#define RX62N_TMR_IRQBASE 174 | |
75 | +#define RX62N_CMT_IRQBASE 28 | |
76 | +#define RX62N_SCI_IRQBASE 214 | |
77 | + | |
78 | +/* | |
79 | + * RX62N Internal Memory | |
80 | + * It is the value of R5F562N8. | |
81 | + * Please change the size for R5F562N7. | |
82 | + */ | |
83 | +#define RX62N_IRAM_BASE 0x00000000 | |
84 | +#define RX62N_IRAM_SIZE (96 * KiB) | |
85 | +#define RX62N_DFLASH_BASE 0x00100000 | |
86 | +#define RX62N_DFLASH_SIZE (32 * KiB) | |
87 | +#define RX62N_CFLASH_BASE 0xfff80000 | |
88 | +#define RX62N_CFLASH_SIZE (512 * KiB) | |
89 | + | |
90 | +#define RX62N_PCLK (48 * 1000 * 1000) | |
91 | +#endif |