Skip to contentSkip to conversation

net: mdio-ipq4019: Add mdio reset function

PATCH In review Luo Jie 4 participants 14 messages Jul 29, 2021 – Aug 4, 2021

Subsystems (5)
lore
Share & tools
lore

Luo Jie

author
#0 lore raw

PATCH 1/3 net: mdio-ipq4019: Add mdio reset function

Support PHY reset function and MDIO clock frequency configuration.

---
 drivers/net/mdio/Kconfig        |  1 +
 drivers/net/mdio/mdio-ipq4019.c | 71 +++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
drivers/net/mdio/Kconfig +1 -0
index 99a6c13a11af..06a605ffb950 100644
@@ -169,6 +169,7 @@ config MDIO_OCTEON
 config MDIO_IPQ4019
 	tristate "Qualcomm IPQ4019 MDIO interface support"
 	depends on HAS_IOMEM && OF_MDIO
+	depends on GPIOLIB && COMMON_CLK && RESET_CONTROLLER
 	help
 	  This driver supports the MDIO interface found in Qualcomm
 	  IPQ40xx series Soc-s.
drivers/net/mdio/mdio-ipq4019.c +71 -0

109 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#1 lore raw

PATCH 2/3 net: mdio-ipq4019: rename mdio_ipq4019 to mdio_ipq

mdio_ipq driver supports more SOCs such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 drivers/net/mdio/Kconfig                      |  6 +-
 drivers/net/mdio/Makefile                     |  2 +-
 .../net/mdio/{mdio-ipq4019.c => mdio-ipq.c}   | 66 +++++++++----------
 3 files changed, 37 insertions(+), 37 deletions(-)
 rename drivers/net/mdio/{mdio-ipq4019.c => mdio-ipq.c} (81%)
drivers/net/mdio/Kconfig +3 -3
index 06a605ffb950..133c3d9cb083 100644
@@ -166,13 +166,13 @@ config MDIO_OCTEON
 	  buses. It is required by the Octeon and ThunderX ethernet device
 	  drivers on some systems.
 
-config MDIO_IPQ4019
-	tristate "Qualcomm IPQ4019 MDIO interface support"
+config MDIO_IPQ
+	tristate "Qualcomm IPQ MDIO interface support"
 	depends on HAS_IOMEM && OF_MDIO
 	depends on GPIOLIB && COMMON_CLK && RESET_CONTROLLER
 	help
 	  This driver supports the MDIO interface found in Qualcomm
-	  IPQ40xx series Soc-s.
+	  IPQ40xx, IPQ60XX, IPQ807X and IPQ50XX series Soc-s.
 
 config MDIO_IPQ8064
 	tristate "Qualcomm IPQ8064 MDIO interface support"
drivers/net/mdio/Makefile +1 -1
index 15f8dc4042ce..df7afc8462de 100644
@@ -13,7 +13,7 @@ obj-$(CONFIG_MDIO_CAVIUM)		+= mdio-cavium.o
 obj-$(CONFIG_MDIO_GPIO)			+= mdio-gpio.o
 obj-$(CONFIG_MDIO_HISI_FEMAC)		+= mdio-hisi-femac.o
 obj-$(CONFIG_MDIO_I2C)			+= mdio-i2c.o
-obj-$(CONFIG_MDIO_IPQ4019)		+= mdio-ipq4019.o
+obj-$(CONFIG_MDIO_IPQ)			+= mdio-ipq.o
 obj-$(CONFIG_MDIO_IPQ8064)		+= mdio-ipq8064.o
 obj-$(CONFIG_MDIO_MOXART)		+= mdio-moxart.o
 obj-$(CONFIG_MDIO_MSCC_MIIM)		+= mdio-mscc-miim.o
drivers/net/mdio/mdio-ipq.c renamed from drivers/net/mdio/mdio-ipq4019.c +33 -33

168 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#2 lore raw

Re: [PATCH 2/3] net: mdio-ipq4019: rename mdio_ipq4019 to mdio_ipq

Quoted 10 lines · Luo Jie

mdio_ipq driver supports more SOCs such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 drivers/net/mdio/Kconfig                      |  6 +-
 drivers/net/mdio/Makefile                     |  2 +-
 .../net/mdio/{mdio-ipq4019.c => mdio-ipq.c}   | 66 +++++++++----------
 3 files changed, 37 insertions(+), 37 deletions(-)
 rename drivers/net/mdio/{mdio-ipq4019.c => mdio-ipq.c} (81%)

Hi Luo

We don't rename files unless there is a very good reason. It makes back porting of fixes harder in stable. There are plenty of examples of files with device specific names, but supporting a broad range of devices. Take for example lm75, at24.

drivers/net/mdio/Kconfig config MDIO_OCTEON · line 175

Quoted 10 lines
drivers/net/mdio/Kconfig +3 -3
-config MDIO_IPQ4019
-	tristate "Qualcomm IPQ4019 MDIO interface support"
+config MDIO_IPQ
+	tristate "Qualcomm IPQ MDIO interface support"
 	depends on HAS_IOMEM && OF_MDIO
 	depends on GPIOLIB && COMMON_CLK && RESET_CONTROLLER
 	help
 	  This driver supports the MDIO interface found in Qualcomm
-	  IPQ40xx series Soc-s.
+	  IPQ40xx, IPQ60XX, IPQ807X and IPQ50XX series Soc-s.

Please leave the MDIO_IPQ4019 unchanged, so we don't break backwards compatibility, but the changes to the text are O.K.

drivers/net/mdio/mdio-ipq.c line 35

Quoted 8 lines
drivers/net/mdio/mdio-ipq.c renamed from drivers/net/mdio/mdio-ipq4019.c +2 -2
@@ -31,38 +31,38 @@
 /* 0 = Clause 22, 1 = Clause 45 */
 #define MDIO_MODE_C45				BIT(8)
 
-#define IPQ4019_MDIO_TIMEOUT	10000
-#define IPQ4019_MDIO_SLEEP		10
+#define IPQ_MDIO_TIMEOUT	10000
+#define IPQ_MDIO_SLEEP		10

This sort of mass rename will also make back porting fixes harder. Please don't do it.

drivers/net/mdio/mdio-ipq.c static int ipq4019_mdio_remove(struct platform_device *pdev) · line 290

