net: enable TC956x support
Subsystems (13)
v2 cover net: enable TC956x support
(A fairly detailed list of changes since v1 is included below. Because there are so many changes listed, they are not repeated in the individual patches that follow. Note also that this series depends on two prerequisite commits, as explained below.)
This series introduces stmmac driver support for the Toshiba TC9564 (also known as Qualcomm QPS615). This is an Ethernet-AVB/TSN bridge IC that provides a high-speed connection between a host SoC and Ethernet devices on a network. It incorporates a PCIe switch, and implements two 10 Gbps capable Ethernet MACs (along with other IP blocks), and is essentially a small and highly-specialized SoC. The TC9564 is a member of a family of similar chips, and the driver code uses "tc956x" to reflect this.
TC956x chips incorporate a PCIe gen 3 switch, with one upstream and three downstream ports. Its PCIe functionality is already supported upstream, including a power control driver that performs some early configuration of the PCI ports ("pci-pwrctrl-tc9563.c").
One of the PCIe switch's downstream ports has an internal PCIe endpoint, which implements two PCIe functions, each of which has an Ethernet MAC (eMAC) subsystem. The eMAC is composed of a Synopsis Designware XGMAC combined with an XPCS and PMA. Each MAC is capable of operating at 10M/100M/1G/2.5G/5Gps and 10Gps. The initial target platform is the Qualcomm RB3gen2, which supports a 10Gbps Marvell PHY on port A, and a 2.5Gbps Qualcomm PHY on port B. (The Marvell PHY is not populated on all RB3gen2 boards, and only the 2.5 Gbps Qualcomm PHY is supported initially.)
TC956x chips also implement several other blocks of functionality, including a GPIO controller, interrupt controllers (MSIGEN), I2C and SPI, a UART, and an Arm Cortex M3 CPU with 128KB SRAM. The GPIO interface exposes several lines to manage external resets. The interrupt controllers are used internally by the eMAC functions. The UART, SPI, microcontroller, and SRAM are currently unused.
----------------------------------
| Host |
------+...+----------+........+---
|i2c| | PCIe |
----------------+...+----------+........+------
| TC956x |I2C| |upstream| |
| ----- --+--------+--- |
| ----- ------ ------- | PCIe switch | |
| |SPI| |GPIO| |reset| | | |
| ----- ------ |clock| | DS3 DS2 DS1 | |
| ------- ---++--++--++-- |
| ----- ------ downstream// \\ \\ | downstream
| |MCU| |SRAM| /==========/ \\ \===== PCIe port 1
| ----- ------ //PCIe port 3 \\ |
| || \======= downstream
| ----+-----------++-----------+---- | PCIe port 2
| | M | internal PCIe endpoint | M | |
| | S |------------------------| S | ------ |
| | I | PCIe | | PCIe | I | |UART| |
| | G |function 0| |function 1| G | ------ |
| | E |----++----| |----++----| E | |
| | N | eMAC 0 | | eMAC 1 | N | |
--------+.......+------+.....+-----------------
|USXGMII| |SGMII|
--+.......+-- --+.....+--
| ARQ113C | | QEP8121 |
| PHY | | PHY |
------------- -----------The primary objective for this series is to support the Ethernet functionality provided by the TC956x. The code providing this support has been structured into three distinct modules.
- A "chip" driver, associated with the PCIe functions
- A driver for the GPIO controller
- Code enabling the TC956x-specific eMAC/MSIGEN hardware
To manage the common functionality (including configuring address translation and controlling internal reset and clock signals), a "chip" driver is implemented. The chip driver binds to PCI functions 0 and 1, and creates a shared data structure describing the common chip elements shared by the two driver instances. PCIe function 1 defers probing until after PCIe function 0 has created this shared data structure.
Common/shared functionality is handled by PCIe function 0. This common code uses PCIe function 0's mapped BARs to configure the hardware. If the TC9564 GPIO controller is needed (i.e., defined in a node in devicetree), it is created as an auxiliary device when PCIe function 0 is probed.
Both PCIe function 0 and function 1 implement an Ethernet controller as well, though one or the other might be unused on a given platform. If a PCIe function node defines an ethernet subnode in devicetree, the corresponding eMAC is enabled, and the PCIe function driver will create an auxiliary device to represent it.
The GPIO driver is implemented separately because in some hardware configurations, these GPIO lines are used to manage resets for external Ethernet PHYs. We describe these PHYs via devicetree, where the GPIO-based reset signals are defined using phandles.
The code for eMAC and MSIGEN consists of a new source file that populates hardware-specific details about the two MACs, and integrates with the existing stmmac driver. This also required implementing some enhancements to the core stmmac driver, described further below.
The version of the Synopsys MAC IP is 3.01, which is largely compatible with version 2.20. The core stmmac driver required several changes to enable support for the TC956x.
- A change to dwxgmac2 support changes the interrupt mode when multi_msi_en is enabled.
- While most support for version 3.01 simply uses the 2.20 code, an erratum related to the RX ring length is implemented for 3.01 DMA operations.
- Having the PCIe device be separate from an auxiliarly device implementing the eMAC required allowing a distinct DMA device to be maintained for an stmmac interface.
In addition:
- A new source file provides memory-mapped access to XPCS using regmap. The alignment of the TC956x MDIO registers aren't suitable for using simple MMIO.
- Two additional XPCS changes are implemented that provides support for the XPCS as implemented in the TC956x.
NOTE:
This series is based on net-next/main, but depends on these two commits found in linux-next/master:
68d801eabda52 gpio: regmap: Support sparsed fixed direction 806e7acf7f331 gpio: regmap: Don't set a fixed direction line
-Alex (and Daniel)
This series is available here:
https://github.com/riscstar/linux/tree/tc956x/stmmac-v2
Changes between version 1 and version 2:
NEW
- The qca808x.c PHY driver now supports enabling up to four optional regulators
GENERAL
- The order of patches has been rearranged a bit. One consequence is that the TOSHIBA_TC956X_PCI Kconfig symbol is now defined before it's used.
PATCH 00/12
- MAINTAINERS entries have been added for all new files
PATCH 01/12
- devm_xpcs_regmap_register() now ensures the xpcs_destroy() is called when the device is unbound (suggested by Sashiko).
PATCH 02/12
- Reworked how the quirky behavior was handled. Now:
- A soft reset is issued in xpcs_pre_config() *before* calling xpcs_switch_interface_mode() calls txgbe_xpcs_switch_mode(). It does this now for an SGMII interface, not just if the need-reset flag is set
- xpcs_switch_interface_mode() calls txgbe_xpcs_switch_mode(), preserving previous behavior
- For other (non-Wangxun) platforms, if the XPCS supports 10Gbase-R, xpcs_switch_interface_mode() programs the interface operating mode to use a reserved value rather than the default
PATCH 03/12
- This change has been removed; the default_an_inband platform data flag is set instead (in what was previously patch 10)
PATCH 04/12
- Two issues were pointed out by Sashiko, both of which were problems related to DMA handling. They were pre-existing issues, and I plan to send separate patches to address them.
- A mask local variable (to shorten a long line) is no longer created. Checkpatch no longer complains about that line.
PATCH 05/12
- The description was clarified a bit in response to a comment from Andrew
PATCH 06/12
- No comments received, no changes
PATCH 07/12
- Sashiko suggested that exporting some symbols from the stmmac core might not be desirable, and suggested using the standard DMA API to accomplish the same thing. For now we are igoring this suggestion--not finding a way to do what was suggested.
PATCH 08/12
- The description has been revised to focus on the hardware and not the "node".
- The ASCII art (copied from below) has been incorporated into the binding
- The file name has been changed to "toshiba,tc9564-dwmac.yaml" and the $id value matches the file name
- Only one example is provided now
- The references and unevaluatedProperties have been moved later in the file
- We no longer reference "pci-bus-common.yaml". We are describing a device, not a bridge.
- Subnodes have been added to represent the GPIO controller (on PCIe function 0) and the Ethernet interfaces (possible on PCIe functions 0 and 1).
PATCH 09/12
- The GPIO controller is now implemented using regmap-gpio
- The Kconfig entry for the GPIO driver has been updated to select GPIO_REGMAP, and to define its default value as "m" unconditionally
- The Kconfig entry is now defined in the memory-mapped GPIO section
- The regmap use has been adjusted so it's clear it is MMIO-based, which normally does not require error checking.
- We no longer call drv_get_drvdata()
PATCH 10/12
- The name of the IRQ domain now includes the MAC ID (0 or 1)
- SP_SEL_SGMII_2500M is now named SP_SEL_2500BASEX
- A typo in the commit has been fixed, and the error check after creating the RX IRQ mapping now checks the right pointer for an error
- The Kconfig entry now selects GENERIC_IRQ_CHIP
- The PHY interface is now taken into account in the fix_max_speed callback
- We now check the correct pointer for an error when creating the RX IRQ mappings
- We are not implementing a shutdown driver callback
- Xilin has other discussion related to WoL, which we should save and use, but we're not acting on it now.
- In four function, Sashiko noted that a 32-bit dma_addr_t can't hold
TC956X_SLV00_SRC_ADDR, so the type of local variable has been changed
to be u64: tc956x_dma_init_rx_chan(), tc956x_dma_init_tx_chan(),
tc956x_desc_set_addr(), and tc956x_desc_set_sec_addr(). - tc956x_mac_disable() is now called if stmmac_dvr_probe() fails; suggested by Sashiko.
- Sashiko noted the MDIO device tree node was being leaked. This has been resolved.
- Sashiko also pointed out that IRQ mappings were not being freed, and this too is fixed.
PATCH 11/12
- The reset and clock functions are no longer defined inline
- The REFCLK clock name has been renamed REFCLKO, and a comment has been added to explain it is an (unused) output clock.
- If the PCI device has no DT node it is reported with dev_err().
- <linux/bitfield.h> is now included, to avoid errors in various non-Arm64 builds.
- The devicetree Ethernet node is no longer leaked in adev_device_add() (noticed by Sashiko).
- The Kconfig entry now depends on ARM64 or COMPILE_TEST
- The Kconfig entry now selects REGMAP and REGMAP_MMIO
- Sashiko reported that the reference count on the PCIe slot for function 0 was being leaked. This has been fixed.
- Sashiko questioned whether the cleanup action to delete
a created device link was associated with the wrong device. It was, and this has been fixed.
- Sashiko also suggested that the allocated PCI IRQ vector was not properly getting removed. It now is.
- Sashiko suggested that function 1 might proceed with probing even though there was still a chance that function 0's probe failed. The platform_data pointer that function 1 uses to decide it's OK to probe is now assigned later.
PATCH 12/12
- The PHY interrupt is now defined as a level interrupt.
- A typo in the PHY name has been corrected in the patch description
Here is the initial version of the series.
https://lore.kernel.org/netdev/[email protected]/
Alex Elder (3):
net: stmmac: dma: create a separate dma_device pointer
misc: tc956x_pci: add TC956x/QPS615 support
gpio: tc956x: add TC956x/QPS615 support
Daniel Thompson (11):
dt-bindings: net: qca,qca808x: Add regulator properties
net: phy: qcom: qca808x: Add regulator management
net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via
regmap
net: pcs: xpcs: re-order xpcs_pre_config() to update after the reset
net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
net: stmmac: dwxgmac2: Add multi MSI interrupt mode
net: stmmac: dwxgmac2: Add XGMAC 3.01a support
net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA
dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
net: stmmac: tc956x: add TC956x/QPS615 support
arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081
phy
.../devicetree/bindings/net/qca,qca808x.yaml | 14 + .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 +++ MAINTAINERS | 12 + arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 48 + drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++ drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/tc956x_pci.c | 741 ++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../net/ethernet/stmicro/stmmac/chain_mode.c | 12 +- .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 12 + .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 79 +- .../net/ethernet/stmicro/stmmac/ring_mode.c | 12 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 58 +- .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 2 +- drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-regmap.c | 219 +++++ drivers/net/pcs/pcs-xpcs.c | 93 +- drivers/net/phy/qcom/qca808x.c | 30 + include/linux/pcs/pcs-xpcs-regmap.h | 20 + include/linux/stmmac.h | 1 + include/soc/toshiba/tc956x-dwmac.h | 84 ++ 29 files changed, 2478 insertions(+), 76 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml create mode 100644 drivers/gpio/gpio-tc956x.c create mode 100644 drivers/misc/tc956x_pci.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c create mode 100644 drivers/net/pcs/pcs-xpcs-regmap.c create mode 100644 include/linux/pcs/pcs-xpcs-regmap.h create mode 100644 include/soc/toshiba/tc956x-dwmac.h
base-commit: 07c4bca9d92e51ab6b46797a86c6ea559812351a
Signature · 1 line
2.51.0
PATCH v2 1/14 dt-bindings: net: qca,qca808x: Add regulator properties
From: Daniel Thompson <[email protected]>
QCA808x has four different power rails (although in many board designs the different rails share a regulator). Add each of these supplies to the corresponding DT binding.
--- .../devicetree/bindings/net/qca,qca808x.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/net/qca,qca808x.yaml +14 -0
@@ -25,6 +25,18 @@ properties: enum: - ethernet-phy-id004d.d101 + avdd18-supply: + description: 1.8v analog power supply. + + vdd-supply: + description: 1.05v power supply. + + vdd18-supply: + description: 1.8v power supply. + + vdd125-supply: + description: (1.25v to 1.98v) LDO regulator power supply. + unevaluatedProperties: false examples:
@@ -39,6 +51,8 @@ examples: compatible = "ethernet-phy-id004d.d101"; reg = <0>; + vdd-supply = <&phy_vreg_1v8>; + leds { #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 01/14] dt-bindings: net: qca,qca808x: Add regulator properties
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The device tree example incorrectly assigns a 1.8V regulator phandle to a 1.05V supply property. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The device tree example incorrectly assigns a 1.8V regulator phandle to a 1.05V supply property. --
commit 9408235f22241ddbd72a22ee2611a98eece3d7f2
Author: Daniel Thompson <[email protected]>
dt-bindings: net: qca,qca808x: Add regulator properties
This commit adds four power rail supply properties (avdd18, vdd, vdd18, and vdd125) to the QCA808x ethernet PHY device tree binding. It also updates the example section to demonstrate how to configure the power supplies.
Quoted 4 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +0
-0
[ ... ]
Quoted 10 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +6
-0@@ -25,6 +25,18 @@ properties: enum: - ethernet-phy-id004d.d101 + avdd18-supply: + description: 1.8v analog power supply. + + vdd-supply: + description: 1.05v power supply. +
[ ... ]
Documentation/devicetree/bindings/net/qca,qca808x.yaml examples: · line 55
Quoted 6 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +2
-0@@ -39,6 +51,8 @@ examples: compatible = "ethernet-phy-id004d.d101"; reg = <0>; + vdd-supply = <&phy_vreg_1v8>; +
[Severity: Low]
Is this the intended phandle for the vdd-supply property in this example?
The property description defines vdd-supply as a 1.05v power supply, but the example assigns what appears to be a 1.8v regulator (&phy_vreg_1v8) to it. Could this discrepancy lead developers to copy-paste an overvoltage configuration into their actual board device trees?
Quoted 3 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +0
-0leds { #address-cells = <1>; #size-cells = <0>;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH net-next v2 01/14] dt-bindings: net: qca,qca808x: Add regulator properties
Quoted 3 lines · On 6/5/26 8:01 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The device tree example incorrectly assigns a 1.8V regulator phandle to a 1.05V supply property. --
Impressive catch. This will be fixed in the next version.
-Alex
Quoted 44 lines
commit
9408235f22241ddbd72a22ee2611a98eece3d7f2
Author: Daniel Thompson <[email protected]>dt-bindings: net: qca,qca808x: Add regulator properties
This commit adds four power rail supply properties (avdd18, vdd, vdd18, and vdd125) to the QCA808x ethernet PHY device tree binding. It also updates the example section to demonstrate how to configure the power supplies.
Quoted 4 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +0
-0[ ... ]
Quoted 10 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +6
-0@@ -25,6 +25,18 @@ properties: enum: - ethernet-phy-id004d.d101 + avdd18-supply: + description: 1.8v analog power supply. + + vdd-supply: + description: 1.05v power supply. +[ ... ]
Documentation/devicetree/bindings/net/qca,qca808x.yaml examples: · line 55
Quoted 6 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +2
-0@@ -39,6 +51,8 @@ examples: compatible = "ethernet-phy-id004d.d101"; reg = <0>; + vdd-supply = <&phy_vreg_1v8>; +[Severity: Low]
Is this the intended phandle for the vdd-supply property in this example?The property description defines vdd-supply as a 1.05v power supply, but the example assigns what appears to be a 1.8v regulator (
&phy_vreg_1v8) to it. Could this discrepancy lead developers to copy-paste an overvoltage configuration into their actual board device trees?Quoted 3 lines
Documentation/devicetree/bindings/net/qca,qca808x.yaml +0
-0leds { #address-cells = <1>; #size-cells = <0>;
PATCH v2 2/14 net: phy: qcom: qca808x: Add regulator management
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
QCA8081 appears in embedded board designs paired with GPIO controlled regulators for its power rails. Add logic to allow these regulators to be turned on during a probe.
In order to avoid the complexity of tracking state for suspend with and without WoL we take a tremendously simple "always-on" approach to regulator management, essentially relying on BMCR_PDOWN to conserve power when the phy device exists.
--- drivers/net/phy/qcom/qca808x.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/net/phy/qcom/qca808x.c +30 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ #include <linux/phy.h> +#include <linux/regulator/consumer.h> #include <linux/module.h> #include "qcom.h"
@@ -178,15 +179,44 @@ static void qca808x_fill_possible_interfaces(struct phy_device *phydev)__set_bit (PHY_INTERFACE_MODE_2500BASEX , possible); } +static int qca808x_power_on (struct phy_device *phydev) +{ +#ifdef CONFIG_OF +static const char *const regulator_names[] = { +"avdd18" ,"vdd" ,"vdd18" ,"vdd125" + }; +struct device *dev = &phydev->mdio.dev; +u32 count =0 ; +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (regulator_names); i++) { + ret =devm_regulator_get_enable_optional (dev, regulator_names[i]); +if (!ret) + count++; +else if (ret != -ENODEV ) +return ret; + } + +if (count) +fsleep (phydev->mdio.reset_assert_delay); +#endif +return 0 ; +} +static int qca808x_probe (struct phy_device *phydev) {struct device *dev = &phydev->mdio.dev;struct qca808x_priv *priv; +int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; + ret =qca808x_power_on (phydev); +if (ret) +return ret; +/* Init LED polarity mode to -1 */ priv->led_polarity_mode =-1 ;
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 02/14] net: phy: qcom: qca808x: Add regulator management
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The PHY regulators are enabled during `probe()` without re-triggering a hardware reset, violating…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The PHY regulators are enabled during probe() without re-triggering a hardware reset, violating power-on sequencing, and the code incorrectly repurposes the MDIO reset_assert_delay as a post-power-on stabilization delay. --
commit 7b9b83105850db948e3794f9c1593ea2fbeac999
Author: Daniel Thompson <[email protected]>
net: phy: qcom: qca808x: Add regulator management
This commit adds optional regulator management to the QCA8081 PHY driver. It attempts to enable the regulators during the probe sequence.
Quoted 4 lines
drivers/net/phy/qcom/qca808x.c +0
-0
[ ... ]
Quoted 14 lines
drivers/net/phy/qcom/qca808x.c +10
-0@@ -178,15 +179,44 @@ static void qca808x_fill_possible_interfaces(struct phy_device *phydev)__set_bit (PHY_INTERFACE_MODE_2500BASEX , possible); } +static int qca808x_power_on (struct phy_device *phydev) +{ +#ifdef CONFIG_OF +static const char *const regulator_names[] = { +"avdd18" ,"vdd" ,"vdd18" ,"vdd125" + }; +struct device *dev = &phydev->mdio.dev; +u32 count =0 ; +int i, ret; +
drivers/net/phy/qcom/qca808x.c static void qca808x_fill_possible_interfaces(struct phy_device *phydev) · line 201
Quoted 10 lines
drivers/net/phy/qcom/qca808x.c +10
-0+for (i =0 ; i <ARRAY_SIZE (regulator_names); i++) { + ret =devm_regulator_get_enable_optional (dev, regulator_names[i]); +if (!ret) + count++; +else if (ret != -ENODEV ) +return ret; + } + +if (count) +fsleep (phydev->mdio.reset_assert_delay);
[Severity: High]
Does this apply power to the PHY without re-asserting the hardware reset line?
The Linux PHY framework pulses the hardware reset line (asserting and then deasserting via phy_device_reset()) during device registration, which happens before the driver's probe callback is invoked. By enabling the regulators here inside probe(), power is applied while the reset line is already deasserted, which violates standard hardware power-on sequencing and can leave the PHY in an undefined or unstable state.
Additionally, is it safe to repurpose the MDIO reset_assert_delay for this settling time?
This uses the reset-assert-us device tree property (meant to dictate the minimum active pulse width of the reset signal) as a post-power-on settling delay. If a board's device tree lacks a reset-assert-us property, reset_assert_delay will be 0, causing fsleep(0) to return immediately. The lack of a proper stabilization delay could cause subsequent MDIO accesses to fail.
Quoted 18 lines
drivers/net/phy/qcom/qca808x.c +9
-0+#endif +return 0 ; +} +static int qca808x_probe (struct phy_device *phydev) {struct device *dev = &phydev->mdio.dev;struct qca808x_priv *priv; +int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; + ret =qca808x_power_on (phydev); +if (ret) +return ret; +
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Linus Walleij
maintainerRe: [PATCH net-next v2 02/14] net: phy: qcom: qca808x: Add regulator management
In reply to Alex ElderHi Alex/Daniel,
thanks for your patch!
Quoted 13 lines · Alex Elder
From: Daniel Thompson <[email protected]>
QCA8081 appears in embedded board designs paired with GPIO controlled regulators for its power rails. Add logic to allow these regulators to be turned on during a probe.
In order to avoid the complexity of tracking state for suspend with and without WoL we take a tremendously simple "always-on" approach to regulator management, essentially relying on
BMCR_PDOWNto conserve power when the phy device exists.Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>
(...)
Quoted 1 line
+#ifdef
CONFIG_OF
Is this an extremely footprint-sensitive system?
Regulators provide small stubs if unused, I don't know if they compile to zero bytes but this ifdeffery should normally not be necessary, just unconditionally get_enable the regulators.
Yours,
Linus Walleij
PATCH v2 3/14 net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
In some DesignWare XPCS implementatons the memory-mapped MDIO bus is allocated to a register window that does not align to a page boundary. This makes iomapping the registers problematic.
For example the Toshiba TC9564 (a PCIe Ethernet-AVB/TSN bridge) provides an "eMAC" subsystem with the XPCS base address cuddled up to XGMAC registers.
Let's introduce helpers to allow the driver that owns the eMAC to register an XPCS using is regmap for the memory-mapped MDIO bus.
--- MAINTAINERS | 2 + drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-regmap.c | 219 ++++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs-regmap.h | 20 +++ 4 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs-regmap.c create mode 100644 include/linux/pcs/pcs-xpcs-regmap.h
MAINTAINERS +2 -0
@@ -25931,8 +25931,10 @@ F: drivers/net/ethernet/synopsys/ SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER L: [email protected] S: Orphan +F: drivers/net/pcs/pcs-xpcs-regmap.c F: drivers/net/pcs/pcs-xpcs.c F: drivers/net/pcs/pcs-xpcs.h +F include/linux/pcs/pcs-xpcs-regmap.h F: include/linux/pcs/pcs-xpcs.h SYNOPSYS DESIGNWARE HDMI RX CONTROLLER DRIVER
drivers/net/pcs/Makefile +2 -2
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers -pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \ - pcs-xpcs-nxp.o pcs-xpcs-wx.o +pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-regmap.o \ + pcs-xpcs-plat.o pcs-xpcs-wx.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o
drivers/net/pcs/pcs-xpcs-regmap.c new file +219 -0
219 lines not on this page · raw message
include/linux/pcs/pcs-xpcs-regmap.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __LINUX_PCS_XPCS_REGMAP_H +#define __LINUX_PCS_XPCS_REGMAP_H + +#include <linux/types.h> + +struct device ; +struct regmap ; +struct dw_xpcs ; + +struct xpcs_regmap_config { +struct regmap *regmap; +bool reg_indir; +}; + +struct dw_xpcs *devm_xpcs_regmap_register ( +struct device *dev,const struct xpcs_regmap_config *config); + +#endif /* __LINUX_PCS_XPCS_REGMAP_H */
Signature · 1 line
2.51.0
Maxime Chevallier
maintainerRe: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
Hi Alex,
Quoted 231 lines · Alex Elder
From: Daniel Thompson <[email protected]>
In some DesignWare XPCS implementatons the memory-mapped MDIO bus is allocated to a register window that does not align to a page boundary. This makes iomapping the registers problematic.
For example the Toshiba TC9564 (a PCIe Ethernet-AVB/TSN bridge) provides an "eMAC" subsystem with the XPCS base address cuddled up to XGMAC registers.
Let's introduce helpers to allow the driver that owns the eMAC to register an XPCS using is regmap for the memory-mapped MDIO bus.
Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 2 + drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-regmap.c | 219 ++++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs-regmap.h | 20 +++ 4 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs-regmap.c create mode 100644 include/linux/pcs/pcs-xpcs-regmap.hMAINTAINERS +2
-0@@ -25931,8 +25931,10 @@ F: drivers/net/ethernet/synopsys/ SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER L: [email protected] S: Orphan +F: drivers/net/pcs/pcs-xpcs-regmap.c F: drivers/net/pcs/pcs-xpcs.c F: drivers/net/pcs/pcs-xpcs.h +F include/linux/pcs/pcs-xpcs-regmap.h F: include/linux/pcs/pcs-xpcs.h SYNOPSYS DESIGNWARE HDMI RX CONTROLLER DRIVERdrivers/net/pcs/Makefile +2
-2@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers -pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-plat.o \ - pcs-xpcs-nxp.o pcs-xpcs-wx.o +pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o pcs-xpcs-regmap.o \ + pcs-xpcs-plat.o pcs-xpcs-wx.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.odrivers/net/pcs/pcs-xpcs-regmap.c new file +171
-0@@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Synopsys DesignWare XPCS regmap helpers +* +* Copyright (C) 2026 RISCstar Solutions. +* Copyright (C) 2024 Serge Semin +*/ + +#include <linux/device.h> +#include <linux/kernel.h> +#include <linux/mdio.h> +#include <linux/pcs/pcs-xpcs.h> +#include <linux/pcs/pcs-xpcs-regmap.h> +#include <linux/regmap.h> + +#include "pcs-xpcs.h" + +/* Page select register for the indirect MMIO CSRs access */ +#define DW_VR_CSR_VIEWPORT 0xff + +struct dw_xpcs_regmap { +struct device *dev; +struct mii_bus *bus; +struct regmap *regmap; +bool reg_indir; +}; + +static ptrdiff_t xpcs_regmap_addr_format (int dev,int reg) +{ +return FIELD_PREP (0x1f0000 , dev) |FIELD_PREP (0xffff , reg); +} + +static u16 xpcs_regmap_addr_page (ptrdiff_t csr) +{ +return FIELD_GET (0x1fff00 , csr); +} + +static ptrdiff_t xpcs_regmap_addr_offset (ptrdiff_t csr) +{ +return FIELD_GET (0xff , csr); +} + +static int xpcs_regmap_read_reg_indirect (struct dw_xpcs_regmap *pxpcs,int dev, +int reg) +{ +ptrdiff_t csr, ofs; +unsigned int val; +u16 page; +int res; + + csr =xpcs_regmap_addr_format (dev, reg); + page =xpcs_regmap_addr_page (csr); + ofs =xpcs_regmap_addr_offset (csr); + + res =regmap_write (pxpcs->regmap,DW_VR_CSR_VIEWPORT , page); +if (res <0 ) +return res; + + res =regmap_read (pxpcs->regmap, ofs, &val); +if (res <0 ) +return res; + +return val &0xffff ; +} + +static int xpcs_regmap_write_reg_indirect (struct dw_xpcs_regmap *pxpcs,int dev, +int reg,u16 val) +{ +ptrdiff_t csr, ofs; +u16 page; +int res; + + csr =xpcs_regmap_addr_format (dev, reg); + page =xpcs_regmap_addr_page (csr); + ofs =xpcs_regmap_addr_offset (csr); + + res =regmap_write (pxpcs->regmap,DW_VR_CSR_VIEWPORT , page); +if (res <0 ) +return res; + +return regmap_write (pxpcs->regmap, ofs, val); +} + +static int xpcs_regmap_read_reg_direct (struct dw_xpcs_regmap *pxpcs,int dev, +int reg) +{ +unsigned int val; +ptrdiff_t csr; +int res; + + csr =xpcs_regmap_addr_format (dev, reg); + res =regmap_read (pxpcs->regmap, csr, &val); +if (res <0 ) +return res; + +return val &0xffff ; +} + +static int xpcs_regmap_write_reg_direct (struct dw_xpcs_regmap *pxpcs,int dev, +int reg,u16 val) +{ +ptrdiff_t csr =xpcs_regmap_addr_format (dev, reg); + +return regmap_write (pxpcs->regmap, csr, val); +} + +static int xpcs_regmap_read_c22 (struct mii_bus *bus,int addr,int reg) +{ +struct dw_xpcs_regmap *pxpcs = bus->priv; + +if (addr !=0 ) +return -ENODEV ; + +if (pxpcs->reg_indir) +return xpcs_regmap_read_reg_indirect (pxpcs,MDIO_MMD_VEND2 , reg); +else +return xpcs_regmap_read_reg_direct (pxpcs,MDIO_MMD_VEND2 , reg); +} + +static int xpcs_regmap_write_c22 (struct mii_bus *bus,int addr,int reg,u16 val) +{ +struct dw_xpcs_regmap *pxpcs = bus->priv; + +if (addr !=0 ) +return -ENODEV ; + +if (pxpcs->reg_indir) +return xpcs_regmap_write_reg_indirect (pxpcs,MDIO_MMD_VEND2 , reg, val); +else +return xpcs_regmap_write_reg_direct (pxpcs,MDIO_MMD_VEND2 , reg, val); +} + +static int xpcs_regmap_read_c45 (struct mii_bus *bus,int addr,int dev,int reg) +{ +struct dw_xpcs_regmap *pxpcs = bus->priv; + +if (addr !=0 ) +return -ENODEV ; + +if (pxpcs->reg_indir) +return xpcs_regmap_read_reg_indirect (pxpcs, dev, reg); +else +return xpcs_regmap_read_reg_direct (pxpcs, dev, reg); +} + +static int xpcs_regmap_write_c45 (struct mii_bus *bus,int addr,int dev, +int reg,u16 val) +{ +struct dw_xpcs_regmap *pxpcs = bus->priv; + +if (addr !=0 ) +return -ENODEV ; + +if (pxpcs->reg_indir) +return xpcs_regmap_write_reg_indirect (pxpcs, dev, reg, val); +else +return xpcs_regmap_write_reg_direct (pxpcs, dev, reg, val); +} + +static void devm_xpcs_regmap_destroy (void *data) +{ +struct dw_xpcs *xpcs = data; + +xpcs_destroy (xpcs); +} + +struct dw_xpcs *devm_xpcs_regmap_register (struct device *dev, +const struct xpcs_regmap_config *config) +{ +static atomic_t id =ATOMIC_INIT (-1 ); +struct dw_xpcs_regmap *pxpcs;
drivers/net/pcs/pcs-xpcs-regmap.c line 181
Quoted 10 lines
drivers/net/pcs/pcs-xpcs-regmap.c new file +10
-0+struct dw_xpcs *xpcs; +int ret; + + pxpcs =devm_kzalloc (dev,sizeof (*pxpcs),GFP_KERNEL ); +if (!pxpcs) +return ERR_PTR (-ENOMEM ); + + pxpcs->dev = dev; + pxpcs->regmap = config->regmap; + pxpcs->reg_indir = config->reg_indir;
Looking at the overall series, is there any reason for this flag ?
Looks like the reg_indir=false path isn't used at all in this series.
Maybe just drop it and let anyone add it back should the need arise ?
Maxime
Re: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
Quoted 16 lines · Maxime Chevallier
Quoted 4 lines
drivers/net/pcs/pcs-xpcs-regmap.c new file +4
-0+ const struct xpcs_regmap_config *config) +{ +static atomic_t id =ATOMIC_INIT (-1 ); +struct dw_xpcs_regmap *pxpcs;drivers/net/pcs/pcs-xpcs-regmap.c line 181
Quoted 10 lines
drivers/net/pcs/pcs-xpcs-regmap.c new file +10
-0+struct dw_xpcs *xpcs; +int ret; + + pxpcs =devm_kzalloc (dev,sizeof (*pxpcs),GFP_KERNEL ); +if (!pxpcs) +return ERR_PTR (-ENOMEM ); + + pxpcs->dev = dev; + pxpcs->regmap = config->regmap; + pxpcs->reg_indir = config->reg_indir;Looking at the overall series, is there any reason for this flag ?
Quoted 3 lines
Looks like the reg_indir=false path isn't used at all in this series.
Maybe just drop it and let anyone add it back should the need arise ?
You're right that it's always true (in this one case it's used).
I think it's fine to get rid of the reg_indir flag, and that will simplify a lot of things. It eliminates the need for the xpcs_regmap_config structure (just register with regmap pointer instead).
The "pcs-xpcs-regmap.h" header could be removed too if we declared devm_xpcs_regmap_register() in "drivers/net/pcs/pcs-xpcs.h". (I won't do this unless you or someone else suggests it though.)
I will rearrange the code to support only the indirect access method for this code.
-Alex
[email protected]
AI reviewRe: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
In reply to Alex ElderThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Missing colon ':' after 'F' in the MAINTAINERS file entry. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing colon ':' after 'F' in the MAINTAINERS file entry.
--
commit 2d23c3db72012c33d05246dcd5eb68b21952d164
Author: Daniel Thompson <[email protected]>
net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
This commit introduces helpers to allow drivers to register an XPCS using a regmap for the memory-mapped MDIO bus. It addresses issues where the MDIO bus is allocated to a register window that does not align to a page boundary.
MAINTAINERS F: drivers/net/ethernet/synopsys/ · line 25937
Quoted 12 lines
MAINTAINERS +2
-0@@ -25931,8 +25931,10 @@ F: drivers/net/ethernet/synopsys/ SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER L: [email protected] S: Orphan +F: drivers/net/pcs/pcs-xpcs-regmap.c F: drivers/net/pcs/pcs-xpcs.c F: drivers/net/pcs/pcs-xpcs.h +F include/linux/pcs/pcs-xpcs-regmap.h
[Severity: Low]
This isn't a bug, but should this entry have a colon after the 'F'?
Quoted 1 line
MAINTAINERS +0
-0F: include/linux/pcs/pcs-xpcs.h
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
Quoted 13 lines · On 6/5/26 8:01 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing colon ':' after 'F' in theMAINTAINERSfile entry.
--commit
2d23c3db72012c33d05246dcd5eb68b21952d164
Author: Daniel Thompson <[email protected]>net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
This commit introduces helpers to allow drivers to register an XPCS using a regmap for the memory-mapped MDIO bus. It addresses issues where the MDIO bus is allocated to a register window that does not align to a page boundary.
Quoted 15 lines
MAINTAINERS F: drivers/net/ethernet/synopsys/ · line 25937
Quoted 12 lines
MAINTAINERS +2
-0@@ -25931,8 +25931,10 @@ F: drivers/net/ethernet/synopsys/ SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER L: [email protected] S: Orphan +F: drivers/net/pcs/pcs-xpcs-regmap.c F: drivers/net/pcs/pcs-xpcs.c F: drivers/net/pcs/pcs-xpcs.h +F include/linux/pcs/pcs-xpcs-regmap.h[Severity: Low]
This isn't a bug, but should this entry have a colon after the 'F'?
Yes. This will be fixed in the next version. -Alex
Quoted 3 lines
Quoted 2 lines
MAINTAINERS +0
-0F: include/linux/pcs/pcs-xpcs.h
Andrew Lunn
maintainerRe: [PATCH net-next v2 03/14] net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via regmap
In reply to Alex ElderQuoted 4 lines
drivers/net/pcs/pcs-xpcs-regmap.c new file +4
-0+struct dw_xpcs *devm_xpcs_regmap_register (struct device *dev, +const struct xpcs_regmap_config *config) +{ +static atomic_t id =ATOMIC_INIT (-1 );
...
drivers/net/pcs/pcs-xpcs-regmap.c line 197
Quoted 2 lines
drivers/net/pcs/pcs-xpcs-regmap.c new file +2
-0+snprintf (pxpcs->bus->id,MII_BUS_ID_SIZE , +"dwxpcs-%x" ,atomic_inc_return (&id));
dev_name(dev) should be unique, and it also makes it easier to associate the PCS to the MAC when looking in /sys.
Andrew
PATCH v2 4/14 net: pcs: xpcs: re-order xpcs_pre_config() to update after the reset
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Currently, on Wangxun platforms, the XPCS is configured during the call to xpcs_switch_interface_mode() and, if the need_reset flag is set, the XPCS is reset and the configuration will be lost. This is harmless at present because need_reset will never actually be set on these platforms.
Nevertheless having xpcs_switch_interface_mode() on the wrong side of the reset is an obstacle for future changes where wiping out programmed configuration with a reset could be harmful.
Reorder xpcs_pre_config() to allow the reset can happen before we switch interface mode. To make this work we have to hoist the special case logic for SGMII into the parent function.
--- drivers/net/pcs/pcs-xpcs.c | 56 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 26 deletions(-)
drivers/net/pcs/pcs-xpcs.c +30 -26
@@ -705,46 +705,50 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)static int xpcs_switch_interface_mode (struct dw_xpcs *xpcs,phy_interface_t interface) { -int ret =0 ; +/* Wangxun provides a full alternative implementation to handle quirks */ +if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) +return txgbe_xpcs_switch_mode (xpcs, interface); -if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID ) { - ret =txgbe_xpcs_switch_mode (xpcs, interface); - }else if (xpcs->interface != interface) { -if (interface ==PHY_INTERFACE_MODE_SGMII ) - xpcs->need_reset = true; - xpcs->interface = interface; - } + xpcs->interface = interface; -return ret; +return 0 ; }static void xpcs_pre_config (struct phylink_pcs *pcs,phy_interface_t interface) {struct dw_xpcs *xpcs =phylink_pcs_to_xpcs (pcs);const struct dw_xpcs_compat *compat; +bool force_reset;int ret; +/* +* According to the XPCS datasheet, a soft reset is required to initiate +* Clause 37 auto-negotiation when the XPCS switches interface modes. +*/ + force_reset = interface ==PHY_INTERFACE_MODE_SGMII ; + +if (force_reset || xpcs->need_reset) { + compat =xpcs_find_compat (xpcs, interface); +if (!compat) { +dev_err (&xpcs->mdiodev->dev,"unsupported interface %s\n" , +phy_modes (interface)); +return ; + } + + ret =xpcs_soft_reset (xpcs, compat); +if (ret) { +dev_err (&xpcs->mdiodev->dev,"soft reset failed: %pe\n" , +ERR_PTR (ret)); +return ; + } + + xpcs->need_reset = false; + } + ret =xpcs_switch_interface_mode (xpcs, interface);if (ret)dev_err (&xpcs->mdiodev->dev,"switch interface failed: %pe\n" ,ERR_PTR (ret)); - -if (!xpcs->need_reset) -return ; - - compat =xpcs_find_compat (xpcs, interface); -if (!compat) { -dev_err (&xpcs->mdiodev->dev,"unsupported interface %s\n" , -phy_modes (interface)); -return ; - } - - ret =xpcs_soft_reset (xpcs, compat); -if (ret) -dev_err (&xpcs->mdiodev->dev,"soft reset failed: %pe\n" , -ERR_PTR (ret)); - - xpcs->need_reset = false; } static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs,
Signature · 1 line
2.51.0
PATCH v2 5/14 net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Currently the XPCS found on Toshiba TC9564 (a.k.a. Qualcomm QPS615) is unable to operate at 2500base-X and slower with a PHY connected using SGMII/2500base-X (in our case a Qualcomm QCA8081).
The problem arises because this XPCS supports 10Gbase-R. That means that the reset value of SR_XS_PCS_CTRL2:PCS_TYPE_SEL (0) is valid and this suppresses the modal switching based on bit 13 of SR_PMA_CTRL1 or SR_XS_PCS_CTRL1.
A fix for this behaviour is already implemented by txgbe_xpcs_switch_mode() as part of the quirks for WangXun devices.
Rather than introduce another quirk for TC956x let's attempt so solve this generically by setting SR_XS_PCS_CTRL2:PCS_TYPE_SEL to a reserved value when we detect the right we detect the right combination of phy interface and XPCS feature support.
The generic strategy adopted requires the default value of PCS_TYPE_SEL to be 0 on devices that support 10Gbase-R. Based on TC9564 documentation and the logic already implemented for WangXun I believe this is likely to be the case for currently supported XPCS devices. Sadly I don't have access to generic XPCS docs to confirm. However I think the benefits of avoiding a cargo culted quirk outweights the risk of regression.
--- drivers/net/pcs/pcs-xpcs.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/net/pcs/pcs-xpcs.c +39 -0
@@ -705,10 +705,49 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)static int xpcs_switch_interface_mode (struct dw_xpcs *xpcs,phy_interface_t interface) { +int mdio_stat2, ret; +/* Wangxun provides a full alternative implementation to handle quirks */ if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID )return txgbe_xpcs_switch_mode (xpcs, interface); + mdio_stat2 =xpcs_read (xpcs,MDIO_MMD_PCS ,MDIO_STAT2 ); +if (mdio_stat2 <0 ) +return mdio_stat2; + +/* +* If this XPCS supports 10Gbase-R then that will be the default +* operating mode. There are several interface modes where this default +* is unhelpful. Change the operating mode for interfaces were we know +* the default is wrong, and restore the default otherwise. +*/ +if (mdio_stat2 &MDIO_PCS_STAT2_10GBR ) { +switch (interface) { +case PHY_INTERFACE_MODE_SGMII : +case PHY_INTERFACE_MODE_1000BASEX : +case PHY_INTERFACE_MODE_2500BASEX : +/* +* Why are we writing MDIO_PCS_CTRL2_TYPE + 1? We want +* the modal behaviour that comes when we pick a +* reserved value. XPCS allocates extra bits to this +* field and allocates values from 15 down so +* MDIO_PCS_CTRL2_TYPE + 1 is the value likely to be +* allocated last (and hopefully never). +*/ + ret =xpcs_write (xpcs,MDIO_MMD_PCS ,MDIO_CTRL2 , +MDIO_PCS_CTRL2_TYPE +1 ); +if (ret <0 ) +return ret; +break ; +default : + ret =xpcs_write (xpcs,MDIO_MMD_PCS ,MDIO_CTRL2 , +MDIO_PCS_CTRL2_10GBR ); +if (ret <0 ) +return ret; +break ; + } + } + xpcs->interface = interface;return 0 ;
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 05/14] net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] False detection of 10Gbase-R capability on 1G-only devices lacking MMD 3 (PCS) due to unhandled…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] False detection of 10Gbase-R capability on 1G-only devices lacking MMD 3 (PCS) due to unhandled 0xffff MDIO read response. --
commit 8962f48f9cb6674f919016e2d22817c0d0ed132d
Author: Daniel Thompson <[email protected]>
net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
This commit adds generic logic to change the operating mode on XPCS devices that support 10Gbase-R when the default mode is inappropriate. It sets PCS_TYPE_SEL to a reserved value to fix an issue where modal switching is otherwise suppressed.
Quoted 15 lines
drivers/net/pcs/pcs-xpcs.c +3
-0@@ -705,10 +705,49 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces)static int xpcs_switch_interface_mode (struct dw_xpcs *xpcs,phy_interface_t interface) { +int mdio_stat2, ret; +/* Wangxun provides a full alternative implementation to handle quirks */ if (xpcs->info.pma ==WX_TXGBE_XPCS_PMA_10G_ID )return txgbe_xpcs_switch_mode (xpcs, interface); + mdio_stat2 =xpcs_read (xpcs,MDIO_MMD_PCS ,MDIO_STAT2 );
drivers/net/pcs/pcs-xpcs.c static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) · line 724
Quoted 10 lines
drivers/net/pcs/pcs-xpcs.c +10
-0+if (mdio_stat2 <0 ) +return mdio_stat2; + +/* +* If this XPCS supports 10Gbase-R then that will be the default +* operating mode. There are several interface modes where this default +* is unhelpful. Change the operating mode for interfaces were we know +* the default is wrong, and restore the default otherwise. +*/ +if (mdio_stat2 &MDIO_PCS_STAT2_10GBR ) {
[Severity: Medium]
Will this falsely detect 10GBASE-R support on 1G-only devices?
If a device lacks the PCS MMD (MMD 3), the MDIO bus read in xpcs_read() naturally returns 0xffff due to floating bus pull-ups. Because 0xffff is greater than 0, it bypasses the mdio_stat2 < 0 error check above.
Since 0xffff & MDIO_PCS_STAT2_10GBR (0x0001) evaluates to true, the driver will falsely identify the device as 10GBASE-R capable and perform unintended writes to MDIO_CTRL2 in the unpopulated MMD 3. Does this check need to account for 0xffff responses?
Quoted 2 lines
drivers/net/pcs/pcs-xpcs.c +2
-0+switch (interface) { +case PHY_INTERFACE_MODE_SGMII :
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Andrew Lunn
maintainerRe: [PATCH net-next v2 05/14] net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
In reply to Alex ElderQuoted 4 lines
Rather than introduce another quirk for TC956x let's attempt so solve this generically by setting SR_XS_PCS_CTRL2:PCS_TYPE_SEL to a reserved value when we detect the right we detect the right combination of phy interface and XPCS feature support.
This sentence is broken.
Andrew
PATCH v2 6/14 net: stmmac: dma: create a separate dma_device pointer
In reply to Alex ElderThe Toshiba TC956x Ethernet bridge chip is an Ethernet AVN/TSN bridge that is essentially a small but specialized SoC. It provides two XGMAC Ethernet interfaces along with a number of internal IP blocks, some of which are used by both eMACs.
The chip implements two internal PCIe functions, and one of these is used to manage the common internal IPs. Both of the PCIe functions use an auxiliary bus device to represent an XGMAC Ethernet interface. Separating the PCIe function from the XGMAC IP this way helps in managing the life cycle for various objects (common and per-MAC).
However this separation means that the MAC device is no longer the proper device to use for DMA. To address this, we add support for a second "DMA device" pointer in the stmmac_priv structure. The DMA device pointer is used for all DMA operations, while the "normal" device pointer is used for log messages, memory allocation, runtime power management, and a few other things.
To set up the DMA device pointer, we add a new device structure pointer to the plat_stmmacenet_data structure. If set, it will be assigned as the (new) dma_device pointer field in the stmmac_priv structure. If the plat_stmmacenet_data field is NULL, the "normal" device pointer is assigned as the dma_device pointer instead (preserving existing behavior).
--- .../net/ethernet/stmicro/stmmac/chain_mode.c | 12 ++-- .../net/ethernet/stmicro/stmmac/ring_mode.c | 12 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 58 ++++++++++--------- .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 2 +- include/linux/stmmac.h | 1 + 6 files changed, 45 insertions(+), 41 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +6 -6
@@ -34,10 +34,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, buf_len = min_t(unsigned int, nopaged_len, bmax); len = nopaged_len - buf_len; - des2 =dma_map_single (priv->device, skb->data, + des2 =dma_map_single (priv->dma_device, skb->data, buf_len,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2; tx_q->tx_skbuff_dma[entry].len = buf_len;
@@ -51,11 +51,11 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, desc = tx_q->dma_tx + entry;if (len > bmax) { - des2 =dma_map_single (priv->device, + des2 =dma_map_single (priv->dma_device, (skb->data + bmax * i), bmax,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2; tx_q->tx_skbuff_dma[entry].len = bmax;
@@ -64,11 +64,11 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, len -= bmax; i++; }else { - des2 =dma_map_single (priv->device, + des2 =dma_map_single (priv->dma_device, (skb->data + bmax * i), len,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2; tx_q->tx_skbuff_dma[entry].len = len;
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +6 -6
@@ -37,10 +37,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,if (nopaged_len > BUF_SIZE_8KiB) { - des2 =dma_map_single (priv->device, skb->data, bmax, + des2 =dma_map_single (priv->dma_device, skb->data, bmax,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2;
@@ -58,10 +58,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,else desc = tx_q->dma_tx + entry; - des2 =dma_map_single (priv->device, skb->data + bmax, len, + des2 =dma_map_single (priv->dma_device, skb->data + bmax, len,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2; tx_q->tx_skbuff_dma[entry].len = len;
@@ -72,10 +72,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,STMMAC_RING_MODE ,1 , !skb_is_nonlinear (skb), skb->len); }else { - des2 =dma_map_single (priv->device, skb->data, + des2 =dma_map_single (priv->dma_device, skb->data, nopaged_len,DMA_TO_DEVICE ); desc->des2 =cpu_to_le32 (des2); -if (dma_mapping_error (priv->device, des2)) +if (dma_mapping_error (priv->dma_device, des2))return -1 ; tx_q->tx_skbuff_dma[entry].buf = des2; tx_q->tx_skbuff_dma[entry].len = nopaged_len;
drivers/net/ethernet/stmicro/stmmac/stmmac.h +1 -0
@@ -278,6 +278,7 @@ struct stmmac_priv {void __iomem *ioaddr;struct net_device *dev;struct device *device; +struct device *dma_device;struct mac_device_info *hw;int (*hwif_quirks)(struct stmmac_priv *priv);struct mutex lock;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +30 -28
185 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c +1 -1
@@ -25,7 +25,7 @@ static int stmmac_xdp_enable_pool(struct stmmac_priv *priv,if (frame_size <ETH_FRAME_LEN +VLAN_HLEN *2 )return -EOPNOTSUPP ; - err =xsk_pool_dma_map (pool, priv->device,STMMAC_RX_DMA_ATTR ); + err =xsk_pool_dma_map (pool, priv->dma_device,STMMAC_RX_DMA_ATTR );if (err) {netdev_err (priv->dev,"Failed to map xsk pool\n" );return err;
include/linux/stmmac.h +1 -0
@@ -245,6 +245,7 @@ struct plat_stmmacenet_data {struct stmmac_mdio_bus_data *mdio_bus_data;struct device_node *phy_node;struct device_node *mdio_node; +struct device *dma_device;struct stmmac_dma_cfg *dma_cfg;struct stmmac_safety_feature_cfg *safety_feat_cfg;int clk_csr;
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 06/14] net: stmmac: dma: create a separate dma_device pointer
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] When DMA mapping fails during transmission, the driver either leaks mapped memory (non-TSO path) or causes a permanent hardware TX queue stall (TSO path).
- [High] Kernel panic in the DMA descriptor allocation error path due to a NULL pointer dereference when tearing down uninitialized queues. --
commit 66acc331f7f048d75e9c4b2fb700576508be93dc
Author: Alex Elder <[email protected]>
Subject: net: stmmac: dma: create a separate dma_device pointer
The patch separates the DMA device from the MAC device in the stmmac driver. It adds a dma_device pointer to the stmmac_priv and plat_stmmacenet_data structures, and updates all DMA operations to use it.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-1@@ -1730,12 +1730,12 @@ static void stmmac_free_tx_buffer(struct stmmac_priv *priv,if (tx_q->tx_skbuff_dma[i].buf && tx_q->tx_skbuff_dma[i].buf_type !=STMMAC_TXBUF_T_XDP_TX ) {if (tx_q->tx_skbuff_dma[i].map_as_page) - dma_unmap_page(priv->device,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_free_tx_buffer(struct stmmac_priv *priv, · line 1741
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-1+dma_unmap_page (priv->dma_device, tx_q->tx_skbuff_dma[i].buf, tx_q->tx_skbuff_dma[i].len,DMA_TO_DEVICE ); else - dma_unmap_single(priv->device, + dma_unmap_single(priv->dma_device, tx_q->tx_skbuff_dma[i].buf, tx_q->tx_skbuff_dma[i].len,DMA_TO_DEVICE );
[Severity: High]
This is a pre-existing issue, but is there a risk of a NULL pointer dereference in the DMA descriptor allocation error path?
In the error path of alloc_dma_tx_desc_resources() or alloc_dma_rx_desc_resources(), if queue allocation fails (e.g., -ENOMEM from kzalloc_objs), the driver unconditionally cleans up all configured queues, including those that were never initialized.
When free_dma_rx_desc_resources() or free_dma_tx_desc_resources() processes an uninitialized queue, it iterates over the descriptor ring and calls stmmac_free_tx_buffer() or stmmac_free_rx_buffer(). Since tx_skbuff_dma or buf_pool is NULL for uninitialized queues, attempting to check conditions like the one above will dereference a pointer relative to NULL, triggering a panic.
[ ... ]
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-2@@ -4571,9 +4571,9 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) first = desc;/* first descriptor: fill Headers on Buf1 */ - des =dma_map_single (priv->device, skb->data,skb_headlen (skb), + des =dma_map_single (priv->dma_device, skb->data,skb_headlen (skb),DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, des)) +if (dma_mapping_error (priv->dma_device, des)) goto dma_map_err;stmmac_set_desc_addr (priv, first, des);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) · line 4606
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-2@@ -4599,10 +4599,10 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)for (i =0 ; i < nfrags; i++) {const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; - des =skb_frag_dma_map (priv->device, frag,0 , + des =skb_frag_dma_map (priv->dma_device, frag,0 ,skb_frag_size (frag),DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, des)) +if (dma_mapping_error (priv->dma_device, des)) goto dma_map_err;
[Severity: High]
This is a pre-existing issue, but does a DMA mapping failure here cause a permanent hardware TX queue stall?
In stmmac_tso_xmit(), intermediate descriptors are eagerly marked with the OWN=1 bit by stmmac_tso_allocator() before all fragments are mapped. If a subsequent fragment mapping fails, the code jumps to dma_map_err before setting the OWN bit on the first descriptor.
The hardware DMA engine won't process the intermediate fragments. Later, when stmmac_tx_clean() processes the ring, it will encounter the OWN=1 descriptor and permanently halt, freezing the entire TX queue.
[ ... ]
Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2
-2@@ -4827,9 +4827,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) }else {bool last_segment = (nfrags ==0 ); - dma_addr =dma_map_single (priv->device, skb->data, + dma_addr =dma_map_single (priv->dma_device, skb->data, nopaged_len,DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, dma_addr)) +if (dma_mapping_error (priv->dma_device, dma_addr)) goto dma_map_err; stmmac_set_tx_skb_dma_entry(tx_q, first_entry, dma_addr,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · line 4884
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3
-3@@ -4878,9 +4878,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) desc =stmmac_get_tx_desc (priv, tx_q, entry); - dma_addr =skb_frag_dma_map (priv->device, frag,0 , frag_size, -DMA_TO_DEVICE ); -if (dma_mapping_error (priv->device, dma_addr)) + dma_addr =skb_frag_dma_map (priv->dma_device, frag,0 , + frag_size,DMA_TO_DEVICE ); +if (dma_mapping_error (priv->dma_device, dma_addr)) goto dma_map_err;/* should reuse desc w/o issues */
[Severity: High]
This is a pre-existing issue, but does this error path lead to a memory leak?
In stmmac_xmit(), if dma_map_single() or skb_frag_dma_map() fails, the code jumps to dma_map_err without advancing tx_q->cur_tx.
Subsequent transmissions will reuse the same descriptor index and overwrite the DMA addresses in tx_q->tx_skbuff_dma. This causes a permanent memory leak of the previously mapped fragments for this skb, as they are never unmapped.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH v2 7/14 net: stmmac: dwxgmac2: Add multi MSI interrupt mode
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Currently there are no XGMAC platforms integrated using the multi MSI interrupt mode. In other words no existing driver sets both DWMAC_CORE_XGMAC and STMMAC_FLAG_MULTI_MSI_EN.
In order to support systems that do enable both options (such as the Toshiba TC9564 whose driver is currently being developed) we need to add logic to the XGMAC DMA callbacks. Happily we can simply replicate similar code from GMAC4. Let's do that!
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 8 ++++++++ 2 files changed, 10 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +2 -0
@@ -320,6 +320,8 @@/* DMA Registers */ #define XGMAC_DMA_MODE 0x00003000#define XGMAC_SWR BIT(0) +#define XGMAC_INTM_MASK GENMASK(13, 12) +#define XGMAC_INTM_MODE1 0x1#define XGMAC_DMA_SYSBUS_MODE 0x00003004#define XGMAC_WR_OSR_LMT GENMASK(29, 24)#define XGMAC_RD_OSR_LMT GENMASK(21, 16)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +8 -0
@@ -31,6 +31,14 @@ static void dwxgmac2_dma_init(void __iomem *ioaddr, value |=XGMAC_EAME ;writel (value, ioaddr +XGMAC_DMA_SYSBUS_MODE ); + + value =readl (ioaddr +XGMAC_DMA_MODE ); + +if (dma_cfg->multi_msi_en) + value =u32_replace_bits (value,XGMAC_INTM_MODE1 , +XGMAC_INTM_MASK ); + +writel (value, ioaddr +XGMAC_DMA_MODE ); } static void dwxgmac2_dma_init_chan(struct stmmac_priv *priv,
Signature · 1 line
2.51.0
PATCH v2 8/14 net: stmmac: dwxgmac2: Add XGMAC 3.01a support
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
XGMAC 2.x and 3.x are architecturally very similar. That means that for everything except one erratum we can simply use the XGMAC 2.x callback functions in the stmmac_dma_ops structure.
Only the set_rx_ring_len callback is specific to XGMAC 3.01. It limits the number of outstanding write requests that can be serviced per DMA.
The other erratum addressed in this patch is simply a comment to ensure that a feature that stmmac doesn't currently use is not enabled without contemplating the errata.
--- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 3 ++ .../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +3 -0
@@ -374,6 +374,8 @@#define XGMAC_DMA_CH_RxDESC_TAIL_LPTR (x) (0x0000312c + (0x80 * (x)))#define XGMAC_DMA_CH_TxDESC_RING_LEN (x) (0x00003130 + (0x80 * (x)))#define XGMAC_DMA_CH_RxDESC_RING_LEN (x) (0x00003134 + (0x80 * (x))) +#define XGMAC_OWRQ GENMASK(25, 24) +#define XGMAC_RDRL GENMASK(15, 0)#define XGMAC_DMA_CH_INT_EN (x) (0x00003138 + (0x80 * (x)))#define XGMAC_NIE BIT(15)#define XGMAC_AIE BIT(14)
@@ -463,6 +465,7 @@extern const struct stmmac_ops dwxgmac210_ops;extern const struct stmmac_ops dwxlgmac2_ops;extern const struct stmmac_dma_ops dwxgmac210_dma_ops; +extern const struct stmmac_dma_ops dwxgmac301_dma_ops;extern const struct stmmac_desc_ops dwxgmac210_desc_ops;#endif /* __STMMAC_DWXGMAC2_H__ */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +53 -0
68 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v2 9/14 net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialised SoC. Ethernet on this chip is provided by a DesignWare XGMAC.
One consequence of the SoC-like design is that the internal AXI bus (used by the XGMAC for DMA) maps the PCI DMA space with a non-zero base address. This requires a translation step (happily just simple addition) to convert the PCI DMA address to the hardware DMA address.
This is pretty funky so rather than push that translation logic into the core driver we intend to keep that logic inside the TC956x platform code. In order to do that we need to export a few symbols to allow us to override some of the DMA and descriptor op tables.
FWIW this approach to overriding the ops tables is similar to the mechanism currently found in dwmac-loongson.c (with the exception that we have also exported a couple of functions so we don't have to replicate their content in the TC956x platform code).
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 7 +++++++ .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 1 + .../net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +7 -0
@@ -468,4 +468,11 @@ extern const struct stmmac_dma_ops dwxgmac210_dma_ops;extern const struct stmmac_dma_ops dwxgmac301_dma_ops;extern const struct stmmac_desc_ops dwxgmac210_desc_ops; +void dwxgmac2_dma_init_rx_chan (struct stmmac_priv *priv,void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg,dma_addr_t phy, +u32 chan); +void dwxgmac2_dma_init_tx_chan (struct stmmac_priv *priv,void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg,dma_addr_t phy, +u32 chan); +#endif /* __STMMAC_DWXGMAC2_H__ */
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +1 -0
@@ -1556,6 +1556,7 @@ int dwxgmac2_setup(struct stmmac_priv *priv)return 0 ; } +EXPORT_SYMBOL_GPL (dwxgmac2_setup);int dwxlgmac2_setup (struct stmmac_priv *priv) {
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +1 -0
@@ -368,3 +368,4 @@ const struct stmmac_desc_ops dwxgmac210_desc_ops = { .set_vlan = dwxgmac2_set_vlan, .set_tbs = dwxgmac2_set_tbs, }; +EXPORT_SYMBOL_GPL (dwxgmac210_desc_ops);
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +10 -8
@@ -62,10 +62,10 @@ static void dwxgmac2_dma_init_chan(struct stmmac_priv *priv,writel (XGMAC_DMA_INT_DEFAULT_EN , ioaddr +XGMAC_DMA_CH_INT_EN (chan)); } -static void dwxgmac2_dma_init_rx_chan (struct stmmac_priv *priv, -void __iomem *ioaddr, -struct stmmac_dma_cfg *dma_cfg, -dma_addr_t phy,u32 chan) +void dwxgmac2_dma_init_rx_chan (struct stmmac_priv *priv, +void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg, +dma_addr_t phy,u32 chan) {u32 rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;u32 value;
@@ -77,11 +77,11 @@ static void dwxgmac2_dma_init_rx_chan(struct stmmac_priv *priv,writel (upper_32_bits (phy), ioaddr +XGMAC_DMA_CH_RxDESC_HADDR (chan));writel (lower_32_bits (phy), ioaddr +XGMAC_DMA_CH_RxDESC_LADDR (chan)); } +EXPORT_SYMBOL_GPL (dwxgmac2_dma_init_rx_chan); -static void dwxgmac2_dma_init_tx_chan (struct stmmac_priv *priv, -void __iomem *ioaddr, -struct stmmac_dma_cfg *dma_cfg, -dma_addr_t phy,u32 chan) +void dwxgmac2_dma_init_tx_chan (struct stmmac_priv *priv,void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg,dma_addr_t phy, +u32 chan) {u32 txpbl = dma_cfg->txpbl ?: dma_cfg->pbl;u32 value;
@@ -93,6 +93,7 @@ static void dwxgmac2_dma_init_tx_chan(struct stmmac_priv *priv,writel (upper_32_bits (phy), ioaddr +XGMAC_DMA_CH_TxDESC_HADDR (chan));writel (lower_32_bits (phy), ioaddr +XGMAC_DMA_CH_TxDESC_LADDR (chan)); } +EXPORT_SYMBOL_GPL (dwxgmac2_dma_init_tx_chan);static void dwxgmac2_dma_axi (void __iomem *ioaddr,struct stmmac_axi *axi) {
@@ -672,3 +673,4 @@ const struct stmmac_dma_ops dwxgmac301_dma_ops = { .enable_sph = dwxgmac2_enable_sph, .enable_tbs = dwxgmac2_enable_tbs, }; +EXPORT_SYMBOL_GPL (dwxgmac301_dma_ops);
Signature · 1 line
2.51.0
PATCH v2 10/14 dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges.
The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation.
The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused.
The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers.
--- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +120 -0
@@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/toshiba,tc9564-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC956x Ethernet-AVB/TSN Controller + +maintainers: + - Alex Elder <[email protected]> + - Daniel Thompson <[email protected]> + +description: | + The Toshiba TC9564 (and more generally, TC956x) incorporates a PCIe + gen 3 switch with one upstream and three downstream ports. The first + two downstream ports are exposed externally, while the third is used + by an internal PCIe endpoint. The PCIe endpoint implements two PCIe + functions, and attached to each of these is a 10 Gbps capable Synopsys + Ethernet controller. + + The TC956x additionally implements other internal IP blocks, and in + particular it implements a GPIO controller. Ten of the 35 GPIO lines + implemented are exposed externally and are usable by the platform. + It is platform-dependent whether the GPIO function must be exposed, + and if it is, PCIe function 0 supplies it. + + ---------------------------------- + | Host | + ------+...+----------+........+--- + |i2c| | PCIe | + ----------------+...+----------+........+------ + | TC956x |I2C| |upstream| | + | ----- --+--------+--- | + | ----- ------ ------- | PCIe switch | | + | |SPI| |GPIO| |reset| | | | + | ----- ------ |clock| | DS3 DS2 DS1 | | + | ------- ---++--++--++-- | + | ----- ------ downstream// \\ \\ | downstream + | |MCU| |SRAM| /==========/ \\ \===== PCIe port 1 + | ----- ------ //PCIe port 3 \\ | + | || \======= downstream + | ----+-----------++-----------+---- | PCIe port 2 + | | M | internal PCIe endpoint | M | | + | | S |------------------------| S | ------ | + | | I | PCIe | | PCIe | I | |UART| | + | | G |function 0| |function 1| G | ------ | + | | E |----++----| |----++----| E | | + | | N | eMAC 0 | | eMAC 1 | N | | + --------+.......+------+.....+----------------- + |USXGMII| |SGMII| + --+.......+-- --+.....+-- + | ARQ113C | | QEP8121 | + | PHY | | PHY | + ------------- ----------- + +properties: + compatible: + enum: + - pci1179,0220 # Toshiba TC9564 (a.k.a. Qualcomm QPS615) + + gpio: + type: object + description: Embedded GPIO controller + $ref: /schemas/gpio/gpio.yaml# + + ethernet: + type: object + description: XGMAC Ethernet controller + $ref: /schemas/net/ethernet-controller.yaml# + properties: + mdio: + $ref: snps,dwmac.yaml#/properties/mdio + required: + - mdio + +required: + - compatible + +allOf: + - $ref: /schemas/pci/pci-device.yaml# + - $ref: /schemas/pci/pci-bus-common.yaml# + +unevaluatedProperties: false + +examples: + - | + pcie { + #address-cells = <3>; + #size-cells = <2>; + + pci@0,0 { + compatible = "pci1179,0220"; + reg = <0x50000 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges; + + gpio { + gpio-controller; + #gpio-cells = <2>; + }; + + ethernet { + phy-mode = "10gbase-r"; + phy-handle = <&tc9564_emac0_phy>; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + tc9564_emac0_phy: ethernet-phy@1c { + compatible = "ethernet-phy-id311c.1c12"; + reg = <0x1c>; + }; + }; + }; + }; + };
MAINTAINERS +6 -0
@@ -27052,6 +27052,12 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.txt F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC956X/QUALCOMM QPS615 DWMAC ETHERNET DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml + TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]
Signature · 1 line
2.51.0
Rob Herring (Arm)
maintainerRe: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
Quoted 20 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges.
The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation.
The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused.
The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers.
Quoted 8 lines
Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml: gpio: Missing additionalProperties/unevaluatedProperties constraint /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml: ethernet: Missing additionalProperties/unevaluatedProperties constraint
doc reference errors (make refcheckdocs):
Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yamlMAINTAINERS: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml
See https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
Quoted 31 lines · Rob Herring (Arm)
Quoted 20 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges.
The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation.
The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused.
The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers.
Quoted 8 lines
Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+)create mode 100644
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml
Quoted 1 line
My bot found errors running 'make
dt_binding_check' on your patch:
Thank you for this report. After upgrading the "dtschema" package I also see these errors. The "gpio" and "ethernet" properties will have an "unevaluatedProperties: false" constraint added in the next version of this series. The name of the binding file will also be correct in the MAINTAINERS file.
-Alex
Quoted 25 lines
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml: gpio: Missing additionalProperties/unevaluatedProperties constraint /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml: ethernet: Missing additionalProperties/unevaluatedProperties constraintdoc reference errors (make refcheckdocs):
Warning:MAINTAINERSreferences a file that doesn't exist:Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yamlMAINTAINERS:Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yamlSee https://patchwork.kernel.org/project/devicetree/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that
DT_SCHEMA_FILEScan be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Rob Herring
maintainerRe: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
In reply to Alex ElderQuoted 70 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges.
The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation.
The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused.
The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers.
Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yamlDocumentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +36
-0@@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/toshiba,tc9564-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC956x Ethernet-AVB/TSN Controller + +maintainers: + - Alex Elder <[email protected]> + - Daniel Thompson <[email protected]> + +description: | + The Toshiba TC9564 (and more generally, TC956x) incorporates a PCIe + gen 3 switch with one upstream and three downstream ports. The first + two downstream ports are exposed externally, while the third is used + by an internal PCIe endpoint. The PCIe endpoint implements two PCIe + functions, and attached to each of these is a 10 Gbps capable Synopsys + Ethernet controller. + + The TC956x additionally implements other internal IP blocks, and in + particular it implements a GPIO controller. Ten of the 35 GPIO lines + implemented are exposed externally and are usable by the platform. + It is platform-dependent whether the GPIO function must be exposed, + and if it is, PCIe function 0 supplies it. + + ---------------------------------- + | Host | + ------+...+----------+........+--- + |i2c| | PCIe | + ----------------+...+----------+........+------ + | TC956x |I2C| |upstream| | + | ----- --+--------+--- | + | ----- ------ ------- | PCIe switch | | + | |SPI| |GPIO| |reset| | | | + | ----- ------ |clock| | DS3 DS2 DS1 | |
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +10
-0+ | ------- ---++--++--++-- | + | ----- ------ downstream// \\ \\ | downstream + | |MCU| |SRAM| /==========/ \\ \===== PCIe port 1 + | ----- ------ //PCIe port 3 \\ | + | || \======= downstream + | ----+-----------++-----------+---- | PCIe port 2 + | | M | internal PCIe endpoint | M | | + | | S |------------------------| S | ------ | + | | I | PCIe | | PCIe | I | |UART| | + | | G |function 0| |function 1| G | ------ |
I don't see nodes for these PCI functions. Boot this platform with CONFIG_PCI_DYNAMIC_OF_NODES enabled and use the resulting DT node structure. Anything else is wrong. This will give you the DTS:
dtc -O dts /proc/device-tree
The ethernet nodes should be just these PCI function nodes. You need to make the DWMAC PCI driver (stmmac_pci.c) bind to those 2 PCI devices. And really, a DT node for them should be completely optional (unless there's some power on ctrl needed).
Everything else like SPI, GPIO, UART, etc. should be under the PCIe switch upstream node in a pci-ep-bus.
Quoted 8 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +8
-0+ | | E |----++----| |----++----| E | | + | | N | eMAC 0 | | eMAC 1 | N | | + --------+.......+------+.....+----------------- + |USXGMII| |SGMII| + --+.......+-- --+.....+-- + | ARQ113C | | QEP8121 | + | PHY | | PHY | + ------------- -----------
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 64
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +10
-0+ +properties: + compatible: + enum: + - pci1179,0220 # Toshiba TC9564 (a.k.a. Qualcomm QPS615) + + gpio: + type: object + description: Embedded GPIO controller + $ref: /schemas/gpio/gpio.yaml#
gpio.yaml alone does not define a GPIO controller. How many #gpio-cells needs to be defined.
Is there no address associated with the controller?
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 72
Quoted 8 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +8
-0+ + ethernet: + type: object + description: XGMAC Ethernet controller + $ref: /schemas/net/ethernet-controller.yaml# + properties: + mdio: + $ref: snps,dwmac.yaml#/properties/mdio
Either all of snps,dwmac.yaml should apply or none of it. Generally, we only reference whole schema files (OF graph being a notable exception).
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 81
Quoted 9 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +9
-0+ required: + - mdio + +required: + - compatible + +allOf: + - $ref: /schemas/pci/pci-device.yaml# + - $ref: /schemas/pci/pci-bus-common.yaml#
These 2 are just pci-pci-bridge.yaml.
Rob
Re: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
Quoted 88 lines · Rob Herring
Quoted 70 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges.
The TC9564 contains a PCIe switch with one upstream and three downstream PCIe ports. The third PCIe downstream port has an attached embedded PCIe endpoint, and that endpoint implements two PCIe functions. Each internal PCIe function has a Synopsys XGMAC Ethernet interface capable of 10 Gbps operation.
The TC9564 also implements an embedded GPIO controller, which exposes 10 lines externally. Some platforms use these GPIO lines, so this GPIO controller is managed by a separate driver. Other embedded peripherals (like a microcontroller, SRAM, and UART) are currently unused.
The GPIO controller is managed by registers accessed via MMIO on an internal PCIe function's registers.
Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 126 insertions(+)create mode 100644
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yamlDocumentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +36
-0@@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/toshiba,tc9564-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba TC956x Ethernet-AVB/TSN Controller + +maintainers: + - Alex Elder <[email protected]> + - Daniel Thompson <[email protected]> + +description: | + The Toshiba TC9564 (and more generally, TC956x) incorporates a PCIe + gen 3 switch with one upstream and three downstream ports. The first + two downstream ports are exposed externally, while the third is used + by an internal PCIe endpoint. The PCIe endpoint implements two PCIe + functions, and attached to each of these is a 10 Gbps capable Synopsys + Ethernet controller. + + The TC956x additionally implements other internal IP blocks, and in + particular it implements a GPIO controller. Ten of the 35 GPIO lines + implemented are exposed externally and are usable by the platform. + It is platform-dependent whether the GPIO function must be exposed, + and if it is, PCIe function 0 supplies it. + + ---------------------------------- + | Host | + ------+...+----------+........+--- + |i2c| | PCIe | + ----------------+...+----------+........+------ + | TC956x |I2C| |upstream| | + | ----- --+--------+--- | + | ----- ------ ------- | PCIe switch | | + | |SPI| |GPIO| |reset| | | | + | ----- ------ |clock| | DS3 DS2 DS1 | |Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 46
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +10
-0+ | ------- ---++--++--++-- | + | ----- ------ downstream// \\ \\ | downstream + | |MCU| |SRAM| /==========/ \\ \===== PCIe port 1 + | ----- ------ //PCIe port 3 \\ | + | || \======= downstream + | ----+-----------++-----------+---- | PCIe port 2 + | | M | internal PCIe endpoint | M | | + | | S |------------------------| S | ------ | + | | I | PCIe | | PCIe | I | |UART| | + | | G |function 0| |function 1| G | ------ |I don't see nodes for these PCI functions. Boot this platform with
CONFIG_PCI_DYNAMIC_OF_NODESenabled and use the resulting DT node structure. Anything else is wrong. This will give you the DTS:dtc -O dts
/proc/device-tree
Quoted 7 lines
The ethernet nodes should be just these PCI function nodes. You need to make the DWMAC PCI driver (
stmmac_pci.c) bind to those 2 PCI devices. And really, a DT node for them should be completely optional (unless there's some power on ctrl needed).Everything else like SPI, GPIO, UART, etc. should be under the PCIe switch upstream node in a pci-ep-bus.
I unfortunately hadn't looked closely enough at pci-ep-bus before. It really looks like what we should use. It's a simple bus, and we'll use platform drivers and compatible strings to match the devices on the bus.
I'll work toward converting things over to use this model.
Quoted 35 lines
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +8
-0+ | | E |----++----| |----++----| E | | + | | N | eMAC 0 | | eMAC 1 | N | | + --------+.......+------+.....+----------------- + |USXGMII| |SGMII| + --+.......+-- --+.....+-- + | ARQ113C | | QEP8121 | + | PHY | | PHY | + ------------- -----------Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 64
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +10
-0+ +properties: + compatible: + enum: + - pci1179,0220 # Toshiba TC9564 (a.k.a. Qualcomm QPS615) + + gpio: + type: object + description: Embedded GPIO controller + $ref: /schemas/gpio/gpio.yaml#
gpio.yamlalone does not define a GPIO controller. How many #gpio-cells needs to be defined.Is there no address associated with the controller?
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 72
Quoted 8 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +8
-0+ + ethernet: + type: object + description: XGMAC Ethernet controller + $ref: /schemas/net/ethernet-controller.yaml# + properties: + mdio: + $ref: snps,dwmac.yaml#/properties/mdio
Quoted 2 lines
Either all of snps,dwmac.yaml should apply or none of it. Generally, we only reference whole schema files (OF graph being a notable exception).
OK.
Quoted 12 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 81
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +9
-0+ required: + - mdio + +required: + - compatible + +allOf: + - $ref: /schemas/pci/pci-device.yaml# + - $ref: /schemas/pci/pci-bus-common.yaml#These 2 are just
pci-pci-bridge.yaml.
OK.
-Alex
Quoted 2 lines
Rob
[email protected]
AI reviewRe: [PATCH net-next v2 10/14] dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
In reply to Alex ElderThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] The DT binding schema for the embedded GPIO controller lacks required provider properties and…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The DT binding schema for the embedded GPIO controller lacks required provider properties and constraints.
- [Medium] The schema incorrectly includes PCI bus properties (device_type = "pci", ranges, #address-cells) on a PCIe endpoint node.
- [Low] The file pattern listed in the new MAINTAINERS entry does not match the actual file added by the commit.
--
commit b83533ab8022940a0adcc430e19c789576b6a45b
Author: Daniel Thompson <[email protected]>
dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
Add devicetree bindings for the Toshiba TC956x family of Ethernet-AVB/TSN bridges. The TC9564 contains a PCIe switch with an attached embedded PCIe endpoint implementing two PCIe functions, each with an Ethernet interface and an embedded GPIO controller.
Quoted 6 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +0
-0@@ -0,0 +1,120 @@
[ ... ]
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 64
Quoted 9 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +9
-0+properties: + compatible: + enum: + - pci1179,0220 # Toshiba TC9564 (a.k.a. Qualcomm QPS615) + + gpio: + type: object + description: Embedded GPIO controller + $ref: /schemas/gpio/gpio.yaml#
[Severity: Medium]
When adding a hardware capability like a GPIO controller, should the schema explicitly list standard properties like gpio-controller and #gpio-cells in the required list?
Also, would it make sense to enforce a const constraint for #gpio-cells? Without these requirements, device tree nodes missing the provider properties might silently pass validation.
[ ... ]
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 81
Quoted 3 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +3
-0+allOf: + - $ref: /schemas/pci/pci-device.yaml# + - $ref: /schemas/pci/pci-bus-common.yaml#
[Severity: Medium]
Is it intentional to reference pci-bus-common.yaml# for a PCIe endpoint?
This reference applies bus-specific properties to an endpoint node.
Quoted 6 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +6
-0+ +unevaluatedProperties: false + +examples: + - | + pcie {
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml line 97
Quoted 10 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +10
-0+ #address-cells = <3>; + #size-cells = <2>; + + pci@0,0 { + compatible = "pci1179,0220"; + reg = <0x50000 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges;
[Severity: Medium]
Are device_type = "pci", ranges, and the address translation cell properties valid on this endpoint node?
The Devicetree specification dictates that device_type = "pci" should strictly be used on PCI bus nodes like host bridges or PCI-to-PCI bridges.
Additionally, since the gpio and ethernet child nodes do not use reg properties, the address and size cell sizing here seems unnecessary.
Quoted 5 lines
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yaml new file +5
-0+ + gpio { + gpio-controller; + #gpio-cells = <2>; + };
[ ... ]
MAINTAINERS F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.txt · line 27059
Quoted 13 lines
MAINTAINERS +5
-0@@ -27052,6 +27052,12 @@ F: Documentation/devicetree/bindings/media/i2c/toshiba,tc358743.txt F: drivers/media/i2c/tc358743* F: include/media/i2c/tc358743.h +TOSHIBA TC956X/QUALCOMM QPS615 DWMAC ETHERNET DRIVER +M: Alex Elder <[email protected]> +M: Daniel Thompson <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml
[Severity: Low]
Is there a typo in the filename here?
The commit introduces the file toshiba,tc9564-dwmac.yaml, but the MAINTAINERS entry lists toshiba,tc956x-dwmac.yaml. This might prevent get_maintainer.pl from properly matching the new binding file.
Quoted 4 lines
MAINTAINERS +1
-0+ TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]> L: [email protected]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
PATCH v2 11/14 misc: tc956x_pci: add TC956x/QPS615 support
In reply to Alex ElderThe Toshiba TC956x is an Ethernet AVB/TSN bridge, and is essentially a small and highly-specialized SoC. It implements a number of internal functions, including a GPIO controller, registers that manage internal reset and clock control signals, a PCIe switch, an internal PCIe endpoint, and mapping hardware that translates between PCIe and internal addressing.
The internal PCIe endpoint implements two PCIe functions, each of which has an attached eMAC. Two devices represent each of these:
a PCIe function; and the eMAC. The PCIe function driver serves as the primary driver, creating other associated devices using the auxiliary bus.
PCIe function 0 is responsible for managing common features on the TC956x chip. It initializes a "chip" data structure that keeps track of common information, and makes that available via its platform_data pointer to its PCIe function 1 peer. It also configures the address mapping hardware, and if a "gpio" devicetree sub-node is found, it creates an auxiliary device to represent the GPIO controller embedded in the TC956x.
For both PCIe function 0 and function 1, an "ethernet" devicetree sub-node indicates that the attached XGMAC Ethernet controller should be active. In this case, an auxiliary device is created to represent that hardware. A block of information is set up to be shared with the auxiliary device. It provides the IRQ to be used by the MAC device, as well as a some memory-mapped I/O pointers and a few other bits of information about the chip. This information is supplied via the auxiliary device's platform_data pointer.
--- MAINTAINERS | 1 + drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/tc956x_pci.c | 741 +++++++++++++++++++++++++++++ include/soc/toshiba/tc956x-dwmac.h | 84 ++++ 5 files changed, 839 insertions(+) create mode 100644 drivers/misc/tc956x_pci.c create mode 100644 include/soc/toshiba/tc956x-dwmac.h
MAINTAINERS +1 -0
@@ -27057,6 +27057,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/misc/tc956x_pci.c TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]>
drivers/misc/Kconfig +12 -0
@@ -644,6 +644,18 @@ config MCHP_LAN966X_PCI - lan966x-miim (MDIO_MSCC_MIIM) - lan966x-switch (LAN966X_SWITCH) +config TOSHIBA_TC956X_PCI + tristate "Toshiba TC956X PCI function support" + depends on PCI + select AUXILIARY_BUS + select REGMAP + select REGMAP_MMIO + help + This enables support for the two PCI functions implemented by + the embedded PCIe endpoint in the Toshiba TC956X. This driver + creates auxiliary devices and requires drivers for these devices + to function. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -75,3 +75,4 @@ obj-$(CONFIG_MCHP_LAN966X_PCI) += lan966x-pci.o obj-y += keba/ obj-y += amd-sbi/ obj-$(CONFIG_MISC_RP1) += rp1/ +obj-$(CONFIG_TOSHIBA_TC956X_PCI) += tc956x_pci.o
drivers/misc/tc956x_pci.c new file +741 -0
741 lines not on this page · raw message
include/soc/toshiba/tc956x-dwmac.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 11/14] misc: tc956x_pci: add TC956x/QPS615 support
Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider: - [High] Custom pcim_alloc_irq_vectors() bypasses devres registration on success, leaking IRQs on probe…
Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:
- [High] Custom pcim_alloc_irq_vectors() bypasses devres registration on success, leaking IRQs on probe errors, and manual cleanup conflicts with devres.
- [High] Missing pci_dev_put() in the success path of chip_get() leaks a PCI device reference.
- [High] Stateless device link between PCI functions allows unbind ordering violations, leading to a Use-After-Free of the chip structure.
- [High] Premature hardware teardown in remove() causing active child devices to access disabled hardware.
- [High] regmap_update_bits is called from a noirq PM callback without a raw spinlock, causing a sleep-in-atomic deadlock on PREEMPT_RT.
- [Medium] Incorrect devicetree property names gpio-controllerX and #gpio-cellsX break GPIO controller detection.
- [Medium] Missing memory barriers when publishing and reading the shared chip structure.
- [Medium] Address translation (TAMAP) is enabled before the translation addresses are fully programmed.
--
commit 5c68969ec59d12e7df704f4552de14c677e77240
Author: Alex Elder <[email protected]>
misc: tc956x_pci: add TC956x/QPS615 support
The Toshiba TC956x is an Ethernet AVB/TSN bridge, and is essentially a small and highly-specialized SoC. It implements a number of internal functions, including a GPIO controller, registers that manage internal reset and clock control signals, a PCIe switch, an internal PCIe endpoint, and mapping hardware that translates between PCIe and internal addressing.
Quoted 4 lines
drivers/misc/tc956x_pci.c new file +0
-0
[ ... ]
Quoted 14 lines
drivers/misc/tc956x_pci.c new file +14
-0+static const struct regmap_config reset_clock_regmap_config = { + .name ="tc956x-clk-reset" , + .reg_bits =32 , + .reg_stride =4 , + .reg_base =0x1000 ,/* Register NCTLSTS */ + .val_bits =32 , + .max_register =0x1010 ,/* Register NRSTCTRL1 */ +}; + +/* Common clock/reset register update function (also used for MACs) */ +void tc956x_reset_clock_set (const struct tc956x_chip *chip,bool reset, +bool reg0,bool set,u8 bit) +{ +u32 mask =BIT (bit);
drivers/misc/tc956x_pci.c line 197
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+u32 offset; + +if (reset) + offset = reg0 ?RSTCTRL0_OFFSET :RSTCTRL1_OFFSET ; +else + offset = reg0 ?CLKCTRL0_OFFSET :CLKCTRL1_OFFSET ; + +/* Note: no need to check for errors on read/write for MMIO regmap */ + (void )regmap_update_bits (chip->reset_clock_regmap, offset, mask, + set ? mask :0 );
[Severity: High]
This regmap config does not set .use_raw_spinlock = true. Because this is called from tc956x_chip_suspend_noirq(), which executes with local hardware interrupts disabled, won't taking the sleepable rt_mutex (on PREEMPT_RT) produce a sleep-in-atomic bug?
[ ... ]
Quoted 6 lines
drivers/misc/tc956x_pci.c new file +6
-0+static struct device_node *dev_node_child_gpio (struct device *dev) +{ +struct device_node *np; + +/* The GPIO sub-node is not required (platform might not need it) */ +for_each_child_of_node (dev->of_node, np)
drivers/misc/tc956x_pci.c line 291
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+if (!strcmp (np->name,"gpio" )) +break ; +if (!np) +return NULL ; + +/* If it's there, make sure it contains its required properties */ +if (!of_property_present (np,"gpio-controllerX" )) +dev_err (dev,"gpio node contains no gpio-contrller property\n" ); +else if (!of_property_present (np,"#gpio-cellsX" )) +dev_err (dev,"gpio node contains no #gpio-cells property\n" );
[Severity: Medium]
Are these property names correct? A correctly written devicetree uses gpio-controller and #gpio-cells. The trailing "X" seems like a typo that could cause valid devicetree nodes to fail validation, silently disabling the embedded GPIO controller auxiliary device.
[ ... ]
Quoted 22 lines
drivers/misc/tc956x_pci.c new file +22
-0+static void chip_tamap_config (struct tc956x_chip *chip) +{ +void __iomem *table_base = chip->bridge_config; +void __iomem *entry_base; +u32 trsl_param_val; +u32 atr_size_val; +u32 val; +u32 i; + +/* +* The lower bits of the source address must be zero, because the +* SRC_ADDR_LO register encodes the address translation space size +* and "implmented" bit there. The size field defines the size of +* the translation space (2^(ATR_SIZE + 1)). The minimum size is +* 4096 bytes, so ATR_SIZE value must be 11 or more. +*/ +BUILD_BUG_ON (!!u32_get_bits (lower_32_bits (TC956X_SLV00_SRC_ADDR ), +ATR_SIZE_MASK )); +BUILD_BUG_ON (TC956X_SLV00_SRC_ADDR &ATR_IMPL ); +BUILD_BUG_ON (SLV00_ATR_SIZE <11 ); + +/*
drivers/misc/tc956x_pci.c line 433
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+* We only use the first AXI4 slave TAMAC table: +* EDMA address region: 0x10 0000 0000 - 0x1f ffff ffff +* is translated to: 0x00 0000 0000 - 0x0f ffff ffff +*/ + entry_base = table_base +AXI4_ENTRY_BASE (0 ); + + atr_size_val =u32_encode_bits (SLV00_ATR_SIZE ,ATR_SIZE_MASK ); + atr_size_val |=ATR_IMPL ; + val =lower_32_bits (TC956X_SLV00_SRC_ADDR ) | atr_size_val; +writel (val, entry_base +SRC_ADDR_LO_OFFSET );
[Severity: Medium]
Does writing ATR_IMPL here enable the translation window before the destination addresses (TRSL_ADDR_LO_OFFSET and TRSL_ADDR_HI_OFFSET) are fully programmed? This could create a race condition where any DMA transfer or bus access occurring in this brief window will be translated using stale or uninitialized address registers. Should the enable bit be set after all other registers are programmed?
[ ... ]
Quoted 21 lines
drivers/misc/tc956x_pci.c new file +21
-0+static struct tc956x_chip *chip_get (struct pci_dev *pdev) +{ +unsigned int devfn = pdev->devfn; +struct device *dev = &pdev->dev; +struct tc956x_chip *chip; +struct device_link *link; +struct pci_dev *slot0; +int ret; + +/* Function 0 just allocates the chip structure */ +if (!PCI_FUNC (devfn)) { + chip =devm_kzalloc (dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return ERR_PTR (-ENOMEM ); + +/* +* The function whose device pointer matches the chip's +* device pointer manages common resources (like MSIGEN). +*/ + chip->dev = dev; +
drivers/misc/tc956x_pci.c line 538
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+return chip; + } + +/* Function 1 has to get the chip structure from function 0 */ + slot0 =pci_get_slot (pdev->bus,PCI_DEVFN (PCI_SLOT (devfn),0 )); +if (!slot0) +return ERR_PTR (-ENXIO ); + +/* If function 0 hasn't set up the chip yet, try again later */ + chip =dev_get_platdata (&slot0->dev);
[Severity: Medium]
Since function 0 locklessly assigns dev->platform_data = chip, and function 1 retrieves it here locklessly, could concurrent probing or sysfs binding cause function 1 to observe the pointer but read uninitialized or partially initialized fields? Would it be safer to use smp_store_release() and smp_load_acquire() when publishing and reading this shared pointer?
drivers/misc/tc956x_pci.c line 545
Quoted 7 lines
drivers/misc/tc956x_pci.c new file +7
-0+if (!chip) { + ret = -EPROBE_DEFER ; + goto err_put_slot; + } + +/* Mark function 1's device as dependent on function 0 */ + link =device_link_add (dev, &slot0->dev,DL_FLAG_STATELESS );
[Severity: High]
Does creating a stateless device link correctly enforce unbind ordering? With DL_FLAG_STATELESS, if Function 0 is manually unbound via sysfs, its devres actions will immediately free the shared chip structure and unmap its PCI BARs. Meanwhile, Function 1 and its auxiliary devices would remain bound, potentially leading to a use-after-free and bus faults when they access the freed structure and disabled hardware.
drivers/misc/tc956x_pci.c line 555
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+if (!link) { + ret = -ENODEV ; + goto err_put_slot; + } + + ret =devm_add_action_or_reset (dev, chip_link_del, link); +if (ret) + goto err_put_slot; + +return chip;
[Severity: High]
Does this success path leak the PCI device reference? pci_get_slot() acquires a reference to Function 0's device, which is dropped in the error paths via pci_dev_put(slot0), but it appears the reference is never released here. Over multiple bind/unbind cycles, this could prevent the PCI device from ever being freed.
Quoted 6 lines
drivers/misc/tc956x_pci.c new file +6
-0+ +err_put_slot: +pci_dev_put (slot0); + +return ERR_PTR (ret); +}
[ ... ]
drivers/misc/tc956x_pci.c line 616
Quoted 8 lines
drivers/misc/tc956x_pci.c new file +8
-0+static int pcim_alloc_irq_vectors (struct pci_dev *pdev,unsigned int min_vecs, +unsigned int max_vecs,unsigned int flags) +{ +int ret; + + ret =pci_alloc_irq_vectors (pdev, min_vecs, max_vecs, flags); +if (ret) +return ret;
[Severity: High]pci_alloc_irq_vectors() returns the number of allocated vectors on success, which is a positive number. Does this check cause the function to return early on success, bypassing the devm_add_action_or_reset() below? This would leak IRQs if the probe fails later.
Quoted 7 lines
drivers/misc/tc956x_pci.c new file +7
-0+ +return devm_add_action_or_reset (&pdev->dev, pcim_free_irq_vectors, pdev); +} + +static int +tc956x_function_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{
[ ... ]
Quoted 15 lines
drivers/misc/tc956x_pci.c new file +15
-0+ ret =chip_init (chip, pdev); +if (ret) +return dev_err_probe (dev, ret,"failed to initialize chip\n" ); + + ret =function_xgmac_adev_add (pdev, chip, msigen_irq); +if (ret) +return dev_err_probe (dev, ret,"failed to add xgmap device\n" ); + +/* We're ready; the other function can now probe */ + dev->platform_data = chip; + +return 0 ; +} + +static void tc956x_function_remove (struct pci_dev *pdev)
drivers/misc/tc956x_pci.c line 679
Quoted 10 lines
drivers/misc/tc956x_pci.c new file +10
-0+{ +struct tc956x_chip *chip =dev_get_platdata (&pdev->dev); + +if (&pdev->dev == chip->dev) +chip_msigen_disable (chip); + +pci_free_irq_vectors (pdev); + +pci_clear_master (pdev); +}
[Severity: High]
Does this premature hardware teardown cause active child devices to access disabled hardware? Auxiliary child devices registered using devres will execute their remove callbacks after this tc956x_function_remove() completely finishes. However, the parent here actively resets hardware, disables clocks, clears PCI bus mastering, and frees IRQs before the children are dismantled. This could result in bus faults or system crashes when child devices later execute their teardown.
Also, calling pci_free_irq_vectors() here explicitly conflicts with the devres management established in pcim_alloc_irq_vectors() and could lead to a double-free once the success path in pcim_alloc_irq_vectors() is fixed.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v2 12/14 gpio: tc956x: add TC956x/QPS615 support
In reply to Alex ElderToshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver.
This driver is implemented using the generic regmap-based GPIO driver.
--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/gpio/gpio-tc956x.c
MAINTAINERS +1 -0
@@ -27057,6 +27057,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c TOSHIBA WMI HOTKEYS DRIVER
drivers/gpio/Kconfig +12 -0
@@ -743,6 +743,18 @@ config GPIO_TB10X select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_TC956X + tristate "Toshiba TC956X GPIO support" + depends on TOSHIBA_TC956X_PCI + select GPIO_REGMAP + default m + help + This enables support for the GPIO controller embedded in the Toshiba + TC956X (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. On some platforms, a few of the GPIO lines are used to + manage external resets. + config GPIO_TEGRA tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRA
drivers/gpio/Makefile +1 -0
@@ -178,6 +178,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_TC956X) += gpio-tc956x.o obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.o
drivers/gpio/gpio-tc956x.c new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] API Misuse: `fixed_direction_output` completely breaks direction querying and fails to enforce…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] API Misuse: fixed_direction_output completely breaks direction querying and fails to enforce input-only pins.
- [Low] Build failure due to assignment to non-existent member fixed_direction_mask in struct gpio_regmap_config. --
commit 5da78e90b4b1867131b8f557ae59d72ce4db9776
Author: Alex Elder <[email protected]>
gpio: tc956x: add TC956x/QPS615 support
This commit adds a generic regmap-based GPIO driver for the Toshiba TC956x Ethernet-AVB/TSN bridge. The device acts as an auxiliary device to the PCIe endpoint function driver.
Quoted 5 lines
drivers/gpio/gpio-tc956x.c new file +0
-0
[ ... ]
Quoted 3 lines
drivers/gpio/gpio-tc956x.c new file +3
-0+static int tc956x_gpio_probe (struct auxiliary_device *adev, +const struct auxiliary_device_id *id) +{
[ ... ]
drivers/gpio/gpio-tc956x.c line 100
Quoted 4 lines
drivers/gpio/gpio-tc956x.c new file +4
-0+ config.reg_stride =GPIO_REG_STRIDE ; + config.ngpio_per_reg =GPIO_PER_REG ; + config.init_valid_mask = tc956x_gpio_init_valid_mask; + config.fixed_direction_mask = fixed;
[Severity: Low]
Is fixed_direction_mask a valid member of struct gpio_regmap_config? It does not appear to be defined in include/linux/gpio/regmap.h, which could lead to a build failure here.
drivers/gpio/gpio-tc956x.c line 101
Quoted 1 line
drivers/gpio/gpio-tc956x.c new file +1
-0+ config.fixed_direction_output = zeroes;
[Severity: High]
Does providing an all-zeroes bitmap to fixed_direction_output achieve the intended input-only constraints?
Looking at gpio_regmap_get_direction() in drivers/gpio/gpio-regmap.c:
if (gpio->fixed_direction_output) {
if (test_bit(offset, gpio->fixed_direction_output))
return GPIO_LINE_DIRECTION_OUT;
else
return GPIO_LINE_DIRECTION_IN;
}Providing a non-NULL fixed_direction_output causes the API to bypass hardware direction queries for all pins, unconditionally reporting all 37 pins as inputs.
Furthermore, since reg_dir_in_base is also provided, the API will still allow users to configure these supposedly input-only pins as outputs because it does not check fixed_direction_output during set_direction operations.
Quoted 2 lines
drivers/gpio/gpio-tc956x.c new file +2
-0+ + gpio_regmap =devm_gpio_regmap_register (dev, &config);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Bartosz Golaszewski
maintainerRe: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
In reply to Alex ElderQuoted 137 lines · Alex Elder
Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver.
This driver is implemented using the generic regmap-based GPIO driver.
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/gpio/gpio-tc956x.cMAINTAINERS +1
-0@@ -27057,6 +27057,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c TOSHIBA WMI HOTKEYS DRIVERdrivers/gpio/Kconfig +12
-0@@ -743,6 +743,18 @@ config GPIO_TB10X select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_TC956X + tristate "Toshiba TC956X GPIO support" + depends on TOSHIBA_TC956X_PCI + select GPIO_REGMAP + default m + help + This enables support for the GPIO controller embedded in the Toshiba + TC956X (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. On some platforms, a few of the GPIO lines are used to + manage external resets. + config GPIO_TEGRA tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRAdrivers/gpio/Makefile +1
-0@@ -178,6 +178,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_TC956X) += gpio-tc956x.o obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.odrivers/gpio/gpio-tc956x.c new file +64
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +/* +* The Toshiba TC956X 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. +* +* 35 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". +* +* There is a TC956X PCI power controller driver that accesses the +* direction and output value registers for GPIOs 2 and 3. These +* GPIOs control the reset signal for the two downstream PCIe ports. +* Their values will never change during operation of this driver, and +* this driver reserves these two GPIOS. +*/ + +#include <linux/auxiliary_bus.h> +#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/gpio/regmap.h> + +#define DRIVER_NAME "tc956x-gpio" + +#define TC956X_GPIO_COUNT 37/* Number of GPIOs (20-21 reserved) */ + +/* The GPIO offsets are relative to 0x1200 in TC956X SFR space. */ +#define GPIO_IN0_OFFSET 0x00/* Input value (0-31) */ +#define GPIO_EN0_OFFSET 0x08/* 0: out; 1: in (0-31) */ +#define GPIO_OUT0_OFFSET 0x10/* Output value (0-31) */ + +/* +* 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 GPIO_PER_REG 32 +#define GPIO_REG_STRIDE 4 + +static int tc956x_gpio_init_valid_mask (struct gpio_chip *gc, +unsigned long *valid_mask, +unsigned int ngpios) +{ +/* +* GPIOs 2 and 3 are used by the PCI power control driver, and +* we don't allow them to be used. GPIOs 20 and 21 are reserved +* (and not usable). +*/ +bitmap_fill (valid_mask, ngpios); +bitmap_clear (valid_mask,2 ,2 ); +bitmap_clear (valid_mask,20 ,2 ); + +return 0 ; +} + +static int tc956x_gpio_probe (struct auxiliary_device *adev, +const struct auxiliary_device_id *id)
drivers/gpio/gpio-tc956x.c line 74
Quoted 10 lines
drivers/gpio/gpio-tc956x.c new file +10
-0+{ +DECLARE_BITMAP (zeroes,TC956X_GPIO_COUNT ); +DECLARE_BITMAP (fixed,TC956X_GPIO_COUNT ); +struct gpio_regmap_config config = { }; +struct gpio_regmap *gpio_regmap; +struct device *dev = &adev->dev; + +/* We need the regmap pointer, stored in our platform data */ +if (!dev->platform_data) +return -EINVAL ;
Please use the standardized accessor: dev_get_platdata().
Quoted 17 lines
drivers/gpio/gpio-tc956x.c new file +17
-0+ +/* +* Only some of our GPIOs are fixed direction: +* 22, 23, 24, 27, 28, 31, and 34 (all input-only) +* Set up the fixed bitmap to indicate which are fixed. +*/ +bitmap_zero (fixed,TC956X_GPIO_COUNT ); +bitmap_set (fixed,22 ,3 ); +bitmap_set (fixed,27 ,2 ); +set_bit (31 , fixed); +set_bit (34 , fixed); + +/* All fixed GPIOs are input; the zeroes bitmap indicates that. */ +bitmap_zero (zeroes,TC956X_GPIO_COUNT ); + + config.parent = dev; + config.regmap = dev->platform_data;
drivers/gpio/gpio-tc956x.c line 101
Quoted 10 lines
drivers/gpio/gpio-tc956x.c new file +10
-0+ config.label =DRIVER_NAME ; + config.ngpio =TC956X_GPIO_COUNT ; + config.reg_dat_base =GPIO_REGMAP_ADDR (GPIO_IN0_OFFSET ); + config.reg_set_base =GPIO_REGMAP_ADDR (GPIO_OUT0_OFFSET ); + config.reg_dir_in_base =GPIO_REGMAP_ADDR (GPIO_EN0_OFFSET ); + config.reg_stride =GPIO_REG_STRIDE ; + config.ngpio_per_reg =GPIO_PER_REG ; + config.init_valid_mask = tc956x_gpio_init_valid_mask; + config.fixed_direction_mask = fixed; + config.fixed_direction_output = zeroes;
May I suggest using a compound literal here like:
config = (struct gpio_regmap_config){
...
};?
drivers/gpio/gpio-tc956x.c line 107
Quoted 6 lines
drivers/gpio/gpio-tc956x.c new file +6
-0+ + gpio_regmap =devm_gpio_regmap_register (dev, &config); +if (IS_ERR (gpio_regmap)) +return PTR_ERR (gpio_regmap); + +return 0 ;
You can do:
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &config));
and save a few lines.
Quoted 24 lines
drivers/gpio/gpio-tc956x.c new file +23
-1+} + +static const struct auxiliary_device_id tc956x_gpio_ids[] = { + { .name ="tc956x_pci.tc9564-gpio" , }, + { } +}; +MODULE_DEVICE_TABLE (auxiliary, tc956x_gpio_ids); + +static struct auxiliary_driver tc956x_gpio_driver = { + .name =DRIVER_NAME , + .probe = tc956x_gpio_probe, + .id_table = tc956x_gpio_ids, + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + .probe_type =PROBE_PREFER_ASYNCHRONOUS , + }, +}; +module_auxiliary_driver (tc956x_gpio_driver); + +MODULE_DESCRIPTION ("Toshiba TC956X PCIe GPIO Driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("auxiliary:" DRIVER_NAME ); --
Quoted 3 lines
2.51.0
Bart
Re: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
In reply to Alex ElderQuoted 9 lines · Alex Elder
Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver.
This driver is implemented using the generic regmap-based GPIO driver.
While the regmap over the switch BAR works for GPIO access post-enumeration, there is a blocker in using these GPIOs to control the power to endpoints.
We have a design [1] where the GPIOs from the switch are used to control power and PERST# signals to the EP. With this current design, during the initial PCI bus scan, the switch will get enumerated, but the EP will not. Because, power to the EP depends on the GPIO Aux driver that will get probed only after the switch enumeration.
But this creates a chicken-and-egg problem with the PCI Pwrctrl design. pcie-qcom driver uses the Pwrctrl framework to power on the PCI endpoints before the initial PCI bus scan. It calls pci_pwrctrl_create_devices() and pci_pwrctrl_power_on_devices() APIs to create the platform device for all PCI devices defined in DT (that require pwrctrl support), waits for their respective pwrctrl drivers to get probed and then power ON all of them. This step is required because in DT platforms, many Root Ports are not hotplug capable and also BIOS doesn't assign bridge windows during boot. So all the devices has to appear during the initial PCI bus scan so that the PCI core can allocate the resources properly.
Now the issue with this Aux driver design is that, if an EP makes use of the switch GPIO for PERST# or power, like:
tc9563: pcie@0,0 {
compatible = "pci1179,0623";
reg = <0x10000 0x0 0x0 0x0 0x0>;
...
pcie@1,0 {
compatible = "pciclass,0604";
reg = <0x20800 0x0 0x0 0x0 0x0>;
#address-cells = <3>;
#size-cells = <2>;
device_type = "pci";
ranges;
bus-range = <0x3 0xff>;
reset-gpios = <&tc9563 5 GPIO_ACTIVE_LOW>;
};
...
};Then the pwrctrl driver (pci/pwrctrl/generic.c) will try to acquire the GPIO controller during its probe, but will fail with -EPROBE_DEFER as the GPIO controller won't be available at that time. So the whole PCIe instance will probe defer as the driver requires all pwrctrl drivers to be probed before starting the initial bus scan.
So we need to make sure that the GPIO controller driver is available before enumerating the switch device. One way to achieve is by creating the GPIO Aux device in the pci/pwrctrl/pci-pwrctrl-tc9563.c driver and let the GPIO controller driver use I2C communication for setting up the GPIOs. Thankfully, the switch allows both I2C and BAR MMIO configurations for internal GPIOs.
With this change, the GPIO driver will get probed by the time the pwrctrl generic driver acquires the 'reset-gpios' and will turn ON the EP.
Let me know your thoughts!
- Mani
[1] https://lore.kernel.org/linux-pci/e2inl7k5gsjj6oomv2k5ximuzpb3gfiz66ufet3b4hvov7zqt4@qz4pifbos7yf/
Quoted 197 lines
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/gpio/gpio-tc956x.cMAINTAINERS +1
-0@@ -27057,6 +27057,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c TOSHIBA WMI HOTKEYS DRIVERdrivers/gpio/Kconfig +12
-0@@ -743,6 +743,18 @@ config GPIO_TB10X select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_TC956X + tristate "Toshiba TC956X GPIO support" + depends on TOSHIBA_TC956X_PCI + select GPIO_REGMAP + default m + help + This enables support for the GPIO controller embedded in the Toshiba + TC956X (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. On some platforms, a few of the GPIO lines are used to + manage external resets. + config GPIO_TEGRA tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRAdrivers/gpio/Makefile +1
-0@@ -178,6 +178,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_TC956X) += gpio-tc956x.o obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.odrivers/gpio/gpio-tc956x.c new file +130
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +/* +* The Toshiba TC956X 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. +* +* 35 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". +* +* There is a TC956X PCI power controller driver that accesses the +* direction and output value registers for GPIOs 2 and 3. These +* GPIOs control the reset signal for the two downstream PCIe ports. +* Their values will never change during operation of this driver, and +* this driver reserves these two GPIOS. +*/ + +#include <linux/auxiliary_bus.h> +#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/gpio/regmap.h> + +#define DRIVER_NAME "tc956x-gpio" + +#define TC956X_GPIO_COUNT 37/* Number of GPIOs (20-21 reserved) */ + +/* The GPIO offsets are relative to 0x1200 in TC956X SFR space. */ +#define GPIO_IN0_OFFSET 0x00/* Input value (0-31) */ +#define GPIO_EN0_OFFSET 0x08/* 0: out; 1: in (0-31) */ +#define GPIO_OUT0_OFFSET 0x10/* Output value (0-31) */ + +/* +* 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 GPIO_PER_REG 32 +#define GPIO_REG_STRIDE 4 + +static int tc956x_gpio_init_valid_mask (struct gpio_chip *gc, +unsigned long *valid_mask, +unsigned int ngpios) +{ +/* +* GPIOs 2 and 3 are used by the PCI power control driver, and +* we don't allow them to be used. GPIOs 20 and 21 are reserved +* (and not usable). +*/ +bitmap_fill (valid_mask, ngpios); +bitmap_clear (valid_mask,2 ,2 ); +bitmap_clear (valid_mask,20 ,2 ); + +return 0 ; +} + +static int tc956x_gpio_probe (struct auxiliary_device *adev, +const struct auxiliary_device_id *id) +{ +DECLARE_BITMAP (zeroes,TC956X_GPIO_COUNT ); +DECLARE_BITMAP (fixed,TC956X_GPIO_COUNT ); +struct gpio_regmap_config config = { }; +struct gpio_regmap *gpio_regmap; +struct device *dev = &adev->dev; + +/* We need the regmap pointer, stored in our platform data */ +if (!dev->platform_data) +return -EINVAL ; + +/* +* Only some of our GPIOs are fixed direction: +* 22, 23, 24, 27, 28, 31, and 34 (all input-only) +* Set up the fixed bitmap to indicate which are fixed. +*/ +bitmap_zero (fixed,TC956X_GPIO_COUNT ); +bitmap_set (fixed,22 ,3 ); +bitmap_set (fixed,27 ,2 ); +set_bit (31 , fixed); +set_bit (34 , fixed); + +/* All fixed GPIOs are input; the zeroes bitmap indicates that. */ +bitmap_zero (zeroes,TC956X_GPIO_COUNT ); + + config.parent = dev; + config.regmap = dev->platform_data; + config.label =DRIVER_NAME ; + config.ngpio =TC956X_GPIO_COUNT ; + config.reg_dat_base =GPIO_REGMAP_ADDR (GPIO_IN0_OFFSET ); + config.reg_set_base =GPIO_REGMAP_ADDR (GPIO_OUT0_OFFSET ); + config.reg_dir_in_base =GPIO_REGMAP_ADDR (GPIO_EN0_OFFSET ); + config.reg_stride =GPIO_REG_STRIDE ; + config.ngpio_per_reg =GPIO_PER_REG ; + config.init_valid_mask = tc956x_gpio_init_valid_mask; + config.fixed_direction_mask = fixed; + config.fixed_direction_output = zeroes; + + gpio_regmap =devm_gpio_regmap_register (dev, &config); +if (IS_ERR (gpio_regmap)) +return PTR_ERR (gpio_regmap); + +return 0 ; +} + +static const struct auxiliary_device_id tc956x_gpio_ids[] = { + { .name ="tc956x_pci.tc9564-gpio" , }, + { } +}; +MODULE_DEVICE_TABLE (auxiliary, tc956x_gpio_ids); + +static struct auxiliary_driver tc956x_gpio_driver = { + .name =DRIVER_NAME , + .probe = tc956x_gpio_probe, + .id_table = tc956x_gpio_ids, + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + .probe_type =PROBE_PREFER_ASYNCHRONOUS , + }, +}; +module_auxiliary_driver (tc956x_gpio_driver); + +MODULE_DESCRIPTION ("Toshiba TC956X PCIe GPIO Driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("auxiliary:" DRIVER_NAME );Signature · 1 line
2.51.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Andrew Lunn
maintainerRe: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
Quoted 5 lines
So we need to make sure that the GPIO controller driver is available before enumerating the switch device. One way to achieve is by creating the GPIO Aux device in the
pci/pwrctrl/pci-pwrctrl-tc9563.cdriver and let the GPIO controller driver use I2C communication for setting up the GPIOs. Thankfully, the switch allows both I2C and BAR MMIO configurations for internal GPIOs.
There was a comment from Rob that the GPIO controller should be associated with the upstream port of the switch. And there was a way to do that.
What we need to ensure is that the GPIO controller has an independent lifetime to the downstream ports. That would allow the downstream ports to return EPROBE_AGAIN, if the GPIO controller associated to the upstream port is still initialising.
Andrew
Re: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
In reply to Manivannan SadhasivamQuoted 8 lines · Manivannan Sadhasivam
Quoted 7 lines · Alex Elder
Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver.
Quoted 5 lines
Quoted 2 lines
This driver is implemented using the generic regmap-based GPIO driver.
While the regmap over the switch BAR works for GPIO access post-enumeration, there is a blocker in using these GPIOs to control the power to endpoints.
We're aware of the power control driver and its use of these GPIOs.
I think the point you're making is not about the specific way we are using GPIOs, but that someone could try to use this GPIO controller in a way that would lead to a circular dependency (between the controller and the PCIe device it depends on).
And you suggest a GPIO driver that uses I2C (and would be used by the pwrctrl driver as well), and I think it's a pretty reasonable suggestion.
Quoted 5 lines
We have a design [1] where the GPIOs from the switch are used to control power and PERST# signals to the EP. With this current design, during the initial PCI bus scan, the switch will get enumerated, but the EP will not. Because, power to the EP depends on the GPIO Aux driver that will get probed only after the switch enumeration.
Yes, on the RB3gen2 platform, reset signals (PERST#) for two of the TC9563 PCIe switch ports (downstream 1 and downstream 2) are managed by the GPIO controller that resides within the TC9563 itself. The pwrctl driver takes special care to ensure the GPIO controller is functional (powered) before trying to use it.
The TC9563 *chip* gets powered when its embedded PCIe switch is probed--that is, when its upstream port begins its enumeration. (It's a little unclear to me which of the supplies are required for the various non-PCIe components on the chip, including I2C and GPIO, to be functional.)
And so until the switch gets probed (and its pwrctl driver used),
the GPIO controller can't work. So nothing internal to the TC956x should be dependent on any of the GPIOs supplied by this controller. (Except the pwrctrl driver, which enables power before using GPIO.)
Two things to note:
- We are working with TC9564 (and there are other successors in the TC956x series).
- Downstream port 3 (which we are using) on the switch does not have such a distinct controlled reset line.
Quoted 6 lines
But this creates a chicken-and-egg problem with the PCI Pwrctrl design. pcie-qcom driver uses the Pwrctrl framework to power on the PCI endpoints before the initial PCI bus scan. It calls
pci_pwrctrl_create_devices()andpci_pwrctrl_power_on_devices()APIs to create the platform device for all PCI devices defined in DT (that require pwrctrl support), waits for their respective pwrctrl drivers to get probed and then power ON all of them.
The way I understood it was that certain parameters for the PCIe links needed to be set before using them, and the pwrctrl framework made that possible. (I summarize what that driver does at the end of this message.)
This step is
Quoted 4 lines
required because in DT platforms, many Root Ports are not hotplug capable and also BIOS doesn't assign bridge windows during boot. So all the devices has to appear during the initial PCI bus scan so that the PCI core can allocate the resources properly.
This part I didn't know before. Yes, the bridge windows are allocated by Linux rather than by firmware. And if this host bridge doesn't support hotplug, then yes, to correctly assign address space, all PCIe devices must be available to report their required memory space.
Are you saying that "setting those parameters" wouldn't be needed if this particular root port supported hotplug? (I'm just curious; it's not relevant to the point you're making.)
Quoted 24 lines
Now the issue with this Aux driver design is that, if an EP makes use of the switch GPIO for PERST# or power, like:
tc9563: pcie@0,0 { compatible = "pci1179,0623"; reg = <0x10000 0x0 0x0 0x0 0x0>; ... pcie@1,0 { compatible = "pciclass,0604"; reg = <0x20800 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges; bus-range = <0x3 0xff>; reset-gpios = <&tc9563 5 GPIO_ACTIVE_LOW>; }; ... };
Quoted 5 lines
Then the pwrctrl driver (
pci/pwrctrl/generic.c) will try to acquire the GPIO controller during its probe, but will fail with -EPROBE_DEFER as the GPIO controller won't be available at that time. So the whole PCIe instance will probe defer as the driver requires all pwrctrl drivers to be probed before starting the initial bus scan.
The only GPIOs we're using are for asserting reset on the two Ethernet PHYs. That doesn't occur until after the embedded endpoint functions are probed, so this should be OK.
However you're right, the lines on this GPIO controller should be restricted to avoid this circular dependency.
Quoted 5 lines
So we need to make sure that the GPIO controller driver is available before enumerating the switch device. One way to achieve is by creating the GPIO Aux device in the
pci/pwrctrl/pci-pwrctrl-tc9563.cdriver and let the GPIO controller driver use I2C communication for setting up the GPIOs. Thankfully, the switch allows both I2C and BAR MMIO configurations for internal GPIOs.
Daniel and I have talked about this solution exactly, but opted not to propose using it just yet (not unless someone like you suggested it...). Our solution for now was just to have the (PCIe BAR-based) GPIO driver reserve the two GPIO lines used by the pwrctrl driver, and rely on the fact that the pwrctrl driver will only touch those shared registers at times the "real" GPIO driver does not.
We could instead implement a "proper" I2C-based GPIO controller driver. This would be used by the pwrctrl driver (rather than that driver just updating the registers directly), as well as the Ethernet PHY for reset control, and for any other uses on future platforms.
All uses so far are for managing resets, so the higher I2C latency wouldn't be much of an issue.
Quoted 2 lines
With this change, the GPIO driver will get probed by the time the pwrctrl generic driver acquires the 'reset-gpios' and will turn ON the EP.
One thing I'll point out is that the next version of this code will define "pci-ep-bus" nodes, and will not use the auxiliary bus model. However the issue you raise remains in that model too.
Thank you very much for raising this Mani. Please see my questions a little further below.
-Alex
Quoted 5 lines
Let me know your thoughts!
- Mani
[1] https://lore.kernel.org/linux-pci/e2inl7k5gsjj6oomv2k5ximuzpb3gfiz66ufet3b4hvov7zqt4@qz4pifbos7yf/
Here's what the pwrctrl driver does:
In drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c, the registers at offset 0x1208 and 0x1210 from the base of the "SFR" address space are updated to assert/deassert these two reset signals. It does so using the I2C interface--out of band from access via PCI BARs. The reset signals are GPIO02 (for downstream endpoint 1 on the switch) and GPIO03 (for endpoint 2), which are controlled by bits 2 and 3 in the two registers, respectively.
The pwrctrl driver enables a set of regulators defined in the devicetree node for the upstream port of the TC9564 embedded PCIe switch. It then asserts the main RESX (chip) reset signal, and after a short delay asserts these other two resets.
At that point it uses properties defined in devicetree to
configure five "ports": upstream, downstream 1-3, and Ethernet.
(I have some questions related to this--but I put them below.)
The properties configured are: ASPM L0s entry delay; ASP L1 entry
delay; TX amplitude; Number of Fast Training Sequences (NTFS); and Decision Feedback Equalization (DFE).
Finally, the two resets and the main RESX reset are deasserted, and the driver reports that the device is now ready, with:
devm_pci_pwrctrl_device_set_ready();
Questions related to the "ports" configured by the pwrctrl driver:
- Given that downstream port 3 connects to the internal, embedded PCIe endpoint, does it still require these settings programmed?
- Does the TC9563 chip have only *one* function on its embedded endpoint, supporting just one Ethernet?
- If so, this driver will have to be modified to support the second embedded function and Ethernet controller.
- Why is "Ethernet" configured like the PCIe ports, *in addition* to the downstream port 3 that it sits behind?
Quoted 198 lines
Quoted 197 lines
Co-developed-by Daniel Thompson <[email protected]>Signed-off-by Daniel Thompson <[email protected]>Signed-off-by Alex Elder <[email protected]>--- MAINTAINERS | 1 + drivers/gpio/Kconfig | 12 ++++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+)create mode 100644
drivers/gpio/gpio-tc956x.cMAINTAINERS +1
-0@@ -27057,6 +27057,7 @@ M: Alex Elder <[email protected]> M: Daniel Thompson <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml +F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c TOSHIBA WMI HOTKEYS DRIVERdrivers/gpio/Kconfig +12
-0@@ -743,6 +743,18 @@ config GPIO_TB10X select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_TC956X + tristate "Toshiba TC956X GPIO support" + depends on TOSHIBA_TC956X_PCI + select GPIO_REGMAP + default m + help + This enables support for the GPIO controller embedded in the Toshiba + TC956X (and Qualcomm QPS615). This device connects to the host + via PCIe port, which is the upstream port on an internal PCIe + switch. On some platforms, a few of the GPIO lines are used to + manage external resets. + config GPIO_TEGRA tristate "NVIDIA Tegra GPIO support" default ARCH_TEGRAdrivers/gpio/Makefile +1
-0@@ -178,6 +178,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_TC956X) += gpio-tc956x.o obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.odrivers/gpio/gpio-tc956x.c new file +130
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +*/ + +/* +* The Toshiba TC956X 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. +* +* 35 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". +* +* There is a TC956X PCI power controller driver that accesses the +* direction and output value registers for GPIOs 2 and 3. These +* GPIOs control the reset signal for the two downstream PCIe ports. +* Their values will never change during operation of this driver, and +* this driver reserves these two GPIOS. +*/ + +#include <linux/auxiliary_bus.h> +#include <linux/gpio/driver.h> +#include <linux/module.h> +#include <linux/regmap.h> +#include <linux/gpio/regmap.h> + +#define DRIVER_NAME "tc956x-gpio" + +#define TC956X_GPIO_COUNT 37/* Number of GPIOs (20-21 reserved) */ + +/* The GPIO offsets are relative to 0x1200 in TC956X SFR space. */ +#define GPIO_IN0_OFFSET 0x00/* Input value (0-31) */ +#define GPIO_EN0_OFFSET 0x08/* 0: out; 1: in (0-31) */ +#define GPIO_OUT0_OFFSET 0x10/* Output value (0-31) */ + +/* +* 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 GPIO_PER_REG 32 +#define GPIO_REG_STRIDE 4 + +static int tc956x_gpio_init_valid_mask (struct gpio_chip *gc, +unsigned long *valid_mask, +unsigned int ngpios) +{ +/* +* GPIOs 2 and 3 are used by the PCI power control driver, and +* we don't allow them to be used. GPIOs 20 and 21 are reserved +* (and not usable). +*/ +bitmap_fill (valid_mask, ngpios); +bitmap_clear (valid_mask,2 ,2 ); +bitmap_clear (valid_mask,20 ,2 ); + +return 0 ; +} + +static int tc956x_gpio_probe (struct auxiliary_device *adev, +const struct auxiliary_device_id *id) +{ +DECLARE_BITMAP (zeroes,TC956X_GPIO_COUNT ); +DECLARE_BITMAP (fixed,TC956X_GPIO_COUNT ); +struct gpio_regmap_config config = { }; +struct gpio_regmap *gpio_regmap; +struct device *dev = &adev->dev; + +/* We need the regmap pointer, stored in our platform data */ +if (!dev->platform_data) +return -EINVAL ; + +/* +* Only some of our GPIOs are fixed direction: +* 22, 23, 24, 27, 28, 31, and 34 (all input-only) +* Set up the fixed bitmap to indicate which are fixed. +*/ +bitmap_zero (fixed,TC956X_GPIO_COUNT ); +bitmap_set (fixed,22 ,3 ); +bitmap_set (fixed,27 ,2 ); +set_bit (31 , fixed); +set_bit (34 , fixed); + +/* All fixed GPIOs are input; the zeroes bitmap indicates that. */ +bitmap_zero (zeroes,TC956X_GPIO_COUNT ); + + config.parent = dev; + config.regmap = dev->platform_data; + config.label =DRIVER_NAME ; + config.ngpio =TC956X_GPIO_COUNT ; + config.reg_dat_base =GPIO_REGMAP_ADDR (GPIO_IN0_OFFSET ); + config.reg_set_base =GPIO_REGMAP_ADDR (GPIO_OUT0_OFFSET ); + config.reg_dir_in_base =GPIO_REGMAP_ADDR (GPIO_EN0_OFFSET ); + config.reg_stride =GPIO_REG_STRIDE ; + config.ngpio_per_reg =GPIO_PER_REG ; + config.init_valid_mask = tc956x_gpio_init_valid_mask; + config.fixed_direction_mask = fixed; + config.fixed_direction_output = zeroes; + + gpio_regmap =devm_gpio_regmap_register (dev, &config); +if (IS_ERR (gpio_regmap)) +return PTR_ERR (gpio_regmap); + +return 0 ; +} + +static const struct auxiliary_device_id tc956x_gpio_ids[] = { + { .name ="tc956x_pci.tc9564-gpio" , }, + { } +}; +MODULE_DEVICE_TABLE (auxiliary, tc956x_gpio_ids); + +static struct auxiliary_driver tc956x_gpio_driver = { + .name =DRIVER_NAME , + .probe = tc956x_gpio_probe, + .id_table = tc956x_gpio_ids, + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + .probe_type =PROBE_PREFER_ASYNCHRONOUS , + }, +}; +module_auxiliary_driver (tc956x_gpio_driver); + +MODULE_DESCRIPTION ("Toshiba TC956X PCIe GPIO Driver" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("auxiliary:" DRIVER_NAME );Signature · 1 line
2.51.0
Re: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
Quoted 15 lines · Alex Elder
Quoted 8 lines · Manivannan Sadhasivam
Quoted 7 lines · Alex Elder
Toshiba TC956x is an Ethernet-AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes a GPIO block that can be accessed, alongside several other peripherals, via two PCIe endpoint functions. The PCIe function driver creates an auxiliary device for the GPIO block, and that device gets bound to this auxiliary device driver.
Quoted 5 lines
Quoted 2 lines
This driver is implemented using the generic regmap-based GPIO driver.
While the regmap over the switch BAR works for GPIO access post-enumeration, there is a blocker in using these GPIOs to control the power to endpoints.
Quoted 7 lines
We're aware of the power control driver and its use of these GPIOs.
I think the point you're making is not about the specific way we are using GPIOs, but that someone could try to use this GPIO controller in a way that would lead to a circular dependency (between the controller and the PCIe device it depends on).
This not a future problem, but a present one :)
Quoted 16 lines
And you suggest a GPIO driver that uses I2C (and would be used by the pwrctrl driver as well), and I think it's a pretty reasonable suggestion.
Quoted 5 lines
We have a design [1] where the GPIOs from the switch are used to control power and PERST# signals to the EP. With this current design, during the initial PCI bus scan, the switch will get enumerated, but the EP will not. Because, power to the EP depends on the GPIO Aux driver that will get probed only after the switch enumeration.
Yes, on the RB3gen2 platform, reset signals (PERST#) for two of the TC9563 PCIe switch ports (downstream 1 and downstream 2) are managed by the GPIO controller that resides within the TC9563 itself. The pwrctl driver takes special care to ensure the GPIO controller is functional (powered) before trying to use it.
Quoted 6 lines
The TC9563 *chip* gets powered when its embedded PCIe switch is probed--that is, when its upstream port begins its enumeration. (It's a little unclear to me which of the supplies are required for the various non-PCIe components on the chip, including I2C and GPIO, to be functional.)
Well, the TC9563 should get powered ON when its pwrctrl driver gets probed and the pci_pwrctrl_power_on_device() is called. There is no dependency with the upstream port enumeration AFAIK.
Quoted 19 lines
And so until the switch gets probed (and its pwrctl driver used), the GPIO controller can't work. So nothing internal to the TC956x should be dependent on any of the GPIOs supplied by this controller. (Except the pwrctrl driver, which enables power before using GPIO.)
Two things to note:
- We are working with TC9564 (and there are other successors in the TC956x series).
- Downstream port 3 (which we are using) on the switch does not have such a distinct controlled reset line.Quoted 6 lines
But this creates a chicken-and-egg problem with the PCI Pwrctrl design. pcie-qcom driver uses the Pwrctrl framework to power on the PCI endpoints before the initial PCI bus scan. It calls
pci_pwrctrl_create_devices()andpci_pwrctrl_power_on_devices()APIs to create the platform device for all PCI devices defined in DT (that require pwrctrl support), waits for their respective pwrctrl drivers to get probed and then power ON all of them.
Quoted 5 lines
The way I understood it was that certain parameters for the PCIe links needed to be set before using them, and the pwrctrl framework made that possible. (I summarize what that driver does at the end of this message.)
Yeah, it does handle both power ON and some configuration for stable operation.
Quoted 12 lines
This step is
Quoted 4 lines
required because in DT platforms, many Root Ports are not hotplug capable and also BIOS doesn't assign bridge windows during boot. So all the devices has to appear during the initial PCI bus scan so that the PCI core can allocate the resources properly.
This part I didn't know before. Yes, the bridge windows are allocated by Linux rather than by firmware. And if this host bridge doesn't support hotplug, then yes, to correctly assign address space, all PCIe devices must be available to report their required memory space.
Quoted 4 lines
Are you saying that "setting those parameters" wouldn't be needed if this particular root port supported hotplug? (I'm just curious; it's not relevant to the point you're making.)
Yeah, more or less. If the Root Port is hotplug capable, PCI core will allocate more resources like bridge windows and bus numbers in anticipation of devices getting attached to it after boot. But that also sometimes becomes insufficient if a resource hungry device like GPU gets plugged in later, as the PCI core can only guess the memory for hotplug capable Root Port.
Quoted 42 lines
Quoted 24 lines
Now the issue with this Aux driver design is that, if an EP makes use of the switch GPIO for PERST# or power, like:
tc9563: pcie@0,0 { compatible = "pci1179,0623"; reg = <0x10000 0x0 0x0 0x0 0x0>; ... pcie@1,0 { compatible = "pciclass,0604"; reg = <0x20800 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges; bus-range = <0x3 0xff>; reset-gpios = <&tc9563 5 GPIO_ACTIVE_LOW>; }; ... };Quoted 5 lines
Then the pwrctrl driver (
pci/pwrctrl/generic.c) will try to acquire the GPIO controller during its probe, but will fail with -EPROBE_DEFER as the GPIO controller won't be available at that time. So the whole PCIe instance will probe defer as the driver requires all pwrctrl drivers to be probed before starting the initial bus scan.The only GPIOs we're using are for asserting reset on the two Ethernet PHYs. That doesn't occur until after the embedded endpoint functions are probed, so this should be OK.
However you're right, the lines on this GPIO controller should be restricted to avoid this circular dependency.
Quoted 5 lines
So we need to make sure that the GPIO controller driver is available before enumerating the switch device. One way to achieve is by creating the GPIO Aux device in the
pci/pwrctrl/pci-pwrctrl-tc9563.cdriver and let the GPIO controller driver use I2C communication for setting up the GPIOs. Thankfully, the switch allows both I2C and BAR MMIO configurations for internal GPIOs.
Quoted 8 lines
Daniel and I have talked about this solution exactly, but opted not to propose using it just yet (not unless someone like you suggested it...). Our solution for now was just to have the (PCIe BAR-based) GPIO driver reserve the two GPIO lines used by the pwrctrl driver, and rely on the fact that the pwrctrl driver will only touch those shared registers at times the "real" GPIO driver does not.
Yeah. If those GPIO lines are not used to power up any endpoint devices, then there should be no issues. But this is something we cannot control as the board designers can do whatever they want.
Quoted 7 lines
We could instead implement a "proper" I2C-based GPIO controller driver. This would be used by the pwrctrl driver (rather than that driver just updating the registers directly), as well as the Ethernet PHY for reset control, and for any other uses on future platforms.
Sounds like a plan.
Quoted 11 lines
All uses so far are for managing resets, so the higher I2C latency wouldn't be much of an issue.
Quoted 2 lines
With this change, the GPIO driver will get probed by the time the pwrctrl generic driver acquires the 'reset-gpios' and will turn ON the EP.
One thing I'll point out is that the next version of this code will define "pci-ep-bus" nodes, and will not use the auxiliary bus model. However the issue you raise remains in that model too.
Please do CC me on the upcoming versions as well.
Quoted 27 lines
Thank you very much for raising this Mani. Please see my questions a little further below.
-Alex
Quoted 5 lines
Let me know your thoughts!
- Mani
[1] https://lore.kernel.org/linux-pci/e2inl7k5gsjj6oomv2k5ximuzpb3gfiz66ufet3b4hvov7zqt4@qz4pifbos7yf/
Here's what the pwrctrl driver does:
In
drivers/pci/pwrctrl/pci-pwrctrl-tc9563.c, the registers at offset0x1208and0x1210from the base of the "SFR" address space are updated to assert/deassert these two reset signals. It does so using the I2C interface--out of band from access via PCI BARs. The reset signals are GPIO02 (for downstream endpoint 1 on the switch) and GPIO03 (for endpoint 2), which are controlled by bits 2 and 3 in the two registers, respectively.The pwrctrl driver enables a set of regulators defined in the devicetree node for the upstream port of the TC9564 embedded PCIe switch. It then asserts the main RESX (chip) reset signal, and after a short delay asserts these other two resets.
Quoted 7 lines
At that point it uses properties defined in devicetree to configure five "ports": upstream, downstream 1-3, and Ethernet. (I have some questions related to this--but I put them below.) The properties configured are: ASPM L0s entry delay; ASP L1 entry delay; TX amplitude; Number of Fast Training Sequences (NTFS); and Decision Feedback Equalization (DFE).
The driver confuses between ports and endpoint. TC9563_ETHERNET is not a port, but an integrated endpoint. I've identified some issues while reviewing it now. Will try to fix them asap.
Quoted 10 lines
Finally, the two resets and the main RESX reset are deasserted, and the driver reports that the device is now ready, with:
devm_pci_pwrctrl_device_set_ready();Questions related to the "ports" configured by the pwrctrl driver:
- Given that downstream port 3 connects to the internal, embedded PCIe endpoint, does it still require these settings programmed?
Not all of the settings are applicable to all ports. Only ASPM and N_FTS are applicable to all ports and endpoints, but the rest are optional. But the driver treats all properties mandatory for all ports/endpoint, and safeguards itself by having some absurd checks. This is something I'm going to fix.
Quoted 5 lines
- Does the TC9563 chip have only *one* function on its embedded endpoint, supporting just one Ethernet?
- If so, this driver will have to be modified to support the second embedded function and Ethernet controller.
The driver assumes only one endpoint, but the binding lists 2. So the driver is not complying with its own binding now :/
So technically, the driver supports 2 integrated endpoints.
Quoted 3 lines
- Why is "Ethernet" configured like the PCIe ports, *in addition* to the downstream port 3 that it sits behind?
Both ASPM and N_FTS properties are applicable to ports and integrated endpoints as well. But other 2, DFE and Tx Amplitude are only applicable to ports only, excluding DSP3.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH net-next v2 12/14] gpio: tc956x: add TC956x/QPS615 support
On Tue, Jul 21, 2026 at 04:43:21PM +0200, Manivannan Sadhasivam wrote:
[...]
Quoted 11 lines
Quoted 5 lines
- Does the TC9563 chip have only *one* function on its embedded endpoint, supporting just one Ethernet?
- If so, this driver will have to be modified to support the second embedded function and Ethernet controller.The driver assumes only one endpoint, but the binding lists 2. So the driver is not complying with its own binding now :/
So technically, the driver supports 2 integrated endpoints.
I was wrong here. Driver supports only one endpoint and that's due to TC9563's hw limitation. I confused two functions defined in the binding with endpoints.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH v2 13/14 net: stmmac: tc956x: add TC956x/QPS615 support
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC.
The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs.
Add a driver for the eMAC/MSIGEN combination.
--- MAINTAINERS | 2 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ 4 files changed, 836 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c
MAINTAINERS +2 -0
@@ -27059,6 +27059,8 @@ S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c +F: drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c +F: include/soc/toshiba/tc956x-dwmac.h TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]>
drivers/net/ethernet/stmicro/stmmac/Kconfig +14 -0
@@ -404,6 +404,20 @@ config DWMAC_MOTORCOMM This enables glue driver for Motorcomm DWMAC-based PCI Ethernet controllers. Currently only YT6801 is supported. +config DWMAC_TC956X + tristate "Toshiba TC956X DWMAC support" + depends on PCI + depends on COMMON_CLK + depends on TOSHIBA_TC956X_PCI + default TOSHIBA_TC956X_PCI + select GENERIC_IRQ_CHIP + help + This selects the Toshiba TC956X (and Qualcomm QPS615) support in the + stmmac driver. + + This provides support for the ethernet controllers found on these + devices. + config STMMAC_PCI tristate "STMMAC PCI bus support" depends on PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -0
@@ -51,4 +51,6 @@ obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o obj-$(CONFIG_DWMAC_MOTORCOMM) += dwmac-motorcomm.o +obj-$(CONFIG_TC956X_PCI) += tc956x-pci.o +obj-$(CONFIG_DWMAC_TC956X) += dwmac-tc956x.o stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +818 -0
818 lines not on this page · raw message
Signature · 1 line
2.51.0
Rob Herring
maintainerRe: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support
Quoted 12 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC.
The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs.
Quoted 5 lines
Add a driver for the eMAC/MSIGEN combination.
Co-developed-by Alex Elder <[email protected]>Signed-off-by Alex Elder <[email protected]>Signed-off-by Daniel Thompson <[email protected]>
The order is wrong here unless you worked on it and then Daniel took over. Tags should be chronological order.
Quoted 64 lines
--- MAINTAINERS | 2 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ 4 files changed, 836 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.cMAINTAINERS +2
-0@@ -27059,6 +27059,8 @@ S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c +F: drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c +F: include/soc/toshiba/tc956x-dwmac.h TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]>drivers/net/ethernet/stmicro/stmmac/Kconfig +14
-0@@ -404,6 +404,20 @@ config DWMAC_MOTORCOMM This enables glue driver for Motorcomm DWMAC-based PCI Ethernet controllers. Currently only YT6801 is supported. +config DWMAC_TC956X + tristate "Toshiba TC956X DWMAC support" + depends on PCI + depends on COMMON_CLK + depends on TOSHIBA_TC956X_PCI + default TOSHIBA_TC956X_PCI + select GENERIC_IRQ_CHIP + help + This selects the Toshiba TC956X (and Qualcomm QPS615) support in the + stmmac driver. + + This provides support for the ethernet controllers found on these + devices. + config STMMAC_PCI tristate "STMMAC PCI bus support" depends on PCIdrivers/net/ethernet/stmicro/stmmac/Makefile +2
-0@@ -51,4 +51,6 @@ obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o obj-$(CONFIG_DWMAC_MOTORCOMM) += dwmac-motorcomm.o +obj-$(CONFIG_TC956X_PCI) += tc956x-pci.o +obj-$(CONFIG_DWMAC_TC956X) += dwmac-tc956x.o stmmac-pci-objs:= stmmac_pci.odrivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +1
-0@@ -0,0 +1,818 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 11
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +10
-0+ +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +* +* Derived from code having the following copyrights: +* Copyright (C) 2011-2012 Vayavya Labs Pvt Ltd +* Copyright (C) 2025 Toshiba Electronic Devices & Storage Corporation +*/ + +#include <linux/auxiliary_bus.h>
Based on the block diagram, these are PCI devices. Auxiliary bus is the wrong thing to use here.
Rob
Re: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support
Quoted 13 lines · Rob Herring
Quoted 12 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC.
The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs.
Quoted 8 lines
Quoted 5 lines
Add a driver for the eMAC/MSIGEN combination.
Co-developed-by Alex Elder <[email protected]>Signed-off-by Alex Elder <[email protected]>Signed-off-by Daniel Thompson <[email protected]>The order is wrong here unless you worked on it and then Daniel took over. Tags should be chronological order.
I think this was a dumb reorder I did to address a complaint from checkpatch, but in any case I'll fix this. Yes, my signoff should "wrap" the others.
Quoted 69 lines
Quoted 69 lines
--- MAINTAINERS | 2 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ 4 files changed, 836 insertions(+)create mode 100644
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.cMAINTAINERS +2
-0@@ -27059,6 +27059,8 @@ S: Maintained F: Documentation/devicetree/bindings/net/toshiba,tc956x-dwmac.yaml F: drivers/gpio/gpio-tc956x.c F: drivers/misc/tc956x_pci.c +F: drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c +F: include/soc/toshiba/tc956x-dwmac.h TOSHIBA WMI HOTKEYS DRIVER M: Azael Avalos <[email protected]>drivers/net/ethernet/stmicro/stmmac/Kconfig +14
-0@@ -404,6 +404,20 @@ config DWMAC_MOTORCOMM This enables glue driver for Motorcomm DWMAC-based PCI Ethernet controllers. Currently only YT6801 is supported. +config DWMAC_TC956X + tristate "Toshiba TC956X DWMAC support" + depends on PCI + depends on COMMON_CLK + depends on TOSHIBA_TC956X_PCI + default TOSHIBA_TC956X_PCI + select GENERIC_IRQ_CHIP + help + This selects the Toshiba TC956X (and Qualcomm QPS615) support in the + stmmac driver. + + This provides support for the ethernet controllers found on these + devices. + config STMMAC_PCI tristate "STMMAC PCI bus support" depends on PCIdrivers/net/ethernet/stmicro/stmmac/Makefile +2
-0@@ -51,4 +51,6 @@ obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o obj-$(CONFIG_DWMAC_MOTORCOMM) += dwmac-motorcomm.o +obj-$(CONFIG_TC956X_PCI) += tc956x-pci.o +obj-$(CONFIG_DWMAC_TC956X) += dwmac-tc956x.o stmmac-pci-objs:= stmmac_pci.odrivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +6
-0@@ -0,0 +1,818 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Copyright (C) 2026 by RISCstar Solutions Corporation. All rights reserved. +* +* Derived from code having the following copyrights:
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 11
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +5
-0+* Copyright (C) 2011-2012 Vayavya Labs Pvt Ltd +* Copyright (C) 2025 Toshiba Electronic Devices & Storage Corporation +*/ + +#include <linux/auxiliary_bus.h> Based on the block diagram, these are PCI devices. Auxiliary bus is the wrong thing to use here.
As I said in the other message, I'm going to rearrange this to use pci-ep-bus and platform drivers. Most of the core code should be stay the same but the overall structure will change.
Thanks for your suggestions.
-Alex
Quoted 2 lines
Rob
Maxime Chevallier
maintainerRe: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support
In reply to Alex ElderHi Alex,
Quoted 18 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC.
The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs.
Add a driver for the eMAC/MSIGEN combination.
Co-developed-by Alex Elder <[email protected]>Signed-off-by Alex Elder <[email protected]>Signed-off-by Daniel Thompson <[email protected]>---
[...]
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 559
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +4
-0+static int tc956x_lookup_max_speed (phy_interface_t phy_interface) +{ +switch (phy_interface) { +case PHY_INTERFACE_MODE_SGMII :
The SGMII definition we use in the kernel is the Cisco SGMII de-facto standard that only supports 10/100/1000M. Some vendors use flavours with names such as HS-SGMII and such, that's basically SGMII clocked at 2.5G with aneg disabled. It kinda becomes 2500BaseX then.
So all in all, we don't support 2500M on SGMII.
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 565
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +6
-0+case PHY_INTERFACE_MODE_2500BASEX : +return SPEED_2500 ; + +default : +return -EOPNOTSUPP ; + }
Maxime
Re: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support
Quoted 23 lines · Maxime Chevallier
Hi Alex,
Quoted 18 lines · Alex Elder
From: Daniel Thompson <[email protected]>
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. TC956x includes an "eMAC" subsystem that can be accessed, along with several other peripherals, via two PCIe endpoint functions. There is a main driver for the endpoint that decomposes things and creates auxiliary bus devices to model the SoC.
The eMAC consists of a Designware XGMAC, XPCS and PMA. Each eMAC is supported by an MSIGEN that bridges TC956x level interrupts to PCIe MSIs.
Add a driver for the eMAC/MSIGEN combination.
Co-developed-by Alex Elder <[email protected]>Signed-off-by Alex Elder <[email protected]>Signed-off-by Daniel Thompson <[email protected]>---
[...]
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 559
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +4
-0+static int tc956x_lookup_max_speed (phy_interface_t phy_interface) +{ +switch (phy_interface) { +case PHY_INTERFACE_MODE_SGMII :The SGMII definition we use in the kernel is the Cisco SGMII de-facto standard that only supports 10/100/1000M. Some vendors use flavours with names such as HS-SGMII and such, that's basically SGMII clocked at 2.5G with aneg disabled. It kinda becomes 2500BaseX then.
So for SGMII then, the max speed returned/used should be SPEED_1000, correct? And for 2500BASEX it's SPEED_2500. (I'll fix this.)
For USXGMII I presume we'd use SPEED_10000 as the max_speed.
Can someone explain when the plat_stmmacenet_data->max_speed value must be set? It seems like plat_stmmacenet_data->phy_interface should normally imply the right maximum speed. It looks like phylink_interface_max_speed() has a big switch statement related to this.
Thanks.
-Alex
Quoted 10 lines
So all in all, we don't support 2500M on SGMII.
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 565
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +6
-0+case PHY_INTERFACE_MODE_2500BASEX : +return SPEED_2500 ; + +default : +return -EOPNOTSUPP ; + }Maxime
[email protected]
AI reviewRe: [PATCH net-next v2 13/14] net: stmmac: tc956x: add TC956x/QPS615 support
In reply to Alex ElderThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Leaked IRQ mappings and potential Use-After-Free on the probe error path if IRQ mapping or…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Leaked IRQ mappings and potential Use-After-Free on the probe error path if IRQ mapping or resource initialization fails.
- [High] Uninitialized stack variables passed to devm_irq_domain_instantiate() can cause a kernel panic or memory corruption.
- [Low] Invalid Makefile rule referencing a non-existent Kconfig symbol and missing file.
--
commit 55f951da9fbefea49a26410638dbb60af63d2658
Author: Daniel Thompson <[email protected]>
net: stmmac: tc956x: add TC956x/QPS615 support
Toshiba TC956x is an Ethernet AVB/TSN bridge and is essentially a small and highly-specialized SoC. This commit adds a driver for the eMAC/MSIGEN combination found on these devices.
drivers/net/ethernet/stmicro/stmmac/Makefile obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o · line 54
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/Makefile +1
-0@@ -51,4 +51,6 @@ obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o obj-$(CONFIG_DWMAC_INTEL) += dwmac-intel.o obj-$(CONFIG_DWMAC_LOONGSON) += dwmac-loongson.o obj-$(CONFIG_DWMAC_MOTORCOMM) += dwmac-motorcomm.o +obj-$(CONFIG_TC956X_PCI) += tc956x-pci.o
[Severity: Low]
Is this line a leftover from a previous iteration? The correct Kconfig symbol appears to be CONFIG_TOSHIBA_TC956X_PCI, and the source file tc956x_pci.c was placed in drivers/misc/ rather than the stmmac directory.
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +0
-0
[ ... ]
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 222
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +6
-0+/* We have one IRQ chip instance with 25 IRQs in its domain */ +static struct irq_domain * +tc956x_msigen_irq_domain_instantiate (struct tc956x_data *td) +{ +struct irq_domain_chip_generic_info dgc_info; +struct irq_domain_info info;
[Severity: High]
Does this pass uninitialized stack variables to the core IRQ domain subsystem?
These local variables are declared on the stack without zero-initialization. Since only a subset of their fields are populated before passing them to devm_irq_domain_instantiate(), fields like info.fwnode and info.parent could contain arbitrary stack garbage.
If the core IRQ domain subsystem tries to dereference a garbage pointer in info.fwnode, could it lead to memory corruption or a page fault during probe?
Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +3
-0+ + dgc_info.name =devm_kasprintf (td->dev,GFP_KERNEL ,"tc956x-msigen-%d" , + td->auxbus_data->mac_id);
[ ... ]
Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +5
-0+ info.init = tc956x_msigen_irq_domain_init; + info.exit = tc956x_msigen_irq_domain_exit; + +return devm_irq_domain_instantiate (td->dev, &info); +}
[ ... ]
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +4
-0+static int tc956x_stmmac_resources_init (struct tc956x_data *td) +{ +struct irq_domain *irq_domain = td->irq_domain; +struct stmmac_resources *res = &td->res;
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c line 697
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +10
-0+u32 i; + + res->irq =irq_create_mapping (irq_domain,HWIRQ_EVENT ); +if (!res->irq) +return -EINVAL ; + +for (i =0 ; i < td->plat->tx_queues_to_use; i++) { + res->tx_irq[i] =irq_create_mapping (irq_domain,HWIRQ_TX0 + i); +if (!res->tx_irq[i]) +return -EINVAL ;
[Severity: High]
If irq_create_mapping() fails here or in the RX loop below, this returns an error without unwinding previously successful mappings.
When the caller tc956x_dwmac_probe() encounters this error:
tc956x_dwmac_probe() {
...
ret = tc956x_stmmac_resources_init(td);
if (ret) {
ret = dev_err_probe(dev, ret,
"failed to initialize stmmac resources\n");
goto err_put_mdio;
}
...
}It jumps to err_put_mdio, bypassing tc956x_stmmac_resources_exit() entirely.
Since devres will automatically free the irq_domain on probe failure, will the undisposed mappings cause a kernel warning and leave undisposed irq_desc structures pointing to the freed domain, leading to a use-after-free?
Quoted 12 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.c new file +12
-0+ } + +for (i =0 ; i < td->plat->rx_queues_to_use; i++) { + res->rx_irq[i] =irq_create_mapping (irq_domain,HWIRQ_RX0 + i); +if (!res->rx_irq[i]) +return -EINVAL ; + } + + res->addr = td->auxbus_data->emac; + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
PATCH v2 14/14 arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081 phy
In reply to Alex ElderFrom: Daniel Thompson <[email protected]>
The QCS6490 RB3Gen2 includes a Toshiba TC9564 (a.k.a. Qualcomm QPS615). TC9564 is an twin Ethernet-AVB/TSN bridge with an integrated PCIe switch.
Downstream PCIe switch port 3 has an embedded PCIe endpoint, which includes two functions. The GPIO controller embedded within the TC9564 is accessed via memory-mapped I/O through the first PCIe function's BAR4.
Both embedded PCIe functions have an attached Synopsys XGMAC, but not all RB3gen2 builds include PHYs on both ports. All versions include a TC9564 combined with a single QCA8081 attached to eMAC1.
Add properties to the existing PCI nodes to describe how the TC9564 and QCA8081 are connected to each other (and to the host SoC).
---
Checkpatch notes:
- pci1179 is not a recognized vendor ID
- Some lines are longer than recommented
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+)
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +48 -0
@@ -308,6 +308,15 @@ vdd_ntn_1p8: regulator-vdd-ntn-1p8 { regulator-enable-ramp-delay = <10000>; }; + qep_1p8: regulator-qep-1p8 { + compatible = "regulator-fixed"; + regulator-name = "qep_1p8"; + gpio = <&pm7325_gpios 8 GPIO_ACTIVE_HIGH>; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + enable-active-high; + }; + wcn6750-pmu { compatible = "qcom,wcn6750-pmu"; pinctrl-0 = <&bt_en>;
@@ -938,19 +947,51 @@ pcie@3,0 { bus-range = <0x5 0xff>; pci@0,0 { + compatible = "pci1179,0220"; reg = <0x50000 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges; + + tc9564_gpio0: gpio { + gpio-controller; + #gpio-cells = <2>; + }; }; pci@0,1 { + compatible = "pci1179,0220"; reg = <0x50100 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges; + + ethernet { + phy-mode = "sgmii"; + phy-handle = <&tc9564_emac1_phy>; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + tc9564_emac1_phy: ethernet-phy@1c { + compatible = "ethernet-phy-id004d.d101"; + reg = <0x1c>; + snps,reset = <&tc9564_gpio0 1 GPIO_ACTIVE_LOW>; + reset-assert-us = <11000>; + reset-deassert-us = <70000>; + + vdd18-supply = <&qep_1p8>; + + pinctrl-names = "default"; + pinctrl-0 = <&qep_irq_pin>; + interrupts-extended = <&tlmm 101 IRQ_TYPE_LEVEL_LOW>; + }; + }; + }; }; }; };
@@ -1524,6 +1565,13 @@ usb_hub_reset_state: usb-hub-reset-state { drive-strength = <2>; bias-disable; }; + + qep_irq_pin: qep-irq-state { + pins = "gpio101"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; }; &lpass_audiocc {
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH net-next v2 14/14] arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081 phy
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The Ethernet PHY reset GPIO is incorrectly specified as 'snps,reset' within the PHY node, meaning it will never be acquired or toggled.
- [Low] The PCI endpoint nodes (pci@0,0 and pci@0,1) incorrectly include bridge-exclusive properties.
Pre-existing issues:
- [High] The newly added tc9564_gpio0 devicetree node will be rejected by its backing PCI driver due to a typo in the driver codebase. --
commit 68b46926b348f5281d4dc4e8d117989c980cbff5
Author: Daniel Thompson <[email protected]>
arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081 phy
This commit adds device tree properties to support the TC9564 Ethernet bridge and QCA8081 PHY on the QCS6490 RB3Gen2 platform. It describes how the embedded PCIe endpoints, GPIO controller, and Ethernet PHYs are connected.
Quoted 4 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +0
-0
[ ... ]
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@3,0 { · line 955
Quoted 10 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +1
-0@@ -938,19 +947,51 @@ pcie@3,0 { bus-range = <0x5 0xff>; pci@0,0 { + compatible = "pci1179,0220"; reg = <0x50000 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges;
[Severity: Low]
Does this endpoint node incorrectly include bridge-exclusive properties?
Properties like device_type = "pci", ranges, #address-cells, and #size-cells are typically reserved for PCI bridges that enumerate child buses, not for leaf endpoints.
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@3,0 { · line 960
Quoted 5 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +5
-0+ + tc9564_gpio0: gpio { + gpio-controller; + #gpio-cells = <2>; + };
[Severity: High]
This is a pre-existing issue, but the existing PCI MFD driver for this endpoint has a typo that will cause it to reject this node.
Looking at dev_node_child_gpio() in drivers/misc/tc956x_pci.c, the driver explicitly checks for "gpio-controllerX":
if (!of_property_present(np, "gpio-controllerX"))
dev_err(dev, "gpio node contains no gpio-contrller property\n");
Because this patch correctly uses "gpio-controller", will the driver fail to instantiate the controller and prevent the PHY reset line from being driven?
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@3,0 { · line 969
Quoted 9 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +1
-0}; pci@0,1 { + compatible = "pci1179,0220"; reg = <0x50100 0x0 0x0 0x0 0x0>; #address-cells = <3>; #size-cells = <2>; device_type = "pci"; ranges;
[Severity: Low]
Are the bridge-exclusive properties (device_type, ranges, #address-cells) also incorrectly applied to this leaf endpoint node?
Quoted 4 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +4
-0+ + ethernet { + phy-mode = "sgmii"; + phy-handle = <&tc9564_emac1_phy>;
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts pcie@3,0 { · line 983
Quoted 10 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +10
-0+ + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + tc9564_emac1_phy: ethernet-phy@1c { + compatible = "ethernet-phy-id004d.d101"; + reg = <0x1c>; + snps,reset = <&tc9564_gpio0 1 GPIO_ACTIVE_LOW>;
[Severity: High]
Will this reset GPIO ever be acquired or toggled during initialization?
The stmmac_mdio_reset() function looks for the "snps,reset" GPIO on the MAC's device node (ethernet), but it is placed here in the PHY subnode. Meanwhile, the standard mdio_device_register_reset() function looks for "reset-gpios" in the PHY node, not "snps,reset".
Since neither subsystem will find this property, it seems the PHY reset will not be performed. Should this either be renamed to "reset-gpios" or moved to the MAC node?
Quoted 14 lines
arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts +11
-0+ reset-assert-us = <11000>; + reset-deassert-us = <70000>; + + vdd18-supply = <&qep_1p8>; + + pinctrl-names = "default"; + pinctrl-0 = <&qep_irq_pin>; + interrupts-extended = <&tlmm 101 IRQ_TYPE_LEVEL_LOW>; + }; + }; + }; }; }; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
Quoted 4 lines · Alex Elder
(A fairly detailed list of changes since v1 is included below. Because there are so many changes listed, they are not repeated in the individual patches that follow. Note also that this series depends on two prerequisite commits, as explained below.)
We are now ready to send version 3 of this series. It has undergone a complete restructuring, though many detailed bits of code remain the same as before. Because of this we intend to use a new strategy in posting the code for review. I describe that here; if you think there are things we could do differently to improve this process, please say so.
I can provide a longer explanation for how the new model works if that is requested, but here is a summary of the process:
- There will be no "version 3" of the original series.
- Instead, the TC9564 will be treated as an SoC that consists of a set of distinct components (clock, reset, interrupts, GPIO, etc.).
- Support for each of these components will be provided by distinct platform device drivers.
- These platform drivers will be upstreamed independently. I.e., the clock driver will be sent to clock maintainers for review, the reset driver will be sent to reset maintainers, and so on.
- One of these platform drivers will provide support for the XGMAC 10 Gbit Ethernet interface (whose support was the the original, primary goal of this series).
- The anchor driver is a PCI endpoint/function driver, which implements the framework necessary to support the pci-ep-bus that all the other devices use for their MMIO.
We will send the code for all of these parts out for review separately. Upstreaming each can proceed independently, and when all are eventually accepted (including devicetree updates), the originally-desired XGMAC functionality will be supported.
Here is a list of the "components":
- PCI driver (drivers/misc/tc9564-pci.c)
- Clock driver (drivers/clk/clk-tc9564.c)
- Reset driver (drivers/reset/reset-tc9564.c)
- Interrupt controller driver (drivers/irqchip/irq-tc9564-msigen.c)
- Address translation unit driver (drivers/misc/tc9564-translate.c)
- XGMAC driver (drivers/net/ethernet/stmicro/stmmac/dwmac-tc9564.c)
There was previously a GPIO driver included. That has been reimplemented to be accessed via I2C rather than PCIe BARs. The new version will be associated with the PCI pwrctl driver, pci-pwrctrl-tc9563.c, and will be posted for review separately.
-Alex
Quoted 322 lines
This series introduces stmmac driver support for the Toshiba TC9564 (also known as Qualcomm QPS615). This is an Ethernet-AVB/TSN bridge IC that provides a high-speed connection between a host SoC and Ethernet devices on a network. It incorporates a PCIe switch, and implements two 10 Gbps capable Ethernet MACs (along with other IP blocks), and is essentially a small and highly-specialized SoC. The TC9564 is a member of a family of similar chips, and the driver code uses "tc956x" to reflect this.
TC956x chips incorporate a PCIe gen 3 switch, with one upstream and three downstream ports. Its PCIe functionality is already supported upstream, including a power control driver that performs some early configuration of the PCI ports ("
pci-pwrctrl-tc9563.c").One of the PCIe switch's downstream ports has an internal PCIe endpoint, which implements two PCIe functions, each of which has an Ethernet MAC (eMAC) subsystem. The eMAC is composed of a Synopsis Designware XGMAC combined with an XPCS and PMA. Each MAC is capable of operating at 10M/100M/1G/2.5G/5Gps and 10Gps. The initial target platform is the Qualcomm RB3gen2, which supports a 10Gbps Marvell PHY on port A, and a 2.5Gbps Qualcomm PHY on port B. (The Marvell PHY is not populated on all RB3gen2 boards, and only the 2.5 Gbps Qualcomm PHY is supported initially.)
TC956x chips also implement several other blocks of functionality, including a GPIO controller, interrupt controllers (MSIGEN), I2C and SPI, a UART, and an Arm Cortex M3 CPU with 128KB SRAM. The GPIO interface exposes several lines to manage external resets. The interrupt controllers are used internally by the eMAC functions. The UART, SPI, microcontroller, and SRAM are currently unused.
---------------------------------- | Host | ------+...+----------+........+--- |i2c| | PCIe | ----------------+...+----------+........+------ | TC956x |I2C| |upstream| | | ----- --+--------+--- | | ----- ------ ------- | PCIe switch | | | |SPI| |GPIO| |reset| | | | | ----- ------ |clock| | DS3 DS2 DS1 | | | ------- ---++--++--++-- | | ----- ------ downstream// \\ \\ | downstream | |MCU| |SRAM| /==========/ \\ \===== PCIe port 1 | ----- ------ //PCIe port 3 \\ | | || \======= downstream | ----+-----------++-----------+---- | PCIe port 2 | | M | internal PCIe endpoint | M | | | | S |------------------------| S | ------ | | | I | PCIe | | PCIe | I | |UART| | | | G |function 0| |function 1| G | ------ | | | E |----++----| |----++----| E | | | | N | eMAC 0 | | eMAC 1 | N | | --------+.......+------+.....+----------------- |USXGMII| |SGMII| --+.......+-- --+.....+-- | ARQ113C | | QEP8121 | | PHY | | PHY | ------------- -----------The primary objective for this series is to support the Ethernet functionality provided by the TC956x. The code providing this support has been structured into three distinct modules.
- A "chip" driver, associated with the PCIe functions
- A driver for the GPIO controller
- Code enabling the TC956x-specific eMAC/MSIGEN hardwareTo manage the common functionality (including configuring address translation and controlling internal reset and clock signals), a "chip" driver is implemented. The chip driver binds to PCI functions 0 and 1, and creates a shared data structure describing the common chip elements shared by the two driver instances. PCIe function 1 defers probing until after PCIe function 0 has created this shared data structure.
Common/shared functionality is handled by PCIe function 0. This common code uses PCIe function 0's mapped BARs to configure the hardware. If the TC9564 GPIO controller is needed (i.e., defined in a node in devicetree), it is created as an auxiliary device when PCIe function 0 is probed.
Both PCIe function 0 and function 1 implement an Ethernet controller as well, though one or the other might be unused on a given platform. If a PCIe function node defines an ethernet subnode in devicetree, the corresponding eMAC is enabled, and the PCIe function driver will create an auxiliary device to represent it.
The GPIO driver is implemented separately because in some hardware configurations, these GPIO lines are used to manage resets for external Ethernet PHYs. We describe these PHYs via devicetree, where the GPIO-based reset signals are defined using phandles.
The code for eMAC and MSIGEN consists of a new source file that populates hardware-specific details about the two MACs, and integrates with the existing stmmac driver. This also required implementing some enhancements to the core stmmac driver, described further below.
The version of the Synopsys MAC IP is 3.01, which is largely compatible with version 2.20. The core stmmac driver required several changes to enable support for the TC956x.
- A change to dwxgmac2 support changes the interrupt mode whenmulti_msi_enis enabled.
- While most support for version 3.01 simply uses the 2.20 code, an erratum related to the RX ring length is implemented for 3.01 DMA operations.
- Having the PCIe device be separate from an auxiliarly device implementing the eMAC required allowing a distinct DMA device to be maintained for an stmmac interface.In addition:
- A new source file provides memory-mapped access to XPCS using regmap. The alignment of the TC956x MDIO registers aren't suitable for using simple MMIO.
- Two additional XPCS changes are implemented that provides support for the XPCS as implemented in the TC956x.NOTE:
This series is based on net-next/main, but depends on these two commits found in linux-next/master:
68d801eabda52gpio: regmap: Support sparsed fixed direction806e7acf7f331gpio: regmap: Don't set a fixed direction line-Alex (and Daniel)
This series is available here:
https://github.com/riscstar/linux/tree/tc956x/stmmac-v2Changes between version 1 and version 2:
NEW
- Theqca808x.cPHY driver now supports enabling up to four optional regulatorsGENERAL
- The order of patches has been rearranged a bit. One consequence is that theTOSHIBA_TC956X_PCIKconfigsymbol is now defined before it's used.PATCH 00/12
-MAINTAINERSentries have been added for all new filesPATCH 01/12
-devm_xpcs_regmap_register()now ensures thexpcs_destroy()is called when the device is unbound (suggested by Sashiko).PATCH 02/12
- Reworked how the quirky behavior was handled. Now:
- A soft reset is issued inxpcs_pre_config()*before* callingxpcs_switch_interface_mode()callstxgbe_xpcs_switch_mode(). It does this now for an SGMII interface, not just if the need-reset flag is set
-xpcs_switch_interface_mode()callstxgbe_xpcs_switch_mode(), preserving previous behavior
- For other (non-Wangxun) platforms, if the XPCS supports 10Gbase-R,xpcs_switch_interface_mode()programs the interface operating mode to use a reserved value rather than the defaultPATCH 03/12
- This change has been removed; thedefault_an_inbandplatform data flag is set instead (in what was previously patch 10)PATCH 04/12
- Two issues were pointed out by Sashiko, both of which were problems related to DMA handling. They were pre-existing issues, and I plan to send separate patches to address them.
- A mask local variable (to shorten a long line) is no longer created. Checkpatch no longer complains about that line.PATCH 05/12
- The description was clarified a bit in response to a comment from AndrewPATCH 06/12
- No comments received, no changesPATCH 07/12
- Sashiko suggested that exporting some symbols from the stmmac core might not be desirable, and suggested using the standard DMA API to accomplish the same thing. For now we are igoring this suggestion--not finding a way to do what was suggested.PATCH 08/12
- The description has been revised to focus on the hardware and not the "node".
- The ASCII art (copied from below) has been incorporated into the binding
- The file name has been changed to "toshiba,tc9564-dwmac.yaml" and the $id value matches the file name
- Only one example is provided now
- The references and unevaluatedProperties have been moved later in the file
- We no longer reference "pci-bus-common.yaml". We are describing a device, not a bridge.
- Subnodes have been added to represent the GPIO controller (on PCIe function 0) and the Ethernet interfaces (possible on PCIe functions 0 and 1).PATCH 09/12
- The GPIO controller is now implemented using regmap-gpio
- TheKconfigentry for the GPIO driver has been updated to selectGPIO_REGMAP, and to define its default value as "m" unconditionally
- TheKconfigentry is now defined in the memory-mapped GPIO section
- The regmap use has been adjusted so it's clear it is MMIO-based, which normally does not require error checking.
- We no longer calldrv_get_drvdata()PATCH 10/12
- The name of the IRQ domain now includes the MAC ID (0 or 1)
-SP_SEL_SGMII_2500Mis now namedSP_SEL_2500BASEX
- A typo in the commit has been fixed, and the error check after creating the RX IRQ mapping now checks the right pointer for an error
- TheKconfigentry now selectsGENERIC_IRQ_CHIP
- The PHY interface is now taken into account in thefix_max_speedcallback
- We now check the correct pointer for an error when creating the RX IRQ mappings
- We are not implementing a shutdown driver callback
- Xilin has other discussion related to WoL, which we should save and use, but we're not acting on it now.
- In four function, Sashiko noted that a 32-bitdma_addr_tcan't holdTC956X_SLV00_SRC_ADDR, so the type of local variable has been changed to be u64: tc956x_dma_init_rx_chan(), tc956x_dma_init_tx_chan(), tc956x_desc_set_addr(), and tc956x_desc_set_sec_addr().-
tc956x_mac_disable()is now called ifstmmac_dvr_probe()fails; suggested by Sashiko.
- Sashiko noted the MDIO device tree node was being leaked. This has been resolved.
- Sashiko also pointed out that IRQ mappings were not being freed, and this too is fixed.PATCH 11/12
- The reset and clock functions are no longer defined inline
- The REFCLK clock name has been renamed REFCLKO, and a comment has been added to explain it is an (unused) output clock.
- If the PCI device has no DT node it is reported withdev_err().
- <linux/bitfield.h> is now included, to avoid errors in various non-Arm64 builds.
- The devicetree Ethernet node is no longer leaked inadev_device_add()(noticed by Sashiko).
- TheKconfigentry now depends on ARM64 orCOMPILE_TEST
- TheKconfigentry now selects REGMAP andREGMAP_MMIO
- Sashiko reported that the reference count on the PCIe slot for function 0 was being leaked. This has been fixed.
- Sashiko questioned whether the cleanup action to delete
a created device link was associated with the wrong device. It was, and this has been fixed.
- Sashiko also suggested that the allocated PCI IRQ vector was not properly getting removed. It now is.
- Sashiko suggested that function 1 might proceed with probing even though there was still a chance that function 0's probe failed. Theplatform_datapointer that function 1 uses to decide it's OK to probe is now assigned later.PATCH 12/12
- The PHY interrupt is now defined as a level interrupt.
- A typo in the PHY name has been corrected in the patch descriptionHere is the initial version of the series.
https://lore.kernel.org/netdev/[email protected]/Alex Elder (3):
net: stmmac: dma: create a separate dma_device pointer misc: tc956x_pci: add TC956x/QPS615 support gpio: tc956x: add TC956x/QPS615 supportDaniel Thompson (11):
dt-bindings: net: qca,qca808x: Add regulator properties
net: phy: qcom: qca808x: Add regulator management
net: pcs: pcs-xpcs-regmap: support XPCS memory-mapped MDIO bus via
regmap
net: pcs: xpcs: re-orderxpcs_pre_config()to update after the reset
net: pcs: pcs-xpcs: select operating mode for 10G-baseR capable PCS
net: stmmac: dwxgmac2: Add multi MSI interrupt mode
net: stmmac: dwxgmac2: Add XGMAC 3.01a support
net: stmmac: dwxgmac2: export symbols for XGMAC 3.01a DMA
dt-bindings: net: toshiba,tc9654-dwmac: add TC9564 Ethernet bridge
net: stmmac: tc956x: add TC956x/QPS615 support
arm64: dts: qcom: qcs6490-rb3gen2: enable TC9564 with a single QCA8081
phy.../devicetree/bindings/net/qca,qca808x.yaml | 14 + .../bindings/net/toshiba,tc9564-dwmac.yaml | 120 +++ MAINTAINERS | 12 + arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts | 48 + drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-tc956x.c | 130 +++ drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 1 + drivers/misc/tc956x_pci.c | 741 ++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/Kconfig | 14 + drivers/net/ethernet/stmicro/stmmac/Makefile | 2 + .../net/ethernet/stmicro/stmmac/chain_mode.c | 12 +- .../ethernet/stmicro/stmmac/dwmac-tc956x.c | 818 ++++++++++++++++++ .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 12 + .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_descs.c | 1 + .../ethernet/stmicro/stmmac/dwxgmac2_dma.c | 79 +- .../net/ethernet/stmicro/stmmac/ring_mode.c | 12 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 58 +- .../net/ethernet/stmicro/stmmac/stmmac_xdp.c | 2 +- drivers/net/pcs/Makefile | 4 +- drivers/net/pcs/pcs-xpcs-regmap.c | 219 +++++ drivers/net/pcs/pcs-xpcs.c | 93 +- drivers/net/phy/qcom/qca808x.c | 30 + include/linux/pcs/pcs-xpcs-regmap.h | 20 + include/linux/stmmac.h | 1 + include/soc/toshiba/tc956x-dwmac.h | 84 ++ 29 files changed, 2478 insertions(+), 76 deletions(-)create mode 100644
Documentation/devicetree/bindings/net/toshiba,tc9564-dwmac.yamlcreate mode 100644drivers/gpio/gpio-tc956x.c
create mode 100644drivers/misc/tc956x_pci.c
create mode 100644drivers/net/ethernet/stmicro/stmmac/dwmac-tc956x.ccreate mode 100644drivers/net/pcs/pcs-xpcs-regmap.c
create mode 100644include/linux/pcs/pcs-xpcs-regmap.h
create mode 100644include/soc/toshiba/tc956x-dwmac.hbase-commit:
07c4bca9d92e51ab6b46797a86c6ea559812351a