xref: /openbmc/qemu/hw/arm/b-l475e-iot01a.c (revision 86e372ad)
1 /*
2  * B-L475E-IOT01A Discovery Kit machine
3  * (B-L475E-IOT01A IoT Node)
4  *
5  * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
6  * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  *
10  * This work is licensed under the terms of the GNU GPL, version 2 or later.
11  * See the COPYING file in the top-level directory.
12  *
13  * This work is heavily inspired by the netduinoplus2 by Alistair Francis.
14  * Original code is licensed under the MIT License:
15  *
16  * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
17  */
18 
19 /*
20  * The reference used is the STMicroElectronics UM2153 User manual
21  * Discovery kit for IoT node, multi-channel communication with STM32L4.
22  * https://www.st.com/en/evaluation-tools/b-l475e-iot01a.html#documentation
23  */
24 
25 #include "qemu/osdep.h"
26 #include "qapi/error.h"
27 #include "hw/boards.h"
28 #include "hw/qdev-properties.h"
29 #include "qemu/error-report.h"
30 #include "hw/arm/stm32l4x5_soc.h"
31 #include "hw/arm/boot.h"
32 
33 /* B-L475E-IOT01A implementation is derived from netduinoplus2 */
34 
35 static void b_l475e_iot01a_init(MachineState *machine)
36 {
37     const Stm32l4x5SocClass *sc;
38     DeviceState *dev;
39 
40     dev = qdev_new(TYPE_STM32L4X5XG_SOC);
41     object_property_add_child(OBJECT(machine), "soc", OBJECT(dev));
42     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
43 
44     sc = STM32L4X5_SOC_GET_CLASS(dev);
45     armv7m_load_kernel(ARM_CPU(first_cpu),
46                        machine->kernel_filename,
47                        0, sc->flash_size);
48 }
49 
50 static void b_l475e_iot01a_machine_init(MachineClass *mc)
51 {
52     static const char *machine_valid_cpu_types[] = {
53         ARM_CPU_TYPE_NAME("cortex-m4"),
54         NULL
55     };
56     mc->desc = "B-L475E-IOT01A Discovery Kit (Cortex-M4)";
57     mc->init = b_l475e_iot01a_init;
58     mc->valid_cpu_types = machine_valid_cpu_types;
59 
60     /* SRAM pre-allocated as part of the SoC instantiation */
61     mc->default_ram_size = 0;
62 }
63 
64 DEFINE_MACHINE("b-l475e-iot01a", b_l475e_iot01a_machine_init)
65