Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support
@ 2026-11-23 20:32 Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

Add CS7542 PCIe support with global gate/reset controls, a Snow Bush
SerDes PHY and DesignWare host glue. The global syscon already provides
the APB/CPU/AXI clocks; extend that same provider with three PCIe gates
and controller resets. No resource-less pcie-control child is created.
The existing clock indices remain unchanged; PCIe gets named specifiers.

This series depends on the posted global clock/pinctrl v2:
https://lore.kernel.org/all/20261123-cs7542-syscon-v2-0-1cd74b2522f9@gmail.com/
The complete prerequisite and this series apply to Linux v7.4-rc4.
Board DTS changes are prepared separately.

The host protects its 512-byte root configuration limit, owns the
combined INTx/MSI interrupt lifecycle and reads link status from the
application wrapper. Unused SATA mode, hotplug and suspend are outside
this initial support. Gate source rates are not assumed.

Validation of v2:
- Full independent ARM GCC14.2 vmlinux/modules builds with PHY/host=y
  and=m, COMPILE_TEST=n and no Cortina platform series. The early global
  provider is built in because the APB timer clock must be available early.
- Updated schemas/examples and strict global-driver checkpatch pass.
- Actual parent-provider source: 461 cases and 23309 assertions under
  ASan/UBSan, including all strap modes, six clock outputs, unrelated
  bits and every allocation/registration failure path.
- Combined ARM multi_v7 vmlinux/modules and board DT build pass.

The revised parent provider and PCIe host booted Linux 7.4 on Almond+
in RAM. Enumeration, all 3 root ports' post-enumeration MSI enable bits,
MSI-X/INTx xHCI completions and host unload/reload passed. The INTx
mapping count returned to its pre-probe baseline after unload. Final
result: failures=0, followed by automatic return to installed OpenWrt.
No flash writes were performed. Actual config/DBI tests cover 49298
cases, including zero hardware accesses after link loss; lifecycle tests
check locked masking, IRQ draining and sparse mapping disposal.

---
Changes in v2:
- Expose PCIe gates/resets on the existing global syscon provider.
- Remove the virtual child binding and separate gate/reset driver.
- Preserve early strap clocks and unwind partial registration failures.
- Put clocks before interrupts in the host binding and example.
- Enable root-port MSI after enumeration; dispose INTx mappings on teardown.
- Return 0 for lost-link DBI reads to fail iATU polling; serialize quiesce,
  config/DBI access and IRQ draining before reset.
- Link to v1: https://patch.msgid.link/20261123-b4-cs7542-pcie-v1-0-4cde5201d404@gmail.com

To: Jingoo Han <jingoohan1@gmail.com>
To: Manivannan Sadhasivam <mani@kernel.org>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Krzysztof Wilczyński <kwilczynski@kernel.org>
To: Rob Herring <robh@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
To: Fil Dunsky <filipp.dunsky@gmail.com>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
To: Stephen Boyd <sboyd@kernel.org>
To: Brian Masney <bmasney+clk@redhat.com>
To: Jerome Brunet <jbrunet+clk@baylibre.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
To: Vinod Koul <vkoul@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: linux-pci@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-clk@vger.kernel.org
Cc: linux-phy@lists.infradead.org

---
Fil Dunsky (8):
      PCI: dwc: Export the multiplexed MSI interrupt handler
      dt-bindings: soc: Describe CS7542 PCIe clocks and resets
      clk: cs7542: Add PCIe gates and resets to the global provider
      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          | 129 +++++
 .../bindings/phy/cortina,cs7542-pcie-phy.yaml      |  67 +++
 .../soc/cortina/cortina,cs7542-syscon.yaml         |  10 +-
 MAINTAINERS                                        |   7 +-
 drivers/clk/Kconfig                                |   6 +-
 drivers/clk/clk-cs7542.c                           | 183 ++++++-
 drivers/pci/controller/dwc/Kconfig                 |  12 +
 drivers/pci/controller/dwc/Makefile                |   2 +
 drivers/pci/controller/dwc/pcie-cs7542.c           | 551 +++++++++++++++++++++
 drivers/pci/controller/dwc/pcie-designware-host.c  |   1 +
 drivers/phy/Kconfig                                |  11 +
 drivers/phy/Makefile                               |   2 +
 drivers/phy/phy-cs7542-pcie.c                      | 232 +++++++++
 include/dt-bindings/clock/cortina,cs7542-clock.h   |   4 +
 include/dt-bindings/reset/cortina,cs7542-reset.h   |   9 +
 15 files changed, 1200 insertions(+), 26 deletions(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-pcie-224e359c8698
prerequisite-message-id: 20261123-cs7542-syscon-v2-0-1cd74b2522f9@gmail.com
prerequisite-patch-id: 4b568d742095f1a61312c911d2b6e81c8e754312
prerequisite-patch-id: a4bba26a3aac57e4e4229a727fdf94677373493a
prerequisite-patch-id: f8a2ba71717f71ca2bedda986f8b861995cdc586
prerequisite-patch-id: 7fbe9405265ef3d1ec62811415a46c0061afd7c8
prerequisite-patch-id: 25220835f5d2506a01ba652d86f9b9ac3ad5121a

Best regards,
--  
Fil Dunsky <filipp.dunsky@gmail.com>




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 2/8] dt-bindings: soc: Describe CS7542 PCIe clocks and resets Fil Dunsky via B4 Relay
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, 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] 11+ messages in thread

* [PATCH v2 2/8] dt-bindings: soc: Describe CS7542 PCIe clocks and resets
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 3/8] clk: cs7542: Add PCIe gates and resets to the global provider Fil Dunsky via B4 Relay
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

From: Fil Dunsky <filipp.dunsky@gmail.com>

The global register block already supplies the strap clocks. Extend that
same provider with the three PCIe gate clocks and controller reset lines,
rather than inventing a resource-less child to instantiate a driver.

Keep the existing APB/CPU/AXI indices and add named PCIe clock and reset
specifiers. The reset property is optional for clock-only descriptions.

Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 .../devicetree/bindings/soc/cortina/cortina,cs7542-syscon.yaml | 10 ++++++++--
 include/dt-bindings/clock/cortina,cs7542-clock.h               |  4 ++++
 include/dt-bindings/reset/cortina,cs7542-reset.h               |  9 +++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/soc/cortina/cortina,cs7542-syscon.yaml b/Documentation/devicetree/bindings/soc/cortina/cortina,cs7542-syscon.yaml
index fb074de87..dc7306868 100644
--- a/Documentation/devicetree/bindings/soc/cortina/cortina,cs7542-syscon.yaml
+++ b/Documentation/devicetree/bindings/soc/cortina/cortina,cs7542-syscon.yaml
@@ -12,8 +12,10 @@ maintainers:
 description:
   The global control block contains the boot strap status, GPIO/peripheral
   mux registers, reset controls and the secondary CPU release register.
-  It provides the APB, CPU and AXI clock rates selected by the boot straps.
-  The clock specifiers are defined in dt-bindings/clock/cortina,cs7542-clock.h.
+  It provides the APB, CPU and AXI clock rates selected by the boot straps,
+  and the three PCIe clock gates and controller reset lines.
+  Clock specifiers are defined in dt-bindings/clock/cortina,cs7542-clock.h;
+  reset specifiers are defined in dt-bindings/reset/cortina,cs7542-reset.h.
   The pin controller uses the same register map through its parent syscon.
 
 properties:
@@ -29,6 +31,9 @@ properties:
   "#clock-cells":
     const: 1
 
+  "#reset-cells":
+    const: 1
+
   pinctrl:
     type: object
     $ref: /schemas/pinctrl/cortina,cs7542-pinctrl.yaml#
@@ -46,4 +51,5 @@ examples:
         compatible = "cortina,cs7542-syscon", "syscon", "simple-mfd";
         reg = <0xf0000000 0x100>;
         #clock-cells = <1>;
+        #reset-cells = <1>;
     };
diff --git a/include/dt-bindings/clock/cortina,cs7542-clock.h b/include/dt-bindings/clock/cortina,cs7542-clock.h
index 34d544238..c68c6ba20 100644
--- a/include/dt-bindings/clock/cortina,cs7542-clock.h
+++ b/include/dt-bindings/clock/cortina,cs7542-clock.h
@@ -6,4 +6,8 @@
 #define CS7542_CLK_CPU	1
 #define CS7542_CLK_AXI	2
 
+#define CS7542_CLK_PCIE0	3
+#define CS7542_CLK_PCIE1	4
+#define CS7542_CLK_PCIE2	5
+
 #endif
diff --git a/include/dt-bindings/reset/cortina,cs7542-reset.h b/include/dt-bindings/reset/cortina,cs7542-reset.h
new file mode 100644
index 000000000..bfd5799b2
--- /dev/null
+++ b/include/dt-bindings/reset/cortina,cs7542-reset.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+#ifndef _DT_BINDINGS_RESET_CORTINA_CS7542_H
+#define _DT_BINDINGS_RESET_CORTINA_CS7542_H
+
+#define CS7542_RESET_PCIE0	0
+#define CS7542_RESET_PCIE1	1
+#define CS7542_RESET_PCIE2	2
+
+#endif

-- 
2.53.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 3/8] clk: cs7542: Add PCIe gates and resets to the global provider
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 2/8] dt-bindings: soc: Describe CS7542 PCIe clocks and resets Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

From: Fil Dunsky <filipp.dunsky@gmail.com>

Register the three PCIe gate clocks and controller resets from the global
syscon node. Preserve the early strap clocks used by the ARM timers and
the shared regmap updates that protect unrelated reset and gate bits.

The driver is built in because APB is needed during timer discovery. The
PCIe host and PHY consumers remain independently modular. Unwind all
registered clocks and the reset provider on initialization failures.

Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 drivers/clk/Kconfig      |   6 +-
 drivers/clk/clk-cs7542.c | 183 +++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 166 insertions(+), 23 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 47b5265fe..4dcc60979 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -59,13 +59,15 @@ config LMK04832
 	  Low-Noise JESD204B Compliant Clock Jitter Cleaner With Dual Loop PLLs
 
 config COMMON_CLK_CS7542
-	bool "Cortina Systems CS7542 strap-selected clocks"
+	bool "Cortina Systems CS7542 global clocks and resets"
 	depends on OF && HAS_IOMEM
 	select MFD_SYSCON
+	select RESET_CONTROLLER
 	help
 	  Read the boot straps of the CS7542 global control block to provide
 	  its APB, CPU and AXI clocks. This driver does not change PLLs or
-	  dividers. It is built in because the APB clock is needed by timers.
+	  dividers. It also provides the three PCIe clock gates and resets.
+	  It is built in because the APB clock is needed by timers.
 
 config COMMON_CLK_APPLE_NCO
 	tristate "Clock driver for Apple SoC NCOs"
diff --git a/drivers/clk/clk-cs7542.c b/drivers/clk/clk-cs7542.c
index 4e6c1e98a..e4bb1bb70 100644
--- a/drivers/clk/clk-cs7542.c
+++ b/drivers/clk/clk-cs7542.c
@@ -1,24 +1,28 @@
 // SPDX-License-Identifier: GPL-2.0-only
-/* Cortina Systems CS7542 strap-selected clocks */
+/* Cortina Systems CS7542 global clocks and PCIe resets. */
 
 #include <linux/bitfield.h>
 #include <linux/clk-provider.h>
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/mfd/syscon.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/printk.h>
 #include <linux/regmap.h>
+#include <linux/reset-controller.h>
 #include <linux/slab.h>
 
 #include <dt-bindings/clock/cortina,cs7542-clock.h>
 
 #define CS7542_GLOBAL_STRAP	0x0c
 #define CS7542_STRAP_SPEED	GENMASK(3, 1)
-#define CS7542_NUM_CLKS		3
+#define CS7542_NUM_FIXED_CLKS	3
+#define CS7542_NUM_CLKS		6
 
 /* Rates from the GPL vendor kernel's get_platform_clk(). */
-static const unsigned long cs7542_rates[][CS7542_NUM_CLKS] = {
+static const unsigned long cs7542_rates[][CS7542_NUM_FIXED_CLKS] = {
 	/* APB, CPU, AXI */
 	{ 100000000, 400000000, 133333333 },
 	{ 100000000, 600000000, 150000000 },
@@ -33,14 +37,115 @@ static const char * const cs7542_clock_names[] = {
 	[CS7542_CLK_APB] = "cs7542-apb",
 	[CS7542_CLK_CPU] = "cs7542-cpu",
 	[CS7542_CLK_AXI] = "cs7542-axi",
+	[CS7542_CLK_PCIE0] = "cs7542-pcie0",
+	[CS7542_CLK_PCIE1] = "cs7542-pcie1",
+	[CS7542_CLK_PCIE2] = "cs7542-pcie2",
+};
+
+#define CS7542_PORTS	3
+#define GLOBAL_RESET	0x04
+#define GLOBAL_CONFIG	0x10
+
+struct cs7542_gate {
+	struct clk_hw hw;
+	struct regmap *map;
+	u32 mask;
+};
+
+struct cs7542_control {
+	struct reset_controller_dev rcdev;
+	struct regmap *map;
+	struct cs7542_gate gates[CS7542_PORTS];
+	struct clk_hw_onecell_data *clks;
+};
+
+static int cs7542_gate_prepare(struct clk_hw *hw)
+{
+	struct cs7542_gate *gate = container_of(hw, struct cs7542_gate, hw);
+
+	return regmap_update_bits(gate->map, GLOBAL_CONFIG, gate->mask, gate->mask);
+}
+
+static void cs7542_gate_unprepare(struct clk_hw *hw)
+{
+	struct cs7542_gate *gate = container_of(hw, struct cs7542_gate, hw);
+
+	regmap_update_bits(gate->map, GLOBAL_CONFIG, gate->mask, 0);
+}
+
+static int cs7542_gate_is_prepared(struct clk_hw *hw)
+{
+	struct cs7542_gate *gate = container_of(hw, struct cs7542_gate, hw);
+	unsigned int value;
+	int ret;
+
+	ret = regmap_read(gate->map, GLOBAL_CONFIG, &value);
+	return ret ? ret : !!(value & gate->mask);
+}
+
+static const struct clk_ops cs7542_gate_ops = {
+	.prepare = cs7542_gate_prepare,
+	.unprepare = cs7542_gate_unprepare,
+	.is_prepared = cs7542_gate_is_prepared,
+};
+
+static int cs7542_reset_update(struct reset_controller_dev *rcdev,
+			       unsigned long id, bool assert)
+{
+	struct cs7542_control *ctl = container_of(rcdev, struct cs7542_control, rcdev);
+	u32 mask = BIT(6 + id);
+
+	return regmap_update_bits(ctl->map, GLOBAL_RESET, mask, assert ? mask : 0);
+}
+
+static int cs7542_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return cs7542_reset_update(rcdev, id, true);
+}
+
+static int cs7542_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	return cs7542_reset_update(rcdev, id, false);
+}
+
+static int cs7542_reset_status(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	struct cs7542_control *ctl = container_of(rcdev, struct cs7542_control, rcdev);
+	unsigned int value;
+	int ret;
+
+	ret = regmap_read(ctl->map, GLOBAL_RESET, &value);
+	return ret ? ret : !!(value & BIT(6 + id));
+}
+
+static int cs7542_reset_pulse(struct reset_controller_dev *rcdev, unsigned long id)
+{
+	int ret;
+
+	ret = cs7542_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+	usleep_range(10000, 12000);
+	ret = cs7542_reset_deassert(rcdev, id);
+	if (ret)
+		return ret;
+	usleep_range(10000, 12000);
+	return 0;
+}
+
+static const struct reset_control_ops cs7542_reset_ops = {
+	.assert = cs7542_reset_assert,
+	.deassert = cs7542_reset_deassert,
+	.status = cs7542_reset_status,
+	.reset = cs7542_reset_pulse,
 };
 
 static void __init cs7542_clk_init(struct device_node *np)
 {
-	struct clk_hw_onecell_data *data;
+	struct cs7542_control *ctl;
 	struct regmap *map;
 	unsigned int strap, speed;
-	int i, ret;
+	int i, j, ret;
 
 	map = syscon_node_to_regmap(np);
 	if (IS_ERR(map)) {
@@ -60,30 +165,66 @@ static void __init cs7542_clk_init(struct device_node *np)
 		return;
 	}
 
-	data = kzalloc_flex(*data, hws, CS7542_NUM_CLKS);
-	if (!data)
+	ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+	if (!ctl)
+		return;
+	ctl->map = map;
+	ctl->clks = kzalloc_flex(*ctl->clks, hws, CS7542_NUM_CLKS);
+	if (!ctl->clks) {
+		kfree(ctl);
 		return;
-	data->num = CS7542_NUM_CLKS;
-
-	for (i = 0; i < CS7542_NUM_CLKS; i++) {
-		data->hws[i] = clk_hw_register_fixed_rate(NULL,
-							  cs7542_clock_names[i], NULL,
-							  0, cs7542_rates[speed][i]);
-		if (IS_ERR(data->hws[i])) {
-			ret = PTR_ERR(data->hws[i]);
-			goto err_unregister;
+	}
+	ctl->clks->num = CS7542_NUM_CLKS;
+
+	for (i = 0; i < CS7542_NUM_FIXED_CLKS; i++) {
+		ctl->clks->hws[i] = clk_hw_register_fixed_rate(NULL,
+							       cs7542_clock_names[i], NULL,
+							       0, cs7542_rates[speed][i]);
+		if (IS_ERR(ctl->clks->hws[i])) {
+			ret = PTR_ERR(ctl->clks->hws[i]);
+			goto err_unregister_fixed;
 		}
 	}
 
-	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, data);
+	for (j = 0; j < CS7542_PORTS; j++) {
+		struct cs7542_gate *gate = &ctl->gates[j];
+		struct clk_init_data init = {
+			.name = cs7542_clock_names[CS7542_CLK_PCIE0 + j],
+			.ops = &cs7542_gate_ops,
+		};
+
+		/* Gate-only controls: no source frequency is assumed. */
+		gate->map = map;
+		gate->mask = BIT(10 + 2 * j);
+		gate->hw.init = &init;
+		ret = clk_hw_register(NULL, &gate->hw);
+		if (ret)
+			goto err_unregister_gates;
+		ctl->clks->hws[CS7542_CLK_PCIE0 + j] = &gate->hw;
+	}
+
+	ctl->rcdev.owner = THIS_MODULE;
+	ctl->rcdev.ops = &cs7542_reset_ops;
+	ctl->rcdev.of_node = np;
+	ctl->rcdev.nr_resets = CS7542_PORTS;
+	ret = reset_controller_register(&ctl->rcdev);
+	if (ret)
+		goto err_unregister_gates;
+
+	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, ctl->clks);
 	if (!ret)
 		return;
 
-err_unregister:
+	reset_controller_unregister(&ctl->rcdev);
+err_unregister_gates:
+	while (j--)
+		clk_hw_unregister(&ctl->gates[j].hw);
+err_unregister_fixed:
 	while (i--)
-		clk_hw_unregister_fixed_rate(data->hws[i]);
-	kfree(data);
-	pr_err("%pOF: cannot register clocks: %d\n", np, ret);
+		clk_hw_unregister_fixed_rate(ctl->clks->hws[i]);
+	kfree(ctl->clks);
+	kfree(ctl);
+	pr_err("%pOF: cannot register global controls: %d\n", np, ret);
 }
 
 /* Timers need APB before platform devices, but the pinctrl child must probe. */

-- 
2.53.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (2 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 3/8] clk: cs7542: Add PCIe gates and resets to the global provider Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 5/8] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, 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] 11+ messages in thread

* [PATCH v2 5/8] phy: Add CS7542 PCIe SerDes support
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (3 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 6/8] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, 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.

Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 drivers/phy/Kconfig           |  11 ++
 drivers/phy/Makefile          |   2 +
 drivers/phy/phy-cs7542-pcie.c | 232 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 245 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..d027baa93
--- /dev/null
+++ b/drivers/phy/phy-cs7542-pcie.c
@@ -0,0 +1,232 @@
+// 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));
+	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:
+	cs7542_phy_power_off(phy);
+	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] 11+ messages in thread

* [PATCH v2 6/8] dt-bindings: PCI: Describe the CS7542 host controller
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (4 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 5/8] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 7/8] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, 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          | 129 +++++++++++++++++++++
 1 file changed, 129 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..c8ef5176d
--- /dev/null
+++ b/Documentation/devicetree/bindings/pci/cortina,cs7542-pcie.yaml
@@ -0,0 +1,129 @@
+# 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:
+    maxItems: 1
+    description: Optional active-low endpoint PERST#
+
+  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
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - clocks
+  - interrupts
+  - interrupt-names
+  - resets
+  - phys
+  - phy-names
+  - num-lanes
+  - 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_intc: interrupt-controller {
+            #address-cells = <0>;
+            #interrupt-cells = <1>;
+            interrupt-controller;
+        };
+    };

-- 
2.53.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v2 7/8] PCI: cs7542: Add CS7542 PCIe host support
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (5 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 6/8] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 20:32 ` [PATCH v2 8/8] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
  2026-11-23 22:54 ` [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Bjorn Helgaas
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, 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.

Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 drivers/pci/controller/dwc/Kconfig       |  12 +
 drivers/pci/controller/dwc/Makefile      |   2 +
 drivers/pci/controller/dwc/pcie-cs7542.c | 551 +++++++++++++++++++++++++++++++
 3 files changed, 565 insertions(+)

diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
index 0a0d56fcf..2ebaa8db1 100644
--- a/drivers/pci/controller/dwc/Kconfig
+++ b/drivers/pci/controller/dwc/Kconfig
@@ -577,4 +577,16 @@ config PCIE_ULTRARISC
 	  By default, this symbol is enabled when ARCH_ULTRARISC is active,
 	  requiring no further configuration on that platform.
 
+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
+	select RESET_CONTROLLER
+	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.
+
 endmenu
diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile
index d4f88cfc6..4a6ae9037 100644
--- a/drivers/pci/controller/dwc/Makefile
+++ b/drivers/pci/controller/dwc/Makefile
@@ -61,3 +61,5 @@ obj-$(CONFIG_ARM64) += pcie-hisi.o
 obj-$(CONFIG_ARM64) += pcie-tegra194-acpi.o
 endif
 endif
+
+obj-$(CONFIG_PCIE_CS7542) += pcie-cs7542.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..5487e667d
--- /dev/null
+++ b/drivers/pci/controller/dwc/pcie-cs7542.c
@@ -0,0 +1,551 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/iopoll.h>
+#include <linux/phy/phy.h>
+#include <linux/reset.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/interrupt.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/pci.h>
+#include <linux/platform_device.h>
+#include <linux/resource.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_TARGET		0xC0
+#define RC_CFG_LIMIT		0x200
+
+struct cortina_pcie {
+	struct dw_pcie		pci;
+	void __iomem		*app;
+	struct clk		*clk;
+	struct phy		*phy;
+	struct reset_control	*reset;
+	struct gpio_desc	*perst;
+	int			irq;
+	bool			msi_ready;
+	bool			link_lost;
+	struct irq_domain	*intx_domain;
+	raw_spinlock_t		lock;
+	resource_size_t		dbi_phys;
+	resource_size_t		app_phys;
+	int			port;
+};
+
+#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, 10, 10000);
+	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 v;
+
+	v = readl(cp->app + APP_CORE_CONFIG);
+	v |= CORE_CFG_LTSSM_EN | CORE_CFG_AXI_UR_MASK;
+	writel(v, 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) {
+		/* The DBI interface needs a controller reset after link loss. */
+		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->port, 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);
+	if (!READ_ONCE(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;
+
+	intc = of_get_child_by_name(dev->of_node, "interrupt-controller");
+	if (!intc)
+		return dev_err_probe(dev, -ENODEV, "no interrupt-controller child\n");
+
+	cp->intx_domain = irq_domain_create_linear(of_fwnode_handle(intc), 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 cortina_pcie *cp = to_cortina_pcie(to_dw_pcie_from_pp(bus->sysdata));
+
+	unsigned long flags;
+	int ret;
+
+	*val = ~0U;
+	if (where < 0 || (size != 1 && size != 2 && size != 4) ||
+	    (where & (size - 1)))
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (READ_ONCE(cp->link_lost))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	if (where >= RC_CFG_LIMIT || size > RC_CFG_LIMIT - where) {
+		*val = 0;
+		return PCIBIOS_SUCCESSFUL;
+	}
+	raw_spin_lock_irqsave(&cp->lock, flags);
+	ret = cp->link_lost ? PCIBIOS_DEVICE_NOT_FOUND :
+	      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 cortina_pcie *cp = to_cortina_pcie(to_dw_pcie_from_pp(bus->sysdata));
+
+	unsigned long flags;
+	int ret;
+
+	if (where < 0 || (size != 1 && size != 2 && size != 4) ||
+	    (where & (size - 1)))
+		return PCIBIOS_BAD_REGISTER_NUMBER;
+	if (READ_ONCE(cp->link_lost))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+	if (where >= RC_CFG_LIMIT || size > RC_CFG_LIMIT - where) {
+		dev_dbg(bus->dev.parent, "ignoring RC config write at %#x\n", where);
+		return PCIBIOS_SUCCESSFUL;
+	}
+	raw_spin_lock_irqsave(&cp->lock, flags);
+	ret = cp->link_lost ? PCIBIOS_DEVICE_NOT_FOUND :
+	      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);
+	u8 cap = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI);
+	u16 flags;
+
+	/* 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));
+	u32 ctrl;
+	int ret;
+
+	/* The application IRQ multiplexes MSI and INTx, so do not chain it twice. */
+	pp->msi_irq[0] = -ENODEV;
+	ret = dw_pcie_msi_host_init(pp);
+	if (ret)
+		return ret;
+	/* CS7542 routes endpoint MSI writes through its application target. */
+	pp->msi_data = cp->app_phys + APP_MSI_TARGET;
+	/* A custom MSI hook owns setup and teardown of the multiplexed receiver. */
+	for (ctrl = 0; ctrl < pp->num_vectors / MAX_MSI_IRQS_PER_CTRL; ctrl++) {
+		dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_INTR0_MASK + ctrl * MSI_REG_CTRL_BLOCK_SIZE,
+				   pp->irq_mask[ctrl]);
+		dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_INTR0_ENABLE + ctrl * MSI_REG_CTRL_BLOCK_SIZE,
+				   ~0);
+	}
+	dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_ADDR_LO, lower_32_bits(pp->msi_data));
+	dw_pcie_writel_dbi(&cp->pci, PCIE_MSI_ADDR_HI, upper_32_bits(pp->msi_data));
+	cp->msi_ready = true;
+	return 0;
+}
+
+static void cortina_pcie_quiesce(struct cortina_pcie *cp)
+{
+	unsigned long flags;
+
+	/* Serialize with config/DBI accesses 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);
+	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; now 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 and above remains accessible.
+ */
+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 < 0x700 && 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 < 0x700 && 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->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_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");
+	cp->app_phys = res->start;
+	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->port = (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");
+	cp->perst = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(cp->perst))
+		return dev_err_probe(dev, PTR_ERR(cp->perst), "PERST# GPIO\n");
+	cp->irq = platform_get_irq(pdev, 0);
+	if (cp->irq < 0)
+		return cp->irq;
+
+	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;
+	ret = reset_control_reset(cp->reset);
+	if (ret)
+		goto power_off;
+	writel(0, cp->app + APP_INT_ENABLE);
+	cortina_pcie_stop_link(pci);
+	writel(readl(cp->app + APP_INT_STATUS), cp->app + APP_INT_STATUS);
+	gpiod_set_value_cansleep(cp->perst, 0);
+	msleep(100);
+	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) {
+		cortina_pcie_quiesce(cp);
+		cortina_pcie_remove_irq_domain(cp);
+		goto power_off;
+	}
+	platform_set_drvdata(pdev, cp);
+	return 0;
+
+power_off:
+	gpiod_set_value_cansleep(cp->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->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] 11+ messages in thread

