MAX78000: Add UART to SOC
This commit adds UART to max78000_soc Signed-off-by: Jackson Donaldson <jcksn@duck.com> Reviewed-by: Peter Maydell <petermaydell@linaro.org> Message-id: 20250704223239.248781-6-jcksn@duck.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
d447e4b702
commit
a670bb8a72
2 changed files with 27 additions and 4 deletions
|
|
@ -18,6 +18,10 @@
|
|||
#include "hw/misc/unimp.h"
|
||||
|
||||
static const uint32_t max78000_icc_addr[] = {0x4002a000, 0x4002a800};
|
||||
static const uint32_t max78000_uart_addr[] = {0x40042000, 0x40043000,
|
||||
0x40044000};
|
||||
|
||||
static const int max78000_uart_irq[] = {14, 15, 34};
|
||||
|
||||
static void max78000_soc_initfn(Object *obj)
|
||||
{
|
||||
|
|
@ -31,6 +35,12 @@ static void max78000_soc_initfn(Object *obj)
|
|||
object_initialize_child(obj, name, &s->icc[i], TYPE_MAX78000_ICC);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX78000_NUM_UART; i++) {
|
||||
g_autofree char *name = g_strdup_printf("uart%d", i);
|
||||
object_initialize_child(obj, name, &s->uart[i],
|
||||
TYPE_MAX78000_UART);
|
||||
}
|
||||
|
||||
s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +49,7 @@ static void max78000_soc_realize(DeviceState *dev_soc, Error **errp)
|
|||
MAX78000State *s = MAX78000_SOC(dev_soc);
|
||||
MemoryRegion *system_memory = get_system_memory();
|
||||
DeviceState *dev, *armv7m;
|
||||
SysBusDevice *busdev;
|
||||
Error *err = NULL;
|
||||
int i;
|
||||
|
||||
|
|
@ -89,6 +100,19 @@ static void max78000_soc_realize(DeviceState *dev_soc, Error **errp)
|
|||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, max78000_icc_addr[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX78000_NUM_UART; i++) {
|
||||
dev = DEVICE(&(s->uart[i]));
|
||||
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->uart[i]), errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_mmio_map(busdev, 0, max78000_uart_addr[i]);
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m,
|
||||
max78000_uart_irq[i]));
|
||||
}
|
||||
|
||||
create_unimplemented_device("globalControl", 0x40000000, 0x400);
|
||||
create_unimplemented_device("systemInterface", 0x40000400, 0x400);
|
||||
create_unimplemented_device("functionControl", 0x40000800, 0x400);
|
||||
|
|
@ -127,10 +151,6 @@ static void max78000_soc_realize(DeviceState *dev_soc, Error **errp)
|
|||
create_unimplemented_device("oneWireMaster", 0x4003d000, 0x1000);
|
||||
create_unimplemented_device("semaphore", 0x4003e000, 0x1000);
|
||||
|
||||
create_unimplemented_device("uart0", 0x40042000, 0x1000);
|
||||
create_unimplemented_device("uart1", 0x40043000, 0x1000);
|
||||
create_unimplemented_device("uart2", 0x40044000, 0x1000);
|
||||
|
||||
create_unimplemented_device("spi1", 0x40046000, 0x2000);
|
||||
create_unimplemented_device("trng", 0x4004d000, 0x1000);
|
||||
create_unimplemented_device("i2s", 0x40060000, 0x1000);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "hw/or-irq.h"
|
||||
#include "hw/arm/armv7m.h"
|
||||
#include "hw/misc/max78000_icc.h"
|
||||
#include "hw/char/max78000_uart.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_MAX78000_SOC "max78000-soc"
|
||||
|
|
@ -24,6 +25,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(MAX78000State, MAX78000_SOC)
|
|||
|
||||
/* The MAX78k has 2 instruction caches; only icc0 matters, icc1 is for RISC */
|
||||
#define MAX78000_NUM_ICC 2
|
||||
#define MAX78000_NUM_UART 3
|
||||
|
||||
struct MAX78000State {
|
||||
SysBusDevice parent_obj;
|
||||
|
|
@ -34,6 +36,7 @@ struct MAX78000State {
|
|||
MemoryRegion flash;
|
||||
|
||||
Max78000IccState icc[MAX78000_NUM_ICC];
|
||||
Max78000UartState uart[MAX78000_NUM_UART];
|
||||
|
||||
Clock *sysclk;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue