linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function
@ 2021-08-12 10:06 Luo Jie
  2021-08-12 10:06 ` [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Luo Jie @ 2021-08-12 10:06 UTC (permalink / raw)
  To: andrew, agross, bjorn.andersson, davem, kuba, robh+dt,
	hkallweit1, linux, robert.marko
  Cc: linux-arm-msm, netdev, devicetree, linux-kernel, sricharan, Luo Jie

This patch series add the MDIO reset features, which includes
configuring MDIO clock source frequency and indicating CMN_PLL that
ethernet LDO has been ready, this ethernet LDO is dedicated in the
IPQ5018 platform.

Specify more chipset IPQ40xx, IPQ807x, IPQ60xx and IPQ50xx supported by
this MDIO driver.

Changes in v3:
	* simplify the function ipq_mdio_reset.

Changes in v2:
	* Addressed review comments (Andrew Lunn).
	* Remove the IS_ERR().
	* make binding patch part of series.
	* document the property 'reg' and 'clock'.

Changes in v1:
	* make MDIO_IPQ4019 unchanged for backwards compatibility.
	* remove the PHY reset functions

Luo Jie (3):
  net: mdio: Add the reset function for IPQ MDIO driver
  MDIO: Kconfig: Specify more IPQ chipset supported
  dt-bindings: net: Add the properties for ipq4019 MDIO

 .../bindings/net/qcom,ipq4019-mdio.yaml       | 15 ++++++-
 drivers/net/mdio/Kconfig                      |  3 +-
 drivers/net/mdio/mdio-ipq4019.c               | 44 +++++++++++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)

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


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

* [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver
  2021-08-12 10:06 [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function Luo Jie
@ 2021-08-12 10:06 ` Luo Jie
  2021-08-15 14:49   ` Andrew Lunn
  2021-08-12 10:06 ` [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported Luo Jie
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Luo Jie @ 2021-08-12 10:06 UTC (permalink / raw)
  To: andrew, agross, bjorn.andersson, davem, kuba, robh+dt,
	hkallweit1, linux, robert.marko
  Cc: linux-arm-msm, netdev, devicetree, linux-kernel, sricharan, Luo Jie

1. configure the MDIO clock source frequency.
2. the LDO resource is needed to configure the ethernet LDO available
for CMN_PLL.

Signed-off-by: Luo Jie <luoj@codeaurora.org>
---
 drivers/net/mdio/Kconfig        |  1 +
 drivers/net/mdio/mdio-ipq4019.c | 43 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index 99a6c13a11af..a94d34cc7dc1 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -169,6 +169,7 @@ config MDIO_OCTEON
 config MDIO_IPQ4019
 	tristate "Qualcomm IPQ4019 MDIO interface support"
 	depends on HAS_IOMEM && OF_MDIO
+	depends on COMMON_CLK
 	help
 	  This driver supports the MDIO interface found in Qualcomm
 	  IPQ40xx series Soc-s.
diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index 9cd71d896963..e14d437e42a8 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -11,6 +11,7 @@
 #include <linux/of_mdio.h>
 #include <linux/phy.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
 
 #define MDIO_MODE_REG				0x40
 #define MDIO_ADDR_REG				0x44
@@ -31,8 +32,15 @@
 #define IPQ4019_MDIO_TIMEOUT	10000
 #define IPQ4019_MDIO_SLEEP		10
 
+/* MDIO clock source frequency is fixed to 100M */
+#define IPQ_MDIO_CLK_RATE	100000000
+
+#define IPQ_PHY_SET_DELAY_US	100000
+
 struct ipq4019_mdio_data {
 	void __iomem	*membase;
+	void __iomem *eth_ldo_rdy;
+	struct clk *mdio_clk;
 };
 
 static int ipq4019_mdio_wait_busy(struct mii_bus *bus)
@@ -171,10 +179,35 @@ static int ipq4019_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 	return 0;
 }
 
+static int ipq_mdio_reset(struct mii_bus *bus)
+{
+	struct ipq4019_mdio_data *priv = bus->priv;
+	u32 val;
+	int ret;
+
+	/* To indicate CMN_PLL that ethernet_ldo has been ready if platform resource 1
+	 * is specified in the device tree.
+	 */
+	if (priv->eth_ldo_rdy) {
+		val = readl(priv->eth_ldo_rdy);
+		val |= BIT(0);
+		writel(val, priv->eth_ldo_rdy);
+		fsleep(IPQ_PHY_SET_DELAY_US);
+	}
+
+	/* Configure MDIO clock source frequency if clock is specified in the device tree */
+	ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE);
+	if (ret)
+		return ret;
+
+	return clk_prepare_enable(priv->mdio_clk);
+}
+
 static int ipq4019_mdio_probe(struct platform_device *pdev)
 {
 	struct ipq4019_mdio_data *priv;
 	struct mii_bus *bus;
+	struct resource *res;
 	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -187,9 +220,19 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->membase))
 		return PTR_ERR(priv->membase);
 
+	priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "gcc_mdio_ahb_clk");
+	if (IS_ERR(priv->mdio_clk))
+		return PTR_ERR(priv->mdio_clk);
+
+	/* The platform resource is provided on the chipset IPQ5018 */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res)
+		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
+
 	bus->name = "ipq4019_mdio";
 	bus->read = ipq4019_mdio_read;
 	bus->write = ipq4019_mdio_write;
+	bus->reset = ipq_mdio_reset;
 	bus->parent = &pdev->dev;
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported
  2021-08-12 10:06 [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function Luo Jie
  2021-08-12 10:06 ` [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
@ 2021-08-12 10:06 ` Luo Jie
  2021-08-15 14:49   ` Andrew Lunn
  2021-08-12 10:06 ` [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO Luo Jie
  2021-08-16 10:00 ` [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Luo Jie @ 2021-08-12 10:06 UTC (permalink / raw)
  To: andrew, agross, bjorn.andersson, davem, kuba, robh+dt,
	hkallweit1, linux, robert.marko
  Cc: linux-arm-msm, netdev, devicetree, linux-kernel, sricharan, Luo Jie

The IPQ MDIO driver currently supports the chipset IPQ40xx, IPQ807x,
IPQ60xx and IPQ50xx.

Add the compatible 'qcom,ipq5018-mdio' because of ethernet LDO dedicated
to the IPQ5018 platform.

Signed-off-by: Luo Jie <luoj@codeaurora.org>
---
 drivers/net/mdio/Kconfig        | 2 +-
 drivers/net/mdio/mdio-ipq4019.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig
index a94d34cc7dc1..6da1fcb25847 100644
--- a/drivers/net/mdio/Kconfig
+++ b/drivers/net/mdio/Kconfig
@@ -172,7 +172,7 @@ config MDIO_IPQ4019
 	depends on COMMON_CLK
 	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"
diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index e14d437e42a8..14e08b786334 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -258,6 +258,7 @@ static int ipq4019_mdio_remove(struct platform_device *pdev)
 
 static const struct of_device_id ipq4019_mdio_dt_ids[] = {
 	{ .compatible = "qcom,ipq4019-mdio" },
+	{ .compatible = "qcom,ipq5018-mdio" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ipq4019_mdio_dt_ids);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO
  2021-08-12 10:06 [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function Luo Jie
  2021-08-12 10:06 ` [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
  2021-08-12 10:06 ` [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported Luo Jie
@ 2021-08-12 10:06 ` Luo Jie
  2021-08-15 14:50   ` Andrew Lunn
  2021-08-16 10:00 ` [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Luo Jie @ 2021-08-12 10:06 UTC (permalink / raw)
  To: andrew, agross, bjorn.andersson, davem, kuba, robh+dt,
	hkallweit1, linux, robert.marko
  Cc: linux-arm-msm, netdev, devicetree, linux-kernel, sricharan, Luo Jie

The new added properties resource "reg" is for configuring
ethernet LDO in the IPQ5018 chipset, the property "clocks"
is for configuring the MDIO clock source frequency.

Signed-off-by: Luo Jie <luoj@codeaurora.org>
---
 .../bindings/net/qcom,ipq4019-mdio.yaml           | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
index 0c973310ada0..2af304341772 100644
--- a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
+++ b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml
@@ -14,7 +14,9 @@ allOf:
 
 properties:
   compatible:
-    const: qcom,ipq4019-mdio
+    enum:
+      - qcom,ipq4019-mdio
+      - qcom,ipq5018-mdio
 
   "#address-cells":
     const: 1
@@ -23,7 +25,18 @@ properties:
     const: 0
 
   reg:
+    minItems: 1
+    maxItems: 2
+    description:
+      the first Address and length of the register set for the MDIO controller.
+      the second Address and length of the register for ethernet LDO, this second
+      address range is only required by the platform IPQ50xx.
+
+  clocks:
     maxItems: 1
+    description: |
+      MDIO clock source frequency fixed to 100MHZ, this clock should be specified
+      by the platform IPQ807x, IPQ60xx and IPQ50xx.
 
 required:
   - compatible
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver
  2021-08-12 10:06 ` [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
@ 2021-08-15 14:49   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2021-08-15 14:49 UTC (permalink / raw)
  To: Luo Jie
  Cc: agross, bjorn.andersson, davem, kuba, robh+dt, hkallweit1, linux,
	robert.marko, linux-arm-msm, netdev, devicetree, linux-kernel,
	sricharan

On Thu, Aug 12, 2021 at 06:06:40PM +0800, Luo Jie wrote:
> 1. configure the MDIO clock source frequency.
> 2. the LDO resource is needed to configure the ethernet LDO available
> for CMN_PLL.
> 
> Signed-off-by: Luo Jie <luoj@codeaurora.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported
  2021-08-12 10:06 ` [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported Luo Jie
@ 2021-08-15 14:49   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2021-08-15 14:49 UTC (permalink / raw)
  To: Luo Jie
  Cc: agross, bjorn.andersson, davem, kuba, robh+dt, hkallweit1, linux,
	robert.marko, linux-arm-msm, netdev, devicetree, linux-kernel,
	sricharan

On Thu, Aug 12, 2021 at 06:06:41PM +0800, Luo Jie wrote:
> The IPQ MDIO driver currently supports the chipset IPQ40xx, IPQ807x,
> IPQ60xx and IPQ50xx.
> 
> Add the compatible 'qcom,ipq5018-mdio' because of ethernet LDO dedicated
> to the IPQ5018 platform.
> 
> Signed-off-by: Luo Jie <luoj@codeaurora.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO
  2021-08-12 10:06 ` [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO Luo Jie
@ 2021-08-15 14:50   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2021-08-15 14:50 UTC (permalink / raw)
  To: Luo Jie
  Cc: agross, bjorn.andersson, davem, kuba, robh+dt, hkallweit1, linux,
	robert.marko, linux-arm-msm, netdev, devicetree, linux-kernel,
	sricharan

On Thu, Aug 12, 2021 at 06:06:42PM +0800, Luo Jie wrote:
> The new added properties resource "reg" is for configuring
> ethernet LDO in the IPQ5018 chipset, the property "clocks"
> is for configuring the MDIO clock source frequency.
> 
> Signed-off-by: Luo Jie <luoj@codeaurora.org>
> ---

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function
  2021-08-12 10:06 [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function Luo Jie
                   ` (2 preceding siblings ...)
  2021-08-12 10:06 ` [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO Luo Jie
@ 2021-08-16 10:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-16 10:00 UTC (permalink / raw)
  To: Luo Jie
  Cc: andrew, agross, bjorn.andersson, davem, kuba, robh+dt,
	hkallweit1, linux, robert.marko, linux-arm-msm, netdev,
	devicetree, linux-kernel, sricharan

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Thu, 12 Aug 2021 18:06:39 +0800 you wrote:
> This patch series add the MDIO reset features, which includes
> configuring MDIO clock source frequency and indicating CMN_PLL that
> ethernet LDO has been ready, this ethernet LDO is dedicated in the
> IPQ5018 platform.
> 
> Specify more chipset IPQ40xx, IPQ807x, IPQ60xx and IPQ50xx supported by
> this MDIO driver.
> 
> [...]

Here is the summary with links:
  - [v3,1/3] net: mdio: Add the reset function for IPQ MDIO driver
    https://git.kernel.org/netdev/net-next/c/23a890d493e3
  - [v3,2/3] MDIO: Kconfig: Specify more IPQ chipset supported
    https://git.kernel.org/netdev/net-next/c/c76ee26306b2
  - [v3,3/3] dt-bindings: net: Add the properties for ipq4019 MDIO
    https://git.kernel.org/netdev/net-next/c/2a4c32e767ad

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-08-16 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 10:06 [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function Luo Jie
2021-08-12 10:06 ` [PATCH v3 1/3] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
2021-08-15 14:49   ` Andrew Lunn
2021-08-12 10:06 ` [PATCH v3 2/3] MDIO: Kconfig: Specify more IPQ chipset supported Luo Jie
2021-08-15 14:49   ` Andrew Lunn
2021-08-12 10:06 ` [PATCH v3 3/3] dt-bindings: net: Add the properties for ipq4019 MDIO Luo Jie
2021-08-15 14:50   ` Andrew Lunn
2021-08-16 10:00 ` [PATCH v3 0/3] net: mdio: Add IPQ MDIO reset related function patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).