Skip to content

Commit

Permalink
hw/arm: Add PCI mailbox module to Nuvoton SoC
Browse files Browse the repository at this point in the history
This patch wires the PCI mailbox module to Nuvoton SoC.

Change-Id: I14c42c628258804030f0583889882842bde0d972
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Signed-off-by: Nabih Estefan <nabihestefan@google.com>
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
Message-id: 20240110234232.4116804-3-nabihestefan@google.com
[PMM: moved some changes incorrectly in previous patch into this one]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jan 15, 2024
1 parent d322429 commit 981b2c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/system/arm/nuvoton.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Supported devices
* Ethernet controller (EMC)
* Tachometer
* Peripheral SPI controller (PSPI)
* BIOS POST code FIFO
* PCI Mailbox

Missing devices
---------------
Expand Down
17 changes: 16 additions & 1 deletion hw/arm/npcm7xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
/* ADC Module */
#define NPCM7XX_ADC_BA (0xf000c000)

/* PCI Mailbox Module */
#define NPCM7XX_PCI_MBOX_BA (0xf0848000)

/* Internal AHB SRAM */
#define NPCM7XX_RAM3_BA (0xc0008000)
#define NPCM7XX_RAM3_SZ (4 * KiB)
Expand Down Expand Up @@ -83,6 +86,9 @@ enum NPCM7xxInterrupt {
NPCM7XX_UART1_IRQ,
NPCM7XX_UART2_IRQ,
NPCM7XX_UART3_IRQ,
NPCM7XX_PCI_MBOX_IRQ = 8,
NPCM7XX_KCS_HIB_IRQ = 9,
NPCM7XX_GMAC1_IRQ = 14,
NPCM7XX_EMC1RX_IRQ = 15,
NPCM7XX_EMC1TX_IRQ,
NPCM7XX_MMC_IRQ = 26,
Expand Down Expand Up @@ -456,6 +462,8 @@ static void npcm7xx_init(Object *obj)
object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI);
}

object_initialize_child(obj, "pci-mbox", &s->pci_mbox,
TYPE_NPCM7XX_PCI_MBOX);
object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI);
}

Expand Down Expand Up @@ -706,6 +714,14 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
}
}

/* PCI Mailbox. Cannot fail */
sysbus_realize(SYS_BUS_DEVICE(&s->pci_mbox), &error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->pci_mbox), 0, NPCM7XX_PCI_MBOX_BA);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->pci_mbox), 1,
NPCM7XX_PCI_MBOX_BA + NPCM7XX_PCI_MBOX_RAM_SIZE);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->pci_mbox), 0,
npcm7xx_irq(s, NPCM7XX_PCI_MBOX_IRQ));

/* RAM2 (SRAM) */
memory_region_init_ram(&s->sram, OBJECT(dev), "ram2",
NPCM7XX_RAM2_SZ, &error_abort);
Expand Down Expand Up @@ -765,7 +781,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
create_unimplemented_device("npcm7xx.usbd[8]", 0xf0838000, 4 * KiB);
create_unimplemented_device("npcm7xx.usbd[9]", 0xf0839000, 4 * KiB);
create_unimplemented_device("npcm7xx.sd", 0xf0840000, 8 * KiB);
create_unimplemented_device("npcm7xx.pcimbx", 0xf0848000, 512 * KiB);
create_unimplemented_device("npcm7xx.aes", 0xf0858000, 4 * KiB);
create_unimplemented_device("npcm7xx.des", 0xf0859000, 4 * KiB);
create_unimplemented_device("npcm7xx.sha", 0xf085a000, 4 * KiB);
Expand Down
2 changes: 2 additions & 0 deletions include/hw/arm/npcm7xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "hw/misc/npcm7xx_clk.h"
#include "hw/misc/npcm7xx_gcr.h"
#include "hw/misc/npcm7xx_mft.h"
#include "hw/misc/npcm7xx_pci_mbox.h"
#include "hw/misc/npcm7xx_pwm.h"
#include "hw/misc/npcm7xx_rng.h"
#include "hw/net/npcm7xx_emc.h"
Expand Down Expand Up @@ -104,6 +105,7 @@ struct NPCM7xxState {
OHCISysBusState ohci;
NPCM7xxFIUState fiu[2];
NPCM7xxEMCState emc[2];
NPCM7xxPCIMBoxState pci_mbox;
NPCM7xxSDHCIState mmc;
NPCMPSPIState pspi[2];
};
Expand Down

0 comments on commit 981b2c6

Please sign in to comment.