Add support for AMD MDB IP as Root Port
Subsystems (4)
v13 cover Add support for AMD MDB IP as Root Port
This series of patch add support for AMD MDB IP as Root Port.
The AMD MDB IP support's 32 bit and 64bit BAR's at Gen5 speed. As Root Port it supports MSI and legacy interrupts.
Thippeswamy Havalige (3):
dt-bindings: PCI: dwc: Add AMD Versal2 mdb slcr support
dt-bindings: PCI: amd-mdb: Add AMD Versal2 MDB PCIe Root Port Bridge
PCI: amd-mdb: Add AMD MDB Root Port driver
.../bindings/pci/amd,versal2-mdb-host.yaml | 121 +++++ .../devicetree/bindings/pci/snps,dw-pcie.yaml | 2 + drivers/pci/controller/dwc/Kconfig | 11 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-amd-mdb.c | 470 ++++++++++++++++++ 5 files changed, 605 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/amd,versal2-mdb-host.yaml create mode 100644 drivers/pci/controller/dwc/pcie-amd-mdb.c
Signature · 1 line
2.43.0
PATCH v13 1/3 dt-bindings: PCI: dwc: Add AMD Versal2 mdb slcr support
Add support for mdb slcr aperture that is only supported for AMD Versal2 devices.
---
Changes in v3:
-------------
- Introduced below changes in dwc yaml schema.
Changes in v5:
-------------
- Modify mdb_pcie_slcr as constant.
Changes in v6:
-------------
-Modify slcr constant
Changes in v11:
-None
--- Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/pci/snps,dw-pcie.yaml +2 -0
@@ -113,6 +113,8 @@ properties: enum: [ smu, mpu ] - description: Tegra234 aperture enum: [ ecam ] + - description: AMD MDB PCIe slcr region + const: slcr allOf: - contains: const: dbi
Signature · 1 line
2.43.0
PATCH v13 2/3 dt-bindings: PCI: amd-mdb: Add AMD Versal2 MDB PCIe Root Port Bridge
In reply to Thippeswamy HavaligeAdd AMD Versal2 MDB (Multimedia DMA Bridge) PCIe Root Port Bridge.
---
Changes in v2:
-------------
- Modify patch subject.
- Add pcie host bridge reference.
- Modify filename as per compatible string.
- Remove standard PCI properties.
- Modify interrupt controller description.
- Indentation
Changes in v3:
-------------
- Modified SLCR to lower case.
- Add dwc schemas.
- Remove common properties.
- Move additionalProperties below properties.
- Remove ranges property from required properties.
- Drop blank line.
- Modify pci@ to pcie@
Changes in v4:
-------------
- None.
Changes in v5:
-------------
- None.
Changes in v6:
--------------
- Reduce dbi size to 4k.
- update register name to slcr.
Changes in v7:
--------------
- Add reviewed-by
Changes in v10:
--------------
- None
Changes in v11:
---------------
- None
Changes in v12:
---------------
-None
--- .../bindings/pci/amd,versal2-mdb-host.yaml | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/amd,versal2-mdb-host.yaml
Documentation/devicetree/bindings/pci/amd,versal2-mdb-host.yaml new file +121 -0
@@ -0,0 +1,121 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/amd,versal2-mdb-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMD Versal2 MDB(Multimedia DMA Bridge) Host Controller + +maintainers: + - Thippeswamy Havalige <[email protected]> + +allOf: + - $ref: /schemas/pci/pci-host-bridge.yaml# + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: amd,versal2-mdb-host + + reg: + items: + - description: MDB System Level Control and Status Register (SLCR) Base + - description: configuration region + - description: data bus interface + - description: address translation unit register + + reg-names: + items: + - const: slcr + - const: config + - const: dbi + - const: atu + + ranges: + maxItems: 2 + + msi-map: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-map-mask: + items: + - const: 0 + - const: 0 + - const: 0 + - const: 7 + + interrupt-map: + maxItems: 4 + + "#interrupt-cells": + const: 1 + + interrupt-controller: + description: identifies the node as an interrupt controller + type: object + additionalProperties: false + properties: + interrupt-controller: true + + "#address-cells": + const: 0 + + "#interrupt-cells": + const: 1 + + required: + - interrupt-controller + - "#address-cells" + - "#interrupt-cells" + +required: + - reg + - reg-names + - interrupts + - interrupt-map + - interrupt-map-mask + - msi-map + - "#interrupt-cells" + - interrupt-controller + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + pcie@ed931000 { + compatible = "amd,versal2-mdb-host"; + reg = <0x0 0xed931000 0x0 0x2000>, + <0x1000 0x100000 0x0 0xff00000>, + <0x1000 0x0 0x0 0x1000>, + <0x0 0xed860000 0x0 0x2000>; + reg-names = "slcr", "config", "dbi", "atu"; + ranges = <0x2000000 0x00 0xa0000000 0x00 0xa0000000 0x00 0x10000000>, + <0x43000000 0x1100 0x00 0x1100 0x00 0x00 0x1000000>; + interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>; + interrupt-parent = <&gic>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &pcie_intc_0 0>, + <0 0 0 2 &pcie_intc_0 1>, + <0 0 0 3 &pcie_intc_0 2>, + <0 0 0 4 &pcie_intc_0 3>; + msi-map = <0x0 &gic_its 0x00 0x10000>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + device_type = "pci"; + pcie_intc_0: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; + };
Signature · 1 line
2.43.0
PATCH v13 3/3 PCI: amd-mdb: Add AMD MDB Root Port driver
In reply to Thippeswamy HavaligeAdd support for AMD MDB (Multimedia DMA Bridge) IP core as Root Port.
The Versal2 devices include MDB Module. The integrated block for MDB along with the integrated bridge can function as PCIe Root Port controller at Gen5 32-Gb/s operation per lane.
Bridge supports error and legacy interrupts and are handled using platform specific interrupt line in Versal2.
| Reported-by: kernel test robot <[email protected]> | Closes: | https://lore.kernel.org/oe-kbuild-all/202502191741.xrVmEAG4-lkp@intel. | com/
---
changes in v2:
-------------
- Update Gen5 speed in the patch description.
- Modify Kconfig file.
- Update string _leg_ to intx.
- Get platform structure through automic variables.
- Remove _rp_ in function.
Changes in v3:
--------------
-None.
Changes in v4:
--------------
-None.
Changes in v5:
--------------
-None.
Changes in v6:
--------------
- Remove pdev automatic variable.
- Update register name to slcr.
- Fix whitespace.
- remove Spurious extra line.
- Update Legacy to INTx.
- Add space before (SLCR).
- Update menuconfig description.
Changes in v7:
--------------
- None.
Changes in v8:
--------------
- Remove inline keyword.
- Fix indentations.
- Add AMD MDB prefix to interrupt names.
- Remove Kernel doc.
- Fix return types.
- Modify dev_warn to dev_warn_once.
- Add Intx handler & callbacks.
Changes in v10:
---------------
- Add intx assert & deassert macros.
- Move amd_mdb_pcie_init_port function.
- Add kernel doc for error warning messages. Changes in v11:
---------------
- Remove intx deassert macro & generic handler.
- Update Kconfig description.
- Update INTx mask macro to handle only asser bits.
- Move INTx handler.
- Address other review comments.
Changes in v12:
---------------
- ADD TLP_IR_DISABLE_MISC register.
- Modify intx call back function
Changes in v13:
- Add kernel doc for intx_irq
--- drivers/pci/controller/dwc/Kconfig | 11 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-amd-mdb.c | 470 ++++++++++++++++++++++ 3 files changed, 482 insertions(+) create mode 100644 drivers/pci/controller/dwc/pcie-amd-mdb.c
drivers/pci/controller/dwc/Kconfig +11 -0
@@ -27,6 +27,17 @@ config PCIE_AL required only for DT-based platforms. ACPI platforms with the Annapurna Labs PCIe controller don't need to enable this. +config PCIE_AMD_MDB + bool "AMD MDB Versal2 PCIe Host controller" + depends on OF || COMPILE_TEST + depends on PCI && PCI_MSI + select PCIE_DW_HOST + help + Say Y here if you want to enable PCIe controller support on AMD + Versal2 SoCs. The AMD MDB Versal2 PCIe controller is based on + DesignWare IP and therefore the driver re-uses the Designware core + functions to implement the driver. + config PCI_MESON tristate "Amlogic Meson PCIe controller" default m if ARCH_MESON
drivers/pci/controller/dwc/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o +obj-$(CONFIG_PCIE_AMD_MDB) += pcie-amd-mdb.o obj-$(CONFIG_PCIE_BT1) += pcie-bt1.o obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +470 -0
470 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v13 3/3] PCI: amd-mdb: Add AMD MDB Root Port driver
drivers/pci/controller/dwc/pcie-amd-mdb.c line 53
Quoted 12 lines · Thippeswamy Havalige
Add support for AMD MDB (Multimedia DMA Bridge) IP core as Root Port.
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +9
-0+#define AMD_MDB_TLP_IR_STATUS_MISC 0x4C0 +#define AMD_MDB_TLP_IR_MASK_MISC 0x4C4 +#define AMD_MDB_TLP_IR_ENABLE_MISC 0x4C8 +#define AMD_MDB_TLP_IR_DISABLE_MISC 0x4CC + +#define AMD_MDB_TLP_PCIE_INTX_MASK GENMASK(23, 16) + +#define AMD_MDB_PCIE_INTR_INTX_ASSERT (x) BIT((x) * 2) +#define AMD_MDB_PCIE_INTX_BIT (x) (1U << (2 * (x) + AMD_MDB_PCIE_INTR_INTX))
I don't think you need both AMD_MDB_PCIE_INTR_INTX_ASSERT() and AMD_MDB_PCIE_INTX_BIT().
AMD_MDB_PCIE_INTX_BIT() is essentially the same as FIELD_PREP(AMD_MDB_TLP_PCIE_INTX_MASK, AMD_MDB_PCIE_INTR_INTX_ASSERT).
I would just do this:
#define AMD_MDB_PCIE_INTR_INTX(x) BIT((x) * 2)
and in amd_mdb_intx_irq_mask() and amd_mdb_intx_irq_unmask(), do this:
val = FIELD_PREP(AMD_MDB_TLP_PCIE_INTX_MASK,
AMD_MDB_PCIE_INTR_INTX(data->hwirq));Then all the users do FIELD_PREP() or FIELD_GET() at the point of use.
It's a little confusing for dw_pcie_rp_intx_flow() to do the FIELD_GET() there, but amd_mdb_intx_irq_mask() and amd_mdb_intx_irq_unmask() have the equivalent of FIELD_PREP() hidden inside AMD_MDB_PCIE_INTX_BIT().
drivers/pci/controller/dwc/pcie-amd-mdb.c line 94
Quoted 11 lines
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +11
-0+static void amd_mdb_intx_irq_mask (struct irq_data *data) +{ +struct amd_mdb_pcie *pcie =irq_data_get_irq_chip_data (data); +struct dw_pcie *pci = &pcie->pci; +struct dw_pcie_rp *port = &pci->pp; +unsigned long flags; +u32 val; + +raw_spin_lock_irqsave (&port->lock, flags); + val =AMD_MDB_PCIE_INTX_BIT (data->hwirq); +pcie_write (pcie, val,AMD_MDB_TLP_IR_DISABLE_MISC );
I guess AMD_MDB_TLP_IR_DISABLE_MISC and AMD_MDB_TLP_IR_ENABLE_MISC are set up so writing zero bits does nothing, and writing a one bit only masks or unmasks that single interrupt? It's somewhat unusual, so a comment to that effect might be useful.
Quoted 15 lines
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +15
-0+raw_spin_unlock_irqrestore (&port->lock, flags); +} + +static void amd_mdb_intx_irq_unmask (struct irq_data *data) +{ +struct amd_mdb_pcie *pcie =irq_data_get_irq_chip_data (data); +struct dw_pcie *pci = &pcie->pci; +struct dw_pcie_rp *port = &pci->pp; +unsigned long flags; +u32 val; + +raw_spin_lock_irqsave (&port->lock, flags); + val =AMD_MDB_PCIE_INTX_BIT (data->hwirq); +pcie_write (pcie, val,AMD_MDB_TLP_IR_ENABLE_MISC ); +raw_spin_unlock_irqrestore (&port->lock, flags);
drivers/pci/controller/dwc/pcie-amd-mdb.c line 150
Quoted 10 lines
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +9
-0+} +static irqreturn_t dw_pcie_rp_intx_flow (int irq,void *args) +{ +struct amd_mdb_pcie *pcie = args; +unsigned long val; +int i; + + val =FIELD_GET (AMD_MDB_TLP_PCIE_INTX_MASK , + val =pcie_read (pcie,AMD_MDB_TLP_IR_STATUS_MISC ));
The "val = pcie_read()" looks like a useless assignment to val. I would do something like this:
val = pcie_read(pcie, AMD_MDB_TLP_IR_STATUS_MISC);
intx_status = FIELD_GET(AMD_MDB_TLP_PCIE_INTX_MASK, val);
for (i = 0; i < PCI_NUM_INTX; i++) {
if (intx_status & AMD_MDB_PCIE_INTR_INTX(i))
generic_handle_domain_irq(pcie->intx_domain, i);
}Quoted 7 lines
drivers/pci/controller/dwc/pcie-amd-mdb.c new file +7
-0+for (i =0 ; i <PCI_NUM_INTX ; i++) { +if (val &AMD_MDB_PCIE_INTR_INTX_ASSERT (i)) +generic_handle_domain_irq (pcie->intx_domain, i); + } + +return IRQ_HANDLED ; +}