PHY: Prepare Cadence Torrent PHY driver to support multilink configurations
Subsystems (2)
v3 cover PHY: Prepare Cadence Torrent PHY driver to support multilink configurations
Cadence Torrent PHY is a multiprotocol PHY supporting different multilink PHY configurations including DisplayPort, PCIe, USB, SGMII, QSGMII etc. Existing Torrent PHY driver supports only DisplayPort. This patch series prepares Torrent PHY driver so that different multilink configurations can be supported. It also updates DT bindings accordingly. This doesn't affect ABI as Torrent PHY driver has never been functional, and therefore do not exist in any active use case.
Support for different multilink configurations with register sequences for protocols above will be added in a separate patch series.
Version History:
v3:
- Rebased on latest PHY next
- Fixed v2 review comments for DT patch 7/7
v2:
- Rebased on latest PHY next and new PHY attributes patch series [1]
Swapnil Jakhade (7):
phy: cadence-torrent: Use of_device_get_match_data() to get driver
data
phy: cadence-torrent: Use devm_platform_ioremap_resource() to get reg
addresses
phy: cadence-torrent: Enable support for multiple subnodes
phy: cadence-torrent: Add separate regmap functions for torrent and DP
phy: cadence-torrent: Check total lane count for all subnodes is
within limit
dt-bindings: phy: cadence-torrent: Add binding to specify SSC mode
dt-bindings: phy: cadence-torrent: Update Torrent PHY bindings for
generic use
.../bindings/phy/phy-cadence-torrent.yaml | 86 +++++++++-- drivers/phy/cadence/phy-cadence-torrent.c | 146 ++++++++++-------- include/dt-bindings/phy/phy-cadence-torrent.h | 13 ++ 3 files changed, 166 insertions(+), 79 deletions(-) create mode 100644 include/dt-bindings/phy/phy-cadence-torrent.h
Signature · 1 line
2.26.1
PATCH v3 1/7 phy: cadence-torrent: Use of_device_get_match_data() to get driver data
Use of_device_get_match_data() to get driver data instead of boilerplate code.
--- drivers/phy/cadence/phy-cadence-torrent.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +5 -8
@@ -183,8 +183,6 @@ static const struct reg_field phy_pma_pll_raw_ctrl =static const struct reg_field phy_reset_ctrl =REG_FIELD (PHY_RESET ,8 ,8 ); -static const struct of_device_id cdns_torrent_phy_of_match[]; -struct cdns_torrent_inst {struct phy *phy;u32 mlane;
@@ -203,6 +201,7 @@ struct cdns_torrent_phy {unsigned long ref_clk_rate;struct cdns_torrent_inst phys[MAX_NUM_LANES ];int nsubnodes; +const struct cdns_torrent_data *init_data;struct regmap *regmap;struct regmap *regmap_common_cdb;struct regmap *regmap_phy_pcs_common_cdb;
@@ -1710,24 +1709,22 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)struct cdns_torrent_phy *cdns_phy;struct device *dev = &pdev->dev;struct phy_provider *phy_provider; -const struct of_device_id *match; -struct cdns_torrent_data *data; +const struct cdns_torrent_data *data;struct device_node *child;int ret, subnodes, node =0 , i;/* Get init data for this PHY */ - match =of_match_device (cdns_torrent_phy_of_match, dev); -if (!match) + data =of_device_get_match_data (dev); +if (!data)return -EINVAL ; - data = (struct cdns_torrent_data *)match->data; - cdns_phy =devm_kzalloc (dev,sizeof (*cdns_phy),GFP_KERNEL );if (!cdns_phy)return -ENOMEM ;dev_set_drvdata (dev, cdns_phy); cdns_phy->dev = dev; + cdns_phy->init_data = data; cdns_phy->phy_rst =devm_reset_control_get_exclusive_by_index (dev,0 );if (IS_ERR (cdns_phy->phy_rst)) {
Signature · 1 line
2.26.1
PATCH v3 2/7 phy: cadence-torrent: Use devm_platform_ioremap_resource() to get reg addresses
In reply to Swapnil JakhadeUse devm_platform_ioremap_resource() to get register addresses instead of boilerplate code.
--- drivers/phy/cadence/phy-cadence-torrent.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +2 -6
@@ -1705,7 +1705,6 @@ static int cdns_regmap_init_torrent_dp(struct cdns_torrent_phy *cdns_phy,static int cdns_torrent_phy_probe (struct platform_device *pdev) { -struct resource *regs;struct cdns_torrent_phy *cdns_phy;struct device *dev = &pdev->dev;struct phy_provider *phy_provider;
@@ -1739,8 +1738,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)return PTR_ERR (cdns_phy->clk); } - regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - cdns_phy->sd_base =devm_ioremap_resource (&pdev->dev, regs); + cdns_phy->sd_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (cdns_phy->sd_base))return PTR_ERR (cdns_phy->sd_base);
@@ -1830,9 +1828,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) }/* DPTX registers */ - regs =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); - cdns_phy->base =devm_ioremap_resource (&pdev->dev, - regs); + cdns_phy->base =devm_platform_ioremap_resource (pdev,1 );if (IS_ERR (cdns_phy->base)) { ret =PTR_ERR (cdns_phy->base); goto put_child;
Signature · 1 line
2.26.1
PATCH v3 3/7 phy: cadence-torrent: Enable support for multiple subnodes
In reply to Swapnil JakhadeEnable support for multiple subnodes in torrent PHY to include multi-link combinations.
--- drivers/phy/cadence/phy-cadence-torrent.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +0 -15
@@ -1746,9 +1746,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)if (subnodes ==0 ) {dev_err (dev,"No available link subnodes found\n" );return -EINVAL ; - }else if (subnodes !=1 ) { -dev_err (dev,"Driver supports only one link subnode.\n" ); -return -EINVAL ; }for_each_available_child_of_node (dev->of_node, child) {
@@ -1771,14 +1768,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) goto put_child; } -if (cdns_phy->phys[node].mlane !=0 ) { -dev_err (dev, -"%s: Driver supports only lane-0 as master lane.\n" , - child->full_name); - ret = -EINVAL ; - goto put_child; - } -if (of_property_read_u32 (child,"cdns,phy-type" , &cdns_phy->phys[node].phy_type)) { dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n",
@@ -1849,10 +1838,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; gphy->attrs.mode =PHY_MODE_DP ; - }else { -dev_err (dev,"Driver supports only PHY_TYPE_DP\n" ); - ret = -ENOTSUPP ; - goto put_child; } cdns_phy->phys[node].phy = gphy;phy_set_drvdata (gphy, &cdns_phy->phys[node]);
Signature · 1 line
2.26.1
PATCH v3 4/7 phy: cadence-torrent: Add separate regmap functions for torrent and DP
In reply to Swapnil JakhadeAdded separate functions for regmap initialization of torrent PHY generic registers and DP specific registers.
--- drivers/phy/cadence/phy-cadence-torrent.c | 99 +++++++++++++++-------- 1 file changed, 66 insertions(+), 33 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +66 -33
@@ -1584,7 +1584,24 @@ static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,return devm_regmap_init (dev,NULL , ctx, config); } -static int cdns_regfield_init (struct cdns_torrent_phy *cdns_phy) +static int cdns_torrent_dp_regfield_init (struct cdns_torrent_phy *cdns_phy) +{ +struct device *dev = cdns_phy->dev; +struct regmap_field *field; +struct regmap *regmap; + + regmap = cdns_phy->regmap_dptx_phy_reg; + field =devm_regmap_field_alloc (dev, regmap, phy_reset_ctrl); +if (IS_ERR (field)) { +dev_err (dev,"PHY_RESET reg field init failed\n" ); +return PTR_ERR (field); + } + cdns_phy->phy_reset_ctrl = field; + +return 0 ; +} + +static int cdns_torrent_regfield_init (struct cdns_torrent_phy *cdns_phy) {struct device *dev = cdns_phy->dev;struct regmap_field *field;
@@ -1614,28 +1631,44 @@ static int cdns_regfield_init(struct cdns_torrent_phy *cdns_phy) } cdns_phy->phy_pma_pll_raw_ctrl = field; - regmap = cdns_phy->regmap_dptx_phy_reg; - field =devm_regmap_field_alloc (dev, regmap, phy_reset_ctrl); -if (IS_ERR (field)) { -dev_err (dev,"PHY_RESET reg field init failed\n" ); -return PTR_ERR (field); +return 0 ; +} + +static int cdns_torrent_dp_regmap_init (struct cdns_torrent_phy *cdns_phy) +{ +void __iomem *base = cdns_phy->base; +struct device *dev = cdns_phy->dev; +struct regmap *regmap; +u8 reg_offset_shift; +u32 block_offset; + + reg_offset_shift = cdns_phy->init_data->reg_offset_shift; + + block_offset =TORRENT_DPTX_PHY_OFFSET ; + regmap =cdns_regmap_init (dev, base, block_offset, + reg_offset_shift, + &cdns_torrent_dptx_phy_config); +if (IS_ERR (regmap)) { +dev_err (dev,"Failed to init DPTX PHY regmap\n" ); +return PTR_ERR (regmap); } - cdns_phy->phy_reset_ctrl = field; + cdns_phy->regmap_dptx_phy_reg = regmap;return 0 ; } -static int cdns_regmap_init_torrent_dp (struct cdns_torrent_phy *cdns_phy, -void __iomem *sd_base, -void __iomem *base, -u8 block_offset_shift, -u8 reg_offset_shift) +static int cdns_torrent_regmap_init (struct cdns_torrent_phy *cdns_phy) { +void __iomem *sd_base = cdns_phy->sd_base; +u8 block_offset_shift, reg_offset_shift;struct device *dev = cdns_phy->dev;struct regmap *regmap;u32 block_offset;int i; + block_offset_shift = cdns_phy->init_data->block_offset_shift; + reg_offset_shift = cdns_phy->init_data->reg_offset_shift; +for (i =0 ; i <MAX_NUM_LANES ; i++) { block_offset =TORRENT_TX_LANE_CDB_OFFSET (i, block_offset_shift, reg_offset_shift);
@@ -1690,16 +1723,6 @@ static int cdns_regmap_init_torrent_dp(struct cdns_torrent_phy *cdns_phy, } cdns_phy->regmap_phy_pma_common_cdb = regmap; - block_offset =TORRENT_DPTX_PHY_OFFSET ; - regmap =cdns_regmap_init (dev, base, block_offset, - reg_offset_shift, - &cdns_torrent_dptx_phy_config); -if (IS_ERR (regmap)) { -dev_err (dev,"Failed to init DPTX PHY regmap\n" ); -return PTR_ERR (regmap); - } - cdns_phy->regmap_dptx_phy_reg = regmap; -return 0 ; }
@@ -1711,6 +1734,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)const struct cdns_torrent_data *data;struct device_node *child;int ret, subnodes, node =0 , i; +u8 init_dp_regmap =0 ;/* Get init data for this PHY */ data =of_device_get_match_data (dev);
@@ -1748,6 +1772,14 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)return -EINVAL ; } + ret =cdns_torrent_regmap_init (cdns_phy); +if (ret) +return ret; + + ret =cdns_torrent_regfield_init (cdns_phy); +if (ret) +return ret; +for_each_available_child_of_node (dev->of_node, child) {struct phy *gphy;
@@ -1830,6 +1862,18 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) goto put_child; } +if (!init_dp_regmap) { + ret =cdns_torrent_dp_regmap_init (cdns_phy); +if (ret) + goto put_child; + + ret =cdns_torrent_dp_regfield_init (cdns_phy); +if (ret) + goto put_child; + + init_dp_regmap++; + } + dev_info(dev, "%d lanes, max bit rate %d.%03d Gbps\n", cdns_phy->phys[node].num_lanes, cdns_phy->max_bit_rate / 1000,
@@ -1846,17 +1890,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) } cdns_phy->nsubnodes = node; - ret =cdns_regmap_init_torrent_dp (cdns_phy, cdns_phy->sd_base, - cdns_phy->base, - data->block_offset_shift, - data->reg_offset_shift); -if (ret) - goto put_lnk_rst; - - ret =cdns_regfield_init (cdns_phy); -if (ret) - goto put_lnk_rst; - phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate);if (IS_ERR (phy_provider)) { ret =PTR_ERR (phy_provider);
Signature · 1 line
2.26.1
PATCH v3 5/7 phy: cadence-torrent: Check total lane count for all subnodes is within limit
In reply to Swapnil JakhadeAdd checking if total number of lanes for all subnodes is not greater than number of lanes supported by PHY.
--- drivers/phy/cadence/phy-cadence-torrent.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/phy/cadence/phy-cadence-torrent.c +15 -4
@@ -25,7 +25,6 @@#define REF_CLK_19_2MHz 19200000#define REF_CLK_25MHz 25000000 -#define DEFAULT_NUM_LANES 4#define MAX_NUM_LANES 4#define DEFAULT_MAX_BIT_RATE 8100/* in Mbps */
@@ -1734,6 +1733,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev)const struct cdns_torrent_data *data;struct device_node *child;int ret, subnodes, node =0 , i; +u32 total_num_lanes =0 ;u8 init_dp_regmap =0 ;/* Get init data for this PHY */
@@ -1808,9 +1808,15 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) goto put_child; } - cdns_phy->phys[node].num_lanes =DEFAULT_NUM_LANES ; -of_property_read_u32 (child,"cdns,num-lanes" , - &cdns_phy->phys[node].num_lanes); +if (of_property_read_u32 (child,"cdns,num-lanes" , + &cdns_phy->phys[node].num_lanes)) { +dev_err (dev,"%s: No \"cdns,num-lanes\"-property.\n" , + child->full_name); + ret = -EINVAL ; + goto put_child; + } + + total_num_lanes += cdns_phy->phys[node].num_lanes;if (cdns_phy->phys[node].phy_type ==PHY_TYPE_DP ) {switch (cdns_phy->phys[node].num_lanes) {
@@ -1890,6 +1896,11 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) } cdns_phy->nsubnodes = node; +if (total_num_lanes >MAX_NUM_LANES ) { +dev_err (dev,"Invalid lane configuration\n" ); + goto put_lnk_rst; + } + phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate);if (IS_ERR (phy_provider)) { ret =PTR_ERR (phy_provider);
Signature · 1 line
2.26.1
PATCH v3 6/7 dt-bindings: phy: cadence-torrent: Add binding to specify SSC mode
In reply to Swapnil JakhadeAdd binding to specify Spread Spectrum Clocking mode used.
--- .../bindings/phy/phy-cadence-torrent.yaml | 9 +++++++++ include/dt-bindings/phy/phy-cadence-torrent.h | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 include/dt-bindings/phy/phy-cadence-torrent.h
Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml +9 -0
@@ -87,6 +87,15 @@ patternProperties: enum: [1, 2, 4] default: 4 + cdns,ssc-mode: + description: + Specifies the Spread Spectrum Clocking mode used. It can be NO_SSC, + EXTERNAL_SSC or INTERNAL_SSC. + Refer include/dt-bindings/phy/phy-cadence-torrent.h for the constants to be used. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2] + default: 0 + cdns,max-bit-rate: description: Maximum DisplayPort link bit rate to use, in Mbps
include/dt-bindings/phy/phy-cadence-torrent.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* This header provides constants for Cadence Torrent SERDES. +*/ + +#ifndef _DT_BINDINGS_TORRENT_SERDES_H +#define _DT_BINDINGS_TORRENT_SERDES_H + +#define TORRENT_SERDES_NO_SSC 0 +#define TORRENT_SERDES_EXTERNAL_SSC 1 +#define TORRENT_SERDES_INTERNAL_SSC 2 + +#endif /* _DT_BINDINGS_TORRENT_SERDES_H */
Signature · 1 line
2.26.1
PATCH v3 7/7 dt-bindings: phy: cadence-torrent: Update Torrent PHY bindings for generic use
In reply to Swapnil JakhadeTorrent PHY can be used in different multi-link multi-protocol configurations including protocols other than DisplayPort also, such as PCIe, USB, SGMII, QSGMII etc. Update the bindings to have support for these configurations.
--- .../bindings/phy/phy-cadence-torrent.yaml | 77 +++++++++++++++---- 1 file changed, 60 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/phy/phy-cadence-torrent.yaml +60 -17
@@ -4,11 +4,13 @@ $id: "http://devicetree.org/schemas/phy/phy-cadence-torrent.yaml#" $schema: "http://devicetree.org/meta-schemas/core.yaml#" -title: Cadence Torrent SD0801 PHY binding for DisplayPort +title: Cadence Torrent SD0801 PHY binding description: This binding describes the Cadence SD0801 PHY (also known as Torrent PHY) - hardware included with the Cadence MHDP DisplayPort controller. + hardware included with the Cadence MHDP DisplayPort controller. Torrent + PHY also supports multilink multiprotocol combinations including protocols + such as PCIe, USB, SGMII, QSGMII etc. maintainers: - Swapnil Jakhade <[email protected]>
@@ -49,13 +51,14 @@ properties: - const: dptx_phy resets: - maxItems: 1 - description: - Torrent PHY reset. - See Documentation/devicetree/bindings/reset/reset.txt + minItems: 1 + maxItems: 2 + items: + - description: Torrent PHY reset. + - description: Torrent APB reset. This is optional. patternProperties: - '^phy@[0-7]+$': + '^phy@[0-3]$': type: object description: Each group of PHY lanes with a single master lane should be represented as a sub-node.
@@ -63,6 +66,8 @@ patternProperties: reg: description: The master lane number. This is the lowest numbered lane in the lane group. + minimum: 0 + maximum: 3 resets: minItems: 1
@@ -78,13 +83,14 @@ patternProperties: Specifies the type of PHY for which the group of PHY lanes is used. Refer include/dt-bindings/phy/phy.h. Constants from the header should be used. $ref: /schemas/types.yaml#/definitions/uint32 - enum: [1, 2, 3, 4, 5, 6] + minimum: 1 + maximum: 9 cdns,num-lanes: description: - Number of DisplayPort lanes. + Number of lanes. $ref: /schemas/types.yaml#/definitions/uint32 - enum: [1, 2, 4] + enum: [1, 2, 3, 4] default: 4 cdns,ssc-mode:
@@ -108,6 +114,7 @@ patternProperties: - resets - "#phy-cells" - cdns,phy-type + - cdns,num-lanes additionalProperties: false
@@ -142,13 +149,49 @@ examples: #address-cells = <1>; #size-cells = <0>; phy@0 { - reg = <0>; - resets = <&phyrst 1>, <&phyrst 2>, - <&phyrst 3>, <&phyrst 4>; - #phy-cells = <0>; - cdns,phy-type = <PHY_TYPE_DP>; - cdns,num-lanes = <4>; - cdns,max-bit-rate = <8100>; + reg = <0>; + resets = <&phyrst 1>, <&phyrst 2>, + <&phyrst 3>, <&phyrst 4>; + #phy-cells = <0>; + cdns,phy-type = <PHY_TYPE_DP>; + cdns,num-lanes = <4>; + cdns,max-bit-rate = <8100>; + }; + }; + }; + - | + #include <dt-bindings/phy/phy.h> + #include <dt-bindings/phy/phy-cadence-torrent.h> + + bus { + #address-cells = <2>; + #size-cells = <2>; + + torrent-phy@f0fb500000 { + compatible = "cdns,torrent-phy"; + reg = <0xf0 0xfb500000 0x0 0x00100000>; + reg-names = "torrent_phy"; + resets = <&phyrst 0>, <&phyrst 1>; + clocks = <&ref_clk>; + clock-names = "refclk"; + #address-cells = <1>; + #size-cells = <0>; + phy@0 { + reg = <0>; + resets = <&phyrst 2>, <&phyrst 3>; + #phy-cells = <0>; + cdns,phy-type = <PHY_TYPE_PCIE>; + cdns,num-lanes = <2>; + cdns,ssc-mode = <TORRENT_SERDES_NO_SSC>; + }; + + phy@2 { + reg = <2>; + resets = <&phyrst 4>; + #phy-cells = <0>; + cdns,phy-type = <PHY_TYPE_SGMII>; + cdns,num-lanes = <1>; + cdns,ssc-mode = <TORRENT_SERDES_NO_SSC>; }; }; };
Signature · 1 line
2.26.1
Quoted 10 lines · Swapnil Jakhade
Cadence Torrent PHY is a multiprotocol PHY supporting different multilink PHY configurations including DisplayPort, PCIe, USB, SGMII, QSGMII etc. Existing Torrent PHY driver supports only DisplayPort. This patch series prepares Torrent PHY driver so that different multilink configurations can be supported. It also updates DT bindings accordingly. This doesn't affect ABI as Torrent PHY driver has never been functional, and therefore do not exist in any active use case.
Support for different multilink configurations with register sequences for protocols above will be added in a separate patch series.
Applied, thanks
Signature · 1 line
~Vinod