From: "Grégoire Layet" <gregoire.layet@9elements.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Lubomir Rintel" <lkundrak@v3.sk>,
devicetree@vger.kernel.org, "Joel Stanley" <joel@jms.id.au>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Lee Jones" <lee@kernel.org>,
"Grégoire Layet" <git@gregoirelayet.com>,
"Tan Siewert" <tan.siewert@9elements.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, mfd@lists.linux.dev,
andrew@lunn.ch, jacky_chou@aspeedtech.com,
yh_chung@aspeedtech.com, ninad@linux.ibm.com,
anirudhsriniv@gmail.com,
"Grégoire Layet" <gregoire.layet@9elements.com>
Subject: [PATCH v6 4/6] mfd: aspeed-pci-core: add AST2600 PCIe BMC device driver
Date: Tue, 18 Aug 2026 10:29:17 +0000 [thread overview]
Message-ID: <20260818-aspeed-driver-v6-v6-4-fd7cc0b338ea@9elements.com> (raw)
In-Reply-To: <20260818-aspeed-driver-v6-v6-0-fd7cc0b338ea@9elements.com>
Add support for UART over PCIe between ASPEED AST2600 BMC and
host. This is the host-side driver.
Based on ASPEED 6.18 Kernel SDK and trimmed down and changed to
MFD driver.
The AST2600 has two 8250-compatible register set usable over PCIe.
These act as two UARTs. As there is only a FIFO internally between both
ends, they are called Virtual UARTs. This patch adds both VUARTs as
plat_serial8250_port. This is the core driver in charge of setting up
MSI interrupts. It doesn't bind the whole PCIe resource to allow each
sub-driver to bind the needed addresses.
This is not added as a PCI 8250 UART device, but as a MFD driver, as this
host driver can be expanded upon for IPMI over KCS. It can also be used
in the future for custom BMC<->host communication with shared memory and
doorbell.
This host module should be the entry point for setting up all features
related to an AST2600 present on the PCI bus.
Notes on the implementation:
The host can't detect the VUART addresses, so they are forced to
0x3f8 and 0x2f8, as in the initial ASPEED driver.
The MSI vector index of VUART2 has been changed from 15 to 17.
The index 15 used in the initial driver was not working.
Tested:
Data path in both direction is tested on both VUARTs.
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
Signed-off-by: aspeedyh <yh_chung@aspeedtech.com>
Signed-off-by: Grégoire Layet <gregoire.layet@9elements.com>
---
MAINTAINERS | 6 +++
drivers/mfd/Kconfig | 12 +++++
drivers/mfd/Makefile | 2 +
drivers/mfd/aspeed-pci-core.c | 115 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 135 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 562754f2d166..7ea6c7d4703e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4011,6 +4011,12 @@ S: Maintained
F: Documentation/devicetree/bindings/crypto/aspeed,*
F: drivers/crypto/aspeed/
+ASPEED PCI BMC DEVICE DRIVER
+M: Grégoire Layet <git@gregoirelayet.com>
+M: Tan Siewert <tan.siewert@9elements.com>
+S: Maintained
+F: drivers/mfd/aspeed-pci-core.c
+
ASPEED PECI CONTROLLER
M: Iwona Winiarska <iwona.winiarska@intel.com>
L: linux-aspeed@lists.ozlabs.org (moderated for non-subscribers)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 763ce6a34782..dd780f72d169 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -2573,5 +2573,17 @@ config MFD_MAX7360
additional drivers must be enabled in order to use the functionality
of the device.
+config MFD_ASPEED_PCI_BMC_DEVICE
+ tristate "ASPEED BMC PCIe device"
+ depends on PCI
+ select MFD_CORE
+ help
+ Host-side driver for the ASPEED AST2600 BMC PCIe device found on
+ BMC expansion cards. Exposes two 8250-compatible VUART
+ ports.
+
+ If unsure, say N. Choose M here if this machine has an
+ AST2600-based BMC expansion card on its PCIe bus.
+
endmenu
endif
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index dd4bb7e77c33..a364b1b5936b 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -303,3 +303,5 @@ obj-$(CONFIG_MFD_RSMU_SPI) += rsmu_spi.o rsmu_core.o
obj-$(CONFIG_MFD_UPBOARD_FPGA) += upboard-fpga.o
obj-$(CONFIG_MFD_LOONGSON_SE) += loongson-se.o
+
+obj-$(CONFIG_MFD_ASPEED_PCI_BMC_DEVICE) += aspeed-pci-core.o
diff --git a/drivers/mfd/aspeed-pci-core.c b/drivers/mfd/aspeed-pci-core.c
new file mode 100644
index 000000000000..2f299955bc1b
--- /dev/null
+++ b/drivers/mfd/aspeed-pci-core.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// Copyright (C) ASPEED Technology Inc.
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/serial_8250.h>
+#include <linux/mfd/core.h>
+
+#define ASPEED_BMC_MULTI_MSI 32
+#define ASPEED_BMC_PCI_DEVICE_ID 0x2402
+#define ASPEED_BMC_REVISION_AST2700 0x27
+#define ASPEED_BMC_NR_VUART 2
+
+#define DRIVER_NAME "ast2600-pci-core"
+
+static const unsigned int vuart_msi_index[ASPEED_BMC_NR_VUART] = { 16, 17 };
+static const u16 vuart_port_addr[ASPEED_BMC_NR_VUART] = { 0x3f8, 0x2f8 };
+
+static struct plat_serial8250_port aspeed_uart_port[ASPEED_BMC_NR_VUART + 1] = {
+ {
+ .uartclk = 115200 * 16,
+ .iotype = UPIO_MEM32,
+ .type = PORT_16550A,
+ .flags = (UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE),
+ .regshift = 2
+ },
+ {
+ .uartclk = 115200 * 16,
+ .iotype = UPIO_MEM32,
+ .type = PORT_16550A,
+ .flags = (UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE),
+ .regshift = 2
+ },
+ { 0 }
+};
+
+static const struct mfd_cell aspeed_bmc_cell = {
+ .name = "serial8250",
+ .platform_data = aspeed_uart_port,
+ .pdata_size = sizeof(aspeed_uart_port),
+};
+
+static int aspeed_pci_bmc_device_setup_vuart(struct pci_dev *pdev)
+{
+ resource_size_t bar = pci_resource_start(pdev, 1);
+ unsigned int i;
+
+ for (i = 0; i < ASPEED_BMC_NR_VUART; i++) {
+ aspeed_uart_port[i].mapbase = bar + (vuart_port_addr[i] << 2);
+ aspeed_uart_port[i].irq = pci_irq_vector(pdev, vuart_msi_index[i]);
+ }
+
+ return 0;
+}
+
+static void aspeed_bmc_pci_free_irqs(void *pdev)
+{
+ pci_free_irq_vectors(pdev);
+}
+
+static int aspeed_pci_host_bmc_device_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ struct device *dev = &pdev->dev;
+ int rc = 0;
+
+ if (pdev->revision == ASPEED_BMC_REVISION_AST2700)
+ return dev_err_probe(dev, -ENODEV, "AST2700 detected but not supported\n");
+
+ rc = pcim_enable_device(pdev);
+ if (rc)
+ return dev_err_probe(dev, rc, "failed to enable device\n");
+
+ pci_set_master(pdev);
+
+ rc = pci_alloc_irq_vectors(pdev, ASPEED_BMC_MULTI_MSI, ASPEED_BMC_MULTI_MSI, PCI_IRQ_MSI);
+ if (rc < 0)
+ return dev_err_probe(dev, rc, "failed to allocate %d MSI vectors\n",
+ ASPEED_BMC_MULTI_MSI);
+
+ rc = devm_add_action_or_reset(dev, aspeed_bmc_pci_free_irqs, pdev);
+ if (rc)
+ return rc;
+
+ aspeed_pci_bmc_device_setup_vuart(pdev);
+
+ return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO,
+ &aspeed_bmc_cell, 1, &pdev->resource[1],
+ 0, NULL);
+}
+
+static struct pci_device_id aspeed_bmc_dev_pci_ids[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ASPEED, ASPEED_BMC_PCI_DEVICE_ID),
+ .class = PCI_CLASS_OTHERS << 16,
+ .class_mask = 0xFFFF00
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(pci, aspeed_bmc_dev_pci_ids);
+
+static struct pci_driver aspeed_host_bmc_dev_driver = {
+ .name = DRIVER_NAME,
+ .id_table = aspeed_bmc_dev_pci_ids,
+ .probe = aspeed_pci_host_bmc_device_probe,
+};
+
+module_pci_driver(aspeed_host_bmc_dev_driver);
+
+MODULE_AUTHOR("Grégoire Layet <gregoire.layet@9elements.com>");
+MODULE_DESCRIPTION("Host-side driver for the ASPEED BMC PCIe device");
+MODULE_LICENSE("GPL");
--
2.54.0
next prev parent reply other threads:[~2026-08-18 10:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 10:29 [PATCH v6 0/6] soc: aspeed: Add BMC and host driver for PCIe BMC device Grégoire Layet
2026-08-18 10:29 ` [PATCH v6 1/6] dt-bindings: serial: 8250: aspeed: add ast2600 and aspeed,vuart-over-pci Grégoire Layet
2026-08-18 10:29 ` [PATCH v6 2/6] serial: 8250_aspeed_vuart: add aspeed,ast2600-vuart compatible string Grégoire Layet
2026-08-18 10:29 ` [PATCH v6 3/6] serial: 8250_aspeed_vuart: add VUART over PCI Grégoire Layet
2026-08-18 10:29 ` Grégoire Layet [this message]
2026-08-18 10:29 ` [PATCH v6 5/6] ARM: dts: aspeed: g6: Change vuart compatible string for ast2600 Grégoire Layet
2026-08-18 10:29 ` [PATCH v6 6/6] ARM: dts: aspeed: g6: add aspeed,vuart-over-pci prop to vuart3 and 4 Grégoire Layet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260818-aspeed-driver-v6-v6-4-fd7cc0b338ea@9elements.com \
--to=gregoire.layet@9elements.com \
--cc=andrew@codeconstruct.com.au \
--cc=andrew@lunn.ch \
--cc=anirudhsriniv@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=git@gregoirelayet.com \
--cc=gregkh@linuxfoundation.org \
--cc=jacky_chou@aspeedtech.com \
--cc=jirislaby@kernel.org \
--cc=joel@jms.id.au \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lkundrak@v3.sk \
--cc=mfd@lists.linux.dev \
--cc=ninad@linux.ibm.com \
--cc=robh@kernel.org \
--cc=tan.siewert@9elements.com \
--cc=yh_chung@aspeedtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox