2012-02-16 17:56:05 +08:00
|
|
|
/*
|
|
|
|
* Samsung exynos4 SoC based boards emulation
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
|
|
|
|
* Maksim Kozlov <m.kozlov@samsung.com>
|
|
|
|
* Evgeny Voevodin <e.voevodin@samsung.com>
|
|
|
|
* Igor Mitsyanko <i.mitsyanko@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-12-08 00:23:45 +08:00
|
|
|
#include "qemu/osdep.h"
|
2019-05-23 21:47:44 +08:00
|
|
|
#include "qemu/units.h"
|
2017-06-13 21:56:57 +08:00
|
|
|
#include "qapi/error.h"
|
2017-04-21 00:32:28 +08:00
|
|
|
#include "qemu/error-report.h"
|
2016-01-20 04:51:44 +08:00
|
|
|
#include "cpu.h"
|
2012-12-18 01:20:04 +08:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-02-04 22:40:22 +08:00
|
|
|
#include "hw/sysbus.h"
|
2012-10-24 14:43:34 +08:00
|
|
|
#include "net/net.h"
|
2019-05-23 21:47:43 +08:00
|
|
|
#include "hw/arm/boot.h"
|
2012-12-18 01:19:49 +08:00
|
|
|
#include "exec/address-spaces.h"
|
2013-02-06 00:06:20 +08:00
|
|
|
#include "hw/arm/exynos4210.h"
|
2019-04-13 00:54:15 +08:00
|
|
|
#include "hw/net/lan9118.h"
|
2019-08-12 13:23:51 +08:00
|
|
|
#include "hw/qdev-properties.h"
|
2013-02-04 22:40:22 +08:00
|
|
|
#include "hw/boards.h"
|
2019-08-12 13:23:42 +08:00
|
|
|
#include "hw/irq.h"
|
2012-02-16 17:56:05 +08:00
|
|
|
|
2012-02-16 17:56:06 +08:00
|
|
|
#define SMDK_LAN9118_BASE_ADDR 0x05000000
|
|
|
|
|
2012-02-16 17:56:05 +08:00
|
|
|
typedef enum Exynos4BoardType {
|
|
|
|
EXYNOS4_BOARD_NURI,
|
|
|
|
EXYNOS4_BOARD_SMDKC210,
|
|
|
|
EXYNOS4_NUM_OF_BOARDS
|
|
|
|
} Exynos4BoardType;
|
|
|
|
|
2017-06-13 21:56:57 +08:00
|
|
|
typedef struct Exynos4BoardState {
|
2019-05-23 21:47:44 +08:00
|
|
|
Exynos4210State soc;
|
2017-06-13 21:56:57 +08:00
|
|
|
MemoryRegion dram0_mem;
|
|
|
|
MemoryRegion dram1_mem;
|
|
|
|
} Exynos4BoardState;
|
|
|
|
|
2012-02-16 17:56:05 +08:00
|
|
|
static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = {
|
|
|
|
[EXYNOS4_BOARD_NURI] = 0xD33,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = 0xB16,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
|
|
|
|
[EXYNOS4_BOARD_NURI] = EXYNOS4210_SECOND_CPU_BOOTREG,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG,
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
|
2019-05-23 21:47:44 +08:00
|
|
|
[EXYNOS4_BOARD_NURI] = 1 * GiB,
|
|
|
|
[EXYNOS4_BOARD_SMDKC210] = 1 * GiB,
|
2012-02-16 17:56:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct arm_boot_info exynos4_board_binfo = {
|
|
|
|
.loader_start = EXYNOS4210_BASE_BOOT_ADDR,
|
|
|
|
.smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR,
|
|
|
|
.nb_cpus = EXYNOS4210_NCPUS,
|
2012-04-13 19:39:06 +08:00
|
|
|
.write_secondary_boot = exynos4210_write_secondary,
|
2012-02-16 17:56:05 +08:00
|
|
|
};
|
|
|
|
|
2012-02-16 17:56:06 +08:00
|
|
|
static void lan9215_init(uint32_t base, qemu_irq irq)
|
|
|
|
{
|
|
|
|
DeviceState *dev;
|
|
|
|
SysBusDevice *s;
|
|
|
|
|
|
|
|
/* This should be a 9215 but the 9118 is close enough */
|
2012-07-24 23:35:11 +08:00
|
|
|
if (nd_table[0].used) {
|
2012-02-16 17:56:06 +08:00
|
|
|
qemu_check_nic_model(&nd_table[0], "lan9118");
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 13:31:58 +08:00
|
|
|
dev = qdev_new(TYPE_LAN9118);
|
2012-02-16 17:56:06 +08:00
|
|
|
qdev_set_nic_properties(dev, &nd_table[0]);
|
|
|
|
qdev_prop_set_uint32(dev, "mode_16bit", 1);
|
2013-01-20 09:47:33 +08:00
|
|
|
s = SYS_BUS_DEVICE(dev);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 13:32:34 +08:00
|
|
|
sysbus_realize_and_unref(s, &error_fatal);
|
2012-02-16 17:56:06 +08:00
|
|
|
sysbus_mmio_map(s, 0, base);
|
|
|
|
sysbus_connect_irq(s, 0, irq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-13 21:56:57 +08:00
|
|
|
static void exynos4_boards_init_ram(Exynos4BoardState *s,
|
|
|
|
MemoryRegion *system_mem,
|
|
|
|
unsigned long ram_size)
|
|
|
|
{
|
|
|
|
unsigned long mem_size = ram_size;
|
|
|
|
|
|
|
|
if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) {
|
2017-07-07 22:42:53 +08:00
|
|
|
memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1",
|
2017-06-13 21:56:57 +08:00
|
|
|
mem_size - EXYNOS4210_DRAM_MAX_SIZE,
|
|
|
|
&error_fatal);
|
|
|
|
memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR,
|
|
|
|
&s->dram1_mem);
|
|
|
|
mem_size = EXYNOS4210_DRAM_MAX_SIZE;
|
|
|
|
}
|
|
|
|
|
2017-07-07 22:42:53 +08:00
|
|
|
memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size,
|
2017-06-13 21:56:57 +08:00
|
|
|
&error_fatal);
|
|
|
|
memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR,
|
|
|
|
&s->dram0_mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Exynos4BoardState *
|
|
|
|
exynos4_boards_init_common(MachineState *machine,
|
|
|
|
Exynos4BoardType board_type)
|
2012-02-16 17:56:05 +08:00
|
|
|
{
|
2017-06-13 21:56:57 +08:00
|
|
|
Exynos4BoardState *s = g_new(Exynos4BoardState, 1);
|
2012-02-16 17:56:05 +08:00
|
|
|
|
|
|
|
exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
|
|
|
|
exynos4_board_binfo.board_id = exynos4_board_id[board_type];
|
|
|
|
exynos4_board_binfo.smp_bootreg_addr =
|
|
|
|
exynos4_board_smp_bootreg_addr[board_type];
|
2012-02-16 17:56:09 +08:00
|
|
|
exynos4_board_binfo.gic_cpu_if_addr =
|
|
|
|
EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
|
2012-02-16 17:56:05 +08:00
|
|
|
|
2017-06-13 21:56:57 +08:00
|
|
|
exynos4_boards_init_ram(s, get_system_memory(),
|
|
|
|
exynos4_board_ram_size[board_type]);
|
|
|
|
|
sysbus: Convert qdev_set_parent_bus() use with Coccinelle, part 1
I'm converting from qdev_set_parent_bus()/realize to qdev_realize();
recent commit "qdev: Convert uses of qdev_set_parent_bus() with
Coccinelle" explains why.
sysbus_init_child_obj() is a wrapper around
object_initialize_child_with_props() and qdev_set_parent_bus(). It
passes no properties.
Convert sysbus_init_child_obj()/realize to object_initialize_child()/
qdev_realize().
Coccinelle script:
@@
expression parent, name, size, type, errp;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, &child, size, type);
+ sysbus_init_child_XXX(parent, name, &child, size, type);
...
- object_property_set_bool(OBJECT(&child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(&child), errp);
@@
expression parent, name, size, type, errp;
expression child;
symbol true;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
...
- object_property_set_bool(OBJECT(child), true, "realized", errp);
+ sysbus_realize(SYS_BUS_DEVICE(child), errp);
@@
expression parent, name, size, type;
expression child;
expression dev;
expression expr;
@@
- sysbus_init_child_obj(parent, name, child, size, type);
+ sysbus_init_child_XXX(parent, name, child, size, type);
...
dev = DEVICE(child);
... when != dev = expr;
- qdev_init_nofail(dev);
+ sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, child, sizeof(*child), type)
+ object_initialize_child(parent, propname, child, type)
@@
expression parent, propname, type;
expression child;
@@
- sysbus_init_child_XXX(parent, propname, &child, sizeof(child), type)
+ object_initialize_child(parent, propname, &child, type)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-48-armbru@redhat.com>
2020-06-10 13:32:36 +08:00
|
|
|
object_initialize_child(OBJECT(machine), "soc", &s->soc,
|
|
|
|
TYPE_EXYNOS4210_SOC);
|
|
|
|
sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
|
2017-06-13 21:56:57 +08:00
|
|
|
|
|
|
|
return s;
|
2012-02-16 17:56:05 +08:00
|
|
|
}
|
|
|
|
|
2014-05-07 22:42:57 +08:00
|
|
|
static void nuri_init(MachineState *machine)
|
2012-02-16 17:56:05 +08:00
|
|
|
{
|
2014-05-07 22:42:57 +08:00
|
|
|
exynos4_boards_init_common(machine, EXYNOS4_BOARD_NURI);
|
2012-02-16 17:56:05 +08:00
|
|
|
|
2019-08-09 14:57:21 +08:00
|
|
|
arm_load_kernel(ARM_CPU(first_cpu), machine, &exynos4_board_binfo);
|
2012-02-16 17:56:05 +08:00
|
|
|
}
|
|
|
|
|
2014-05-07 22:42:57 +08:00
|
|
|
static void smdkc210_init(MachineState *machine)
|
2012-02-16 17:56:05 +08:00
|
|
|
{
|
2017-06-13 21:56:57 +08:00
|
|
|
Exynos4BoardState *s = exynos4_boards_init_common(machine,
|
|
|
|
EXYNOS4_BOARD_SMDKC210);
|
2012-02-16 17:56:05 +08:00
|
|
|
|
2012-02-16 17:56:06 +08:00
|
|
|
lan9215_init(SMDK_LAN9118_BASE_ADDR,
|
2019-05-23 21:47:44 +08:00
|
|
|
qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)]));
|
2019-08-09 14:57:21 +08:00
|
|
|
arm_load_kernel(ARM_CPU(first_cpu), machine, &exynos4_board_binfo);
|
2012-02-16 17:56:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 16:49:44 +08:00
|
|
|
static void nuri_class_init(ObjectClass *oc, void *data)
|
2015-09-05 02:37:08 +08:00
|
|
|
{
|
2015-09-19 16:49:44 +08:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
|
2015-09-05 02:37:08 +08:00
|
|
|
mc->desc = "Samsung NURI board (Exynos4210)";
|
|
|
|
mc->init = nuri_init;
|
|
|
|
mc->max_cpus = EXYNOS4210_NCPUS;
|
2017-11-13 21:55:27 +08:00
|
|
|
mc->min_cpus = EXYNOS4210_NCPUS;
|
|
|
|
mc->default_cpus = EXYNOS4210_NCPUS;
|
2017-09-07 20:54:54 +08:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2015-09-05 02:37:08 +08:00
|
|
|
}
|
2015-09-05 02:37:05 +08:00
|
|
|
|
2015-09-19 16:49:44 +08:00
|
|
|
static const TypeInfo nuri_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("nuri"),
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.class_init = nuri_class_init,
|
|
|
|
};
|
2012-02-16 17:56:05 +08:00
|
|
|
|
2015-09-19 16:49:44 +08:00
|
|
|
static void smdkc210_class_init(ObjectClass *oc, void *data)
|
2012-02-16 17:56:05 +08:00
|
|
|
{
|
2015-09-19 16:49:44 +08:00
|
|
|
MachineClass *mc = MACHINE_CLASS(oc);
|
|
|
|
|
2015-09-05 02:37:08 +08:00
|
|
|
mc->desc = "Samsung SMDKC210 board (Exynos4210)";
|
|
|
|
mc->init = smdkc210_init;
|
|
|
|
mc->max_cpus = EXYNOS4210_NCPUS;
|
2017-11-13 21:55:27 +08:00
|
|
|
mc->min_cpus = EXYNOS4210_NCPUS;
|
|
|
|
mc->default_cpus = EXYNOS4210_NCPUS;
|
2017-09-07 20:54:54 +08:00
|
|
|
mc->ignore_memory_transaction_failures = true;
|
2012-02-16 17:56:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 16:49:44 +08:00
|
|
|
static const TypeInfo smdkc210_type = {
|
|
|
|
.name = MACHINE_TYPE_NAME("smdkc210"),
|
|
|
|
.parent = TYPE_MACHINE,
|
|
|
|
.class_init = smdkc210_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exynos4_machines_init(void)
|
|
|
|
{
|
|
|
|
type_register_static(&nuri_type);
|
|
|
|
type_register_static(&smdkc210_type);
|
|
|
|
}
|
|
|
|
|
2016-02-17 04:59:04 +08:00
|
|
|
type_init(exynos4_machines_init)
|