All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
@ 2018-07-27 21:23 ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Hi,
The patchset is based on David Miller's "net-next" repo.

The patchset extends the Broadcom iProc mdio mux to add support for
suspend/resume and the ability to configure the internal clock
divider. The patchset also sets the scan control register to
disable external master access.

The base address of the mdio-mux-bcm-iproc is modified to point to the
start of the mdio block's address space, to be able to access all the
mdio's registers. The missing registers are required to configure the
internal clock divider registers in some of the Broadcom SoC's.

Changes from v1:
 - Addressed Andrew's comments.
   - Reworked the patches to be based on 'net-next'
   - Removed 'fixes' from the commit messages, the changes are related
     to the new features being added.
   - Maintained backward compatibility to older dt-blob's specifying
     base addresse with an offset. The correction is applied in the
     driver and a message is printed to update the dt-blob.
   - Re-worked and re-ordered the last four patches (4-7).
     - Added setting of the scan control register as a new patch
     - Added a call to 'clk_prepare_enable()' in the patch that adds
       the clock config support, removed the debug message when clock
       is not passed.
     - Simplified the pm support patch (removed the array used for the
       save/restore logic).

Thanks
Arun

Arun Parameswaran (7):
  dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
  arm64: dts: Fix the base address of the Broadcom iProc mdio mux
  net: phy: Disable external master access in bcm mdio mux driver
  dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  net: phy: Add support to configure clock in Broadcom iProc mdio mux
  net: phy: Add pm support to Broadcom iProc mdio mux driver

 .../bindings/net/brcm,mdio-mux-iproc.txt           |   7 +-
 arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi   |   4 +-
 .../arm64/boot/dts/broadcom/stingray/stingray.dtsi |   4 +-
 drivers/net/phy/mdio-mux-bcm-iproc.c               | 109 +++++++++++++++++++--
 4 files changed, 109 insertions(+), 15 deletions(-)

-- 
1.9.1


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

* [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
@ 2018-07-27 21:23 ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,
The patchset is based on David Miller's "net-next" repo.

The patchset extends the Broadcom iProc mdio mux to add support for
suspend/resume and the ability to configure the internal clock
divider. The patchset also sets the scan control register to
disable external master access.

The base address of the mdio-mux-bcm-iproc is modified to point to the
start of the mdio block's address space, to be able to access all the
mdio's registers. The missing registers are required to configure the
internal clock divider registers in some of the Broadcom SoC's.

Changes from v1:
 - Addressed Andrew's comments.
   - Reworked the patches to be based on 'net-next'
   - Removed 'fixes' from the commit messages, the changes are related
     to the new features being added.
   - Maintained backward compatibility to older dt-blob's specifying
     base addresse with an offset. The correction is applied in the
     driver and a message is printed to update the dt-blob.
   - Re-worked and re-ordered the last four patches (4-7).
     - Added setting of the scan control register as a new patch
     - Added a call to 'clk_prepare_enable()' in the patch that adds
       the clock config support, removed the debug message when clock
       is not passed.
     - Simplified the pm support patch (removed the array used for the
       save/restore logic).

Thanks
Arun

Arun Parameswaran (7):
  dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
  arm64: dts: Fix the base address of the Broadcom iProc mdio mux
  net: phy: Disable external master access in bcm mdio mux driver
  dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  net: phy: Add support to configure clock in Broadcom iProc mdio mux
  net: phy: Add pm support to Broadcom iProc mdio mux driver

 .../bindings/net/brcm,mdio-mux-iproc.txt           |   7 +-
 arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi   |   4 +-
 .../arm64/boot/dts/broadcom/stingray/stingray.dtsi |   4 +-
 drivers/net/phy/mdio-mux-bcm-iproc.c               | 109 +++++++++++++++++++--
 4 files changed, 109 insertions(+), 15 deletions(-)

-- 
1.9.1

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

* [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Modify the base address of the Broadcom iProc MDIO mux driver to
point to the start of the block's register address space.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
index dfe287a..dc8aa68 100644
--- a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
+++ b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
@@ -18,9 +18,9 @@ at- Documentation/devicetree/bindings/net/mdio-mux.txt
 
 
 for example:
-		mdio_mux_iproc: mdio-mux@6602023c {
+		mdio_mux_iproc: mdio-mux@66020000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x6602023c 0x14>;
+			reg = <0x66020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
-- 
1.9.1


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

* [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Modify the base address of the Broadcom iProc MDIO mux driver to
point to the start of the block's register address space.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
index dfe287a..dc8aa68 100644
--- a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
+++ b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
@@ -18,9 +18,9 @@ at- Documentation/devicetree/bindings/net/mdio-mux.txt
 
 
 for example:
-		mdio_mux_iproc: mdio-mux at 6602023c {
+		mdio_mux_iproc: mdio-mux at 66020000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x6602023c 0x14>;
+			reg = <0x66020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
-- 
1.9.1

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

* [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Modify the register offsets in the Broadcom iProc mdio mux to start
from the top of the register address space.

Earlier, the base address pointed to the end of the block's register
space. The base address will now point to the start of the mdio's
address space. The offsets have been fixed to match this.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 0831b71..48bb74a 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -22,7 +22,7 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
-#define MDIO_PARAM_OFFSET		0x00
+#define MDIO_PARAM_OFFSET		0x23c
 #define MDIO_PARAM_MIIM_CYCLE		29
 #define MDIO_PARAM_INTERNAL_SEL		25
 #define MDIO_PARAM_BUS_ID		22
@@ -30,20 +30,22 @@
 #define MDIO_PARAM_PHY_ID		16
 #define MDIO_PARAM_PHY_DATA		0
 
-#define MDIO_READ_OFFSET		0x04
+#define MDIO_READ_OFFSET		0x240
 #define MDIO_READ_DATA_MASK		0xffff
-#define MDIO_ADDR_OFFSET		0x08
+#define MDIO_ADDR_OFFSET		0x244
 
-#define MDIO_CTRL_OFFSET		0x0C
+#define MDIO_CTRL_OFFSET		0x248
 #define MDIO_CTRL_WRITE_OP		0x1
 #define MDIO_CTRL_READ_OP		0x2
 
-#define MDIO_STAT_OFFSET		0x10
+#define MDIO_STAT_OFFSET		0x24c
 #define MDIO_STAT_DONE			1
 
 #define BUS_MAX_ADDR			32
 #define EXT_BUS_START_ADDR		16
 
+#define MDIO_REG_ADDR_SPACE_SIZE	0x250
+
 struct iproc_mdiomux_desc {
 	void *mux_handle;
 	void __iomem *base;
@@ -169,6 +171,14 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 	md->dev = &pdev->dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res->start & 0xfff) {
+		/* For backward compatibility in case the
+		 * base address is specified with an offset.
+		 */
+		dev_info(&pdev->dev, "fix base address in dt-blob\n");
+		res->start &= ~0xfff;
+		res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1;
+	}
 	md->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(md->base)) {
 		dev_err(&pdev->dev, "failed to ioremap register\n");
-- 
1.9.1


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

* [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Modify the register offsets in the Broadcom iProc mdio mux to start
from the top of the register address space.

Earlier, the base address pointed to the end of the block's register
space. The base address will now point to the start of the mdio's
address space. The offsets have been fixed to match this.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 0831b71..48bb74a 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -22,7 +22,7 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
-#define MDIO_PARAM_OFFSET		0x00
+#define MDIO_PARAM_OFFSET		0x23c
 #define MDIO_PARAM_MIIM_CYCLE		29
 #define MDIO_PARAM_INTERNAL_SEL		25
 #define MDIO_PARAM_BUS_ID		22
@@ -30,20 +30,22 @@
 #define MDIO_PARAM_PHY_ID		16
 #define MDIO_PARAM_PHY_DATA		0
 
-#define MDIO_READ_OFFSET		0x04
+#define MDIO_READ_OFFSET		0x240
 #define MDIO_READ_DATA_MASK		0xffff
-#define MDIO_ADDR_OFFSET		0x08
+#define MDIO_ADDR_OFFSET		0x244
 
-#define MDIO_CTRL_OFFSET		0x0C
+#define MDIO_CTRL_OFFSET		0x248
 #define MDIO_CTRL_WRITE_OP		0x1
 #define MDIO_CTRL_READ_OP		0x2
 
-#define MDIO_STAT_OFFSET		0x10
+#define MDIO_STAT_OFFSET		0x24c
 #define MDIO_STAT_DONE			1
 
 #define BUS_MAX_ADDR			32
 #define EXT_BUS_START_ADDR		16
 
+#define MDIO_REG_ADDR_SPACE_SIZE	0x250
+
 struct iproc_mdiomux_desc {
 	void *mux_handle;
 	void __iomem *base;
@@ -169,6 +171,14 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 	md->dev = &pdev->dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (res->start & 0xfff) {
+		/* For backward compatibility in case the
+		 * base address is specified with an offset.
+		 */
+		dev_info(&pdev->dev, "fix base address in dt-blob\n");
+		res->start &= ~0xfff;
+		res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1;
+	}
 	md->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(md->base)) {
 		dev_err(&pdev->dev, "failed to ioremap register\n");
-- 
1.9.1

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

* [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Modify the base address of the mdio mux driver to point to the
start of the mdio mux block's register address space.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi    | 4 ++--
 arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
index 4057197..1a406a7 100644
--- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
@@ -482,9 +482,9 @@
 			status = "disabled";
 		};
 
-		mdio_mux_iproc: mdio-mux@6602023c {
+		mdio_mux_iproc: mdio-mux@66020000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x6602023c 0x14>;
+			reg = <0x66020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
index b203152..a70e8dd 100644
--- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
+++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
@@ -278,9 +278,9 @@
 
 		#include "stingray-pinctrl.dtsi"
 
-		mdio_mux_iproc: mdio-mux@2023c {
+		mdio_mux_iproc: mdio-mux@20000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x0002023c 0x14>;
+			reg = <0x00020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
-- 
1.9.1


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

* [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Modify the base address of the mdio mux driver to point to the
start of the mdio mux block's register address space.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi    | 4 ++--
 arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
index 4057197..1a406a7 100644
--- a/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
+++ b/arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
@@ -482,9 +482,9 @@
 			status = "disabled";
 		};
 
-		mdio_mux_iproc: mdio-mux at 6602023c {
+		mdio_mux_iproc: mdio-mux at 66020000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x6602023c 0x14>;
+			reg = <0x66020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
diff --git a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
index b203152..a70e8dd 100644
--- a/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
+++ b/arch/arm64/boot/dts/broadcom/stingray/stingray.dtsi
@@ -278,9 +278,9 @@
 
 		#include "stingray-pinctrl.dtsi"
 
-		mdio_mux_iproc: mdio-mux at 2023c {
+		mdio_mux_iproc: mdio-mux at 20000 {
 			compatible = "brcm,mdio-mux-iproc";
-			reg = <0x0002023c 0x14>;
+			reg = <0x00020000 0x250>;
 			#address-cells = <1>;
 			#size-cells = <0>;
 
-- 
1.9.1

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

* [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Configure the scan control register in the Broadcom iProc
mdio mux driver to disable access to external master.

In some SoC's, the scan control register defaults to an incorrect
value.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 48bb74a..c36ce4b 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -22,6 +22,9 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
+#define MDIO_SCAN_CTRL_OFFSET		0x008
+#define MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR	28
+
 #define MDIO_PARAM_OFFSET		0x23c
 #define MDIO_PARAM_MIIM_CYCLE		29
 #define MDIO_PARAM_INTERNAL_SEL		25
@@ -53,6 +56,16 @@ struct iproc_mdiomux_desc {
 	struct mii_bus *mii_bus;
 };
 
+static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
+{
+	u32 val;
+
+	/* Disable external mdio master access */
+	val = readl(md->base + MDIO_SCAN_CTRL_OFFSET);
+	val |= BIT(MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR);
+	writel(val, md->base + MDIO_SCAN_CTRL_OFFSET);
+}
+
 static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
 {
 	unsigned int timeout = 1000; /* loop for 1s */
@@ -216,6 +229,8 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 		goto out_register;
 	}
 
+	mdio_mux_iproc_config(md);
+
 	dev_info(md->dev, "iProc mdiomux registered\n");
 	return 0;
 
-- 
1.9.1


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

* [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Configure the scan control register in the Broadcom iProc
mdio mux driver to disable access to external master.

In some SoC's, the scan control register defaults to an incorrect
value.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 48bb74a..c36ce4b 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -22,6 +22,9 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
+#define MDIO_SCAN_CTRL_OFFSET		0x008
+#define MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR	28
+
 #define MDIO_PARAM_OFFSET		0x23c
 #define MDIO_PARAM_MIIM_CYCLE		29
 #define MDIO_PARAM_INTERNAL_SEL		25
@@ -53,6 +56,16 @@ struct iproc_mdiomux_desc {
 	struct mii_bus *mii_bus;
 };
 
+static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
+{
+	u32 val;
+
+	/* Disable external mdio master access */
+	val = readl(md->base + MDIO_SCAN_CTRL_OFFSET);
+	val |= BIT(MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR);
+	writel(val, md->base + MDIO_SCAN_CTRL_OFFSET);
+}
+
 static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
 {
 	unsigned int timeout = 1000; /* loop for 1s */
@@ -216,6 +229,8 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 		goto out_register;
 	}
 
+	mdio_mux_iproc_config(md);
+
 	dev_info(md->dev, "iProc mdiomux registered\n");
 	return 0;
 
-- 
1.9.1

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

* [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Add clock phandle, of the core clock driving the mdio block, as an
optional property to the Broadcom iProc mdio mux.

The clock, when specified, will be used to setup the rate adjust registers
in the mdio to derrive the mdio's operating frequency.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
index dc8aa68..b58843f 100644
--- a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
+++ b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
@@ -13,6 +13,9 @@ MDIO multiplexer node:
 Every non-ethernet PHY requires a compatible so that it could be probed based
 on this compatible string.
 
+Optional properties:
+- clocks: phandle of the core clock which drives the mdio block.
+
 Additional information regarding generic multiplexer properties can be found
 at- Documentation/devicetree/bindings/net/mdio-mux.txt
 
-- 
1.9.1


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

* [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add clock phandle, of the core clock driving the mdio block, as an
optional property to the Broadcom iProc mdio mux.

The clock, when specified, will be used to setup the rate adjust registers
in the mdio to derrive the mdio's operating frequency.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
index dc8aa68..b58843f 100644
--- a/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
+++ b/Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt
@@ -13,6 +13,9 @@ MDIO multiplexer node:
 Every non-ethernet PHY requires a compatible so that it could be probed based
 on this compatible string.
 
+Optional properties:
+- clocks: phandle of the core clock which drives the mdio block.
+
 Additional information regarding generic multiplexer properties can be found
 at- Documentation/devicetree/bindings/net/mdio-mux.txt
 
-- 
1.9.1

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Add support to configure the internal rate adjust register based on the
core clock supplied through device tree in the Broadcom iProc mdio mux.

The operating frequency of the mdio mux block is 11MHz. This is derrived
by dividing the clock to the mdio mux with the rate adjust register.

In some SoC's the default values of the rate adjust register do not yield
11MHz. These SoC's are required to specify the clock via the device tree
for proper operation.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 46 ++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index c36ce4b..51d1003 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * version 2 (GPLv2) along with this source code.
  */
-
+#include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/device.h>
 #include <linux/of_mdio.h>
@@ -22,6 +22,10 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
+#define MDIO_RATE_ADJ_EXT_OFFSET	0x000
+#define MDIO_RATE_ADJ_INT_OFFSET	0x004
+#define MDIO_RATE_ADJ_DIVIDENT_SHIFT	16
+
 #define MDIO_SCAN_CTRL_OFFSET		0x008
 #define MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR	28
 
@@ -49,21 +53,38 @@
 
 #define MDIO_REG_ADDR_SPACE_SIZE	0x250
 
+#define MDIO_OPERATING_FREQUENCY	11000000
+#define MDIO_RATE_ADJ_DIVIDENT		1
+
 struct iproc_mdiomux_desc {
 	void *mux_handle;
 	void __iomem *base;
 	struct device *dev;
 	struct mii_bus *mii_bus;
+	struct clk *core_clk;
 };
 
 static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
 {
 	u32 val;
+	u32 divisor;
 
 	/* Disable external mdio master access */
 	val = readl(md->base + MDIO_SCAN_CTRL_OFFSET);
 	val |= BIT(MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR);
 	writel(val, md->base + MDIO_SCAN_CTRL_OFFSET);
+
+	if (md->core_clk) {
+		/* use rate adjust regs to derrive the mdio's operating
+		 * frequency from the specified core clock
+		 */
+		divisor = clk_get_rate(md->core_clk) / MDIO_OPERATING_FREQUENCY;
+		divisor = divisor / (MDIO_RATE_ADJ_DIVIDENT + 1);
+		val = divisor;
+		val |= MDIO_RATE_ADJ_DIVIDENT << MDIO_RATE_ADJ_DIVIDENT_SHIFT;
+		writel(val, md->base + MDIO_RATE_ADJ_EXT_OFFSET);
+		writel(val, md->base + MDIO_RATE_ADJ_INT_OFFSET);
+	}
 }
 
 static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
@@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 		return PTR_ERR(md->base);
 	}
 
+	md->core_clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(md->core_clk)) {
+		md->core_clk = NULL;
+	} else {
+		rc = clk_prepare_enable(md->core_clk);
+		if (rc) {
+			dev_err(&pdev->dev, "failed to enable core clk\n");
+			return rc;
+		}
+	}
+
 	md->mii_bus = mdiobus_alloc();
 	if (!md->mii_bus) {
 		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto out;
 	}
 
 	bus = md->mii_bus;
@@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 	rc = mdiobus_register(bus);
 	if (rc) {
 		dev_err(&pdev->dev, "mdiomux registration failed\n");
-		goto out;
+		goto out_alloc;
 	}
 
 	platform_set_drvdata(pdev, md);
@@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 
 out_register:
 	mdiobus_unregister(bus);
-out:
+out_alloc:
 	mdiobus_free(bus);
+out:
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
 	return rc;
 }
 
@@ -248,6 +284,8 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	mdio_mux_uninit(md->mux_handle);
 	mdiobus_unregister(md->mii_bus);
 	mdiobus_free(md->mii_bus);
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
 
 	return 0;
 }
-- 
1.9.1


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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add support to configure the internal rate adjust register based on the
core clock supplied through device tree in the Broadcom iProc mdio mux.

The operating frequency of the mdio mux block is 11MHz. This is derrived
by dividing the clock to the mdio mux with the rate adjust register.

In some SoC's the default values of the rate adjust register do not yield
11MHz. These SoC's are required to specify the clock via the device tree
for proper operation.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 46 ++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index c36ce4b..51d1003 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -13,7 +13,7 @@
  * You should have received a copy of the GNU General Public License
  * version 2 (GPLv2) along with this source code.
  */
-
+#include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/device.h>
 #include <linux/of_mdio.h>
@@ -22,6 +22,10 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
+#define MDIO_RATE_ADJ_EXT_OFFSET	0x000
+#define MDIO_RATE_ADJ_INT_OFFSET	0x004
+#define MDIO_RATE_ADJ_DIVIDENT_SHIFT	16
+
 #define MDIO_SCAN_CTRL_OFFSET		0x008
 #define MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR	28
 
@@ -49,21 +53,38 @@
 
 #define MDIO_REG_ADDR_SPACE_SIZE	0x250
 
+#define MDIO_OPERATING_FREQUENCY	11000000
+#define MDIO_RATE_ADJ_DIVIDENT		1
+
 struct iproc_mdiomux_desc {
 	void *mux_handle;
 	void __iomem *base;
 	struct device *dev;
 	struct mii_bus *mii_bus;
+	struct clk *core_clk;
 };
 
 static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
 {
 	u32 val;
+	u32 divisor;
 
 	/* Disable external mdio master access */
 	val = readl(md->base + MDIO_SCAN_CTRL_OFFSET);
 	val |= BIT(MDIO_SCAN_CTRL_OVRIDE_EXT_MSTR);
 	writel(val, md->base + MDIO_SCAN_CTRL_OFFSET);
+
+	if (md->core_clk) {
+		/* use rate adjust regs to derrive the mdio's operating
+		 * frequency from the specified core clock
+		 */
+		divisor = clk_get_rate(md->core_clk) / MDIO_OPERATING_FREQUENCY;
+		divisor = divisor / (MDIO_RATE_ADJ_DIVIDENT + 1);
+		val = divisor;
+		val |= MDIO_RATE_ADJ_DIVIDENT << MDIO_RATE_ADJ_DIVIDENT_SHIFT;
+		writel(val, md->base + MDIO_RATE_ADJ_EXT_OFFSET);
+		writel(val, md->base + MDIO_RATE_ADJ_INT_OFFSET);
+	}
 }
 
 static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
@@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 		return PTR_ERR(md->base);
 	}
 
+	md->core_clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(md->core_clk)) {
+		md->core_clk = NULL;
+	} else {
+		rc = clk_prepare_enable(md->core_clk);
+		if (rc) {
+			dev_err(&pdev->dev, "failed to enable core clk\n");
+			return rc;
+		}
+	}
+
 	md->mii_bus = mdiobus_alloc();
 	if (!md->mii_bus) {
 		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto out;
 	}
 
 	bus = md->mii_bus;
@@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 	rc = mdiobus_register(bus);
 	if (rc) {
 		dev_err(&pdev->dev, "mdiomux registration failed\n");
-		goto out;
+		goto out_alloc;
 	}
 
 	platform_set_drvdata(pdev, md);
@@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 
 out_register:
 	mdiobus_unregister(bus);
-out:
+out_alloc:
 	mdiobus_free(bus);
+out:
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
 	return rc;
 }
 
@@ -248,6 +284,8 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	mdio_mux_uninit(md->mux_handle);
 	mdiobus_unregister(md->mii_bus);
 	mdiobus_free(md->mii_bus);
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
 
 	return 0;
 }
-- 
1.9.1

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

* [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-27 21:23   ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: David S. Miller, Florian Fainelli, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list, Arun Parameswaran

Add support for suspend and resume to the Broadcom iProc mdio
mux driver.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 51d1003..d89dce0 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int mdio_mux_iproc_suspend(struct device *dev)
+{
+	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
+
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
+
+	return 0;
+}
+
+static int mdio_mux_iproc_resume(struct device *dev)
+{
+	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
+
+	if (md->core_clk)
+		clk_prepare_enable(md->core_clk);
+
+	mdio_mux_iproc_config(md);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(mdio_mux_iproc_pm_ops,
+			 mdio_mux_iproc_suspend, mdio_mux_iproc_resume);
+
 static const struct of_device_id mdio_mux_iproc_match[] = {
 	{
 		.compatible = "brcm,mdio-mux-iproc",
@@ -302,6 +329,7 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	.driver = {
 		.name		= "mdio-mux-iproc",
 		.of_match_table = mdio_mux_iproc_match,
+		.pm		= &mdio_mux_iproc_pm_ops,
 	},
 	.probe		= mdio_mux_iproc_probe,
 	.remove		= mdio_mux_iproc_remove,
-- 
1.9.1


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

* [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
@ 2018-07-27 21:23   ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-27 21:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for suspend and resume to the Broadcom iProc mdio
mux driver.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 51d1003..d89dce0 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int mdio_mux_iproc_suspend(struct device *dev)
+{
+	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
+
+	if (md->core_clk)
+		clk_disable_unprepare(md->core_clk);
+
+	return 0;
+}
+
+static int mdio_mux_iproc_resume(struct device *dev)
+{
+	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
+
+	if (md->core_clk)
+		clk_prepare_enable(md->core_clk);
+
+	mdio_mux_iproc_config(md);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(mdio_mux_iproc_pm_ops,
+			 mdio_mux_iproc_suspend, mdio_mux_iproc_resume);
+
 static const struct of_device_id mdio_mux_iproc_match[] = {
 	{
 		.compatible = "brcm,mdio-mux-iproc",
@@ -302,6 +329,7 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
 	.driver = {
 		.name		= "mdio-mux-iproc",
 		.of_match_table = mdio_mux_iproc_match,
+		.pm		= &mdio_mux_iproc_pm_ops,
 	},
 	.probe		= mdio_mux_iproc_probe,
 	.remove		= mdio_mux_iproc_remove,
-- 
1.9.1

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28  0:03     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28  0:03 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

>  static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
>  {
>  	u32 val;
> +	u32 divisor;

Hi Arun

Reverse Christmas tree please.

	Andrew

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-28  0:03     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28  0:03 UTC (permalink / raw)
  To: linux-arm-kernel

>  static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
>  {
>  	u32 val;
> +	u32 divisor;

Hi Arun

Reverse Christmas tree please.

	Andrew

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

* Re: [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:09     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:09 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:27PM -0700, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
@ 2018-07-28 21:09     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:27PM -0700, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:10     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:10 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:28PM -0700, Arun Parameswaran wrote:
> Modify the register offsets in the Broadcom iProc mdio mux to start
> from the top of the register address space.
> 
> Earlier, the base address pointed to the end of the block's register
> space. The base address will now point to the start of the mdio's
> address space. The offsets have been fixed to match this.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
@ 2018-07-28 21:10     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:28PM -0700, Arun Parameswaran wrote:
> Modify the register offsets in the Broadcom iProc mdio mux to start
> from the top of the register address space.
> 
> Earlier, the base address pointed to the end of the block's register
> space. The base address will now point to the start of the mdio's
> address space. The offsets have been fixed to match this.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:11     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:11 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:29PM -0700, Arun Parameswaran wrote:
> Modify the base address of the mdio mux driver to point to the
> start of the mdio mux block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
@ 2018-07-28 21:11     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:29PM -0700, Arun Parameswaran wrote:
> Modify the base address of the mdio mux driver to point to the
> start of the mdio mux block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:13     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:13 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:30PM -0700, Arun Parameswaran wrote:
> Configure the scan control register in the Broadcom iProc
> mdio mux driver to disable access to external master.
> 
> In some SoC's, the scan control register defaults to an incorrect
> value.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
@ 2018-07-28 21:13     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:30PM -0700, Arun Parameswaran wrote:
> Configure the scan control register in the Broadcom iProc
> mdio mux driver to disable access to external master.
> 
> In some SoC's, the scan control register defaults to an incorrect
> value.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:15     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:15 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:31PM -0700, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
@ 2018-07-28 21:15     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:31PM -0700, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-28 21:22     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:22 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  		return PTR_ERR(md->base);
>  	}
>  
> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(md->core_clk)) {
> +		md->core_clk = NULL;
> +	} else {
> +		rc = clk_prepare_enable(md->core_clk);
> +		if (rc) {
> +			dev_err(&pdev->dev, "failed to enable core clk\n");
> +			return rc;
> +		}
> +	}
> +
>  	md->mii_bus = mdiobus_alloc();
>  	if (!md->mii_bus) {
>  		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
> -		return -ENOMEM;
> +		rc = -ENOMEM;
> +		goto out;

Hi Arun

There is a devm_mdiobus_alloc() which could make the cleanup on error
simple.

>  	}
>  
>  	bus = md->mii_bus;
> @@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  	rc = mdiobus_register(bus);
>  	if (rc) {
>  		dev_err(&pdev->dev, "mdiomux registration failed\n");
> -		goto out;
> +		goto out_alloc;
>  	}
>  
>  	platform_set_drvdata(pdev, md);
> @@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  
>  out_register:
>  	mdiobus_unregister(bus);
> -out:
> +out_alloc:
>  	mdiobus_free(bus);
> +out:
> +	if (md->core_clk)
> +		clk_disable_unprepare(md->core_clk);
>  	return rc;
>  }

   Andrew

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-28 21:22     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:22 UTC (permalink / raw)
  To: linux-arm-kernel

> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  		return PTR_ERR(md->base);
>  	}
>  
> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(md->core_clk)) {
> +		md->core_clk = NULL;
> +	} else {
> +		rc = clk_prepare_enable(md->core_clk);
> +		if (rc) {
> +			dev_err(&pdev->dev, "failed to enable core clk\n");
> +			return rc;
> +		}
> +	}
> +
>  	md->mii_bus = mdiobus_alloc();
>  	if (!md->mii_bus) {
>  		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
> -		return -ENOMEM;
> +		rc = -ENOMEM;
> +		goto out;

Hi Arun

There is a devm_mdiobus_alloc() which could make the cleanup on error
simple.

>  	}
>  
>  	bus = md->mii_bus;
> @@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  	rc = mdiobus_register(bus);
>  	if (rc) {
>  		dev_err(&pdev->dev, "mdiomux registration failed\n");
> -		goto out;
> +		goto out_alloc;
>  	}
>  
>  	platform_set_drvdata(pdev, md);
> @@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  
>  out_register:
>  	mdiobus_unregister(bus);
> -out:
> +out_alloc:
>  	mdiobus_free(bus);
> +out:
> +	if (md->core_clk)
> +		clk_disable_unprepare(md->core_clk);
>  	return rc;
>  }

   Andrew

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

* Re: [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
  (?)
@ 2018-07-28 21:27     ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:27 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:33PM -0700, Arun Parameswaran wrote:
> Add support for suspend and resume to the Broadcom iProc mdio
> mux driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
@ 2018-07-28 21:27     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:27 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: Mark Rutland, devicetree, Florian Fainelli, Scott Branden,
	Ray Jui, Will Deacon, linux-kernel, Rob Herring,
	bcm-kernel-feedback-list, Catalin Marinas, netdev,
	David S. Miller, linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:33PM -0700, Arun Parameswaran wrote:
> Add support for suspend and resume to the Broadcom iProc mdio
> mux driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
@ 2018-07-28 21:27     ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:33PM -0700, Arun Parameswaran wrote:
> Add support for suspend and resume to the Broadcom iProc mdio
> mux driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

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

    Andrew

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

* Re: [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
  2018-07-27 21:23 ` Arun Parameswaran
@ 2018-07-28 21:32   ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:32 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:26PM -0700, Arun Parameswaran wrote:
> Hi,
> The patchset is based on David Miller's "net-next" repo.
> 
> The patchset extends the Broadcom iProc mdio mux to add support for
> suspend/resume and the ability to configure the internal clock
> divider. The patchset also sets the scan control register to
> disable external master access.

Hi Arun

It would be good to modify the .dtsi files to make use of the new
clock properties.

      Andrew

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

* [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
@ 2018-07-28 21:32   ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-28 21:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:26PM -0700, Arun Parameswaran wrote:
> Hi,
> The patchset is based on David Miller's "net-next" repo.
> 
> The patchset extends the Broadcom iProc mdio mux to add support for
> suspend/resume and the ability to configure the internal clock
> divider. The patchset also sets the scan control register to
> disable external master access.

Hi Arun

It would be good to modify the .dtsi files to make use of the new
clock properties.

      Andrew

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-28  0:03     ` Andrew Lunn
@ 2018-07-30 16:47       ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:47 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

Hi Andrew

On 18-07-27 05:03 PM, Andrew Lunn wrote:
>>  static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
>>  {
>>  	u32 val;
>> +	u32 divisor;
> 
> Hi Arun
> 
> Reverse Christmas tree please.
> 
> 	Andrew
> 
Ok, will send out an updated patch.

Thanks
Arun

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-30 16:47       ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew

On 18-07-27 05:03 PM, Andrew Lunn wrote:
>>  static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)
>>  {
>>  	u32 val;
>> +	u32 divisor;
> 
> Hi Arun
> 
> Reverse Christmas tree please.
> 
> 	Andrew
> 
Ok, will send out an updated patch.

Thanks
Arun

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-28 21:22     ` Andrew Lunn
@ 2018-07-30 16:49       ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:49 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

Hi Andrew,

On 18-07-28 02:22 PM, Andrew Lunn wrote:
>> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  		return PTR_ERR(md->base);
>>  	}
>>  
>> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
>> +	if (IS_ERR(md->core_clk)) {
>> +		md->core_clk = NULL;
>> +	} else {
>> +		rc = clk_prepare_enable(md->core_clk);
>> +		if (rc) {
>> +			dev_err(&pdev->dev, "failed to enable core clk\n");
>> +			return rc;
>> +		}
>> +	}
>> +
>>  	md->mii_bus = mdiobus_alloc();
>>  	if (!md->mii_bus) {
>>  		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
>> -		return -ENOMEM;
>> +		rc = -ENOMEM;
>> +		goto out;
> 
> Hi Arun
> 
> There is a devm_mdiobus_alloc() which could make the cleanup on error
> simple.
> 
Should I do this as a separate patch ?

Thanks
Arun
>>  	}
>>  
>>  	bus = md->mii_bus;
>> @@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  	rc = mdiobus_register(bus);
>>  	if (rc) {
>>  		dev_err(&pdev->dev, "mdiomux registration failed\n");
>> -		goto out;
>> +		goto out_alloc;
>>  	}
>>  
>>  	platform_set_drvdata(pdev, md);
>> @@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  
>>  out_register:
>>  	mdiobus_unregister(bus);
>> -out:
>> +out_alloc:
>>  	mdiobus_free(bus);
>> +out:
>> +	if (md->core_clk)
>> +		clk_disable_unprepare(md->core_clk);
>>  	return rc;
>>  }
> 
>    Andrew
> 

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-30 16:49       ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andrew,

On 18-07-28 02:22 PM, Andrew Lunn wrote:
>> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  		return PTR_ERR(md->base);
>>  	}
>>  
>> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
>> +	if (IS_ERR(md->core_clk)) {
>> +		md->core_clk = NULL;
>> +	} else {
>> +		rc = clk_prepare_enable(md->core_clk);
>> +		if (rc) {
>> +			dev_err(&pdev->dev, "failed to enable core clk\n");
>> +			return rc;
>> +		}
>> +	}
>> +
>>  	md->mii_bus = mdiobus_alloc();
>>  	if (!md->mii_bus) {
>>  		dev_err(&pdev->dev, "mdiomux bus alloc failed\n");
>> -		return -ENOMEM;
>> +		rc = -ENOMEM;
>> +		goto out;
> 
> Hi Arun
> 
> There is a devm_mdiobus_alloc() which could make the cleanup on error
> simple.
> 
Should I do this as a separate patch ?

Thanks
Arun
>>  	}
>>  
>>  	bus = md->mii_bus;
>> @@ -217,7 +250,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  	rc = mdiobus_register(bus);
>>  	if (rc) {
>>  		dev_err(&pdev->dev, "mdiomux registration failed\n");
>> -		goto out;
>> +		goto out_alloc;
>>  	}
>>  
>>  	platform_set_drvdata(pdev, md);
>> @@ -236,8 +269,11 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>>  
>>  out_register:
>>  	mdiobus_unregister(bus);
>> -out:
>> +out_alloc:
>>  	mdiobus_free(bus);
>> +out:
>> +	if (md->core_clk)
>> +		clk_disable_unprepare(md->core_clk);
>>  	return rc;
>>  }
> 
>    Andrew
> 

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

* Re: [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
  2018-07-28 21:32   ` Andrew Lunn
@ 2018-07-30 16:57     ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:57 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list


Hi Andrew,

On 18-07-28 02:32 PM, Andrew Lunn wrote:
> On Fri, Jul 27, 2018 at 02:23:26PM -0700, Arun Parameswaran wrote:
>> Hi,
>> The patchset is based on David Miller's "net-next" repo.
>>
>> The patchset extends the Broadcom iProc mdio mux to add support for
>> suspend/resume and the ability to configure the internal clock
>> divider. The patchset also sets the scan control register to
>> disable external master access.
> 
> Hi Arun
> 
> It would be good to modify the .dtsi files to make use of the new
> clock properties.
> 
The clock is done primarily for the newer Omega SoC. I hope, we will
upstream the devicetree file for Omega soon.

The existing NS2 and Stingray SoC's, default to proper values in the
hardware registers, so they did not need to specify the clock. They
will also work over sleep cycles for the same reason.

But, I will ask around to see if we can add the clock for those
SoC's as well.

Thanks
Arun

>       Andrew
> 


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

* [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux
@ 2018-07-30 16:57     ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-30 16:57 UTC (permalink / raw)
  To: linux-arm-kernel


Hi Andrew,

On 18-07-28 02:32 PM, Andrew Lunn wrote:
> On Fri, Jul 27, 2018 at 02:23:26PM -0700, Arun Parameswaran wrote:
>> Hi,
>> The patchset is based on David Miller's "net-next" repo.
>>
>> The patchset extends the Broadcom iProc mdio mux to add support for
>> suspend/resume and the ability to configure the internal clock
>> divider. The patchset also sets the scan control register to
>> disable external master access.
> 
> Hi Arun
> 
> It would be good to modify the .dtsi files to make use of the new
> clock properties.
> 
The clock is done primarily for the newer Omega SoC. I hope, we will
upstream the devicetree file for Omega soon.

The existing NS2 and Stingray SoC's, default to proper values in the
hardware registers, so they did not need to specify the clock. They
will also work over sleep cycles for the same reason.

But, I will ask around to see if we can add the clock for those
SoC's as well.

Thanks
Arun

>       Andrew
> 

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-30 16:49       ` Arun Parameswaran
@ 2018-07-30 18:04         ` Andrew Lunn
  -1 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-30 18:04 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Rob Herring, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

> > Hi Arun
> > 
> > There is a devm_mdiobus_alloc() which could make the cleanup on error
> > simple.
> > 
> Should I do this as a separate patch ?

A separate patch is easier to review. And if something breaks, a git
bisect gives you a better idea what actually broke it, if you have
lots of small patches.

     Andrew

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-30 18:04         ` Andrew Lunn
  0 siblings, 0 replies; 63+ messages in thread
From: Andrew Lunn @ 2018-07-30 18:04 UTC (permalink / raw)
  To: linux-arm-kernel

> > Hi Arun
> > 
> > There is a devm_mdiobus_alloc() which could make the cleanup on error
> > simple.
> > 
> Should I do this as a separate patch ?

A separate patch is easier to review. And if something breaks, a git
bisect gives you a better idea what actually broke it, if you have
lots of small patches.

     Andrew

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

* Re: [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:48     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:48 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>


-- 
Florian

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

* [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
@ 2018-07-30 22:48     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>


-- 
Florian

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

* Re: [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:50     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:50 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the register offsets in the Broadcom iProc mdio mux to start
> from the top of the register address space.
> 
> Earlier, the base address pointed to the end of the block's register
> space. The base address will now point to the start of the mdio's
> address space. The offsets have been fixed to match this.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
@ 2018-07-30 22:50     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:50 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the register offsets in the Broadcom iProc mdio mux to start
> from the top of the register address space.
> 
> Earlier, the base address pointed to the end of the block's register
> space. The base address will now point to the start of the mdio's
> address space. The offsets have been fixed to match this.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:50     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:50 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the base address of the mdio mux driver to point to the
> start of the mdio mux block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux
@ 2018-07-30 22:50     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:50 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Modify the base address of the mdio mux driver to point to the
> start of the mdio mux block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:51     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:51 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Configure the scan control register in the Broadcom iProc
> mdio mux driver to disable access to external master.
> 
> In some SoC's, the scan control register defaults to an incorrect
> value.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian

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

* [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver
@ 2018-07-30 22:51     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Configure the scan control register in the Broadcom iProc
> mdio mux driver to disable access to external master.
> 
> In some SoC's, the scan control register defaults to an incorrect
> value.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian

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

* Re: [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:51     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:51 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
@ 2018-07-30 22:51     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:51 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-30 22:53     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:53 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Florian Fainelli,
	Andrew Lunn, Rob Herring, Mark Rutland, Ray Jui, Scott Branden,
	Catalin Marinas, Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add support for suspend and resume to the Broadcom iProc mdio
> mux driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
> index 51d1003..d89dce0 100644
> --- a/drivers/net/phy/mdio-mux-bcm-iproc.c
> +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
> @@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int mdio_mux_iproc_suspend(struct device *dev)
> +{
> +	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
> +
> +	if (md->core_clk)
> +		clk_disable_unprepare(md->core_clk);

Since you are assigning md->core_clk to NULL in case clk_get() returned
an error, checking for md->core_clk is not necessary since the Linux
common clock framework perform that NULL check already.
-- 
-- 
Florian

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

* [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
@ 2018-07-30 22:53     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-30 22:53 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add support for suspend and resume to the Broadcom iProc mdio
> mux driver.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
> index 51d1003..d89dce0 100644
> --- a/drivers/net/phy/mdio-mux-bcm-iproc.c
> +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
> @@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int mdio_mux_iproc_suspend(struct device *dev)
> +{
> +	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
> +
> +	if (md->core_clk)
> +		clk_disable_unprepare(md->core_clk);

Since you are assigning md->core_clk to NULL in case clk_get() returned
an error, checking for md->core_clk is not necessary since the Linux
common clock framework perform that NULL check already.
-- 
-- 
Florian

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

* Re: [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
  2018-07-30 22:53     ` Florian Fainelli
@ 2018-07-31 17:51       ` Arun Parameswaran
  -1 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-31 17:51 UTC (permalink / raw)
  To: Florian Fainelli, David S. Miller, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

Hi Florian,

On 18-07-30 03:53 PM, Florian Fainelli wrote:
> On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
>> Add support for suspend and resume to the Broadcom iProc mdio
>> mux driver.
>>
>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>> ---
>>  drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
>>  1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
>> index 51d1003..d89dce0 100644
>> --- a/drivers/net/phy/mdio-mux-bcm-iproc.c
>> +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
>> @@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> +#ifdef CONFIG_PM_SLEEP
>> +static int mdio_mux_iproc_suspend(struct device *dev)
>> +{
>> +	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
>> +
>> +	if (md->core_clk)
>> +		clk_disable_unprepare(md->core_clk);
> 
> Since you are assigning md->core_clk to NULL in case clk_get() returned
> an error, checking for md->core_clk is not necessary since the Linux
> common clock framework perform that NULL check already.
> 
Will remove the check.

I am working on Andrew's comments (which will add one more patch to the series).
I will send the whole patchset again, with reviewed-by tags (From Florian
and Andrew on the ones that apply).

Thanks
Arun

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

* [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver
@ 2018-07-31 17:51       ` Arun Parameswaran
  0 siblings, 0 replies; 63+ messages in thread
From: Arun Parameswaran @ 2018-07-31 17:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Florian,

On 18-07-30 03:53 PM, Florian Fainelli wrote:
> On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
>> Add support for suspend and resume to the Broadcom iProc mdio
>> mux driver.
>>
>> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
>> ---
>>  drivers/net/phy/mdio-mux-bcm-iproc.c | 28 ++++++++++++++++++++++++++++
>>  1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
>> index 51d1003..d89dce0 100644
>> --- a/drivers/net/phy/mdio-mux-bcm-iproc.c
>> +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
>> @@ -290,6 +290,33 @@ static int mdio_mux_iproc_remove(struct platform_device *pdev)
>>  	return 0;
>>  }
>>  
>> +#ifdef CONFIG_PM_SLEEP
>> +static int mdio_mux_iproc_suspend(struct device *dev)
>> +{
>> +	struct iproc_mdiomux_desc *md = dev_get_drvdata(dev);
>> +
>> +	if (md->core_clk)
>> +		clk_disable_unprepare(md->core_clk);
> 
> Since you are assigning md->core_clk to NULL in case clk_get() returned
> an error, checking for md->core_clk is not necessary since the Linux
> common clock framework perform that NULL check already.
> 
Will remove the check.

I am working on Andrew's comments (which will add one more patch to the series).
I will send the whole patchset again, with reviewed-by tags (From Florian
and Andrew on the ones that apply).

Thanks
Arun

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

* Re: [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-31 17:57     ` Florian Fainelli
  -1 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-31 17:57 UTC (permalink / raw)
  To: Arun Parameswaran, David S. Miller, Andrew Lunn, Rob Herring,
	Mark Rutland, Ray Jui, Scott Branden, Catalin Marinas,
	Will Deacon
  Cc: netdev, devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add support to configure the internal rate adjust register based on the
> core clock supplied through device tree in the Broadcom iProc mdio mux.
> 
> The operating frequency of the mdio mux block is 11MHz. This is derrived
> by dividing the clock to the mdio mux with the rate adjust register.
> 
> In some SoC's the default values of the rate adjust register do not yield
> 11MHz. These SoC's are required to specify the clock via the device tree
> for proper operation.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---

[snip]

>  static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  		return PTR_ERR(md->base);
>  	}
>  
> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(md->core_clk)) {
> +		md->core_clk = NULL;

You need to specifically check for -EPROBE_DEFER here and propagate that
to the caller, other errors could be ignored like you do it here, same
comment as in patch 7, if you make md->core_clk NULL, then you can drop
testing for that pointer being valid.
-- 
Florian

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

* [PATCH v2 6/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
@ 2018-07-31 17:57     ` Florian Fainelli
  0 siblings, 0 replies; 63+ messages in thread
From: Florian Fainelli @ 2018-07-31 17:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/27/2018 02:23 PM, Arun Parameswaran wrote:
> Add support to configure the internal rate adjust register based on the
> core clock supplied through device tree in the Broadcom iProc mdio mux.
> 
> The operating frequency of the mdio mux block is 11MHz. This is derrived
> by dividing the clock to the mdio mux with the rate adjust register.
> 
> In some SoC's the default values of the rate adjust register do not yield
> 11MHz. These SoC's are required to specify the clock via the device tree
> for proper operation.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---

[snip]

>  static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
> @@ -198,10 +219,22 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
>  		return PTR_ERR(md->base);
>  	}
>  
> +	md->core_clk = devm_clk_get(&pdev->dev, NULL);
> +	if (IS_ERR(md->core_clk)) {
> +		md->core_clk = NULL;

You need to specifically check for -EPROBE_DEFER here and propagate that
to the caller, other errors could be ignored like you do it here, same
comment as in patch 7, if you make md->core_clk NULL, then you can drop
testing for that pointer being valid.
-- 
Florian

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

* Re: [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-31 20:47     ` Rob Herring
  -1 siblings, 0 replies; 63+ messages in thread
From: Rob Herring @ 2018-07-31 20:47 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Andrew Lunn, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:27PM -0700, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

The example is just an example, but okay...

Reviewed-by: Rob Herring <robh@kernel.org>

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

* [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address
@ 2018-07-31 20:47     ` Rob Herring
  0 siblings, 0 replies; 63+ messages in thread
From: Rob Herring @ 2018-07-31 20:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:27PM -0700, Arun Parameswaran wrote:
> Modify the base address of the Broadcom iProc MDIO mux driver to
> point to the start of the block's register address space.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

The example is just an example, but okay...

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
  2018-07-27 21:23   ` Arun Parameswaran
@ 2018-07-31 20:48     ` Rob Herring
  -1 siblings, 0 replies; 63+ messages in thread
From: Rob Herring @ 2018-07-31 20:48 UTC (permalink / raw)
  To: Arun Parameswaran
  Cc: David S. Miller, Florian Fainelli, Andrew Lunn, Mark Rutland,
	Ray Jui, Scott Branden, Catalin Marinas, Will Deacon, netdev,
	devicetree, linux-arm-kernel, linux-kernel,
	bcm-kernel-feedback-list

On Fri, Jul 27, 2018 at 02:23:31PM -0700, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

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

* [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux
@ 2018-07-31 20:48     ` Rob Herring
  0 siblings, 0 replies; 63+ messages in thread
From: Rob Herring @ 2018-07-31 20:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jul 27, 2018 at 02:23:31PM -0700, Arun Parameswaran wrote:
> Add clock phandle, of the core clock driving the mdio block, as an
> optional property to the Broadcom iProc mdio mux.
> 
> The clock, when specified, will be used to setup the rate adjust registers
> in the mdio to derrive the mdio's operating frequency.
> 
> Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
> ---
>  Documentation/devicetree/bindings/net/brcm,mdio-mux-iproc.txt | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2018-07-31 20:48 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 21:23 [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux Arun Parameswaran
2018-07-27 21:23 ` Arun Parameswaran
2018-07-27 21:23 ` [PATCH v2 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:09   ` Andrew Lunn
2018-07-28 21:09     ` Andrew Lunn
2018-07-30 22:48   ` Florian Fainelli
2018-07-30 22:48     ` Florian Fainelli
2018-07-31 20:47   ` Rob Herring
2018-07-31 20:47     ` Rob Herring
2018-07-27 21:23 ` [PATCH v2 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:10   ` Andrew Lunn
2018-07-28 21:10     ` Andrew Lunn
2018-07-30 22:50   ` Florian Fainelli
2018-07-30 22:50     ` Florian Fainelli
2018-07-27 21:23 ` [PATCH v2 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:11   ` Andrew Lunn
2018-07-28 21:11     ` Andrew Lunn
2018-07-30 22:50   ` Florian Fainelli
2018-07-30 22:50     ` Florian Fainelli
2018-07-27 21:23 ` [PATCH v2 4/7] net: phy: Disable external master access in bcm mdio mux driver Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:13   ` Andrew Lunn
2018-07-28 21:13     ` Andrew Lunn
2018-07-30 22:51   ` Florian Fainelli
2018-07-30 22:51     ` Florian Fainelli
2018-07-27 21:23 ` [PATCH v2 5/7] dt-bindings: net: Add clock handle to Broadcom iProc mdio mux Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:15   ` Andrew Lunn
2018-07-28 21:15     ` Andrew Lunn
2018-07-30 22:51   ` Florian Fainelli
2018-07-30 22:51     ` Florian Fainelli
2018-07-31 20:48   ` Rob Herring
2018-07-31 20:48     ` Rob Herring
2018-07-27 21:23 ` [PATCH v2 6/7] net: phy: Add support to configure clock in " Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28  0:03   ` Andrew Lunn
2018-07-28  0:03     ` Andrew Lunn
2018-07-30 16:47     ` Arun Parameswaran
2018-07-30 16:47       ` Arun Parameswaran
2018-07-28 21:22   ` Andrew Lunn
2018-07-28 21:22     ` Andrew Lunn
2018-07-30 16:49     ` Arun Parameswaran
2018-07-30 16:49       ` Arun Parameswaran
2018-07-30 18:04       ` Andrew Lunn
2018-07-30 18:04         ` Andrew Lunn
2018-07-31 17:57   ` Florian Fainelli
2018-07-31 17:57     ` Florian Fainelli
2018-07-27 21:23 ` [PATCH v2 7/7] net: phy: Add pm support to Broadcom iProc mdio mux driver Arun Parameswaran
2018-07-27 21:23   ` Arun Parameswaran
2018-07-28 21:27   ` Andrew Lunn
2018-07-28 21:27     ` Andrew Lunn
2018-07-28 21:27     ` Andrew Lunn
2018-07-30 22:53   ` Florian Fainelli
2018-07-30 22:53     ` Florian Fainelli
2018-07-31 17:51     ` Arun Parameswaran
2018-07-31 17:51       ` Arun Parameswaran
2018-07-28 21:32 ` [PATCH v2 0/7] Add clock config and pm support to bcm iProc mdio mux Andrew Lunn
2018-07-28 21:32   ` Andrew Lunn
2018-07-30 16:57   ` Arun Parameswaran
2018-07-30 16:57     ` Arun Parameswaran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.