* [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support
@ 2026-11-27 4:35 Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 1/6] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
Add a Snow Bush PCIe SerDes PHY and DesignWare host glue for CS7542.
The combined global-controls prerequisite supplies PCIe gates and resets;
this series contains no separate or duplicate global-control driver.
Prerequisite on Linux v7.4-rc4: the combined clock/reset/pinctrl v4,
posted on 25 November:
https://lore.kernel.org/all/20261125-cs7542-syscon-v4-0-3337bb0d3b48@gmail.com/
Brian's review places the early clock and separately probing reset
providers in that prerequisite. Local v5 error-path corrections are
included in the current integration tests; they keep its PCIe clock/reset
IDs and consumer interface unchanged. Binding review remains ongoing.
Board DTS enablement is separate. Ethernet is not a prerequisite.
The host protects its 512-byte root configuration limit, owns the
combined INTx/MSI lifecycle and reads link status from the application
wrapper. Unused SATA mode, hotplug and suspend remain outside this support.
Before the reset timing change, an Almond+ Linux v7.4-rc4 RAM run passed with
all three Root Ports/endpoints and Root Port MSI enabled after enumeration.
xHCI serviced MSI-X interrupts with three vectors, then forced legacy INTx
with no MSI vectors, then restored MSI-X. Complete host unload/reload,
repeated enumeration, real PCI OF nodes and factory calibration/MAC NVMEM
lookups all passed. Two NE load/unload cycles and external LAN1 traffic
ran alongside the live PCIe hosts without changing their reset bits.
The watchdog automatically returned to the installed firmware; no flash
writes were performed.
The updated host compiled for ARM with reset-controller support enabled
and disabled. Its framework-disabled object has no unresolved reset
symbols. The current reset sequence also passed the error-path tests.
Earlier independent ARM GCC14.2 W=1 vmlinux/modules with PHY/host=m and
COMPILE_TEST=n, full combined multi_v7 built-in/module builds, binding
examples and actual-source config/DBI/probe/Root-Port/MSI tests passed.
Two expected reset-core WARN/-EBUSY traces came from the fixture's
intentional duplicate-exclusive NE reset requests, not PCIe operations.
The fixture did not reset an active NE DMA consumer.
The lock serializes MMIO against the IRQ latch and teardown; it cannot
eliminate a physical link transition before IRQ delivery. Link-loss gating
remains conservative no-retrain policy, not a newly established silicon
requirement for upstream RC configuration. Non-identity MSI bus-window
arithmetic has host-test coverage; the hardware run used this board's
existing windows and unchanged comparator tokens.
Final self-review also exercised the actual MSI/GPIO policy helpers in
12 GCC and Clang ASan/UBSan cases each. The independent ARM build of
vmlinux and modules with host/PHY=m, COMPILE_TEST=n and no platform series
passed again after those fixes. Exact Linux 6.18 ARM W=1 Werror objects
and the combined personal image build pass. An actual normal-image RAM
boot enumerated the three Root Ports and endpoints and reached its root
filesystem with 432844 KiB available to Linux, then the watchdog returned
automatically to unchanged NAND OpenWrt. This boot is not hardware fault
injection or a new non-identity DMA-window test. The two Wi-Fi Root Ports
share one physical PERST# GPIO; independent hotplug is not qualified.
Changes in v3:
- Hold the host reset through PHY preparation. Wait 10 ms before
deasserting it and 10 ms afterwards before accessing the host.
- Drop the PCIe consumer's Kconfig select of RESET_CONTROLLER.
- Balance the PHY reference clock if power-on and its cleanup both fail.
- Put PERST# on the Root Port child; retain three independent hosts and
acquire the board's shared Wi-Fi reset GPIO only once.
- Assert the core before clock/PHY setup and release endpoint PERST#
after Root Port setup, using the standard reset configuration wait.
- Describe MSI addresses as internal PCI bus match tokens, preserve their
tested values and reject overlap with translated PCI memory windows.
- Keep v2 config/DBI/IRQ serialization; describe the no-retrain latch as
conservative software policy, with no physical link-loss race claim.
- Preserve pci=nomsi in post-enumeration setup; an uninitialized receiver
must not be enabled. Skip the optional PERST# lookup when the Root Port
has no reset-gpios, including builds with GPIOLIB disabled.
- Address Kconfig/include ordering, bounded polling constants, error
response helper, block comments, formatting and cleanup labels.
- Move the global binding, clock gates and reset provider into the
independent shared-controls prerequisite; drop former patches 2 and 3.
- Keep only DWC export, PHY, host and their ownership in this series.
- Preserve existing PCIe reset IDs 0..2 and clock IDs 3..5.
- Link to v2: https://patch.msgid.link/20261123-b4-cs7542-pcie-v2-0-f589a9cd0bef@gmail.com
---
Fil Dunsky (6):
PCI: dwc: Export the multiplexed MSI interrupt handler
dt-bindings: phy: Describe CS7542 PCIe SerDes
phy: Add CS7542 PCIe SerDes support
dt-bindings: PCI: Describe the CS7542 host controller
PCI: cs7542: Add CS7542 PCIe host support
MAINTAINERS: Add CS7542 PCIe support
.../bindings/pci/cortina,cs7542-pcie.yaml | 157 +++++
.../bindings/phy/cortina,cs7542-pcie-phy.yaml | 67 +++
MAINTAINERS | 6 +-
drivers/pci/controller/dwc/Kconfig | 12 +
drivers/pci/controller/dwc/Makefile | 1 +
drivers/pci/controller/dwc/pcie-cs7542.c | 658 +++++++++++++++++++++
drivers/pci/controller/dwc/pcie-designware-host.c | 1 +
drivers/phy/Kconfig | 11 +
drivers/phy/Makefile | 2 +
drivers/phy/phy-cs7542-pcie.c | 236 ++++++++
10 files changed, 1150 insertions(+), 1 deletion(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-pcie-224e359c8698
prerequisite-change-id: 20261123-cs7542-syscon-273d545c7af2:v4
prerequisite-patch-id: a9208276c628f8741a807d0e5c5945d4bf211c8a
prerequisite-patch-id: 65d46bb3caaa8518ee561f65d3f603ade396fff9
prerequisite-patch-id: a0ed5fbcfa308b16eaf265371a6697ad0aea6802
prerequisite-patch-id: bb8ffd99cb30e5a0b47881f6ba19a36329d5f4f2
prerequisite-patch-id: 7fbe9405265ef3d1ec62811415a46c0061afd7c8
prerequisite-patch-id: 01ece2c91e080d5cae6af81944159373776484ca
Best regards,
--
Fil Dunsky <filipp.dunsky@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/6] PCI: dwc: Export the multiplexed MSI interrupt handler
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 2/6] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Allow modular host glue with a combined application interrupt to dispatch
the internal MSI receiver without installing a second chained handler.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index bbb02458a..1d076bb62 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -85,6 +85,7 @@ void dw_handle_msi_irq(struct dw_pcie_rp *pp)
generic_handle_demux_domain_irq(pp->msi_irq_domain, irq_off + pos);
}
}
+EXPORT_SYMBOL_GPL(dw_handle_msi_irq);
/* Chained MSI interrupt service routine */
static void dw_chained_msi_isr(struct irq_desc *desc)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/6] dt-bindings: phy: Describe CS7542 PCIe SerDes
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 1/6] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 3/6] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Describe three Snow Bush lanes, their shared status bank, global reset
controls and 24 MHz reference. PCIe is the only supported operating mode.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
.../bindings/phy/cortina,cs7542-pcie-phy.yaml | 67 ++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/cortina,cs7542-pcie-phy.yaml b/Documentation/devicetree/bindings/phy/cortina,cs7542-pcie-phy.yaml
new file mode 100644
index 000000000..9ccde6e05
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/cortina,cs7542-pcie-phy.yaml
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/cortina,cs7542-pcie-phy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cortina Systems CS7542 PCIe SerDes
+
+maintainers:
+ - Fil Dunsky <filipp.dunsky@gmail.com>
+
+description: |
+ Three Snow Bush SerDes lanes shared by PCIe and SATA. Only PCIe mode
+ with a 24 MHz reference is described. The PHY specifier is the lane
+ number, 0 through 2. The status resource contains the shared PHY
+ status registers, with a stride of 0x80 bytes per lane.
+
+properties:
+ compatible:
+ const: cortina,cs7542-pcie-phy
+
+ reg:
+ items:
+ - description: Lane 0 programming registers
+ - description: Lane 1 programming registers
+ - description: Lane 2 programming registers
+ - description: Shared PHY status registers
+
+ reg-names:
+ items:
+ - const: phy0
+ - const: phy1
+ - const: phy2
+ - const: status
+
+ clocks:
+ maxItems: 1
+ description: 24 MHz SerDes reference clock
+
+ cortina,global-syscon:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: Global control syscon providing lane reset and mode selection
+
+ "#phy-cells":
+ const: 1
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - clocks
+ - cortina,global-syscon
+ - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+ - |
+ phy@f00a1000 {
+ compatible = "cortina,cs7542-pcie-phy";
+ reg = <0xf00a1000 0x400>, <0xf00a5000 0x400>,
+ <0xf00a9000 0x400>, <0xf00a0e00 0x180>;
+ reg-names = "phy0", "phy1", "phy2", "status";
+ clocks = <&ref24>;
+ cortina,global-syscon = <&global>;
+ #phy-cells = <1>;
+ };
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/6] phy: Add CS7542 PCIe SerDes support
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 1/6] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 2/6] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 4/6] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Provide per-lane generic PHYs using the vendor 24 MHz programming table
and revision-dependent value. Sequence power and reset through the shared
global regmap and fail on CMU lock timeout with balanced power cleanup.
Use the shared PHY status bank without overlapping PCIe wrapper resources.
Release the reference clock if power-on fails, including when the
power-down register write used for cleanup also fails.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
drivers/phy/Kconfig | 11 ++
drivers/phy/Makefile | 2 +
drivers/phy/phy-cs7542-pcie.c | 236 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 249 insertions(+)
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 105fbe408..77cff94fe 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -204,4 +204,15 @@ source "drivers/phy/tegra/Kconfig"
source "drivers/phy/ti/Kconfig"
source "drivers/phy/xilinx/Kconfig"
+config PHY_CS7542_PCIE
+ tristate "Cortina Systems CS7542 PCIe SerDes"
+ depends on OF && HAS_IOMEM && COMMON_CLK
+ select GENERIC_PHY
+ select MFD_SYSCON
+ help
+ Support the three CS7542 Snow Bush SerDes lanes in PCIe mode
+ with a 24 MHz reference clock. Lane resets share the global syscon.
+ SATA mode and other reference frequencies are not supported.
+ The module is called phy-cs7542-pcie.
+
endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c6dd02003..54df29e74 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -55,3 +55,5 @@ obj-$(CONFIG_GENERIC_PHY) += allwinner/ \
tegra/ \
ti/ \
xilinx/
+
+obj-$(CONFIG_PHY_CS7542_PCIE) += phy-cs7542-pcie.o
diff --git a/drivers/phy/phy-cs7542-pcie.c b/drivers/phy/phy-cs7542-pcie.c
new file mode 100644
index 000000000..71490885e
--- /dev/null
+++ b/drivers/phy/phy-cs7542-pcie.c
@@ -0,0 +1,236 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* CS7542 Snow Bush SerDes, PCIe mode with a 24 MHz reference clock. */
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#define GLOBAL_JTAG_ID 0x00
+#define GLOBAL_PHY_CONTROL 0x14
+#define PHY_REFCLK_MASK(p) (3U << ((p) * 2))
+#define PHY_REFCLK_24MHZ(p) (2U << ((p) * 2))
+#define PHY_PD(p) BIT(8 + (p))
+#define PHY_CMU_RESETN(p) BIT(16 + (p) * 4)
+#define PHY_LN0_RESETN(p) BIT(17 + (p) * 4)
+#define PHY_POR_N(p) BIT(19 + (p) * 4)
+#define PHY_CMU_OK BIT(18)
+#define PHY_STATUS_STRIDE 0x80
+#define SNOW_COM_REG0 0x00
+#define SNOW_REG0_CFG 0x00090006
+#define SNOW_REG0_AHB_RESETN BIT(0)
+#define SNOW_REV_REG 96
+#define SNOW_REV_REG_A0 0x5e082e00
+#define SNOW_REV_REG_A1 0x5e080600
+#define SNOW_COM_LANE_REG0 0xc8
+#define SNOW_LANE_REG0_CFG 0x400290c0
+#define SNOW_LANE_REG0_MASTER_RESETN BIT(1)
+#define CS7542_PORTS 3
+
+struct cs7542_serdes;
+struct cs7542_lane {
+ struct cs7542_serdes *serdes;
+ void __iomem *base;
+ struct phy *phy;
+ unsigned int id;
+};
+
+struct cs7542_serdes {
+ struct device *dev;
+ struct regmap *global;
+ void __iomem *status;
+ struct clk *ref;
+ struct cs7542_lane lanes[CS7542_PORTS];
+ u32 revision_value;
+};
+
+struct snow_reg {
+ u16 off;
+ u32 val;
+};
+
+static const struct snow_reg snow_phy_24mhz[] = {
+ { 0, SNOW_REG0_CFG }, { 4, 0x000e0960 }, { 32, 0x68a00000 },
+ { 44, 0x50040000 }, { 48, 0x40250270 }, { 52, 0x00004001 },
+ { 100, 0xf0914200 }, { 104, 0x4c0c9048 }, { 108, 0x00000373 },
+ { 124, 0x04841000 }, { 128, 0x000000e0 }, { 132, 0x04000023 },
+ { 136, 0x68001038 }, { 140, 0x0d181ea2 }, { 144, 0x0000000c },
+ { 196, 0x0f600000 }, { 200, SNOW_LANE_REG0_CFG }, { 204, 0x0000003c },
+ { 208, 0xc68b8300 }, { 212, 0x98280301 }, { 216, 0xe1782819 },
+ { 220, 0x00f410f0 }, { 232, 0xa0a0a000 }, { 236, 0xa0a0a0a0 },
+ { 240, 0x9fc00068 }, { 244, 0x00000001 }, { 248, 0x00000000 },
+ { 252, 0xd07e4130 }, { 256, 0x935285cc }, { 260, 0xb0dd49e0 },
+ { 264, 0x0000020b }, { 300, 0xd8000000 }, { 304, 0x0001ff1a },
+ { 308, 0xf0000000 }, { 312, 0xffffffff }, { 316, 0x3fc3c21c },
+ { 320, 0x0000000a }, { 324, 0x00f80000 },
+};
+
+static int cs7542_phy_power_off(struct phy *phy)
+{
+ struct cs7542_lane *lane = phy_get_drvdata(phy);
+ unsigned int p = lane->id;
+ u32 mask = PHY_PD(p) | PHY_CMU_RESETN(p) | PHY_LN0_RESETN(p) | PHY_POR_N(p);
+ int ret;
+
+ ret = regmap_update_bits(lane->serdes->global, GLOBAL_PHY_CONTROL, mask, PHY_PD(p));
+ if (ret)
+ return ret;
+ clk_disable_unprepare(lane->serdes->ref);
+ return ret;
+}
+
+static int cs7542_phy_power_on(struct phy *phy)
+{
+ struct cs7542_lane *lane = phy_get_drvdata(phy);
+ struct cs7542_serdes *sd = lane->serdes;
+ unsigned int p = lane->id;
+ u32 mask, value;
+ int ret, i;
+
+ ret = clk_prepare_enable(sd->ref);
+ if (ret)
+ return ret;
+ mask = PHY_PD(p) | PHY_CMU_RESETN(p) | PHY_LN0_RESETN(p) | PHY_POR_N(p) |
+ PHY_REFCLK_MASK(p);
+ ret = regmap_update_bits(sd->global, GLOBAL_PHY_CONTROL, mask,
+ PHY_PD(p) | PHY_REFCLK_24MHZ(p));
+ if (ret)
+ goto power_off;
+ msleep(100);
+ ret = regmap_update_bits(sd->global, GLOBAL_PHY_CONTROL, PHY_PD(p) | PHY_POR_N(p),
+ PHY_POR_N(p));
+ if (ret)
+ goto power_off;
+ usleep_range(10, 20);
+ for (i = 0; i < ARRAY_SIZE(snow_phy_24mhz); i++) {
+ if (snow_phy_24mhz[i].off == SNOW_REV_REG + 4)
+ writel(sd->revision_value, lane->base + SNOW_REV_REG);
+ writel(snow_phy_24mhz[i].val, lane->base + snow_phy_24mhz[i].off);
+ }
+ writel(SNOW_REG0_CFG | SNOW_REG0_AHB_RESETN, lane->base + SNOW_COM_REG0);
+ ret = regmap_update_bits(sd->global, GLOBAL_PHY_CONTROL, PHY_CMU_RESETN(p),
+ PHY_CMU_RESETN(p));
+ if (ret)
+ goto power_off;
+ ret = readl_poll_timeout(sd->status + p * PHY_STATUS_STRIDE, value,
+ value & PHY_CMU_OK, 100, 100000);
+ if (ret) {
+ dev_err(sd->dev, "lane %u CMU did not lock\n", p);
+ goto power_off;
+ }
+ writel(SNOW_LANE_REG0_CFG | SNOW_LANE_REG0_MASTER_RESETN,
+ lane->base + SNOW_COM_LANE_REG0);
+ ret = regmap_update_bits(sd->global, GLOBAL_PHY_CONTROL, PHY_LN0_RESETN(p),
+ PHY_LN0_RESETN(p));
+ if (ret)
+ goto power_off;
+ msleep(100);
+ return 0;
+
+power_off:
+ /* Failed power_on has no generic PHY power reference to retain. */
+ if (cs7542_phy_power_off(phy))
+ clk_disable_unprepare(sd->ref);
+ return ret;
+}
+
+static int cs7542_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+ return mode == PHY_MODE_PCIE && !submode ? 0 : -EINVAL;
+}
+
+static const struct phy_ops cs7542_phy_ops = {
+ .power_on = cs7542_phy_power_on,
+ .power_off = cs7542_phy_power_off,
+ .set_mode = cs7542_phy_set_mode,
+ .owner = THIS_MODULE,
+};
+
+static struct phy *cs7542_phy_xlate(struct device *dev, const struct of_phandle_args *args)
+{
+ struct cs7542_serdes *sd = dev_get_drvdata(dev);
+
+ if (args->args_count != 1 || args->args[0] >= CS7542_PORTS)
+ return ERR_PTR(-EINVAL);
+ return sd->lanes[args->args[0]].phy;
+}
+
+static int cs7542_phy_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct phy_provider *provider;
+ struct cs7542_serdes *sd;
+ unsigned int id;
+ int ret, i;
+
+ sd = devm_kzalloc(dev, sizeof(*sd), GFP_KERNEL);
+ if (!sd)
+ return -ENOMEM;
+ sd->dev = dev;
+ sd->global = syscon_regmap_lookup_by_phandle(dev->of_node, "cortina,global-syscon");
+ if (IS_ERR(sd->global))
+ return dev_err_probe(dev, PTR_ERR(sd->global), "global register map\n");
+ sd->ref = devm_clk_get(dev, NULL);
+ if (IS_ERR(sd->ref))
+ return dev_err_probe(dev, PTR_ERR(sd->ref), "reference clock\n");
+ if (clk_get_rate(sd->ref) != 24000000)
+ return dev_err_probe(dev, -EINVAL, "only 24 MHz reference supported\n");
+ ret = regmap_read(sd->global, GLOBAL_JTAG_ID, &id);
+ if (ret)
+ return ret;
+ switch (FIELD_GET(GENMASK(15, 12), id)) {
+ case 0:
+ case 1:
+ sd->revision_value = SNOW_REV_REG_A0;
+ break;
+ case 8:
+ case 9:
+ sd->revision_value = SNOW_REV_REG_A1;
+ break;
+ default:
+ return dev_err_probe(dev, -ENODEV, "unsupported silicon revision %#x\n", id);
+ }
+ sd->status = devm_platform_ioremap_resource(pdev, CS7542_PORTS);
+ if (IS_ERR(sd->status))
+ return PTR_ERR(sd->status);
+ for (i = 0; i < CS7542_PORTS; i++) {
+ struct cs7542_lane *lane = &sd->lanes[i];
+
+ lane->id = i;
+ lane->serdes = sd;
+ lane->base = devm_platform_ioremap_resource(pdev, i);
+ if (IS_ERR(lane->base))
+ return PTR_ERR(lane->base);
+ lane->phy = devm_phy_create(dev, NULL, &cs7542_phy_ops);
+ if (IS_ERR(lane->phy))
+ return PTR_ERR(lane->phy);
+ phy_set_drvdata(lane->phy, lane);
+ }
+ platform_set_drvdata(pdev, sd);
+ provider = devm_of_phy_provider_register(dev, cs7542_phy_xlate);
+ return PTR_ERR_OR_ZERO(provider);
+}
+
+static const struct of_device_id cs7542_phy_match[] = {
+ { .compatible = "cortina,cs7542-pcie-phy" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, cs7542_phy_match);
+
+static struct platform_driver cs7542_phy_driver = {
+ .probe = cs7542_phy_probe,
+ .driver = {
+ .name = "cs7542-pcie-phy",
+ .of_match_table = cs7542_phy_match,
+ },
+};
+module_platform_driver(cs7542_phy_driver);
+
+MODULE_DESCRIPTION("Cortina Systems CS7542 PCIe SerDes");
+MODULE_LICENSE("GPL");
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/6] dt-bindings: PCI: Describe the CS7542 host controller
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
` (2 preceding siblings ...)
2026-11-27 4:35 ` [PATCH v3 3/6] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 5/6] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Describe the DesignWare host wrapper, clock/reset/PHY consumers, combined
interrupt and INTx domain. Document the root configuration access limit.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
.../bindings/pci/cortina,cs7542-pcie.yaml | 157 +++++++++++++++++++++
1 file changed, 157 insertions(+)
diff --git a/Documentation/devicetree/bindings/pci/cortina,cs7542-pcie.yaml b/Documentation/devicetree/bindings/pci/cortina,cs7542-pcie.yaml
new file mode 100644
index 000000000..64cd7c744
--- /dev/null
+++ b/Documentation/devicetree/bindings/pci/cortina,cs7542-pcie.yaml
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pci/cortina,cs7542-pcie.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Cortina Systems CS7542 PCIe host controller
+
+maintainers:
+ - Fil Dunsky <filipp.dunsky@gmail.com>
+
+description: |
+ DesignWare host with a Cortina application wrapper. A single interrupt
+ multiplexes four INTx lines, the internal MSI receiver and link errors.
+ Root-port configuration is accessible only below offset 0x200; the
+ DesignWare private register bank starts at offset 0x700.
+
+allOf:
+ - $ref: /schemas/pci/snps,dw-pcie.yaml#
+
+properties:
+ compatible:
+ const: cortina,cs7542-pcie
+
+ reg:
+ items:
+ - description: DBI registers including the viewport iATU
+ - description: Downstream configuration window
+ - description: Application wrapper registers
+
+ reg-names:
+ items:
+ - const: dbi
+ - const: config
+ - const: app
+
+ clocks:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ interrupt-names:
+ const: msi
+
+ resets:
+ maxItems: 1
+
+ phys:
+ maxItems: 1
+
+ phy-names:
+ const: pcie
+
+ num-lanes:
+ const: 1
+
+ reset-gpios: false
+
+ interrupt-controller:
+ type: object
+ additionalProperties: false
+ properties:
+ "#address-cells":
+ const: 0
+ "#interrupt-cells":
+ const: 1
+ interrupt-controller: true
+ required:
+ - "#address-cells"
+ - "#interrupt-cells"
+ - interrupt-controller
+
+patternProperties:
+ "^pcie@[0-9a-f]+,[0-7]$":
+ type: object
+ $ref: /schemas/pci/pci-pci-bridge.yaml#
+ additionalProperties: true
+ description: |
+ The single Root Port of this controller. Endpoint PERST# belongs to
+ this port, rather than the host bridge.
+ properties:
+ reset-gpios:
+ maxItems: 1
+ description: Optional active-low endpoint PERST#
+ required:
+ - compatible
+ - reg
+ - device_type
+ - '#address-cells'
+ - '#size-cells'
+ - ranges
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - clocks
+ - interrupts
+ - interrupt-names
+ - resets
+ - phys
+ - phy-names
+ - num-lanes
+ - pcie@0,0
+ - interrupt-controller
+ - interrupt-map
+ - interrupt-map-mask
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/cortina,cs7542-clock.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/reset/cortina,cs7542-reset.h>
+
+ pcie@80000000 {
+ compatible = "cortina,cs7542-pcie";
+ reg = <0x80000000 0x1000>, <0x80001000 0x1000>,
+ <0xf00a0000 0x100>;
+ reg-names = "dbi", "config", "app";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ device_type = "pci";
+ bus-range = <0 0xff>;
+ num-lanes = <1>;
+ ranges = <0x82000000 0 0x80200000 0x80200000 0 0x1fe00000>;
+ clocks = <&global CS7542_CLK_PCIE0>;
+ interrupt-parent = <&gic>;
+ interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "msi";
+ resets = <&global CS7542_RESET_PCIE0>;
+ phys = <&serdes 0>;
+ phy-names = "pcie";
+ #interrupt-cells = <1>;
+ interrupt-map-mask = <0 0 0 7>;
+ interrupt-map = <0 0 0 1 &pcie_intc 1>,
+ <0 0 0 2 &pcie_intc 2>,
+ <0 0 0 3 &pcie_intc 3>,
+ <0 0 0 4 &pcie_intc 4>;
+
+ pcie@0,0 {
+ compatible = "pciclass,0604";
+ reg = <0 0 0 0 0>;
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+ };
+
+ pcie_intc: interrupt-controller {
+ #address-cells = <0>;
+ #interrupt-cells = <1>;
+ interrupt-controller;
+ };
+ };
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 5/6] PCI: cs7542: Add CS7542 PCIe host support
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
` (3 preceding siblings ...)
2026-11-27 4:35 ` [PATCH v3 4/6] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 6/6] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
2026-11-27 4:46 ` [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support sashiko-bot
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Add DesignWare host glue consuming separate clock, reset and PHY
providers. Use live link status and stop previous training before
enumeration. Finish endpoint teardown before draining the shared IRQ and
freeing MSI domains. Dispatch enabled INTx/MSI sources through one
application interrupt and use its MSI target window.
Prevent root configuration accesses at and above 0x200, including direct
DesignWare DBI reads, while preserving the private CSR bank and separate
iATU callback base. Unwind power and IRQ domains on failure and removal.
Read live link/LTSSM state through the application wrapper. After link
loss, block configuration and DBI accesses until controller reset and
reprobe.
Hold the controller reset throughout PHY power-up. After the PHY is
ready, wait 10 ms before releasing the reset and another 10 ms before
accessing the host registers. The host uses the reset consumer API.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
drivers/pci/controller/dwc/Kconfig | 12 +
drivers/pci/controller/dwc/Makefile | 1 +
drivers/pci/controller/dwc/pcie-cs7542.c | 658 +++++++++++++++++++++++++++++++
3 files changed, 671 insertions(+)
diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
index 0a0d56fcf..a9b489801 100644
--- a/drivers/pci/controller/dwc/Kconfig
+++ b/drivers/pci/controller/dwc/Kconfig
@@ -95,6 +95,17 @@ config PCIE_ARTPEC6_EP
Enables support for the PCIe controller in the ARTPEC-6 SoC to work in
endpoint mode. This uses the DesignWare core.
+config PCIE_CS7542
+ tristate "Cortina Systems CS7542 PCIe controller"
+ depends on OF && HAS_IOMEM && PCI_MSI && COMMON_CLK
+ select PCIE_DW_HOST
+ select GENERIC_PHY
+ help
+ Enable the DesignWare PCIe host controllers on Cortina CS7542.
+ The global clock/reset provider and a generic PHY are required.
+ The application interrupt handles both legacy INTx and MSI.
+ The module is called pcie-cs7542.
+
config PCIE_ESWIN
tristate "ESWIN PCIe controller"
depends on ARCH_ESWIN || COMPILE_TEST
@@ -577,4 +588,5 @@ config PCIE_ULTRARISC
By default, this symbol is enabled when ARCH_ULTRARISC is active,
requiring no further configuration on that platform.
+
endmenu
diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile
index d4f88cfc6..185a9fa43 100644
--- a/drivers/pci/controller/dwc/Makefile
+++ b/drivers/pci/controller/dwc/Makefile
@@ -6,6 +6,7 @@ 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_ANDES_QILAI) += pcie-andes-qilai.o
+obj-$(CONFIG_PCIE_CS7542) += pcie-cs7542.o
obj-$(CONFIG_PCIE_ESWIN) += pcie-eswin.o
obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o
obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
diff --git a/drivers/pci/controller/dwc/pcie-cs7542.c b/drivers/pci/controller/dwc/pcie-cs7542.c
new file mode 100644
index 000000000..759ba1f52
--- /dev/null
+++ b/drivers/pci/controller/dwc/pcie-cs7542.c
@@ -0,0 +1,658 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <linux/irqchip/chained_irq.h>
+#include <linux/irqdomain.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
+#include <linux/of_pci.h>
+#include <linux/pci.h>
+#include <linux/phy/phy.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+#include <linux/resource.h>
+
+#include "../../pci.h"
+
+#include "pcie-designware.h"
+
+#define APP_INT_STATUS 0x00
+#define APP_INT_ENABLE 0x04
+#define APP_CORE_CONFIG 0x1c
+#define APP_PM_STATUS 0x20
+#define APP_LINK_ACTIVE BIT(18)
+#define APP_LTSSM_STATE GENMASK(9, 4)
+#define APP_CFG_START 0x80
+#define APP_CFG_END 0x84
+
+#define INT_INTX_ASSERT(x) BIT((x) * 2)
+#define INT_INTX_ASSERT_MASK (BIT(0) | BIT(2) | BIT(4) | BIT(6))
+#define INT_MSI BIT(8)
+#define INT_LINK_UP BIT(9)
+#define INT_RADM_NONFATAL_ERR BIT(12)
+#define INT_RADM_FATAL_ERR BIT(13)
+#define INT_GM_COMPOSER_ERR BIT(16)
+#define INT_RADMX_COMPOSER_ERR BIT(17)
+#define INT_ELASTIC_OVF BIT(18)
+#define INT_ELASTIC_UNF BIT(19)
+#define INT_LINK_DOWN BIT(22)
+#define INT_ERR_MASK (INT_RADM_NONFATAL_ERR | INT_RADM_FATAL_ERR | \
+ INT_GM_COMPOSER_ERR | \
+ INT_RADMX_COMPOSER_ERR | \
+ INT_ELASTIC_OVF | INT_ELASTIC_UNF | \
+ INT_LINK_DOWN)
+
+#define CORE_CFG_LTSSM_EN BIT(0)
+#define CORE_CFG_AXI_UR_MASK BIT(5)
+
+#define APP_PORT_STRIDE 0x400
+#define APP_PHYS_BASE 0xF00A0000
+#define APP_CFG_WINDOW_LEN 0x1000
+#define APP_MSI_BUS_BASE 0xf00a00c0
+#define APP_CFG_POLL_US 10
+#define APP_CFG_TIMEOUT_US 10000
+#define RC_CFG_LIMIT 0x200
+#define DWC_PRIVATE_REG_BASE 0x700
+
+struct cortina_pcie_port {
+ struct gpio_desc *perst;
+};
+
+struct cortina_pcie {
+ struct dw_pcie pci;
+ void __iomem *app;
+ struct clk *clk;
+ struct phy *phy;
+ struct reset_control *reset;
+ struct cortina_pcie_port port;
+ int irq;
+ bool msi_ready;
+ bool link_lost;
+ struct irq_domain *intx_domain;
+ raw_spinlock_t lock;
+ resource_size_t dbi_phys;
+ int index;
+};
+
+#define to_cortina_pcie(x) container_of((x), struct cortina_pcie, pci)
+
+static int cortina_pcie_port_init(struct cortina_pcie *cp)
+{
+ u32 value;
+ int ret;
+
+ writel(cp->dbi_phys, cp->app + APP_CFG_START);
+ writel(cp->dbi_phys + APP_CFG_WINDOW_LEN - 1, cp->app + APP_CFG_END);
+ ret = readl_poll_timeout(cp->app + APP_CFG_END, value,
+ value == cp->dbi_phys + APP_CFG_WINDOW_LEN - 1,
+ APP_CFG_POLL_US, APP_CFG_TIMEOUT_US);
+ if (ret)
+ return ret;
+ writel(0, cp->app + APP_INT_ENABLE);
+ writel(readl(cp->app + APP_INT_STATUS), cp->app + APP_INT_STATUS);
+ return 0;
+}
+
+/* APP remains accessible after link loss, unlike the DBI port debug bank. */
+static bool cortina_pcie_link_up(struct dw_pcie *pci)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+
+ return !READ_ONCE(cp->link_lost) &&
+ !!(readl(cp->app + APP_PM_STATUS) & APP_LINK_ACTIVE);
+}
+
+static enum dw_pcie_ltssm cortina_pcie_get_ltssm(struct dw_pcie *pci)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+
+ return FIELD_GET(APP_LTSSM_STATE, readl(cp->app + APP_PM_STATUS));
+}
+
+static int cortina_pcie_start_link(struct dw_pcie *pci)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ u32 value;
+
+ /* DesignWare calls this after programming the Root Port. */
+ gpiod_set_value_cansleep(cp->port.perst, 0);
+ msleep(PCIE_RESET_CONFIG_WAIT_MS);
+
+ value = readl(cp->app + APP_CORE_CONFIG);
+ value |= CORE_CFG_LTSSM_EN | CORE_CFG_AXI_UR_MASK;
+ writel(value, cp->app + APP_CORE_CONFIG);
+ return 0;
+}
+
+static void cortina_pcie_stop_link(struct dw_pcie *pci)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ u32 value = readl(cp->app + APP_CORE_CONFIG);
+
+ writel(value & ~CORE_CFG_LTSSM_EN, cp->app + APP_CORE_CONFIG);
+}
+
+static void cortina_pcie_irq_handler(struct irq_desc *desc)
+{
+ struct cortina_pcie *cp = irq_desc_get_handler_data(desc);
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+ u32 status, clear;
+ int i;
+
+ chained_irq_enter(chip, desc);
+
+ status = readl(cp->app + APP_INT_STATUS);
+ status &= readl(cp->app + APP_INT_ENABLE);
+ clear = status & ~INT_LINK_UP;
+ if (status & INT_LINK_DOWN)
+ clear |= INT_LINK_UP;
+ writel(clear, cp->app + APP_INT_STATUS);
+
+ if (status & INT_LINK_DOWN) {
+ /* No in-place link recovery; reject MMIO until reprobe. */
+ raw_spin_lock(&cp->lock);
+ WRITE_ONCE(cp->link_lost, true);
+ writel(0, cp->app + APP_INT_ENABLE);
+ raw_spin_unlock(&cp->lock);
+ dev_warn_ratelimited(cp->pci.dev, "link lost; controller reprobe required\n");
+ goto out;
+ }
+
+ if (status & INT_ERR_MASK)
+ dev_err_ratelimited(cp->pci.dev, "port %d: PCIe error, status %#x\n",
+ cp->index, status);
+
+ for (i = 0; i < PCI_NUM_INTX; i++)
+ if (status & INT_INTX_ASSERT(i))
+ generic_handle_domain_irq(cp->intx_domain, i);
+ if ((status & INT_MSI) && cp->msi_ready)
+ dw_handle_msi_irq(&cp->pci.pp);
+
+out:
+ chained_irq_exit(chip, desc);
+}
+
+static void cortina_intx_mask(struct irq_data *d)
+{
+ struct cortina_pcie *cp = irq_data_get_irq_chip_data(d);
+ u32 bit = INT_INTX_ASSERT(d->hwirq);
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ writel(readl(cp->app + APP_INT_ENABLE) & ~bit,
+ cp->app + APP_INT_ENABLE);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+static void cortina_intx_unmask(struct irq_data *d)
+{
+ struct cortina_pcie *cp = irq_data_get_irq_chip_data(d);
+ u32 bit = INT_INTX_ASSERT(d->hwirq);
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ /* Do not undo link-loss or teardown masking from an INTx callback. */
+ if (!cp->link_lost)
+ writel(readl(cp->app + APP_INT_ENABLE) | bit,
+ cp->app + APP_INT_ENABLE);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+static struct irq_chip cortina_intx_chip = {
+ .name = "cortina-INTx",
+ .irq_mask = cortina_intx_mask,
+ .irq_unmask = cortina_intx_unmask,
+};
+
+static int cortina_pcie_intx_map(struct irq_domain *domain, unsigned int irq,
+ irq_hw_number_t hwirq)
+{
+ irq_set_chip_and_handler(irq, &cortina_intx_chip, handle_simple_irq);
+ irq_set_chip_data(irq, domain->host_data);
+ return 0;
+}
+
+static const struct irq_domain_ops cortina_intx_domain_ops = {
+ .map = cortina_pcie_intx_map,
+ .xlate = pci_irqd_intx_xlate,
+};
+
+static int cortina_pcie_init_irq_domain(struct cortina_pcie *cp)
+{
+ struct device *dev = cp->pci.dev;
+ struct device_node *intc;
+ struct fwnode_handle *fwnode;
+
+ intc = of_get_child_by_name(dev->of_node, "interrupt-controller");
+ if (!intc)
+ return dev_err_probe(dev, -ENODEV, "no interrupt-controller child\n");
+
+ fwnode = of_fwnode_handle(intc);
+ cp->intx_domain = irq_domain_create_linear(fwnode, PCI_NUM_INTX,
+ &cortina_intx_domain_ops, cp);
+ of_node_put(intc);
+ if (!cp->intx_domain)
+ return dev_err_probe(dev, -ENOMEM, "cannot create INTx domain\n");
+ return 0;
+}
+
+static int cortina_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn,
+ int where, int size, u32 *val)
+{
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ unsigned long flags;
+ int ret;
+
+ PCI_SET_ERROR_RESPONSE(val);
+ if (where < 0 || (size != 1 && size != 2 && size != 4) ||
+ (where & (size - 1)))
+ return PCIBIOS_BAD_REGISTER_NUMBER;
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ if (cp->link_lost) {
+ ret = PCIBIOS_DEVICE_NOT_FOUND;
+ } else if (where >= RC_CFG_LIMIT || size > RC_CFG_LIMIT - where) {
+ *val = 0;
+ ret = PCIBIOS_SUCCESSFUL;
+ } else {
+ ret = pci_generic_config_read(bus, devfn, where, size, val);
+ }
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+ return ret;
+}
+
+static int cortina_pcie_wr_own_conf(struct pci_bus *bus, unsigned int devfn,
+ int where, int size, u32 val)
+{
+ struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata);
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ unsigned long flags;
+ int ret;
+
+ if (where < 0 || (size != 1 && size != 2 && size != 4) ||
+ (where & (size - 1)))
+ return PCIBIOS_BAD_REGISTER_NUMBER;
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ if (cp->link_lost)
+ ret = PCIBIOS_DEVICE_NOT_FOUND;
+ else if (where >= RC_CFG_LIMIT || size > RC_CFG_LIMIT - where)
+ ret = PCIBIOS_SUCCESSFUL;
+ else
+ ret = pci_generic_config_write(bus, devfn, where, size, val);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+ return ret;
+}
+
+static struct pci_ops cortina_own_pci_ops = {
+ .map_bus = dw_pcie_own_conf_map_bus,
+ .read = cortina_pcie_rd_own_conf,
+ .write = cortina_pcie_wr_own_conf,
+};
+
+static int cortina_pcie_host_init(struct dw_pcie_rp *pp)
+{
+ pp->bridge->ops = &cortina_own_pci_ops;
+ pp->keep_rp_msi_en = true;
+ return 0;
+}
+
+static void cortina_pcie_host_post_init(struct dw_pcie_rp *pp)
+{
+ struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ u8 cap;
+ u16 flags;
+
+ /* pci=nomsi skips receiver initialization; preserve that policy. */
+ if (!cp->msi_ready)
+ return;
+
+ cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI);
+ /* PCI enumeration clears MSI enable while initializing capabilities. */
+ if (cap) {
+ flags = dw_pcie_readw_dbi(pci, cap + PCI_MSI_FLAGS);
+ dw_pcie_writew_dbi(pci, cap + PCI_MSI_FLAGS,
+ flags | PCI_MSI_FLAGS_ENABLE);
+ }
+}
+
+static int cortina_pcie_msi_init(struct dw_pcie_rp *pp)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(to_dw_pcie_from_pp(pp));
+ struct resource_entry *win;
+ u64 msi_addr = APP_MSI_BUS_BASE + cp->index * APP_PORT_STRIDE;
+ u32 ctrl, offset;
+ int ret;
+
+ /*
+ * iMSI-RX matches the PCI bus address before AXI translation. Keep the
+ * vendor-reserved bus token; it is not a CPU/DMA destination address.
+ */
+ resource_list_for_each_entry(win, &pp->bridge->windows) {
+ if (resource_type(win->res) == IORESOURCE_MEM &&
+ msi_addr >= win->res->start - win->offset &&
+ msi_addr <= win->res->end - win->offset)
+ return dev_err_probe(cp->pci.dev, -EINVAL,
+ "MSI token overlaps a PCI memory window\n");
+ }
+
+ /* The application IRQ multiplexes MSI and INTx; chain it once. */
+ pp->msi_irq[0] = -ENODEV;
+ ret = dw_pcie_msi_host_init(pp);
+ if (ret)
+ return ret;
+
+ pp->msi_data = msi_addr;
+ /* This custom hook owns setup and teardown of the shared receiver. */
+ for (ctrl = 0; ctrl < pp->num_vectors / MAX_MSI_IRQS_PER_CTRL; ctrl++) {
+ offset = ctrl * MSI_REG_CTRL_BLOCK_SIZE;
+ dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_INTR0_MASK + offset,
+ pp->irq_mask[ctrl]);
+ dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_INTR0_ENABLE + offset,
+ ~0);
+ }
+ dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_ADDR_LO, lower_32_bits(msi_addr));
+ dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_ADDR_HI, upper_32_bits(msi_addr));
+ cp->msi_ready = true;
+ return 0;
+}
+
+static void cortina_pcie_quiesce(struct cortina_pcie *cp)
+{
+ unsigned long flags;
+
+ /* Serialize with config/DBI MMIO and prevent interrupt re-enables. */
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ WRITE_ONCE(cp->link_lost, true);
+ writel(0, cp->app + APP_INT_ENABLE);
+ readl(cp->app + APP_INT_ENABLE);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+ /* The custom chained handler can still be dispatching MSI or INTx. */
+ synchronize_irq(cp->irq);
+}
+
+static void cortina_pcie_remove_irq_domain(struct cortina_pcie *cp)
+{
+ unsigned int i;
+
+ irq_set_chained_handler_and_data(cp->irq, NULL, NULL);
+ synchronize_irq(cp->irq);
+ for (i = 0; i < PCI_NUM_INTX; i++)
+ irq_dispose_mapping(irq_find_mapping(cp->intx_domain, i));
+ irq_domain_remove(cp->intx_domain);
+}
+
+static void cortina_pcie_host_deinit(struct dw_pcie_rp *pp)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(to_dw_pcie_from_pp(pp));
+
+ /* Endpoints have stopped; drain the shared IRQ before freeing domains. */
+ cortina_pcie_quiesce(cp);
+ if (cp->msi_ready) {
+ cp->msi_ready = false;
+ dw_pcie_free_msi(pp);
+ pp->msi_irq_domain = NULL;
+ }
+}
+
+static const struct dw_pcie_host_ops cortina_pcie_host_ops = {
+ .init = cortina_pcie_host_init,
+ .post_init = cortina_pcie_host_post_init,
+ .deinit = cortina_pcie_host_deinit,
+ .msi_init = cortina_pcie_msi_init,
+};
+
+/*
+ * Standard RC configuration above 512 bytes wedges the CS7542 bus.
+ * The DesignWare private register bank at 0x700 remains accessible.
+ * The lock serializes MMIO against the link-loss IRQ latch, not against
+ * physical link loss itself. The latch is a conservative no-retrain
+ * policy, not evidence that the RC requires a live downstream link.
+ */
+static u32 cortina_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base,
+ u32 reg, size_t size)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ unsigned long flags;
+ u32 value = 0;
+
+ /* Zero also makes the iATU enable poll fail after link loss. */
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ if (!cp->link_lost &&
+ !(base == pci->dbi_base && reg < DWC_PRIVATE_REG_BASE &&
+ reg + size > RC_CFG_LIMIT))
+ dw_pcie_read(base + reg, size, &value);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+ return value;
+}
+
+static void cortina_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base,
+ u32 reg, size_t size, u32 value)
+{
+ struct cortina_pcie *cp = to_cortina_pcie(pci);
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&cp->lock, flags);
+ if (!cp->link_lost &&
+ !(base == pci->dbi_base && reg < DWC_PRIVATE_REG_BASE &&
+ reg + size > RC_CFG_LIMIT))
+ dw_pcie_write(base + reg, size, value);
+ raw_spin_unlock_irqrestore(&cp->lock, flags);
+}
+
+static const struct dw_pcie_ops cortina_dw_pcie_ops = {
+ .read_dbi = cortina_pcie_read_dbi,
+ .write_dbi = cortina_pcie_write_dbi,
+ .link_up = cortina_pcie_link_up,
+ .get_ltssm = cortina_pcie_get_ltssm,
+ .start_link = cortina_pcie_start_link,
+ .stop_link = cortina_pcie_stop_link,
+};
+
+static void cortina_pcie_power_off(struct cortina_pcie *cp)
+{
+ gpiod_set_value_cansleep(cp->port.perst, 1);
+ reset_control_assert(cp->reset);
+ phy_power_off(cp->phy);
+ phy_exit(cp->phy);
+ clk_disable_unprepare(cp->clk);
+}
+
+static int cortina_pcie_parse_port(struct cortina_pcie *cp)
+{
+ struct device *dev = cp->pci.dev;
+ struct gpio_desc *perst;
+ struct fwnode_handle *fwnode;
+ bool found = false;
+
+ /* CS7542 has one Root Port per controller; keep PERST# per port. */
+ for_each_available_child_of_node_scoped(dev->of_node, node) {
+ if (!of_device_is_compatible(node, "pciclass,0604"))
+ continue;
+ if (found || of_pci_get_devfn(node) != 0)
+ return dev_err_probe(dev, -EINVAL,
+ "expected one Root Port at devfn 0\n");
+ found = true;
+ /* A port without PERST# must also work with GPIOLIB disabled. */
+ if (!of_find_property(node, "reset-gpios", NULL))
+ continue;
+
+ fwnode = of_fwnode_handle(node);
+ perst = devm_fwnode_gpiod_get(dev, fwnode, "reset",
+ GPIOD_OUT_HIGH, "PERST#");
+ if (IS_ERR(perst)) {
+ if (PTR_ERR(perst) != -ENOENT)
+ return dev_err_probe(dev,
+ PTR_ERR(perst),
+ "PERST# GPIO\n");
+ perst = NULL;
+ }
+ cp->port.perst = perst;
+ }
+
+ if (!found)
+ return dev_err_probe(dev, -ENODEV, "missing Root Port node\n");
+
+ return 0;
+}
+
+static int cortina_pcie_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cortina_pcie *cp;
+ struct dw_pcie *pci;
+ struct resource *res;
+ int ret;
+
+ cp = devm_kzalloc(dev, sizeof(*cp), GFP_KERNEL);
+ if (!cp)
+ return -ENOMEM;
+
+ pci = &cp->pci;
+ pci->dev = dev;
+ pci->ops = &cortina_dw_pcie_ops;
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
+ if (!res)
+ return -EINVAL;
+
+ cp->dbi_phys = res->start;
+ cp->app = devm_platform_ioremap_resource_byname(pdev, "app");
+ if (IS_ERR(cp->app))
+ return PTR_ERR(cp->app);
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "app");
+ if (res->start < APP_PHYS_BASE ||
+ (res->start - APP_PHYS_BASE) % APP_PORT_STRIDE ||
+ (res->start - APP_PHYS_BASE) / APP_PORT_STRIDE >= 3)
+ return -EINVAL;
+
+ cp->index = (res->start - APP_PHYS_BASE) / APP_PORT_STRIDE;
+ raw_spin_lock_init(&cp->lock);
+ cp->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(cp->clk))
+ return dev_err_probe(dev, PTR_ERR(cp->clk), "controller clock\n");
+
+ cp->reset = devm_reset_control_get_exclusive(dev, NULL);
+ if (IS_ERR(cp->reset))
+ return dev_err_probe(dev, PTR_ERR(cp->reset), "controller reset\n");
+
+ cp->phy = devm_phy_get(dev, "pcie");
+ if (IS_ERR(cp->phy))
+ return dev_err_probe(dev, PTR_ERR(cp->phy), "SerDes\n");
+
+ ret = cortina_pcie_parse_port(cp);
+ if (ret)
+ return ret;
+
+ cp->irq = platform_get_irq(pdev, 0);
+ if (cp->irq < 0)
+ return cp->irq;
+
+ /* Hold the endpoint and core in reset while stabilizing the PHY. */
+ ret = reset_control_assert(cp->reset);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(cp->clk);
+ if (ret)
+ return ret;
+
+ ret = phy_init(cp->phy);
+ if (ret)
+ goto disable_clk;
+
+ ret = phy_set_mode(cp->phy, PHY_MODE_PCIE);
+ if (ret)
+ goto exit_phy;
+
+ ret = phy_power_on(cp->phy);
+ if (ret)
+ goto exit_phy;
+
+ /* The controller has remained asserted throughout PHY setup. */
+ usleep_range(10000, 12000);
+ ret = reset_control_deassert(cp->reset);
+ if (ret)
+ goto power_off;
+ usleep_range(10000, 12000);
+
+ writel(0, cp->app + APP_INT_ENABLE);
+ cortina_pcie_stop_link(pci);
+ writel(readl(cp->app + APP_INT_STATUS), cp->app + APP_INT_STATUS);
+ ret = cortina_pcie_port_init(cp);
+ if (ret)
+ goto power_off;
+
+ ret = cortina_pcie_init_irq_domain(cp);
+ if (ret)
+ goto power_off;
+
+ irq_set_chained_handler_and_data(cp->irq, cortina_pcie_irq_handler, cp);
+ writel(INT_MSI | INT_ERR_MASK, cp->app + APP_INT_ENABLE);
+ pci->pp.ops = &cortina_pcie_host_ops;
+ ret = dw_pcie_host_init(&pci->pp);
+ if (ret)
+ goto remove_irq_domain;
+
+ platform_set_drvdata(pdev, cp);
+ return 0;
+
+remove_irq_domain:
+ cortina_pcie_quiesce(cp);
+ cortina_pcie_remove_irq_domain(cp);
+power_off:
+ gpiod_set_value_cansleep(cp->port.perst, 1);
+ reset_control_assert(cp->reset);
+ phy_power_off(cp->phy);
+exit_phy:
+ phy_exit(cp->phy);
+disable_clk:
+ reset_control_assert(cp->reset);
+ clk_disable_unprepare(cp->clk);
+ return dev_err_probe(dev, ret, "host initialization\n");
+}
+
+static void cortina_pcie_remove(struct platform_device *pdev)
+{
+ struct cortina_pcie *cp = platform_get_drvdata(pdev);
+
+ dw_pcie_host_deinit(&cp->pci.pp);
+ cortina_pcie_remove_irq_domain(cp);
+ cortina_pcie_power_off(cp);
+}
+
+static void cortina_pcie_shutdown(struct platform_device *pdev)
+{
+ struct cortina_pcie *cp = platform_get_drvdata(pdev);
+
+ cortina_pcie_quiesce(cp);
+ cortina_pcie_stop_link(&cp->pci);
+ gpiod_set_value_cansleep(cp->port.perst, 1);
+ reset_control_assert(cp->reset);
+}
+
+static const struct of_device_id cortina_pcie_of_match[] = {
+ { .compatible = "cortina,cs7542-pcie" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, cortina_pcie_of_match);
+
+static struct platform_driver cortina_pcie_driver = {
+ .probe = cortina_pcie_probe,
+ .remove = cortina_pcie_remove,
+ .shutdown = cortina_pcie_shutdown,
+ .driver = {
+ .name = "cs7542-pcie",
+ .of_match_table = cortina_pcie_of_match,
+ },
+};
+module_platform_driver(cortina_pcie_driver);
+
+MODULE_DESCRIPTION("Cortina Systems CS7542 PCIe host controller");
+MODULE_LICENSE("GPL");
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 6/6] MAINTAINERS: Add CS7542 PCIe support
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
` (4 preceding siblings ...)
2026-11-27 4:35 ` [PATCH v3 5/6] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
@ 2026-11-27 4:35 ` Fil Dunsky via B4 Relay
2026-11-27 4:46 ` [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support sashiko-bot
6 siblings, 0 replies; 8+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-27 4:35 UTC (permalink / raw)
To: Manivannan Sadhasivam, Vinod Koul, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski,
Bjorn Helgaas, Neil Armstrong, Stephen Boyd, Philipp Zabel,
linux-pci, linux-phy, devicetree, linux-arm-kernel, linux-kernel
From: Fil Dunsky <filipp.dunsky@gmail.com>
Cover the PCIe host, SerDes PHY and their bindings under the existing
CS7542 global control entry. The shared clock/reset provider and reset
specifier header are already covered by the prerequisite series.
Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
MAINTAINERS | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 703e95e83..8921c91a7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2949,13 +2949,17 @@ F: tools/perf/tests/shell/coresight/*
F: tools/perf/util/cs-etm-decoder/*
F: tools/perf/util/cs-etm.*
-ARM/CORTINA SYSTEMS CS7542 GLOBAL CONTROL
+ARM/CORTINA SYSTEMS CS7542 GLOBAL CONTROL AND PCIE
M: Fil Dunsky <filipp.dunsky@gmail.com>
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
S: Maintained
+F: Documentation/devicetree/bindings/pci/cortina,cs7542-pcie.yaml
+F: Documentation/devicetree/bindings/phy/cortina,cs7542-pcie-phy.yaml
F: Documentation/devicetree/bindings/pinctrl/cortina,cs7542-pinctrl.yaml
F: Documentation/devicetree/bindings/soc/cortina/
F: drivers/clk/clk-cs7542.c
+F: drivers/pci/controller/dwc/pcie-cs7542.c
+F: drivers/phy/phy-cs7542-pcie.c
F: drivers/pinctrl/pinctrl-cs7542.c
F: drivers/reset/reset-cs7542.c
F: include/dt-bindings/clock/cortina,cs7542-clock.h
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
` (5 preceding siblings ...)
2026-11-27 4:35 ` [PATCH v3 6/6] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
@ 2026-11-27 4:46 ` sashiko-bot
6 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-11-27 4:46 UTC (permalink / raw)
To: Fil Dunsky; +Cc: linux-pci
Sashiko has finished reviewing this 6-patch series:
- Patches 1-5: no issues found.
- Patch 6: skipped (not reviewed).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-b4-cs7542-pcie-v3-0-b067875c56da@gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-27 4:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 4:35 [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 1/6] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 2/6] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 3/6] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 4/6] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 5/6] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
2026-11-27 4:35 ` [PATCH v3 6/6] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
2026-11-27 4:46 ` [PATCH v3 0/6] PCI: cortina: Add CS7542 PCIe host and PHY support sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox