From 1f7a51a5ae7ccd37b45417af750e68bac2c5b65b Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Wed, 9 Sep 2026 16:55:54 +0200 Subject: [PATCH 01/20] BACKPORT: gpio: tc9563: Add support for the embedded GPIO controller Add a driver for the GPIO controller embedded in the Toshiba TC9563 PCIe switch (and the Qualcomm QPS615). The device implements 37 GPIOs using two register banks: three registers control the first 32 GPIOs and three more control GPIOs 32-36. GPIOs 20 and 21 are reserved while GPIOs 22-24, 27-28, 31, and 34 are input-only. Register the driver as an auxiliary device driver. The TC9563 power controller creates the auxiliary device and provides a regmap that gives access to the GPIO registers, so use the gpio-regmap helpers to implement the GPIO chip. Signed-off-by: Alex Elder Co-developed-by: Daniel Thompson Signed-off-by: Daniel Thompson Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi [bhelgaas: commit log per https://lore.kernel.org/arQ2mDjqHv4gmoOK@lore-desk] [bhelgaas: squash Geert Uytterhoeven Kconfig fix: https://lore.kernel.org/all/45484c37512a3102495d8b75b6e9f72a141ba42e.1792574560.git.geert+renesas@glider.be, reviewed by Bartosz Golaszewski , acked by Lorenzo Bianconi ] Signed-off-by: Bjorn Helgaas Reviewed-by: Linus Walleij Reviewed-by: Manivannan Sadhasivam Acked-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260909-pci-tc9563-aux-v5-2-c9b33f56c8d3@oss.qualcomm.com (cherry picked from commit 03ba5646f0f4c26998eb0bbfc9324e003afffb3e) --- drivers/gpio/Kconfig | 27 ++++++++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc9563.c | 92 +++++++++++++++++++++++++++++++++ include/linux/soc/qcom/tc9563.h | 16 ++++++ 4 files changed, 136 insertions(+) create mode 100644 drivers/gpio/gpio-tc9563.c create mode 100644 include/linux/soc/qcom/tc9563.h diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 0d89f93fcb9b2..9b720f0d6f05c 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1750,6 +1750,33 @@ config GPIO_WM8994 endmenu +menu "Auxiliary Bus GPIO drivers" + depends on AUXILIARY_BUS + +config GPIO_LTC4283 + tristate "Analog Devices LTC4283 GPIO support" + depends on SENSORS_LTC4283 + help + If you say yes here you want the GPIO function available in Analog + Devices LTC4283 Negative Voltage Hot Swap Controller. + + This driver can also be built as a module. If so, the module will + be called gpio-ltc4283. + +endmenu + +config GPIO_TC9563 + tristate "Toshiba TC9563 GPIO support" + depends on PCI_PWRCTRL_TC9563 || COMPILE_TEST + default m if ARCH_QCOM + select AUXILIARY_BUS + select GPIO_REGMAP + help + This enables support for the GPIO controller embedded in the Toshiba + TC9563 (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. + menu "PCI GPIO expanders" depends on PCI diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6f31446a528df..ae2886cda1e85 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -174,6 +174,7 @@ obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o obj-$(CONFIG_GPIO_TANGIER) += gpio-tangier.o obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o +obj-$(CONFIG_GPIO_TC9563) += gpio-tc9563.o obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.o diff --git a/drivers/gpio/gpio-tc9563.c b/drivers/gpio/gpio-tc9563.c new file mode 100644 index 0000000000000..4cd0391dd70fa --- /dev/null +++ b/drivers/gpio/gpio-tc9563.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. + */ + +/* + * The Toshiba TC9563 implements a PCIe Gen 3 switch that connects an + * upstream x4 port to two downstream PCIe x2 ports. It incorporates + * an internal endpoint on a internal PCIe port that implements two + * Synopsys XGMAC Ethernet interfaces. + * + * 37 GPIOs are also implemented by an embedded GPIO controller. Three + * registers control the first 32 GPIOs (other than 20 and 21, which are + * reserved). Three other registers control GPIOs 32 through 36. GPIOs + * 22-24, 27-28, 31, and 34 are treated as "input only". + * + */ + +#include +#include +#include +#include +#include +#include + +/* + * There are two sets of registers, each representing (up to) 32 GPIOs with a + * stride of 4 bytes (IN1 is 4 bytes past IN0, EN1 is 4 bytes past EN0, etc.). + */ +#define TC9563_GPIO_COUNT 37 +#define TC9563_GPIO_PER_REG 32 +#define TC9563_GPIO_REG_STRIDE 4 + +static int tc9563_gpio_init_valid_mask(struct gpio_chip *gc, + unsigned long *valid_mask, + unsigned int ngpios) +{ + /* GPIOs 20 and 21 are reserved */ + bitmap_fill(valid_mask, ngpios); + bitmap_clear(valid_mask, 20, 2); + + return 0; +} + +static int tc9563_gpio_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct gpio_regmap_config config = { + .parent = &adev->dev, + .ngpio = TC9563_GPIO_COUNT, + .reg_stride = TC9563_GPIO_REG_STRIDE, + .ngpio_per_reg = TC9563_GPIO_PER_REG, + .reg_dat_base = GPIO_REGMAP_ADDR(TC9563_GPIO_IN0_OFFSET), + .reg_set_base = GPIO_REGMAP_ADDR(TC9563_GPIO_OUT0_OFFSET), + .reg_dir_in_base = GPIO_REGMAP_ADDR(TC9563_GPIO_EN0_OFFSET), + .init_valid_mask = tc9563_gpio_init_valid_mask, + }; + + config.regmap = dev_get_platdata(&adev->dev); + if (!config.regmap) + return -EINVAL; + + /* + * GPIOs 22, 23, 24, 27, 28, 31, and 34 are input-only, but this + * kernel's gpio-regmap core only supports a single, chip-wide + * fixed_direction_output bitmap, with no way to leave the + * remaining GPIOs under reg_dir_in_base control. Rely on + * reg_dir_in_base for direction on all valid GPIOs instead; + * the input-only lines simply never get switched to output. + */ + + return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(&adev->dev, &config)); +}; + +static const struct auxiliary_device_id tc9563_gpio_ids[] = { + { "pci_pwrctrl_tc9563." TC9563_GPIO_DEV_NAME }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(auxiliary, tc9563_gpio_ids); + +static struct auxiliary_driver tc9563_gpio_driver = { + .name = TC9563_GPIO_DEV_NAME, + .probe = tc9563_gpio_probe, + .id_table = tc9563_gpio_ids, +}; +module_auxiliary_driver(tc9563_gpio_driver); + +MODULE_AUTHOR("Alex Elder "); +MODULE_AUTHOR("Daniel Thompson "); +MODULE_AUTHOR("Lorenzo Bianconi "); +MODULE_DESCRIPTION("Toshiba TC9563 GPIO Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/soc/qcom/tc9563.h b/include/linux/soc/qcom/tc9563.h new file mode 100644 index 0000000000000..0dfd25747b9af --- /dev/null +++ b/include/linux/soc/qcom/tc9563.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2026 Qualcomm Innovation Center, Inc. All rights reserved. + * Author: Lorenzo Bianconi + */ + +#ifndef __QCOM_TC9563_H +#define __QCOM_TC9563_H + +#define TC9563_GPIO_DEV_NAME "tc9563-gpio" + +#define TC9563_GPIO_IN0_OFFSET 0x801200 +#define TC9563_GPIO_EN0_OFFSET 0x801208 +#define TC9563_GPIO_OUT0_OFFSET 0x801210 + +#endif /* __QCOM_TC9563_H */ From 0a600a4f8ddb6b25f194cbd3b62f9af48d43c43b Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 9 Sep 2026 16:55:53 +0200 Subject: [PATCH 02/20] BACKPORT: dt-bindings: PCI: toshiba,tc9563: Document embedded GPIO controller The TC9563 PCIe switch embeds a GPIO controller providing 37 GPIO lines, accessed through the switch's I2C interface. The controller is integrated in the switch rather than being a separate device, so expose it by adding the gpio-controller and #gpio-cells properties to the switch node itself, and extend the example to show the downstream ports' reset-gpios being driven from those lines. Signed-off-by: Lorenzo Bianconi Signed-off-by: Bjorn Helgaas Reviewed-by: Krzysztof Kozlowski Link: https://patch.msgid.link/20260909-pci-tc9563-aux-v5-1-c9b33f56c8d3@oss.qualcomm.com (cherry picked from commit 32184f8b8dc14100bd605e157ab70a5a278d7c1e) --- .../devicetree/bindings/pci/toshiba,tc9563.yaml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml index 5d862ce520370..22b870b6c824a 100644 --- a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml +++ b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml @@ -26,14 +26,16 @@ properties: reg: maxItems: 1 - '#gpio-cells': - const: 2 - resx-gpios: maxItems: 1 description: GPIO controlling the RESX# pin. + gpio-controller: true + + '#gpio-cells': + const: 2 + vdd18-supply: true vdd09-supply: true @@ -126,7 +128,7 @@ examples: ranges; bus-range = <0x01 0xff>; - pcie@0,0 { + tc9563: pcie@0,0 { compatible = "pci1179,0623"; reg = <0x10000 0x0 0x0 0x0 0x0>; @@ -148,6 +150,9 @@ examples: resx-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + gpio-controller; + #gpio-cells = <2>; + pcie@1,0 { compatible = "pciclass,0604"; reg = <0x20800 0x0 0x0 0x0 0x0>; @@ -157,6 +162,8 @@ examples: ranges; bus-range = <0x03 0xff>; + reset-gpios = <&tc9563 2 GPIO_ACTIVE_LOW>; + toshiba,no-dfe-support; }; From 367859f07099a269675b1ac09a7e4bfc517ba12c Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 16 Jul 2026 15:25:32 +0200 Subject: [PATCH 03/20] BACKPORT: PCI/pwrctrl: tc9563: Take i2c adapter module reference The i2c subsystem currently blocks during adapter deregistration whenever there are consumers holding a reference. Switch to using of_get_i2c_adapter_by_node() which also takes a reference to the adapter module so that an attempt to unload the module while in use fails gracefully instead of blocking uninterruptibly. Signed-off-by: Johan Hovold Signed-off-by: Bjorn Helgaas Reviewed-by: Bartosz Golaszewski Reviewed-by: Manivannan Sadhasivam Link: https://patch.msgid.link/20260716132532.1565340-1-johan@kernel.org (cherry picked from commit 62ef2a96fe7e66b8b5c4e756a8454146adee1817) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 4197196597bc6..77e6690f37c86 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -680,7 +680,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "Failed to read i2c-parent property\n"); i2c_node = of_parse_phandle(dev->of_node, "i2c-parent", 0); - tc9563->adapter = of_find_i2c_adapter_by_node(i2c_node); + tc9563->adapter = of_get_i2c_adapter_by_node(i2c_node); of_node_put(i2c_node); if (!tc9563->adapter) return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n"); @@ -688,7 +688,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr); if (IS_ERR(tc9563->client)) { dev_err(dev, "Failed to create I2C client\n"); - put_device(&tc9563->adapter->dev); + i2c_put_adapter(tc9563->adapter); return PTR_ERR(tc9563->client); } @@ -756,7 +756,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) tc9563_pwrctrl_power_off(&tc9563->pwrctrl); remove_i2c: i2c_unregister_device(tc9563->client); - put_device(&tc9563->adapter->dev); + i2c_put_adapter(tc9563->adapter); return ret; } @@ -768,7 +768,7 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev) tc9563_pwrctrl_power_off(&tc9563->pwrctrl); i2c_unregister_device(tc9563->client); - put_device(&tc9563->adapter->dev); + i2c_put_adapter(tc9563->adapter); } static const struct of_device_id tc9563_pwrctrl_of_match[] = { From 4f3a8c0777d75f4217eead87d2cdc64463da2e72 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Sat, 25 Jul 2026 10:59:14 +0200 Subject: [PATCH 04/20] BACKPORT: PCI/pwrctrl: tc9563: Fix parsing the integrated Ethernet MAC Endpoint node DSP3 has an integrated Ethernet MAC Endpoint which has its own set of config registers for configuring settings such as ASPM. The Endpoint device has two physical functions and those two functions share the same settings. Parse the Endpoint node under DSP3 instead of parsing both functions. The existing parsing logic also has one OOB issue as parsing both functions will result in accessing past the tc9563_pwrctrl->cfg array. Fixes: 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563") Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Elder Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260725-tc9563-fix-v1-2-ec4286e31331@oss.qualcomm.com (cherry picked from commit 6e5e6c2194b2acbded5b12ed80590d215b786d29) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 77e6690f37c86..ad232221d73d6 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -727,13 +727,19 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) ret = tc9563_pwrctrl_parse_device_dt(tc9563, child, port); if (ret) break; - /* Embedded ethernet device are under DSP3 */ + + /* + * The integrated Ethernet MAC Endpoint under DSP3 is a single + * device whose functions share the same config registers. + */ if (port == TC9563_DSP3) { - for_each_child_of_node_scoped(child, child1) { - port++; + struct device_node *eth __free(device_node) = + of_get_next_available_child(child, NULL); + + if (eth) { ret = tc9563_pwrctrl_parse_device_dt(tc9563, - child1, port); - if (port + 1 >= TC9563_MAX || ret) + eth, TC9563_ETHERNET); + if (ret) break; } } From 83b5c86b46dc0f5a76414f4396778aa0014b2418 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Sat, 25 Jul 2026 10:59:15 +0200 Subject: [PATCH 05/20] BACKPORT: PCI/pwrctrl: tc9563: Power off only the external ports in tc9563_pwrctrl_disable_port() TC9563 supports powering off only the external facing ports like DSP1 and DSP2. It is not recommended to power off USP and DSP3 as they have fixed ports/endpoint connected. Fix tc9563_pwrctrl_disable_port() to power off only DSP1 and DSP2. Fixes: 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563") Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Elder Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260725-tc9563-fix-v1-3-ec4286e31331@oss.qualcomm.com (cherry picked from commit e41bbfc4c109f2db741eef5cd0ac55600930c449) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index ad232221d73d6..1a0820a90062b 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -250,12 +250,18 @@ static int tc9563_pwrctrl_disable_port(struct pci_pwrctrl_tc9563 *tc9563, if (!cfg->disable_port) return 0; - if (port == TC9563_DSP1) { + switch (port) { + case TC9563_DSP1: seq = dsp1_pwroff_seq; len = ARRAY_SIZE(dsp1_pwroff_seq); - } else { + break; + case TC9563_DSP2: seq = dsp2_pwroff_seq; len = ARRAY_SIZE(dsp2_pwroff_seq); + break; + default: + /* Only external downstream ports DSP1/DSP2 can be powered off */ + return 0; } ret = tc9563_pwrctrl_i2c_bulk_write(tc9563->client, seq, len); From 51cdf703927bf48704de023108512951ff2e3043 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Sat, 25 Jul 2026 10:59:16 +0200 Subject: [PATCH 06/20] BACKPORT: PCI/pwrctrl: tc9563: Skip Tx amplitude and DFE tuning for DSP3 DSP3 doesn't support tuning Tx amplitude and DFE settings. Skip the setting if DT has passed the tuning properties. There is no need to error out the whole driver because of it. Fixes: 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563") Signed-off-by: Manivannan Sadhasivam [bhelgaas: squash https://lore.kernel.org/all/oefxm7olagbd3dby2npgly7ausiz3g6cvls5igaxdzvlbr3wrv@rjlfebi2p36j] Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Elder Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260725-tc9563-fix-v1-4-ec4286e31331@oss.qualcomm.com (cherry picked from commit b859b9366b44e48461724c19dd42cd4a05b6f49c) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 1a0820a90062b..95cf4f80cf5d6 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -416,6 +416,7 @@ static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc95 static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { + struct device *dev = tc9563->pwrctrl.dev; u32 amp = tc9563->cfg[port].tx_amp; int port_access; @@ -435,6 +436,9 @@ static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, case TC9563_DSP2: port_access = 0x8; break; + case TC9563_DSP3: + dev_dbg(dev, "Tx amplitude tuning not supported for DSP3\n"); + return 0; default: return -EINVAL; } @@ -453,6 +457,7 @@ static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; + struct device *dev = tc9563->pwrctrl.dev; int port_access, lane_access = 0x3; u32 phy_rate = 0x21; @@ -471,6 +476,9 @@ static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, port_access = 0x8; lane_access = 0x1; break; + case TC9563_DSP3: + dev_dbg(dev, "DFE tuning not supported for DSP3\n"); + return 0; default: return -EINVAL; } @@ -501,11 +509,17 @@ static int tc9563_pwrctrl_set_nfts(struct pci_pwrctrl_tc9563 *tc9563, {TC9563_NFTS_2_5_GT, nfts[0]}, {TC9563_NFTS_5_GT, nfts[1]}, }; + struct device *dev = tc9563->pwrctrl.dev; int ret; if (!nfts[0]) return 0; + if (port == TC9563_VDSP) { + dev_dbg(dev, "N_FTS tuning not supported for VDSP\n"); + return 0; + } + ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, BIT(port)); if (ret) From e26c5995c7d496dfe87934db7bf70a57a7947da0 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Sat, 25 Jul 2026 10:59:17 +0200 Subject: [PATCH 07/20] BACKPORT: PCI/pwrctrl: tc9563: Rename DSP3 to VDSP TC9563 Reference Manual calls DSP3 as VDSP (Virtual Downstream Port). Name it as such to avoid ambiguity. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Elder Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260725-tc9563-fix-v1-5-ec4286e31331@oss.qualcomm.com (cherry picked from commit b7f273a4627505839720d633ffc66c89f46f9eee) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 95cf4f80cf5d6..b7f9fdac5e9b9 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -85,7 +85,7 @@ enum tc9563_pwrctrl_ports { TC9563_USP, TC9563_DSP1, TC9563_DSP2, - TC9563_DSP3, + TC9563_VDSP, TC9563_ETHERNET, TC9563_MAX }; @@ -436,8 +436,8 @@ static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, case TC9563_DSP2: port_access = 0x8; break; - case TC9563_DSP3: - dev_dbg(dev, "Tx amplitude tuning not supported for DSP3\n"); + case TC9563_VDSP: + dev_dbg(dev, "Tx amplitude tuning not supported for VDSP\n"); return 0; default: return -EINVAL; @@ -476,8 +476,8 @@ static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, port_access = 0x8; lane_access = 0x1; break; - case TC9563_DSP3: - dev_dbg(dev, "DFE tuning not supported for DSP3\n"); + case TC9563_VDSP: + dev_dbg(dev, "DFE tuning not supported for VDSP\n"); return 0; default: return -EINVAL; @@ -749,10 +749,10 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) break; /* - * The integrated Ethernet MAC Endpoint under DSP3 is a single + * The integrated Ethernet MAC Endpoint under VDSP is a single * device whose functions share the same config registers. */ - if (port == TC9563_DSP3) { + if (port == TC9563_VDSP) { struct device_node *eth __free(device_node) = of_get_next_available_child(child, NULL); From 1f8407830a5e5eaabccaf931772efd18a844b122 Mon Sep 17 00:00:00 2001 From: "Rob Herring (Arm)" Date: Thu, 7 May 2026 15:16:00 -0500 Subject: [PATCH 08/20] BACKPORT: dt-bindings: Fix phandle-array constraints, again The unfortunately named 'phandle-array' property type is really a matrix with phandle and fixed arg cells entries. A matrix property should have 2 levels of items constraints. Acked-by: Mark Brown Acked-by: Greg Kroah-Hartman Link: https://patch.msgid.link/20260507201749.2605365-1-robh@kernel.org Signed-off-by: Rob Herring (Arm) Signed-off-by: Hariharan Sreedhar (cherry picked from commit 37534121c4e49a32e80d8a11de66fce25d448292) --- Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml index 22b870b6c824a..1bd066a5bbc29 100644 --- a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml +++ b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml @@ -54,8 +54,9 @@ properties: A phandle to the parent I2C node and the slave address of the device used to configure tc9563 to change FTS, tx amplitude etc. items: - - description: Phandle to the I2C controller node - - description: I2C slave address + - items: + - description: Phandle to the I2C controller node + - description: I2C slave address patternProperties: "^pcie@[1-3],0$": From fe8cf3831619f88df1ff589d89d2b9b3aa7906d6 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Sat, 25 Jul 2026 10:59:18 +0200 Subject: [PATCH 09/20] BACKPORT: PCI/pwrctrl: tc9563: Move Integrated MAC Endpoint out of 'tc9563_pwrctrl_ports' enum 'tc9563_pwrctrl_ports' is supposed to list only the internal ports of the switch. But it currently lists the integrated MAC Endpoint as well, which is wrong. Move it to a separate 'ep_cfg' struct and also configure/parse the ports and the MAC Endpoint separately. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Alex Elder Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260725-tc9563-fix-v1-6-ec4286e31331@oss.qualcomm.com (cherry picked from commit b9851611bad7cb227c93c1401dca48995a815d94) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 95 +++++++++++++++--------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index b7f9fdac5e9b9..751b72b3d5ded 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -86,7 +86,6 @@ enum tc9563_pwrctrl_ports { TC9563_DSP1, TC9563_DSP2, TC9563_VDSP, - TC9563_ETHERNET, TC9563_MAX }; @@ -118,6 +117,7 @@ struct pci_pwrctrl_tc9563 { struct pci_pwrctrl pwrctrl; struct regulator_bulk_data supplies[TC9563_PWRCTL_MAX_SUPPLY]; struct tc9563_pwrctrl_cfg cfg[TC9563_MAX]; + struct tc9563_pwrctrl_cfg ep_cfg; struct gpio_desc *reset_gpio; struct i2c_adapter *adapter; struct i2c_client *client; @@ -371,11 +371,11 @@ static int tc9563_pwrctrl_set_eq_fine_tuning(struct pci_pwrctrl_tc9563 *tc9563) TC9563_EQ_FINE_TUNING_ITER); } -static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc9563, - enum tc9563_pwrctrl_ports port, - bool is_l1, u32 ns) +static int tc9563_pwrctrl_set_port_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc9563, + enum tc9563_pwrctrl_ports port, + bool is_l1, u32 ns) { - u32 rd_val, units; + u32 units; int ret; if (ns < TC9563_L0S_L1_DELAY_UNIT_NS) @@ -384,25 +384,6 @@ static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc95 /* convert to units of 256ns */ units = ns / TC9563_L0S_L1_DELAY_UNIT_NS; - if (port == TC9563_ETHERNET) { - ret = tc9563_pwrctrl_i2c_read(tc9563->client, - TC9563_EMBEDDED_ETH_DELAY, - &rd_val); - if (ret) - return ret; - - if (is_l1) - rd_val = u32_replace_bits(rd_val, units, - TC9563_ETH_L1_DELAY_MASK); - else - rd_val = u32_replace_bits(rd_val, units, - TC9563_ETH_L0S_DELAY_MASK); - - return tc9563_pwrctrl_i2c_write(tc9563->client, - TC9563_EMBEDDED_ETH_DELAY, - rd_val); - } - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, BIT(port)); if (ret) @@ -413,6 +394,34 @@ static int tc9563_pwrctrl_set_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc95 units); } +static int tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc9563, + bool is_l1, u32 ns) +{ + u32 rd_val, units; + int ret; + + if (ns < TC9563_L0S_L1_DELAY_UNIT_NS) + return 0; + + /* convert to units of 256ns */ + units = ns / TC9563_L0S_L1_DELAY_UNIT_NS; + + ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_EMBEDDED_ETH_DELAY, + &rd_val); + if (ret) + return ret; + + if (is_l1) + rd_val = u32_replace_bits(rd_val, units, + TC9563_ETH_L1_DELAY_MASK); + else + rd_val = u32_replace_bits(rd_val, units, + TC9563_ETH_L0S_DELAY_MASK); + + return tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_EMBEDDED_ETH_DELAY, + rd_val); +} + static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { @@ -529,11 +538,9 @@ static int tc9563_pwrctrl_set_nfts(struct pci_pwrctrl_tc9563 *tc9563, ARRAY_SIZE(nfts_seq)); } -static int tc9563_pwrctrl_parse_device_dt(struct pci_pwrctrl_tc9563 *tc9563, - struct device_node *node, - enum tc9563_pwrctrl_ports port) +static int tc9563_pwrctrl_parse_device_dt(struct device_node *node, + struct tc9563_pwrctrl_cfg *cfg) { - struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; struct of_phandle_args args; int ret; @@ -636,13 +643,13 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) goto power_off; } - ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(tc9563, i, false, cfg->l0s_delay); + ret = tc9563_pwrctrl_set_port_l0s_l1_entry_delay(tc9563, i, false, cfg->l0s_delay); if (ret) { dev_err(dev, "Setting L0s entry delay failed\n"); goto power_off; } - ret = tc9563_pwrctrl_set_l0s_l1_entry_delay(tc9563, i, true, cfg->l1_delay); + ret = tc9563_pwrctrl_set_port_l0s_l1_entry_delay(tc9563, i, true, cfg->l1_delay); if (ret) { dev_err(dev, "Setting L1 entry delay failed\n"); goto power_off; @@ -675,6 +682,21 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) } + /* Configure the integrated Ethernet MAC endpoint */ + ret = tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(tc9563, false, + tc9563->ep_cfg.l0s_delay); + if (ret) { + dev_err(dev, "Setting Ethernet L0s entry delay failed\n"); + goto power_off; + } + + ret = tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(tc9563, true, + tc9563->ep_cfg.l1_delay); + if (ret) { + dev_err(dev, "Setting Ethernet L1 entry delay failed\n"); + goto power_off; + } + return 0; power_off: @@ -730,8 +752,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) pci_pwrctrl_init(&tc9563->pwrctrl, dev); - port = TC9563_USP; - ret = tc9563_pwrctrl_parse_device_dt(tc9563, node, port); + ret = tc9563_pwrctrl_parse_device_dt(node, &tc9563->cfg[TC9563_USP]); if (ret) { dev_err(dev, "failed to parse device tree properties: %d\n", ret); goto remove_i2c; @@ -742,9 +763,12 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) * The first node represents DSP1, the second node represents DSP2, * and so on. */ + port = TC9563_USP; for_each_child_of_node_scoped(node, child) { - port++; - ret = tc9563_pwrctrl_parse_device_dt(tc9563, child, port); + if (++port >= TC9563_MAX) + break; + + ret = tc9563_pwrctrl_parse_device_dt(child, &tc9563->cfg[port]); if (ret) break; @@ -757,8 +781,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) of_get_next_available_child(child, NULL); if (eth) { - ret = tc9563_pwrctrl_parse_device_dt(tc9563, - eth, TC9563_ETHERNET); + ret = tc9563_pwrctrl_parse_device_dt(eth, &tc9563->ep_cfg); if (ret) break; } From cbef886a7d0190ee69f40040b8ab52fcfe588fc5 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 29 Jul 2026 15:34:25 +0200 Subject: [PATCH 10/20] BACKPORT: PCI/pwrctrl: tc9563: Rely on regmap APIs Replace the custom tc9563_pwrctrl_i2c_{read,write,bulk_write} functions with standard regmap APIs. The device uses 24-bit big-endian register addresses and 32-bit little-endian register values over I2C, which is directly supported by regmap. This removes the open-coded I2C transfer handling and lets the regmap core handle formatting, locking, and multi-register coalescing. Signed-off-by: Lorenzo Bianconi Signed-off-by: Bjorn Helgaas Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260729-pci-pwrctrl-tc956x-regmap-v1-1-20ce61a3ce12@oss.qualcomm.com (cherry picked from commit ebaa06fc5bbeea062e6dc7b2f28f7b042f9cc2ca) --- drivers/pci/pwrctrl/Kconfig | 1 + drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 179 +++++++---------------- 2 files changed, 53 insertions(+), 127 deletions(-) diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig index 811338ceea071..1660f28fab80e 100644 --- a/drivers/pci/pwrctrl/Kconfig +++ b/drivers/pci/pwrctrl/Kconfig @@ -28,6 +28,7 @@ config PCI_PWRCTRL_TC9563 select PCI_PWRCTRL default m if ARCH_QCOM depends on I2C + select REGMAP_I2C help Say Y here to enable the PCI Power Control driver of TC9563 PCIe switch. diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 751b72b3d5ded..c3256bef10834 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -17,10 +17,10 @@ #include #include #include +#include #include #include #include -#include #include "../pci.h" @@ -76,11 +76,6 @@ #define TC9563_L0S_L1_DELAY_UNIT_NS 256 /* Each unit represents 256 ns */ -struct tc9563_pwrctrl_reg_setting { - unsigned int offset; - unsigned int val; -}; - enum tc9563_pwrctrl_ports { TC9563_USP, TC9563_DSP1, @@ -121,13 +116,14 @@ struct pci_pwrctrl_tc9563 { struct gpio_desc *reset_gpio; struct i2c_adapter *adapter; struct i2c_client *client; + struct regmap *regmap; }; /* * downstream port power off sequence, hardcoding the address * as we don't know register names for these register offsets. */ -static const struct tc9563_pwrctrl_reg_setting common_pwroff_seq[] = { +static const struct reg_sequence common_pwroff_seq[] = { {0x82900c, 0x1}, {0x829010, 0x1}, {0x829018, 0x0}, @@ -150,7 +146,7 @@ static const struct tc9563_pwrctrl_reg_setting common_pwroff_seq[] = { {0x829114, 0x1}, }; -static const struct tc9563_pwrctrl_reg_setting dsp1_pwroff_seq[] = { +static const struct reg_sequence dsp1_pwroff_seq[] = { {TC9563_PORT_ACCESS_ENABLE, 0x2}, {TC9563_PORT_LANE_ACCESS_ENABLE, 0x3}, {TC9563_POWER_CONTROL, 0x014f4804}, @@ -158,7 +154,7 @@ static const struct tc9563_pwrctrl_reg_setting dsp1_pwroff_seq[] = { {TC9563_PORT_ACCESS_ENABLE, 0x4}, }; -static const struct tc9563_pwrctrl_reg_setting dsp2_pwroff_seq[] = { +static const struct reg_sequence dsp2_pwroff_seq[] = { {TC9563_PORT_ACCESS_ENABLE, 0x8}, {TC9563_PORT_LANE_ACCESS_ENABLE, 0x1}, {TC9563_POWER_CONTROL, 0x014f4804}, @@ -166,85 +162,11 @@ static const struct tc9563_pwrctrl_reg_setting dsp2_pwroff_seq[] = { {TC9563_PORT_ACCESS_ENABLE, 0x8}, }; -/* - * Since all transfers are initiated by the probe, no locks are necessary, - * as there are no concurrent calls. - */ -static int tc9563_pwrctrl_i2c_write(struct i2c_client *client, - u32 reg_addr, u32 reg_val) -{ - struct i2c_msg msg; - u8 msg_buf[7]; - int ret; - - msg.addr = client->addr; - msg.len = 7; - msg.flags = 0; - - /* Big Endian for reg addr */ - put_unaligned_be24(reg_addr, &msg_buf[0]); - - /* Little Endian for reg val */ - put_unaligned_le32(reg_val, &msg_buf[3]); - - msg.buf = msg_buf; - ret = i2c_transfer(client->adapter, &msg, 1); - return ret == 1 ? 0 : ret; -} - -static int tc9563_pwrctrl_i2c_read(struct i2c_client *client, - u32 reg_addr, u32 *reg_val) -{ - struct i2c_msg msg[2]; - u8 wr_data[3]; - u32 rd_data; - int ret; - - msg[0].addr = client->addr; - msg[0].len = 3; - msg[0].flags = 0; - - /* Big Endian for reg addr */ - put_unaligned_be24(reg_addr, &wr_data[0]); - - msg[0].buf = wr_data; - - msg[1].addr = client->addr; - msg[1].len = 4; - msg[1].flags = I2C_M_RD; - - msg[1].buf = (u8 *)&rd_data; - - ret = i2c_transfer(client->adapter, &msg[0], 2); - if (ret == 2) { - *reg_val = get_unaligned_le32(&rd_data); - return 0; - } - - /* If only one message successfully completed, return -EIO */ - return ret == 1 ? -EIO : ret; -} - -static int tc9563_pwrctrl_i2c_bulk_write(struct i2c_client *client, - const struct tc9563_pwrctrl_reg_setting *seq, - int len) -{ - int ret, i; - - for (i = 0; i < len; i++) { - ret = tc9563_pwrctrl_i2c_write(client, seq[i].offset, seq[i].val); - if (ret) - return ret; - } - - return 0; -} - static int tc9563_pwrctrl_disable_port(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { struct tc9563_pwrctrl_cfg *cfg = &tc9563->cfg[port]; - const struct tc9563_pwrctrl_reg_setting *seq; + const struct reg_sequence *seq; int ret, len; if (!cfg->disable_port) @@ -264,12 +186,12 @@ static int tc9563_pwrctrl_disable_port(struct pci_pwrctrl_tc9563 *tc9563, return 0; } - ret = tc9563_pwrctrl_i2c_bulk_write(tc9563->client, seq, len); + ret = regmap_multi_reg_write(tc9563->regmap, seq, len); if (ret) return ret; - return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, common_pwroff_seq, - ARRAY_SIZE(common_pwroff_seq)); + return regmap_multi_reg_write(tc9563->regmap, common_pwroff_seq, + ARRAY_SIZE(common_pwroff_seq)); } static int tc9563_pwrctrl_ep_pwr_en(struct pci_pwrctrl_tc9563 *tc9563, @@ -286,27 +208,24 @@ static int tc9563_pwrctrl_ep_pwr_en(struct pci_pwrctrl_tc9563 *tc9563, ep_pwr_en_gpio_mask = BIT(ep_pwr_en_gpio); /* Set TC9563 GPIO as output */ - ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_GPIO_CONFIG, - &val); + ret = regmap_read(tc9563->regmap, TC9563_GPIO_CONFIG, &val); if (ret) return ret; val &= ~ep_pwr_en_gpio_mask; - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_GPIO_CONFIG, - val); + ret = regmap_write(tc9563->regmap, TC9563_GPIO_CONFIG, val); if (ret) return ret; /* Toggle 0->1 to enable power */ - ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_RESET_GPIO, - &val); + ret = regmap_read(tc9563->regmap, TC9563_RESET_GPIO, &val); if (ret) return ret; val = enable ? (val | ep_pwr_en_gpio_mask) : (val & ~ep_pwr_en_gpio_mask); - return tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_RESET_GPIO, val); + return regmap_write(tc9563->regmap, TC9563_RESET_GPIO, val); } @@ -333,42 +252,37 @@ static int tc9563_pwrctrl_ep_assert_deassert_reset(struct pci_pwrctrl_tc9563 *tc ep_reset_gpio_mask = BIT(ep_reset_gpio); /* Set TC9563 GPIO as output */ - ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_GPIO_CONFIG, - &val); + ret = regmap_read(tc9563->regmap, TC9563_GPIO_CONFIG, &val); if (ret) return ret; val &= ~ep_reset_gpio_mask; - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_GPIO_CONFIG, - val); + ret = regmap_write(tc9563->regmap, TC9563_GPIO_CONFIG, val); if (ret) return ret; /* Assert-deassert endpoint reset */ - ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_RESET_GPIO, - &val); + ret = regmap_read(tc9563->regmap, TC9563_RESET_GPIO, &val); if (ret) return ret; val = deassert ? (val | ep_reset_gpio_mask) : (val & ~ep_reset_gpio_mask); - return tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_RESET_GPIO, val); + return regmap_write(tc9563->regmap, TC9563_RESET_GPIO, val); } static int tc9563_pwrctrl_set_eq_fine_tuning(struct pci_pwrctrl_tc9563 *tc9563) { int ret; - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, - BIT(TC9563_USP) | BIT(TC9563_DSP1) | - BIT(TC9563_DSP2)); + ret = regmap_write(tc9563->regmap, TC9563_PORT_SELECT, + BIT(TC9563_USP) | BIT(TC9563_DSP1) | BIT(TC9563_DSP2)); if (ret) return ret; - return tc9563_pwrctrl_i2c_write(tc9563->client, - TC9563_K_EQUTUNING_033_028, - TC9563_EQ_FINE_TUNING_ITER); + return regmap_write(tc9563->regmap, TC9563_K_EQUTUNING_033_028, + TC9563_EQ_FINE_TUNING_ITER); } static int tc9563_pwrctrl_set_port_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc9563, @@ -384,14 +298,13 @@ static int tc9563_pwrctrl_set_port_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 /* convert to units of 256ns */ units = ns / TC9563_L0S_L1_DELAY_UNIT_NS; - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, - BIT(port)); + ret = regmap_write(tc9563->regmap, TC9563_PORT_SELECT, BIT(port)); if (ret) return ret; - return tc9563_pwrctrl_i2c_write(tc9563->client, - is_l1 ? TC9563_PORT_L1_DELAY : TC9563_PORT_L0S_DELAY, - units); + return regmap_write(tc9563->regmap, + is_l1 ? TC9563_PORT_L1_DELAY : TC9563_PORT_L0S_DELAY, + units); } static int tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 *tc9563, @@ -406,8 +319,7 @@ static int tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 * /* convert to units of 256ns */ units = ns / TC9563_L0S_L1_DELAY_UNIT_NS; - ret = tc9563_pwrctrl_i2c_read(tc9563->client, TC9563_EMBEDDED_ETH_DELAY, - &rd_val); + ret = regmap_read(tc9563->regmap, TC9563_EMBEDDED_ETH_DELAY, &rd_val); if (ret) return ret; @@ -418,8 +330,7 @@ static int tc9563_pwrctrl_set_eth_l0s_l1_entry_delay(struct pci_pwrctrl_tc9563 * rd_val = u32_replace_bits(rd_val, units, TC9563_ETH_L0S_DELAY_MASK); - return tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_EMBEDDED_ETH_DELAY, - rd_val); + return regmap_write(tc9563->regmap, TC9563_EMBEDDED_ETH_DELAY, rd_val); } static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, @@ -452,14 +363,14 @@ static int tc9563_pwrctrl_set_tx_amplitude(struct pci_pwrctrl_tc9563 *tc9563, return -EINVAL; } - struct tc9563_pwrctrl_reg_setting tx_amp_seq[] = { + const struct reg_sequence tx_amp_seq[] = { {TC9563_PORT_ACCESS_ENABLE, port_access}, {TC9563_PORT_LANE_ACCESS_ENABLE, 0x3}, {TC9563_TX_MARGIN, amp}, }; - return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, tx_amp_seq, - ARRAY_SIZE(tx_amp_seq)); + return regmap_multi_reg_write(tc9563->regmap, tx_amp_seq, + ARRAY_SIZE(tx_amp_seq)); } static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, @@ -492,7 +403,7 @@ static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, return -EINVAL; } - struct tc9563_pwrctrl_reg_setting disable_dfe_seq[] = { + const struct reg_sequence disable_dfe_seq[] = { {TC9563_PORT_ACCESS_ENABLE, port_access}, {TC9563_PORT_LANE_ACCESS_ENABLE, lane_access}, {TC9563_DFE_ENABLE, 0x0}, @@ -506,15 +417,15 @@ static int tc9563_pwrctrl_disable_dfe(struct pci_pwrctrl_tc9563 *tc9563, {TC9563_PHY_RATE_CHANGE_OVERRIDE, 0x0}, }; - return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, disable_dfe_seq, - ARRAY_SIZE(disable_dfe_seq)); + return regmap_multi_reg_write(tc9563->regmap, disable_dfe_seq, + ARRAY_SIZE(disable_dfe_seq)); } static int tc9563_pwrctrl_set_nfts(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { u8 *nfts = tc9563->cfg[port].nfts; - struct tc9563_pwrctrl_reg_setting nfts_seq[] = { + const struct reg_sequence nfts_seq[] = { {TC9563_NFTS_2_5_GT, nfts[0]}, {TC9563_NFTS_5_GT, nfts[1]}, }; @@ -529,13 +440,12 @@ static int tc9563_pwrctrl_set_nfts(struct pci_pwrctrl_tc9563 *tc9563, return 0; } - ret = tc9563_pwrctrl_i2c_write(tc9563->client, TC9563_PORT_SELECT, - BIT(port)); + ret = regmap_write(tc9563->regmap, TC9563_PORT_SELECT, BIT(port)); if (ret) return ret; - return tc9563_pwrctrl_i2c_bulk_write(tc9563->client, nfts_seq, - ARRAY_SIZE(nfts_seq)); + return regmap_multi_reg_write(tc9563->regmap, nfts_seq, + ARRAY_SIZE(nfts_seq)); } static int tc9563_pwrctrl_parse_device_dt(struct device_node *node, @@ -704,6 +614,13 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) return ret; } +static const struct regmap_config tc9563_regmap_config = { + .reg_bits = 24, + .val_bits = 32, + .reg_format_endian = REGMAP_ENDIAN_BIG, + .val_format_endian = REGMAP_ENDIAN_LITTLE, +}; + static int tc9563_pwrctrl_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; @@ -734,6 +651,14 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) return PTR_ERR(tc9563->client); } + tc9563->regmap = devm_regmap_init_i2c(tc9563->client, + &tc9563_regmap_config); + if (IS_ERR(tc9563->regmap)) { + ret = dev_err_probe(dev, PTR_ERR(tc9563->regmap), + "Failed to allocate register map\n"); + goto remove_i2c; + } + for (int i = 0; i < ARRAY_SIZE(tc9563_supply_names); i++) tc9563->supplies[i].supply = tc9563_supply_names[i]; From 28d6bee11c2f6c4ea93738c683fd6dd2c49bde6a Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 29 Jul 2026 15:34:26 +0200 Subject: [PATCH 11/20] BACKPORT: PCI/pwrctrl: tc9563: Use devm-managed I2C dummy device allocation Switch from i2c_new_dummy_device() to its devm variant devm_i2c_new_dummy_device() so the I2C client is automatically unregistered when the driver is removed or on probe failure. This allows removing the manual i2c_unregister_device() calls from both the probe error path and the remove function, and lets the i2c_client pointer be a local variable in probe instead of storing it in the driver data structure. Signed-off-by: Lorenzo Bianconi Signed-off-by: Bjorn Helgaas Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260729-pci-pwrctrl-tc956x-regmap-v1-2-20ce61a3ce12@oss.qualcomm.com (cherry picked from commit 854fc493df555479d73623e87ce2d8233c32b6bc) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index c3256bef10834..ae726d71dda00 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -115,7 +115,6 @@ struct pci_pwrctrl_tc9563 { struct tc9563_pwrctrl_cfg ep_cfg; struct gpio_desc *reset_gpio; struct i2c_adapter *adapter; - struct i2c_client *client; struct regmap *regmap; }; @@ -628,6 +627,7 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) enum tc9563_pwrctrl_ports port; struct pci_pwrctrl_tc9563 *tc9563; struct device_node *i2c_node; + struct i2c_client *client; int ret, addr; tc9563 = devm_kzalloc(dev, sizeof(*tc9563), GFP_KERNEL); @@ -644,15 +644,14 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) if (!tc9563->adapter) return dev_err_probe(dev, -EPROBE_DEFER, "Failed to find I2C adapter\n"); - tc9563->client = i2c_new_dummy_device(tc9563->adapter, addr); - if (IS_ERR(tc9563->client)) { + client = devm_i2c_new_dummy_device(dev, tc9563->adapter, addr); + if (IS_ERR(client)) { dev_err(dev, "Failed to create I2C client\n"); - i2c_put_adapter(tc9563->adapter); - return PTR_ERR(tc9563->client); + ret = PTR_ERR(client); + goto remove_i2c; } - tc9563->regmap = devm_regmap_init_i2c(tc9563->client, - &tc9563_regmap_config); + tc9563->regmap = devm_regmap_init_i2c(client, &tc9563_regmap_config); if (IS_ERR(tc9563->regmap)) { ret = dev_err_probe(dev, PTR_ERR(tc9563->regmap), "Failed to allocate register map\n"); @@ -729,7 +728,6 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) power_off: tc9563_pwrctrl_power_off(&tc9563->pwrctrl); remove_i2c: - i2c_unregister_device(tc9563->client); i2c_put_adapter(tc9563->adapter); return ret; } @@ -741,7 +739,6 @@ static void tc9563_pwrctrl_remove(struct platform_device *pdev) struct pci_pwrctrl_tc9563, pwrctrl); tc9563_pwrctrl_power_off(&tc9563->pwrctrl); - i2c_unregister_device(tc9563->client); i2c_put_adapter(tc9563->adapter); } From 1d1f5e363f911761e274bb6ba6a3f2c1b00b7beb Mon Sep 17 00:00:00 2001 From: Abel Vesa Date: Tue, 25 Aug 2026 14:41:31 +0300 Subject: [PATCH 12/20] BACKPORT: PCI/pwrctrl: tc9563: Allow RESX reset assertion to sleep The RESX GPIO may be provided by a sleeping GPIO controller, such as an I2C or SPI I/O expander. Calling gpiod_set_value() for such a GPIO triggers the following warning: WARNING: ... drivers/gpio/gpiolib.c:4030 at gpiod_set_value() The TC9563 power-on and power-off callbacks already sleep while enabling or disabling regulators and while waiting for oscillator stabilization. Use gpiod_set_value_cansleep() for RESX so it can be driven without triggering the warning. Fixes: 4c9c7be47310 ("PCI: pwrctrl: Add power control driver for TC9563") Signed-off-by: Abel Vesa Signed-off-by: Bjorn Helgaas Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260825-pci-pwrctl-tc9563-use-cansleep-for-resx-v1-1-0dbe7cfd8200@oss.qualcomm.com (cherry picked from commit 028f86457e822ab9de5b0d6d23efddc1b8b54ae1) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index ae726d71dda00..60abbc7de89d4 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -500,7 +500,7 @@ static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) struct pci_pwrctrl_tc9563 *tc9563 = container_of(pwrctrl, struct pci_pwrctrl_tc9563, pwrctrl); - gpiod_set_value(tc9563->reset_gpio, 1); + gpiod_set_value_cansleep(tc9563->reset_gpio, 1); regulator_bulk_disable(ARRAY_SIZE(tc9563->supplies), tc9563->supplies); @@ -520,7 +520,7 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) if (ret < 0) return dev_err_probe(dev, ret, "cannot enable regulators\n"); - gpiod_set_value(tc9563->reset_gpio, 0); + gpiod_set_value_cansleep(tc9563->reset_gpio, 0); fsleep(TC9563_OSC_STAB_DELAY_US); From a22daa226d3ca088fbfad9ab94c57a4ca220bf8d Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Wed, 9 Sep 2026 16:55:55 +0200 Subject: [PATCH 13/20] BACKPORT: PCI/pwrctrl: tc9563: Add GPIO auxiliary device support The TC9563 embeds a GPIO controller used for per-port reset signals. Create an auxiliary device for it so the gpio-tc9563 driver can register the GPIO chip and enable DT-based GPIO lookups. Pass the tc9563 regmap to the auxiliary device as its platform data. The pwrctrl driver does not wait for the GPIO chip to be probed. The per-port reset GPIO lookup, returning -EPROBE_DEFER until the chip is registered, is added in the next patch. Signed-off-by: Lorenzo Bianconi [bhelgaas: squash Geert Uytterhoeven Kconfig fix: https://lore.kernel.org/all/45484c37512a3102495d8b75b6e9f72a141ba42e.1792574560.git.geert+renesas@glider.be, reviewed by Bartosz Golaszewski , acked by Lorenzo Bianconi ] Signed-off-by: Bjorn Helgaas Reviewed-by: Bartosz Golaszewski Reviewed-by: Manivannan Sadhasivam Reviewed-by: Alex Elder Link: https://patch.msgid.link/20260909-pci-tc9563-aux-v5-3-c9b33f56c8d3@oss.qualcomm.com (cherry picked from commit cf3c9cc3c80da7679d52fadcdcd9bafe5929b117) --- drivers/pci/pwrctrl/Kconfig | 1 + drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 80 ++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/drivers/pci/pwrctrl/Kconfig b/drivers/pci/pwrctrl/Kconfig index 1660f28fab80e..a87e2e79ce63c 100644 --- a/drivers/pci/pwrctrl/Kconfig +++ b/drivers/pci/pwrctrl/Kconfig @@ -28,6 +28,7 @@ config PCI_PWRCTRL_TC9563 select PCI_PWRCTRL default m if ARCH_QCOM depends on I2C + select AUXILIARY_BUS select REGMAP_I2C help Say Y here to enable the PCI Power Control driver of TC9563 PCIe diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index 60abbc7de89d4..a42e0ab780606 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -4,12 +4,14 @@ */ #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -19,6 +21,7 @@ #include #include #include +#include #include #include @@ -161,6 +164,8 @@ static const struct reg_sequence dsp2_pwroff_seq[] = { {TC9563_PORT_ACCESS_ENABLE, 0x8}, }; +static DEFINE_IDA(tc9563_pwrctrl_ida); + static int tc9563_pwrctrl_disable_port(struct pci_pwrctrl_tc9563 *tc9563, enum tc9563_pwrctrl_ports port) { @@ -495,6 +500,77 @@ static int tc9563_pwrctrl_parse_device_dt(struct device_node *node, return 0; } +static void tc9563_pwrctrl_adev_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + + ida_free(&tc9563_pwrctrl_ida, adev->id); + of_node_put(adev->dev.of_node); + kfree(adev); +} + +static void tc9563_pwrctrl_adev_remove(void *data) +{ + struct auxiliary_device *adev = data; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +static int tc9563_pwrctrl_adev_add(struct device *dev, const char *name, + struct device_node *of_node, + void *priv_data) +{ + struct auxiliary_device *adev; + int id, ret; + + adev = kzalloc_obj(*adev); + if (!adev) + return -ENOMEM; + + id = ida_alloc(&tc9563_pwrctrl_ida, GFP_KERNEL); + if (id < 0) { + kfree(adev); + return id; + } + + adev->id = id; + adev->name = name; + adev->dev.parent = dev; + adev->dev.platform_data = priv_data; + adev->dev.release = tc9563_pwrctrl_adev_release; + adev->dev.of_node = of_node_get(of_node); + adev->dev.of_node_reused = true; + + ret = auxiliary_device_init(adev); + if (ret) { + ida_free(&tc9563_pwrctrl_ida, id); + of_node_put(adev->dev.of_node); + kfree(adev); + return ret; + } + + ret = auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, tc9563_pwrctrl_adev_remove, adev); +} + +static int tc9563_pwrctrl_add_gpio_adev(struct pci_pwrctrl_tc9563 *tc9563) +{ + struct device *dev = tc9563->pwrctrl.dev; + + if (!of_property_read_bool(dev->of_node, "gpio-controller") || + !of_property_present(dev->of_node, "#gpio-cells")) + return 0; + + return tc9563_pwrctrl_adev_add(dev, TC9563_GPIO_DEV_NAME, dev->of_node, + tc9563->regmap); +} + static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) { struct pci_pwrctrl_tc9563 *tc9563 = container_of(pwrctrl, @@ -719,6 +795,10 @@ static int tc9563_pwrctrl_probe(struct platform_device *pdev) tc9563->pwrctrl.power_on = tc9563_pwrctrl_power_on; tc9563->pwrctrl.power_off = tc9563_pwrctrl_power_off; + ret = tc9563_pwrctrl_add_gpio_adev(tc9563); + if (ret) + goto remove_i2c; + ret = devm_pci_pwrctrl_device_set_ready(dev, &tc9563->pwrctrl); if (ret) goto power_off; From a1ceeaa90089919b2f2a9151254f47d1db4c2a4c Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Wed, 25 Nov 2026 18:40:30 +0530 Subject: [PATCH 14/20] PENDING: PCI/pwrctrl: tc9563: Re-sync endpoint reset GPIO direction after power-on The PCIe host controller driver may request the endpoint reset GPIOs before the switch is powered. gpiolib cannot read their direction then, and refuses to drive a line it does not know to be an output. Now that the switch is accessible and the lines are outputs, make gpiolib read the direction again. Signed-off-by: Hariharan Sreedhar (cherry picked from commit a78a949d23eb7f1e1cca13359e190d94d3c808f3) --- drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c index a42e0ab780606..42fbf1c695013 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -571,6 +572,34 @@ static int tc9563_pwrctrl_add_gpio_adev(struct pci_pwrctrl_tc9563 *tc9563) tc9563->regmap); } +/* + * The PCIe host controller driver may request the endpoint reset GPIOs before + * the switch is powered. gpiolib cannot read their direction then, and refuses + * to drive a line it does not know to be an output. Now that the switch is + * accessible and the lines are outputs, make gpiolib read the direction again. + */ +static void tc9563_pwrctrl_sync_gpio_direction(struct pci_pwrctrl_tc9563 *tc9563) +{ + struct gpio_device *gdev; + struct gpio_desc *desc; + int i; + + gdev = gpio_device_find_by_fwnode(dev_fwnode(tc9563->pwrctrl.dev)); + if (!gdev) + return; + + for (i = 0; i < TC9563_MAX; i++) { + if (tc9563->cfg[i].ep_reset_gpio == TC9563_GPIO_NONE) + continue; + + desc = gpio_device_get_desc(gdev, tc9563->cfg[i].ep_reset_gpio); + if (!IS_ERR(desc)) + gpiod_get_direction(desc); + } + + gpio_device_put(gdev); +} + static int tc9563_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) { struct pci_pwrctrl_tc9563 *tc9563 = container_of(pwrctrl, @@ -682,6 +711,8 @@ static int tc9563_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) goto power_off; } + tc9563_pwrctrl_sync_gpio_direction(tc9563); + return 0; power_off: From 9ed9d6113d22c9d38cbc69f04fc55f8a0bb33cd8 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Wed, 25 Nov 2026 18:41:49 +0530 Subject: [PATCH 15/20] PENDING: PCI: qcom: Allow downstream PCIe devices to provide PERST# GPIOs Create the pwrctrl devices before parsing the Root Port nodes, since a downstream PCIe device (e.g., the TC9563 switch acting as a GPIO controller) may provide the PERST# GPIO for its own downstream ports. Such a provider is not yet powered/probed at the point the RC node's own PERST# is normally requested, so request it with GPIOD_ASIS instead of GPIOD_OUT_HIGH and leave its state untouched until the pwrctrl driver powers the device on and the PCI client driver takes over control of it. Also plug a PHY leak on the parse_perst() failure path in qcom_pcie_parse_port(), and destroy the pwrctrl devices on the corresponding qcom_pcie_probe() error paths. Signed-off-by: Hariharan Sreedhar (cherry picked from commit 93dff6f2a2b5f115c89533072daec6661c52b76a) --- drivers/pci/controller/dwc/pcie-qcom.c | 48 ++++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 9927042741405..f55af1e460ff0 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -1447,16 +1447,10 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp) if (ret) goto err_deinit; - if (!pci->suspended) { - ret = pci_pwrctrl_create_devices(pci->dev); - if (ret) - goto err_disable_phy; - } - if (!pp->skip_pwrctrl_off) { ret = pci_pwrctrl_power_on_devices(pci->dev); if (ret) - goto err_pwrctrl_destroy; + goto err_disable_phy; } if (pcie->cfg->ops->post_init) { @@ -1482,9 +1476,6 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp) err_pwrctrl_power_off: if (!pp->skip_pwrctrl_off) pci_pwrctrl_power_off_devices(pci->dev); -err_pwrctrl_destroy: - if (ret != -EPROBE_DEFER && !pci->suspended) - pci_pwrctrl_destroy_devices(pci->dev); err_disable_phy: qcom_pcie_phy_power_off(pcie); err_deinit: @@ -2195,6 +2186,7 @@ static const struct pci_ecam_ops pci_qcom_ecam_ops = { } }; +/* Check if @node is a child of @dev in DT */ static bool qcom_pcie_is_child_node(struct device *dev, struct device_node *node) { @@ -2220,17 +2212,17 @@ static int qcom_pcie_parse_perst(struct qcom_pcie *pcie, struct qcom_pcie_perst *perst; struct device_node *gpio_np; struct gpio_desc *reset; + enum gpiod_flags flags; int ret; if (!of_find_property(np, "reset-gpios", NULL)) goto parse_child_node; /* - * Skip GPIOs provided by a PCIe device which is a child of the Root - * Complex (e.g., a PCIe switch with GPIO controller capability). Such - * controllers won't be available at RC probe time and their PERST# - * should be controlled by the respective PCI client driver - * implementation. + * GPIOs provided by a PCIe device which is a child of the Root Complex + * (e.g., a PCIe switch with GPIO controller capability) can't be + * accessed at RC probe time, as the device is not powered on yet. Don't + * change their state here. */ gpio_np = of_parse_phandle(np, "reset-gpios", 0); if (!gpio_np) { @@ -2238,14 +2230,11 @@ static int qcom_pcie_parse_perst(struct qcom_pcie *pcie, return -EINVAL; } - if (qcom_pcie_is_child_node(dev, gpio_np)) { - of_node_put(gpio_np); - goto parse_child_node; - } + flags = qcom_pcie_is_child_node(dev, gpio_np) ? GPIOD_ASIS : GPIOD_OUT_HIGH; of_node_put(gpio_np); reset = devm_fwnode_gpiod_get(dev, of_fwnode_handle(np), "reset", - GPIOD_OUT_HIGH, "PERST#"); + flags, "PERST#"); if (IS_ERR(reset)) { /* * FIXME: GPIOLIB currently supports exclusive GPIO access only. @@ -2299,8 +2288,10 @@ static int qcom_pcie_parse_port(struct qcom_pcie *pcie, struct device_node *node INIT_LIST_HEAD(&port->perst); ret = qcom_pcie_parse_perst(pcie, port, node); - if (ret) + if (ret) { + phy_exit(phy); return ret; + } port->phy = phy; INIT_LIST_HEAD(&port->list); @@ -2508,12 +2499,20 @@ static int qcom_pcie_probe(struct platform_device *pdev) pp->ops = &qcom_pcie_dw_ops; + /* + * Create the pwrctrl devices before parsing the ports, as the PERST# + * GPIOs of downstream devices can be provided by them. + */ + ret = pci_pwrctrl_create_devices(dev); + if (ret) + goto err_pm_runtime_put; + ret = qcom_pcie_parse_ports(pcie); if (ret) { if (ret != -ENODEV) { dev_err_probe(pci->dev, ret, "Failed to parse Root Port: %d\n", ret); - goto err_pm_runtime_put; + goto err_pwrctrl_destroy; } /* @@ -2523,7 +2522,7 @@ static int qcom_pcie_probe(struct platform_device *pdev) */ ret = qcom_pcie_parse_legacy_binding(pcie); if (ret) - goto err_pm_runtime_put; + goto err_pwrctrl_destroy; } platform_set_drvdata(pdev, pcie); @@ -2547,6 +2546,9 @@ static int qcom_pcie_probe(struct platform_device *pdev) phy_exit(port->phy); list_del(&port->list); } +err_pwrctrl_destroy: + if (ret != -EPROBE_DEFER) + pci_pwrctrl_destroy_devices(dev); err_pm_runtime_put: pm_runtime_put(dev); pm_runtime_disable(dev); From fad9848c56c5f0389c056d9de82187b458b34756 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Wed, 25 Nov 2026 18:42:48 +0530 Subject: [PATCH 16/20] PENDING: arm64: configs: qcom: Enable TC9563 embedded GPIO controller Enable CONFIG_GPIO_TC9563 so the TC9563 PCIe switch's embedded GPIO controller driver is built on qcom platforms using this defconfig. Signed-off-by: Hariharan Sreedhar (cherry picked from commit 97da98f70df10077bdb0578c38bf5bd18047e557) --- arch/arm64/configs/qcom.config | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/qcom.config b/arch/arm64/configs/qcom.config index 6beb24d2b71bb..3baf636808daf 100644 --- a/arch/arm64/configs/qcom.config +++ b/arch/arm64/configs/qcom.config @@ -38,6 +38,7 @@ CONFIG_EDAC_QCOM=m CONFIG_EXPERT=y CONFIG_FW_LOADER_COMPRESS=y CONFIG_FW_LOADER_COMPRESS_ZSTD=y +CONFIG_GPIO_TC9563=y CONFIG_GUNYAH_WATCHDOG=y CONFIG_I2C_QCOM_GENI=y CONFIG_I6300ESB_WDT=y From 38267ee23cb40173a0c4eacb4fa32d9d52289f78 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Wed, 25 Nov 2026 18:49:09 +0530 Subject: [PATCH 17/20] PENDING: arm64: dts: qcom: talos-lyra-evk: Use TC9563 embedded GPIO controller for EP reset Mark the tc9563 switch's pcie@0,0 node as a gpio-controller so its downstream ports can describe their endpoint reset lines with the standard reset-gpios property, instead of the vendor-specific ep-reset-gpio property that pci-pwrctrl-tc9563.c no longer consumes for pcie@1,0's endpoint. Add reset-gpios to pcie@1,0 and pcie@2,0, and drop the now-redundant ep-reset-gpio from pcie@1,0. Signed-off-by: Hariharan Sreedhar (cherry picked from commit d167e87c0034683f36a9b7dd1ad6334e4245fa1b) --- arch/arm64/boot/dts/qcom/talos-lyra-evk.dts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts b/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts index 29bb654cc8b03..b443504ee5735 100644 --- a/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts +++ b/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts @@ -292,6 +292,7 @@ reg = <0x10000 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; + gpio-controller; #gpio-cells = <2>; device_type = "pci"; ranges; @@ -321,7 +322,7 @@ bus-range = <0x3 0xff>; ep-pwr-en-gpio = <&tc9563 2 GPIO_ACTIVE_HIGH>; - ep-reset-gpio = <&tc9563 5 GPIO_ACTIVE_HIGH>; + reset-gpios = <&tc9563 5 GPIO_ACTIVE_LOW>; port { tc9563_pcie1_ep: endpoint {}; @@ -338,6 +339,7 @@ ep-pwr-en-gpio = <&tc9563 4 GPIO_ACTIVE_HIGH>; ep-reset-gpio = <&tc9563 3 GPIO_ACTIVE_HIGH>; + reset-gpios = <&tc9563 3 GPIO_ACTIVE_LOW>; }; pcie@3,0 { From 5c154fb8e3c79e4736235dc8b0fc1b4933fbffd1 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Wed, 25 Nov 2026 18:50:54 +0530 Subject: [PATCH 18/20] PENDING: dt-bindings: PCI: toshiba,tc9563: Document reset-gpios and gpio-controller usage Document the standard reset-gpios property for downstream ports, used by pci-pwrctrl-tc9563.c to drive the endpoint reset line through the TC9563 embedded GPIO controller. Update the example to mark pcie@0,0 as a gpio-controller, drop the stray duplicate gpio-controller/#gpio-cells pair and the tc9563 label on the outer pcie@0 node, and remove the now-redundant ep-reset-gpio from the pcie@2,0 example. Signed-off-by: Hariharan Sreedhar (cherry picked from commit 974b63200bccd1718486fb839e24c25567ac1416) --- .../devicetree/bindings/pci/toshiba,tc9563.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml index 1bd066a5bbc29..e2043ce6e0fb0 100644 --- a/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml +++ b/Documentation/devicetree/bindings/pci/toshiba,tc9563.yaml @@ -79,6 +79,14 @@ $defs: Specify the TC9563 GPIO used to reset the endpoint connected to the particular TC9563 downstream port. + reset-gpios: + maxItems: 1 + description: + TC9563 GPIO, provided by the embedded GPIO controller, that + resets the endpoint connected to the downstream port. The PCIe + host controller drives it together with its own PERST# when it + keeps the switch powered across system suspend. + ep-pwr-en-gpio: description: Specify the TC9563 GPIO used for enabling power to @@ -120,7 +128,7 @@ examples: #address-cells = <3>; #size-cells = <2>; - tc9563: pcie@0 { + pcie@0 { device_type = "pci"; reg = <0x0 0x0 0x0 0x0 0x0>; @@ -136,6 +144,7 @@ examples: device_type = "pci"; #address-cells = <3>; #size-cells = <2>; + gpio-controller; #gpio-cells = <2>; ranges; bus-range = <0x02 0xff>; @@ -151,9 +160,6 @@ examples: resx-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; - gpio-controller; - #gpio-cells = <2>; - pcie@1,0 { compatible = "pciclass,0604"; reg = <0x20800 0x0 0x0 0x0 0x0>; @@ -178,7 +184,6 @@ examples: bus-range = <0x04 0xff>; ep-pwr-en-gpio = <&tc9563 2 GPIO_ACTIVE_HIGH>; - ep-reset-gpio = <&tc9563 5 GPIO_ACTIVE_HIGH>; }; pcie@3,0 { From 7a57869d1cae9787683ca672cb1ec1747a320892 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Thu, 26 Nov 2026 10:18:02 +0530 Subject: [PATCH 19/20] PENDING: arm64: dts: qcom: talos-lyra-evk: Disable ASPM L1 for TC9563 PCIe ports The TC9563 PCIe switch and its three downstream endpoint ports on the talos-lyra-evk board require ASPM L1 to be fully disabled to avoid link instability caused by board-level connectivity constraints. Add 'aspm-no-l1' to the TC9563 root port (pcie@0,0) and its three downstream child nodes (pcie@1,0, pcie@2,0, pcie@3,0) so the ASPM driver masks L1 and all L1 PM Substates for those links during link initialisation. This DT change depends on: PCI/ASPM: Mask ASPM states based on Devicetree properties https://lore.kernel.org/all/20260727-aspm-v6-0-2ebb3ee7ef71@oss.qualcomm.com/ CRs-Fixed: 4723173 Signed-off-by: Ziyue Zhang Signed-off-by: Hariharan Sreedhar (cherry picked from commit 941af772a667afc75d9ff4b32caf8f627d6aef43) --- arch/arm64/boot/dts/qcom/talos-lyra-evk.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts b/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts index b443504ee5735..e849674675f7e 100644 --- a/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts +++ b/arch/arm64/boot/dts/qcom/talos-lyra-evk.dts @@ -298,6 +298,8 @@ ranges; bus-range = <0x2 0xff>; + aspm-no-l1; + vddc-supply = <&vreg_0p9>; vdd18-supply = <&vreg_1p8>; vdd09-supply = <&vreg_0p9>; @@ -321,6 +323,8 @@ ranges; bus-range = <0x3 0xff>; + aspm-no-l1; + ep-pwr-en-gpio = <&tc9563 2 GPIO_ACTIVE_HIGH>; reset-gpios = <&tc9563 5 GPIO_ACTIVE_LOW>; @@ -337,6 +341,8 @@ ranges; bus-range = <0x4 0xff>; + aspm-no-l1; + ep-pwr-en-gpio = <&tc9563 4 GPIO_ACTIVE_HIGH>; ep-reset-gpio = <&tc9563 3 GPIO_ACTIVE_HIGH>; reset-gpios = <&tc9563 3 GPIO_ACTIVE_LOW>; @@ -350,6 +356,8 @@ ranges; bus-range = <0x5 0xff>; + aspm-no-l1; + pci@0,0 { reg = <0x50000 0x0 0x0 0x0 0x0>; #address-cells = <3>; From 6ab468371ba062ea751a3201b9e4d4bfb9341bd8 Mon Sep 17 00:00:00 2001 From: Hariharan Sreedhar Date: Fri, 27 Nov 2026 10:14:04 +0530 Subject: [PATCH 20/20] PENDING: arm64: dts: qcom: talos-lyra-evk: Move PCIe wake-gpios to root port and fix polarity Move the wake-gpios property from the top-level &pcie controller node to the &pcie_port0 root port node, and correct its polarity from GPIO_ACTIVE_HIGH to GPIO_ACTIVE_LOW to match the board schematic. Signed-off-by: Hariharan Sreedhar --- arch/arm64/boot/dts/qcom/talos-lyra-evk-som.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/talos-lyra-evk-som.dtsi b/arch/arm64/boot/dts/qcom/talos-lyra-evk-som.dtsi index 29232c2a9b183..d031b40be2203 100644 --- a/arch/arm64/boot/dts/qcom/talos-lyra-evk-som.dtsi +++ b/arch/arm64/boot/dts/qcom/talos-lyra-evk-som.dtsi @@ -380,8 +380,6 @@ }; &pcie { - wake-gpios = <&tlmm 100 GPIO_ACTIVE_HIGH>; - iommu-map = <0x0 &apps_smmu 0x400 0x1>, <0x100 &apps_smmu 0x401 0x1>, <0x208 &apps_smmu 0x402 0x1>, @@ -395,6 +393,10 @@ status = "okay"; }; +&pcie_port0 { + wake-gpios = <&tlmm 100 GPIO_ACTIVE_LOW>; +}; + &pcie_phy { vdda-phy-supply = <&vreg_l5a>; vdda-pll-supply = <&vreg_l12a>;