riscv: opentitan: Connect opentitan SPI Host
Connect spi host[1/0] to opentitan. Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220303045426.511588-2-alistair.francis@opensource.wdc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
9c4888c995
commit
9972479fac
@ -120,11 +120,18 @@ static void lowrisc_ibex_soc_init(Object *obj)
|
||||
object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART);
|
||||
|
||||
object_initialize_child(obj, "timer", &s->timer, TYPE_IBEX_TIMER);
|
||||
|
||||
for (int i = 0; i < OPENTITAN_NUM_SPI_HOSTS; i++) {
|
||||
object_initialize_child(obj, "spi_host[*]", &s->spi_host[i],
|
||||
TYPE_IBEX_SPI_HOST);
|
||||
}
|
||||
}
|
||||
|
||||
static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
{
|
||||
const MemMapEntry *memmap = ibex_memmap;
|
||||
DeviceState *dev;
|
||||
SysBusDevice *busdev;
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
LowRISCIbexSoCState *s = RISCV_IBEX_SOC(dev_soc);
|
||||
MemoryRegion *sys_mem = get_system_memory();
|
||||
@ -209,14 +216,35 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
qdev_get_gpio_in(DEVICE(qemu_get_cpu(0)),
|
||||
IRQ_M_TIMER));
|
||||
|
||||
/* SPI-Hosts */
|
||||
for (int i = 0; i < OPENTITAN_NUM_SPI_HOSTS; ++i) {
|
||||
dev = DEVICE(&(s->spi_host[i]));
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi_host[i]), errp)) {
|
||||
return;
|
||||
}
|
||||
busdev = SYS_BUS_DEVICE(dev);
|
||||
sysbus_mmio_map(busdev, 0, memmap[IBEX_DEV_SPI_HOST0 + i].base);
|
||||
|
||||
switch (i) {
|
||||
case OPENTITAN_SPI_HOST0:
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(DEVICE(&s->plic),
|
||||
IBEX_SPI_HOST0_ERR_IRQ));
|
||||
sysbus_connect_irq(busdev, 1, qdev_get_gpio_in(DEVICE(&s->plic),
|
||||
IBEX_SPI_HOST0_SPI_EVENT_IRQ));
|
||||
break;
|
||||
case OPENTITAN_SPI_HOST1:
|
||||
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(DEVICE(&s->plic),
|
||||
IBEX_SPI_HOST1_ERR_IRQ));
|
||||
sysbus_connect_irq(busdev, 1, qdev_get_gpio_in(DEVICE(&s->plic),
|
||||
IBEX_SPI_HOST1_SPI_EVENT_IRQ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.gpio",
|
||||
memmap[IBEX_DEV_GPIO].base, memmap[IBEX_DEV_GPIO].size);
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.spi_device",
|
||||
memmap[IBEX_DEV_SPI_DEVICE].base, memmap[IBEX_DEV_SPI_DEVICE].size);
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.spi_host0",
|
||||
memmap[IBEX_DEV_SPI_HOST0].base, memmap[IBEX_DEV_SPI_HOST0].size);
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.spi_host1",
|
||||
memmap[IBEX_DEV_SPI_HOST1].base, memmap[IBEX_DEV_SPI_HOST1].size);
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.i2c",
|
||||
memmap[IBEX_DEV_I2C].base, memmap[IBEX_DEV_I2C].size);
|
||||
create_unimplemented_device("riscv.lowrisc.ibex.pattgen",
|
||||
|
@ -23,11 +23,18 @@
|
||||
#include "hw/intc/sifive_plic.h"
|
||||
#include "hw/char/ibex_uart.h"
|
||||
#include "hw/timer/ibex_timer.h"
|
||||
#include "hw/ssi/ibex_spi_host.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_RISCV_IBEX_SOC "riscv.lowrisc.ibex.soc"
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(LowRISCIbexSoCState, RISCV_IBEX_SOC)
|
||||
|
||||
enum {
|
||||
OPENTITAN_SPI_HOST0,
|
||||
OPENTITAN_SPI_HOST1,
|
||||
OPENTITAN_NUM_SPI_HOSTS,
|
||||
};
|
||||
|
||||
struct LowRISCIbexSoCState {
|
||||
/*< private >*/
|
||||
SysBusDevice parent_obj;
|
||||
@ -37,6 +44,7 @@ struct LowRISCIbexSoCState {
|
||||
SiFivePLICState plic;
|
||||
IbexUartState uart;
|
||||
IbexTimerState timer;
|
||||
IbexSPIHostState spi_host[OPENTITAN_NUM_SPI_HOSTS];
|
||||
|
||||
MemoryRegion flash_mem;
|
||||
MemoryRegion rom;
|
||||
@ -89,15 +97,19 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
IBEX_TIMER_TIMEREXPIRED0_0 = 126,
|
||||
IBEX_UART0_RX_PARITY_ERR_IRQ = 8,
|
||||
IBEX_UART0_RX_TIMEOUT_IRQ = 7,
|
||||
IBEX_UART0_RX_BREAK_ERR_IRQ = 6,
|
||||
IBEX_UART0_RX_FRAME_ERR_IRQ = 5,
|
||||
IBEX_UART0_RX_OVERFLOW_IRQ = 4,
|
||||
IBEX_UART0_TX_EMPTY_IRQ = 3,
|
||||
IBEX_UART0_RX_WATERMARK_IRQ = 2,
|
||||
IBEX_UART0_TX_WATERMARK_IRQ = 1,
|
||||
IBEX_UART0_TX_WATERMARK_IRQ = 1,
|
||||
IBEX_UART0_RX_WATERMARK_IRQ = 2,
|
||||
IBEX_UART0_TX_EMPTY_IRQ = 3,
|
||||
IBEX_UART0_RX_OVERFLOW_IRQ = 4,
|
||||
IBEX_UART0_RX_FRAME_ERR_IRQ = 5,
|
||||
IBEX_UART0_RX_BREAK_ERR_IRQ = 6,
|
||||
IBEX_UART0_RX_TIMEOUT_IRQ = 7,
|
||||
IBEX_UART0_RX_PARITY_ERR_IRQ = 8,
|
||||
IBEX_TIMER_TIMEREXPIRED0_0 = 126,
|
||||
IBEX_SPI_HOST0_ERR_IRQ = 150,
|
||||
IBEX_SPI_HOST0_SPI_EVENT_IRQ = 151,
|
||||
IBEX_SPI_HOST1_ERR_IRQ = 152,
|
||||
IBEX_SPI_HOST1_SPI_EVENT_IRQ = 153,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user