devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add OF bindings to Micrel PHY
@ 2013-08-01  4:16 Sean Cross
  2013-08-01  4:16 ` [PATCH] net/phy: micrel: Add OF configuration support Sean Cross
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Cross @ 2013-08-01  4:16 UTC (permalink / raw)
  To: netdev, devicetree; +Cc: Sean Cross

Some boards require custom parameters be passed to the Micrel PHY.
Allow these boards to specify custom timing parameters in the device
tree node.

Sean Cross (1):
  net/phy: micrel: Add OF configuration support

 .../devicetree/bindings/net/micrel-phy.txt         |   20 +++++++
 drivers/net/phy/micrel.c                           |   57 ++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/micrel-phy.txt

-- 
1.7.9.5


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

* [PATCH] net/phy: micrel: Add OF configuration support
  2013-08-01  4:16 [PATCH] Add OF bindings to Micrel PHY Sean Cross
@ 2013-08-01  4:16 ` Sean Cross
  2013-08-01  5:31   ` Duan Fugang-B38611
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Cross @ 2013-08-01  4:16 UTC (permalink / raw)
  To: netdev, devicetree; +Cc: Sean Cross

Some boards require custom PHY configuration, for example due to trace
length differences.  Add the ability to configure these registers in
order to get the PHY to function on boards that need it.

Because PHYs are auto-detected based on MDIO device IDs, allow PHY
configuration to be specified in the parent Ethernet device node if no
PHY device node is present.

Signed-off-by: Sean Cross <xobs@kosagi.com>
---
 .../devicetree/bindings/net/micrel-phy.txt         |   20 +++++++
 drivers/net/phy/micrel.c                           |   57 ++++++++++++++++++++
 2 files changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/micrel-phy.txt

diff --git a/Documentation/devicetree/bindings/net/micrel-phy.txt b/Documentation/devicetree/bindings/net/micrel-phy.txt
new file mode 100644
index 0000000..97c1ef2
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/micrel-phy.txt
@@ -0,0 +1,20 @@
+Micrel KS8737, KSZ8041, KSZ8001, KS8721, KSZ8081, KSZ8091, KSZ8061, KSZ9021,
+KSZ9031, Ethernet PHYs, and KSZ8873MLL and KSZ886X Ethernet switches.
+
+Some boards require special tuning values, particularly when it comes to
+clock delays.  You can specify clock delay values by adding
+micrel-specific properties to an Ethernet OF device node.
+
+Optional properties:
+- micrel,clk-control-pad-skew : Timing offset for the MII clock line
+- micrel,rx-data-pad-skew : Timing offset for the RX MII pad
+- micrel,tx-data-pad-skew : Timing offset for the TX MII pad
+
+Example:
+	&enet {
+		micrel,clk-control-pad-skew = <0xf0f0>;
+		micrel,rx-data-pad-skew = <0x0000>;
+		micrel,tx-data-pad-skew = <0xffff>;
+		status = "okay";
+	};
+
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2510435..0abe821 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -25,6 +25,7 @@
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/micrel_phy.h>
+#include <linux/of.h>
 
 /* Operation Mode Strap Override */
 #define MII_KSZPHY_OMSO				0x16
@@ -53,6 +54,25 @@
 #define KS8737_CTRL_INT_ACTIVE_HIGH		(1 << 14)
 #define KSZ8051_RMII_50MHZ_CLK			(1 << 7)
 
+/* Write/read to/from extended registers */
+#define MII_KSZPHY_EXTREG                       0x0b
+#define KSZPHY_EXTREG_WRITE                     0x8000
+
+#define MII_KSZPHY_EXTREG_WRITE                 0x0c
+#define MII_KSZPHY_EXTREG_READ                  0x0d
+
+/* Write/read to/from extended registers */
+#define MII_KSZPHY_EXTREG                       0x0b
+#define KSZPHY_EXTREG_WRITE                     0x8000
+
+#define MII_KSZPHY_EXTREG_WRITE                 0x0c
+#define MII_KSZPHY_EXTREG_READ                  0x0d
+
+/* Extended registers */
+#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW         0x104
+#define MII_KSZPHY_RX_DATA_PAD_SKEW             0x105
+#define MII_KSZPHY_TX_DATA_PAD_SKEW             0x106
+
 static int ksz_config_flags(struct phy_device *phydev)
 {
 	int regval;
@@ -65,6 +85,13 @@ static int ksz_config_flags(struct phy_device *phydev)
 	return 0;
 }
 
+static int kszphy_extended_write(struct phy_device *phydev,
+                                 u32 regnum, u16 val)
+{
+	phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
+	return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
+}
+
 static int kszphy_ack_interrupt(struct phy_device *phydev)
 {
 	/* bit[7..0] int status, which is a read and clear register. */
@@ -121,6 +148,36 @@ static int ks8737_config_intr(struct phy_device *phydev)
 
 static int kszphy_config_init(struct phy_device *phydev)
 {
+	struct device *dev = &phydev->dev;
+	struct device_node *of_node = dev->of_node;
+
+	if (!of_node && dev->parent->of_node)
+		of_node = dev->parent->of_node;
+
+	if (of_node) {
+		u32 val;
+
+		if (!of_property_read_u32(of_node,
+					  "micrel,clk-control-pad-skew",
+					  &val))
+			kszphy_extended_write(phydev,
+					      MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
+					      val);
+
+		if (!of_property_read_u32(of_node,
+					  "micrel,rx-data-pad-skew",
+					  &val))
+			kszphy_extended_write(phydev,
+					      MII_KSZPHY_RX_DATA_PAD_SKEW,
+					      val);
+
+		if (!of_property_read_u32(of_node,
+					  "micrel,tx-data-pad-skew",
+					  &val))
+			kszphy_extended_write(phydev,
+					      MII_KSZPHY_TX_DATA_PAD_SKEW,
+					      val);
+	}
 	return 0;
 }
 
-- 
1.7.9.5


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

* RE: [PATCH] net/phy: micrel: Add OF configuration support
  2013-08-01  4:16 ` [PATCH] net/phy: micrel: Add OF configuration support Sean Cross
@ 2013-08-01  5:31   ` Duan Fugang-B38611
  2013-08-01  6:23     ` Sean Cross
  0 siblings, 1 reply; 5+ messages in thread
From: Duan Fugang-B38611 @ 2013-08-01  5:31 UTC (permalink / raw)
  To: Sean Cross, netdev@vger.kernel.org, devicetree@vger.kernel.org
  Cc: David Miller, stephen@networkplumber.org, Steven Rostedt

On Thu, Aug 01, 2013 at 12:17 PM, Sean Cross wrote:

> +/* Write/read to/from extended registers */
> +#define MII_KSZPHY_EXTREG                       0x0b
> +#define KSZPHY_EXTREG_WRITE                     0x8000
> +
> +#define MII_KSZPHY_EXTREG_WRITE                 0x0c
> +#define MII_KSZPHY_EXTREG_READ                  0x0d
> +
> +/* Write/read to/from extended registers */
> +#define MII_KSZPHY_EXTREG                       0x0b
> +#define KSZPHY_EXTREG_WRITE                     0x8000
> +
> +#define MII_KSZPHY_EXTREG_WRITE                 0x0c
> +#define MII_KSZPHY_EXTREG_READ                  0x0d
> +

Pls don't re-define the registers address and field.

> +		if (!of_property_read_u32(of_node,
> +					  "micrel,clk-control-pad-skew",
> +					  &val))
> +			kszphy_extended_write(phydev,
> +					      MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
> +					      val);

When re-set rx/tx clock delay, rx/tx control delay, it is better to do dummy read the extended MII_KSZPHY_CLK_CONTROL_PAD_SKEW register one time.

Thanks,
Andy



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

* Re: [PATCH] net/phy: micrel: Add OF configuration support
  2013-08-01  5:31   ` Duan Fugang-B38611
@ 2013-08-01  6:23     ` Sean Cross
  2013-08-01  6:52       ` Duan Fugang-B38611
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Cross @ 2013-08-01  6:23 UTC (permalink / raw)
  To: Duan Fugang-B38611
  Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, David Miller,
	stephen@networkplumber.org, Steven Rostedt

On Thursday, August 1, 2013 at 1:31 PM, Duan Fugang-B38611 wrote:
> On Thu, Aug 01, 2013 at 12:17 PM, Sean Cross wrote:
> 
> > +/* Write/read to/from extended registers */
> > +#define MII_KSZPHY_EXTREG 0x0b
> > +#define KSZPHY_EXTREG_WRITE 0x8000
> > +
> > +#define MII_KSZPHY_EXTREG_WRITE 0x0c
> > +#define MII_KSZPHY_EXTREG_READ 0x0d
> > +
> > +/* Write/read to/from extended registers */
> > +#define MII_KSZPHY_EXTREG 0x0b
> > +#define KSZPHY_EXTREG_WRITE 0x8000
> > +
> > +#define MII_KSZPHY_EXTREG_WRITE 0x0c
> > +#define MII_KSZPHY_EXTREG_READ 0x0d
> > +
> 
> 
> 
> Pls don't re-define the registers address and field.
My fault.  I'll remove this redundancy. 
> > + if (!of_property_read_u32(of_node,
> > + "micrel,clk-control-pad-skew",
> > + &val))
> > + kszphy_extended_write(phydev,
> > + MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
> > + val);
> 
> 
> 
> When re-set rx/tx clock delay, rx/tx control delay, it is better to do dummy read the extended MII_KSZPHY_CLK_CONTROL_PAD_SKEW register one time.
Can you please explain this?  I don't see anything in the datasheet I'm looking at (ksz9021rl) describing dummy reads.  If both tx and rx skew are adjusted, should there be two dummy reads or just one? 



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

* RE: [PATCH] net/phy: micrel: Add OF configuration support
  2013-08-01  6:23     ` Sean Cross
@ 2013-08-01  6:52       ` Duan Fugang-B38611
  0 siblings, 0 replies; 5+ messages in thread
From: Duan Fugang-B38611 @ 2013-08-01  6:52 UTC (permalink / raw)
  To: Sean Cross
  Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, David Miller,
	stephen@networkplumber.org, Steven Rostedt

On Thursday, August 1, 2013 at 2:23 PM, Sean Cross wrote:
>> When re-set rx/tx clock delay, rx/tx control delay, it is better to do dummy read the extended MII_KSZPHY_CLK_CONTROL_PAD_SKEW register one time.
> Can you please explain this?  I don't see anything in the datasheet I'm looking at (ksz9021rl) describing dummy reads.
> If both tx and rx skew are adjusted, should there be >two dummy reads or just one? 

When freescale engineers do the phy bring up, they add the dummy read. Pls refer the the patchwork: http://patchwork.ozlabs.org/patch/246616/
From ksz9021r1, there have no such condition. After I remove the dummy read, the imx6q sabrelite platform ethernet Gbps mode work fine.
For at91 micrel phy fixup, there have no dummy read: http://lists.infradead.org/pipermail/linux-arm-kernel/2013-July/183626.html
So, it just one confuse, and the dummy read is unnecessary.



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

end of thread, other threads:[~2013-08-01  7:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01  4:16 [PATCH] Add OF bindings to Micrel PHY Sean Cross
2013-08-01  4:16 ` [PATCH] net/phy: micrel: Add OF configuration support Sean Cross
2013-08-01  5:31   ` Duan Fugang-B38611
2013-08-01  6:23     ` Sean Cross
2013-08-01  6:52       ` Duan Fugang-B38611

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).