Quoted 6 lines
drivers/net/mdio/mdio-ipq.c renamed from drivers/net/mdio/mdio-ipq4019.c +2 -1
-static const struct of_device_id ipq4019_mdio_dt_ids[] = {
+static const struct of_device_id ipq_mdio_dt_ids[] = {
 	{ .compatible = "qcom,ipq4019-mdio" },
+	{ .compatible = "qcom,ipq-mdio" },
 	{ }
 };

Such a generic name is not a good idea. It appears this driver is not compatible with the IPQ8064? It is O.K. to add more specific compatibles. So you could add

qcom,ipq40xx, qcom,ipq60xx, qcom,ipq807x and qcom,ipq50xx.

But really, there is no need. Take for example snps,dwmac-mdio, which is used in all sorts of devices.

Andrew

#3 lore raw

Re: [PATCH 2/3] net: mdio-ipq4019: rename mdio_ipq4019 to mdio_ipq

Quoted 75 lines · Andrew Lunn
Quoted 11 lines · Luo Jie

mdio_ipq driver supports more SOCs such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 drivers/net/mdio/Kconfig                      |  6 +-
 drivers/net/mdio/Makefile                     |  2 +-
 .../net/mdio/{mdio-ipq4019.c => mdio-ipq.c}   | 66 
+++++++++----------
 3 files changed, 37 insertions(+), 37 deletions(-)
 rename drivers/net/mdio/{mdio-ipq4019.c => mdio-ipq.c} (81%)

Hi Luo

We don't rename files unless there is a very good reason. It makes back porting of fixes harder in stable. There are plenty of examples of files with device specific names, but supporting a broad range of devices. Take for example lm75, at24.

Hi Andrew
Thanks for the comments, will update the patch set to keep the name unchanged.

drivers/net/mdio/Kconfig config MDIO_OCTEON · line 175

Quoted 10 lines
drivers/net/mdio/Kconfig +3 -3
-config MDIO_IPQ4019
-	tristate "Qualcomm IPQ4019 MDIO interface support"
+config MDIO_IPQ
+	tristate "Qualcomm IPQ MDIO interface support"
 	depends on HAS_IOMEM && OF_MDIO
 	depends on GPIOLIB && COMMON_CLK && RESET_CONTROLLER
 	help
 	  This driver supports the MDIO interface found in Qualcomm
-	  IPQ40xx series Soc-s.
+	  IPQ40xx, IPQ60XX, IPQ807X and IPQ50XX series Soc-s.

Please leave the MDIO_IPQ4019 unchanged, so we don't break backwards compatibility, but the changes to the text are O.K.

will correct it in the next patch set.

drivers/net/mdio/mdio-ipq.c line 35

Quoted 8 lines
drivers/net/mdio/mdio-ipq.c renamed from drivers/net/mdio/mdio-ipq4019.c +2 -2
@@ -31,38 +31,38 @@
 /* 0 = Clause 22, 1 = Clause 45 */
 #define MDIO_MODE_C45				BIT(8)
 
-#define IPQ4019_MDIO_TIMEOUT	10000
-#define IPQ4019_MDIO_SLEEP		10
+#define IPQ_MDIO_TIMEOUT	10000
+#define IPQ_MDIO_SLEEP		10

This sort of mass rename will also make back porting fixes harder. Please don't do it.

will keep it unchanged in the next patch set.

drivers/net/mdio/mdio-ipq.c static int ipq4019_mdio_remove(struct platform_device *pdev) · line 290

Quoted 6 lines
drivers/net/mdio/mdio-ipq.c renamed from drivers/net/mdio/mdio-ipq4019.c +2 -1
-static const struct of_device_id ipq4019_mdio_dt_ids[] = {
+static const struct of_device_id ipq_mdio_dt_ids[] = {
 	{ .compatible = "qcom,ipq4019-mdio" },
+	{ .compatible = "qcom,ipq-mdio" },
 	{ }
 };

Such a generic name is not a good idea. It appears this driver is not compatible with the IPQ8064? It is O.K. to add more specific compatibles. So you could add

qcom,ipq40xx, qcom,ipq60xx, qcom,ipq807x and qcom,ipq50xx.

But really, there is no need. Take for example snps,dwmac-mdio, which is used in all sorts of devices.

Andrew

Hi Andrew, yes, this driver is not compatible with IPQ8064, but it is compatible with the new chipset such as ipq807x, ipq60xx and ipq50xx, will take your suggestion in the next patch set, thanks for the comments.

author
#4 lore raw

PATCH 3/3 dt-bindings: net: rename Qualcomm IPQ MDIO bindings

In reply to Luo Jie

rename ipq4019-mdio.yaml to ipq-mdio.yaml for supporting more ipq boards such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 ...m,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} | 32 ++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
 rename Documentation/devicetree/bindings/net/{qcom,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} (58%)
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +28 -4
similarity index 58%
rename from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
rename to Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml
index 0c973310ada0..5bdeb461523b 100644
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/net/qcom,ipq4019-mdio.yaml#
+$id: http://devicetree.org/schemas/net/qcom,ipq-mdio.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Qualcomm IPQ40xx MDIO Controller Device Tree Bindings
+title: Qualcomm IPQ MDIO Controller Device Tree Bindings
 
 maintainers:
   - Robert Marko <[email protected]>
@@ -14,7 +14,9 @@ allOf:
 
 properties:
   compatible:
-    const: qcom,ipq4019-mdio
+    oneOf:
+      - const: qcom,ipq4019-mdio
+      - const: qcom,ipq-mdio
 
   "#address-cells":
     const: 1
@@ -23,7 +25,29 @@ properties:
     const: 0
 
   reg:
-    maxItems: 1
+    maxItems: 2
+
+  clocks:
+    items:
+      - description: MDIO clock
+
+  clock-names:
+    items:
+      - const: gcc_mdio_ahb_clk
+
+  resets:
+    items:
+      - description: MDIO reset & GEPHY hardware reset
+
+  reset-names:
+    items:
+      - const: gephy_mdc_rst
+
+  phy-reset-gpios:
+    maxItems: 3
+    description:
+      The phandle and specifier for the GPIO that controls the RESET
+      lines of PHY devices on that MDIO bus.
 
 required:
   - compatible
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#5 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

Quoted 18 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +13 -1
@@ -23,7 +25,29 @@ properties:
     const: 0
 
   reg:
-    maxItems: 1
+    maxItems: 2
+
+  clocks:
+    items:
+      - description: MDIO clock
+
+  clock-names:
+    items:
+      - const: gcc_mdio_ahb_clk
+
+  resets:
+    items:
+      - description: MDIO reset & GEPHY hardware reset

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 50

Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +10 -0
+
+  reset-names:
+    items:
+      - const: gephy_mdc_rst
+
+  phy-reset-gpios:
+    maxItems: 3
+    description:
+      The phandle and specifier for the GPIO that controls the RESET
+      lines of PHY devices on that MDIO bus.

This is clearly not a rename. It is great you are adding missing properties, but please do it as a separate patch.

Andrew

#6 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

Quoted 35 lines · Andrew Lunn
Quoted 18 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +13 -1
@@ -23,7 +25,29 @@ properties:
     const: 0
 
   reg:
-    maxItems: 1
+    maxItems: 2
+
+  clocks:
+    items:
+      - description: MDIO clock
+
+  clock-names:
+    items:
+      - const: gcc_mdio_ahb_clk
+
+  resets:
+    items:
+      - description: MDIO reset & GEPHY hardware reset

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 50

Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +10 -0
+
+  reset-names:
+    items:
+      - const: gephy_mdc_rst
+
+  phy-reset-gpios:
+    maxItems: 3
+    description:
+      The phandle and specifier for the GPIO that controls the RESET
+      lines of PHY devices on that MDIO bus.

This is clearly not a rename. It is great you are adding missing properties, but please do it as a separate patch.

Andrew

Hi Andrew, thanks for the comments, will separate it out in the next patch set.

maintainer
#7 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

In reply to Luo Jie
Quoted 9 lines · Luo Jie

rename ipq4019-mdio.yaml to ipq-mdio.yaml for supporting more ipq boards such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 ...m,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} | 32 ++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
 rename Documentation/devicetree/bindings/net/{qcom,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} (58%)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq-mdio.example.dt.yaml: mdio@90000: reg: [[589824, 100]] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml
\ndoc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1511253

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

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.

#8 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

In reply to Luo Jie
Quoted 31 lines · Luo Jie

rename ipq4019-mdio.yaml to ipq-mdio.yaml for supporting more ipq boards such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 ...m,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} | 32 ++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
 rename Documentation/devicetree/bindings/net/{qcom,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} (58%)
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +2 -2
similarity index 58%
rename from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
rename to Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml
index 0c973310ada0..5bdeb461523b 100644
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/net/qcom,ipq4019-mdio.yaml#
+$id: http://devicetree.org/schemas/net/qcom,ipq-mdio.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Qualcomm IPQ40xx MDIO Controller Device Tree Bindings
+title: Qualcomm IPQ MDIO Controller Device Tree Bindings
 
 maintainers:
   - Robert Marko <[email protected]>

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml allOf: · line 19

Quoted 7 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +3 -1
@@ -14,7 +14,9 @@ allOf:
 
 properties:
   compatible:
-    const: qcom,ipq4019-mdio
+    oneOf:
+      - const: qcom,ipq4019-mdio
+      - const: qcom,ipq-mdio

This is more than the commit log suggests. A generic compatible by itself is not sufficient. If other chips have the same block, just use 'qcom,ipq4019-mdio'. They should also have a compatible for the new SoC in case it's not 'the same'.

Also, use 'enum' rather than oneOf plus const.

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 28

Quoted 9 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +1 -1
   "#address-cells":
     const: 1
@@ -23,7 +25,29 @@ properties:
     const: 0
 
   reg:
-    maxItems: 1
+    maxItems: 2

This breaks compatibility because now 1 entry is not valid.

Quoted 6 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +6 -0
+
+  clocks:
+    items:
+      - description: MDIO clock
+
+  clock-names:

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 44

Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +10 -0
+    items:
+      - const: gcc_mdio_ahb_clk
+
+  resets:
+    items:
+      - description: MDIO reset & GEPHY hardware reset
+
+  reset-names:
+    items:
+      - const: gephy_mdc_rst

These all now apply to 'qcom,ipq4019-mdio'. The h/w had no clocks or resets and now does?

You don't need *-names when there is only 1.

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 50

Quoted 5 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +5 -0
+  phy-reset-gpios:
+    maxItems: 3
+    description:
+      The phandle and specifier for the GPIO that controls the RESET
+      lines of PHY devices on that MDIO bus.

This belongs in the phy node since the reset is connected to the phy.

Quoted 7 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +0 -1
 required:
   - compatible
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

#9 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

Quoted 115 lines · Rob Herring
Quoted 33 lines · Luo Jie

rename ipq4019-mdio.yaml to ipq-mdio.yaml for supporting more ipq boards such as ipq40xx, ipq807x, ipq60xx and ipq50xx.

---
 ...m,ipq4019-mdio.yaml => qcom,ipq-mdio.yaml} | 32 
++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
 rename Documentation/devicetree/bindings/net/{qcom,ipq4019-mdio.yaml 

=> qcom,ipq-mdio.yaml} (58%)

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +2 -2
similarity index 58%
rename from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
rename to Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml
index 0c973310ada0..5bdeb461523b 100644
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
 %YAML 1.2
 ---
-$id: http://devicetree.org/schemas/net/qcom,ipq4019-mdio.yaml#
+$id: http://devicetree.org/schemas/net/qcom,ipq-mdio.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Qualcomm IPQ40xx MDIO Controller Device Tree Bindings
+title: Qualcomm IPQ MDIO Controller Device Tree Bindings
 
 maintainers:
   - Robert Marko <[email protected]>

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml allOf: · line 19

Quoted 7 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +3 -1
@@ -14,7 +14,9 @@ allOf:
 
 properties:
   compatible:
-    const: qcom,ipq4019-mdio
+    oneOf:
+      - const: qcom,ipq4019-mdio
+      - const: qcom,ipq-mdio

This is more than the commit log suggests. A generic compatible by itself is not sufficient. If other chips have the same block, just use 'qcom,ipq4019-mdio'. They should also have a compatible for the new SoC in case it's not 'the same'.

Also, use 'enum' rather than oneOf plus const.

Hi Rob
Thanks for the comments, will keep the compatible "qcom,ipq4019-mdio" unchanged, and add the new compatible name by using 'enum' in the next patch set. the commit log will be updated in the next patch set.

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 28

Quoted 9 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +1 -1
   "#address-cells":
     const: 1
@@ -23,7 +25,29 @@ properties:
     const: 0
 
   reg:
-    maxItems: 1
+    maxItems: 2

This breaks compatibility because now 1 entry is not valid.

will update it by using "minItems: 1, maxItems: 2" in the next patch set.

Quoted 6 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +6 -0
+
+  clocks:
+    items:
+      - description: MDIO clock
+
+  clock-names:

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 44

Quoted 10 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +10 -0
+    items:
+      - const: gcc_mdio_ahb_clk
+
+  resets:
+    items:
+      - description: MDIO reset & GEPHY hardware reset
+
+  reset-names:
+    items:
+      - const: gephy_mdc_rst

These all now apply to 'qcom,ipq4019-mdio'. The h/w had no clocks or resets and now does?

You don't need *-names when there is only 1.

Hi Rob
thanks for the comment, clocks is for configuring the source clock of MDIO bus, which is apply to ipq4019 and the new chip set such as ipq807x, ipq50xx and ipq60xx, which is not configured because of uboot configuring it, kernel should not depends on the configuration of uboot, so i add it.
will remove the *-name in the next patch set.

Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml properties: · line 50

Quoted 5 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +5 -0
+  phy-reset-gpios:
+    maxItems: 3
+    description:
+      The phandle and specifier for the GPIO that controls the RESET
+      lines of PHY devices on that MDIO bus.

This belongs in the phy node since the reset is connected to the phy.

since the phylib code can't satisfy resetting PHY in IPQ chipset, phylib resets phy by configuring GPIO output value to 1, then to 0. however the PHY reset in IPQ chipset need to configuring GPIO output value to 0, then to 1 for the PHY reset, so i put the phy-reset-gpios here.

Quoted 7 lines
Documentation/devicetree/bindings/net/qcom,ipq-mdio.yaml renamed from Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +0 -1
 required:
   - compatible
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

maintainer
#10 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

Quoted 6 lines
Quoted 6 lines

since the phylib code can't satisfy resetting PHY in IPQ chipset, phylib resets phy by
configuring GPIO output value to 1, then to 0. however the PHY reset in IPQ chipset need
to configuring GPIO output value to 0, then to 1 for the PHY reset, so i put the phy-reset-gpios here.

Look at the active low DT property of a GPIO.

Andrew

author
#11 lore raw

Re: [PATCH 3/3] dt-bindings: net: rename Qualcomm IPQ MDIO bindings

Quoted 11 lines · Andrew Lunn
Quoted 6 lines
Quoted 6 lines

since the phylib code can't satisfy resetting PHY in IPQ chipset, phylib resets phy by
configuring GPIO output value to 1, then to 0. however the PHY reset in IPQ chipset need
to configuring GPIO output value to 0, then to 1 for the PHY reset, so i put the phy-reset-gpios here.

Look at the active low DT property of a GPIO.

Andrew

thanks Andrew, will update it in the next patch set.

maintainer
#12 lore raw
In reply to Luo Jie

Hi Luo

For a patchset, netdev wants to see a patch 0/X which describes the big picture. What is the patchset as a whole doing.

Quoted 13 lines
drivers/net/mdio/mdio-ipq4019.c +13 -0
+static int ipq_mdio_reset(struct mii_bus *bus)
+{
+	struct ipq4019_mdio_data *priv = bus->priv;
+	struct device *dev = bus->parent;
+	struct gpio_desc *reset_gpio;
+	u32 val;
+	int i, ret;
+
+	/* To indicate CMN_PLL that ethernet_ldo has been ready if needed */
+	if (!IS_ERR(priv->eth_ldo_rdy)) {
+		val = readl(priv->eth_ldo_rdy);
+		val |= BIT(0);
+		writel(val, priv->eth_ldo_rdy);

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum, · line 207

Quoted 10 lines
drivers/net/mdio/mdio-ipq4019.c +10 -0
+		fsleep(QCA_PHY_SET_DELAY_US);
+	}
+
+	/* Reset GEPHY if need */
+	if (!IS_ERR(priv->reset_ctrl)) {
+		reset_control_assert(priv->reset_ctrl);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		reset_control_deassert(priv->reset_ctrl);
+		fsleep(QCA_PHY_SET_DELAY_US);
+	}

What exactly is being reset here? Which is GEPHY?

The MDIO bus master driver should not be touching any Ethernet PHYs. All it provides is a bus, nothing more.

Quoted 14 lines
drivers/net/mdio/mdio-ipq4019.c +13 -0
+
+	/* Configure MDIO clock frequency */
+	if (!IS_ERR(priv->mdio_clk)) {
+		ret = clk_set_rate(priv->mdio_clk, QCA_MDIO_CLK_RATE);
+		if (ret)
+			return ret;
+
+		ret = clk_prepare_enable(priv->mdio_clk);
+		if (ret)
+			return ret;
+	}
 
+
+	/* Reset PHYs by gpio pins */

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum,

Quoted 10 lines
drivers/net/mdio/mdio-ipq4019.c +10 -0
+	for (i = 0; i < gpiod_count(dev, "phy-reset"); i++) {
+		reset_gpio = gpiod_get_index_optional(dev, "phy-reset", i, GPIOD_OUT_HIGH);
+		if (IS_ERR(reset_gpio))
+			continue;
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		gpiod_set_value_cansleep(reset_gpio, 1);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		gpiod_put(reset_gpio);
+	}

No, there is common code in phylib to do that.

Quoted 14 lines

static int ipq4019_mdio_probe(struct platform_device *pdev) {

drivers/net/mdio/mdio-ipq4019.c +2 -0
 	struct ipq4019_mdio_data *priv;
 	struct mii_bus *bus;
+	struct resource *res;
 	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -182,14 +244,23 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	priv = bus->priv;
+	priv->eth_ldo_rdy = IOMEM_ERR_PTR(-EINVAL);
 

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_probe(struct platform_device *pdev) · line 258

Quoted 10 lines
drivers/net/mdio/mdio-ipq4019.c +6 -0
 	priv->membase = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->membase))
 		return PTR_ERR(priv->membase);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res)
+		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
+
+	priv->reset_ctrl = devm_reset_control_get_exclusive(&pdev->dev, "gephy_mdc_rst");
+	priv->mdio_clk = devm_clk_get(&pdev->dev, "gcc_mdio_ahb_clk");

You probably want to use devm_clk_get_optional().

Andrew

#13 lore raw
Quoted 108 lines · Andrew Lunn

Hi Luo

For a patchset, netdev wants to see a patch 0/X which describes the big picture. What is the patchset as a whole doing.

Hi Andrew,
Thanks for reminder, will provide it in the next patch set.

Quoted 13 lines
drivers/net/mdio/mdio-ipq4019.c +13 -0
+static int ipq_mdio_reset(struct mii_bus *bus)
+{
+	struct ipq4019_mdio_data *priv = bus->priv;
+	struct device *dev = bus->parent;
+	struct gpio_desc *reset_gpio;
+	u32 val;
+	int i, ret;
+
+	/* To indicate CMN_PLL that ethernet_ldo has been ready if needed */
+	if (!IS_ERR(priv->eth_ldo_rdy)) {
+		val = readl(priv->eth_ldo_rdy);
+		val |= BIT(0);
+		writel(val, priv->eth_ldo_rdy);

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum, · line 207

Quoted 10 lines
drivers/net/mdio/mdio-ipq4019.c +10 -0
+		fsleep(QCA_PHY_SET_DELAY_US);
+	}
+
+	/* Reset GEPHY if need */
+	if (!IS_ERR(priv->reset_ctrl)) {
+		reset_control_assert(priv->reset_ctrl);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		reset_control_deassert(priv->reset_ctrl);
+		fsleep(QCA_PHY_SET_DELAY_US);
+	}

What exactly is being reset here? Which is GEPHY?

The MDIO bus master driver should not be touching any Ethernet PHYs. All it provides is a bus, nothing more.

The GEPHY is the embedded Giga Ethernet PHY in the chipset IPQ50xx, there is a dedicated MDIO bus for this internal PHY. what the reset function does here is for resetting this dedicated MDIO bus and this embedded PHY DSP hardware. because this dedicated MDIO bus is only connected with this internal PHY on chip set IPQ50xx, so i put this code in the MDIO reset function.

Quoted 17 lines
drivers/net/mdio/mdio-ipq4019.c +15 -0
+
+	/* Configure MDIO clock frequency */
+	if (!IS_ERR(priv->mdio_clk)) {
+		ret = clk_set_rate(priv->mdio_clk, QCA_MDIO_CLK_RATE);
+		if (ret)
+			return ret;
+
+		ret = clk_prepare_enable(priv->mdio_clk);
+		if (ret)
+			return ret;
+	}
 
+
+	/* Reset PHYs by gpio pins */
+	for (i = 0; i < gpiod_count(dev, "phy-reset"); i++) {
+		reset_gpio = gpiod_get_index_optional(dev, "phy-reset", i, 

GPIOD_OUT_HIGH);

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum, · line 230

Quoted 8 lines
drivers/net/mdio/mdio-ipq4019.c +8 -0
+		if (IS_ERR(reset_gpio))
+			continue;
+		gpiod_set_value_cansleep(reset_gpio, 0);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		gpiod_set_value_cansleep(reset_gpio, 1);
+		fsleep(QCA_PHY_SET_DELAY_US);
+		gpiod_put(reset_gpio);
+	}

No, there is common code in phylib to do that.

Hi Andrew,
The common code in phylib for resetting PHY by GPIO pin is high active, which is not suitable for the PHY reset here. for resetting the PHY, calling gpiod_set_value_cansleep(reset_gpio, 1), then gpiod_set_value_cansleep(reset_gpio, 0). but as for resetting the PHY by GPIO pin in IPQ chipset, this is the opposite process(low active) from the phylib code, which needs to set the GPIO output value to 0, then to 1 for reset as the code above.

Quoted 16 lines

static int ipq4019_mdio_probe(struct platform_device *pdev) {

drivers/net/mdio/mdio-ipq4019.c +2 -0
 	struct ipq4019_mdio_data *priv;
 	struct mii_bus *bus;
+	struct resource *res;
 	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -182,14 +244,23 @@ static int ipq4019_mdio_probe(struct 
 platform_device *pdev)
 		return -ENOMEM;
 
 	priv = bus->priv;
+	priv->eth_ldo_rdy = IOMEM_ERR_PTR(-EINVAL);
 
 	priv->membase = devm_platform_ioremap_resource(pdev, 0);

drivers/net/mdio/mdio-ipq4019.c static int ipq4019_mdio_probe(struct · line 260

Quoted 10 lines
drivers/net/mdio/mdio-ipq4019.c +6 -0
 	if (IS_ERR(priv->membase))
 		return PTR_ERR(priv->membase);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res)
+		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
+
+	priv->reset_ctrl = devm_reset_control_get_exclusive(&pdev->dev, 
 "gephy_mdc_rst");
+	priv->mdio_clk = devm_clk_get(&pdev->dev, "gcc_mdio_ahb_clk");

You probably want to use devm_clk_get_optional().

Andrew

thanks for the comment, will update it in the next patch set.