blob: 8b1a9a24379080f82e657d7ba84526df89356f6d [file] [log] [blame]
Alistair Francisda6bd922015-03-11 13:21:06 +00001/*
2 * Netduino 2 Machine Model
3 *
4 * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
Peter Maydell12b16722015-12-07 16:23:45 +000025#include "qemu/osdep.h"
Markus Armbrusterda34e652016-03-14 09:01:28 +010026#include "qapi/error.h"
Alistair Francisda6bd922015-03-11 13:21:06 +000027#include "hw/boards.h"
Markus Armbrustera27bd6c2019-08-12 07:23:51 +020028#include "hw/qdev-properties.h"
Peter Maydell68ba05f2021-08-12 10:33:43 +010029#include "hw/qdev-clock.h"
Alistair Francisda6bd922015-03-11 13:21:06 +000030#include "qemu/error-report.h"
31#include "hw/arm/stm32f205_soc.h"
Peter Maydell12ec8bd2019-05-23 14:47:43 +010032#include "hw/arm/boot.h"
Alistair Francisda6bd922015-03-11 13:21:06 +000033
Peter Maydelle7e5a952020-08-03 17:55:03 +010034/* Main SYSCLK frequency in Hz (120MHz) */
35#define SYSCLK_FRQ 120000000ULL
36
Alistair Francisda6bd922015-03-11 13:21:06 +000037static void netduino2_init(MachineState *machine)
38{
39 DeviceState *dev;
Peter Maydell68ba05f2021-08-12 10:33:43 +010040 Clock *sysclk;
Alistair Francisda6bd922015-03-11 13:21:06 +000041
Peter Maydell68ba05f2021-08-12 10:33:43 +010042 /* This clock doesn't need migration because it is fixed-frequency */
43 sysclk = clock_new(OBJECT(machine), "SYSCLK");
44 clock_set_hz(sysclk, SYSCLK_FRQ);
45
Markus Armbruster3e80f692020-06-10 07:31:58 +020046 dev = qdev_new(TYPE_STM32F205_SOC);
Philippe Mathieu-Daudéf503bc42024-01-04 15:11:59 +010047 object_property_add_child(OBJECT(machine), "soc", OBJECT(dev));
Peter Maydell68ba05f2021-08-12 10:33:43 +010048 qdev_connect_clock_in(dev, "sysclk", sysclk);
Markus Armbruster3c6ef472020-06-10 07:32:34 +020049 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
Peter Maydellb72e2f62017-02-20 15:36:04 +000050
51 armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
Peter Maydell761c5322022-08-23 17:04:17 +010052 0, FLASH_SIZE);
Alistair Francisda6bd922015-03-11 13:21:06 +000053}
54
Eduardo Habkoste264d292015-09-04 15:37:08 -030055static void netduino2_machine_init(MachineClass *mc)
Alistair Francisda6bd922015-03-11 13:21:06 +000056{
Philippe Mathieu-Daudéff6cda32023-11-17 08:17:03 +010057 static const char * const valid_cpu_types[] = {
58 ARM_CPU_TYPE_NAME("cortex-m3"),
59 NULL
60 };
61
Philippe Mathieu-Daudéfd8f71b2021-01-31 19:44:49 +010062 mc->desc = "Netduino 2 Machine (Cortex-M3)";
Eduardo Habkoste264d292015-09-04 15:37:08 -030063 mc->init = netduino2_init;
Philippe Mathieu-Daudéff6cda32023-11-17 08:17:03 +010064 mc->valid_cpu_types = valid_cpu_types;
Peter Maydell4672cbd2017-09-07 13:54:54 +010065 mc->ignore_memory_transaction_failures = true;
Alistair Francisda6bd922015-03-11 13:21:06 +000066}
67
Eduardo Habkoste264d292015-09-04 15:37:08 -030068DEFINE_MACHINE("netduino2", netduino2_machine_init)