* [PATCH v2 8/8] MAINTAINERS: Add CS7542 PCIe support
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (6 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 7/8] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
@ 2026-11-23 20:32 ` Fil Dunsky via B4 Relay
  2026-11-23 22:54 ` [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Bjorn Helgaas
  8 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-23 20:32 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul
  Cc: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

From: Fil Dunsky <filipp.dunsky@gmail.com>

Cover the new PCIe control, SerDes and host drivers and their bindings
under the existing CS7542 entry.

Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
---
 MAINTAINERS | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index d8835aeca..511a6cb34 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2949,15 +2949,20 @@ 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:	include/dt-bindings/clock/cortina,cs7542-clock.h
+F:	include/dt-bindings/reset/cortina,cs7542-reset.h
 
 ARM/CORTINA SYSTEMS GEMINI ARM ARCHITECTURE
 M:	Hans Ulli Kroll <ulli.kroll@googlemail.com>

-- 
2.53.0




^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support
  2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
                   ` (7 preceding siblings ...)
  2026-11-23 20:32 ` [PATCH v2 8/8] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
@ 2026-11-23 22:54 ` Bjorn Helgaas
  2026-11-23 23:15   ` Fil Dunsky
  8 siblings, 1 reply; 11+ messages in thread
From: Bjorn Helgaas @ 2026-11-23 22:54 UTC (permalink / raw)
  To: Fil Dunsky
  Cc: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul, Jingoo Han,
	Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

On Mon, Nov 23, 2026 at 11:32:14PM +0300, Fil Dunsky wrote:
> Add CS7542 PCIe support with global gate/reset controls, a Snow Bush
> SerDes PHY and DesignWare host glue. The global syscon already provides
> the APB/CPU/AXI clocks; extend that same provider with three PCIe gates
> and controller resets. No resource-less pcie-control child is created.
> The existing clock indices remain unchanged; PCIe gets named specifiers.
> ...

> Changes in v2:
> - Expose PCIe gates/resets on the existing global syscon provider.
> - Remove the virtual child binding and separate gate/reset driver.
> - Preserve early strap clocks and unwind partial registration failures.
> - Put clocks before interrupts in the host binding and example.
> - Enable root-port MSI after enumeration; dispose INTx mappings on teardown.
> - Return 0 for lost-link DBI reads to fail iATU polling; serialize quiesce,
>   config/DBI access and IRQ draining before reset.
> - Link to v1: https://patch.msgid.link/20261123-b4-cs7542-pcie-v1-0-4cde5201d404@gmail.com

v1: Date: Mon, 23 Nov 2026 21:43:28 +0300
v2: Date: Mon, 23 Nov 2026 23:32:14 +0300

That's way too fast and wastes reviewers' time.  Please wait at least
a few days between versions.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support
  2026-11-23 22:54 ` [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Bjorn Helgaas
@ 2026-11-23 23:15   ` Fil Dunsky
  0 siblings, 0 replies; 11+ messages in thread
From: Fil Dunsky @ 2026-11-23 23:15 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Manivannan Sadhasivam, Stephen Boyd, Vinod Koul, Jingoo Han,
	Lorenzo Pieralisi, Krzysztof Wilczynski, Rob Herring,
	Bjorn Helgaas, Brian Masney, Jerome Brunet, Neil Armstrong,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel, linux-pci,
	linux-arm-kernel, linux-clk, linux-phy, devicetree, linux-kernel

Understood, sorry for the rapid reroll. I will wait a few days between
PCIe revisions and collect the review before sending the next version.
I will use the meantime to address your comments and test the changes
on Almond+.

Thanks,
Fil


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-11-23 23:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 20:32 [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 1/8] PCI: dwc: Export the multiplexed MSI interrupt handler Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 2/8] dt-bindings: soc: Describe CS7542 PCIe clocks and resets Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 3/8] clk: cs7542: Add PCIe gates and resets to the global provider Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 4/8] dt-bindings: phy: Describe CS7542 PCIe SerDes Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 5/8] phy: Add CS7542 PCIe SerDes support Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 6/8] dt-bindings: PCI: Describe the CS7542 host controller Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 7/8] PCI: cs7542: Add CS7542 PCIe host support Fil Dunsky via B4 Relay
2026-11-23 20:32 ` [PATCH v2 8/8] MAINTAINERS: Add CS7542 PCIe support Fil Dunsky via B4 Relay
2026-11-23 22:54 ` [PATCH v2 0/8] soc: cortina: Add CS7542 PCIe control, SerDes and host support Bjorn Helgaas
2026-11-23 23:15   ` Fil Dunsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox