
* Update to QEMU v9.0.0 --------- Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Ido Plat <ido.plat@ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Gregory Price <gregory.price@memverge.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Lorenz Brun <lorenz@brun.one> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Sven Schnelle <svens@stackframe.org> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Glenn Miles <milesg@linux.ibm.com> Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Signed-off-by: Yajun Wu <yajunw@nvidia.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Signed-off-by: Lei Wang <lei4.wang@intel.com> Signed-off-by: Wei Wang <wei.w.wang@intel.com> Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Wafer <wafer@jaguarmicro.com> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Signed-off-by: Zack Buhman <zack@buhman.org> Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Yuquan Wang wangyuquan1236@phytium.com.cn Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Co-authored-by: Peter Maydell <peter.maydell@linaro.org> Co-authored-by: Fabiano Rosas <farosas@suse.de> Co-authored-by: Peter Xu <peterx@redhat.com> Co-authored-by: Thomas Huth <thuth@redhat.com> Co-authored-by: Cédric Le Goater <clg@redhat.com> Co-authored-by: Zheyu Ma <zheyuma97@gmail.com> Co-authored-by: Ido Plat <ido.plat@ibm.com> Co-authored-by: Ilya Leoshkevich <iii@linux.ibm.com> Co-authored-by: Markus Armbruster <armbru@redhat.com> Co-authored-by: Marc-André Lureau <marcandre.lureau@redhat.com> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Co-authored-by: David Hildenbrand <david@redhat.com> Co-authored-by: Kevin Wolf <kwolf@redhat.com> Co-authored-by: Stefan Reiter <s.reiter@proxmox.com> Co-authored-by: Fiona Ebner <f.ebner@proxmox.com> Co-authored-by: Gregory Price <gregory.price@memverge.com> Co-authored-by: Lorenz Brun <lorenz@brun.one> Co-authored-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Co-authored-by: Philippe Mathieu-Daudé <philmd@linaro.org> Co-authored-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Co-authored-by: BALATON Zoltan <balaton@eik.bme.hu> Co-authored-by: Igor Mammedov <imammedo@redhat.com> Co-authored-by: Akihiko Odaki <akihiko.odaki@daynix.com> Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Co-authored-by: Sven Schnelle <svens@stackframe.org> Co-authored-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Co-authored-by: Helge Deller <deller@kernel.org> Co-authored-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Co-authored-by: Benjamin Gray <bgray@linux.ibm.com> Co-authored-by: Nicholas Piggin <npiggin@gmail.com> Co-authored-by: Avihai Horon <avihaih@nvidia.com> Co-authored-by: Michael Tokarev <mjt@tls.msk.ru> Co-authored-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Co-authored-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Co-authored-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Dayu Liu <liu.dayu@zte.com.cn> Co-authored-by: Zhao Liu <zhao1.liu@intel.com> Co-authored-by: Glenn Miles <milesg@linux.vnet.ibm.com> Co-authored-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Co-authored-by: Yajun Wu <yajunw@nvidia.com> Co-authored-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Co-authored-by: Pierre-Clément Tosi <ptosi@google.com> Co-authored-by: Wei Wang <wei.w.wang@intel.com> Co-authored-by: Martin Hundebøll <martin@geanix.com> Co-authored-by: Michael S. Tsirkin <mst@redhat.com> Co-authored-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Co-authored-by: Wafer <wafer@jaguarmicro.com> Co-authored-by: lyx634449800 <yuxue.liu@jaguarmicro.com> Co-authored-by: Gerd Hoffmann <kraxel@redhat.com> Co-authored-by: Nguyen Dinh Phi <phind.uet@gmail.com> Co-authored-by: Zack Buhman <zack@buhman.org> Co-authored-by: Keith Packard <keithp@keithp.com> Co-authored-by: Yuquan Wang <wangyuquan1236@phytium.com.cn> Co-authored-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Co-authored-by: Cindy Lu <lulu@redhat.com>
248 lines
8.3 KiB
C
248 lines
8.3 KiB
C
/*
|
|
* Copyright (c) 2013 Jean-Christophe Dubois <jcd@tribudubois.net>
|
|
*
|
|
* i.MX31 SOC emulation.
|
|
*
|
|
* Based on hw/arm/fsl-imx31.c
|
|
*
|
|
* 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/>.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qapi/error.h"
|
|
#include "hw/arm/fsl-imx31.h"
|
|
#include "sysemu/sysemu.h"
|
|
#include "exec/address-spaces.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "chardev/char.h"
|
|
#include "target/arm/cpu-qom.h"
|
|
|
|
static void fsl_imx31_init(Object *obj)
|
|
{
|
|
FslIMX31State *s = FSL_IMX31(obj);
|
|
int i;
|
|
|
|
object_initialize_child(obj, "cpu", &s->cpu, ARM_CPU_TYPE_NAME("arm1136"));
|
|
|
|
object_initialize_child(obj, "avic", &s->avic, TYPE_IMX_AVIC);
|
|
|
|
object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX31_CCM);
|
|
|
|
for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) {
|
|
object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_IMX_SERIAL);
|
|
}
|
|
|
|
object_initialize_child(obj, "gpt", &s->gpt, TYPE_IMX31_GPT);
|
|
|
|
for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) {
|
|
object_initialize_child(obj, "epit[*]", &s->epit[i], TYPE_IMX_EPIT);
|
|
}
|
|
|
|
for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) {
|
|
object_initialize_child(obj, "i2c[*]", &s->i2c[i], TYPE_IMX_I2C);
|
|
}
|
|
|
|
for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) {
|
|
object_initialize_child(obj, "gpio[*]", &s->gpio[i], TYPE_IMX_GPIO);
|
|
}
|
|
|
|
object_initialize_child(obj, "wdt", &s->wdt, TYPE_IMX2_WDT);
|
|
}
|
|
|
|
static void fsl_imx31_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
FslIMX31State *s = FSL_IMX31(dev);
|
|
uint16_t i;
|
|
|
|
if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) {
|
|
return;
|
|
}
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->avic), errp)) {
|
|
return;
|
|
}
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->avic), 0, FSL_IMX31_AVIC_ADDR);
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->avic), 1,
|
|
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->ccm), errp)) {
|
|
return;
|
|
}
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX31_CCM_ADDR);
|
|
|
|
/* Initialize all UARTS */
|
|
for (i = 0; i < FSL_IMX31_NUM_UARTS; i++) {
|
|
static const struct {
|
|
hwaddr addr;
|
|
unsigned int irq;
|
|
} serial_table[FSL_IMX31_NUM_UARTS] = {
|
|
{ FSL_IMX31_UART1_ADDR, FSL_IMX31_UART1_IRQ },
|
|
{ FSL_IMX31_UART2_ADDR, FSL_IMX31_UART2_IRQ },
|
|
};
|
|
|
|
qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i));
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
|
|
return;
|
|
}
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr);
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->avic),
|
|
serial_table[i].irq));
|
|
}
|
|
|
|
s->gpt.ccm = IMX_CCM(&s->ccm);
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpt), errp)) {
|
|
return;
|
|
}
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX31_GPT_ADDR);
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX31_GPT_IRQ));
|
|
|
|
/* Initialize all EPIT timers */
|
|
for (i = 0; i < FSL_IMX31_NUM_EPITS; i++) {
|
|
static const struct {
|
|
hwaddr addr;
|
|
unsigned int irq;
|
|
} epit_table[FSL_IMX31_NUM_EPITS] = {
|
|
{ FSL_IMX31_EPIT1_ADDR, FSL_IMX31_EPIT1_IRQ },
|
|
{ FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ },
|
|
};
|
|
|
|
s->epit[i].ccm = IMX_CCM(&s->ccm);
|
|
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->epit[i]), errp)) {
|
|
return;
|
|
}
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr);
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->avic),
|
|
epit_table[i].irq));
|
|
}
|
|
|
|
/* Initialize all I2C */
|
|
for (i = 0; i < FSL_IMX31_NUM_I2CS; i++) {
|
|
static const struct {
|
|
hwaddr addr;
|
|
unsigned int irq;
|
|
} i2c_table[FSL_IMX31_NUM_I2CS] = {
|
|
{ FSL_IMX31_I2C1_ADDR, FSL_IMX31_I2C1_IRQ },
|
|
{ FSL_IMX31_I2C2_ADDR, FSL_IMX31_I2C2_IRQ },
|
|
{ FSL_IMX31_I2C3_ADDR, FSL_IMX31_I2C3_IRQ }
|
|
};
|
|
|
|
/* Initialize the I2C */
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->i2c[i]), errp)) {
|
|
return;
|
|
}
|
|
/* Map I2C memory */
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr);
|
|
/* Connect I2C IRQ to PIC */
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->avic),
|
|
i2c_table[i].irq));
|
|
}
|
|
|
|
/* Initialize all GPIOs */
|
|
for (i = 0; i < FSL_IMX31_NUM_GPIOS; i++) {
|
|
static const struct {
|
|
hwaddr addr;
|
|
unsigned int irq;
|
|
} gpio_table[FSL_IMX31_NUM_GPIOS] = {
|
|
{ FSL_IMX31_GPIO1_ADDR, FSL_IMX31_GPIO1_IRQ },
|
|
{ FSL_IMX31_GPIO2_ADDR, FSL_IMX31_GPIO2_IRQ },
|
|
{ FSL_IMX31_GPIO3_ADDR, FSL_IMX31_GPIO3_IRQ }
|
|
};
|
|
|
|
object_property_set_bool(OBJECT(&s->gpio[i]), "has-edge-sel", false,
|
|
&error_abort);
|
|
if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
|
|
return;
|
|
}
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
|
|
/* Connect GPIO IRQ to PIC */
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
|
|
qdev_get_gpio_in(DEVICE(&s->avic),
|
|
gpio_table[i].irq));
|
|
}
|
|
|
|
/* Watchdog */
|
|
sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_abort);
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, FSL_IMX31_WDT_ADDR);
|
|
|
|
/* On a real system, the first 16k is a `secure boot rom' */
|
|
if (!memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom",
|
|
FSL_IMX31_SECURE_ROM_SIZE, errp)) {
|
|
return;
|
|
}
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_SECURE_ROM_ADDR,
|
|
&s->secure_rom);
|
|
|
|
/* There is also a 16k ROM */
|
|
if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom",
|
|
FSL_IMX31_ROM_SIZE, errp)) {
|
|
return;
|
|
}
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_ROM_ADDR,
|
|
&s->rom);
|
|
|
|
/* initialize internal RAM (16 KB) */
|
|
if (!memory_region_init_ram(&s->iram, NULL, "imx31.iram",
|
|
FSL_IMX31_IRAM_SIZE, errp)) {
|
|
return;
|
|
}
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ADDR,
|
|
&s->iram);
|
|
|
|
/* internal RAM (16 KB) is aliased over 256 MB - 16 KB */
|
|
memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx31.iram_alias",
|
|
&s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE);
|
|
memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR,
|
|
&s->iram_alias);
|
|
}
|
|
|
|
static void fsl_imx31_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
dc->realize = fsl_imx31_realize;
|
|
dc->desc = "i.MX31 SOC";
|
|
/*
|
|
* Reason: uses serial_hds in realize and the kzm board does not
|
|
* support multiple CPUs
|
|
*/
|
|
dc->user_creatable = false;
|
|
}
|
|
|
|
static const TypeInfo fsl_imx31_type_info = {
|
|
.name = TYPE_FSL_IMX31,
|
|
.parent = TYPE_DEVICE,
|
|
.instance_size = sizeof(FslIMX31State),
|
|
.instance_init = fsl_imx31_init,
|
|
.class_init = fsl_imx31_class_init,
|
|
};
|
|
|
|
static void fsl_imx31_register_types(void)
|
|
{
|
|
type_register_static(&fsl_imx31_type_info);
|
|
}
|
|
|
|
type_init(fsl_imx31_register_types)
|