diff mbox series

[19/20] hw/rx: Add CQ-FRK-RX62N target

Message ID 20200827123859.81793-20-ysato@users.sourceforge.jp
State New
Headers show
Series RX target update | expand

Commit Message

Yoshinori Sato Aug. 27, 2020, 12:38 p.m. UTC
It most popular RX target board in Japan.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 default-configs/rx-softmmu.mak |  1 +
 hw/rx/cq-frk-rx62n.c           | 94 ++++++++++++++++++++++++++++++++++
 hw/rx/Kconfig                  |  3 ++
 hw/rx/meson.build              |  1 +
 4 files changed, 99 insertions(+)
 create mode 100644 hw/rx/cq-frk-rx62n.c

Comments

Philippe Mathieu-Daudé Sept. 8, 2020, 9:20 p.m. UTC | #1
On 8/27/20 2:38 PM, Yoshinori Sato wrote:
> It most popular RX target board in Japan.
> 
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> ---
>  default-configs/rx-softmmu.mak |  1 +
>  hw/rx/cq-frk-rx62n.c           | 94 ++++++++++++++++++++++++++++++++++
>  hw/rx/Kconfig                  |  3 ++
>  hw/rx/meson.build              |  1 +
>  4 files changed, 99 insertions(+)
>  create mode 100644 hw/rx/cq-frk-rx62n.c
> 
> diff --git a/default-configs/rx-softmmu.mak b/default-configs/rx-softmmu.mak
> index ea8731d67b..dbbaee8809 100644
> --- a/default-configs/rx-softmmu.mak
> +++ b/default-configs/rx-softmmu.mak
> @@ -2,3 +2,4 @@
>  
>  CONFIG_RX_GDBSIM=y
>  CONFIG_TKDN_RX62N=y
> +CONFIG_FRK_RX62N=y
> diff --git a/hw/rx/cq-frk-rx62n.c b/hw/rx/cq-frk-rx62n.c
> new file mode 100644
> index 0000000000..a1cd9cb2ad
> --- /dev/null
> +++ b/hw/rx/cq-frk-rx62n.c
> @@ -0,0 +1,94 @@
> +/*
> + * CQ publishing CQ-FRK-RX62N
> + *
> + * Copyright (c) 2020 Yoshinori Sato
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope 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/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/cutils.h"
> +#include "qapi/error.h"
> +#include "qemu-common.h"
> +#include "cpu.h"
> +#include "hw/hw.h"
> +#include "hw/sysbus.h"
> +#include "hw/loader.h"
> +#include "hw/rx/loader.h"
> +#include "hw/qdev-properties.h"
> +#include "hw/rx/rx62n.h"
> +#include "sysemu/sysemu.h"
> +#include "sysemu/qtest.h"
> +#include "sysemu/device_tree.h"
> +#include "hw/boards.h"
> +
> +typedef struct {
> +    /*< private >*/
> +    MachineState parent_obj;
> +    /*< public >*/
> +    RX62NState mcu;
> +} FRK_RX62NMachineState;

CODING_STYLE.rst suggests CamelCase: FrkRx62nMachineState.

Otherwise patch is good.

> +
> +#define TYPE_FRK_RX62N_MACHINE MACHINE_TYPE_NAME("cq-frk-rx62n")
> +
> +#define FRK_RX62N_MACHINE(obj) \
> +    OBJECT_CHECK(FRK_RX62NMachineState, (obj), TYPE_FRK_RX62N_MACHINE)
> +
> +static void frk_rx62n_init(MachineState *machine)
> +{
> +    FRK_RX62NMachineState *s = FRK_RX62N_MACHINE(machine);
> +    RX62NClass *rx62nc;
> +    MemoryRegion *sysmem = get_system_memory();
> +
> +    /* Initialize MCU */
> +    object_initialize_child(OBJECT(machine), "mcu",
> +                            &s->mcu, TYPE_R5F562N7_MCU);
> +    rx62nc = RX62N_MCU_GET_CLASS(&s->mcu);
> +    object_property_set_link(OBJECT(&s->mcu), "main-bus", OBJECT(sysmem),
> +                             &error_abort);
> +    object_property_set_uint(OBJECT(&s->mcu), "xtal-frequency-hz",
> +                             12 * 1000 * 1000, &error_abort);
> +    if (bios_name) {
> +        if (!load_bios(bios_name, rx62nc->rom_flash_size, &error_abort)) {
> +            exit(0);
> +        }
> +    } else if (!qtest_enabled()) {
> +        error_report("No bios specified");
> +        exit(1);
> +    }
> +    qdev_realize(DEVICE(&s->mcu), NULL, &error_abort);
> +}
> +
> +static void frk_rx62n_class_init(ObjectClass *oc, void *data)
> +{
> +    MachineClass *mc = MACHINE_CLASS(oc);
> +
> +    mc->desc = "CQ publishing CQ-FRK-RX62N";
> +    mc->init = frk_rx62n_init;
> +    mc->is_default = 0;
> +    mc->default_cpu_type = TYPE_RX62N_CPU;
> +}
> +
> +static const TypeInfo frk_rx62n_type = {
> +    .name = MACHINE_TYPE_NAME("cq-frk-rx62n"),
> +    .parent = TYPE_MACHINE,
> +    .instance_size  = sizeof(FRK_RX62NMachineState),
> +    .class_init = frk_rx62n_class_init,
> +};
> +
> +static void frk_rx62n_machine_init(void)
> +{
> +    type_register_static(&frk_rx62n_type);
> +}
> +
> +type_init(frk_rx62n_machine_init)
> diff --git a/hw/rx/Kconfig b/hw/rx/Kconfig
> index 0ef20d0c3c..ab2c472510 100644
> --- a/hw/rx/Kconfig
> +++ b/hw/rx/Kconfig
> @@ -17,3 +17,6 @@ config TKDN_RX62N
>      select RX62N_MCU
>      select FITLOADER
>  
> +config FRK_RX62N
> +    bool
> +    select RX62N_MCU
> diff --git a/hw/rx/meson.build b/hw/rx/meson.build
> index 0a741e091c..0f26f1fcb2 100644
> --- a/hw/rx/meson.build
> +++ b/hw/rx/meson.build
> @@ -2,6 +2,7 @@ rx_ss = ss.source_set()
>  rx_ss.add(files('loader.c'))
>  rx_ss.add(when: 'CONFIG_RX_GDBSIM', if_true: files('rx-gdbsim.c'))
>  rx_ss.add(when: 'CONFIG_TKDN_RX62N', if_true: files('tkdn-rx62n.c'))
> +rx_ss.add(when: 'CONFIG_FRK_RX62N', if_true: files('cq-frk-rx62n.c'))
>  rx_ss.add(when: 'CONFIG_RX62N_MCU', if_true: files('rx62n.c', 'rx62n-cpg.c'))
>  
>  hw_arch += {'rx': rx_ss}
>
diff mbox series

Patch

diff --git a/default-configs/rx-softmmu.mak b/default-configs/rx-softmmu.mak
index ea8731d67b..dbbaee8809 100644
--- a/default-configs/rx-softmmu.mak
+++ b/default-configs/rx-softmmu.mak
@@ -2,3 +2,4 @@ 
 
 CONFIG_RX_GDBSIM=y
 CONFIG_TKDN_RX62N=y
+CONFIG_FRK_RX62N=y
diff --git a/hw/rx/cq-frk-rx62n.c b/hw/rx/cq-frk-rx62n.c
new file mode 100644
index 0000000000..a1cd9cb2ad
--- /dev/null
+++ b/hw/rx/cq-frk-rx62n.c
@@ -0,0 +1,94 @@ 
+/*
+ * CQ publishing CQ-FRK-RX62N
+ *
+ * Copyright (c) 2020 Yoshinori Sato
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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/>.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/cutils.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+#include "cpu.h"
+#include "hw/hw.h"
+#include "hw/sysbus.h"
+#include "hw/loader.h"
+#include "hw/rx/loader.h"
+#include "hw/qdev-properties.h"
+#include "hw/rx/rx62n.h"
+#include "sysemu/sysemu.h"
+#include "sysemu/qtest.h"
+#include "sysemu/device_tree.h"
+#include "hw/boards.h"
+
+typedef struct {
+    /*< private >*/
+    MachineState parent_obj;
+    /*< public >*/
+    RX62NState mcu;
+} FRK_RX62NMachineState;
+
+#define TYPE_FRK_RX62N_MACHINE MACHINE_TYPE_NAME("cq-frk-rx62n")
+
+#define FRK_RX62N_MACHINE(obj) \
+    OBJECT_CHECK(FRK_RX62NMachineState, (obj), TYPE_FRK_RX62N_MACHINE)
+
+static void frk_rx62n_init(MachineState *machine)
+{
+    FRK_RX62NMachineState *s = FRK_RX62N_MACHINE(machine);
+    RX62NClass *rx62nc;
+    MemoryRegion *sysmem = get_system_memory();
+
+    /* Initialize MCU */
+    object_initialize_child(OBJECT(machine), "mcu",
+                            &s->mcu, TYPE_R5F562N7_MCU);
+    rx62nc = RX62N_MCU_GET_CLASS(&s->mcu);
+    object_property_set_link(OBJECT(&s->mcu), "main-bus", OBJECT(sysmem),
+                             &error_abort);
+    object_property_set_uint(OBJECT(&s->mcu), "xtal-frequency-hz",
+                             12 * 1000 * 1000, &error_abort);
+    if (bios_name) {
+        if (!load_bios(bios_name, rx62nc->rom_flash_size, &error_abort)) {
+            exit(0);
+        }
+    } else if (!qtest_enabled()) {
+        error_report("No bios specified");
+        exit(1);
+    }
+    qdev_realize(DEVICE(&s->mcu), NULL, &error_abort);
+}
+
+static void frk_rx62n_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "CQ publishing CQ-FRK-RX62N";
+    mc->init = frk_rx62n_init;
+    mc->is_default = 0;
+    mc->default_cpu_type = TYPE_RX62N_CPU;
+}
+
+static const TypeInfo frk_rx62n_type = {
+    .name = MACHINE_TYPE_NAME("cq-frk-rx62n"),
+    .parent = TYPE_MACHINE,
+    .instance_size  = sizeof(FRK_RX62NMachineState),
+    .class_init = frk_rx62n_class_init,
+};
+
+static void frk_rx62n_machine_init(void)
+{
+    type_register_static(&frk_rx62n_type);
+}
+
+type_init(frk_rx62n_machine_init)
diff --git a/hw/rx/Kconfig b/hw/rx/Kconfig
index 0ef20d0c3c..ab2c472510 100644
--- a/hw/rx/Kconfig
+++ b/hw/rx/Kconfig
@@ -17,3 +17,6 @@  config TKDN_RX62N
     select RX62N_MCU
     select FITLOADER
 
+config FRK_RX62N
+    bool
+    select RX62N_MCU
diff --git a/hw/rx/meson.build b/hw/rx/meson.build
index 0a741e091c..0f26f1fcb2 100644
--- a/hw/rx/meson.build
+++ b/hw/rx/meson.build
@@ -2,6 +2,7 @@  rx_ss = ss.source_set()
 rx_ss.add(files('loader.c'))
 rx_ss.add(when: 'CONFIG_RX_GDBSIM', if_true: files('rx-gdbsim.c'))
 rx_ss.add(when: 'CONFIG_TKDN_RX62N', if_true: files('tkdn-rx62n.c'))
+rx_ss.add(when: 'CONFIG_FRK_RX62N', if_true: files('cq-frk-rx62n.c'))
 rx_ss.add(when: 'CONFIG_RX62N_MCU', if_true: files('rx62n.c', 'rx62n-cpg.c'))
 
 hw_arch += {'rx': rx_ss}