mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status()
@ 2016-02-02 11:17 Philipp Zabel
  2016-02-02 11:17 ` [PATCH 2/6] net: phy: micrel: use BIT macro Philipp Zabel
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox

Based on kernel commit 32d73b144eac ("net: phy: micrel: Staticise
ksz8873mll_read_status()") by Jingoo Han <jg1.han@samsung.com>:

    ksz8873mll_read_status() is used only in this file.
    Fix the following sparse warning:

    drivers/net/phy/micrel.c:147:5: warning: symbol 'ksz8873mll_read_status' was not declared. Should it be static?

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 095563a..2f31906 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -233,7 +233,7 @@ static int ksz9031_config_init(struct phy_device *phydev)
 #define KSZ8873MLL_GLOBAL_CONTROL_4	0x06
 #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX	(1 << 6)
 #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED	(1 << 4)
-int ksz8873mll_read_status(struct phy_device *phydev)
+static int ksz8873mll_read_status(struct phy_device *phydev)
 {
 	int regval;
 
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/6] net: phy: micrel: use BIT macro
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
@ 2016-02-02 11:17 ` Philipp Zabel
  2016-02-02 11:17 ` [PATCH 3/6] net: phy: micrel: Be more const correct Philipp Zabel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox

Based on kernel commit 00aee095000c ("net: phy: micrel: use BIT macro")
by Johan Hovold <johan@kernel.org>.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 2f31906..0c97e25 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -25,17 +25,17 @@
 
 /* Operation Mode Strap Override */
 #define MII_KSZPHY_OMSO				0x16
-#define KSZPHY_OMSO_B_CAST_OFF			(1 << 9)
-#define KSZPHY_OMSO_RMII_OVERRIDE		(1 << 1)
-#define KSZPHY_OMSO_MII_OVERRIDE		(1 << 0)
+#define KSZPHY_OMSO_B_CAST_OFF			BIT(9)
+#define KSZPHY_OMSO_RMII_OVERRIDE		BIT(1)
+#define KSZPHY_OMSO_MII_OVERRIDE		BIT(0)
 
 /* general PHY control reg in vendor specific block. */
 #define	MII_KSZPHY_CTRL			0x1F
 /* bitmap of PHY register to set interrupt mode */
-#define KSZPHY_CTRL_INT_ACTIVE_HIGH		(1 << 9)
-#define KSZ9021_CTRL_INT_ACTIVE_HIGH		(1 << 14)
-#define KS8737_CTRL_INT_ACTIVE_HIGH		(1 << 14)
-#define KSZ8051_RMII_50MHZ_CLK			(1 << 7)
+#define KSZPHY_CTRL_INT_ACTIVE_HIGH		BIT(9)
+#define KSZ9021_CTRL_INT_ACTIVE_HIGH		BIT(14)
+#define KS8737_CTRL_INT_ACTIVE_HIGH		BIT(14)
+#define KSZ8051_RMII_50MHZ_CLK			BIT(7)
 
 /* Write/read to/from extended registers */
 #define MII_KSZPHY_EXTREG                       0x0b
@@ -231,8 +231,8 @@ static int ksz9031_config_init(struct phy_device *phydev)
 }
 
 #define KSZ8873MLL_GLOBAL_CONTROL_4	0x06
-#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX	(1 << 6)
-#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED	(1 << 4)
+#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX	BIT(6)
+#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED	BIT(4)
 static int ksz8873mll_read_status(struct phy_device *phydev)
 {
 	int regval;
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/6] net: phy: micrel: Be more const correct
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
  2016-02-02 11:17 ` [PATCH 2/6] net: phy: micrel: use BIT macro Philipp Zabel
@ 2016-02-02 11:17 ` Philipp Zabel
  2016-02-02 11:17 ` [PATCH 4/6] net: phy: micrel: Center FLP timing at 16ms Philipp Zabel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox

Based on kernel commit 3c9a9f7fb0ee ("net/phy: micrel: Be more const
correct") by Jaeden Amero <jaeden.amero@ni.com>:

    In a few places in this driver, we weren't using const where we could
    have. Use const more.

    In addition, change the arrays of strings in ksz9031_config_init() to be
    not only const, but also static.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 0c97e25..6f49e73 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -91,8 +91,8 @@ static int ks8051_config_init(struct phy_device *phydev)
 }
 
 static int ksz9021_load_values_from_of(struct phy_device *phydev,
-				       struct device_node *of_node, u16 reg,
-				       const char *field[])
+				       const struct device_node *of_node,
+				       u16 reg, const char *field[])
 {
 	int val, regval, i;
 
@@ -113,8 +113,8 @@ static int ksz9021_load_values_from_of(struct phy_device *phydev,
 
 static int ksz9021_config_init(struct phy_device *phydev)
 {
-	struct device_d *dev = &phydev->dev;
-	struct device_node *of_node = dev->device_node;
+	const struct device_d *dev = &phydev->dev;
+	const struct device_node *of_node = dev->device_node;
 	const char *clk_pad_skew_names[] = {
 		"txen-skew-ps", "txc-skew-ps",
 		"rxdv-skew-ps", "rxc-skew-ps"
@@ -155,9 +155,9 @@ static int ksz9021_config_init(struct phy_device *phydev)
 #define MII_KSZ9031RN_CLK_PAD_SKEW	8
 
 static int ksz9031_of_load_skew_values(struct phy_device *phydev,
-					struct device_node *of_node,
+					const struct device_node *of_node,
 					u16 reg, size_t field_sz,
-					char *field[], u8 numfields)
+					const char *field[], u8 numfields)
 {
 	int val[4] = {-1, -2, -3, -4};
 	int matches = 0;
@@ -194,18 +194,18 @@ static int ksz9031_of_load_skew_values(struct phy_device *phydev,
 
 static int ksz9031_config_init(struct phy_device *phydev)
 {
-	struct device_d *dev = &phydev->dev;
-	struct device_node *of_node = dev->device_node;
-	char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"};
-	char *rx_data_skews[4] = {
+	const struct device_d *dev = &phydev->dev;
+	const struct device_node *of_node = dev->device_node;
+	static const char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"};
+	static const char *rx_data_skews[4] = {
 		"rxd0-skew-ps", "rxd1-skew-ps",
 		"rxd2-skew-ps", "rxd3-skew-ps"
 	};
-	char *tx_data_skews[4] = {
+	static const char *tx_data_skews[4] = {
 		"txd0-skew-ps", "txd1-skew-ps",
 		"txd2-skew-ps", "txd3-skew-ps"
 	};
-	char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
+	static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
 
 	if (!of_node && dev->parent->device_node)
 		of_node = dev->parent->device_node;
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/6] net: phy: micrel: Center FLP timing at 16ms
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
  2016-02-02 11:17 ` [PATCH 2/6] net: phy: micrel: use BIT macro Philipp Zabel
  2016-02-02 11:17 ` [PATCH 3/6] net: phy: micrel: Be more const correct Philipp Zabel
@ 2016-02-02 11:17 ` Philipp Zabel
  2016-02-02 11:17 ` [PATCH 5/6] net: phy: micrel: Add workaround for bad autoneg Philipp Zabel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox

Based on kernel commit 6270e1ae804a ("net/phy: micrel: Center FLP
timing at 16ms") by Jaeden Amero <jaeden.amero@ni.com>:

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 6f49e73..570272f 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -149,6 +149,11 @@ static int ksz9021_config_init(struct phy_device *phydev)
 #define KSZ9031_PS_TO_REG		60
 
 /* Extended registers */
+/* MMD Address 0x0 */
+#define MII_KSZ9031RN_FLP_BURST_TX_LO	3
+#define MII_KSZ9031RN_FLP_BURST_TX_HI	4
+
+/* MMD Address 0x2 */
 #define MII_KSZ9031RN_CONTROL_PAD_SKEW	4
 #define MII_KSZ9031RN_RX_DATA_PAD_SKEW	5
 #define MII_KSZ9031RN_TX_DATA_PAD_SKEW	6
@@ -192,6 +197,15 @@ static int ksz9031_of_load_skew_values(struct phy_device *phydev,
 	return 0;
 }
 
+static int ksz9031_center_flp_timing(struct phy_device *phydev)
+{
+	/* Center KSZ9031RNX FLP timing at 16ms. */
+	phy_write_mmd_indirect(phydev, MII_KSZ9031RN_FLP_BURST_TX_HI, 0, 0x0006);
+	phy_write_mmd_indirect(phydev, MII_KSZ9031RN_FLP_BURST_TX_LO, 0, 0x1a80);
+
+	return genphy_restart_aneg(phydev);
+}
+
 static int ksz9031_config_init(struct phy_device *phydev)
 {
 	const struct device_d *dev = &phydev->dev;
@@ -227,7 +241,8 @@ static int ksz9031_config_init(struct phy_device *phydev)
 				MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4,
 				tx_data_skews, 4);
 	}
-	return 0;
+
+	return ksz9031_center_flp_timing(phydev);
 }
 
 #define KSZ8873MLL_GLOBAL_CONTROL_4	0x06
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/6] net: phy: micrel: Add workaround for bad autoneg
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
                   ` (2 preceding siblings ...)
  2016-02-02 11:17 ` [PATCH 4/6] net: phy: micrel: Center FLP timing at 16ms Philipp Zabel
@ 2016-02-02 11:17 ` Philipp Zabel
  2016-02-02 11:17 ` [PATCH 6/6] net: phy: micrel: errata for KSZ9031 Philipp Zabel
  2016-02-03  7:39 ` [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Sascha Hauer
  5 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox

Based on kernel commit d2fd719bcb0e ("net/phy: micrel: Add workaround
for bad autoneg") by Nathan Sullivan <nathan.sullivan@ni.com>:

    Very rarely, the KSZ9031 will appear to complete autonegotiation, but
    will drop all traffic afterwards.  When this happens, the idle error
    count will read 0xFF after autonegotiation completes.  Reset the PHY
    when in that state.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 570272f..e8a566d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -273,6 +273,27 @@ static int ksz8873mll_read_status(struct phy_device *phydev)
 	return 0;
 }
 
+static int ksz9031_read_status(struct phy_device *phydev)
+{
+	int err;
+	int regval;
+
+	err = genphy_read_status(phydev);
+	if (err)
+		return err;
+
+	/* Make sure the PHY is not broken. Read idle error count,
+	 * and reset the PHY if it is maxed out.
+	 */
+	regval = phy_read(phydev, MII_STAT1000);
+	if ((regval & 0xff) == 0xff) {
+		phy_init_hw(phydev);
+		phydev->link = 0;
+	}
+
+	return 0;
+}
+
 static int ksz8873mll_config_aneg(struct phy_device *phydev)
 {
 	return 0;
@@ -368,7 +389,7 @@ static struct phy_driver ksphy_driver[] = {
 	.features	= (PHY_GBIT_FEATURES | SUPPORTED_Pause),
 	.config_init	= ksz9031_config_init,
 	.config_aneg	= genphy_config_aneg,
-	.read_status	= genphy_read_status,
+	.read_status	= ksz9031_read_status,
 }, {
 	.phy_id		= PHY_ID_KSZ8873MLL,
 	.phy_id_mask	= 0x00fffff0,
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 6/6] net: phy: micrel: errata for KSZ9031
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
                   ` (3 preceding siblings ...)
  2016-02-02 11:17 ` [PATCH 5/6] net: phy: micrel: Add workaround for bad autoneg Philipp Zabel
@ 2016-02-02 11:17 ` Philipp Zabel
  2016-02-02 14:42   ` Philipp Zabel
  2016-02-03  7:39 ` [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Sascha Hauer
  5 siblings, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 11:17 UTC (permalink / raw)
  To: barebox; +Cc: Markus Niebel

The KSZ9031 erratum #2 stats:
    The 125MHz reference clock (CLK125_NDO pin) output
    has duty cycle variation when the KSZ9031 links up in
    1000Base-T Slave mode, resulting in wide variation on
    the falling clock edge.

The recommended workaround is to either only use the rising edge of
the CLK125_NDO output for PLL locking, or to

    Set KSZ9031 to always link up in 1000Base-T Master mode
    by setting register 9h, bits [12:11] to '11'.

Since we can't guarantee the former, this patch does the latter.
Original patch by Markus Niebel <Markus.Niebel@tqs.de>.

Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/net/phy/micrel.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index e8a566d..5227dfb 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -220,6 +220,7 @@ static int ksz9031_config_init(struct phy_device *phydev)
 		"txd2-skew-ps", "txd3-skew-ps"
 	};
 	static const char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
+	int rc;
 
 	if (!of_node && dev->parent->device_node)
 		of_node = dev->parent->device_node;
@@ -242,6 +243,14 @@ static int ksz9031_config_init(struct phy_device *phydev)
 				tx_data_skews, 4);
 	}
 
+	rc = phy_read(phydev, MII_CTRL1000);
+	if (rc >= 0) {
+		u16 val = rc;
+		/* Enable master mode, config & prefer master */
+		val |= (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER);
+		phy_write(phydev, MII_CTRL1000, val);
+	}
+
 	return ksz9031_center_flp_timing(phydev);
 }
 
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 6/6] net: phy: micrel: errata for KSZ9031
  2016-02-02 11:17 ` [PATCH 6/6] net: phy: micrel: errata for KSZ9031 Philipp Zabel
@ 2016-02-02 14:42   ` Philipp Zabel
  0 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-02-02 14:42 UTC (permalink / raw)
  To: barebox; +Cc: Markus Niebel

Am Dienstag, den 02.02.2016, 12:17 +0100 schrieb Philipp Zabel:
> The KSZ9031 erratum #2 stats:
>     The 125MHz reference clock (CLK125_NDO pin) output
>     has duty cycle variation when the KSZ9031 links up in
>     1000Base-T Slave mode, resulting in wide variation on
>     the falling clock edge.
> 
> The recommended workaround is to either only use the rising edge of
> the CLK125_NDO output for PLL locking, or to
> 
>     Set KSZ9031 to always link up in 1000Base-T Master mode
>     by setting register 9h, bits [12:11] to '11'.
> 
> Since we can't guarantee the former, this patch does the latter.
> Original patch by Markus Niebel <Markus.Niebel@tqs.de>.
> 
> Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Please disregard this one. If in fact the PLL can lock only to the
rising CLK125_NDO edge, we shouldn't force master mode unconditionally.
This should probably only be enabled by a boolean device tree property.

regards
Philipp


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status()
  2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
                   ` (4 preceding siblings ...)
  2016-02-02 11:17 ` [PATCH 6/6] net: phy: micrel: errata for KSZ9031 Philipp Zabel
@ 2016-02-03  7:39 ` Sascha Hauer
  5 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-03  7:39 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: barebox

On Tue, Feb 02, 2016 at 12:17:30PM +0100, Philipp Zabel wrote:
> Based on kernel commit 32d73b144eac ("net: phy: micrel: Staticise
> ksz8873mll_read_status()") by Jingoo Han <jg1.han@samsung.com>:
> 
>     ksz8873mll_read_status() is used only in this file.
>     Fix the following sparse warning:
> 
>     drivers/net/phy/micrel.c:147:5: warning: symbol 'ksz8873mll_read_status' was not declared. Should it be static?
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  drivers/net/phy/micrel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied except 6/6, thanks.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-02-03  7:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 11:17 [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Philipp Zabel
2016-02-02 11:17 ` [PATCH 2/6] net: phy: micrel: use BIT macro Philipp Zabel
2016-02-02 11:17 ` [PATCH 3/6] net: phy: micrel: Be more const correct Philipp Zabel
2016-02-02 11:17 ` [PATCH 4/6] net: phy: micrel: Center FLP timing at 16ms Philipp Zabel
2016-02-02 11:17 ` [PATCH 5/6] net: phy: micrel: Add workaround for bad autoneg Philipp Zabel
2016-02-02 11:17 ` [PATCH 6/6] net: phy: micrel: errata for KSZ9031 Philipp Zabel
2016-02-02 14:42   ` Philipp Zabel
2016-02-03  7:39 ` [PATCH 1/6] net: phy: micrel: Staticise ksz8873mll_read_status() Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox