netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy
@ 2016-01-15  0:55 Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 2/4] net: phy: at803x: Allow specifying the RGMII RX clock delay via phy mode Martin Blumenstingl
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2016-01-15  0:55 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, daniel, festevam, mans, Martin Blumenstingl

The 8030 is only a "RMII Fast Ethernet PHY", thus it must not have the
SUPPORTED_1000* bits set.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
v2: refreshed patch

 drivers/net/phy/at803x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 8a8f6fb..3589447 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -322,7 +322,7 @@ static struct phy_driver at803x_driver[] = {
 	.get_wol		= at803x_get_wol,
 	.suspend		= at803x_suspend,
 	.resume			= at803x_resume,
-	.features		= PHY_GBIT_FEATURES,
+	.features		= PHY_BASIC_FEATURES,
 	.flags			= PHY_HAS_INTERRUPT,
 	.config_aneg		= genphy_config_aneg,
 	.read_status		= genphy_read_status,
-- 
2.7.0

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

* [PATCHv2 2/4] net: phy: at803x: Allow specifying the RGMII RX clock delay via phy mode
  2016-01-15  0:55 [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy Martin Blumenstingl
@ 2016-01-15  0:55 ` Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 3/4] net: phy: at803x: Clean up duplicate register definitions Martin Blumenstingl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2016-01-15  0:55 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, daniel, festevam, mans, Martin Blumenstingl

at803x currently automatically enables the RGMII TX clock delay when the
phy interface mode is PHY_INTERFACE_MODE_RGMII_TXID. The same should be
done when PHY_INTERFACE_MODE_RGMII_ID is specified.
Use a similar logic to enable the RGMII RX clock delay as well.
at803x_context_{save,restore} were not touched because these are only
used on AR8030 which is a RMII phy (RGMII clock delays are irrelevant).

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
v2: renamed at803x_set_{rx,tx}_delay to at803x_enable_{rx,tx}_delay and
    drop the "bool enable".

 drivers/net/phy/at803x.c | 63 +++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 3589447..333c1bc 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -36,8 +36,10 @@
 #define AT803X_INSR				0x0013
 #define AT803X_DEBUG_ADDR			0x1D
 #define AT803X_DEBUG_DATA			0x1E
-#define AT803X_DEBUG_SYSTEM_MODE_CTRL		0x05
-#define AT803X_DEBUG_RGMII_TX_CLK_DLY		BIT(8)
+#define AT803X_DEBUG_REG_0			0x00
+#define AT803X_DEBUG_RX_CLK_DLY_EN		BIT(15)
+#define AT803X_DEBUG_REG_5			0x05
+#define AT803X_DEBUG_TX_CLK_DLY_EN		BIT(8)
 
 #define ATH8030_PHY_ID 0x004dd076
 #define ATH8031_PHY_ID 0x004dd074
@@ -61,6 +63,46 @@ struct at803x_context {
 	u16 led_control;
 };
 
+static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg)
+{
+	int ret;
+
+	ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg);
+	if (ret < 0)
+		return ret;
+
+	return phy_read(phydev, AT803X_DEBUG_DATA);
+}
+
+static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
+				 u16 clear, u16 set)
+{
+	u16 val;
+	int ret;
+
+	ret = at803x_debug_reg_read(phydev, reg);
+	if (ret < 0)
+		return ret;
+
+	val = ret & 0xffff;
+	val &= ~clear;
+	val |= set;
+
+	return phy_write(phydev, AT803X_DEBUG_DATA, val);
+}
+
+static inline int at803x_enable_rx_delay(struct phy_device *phydev)
+{
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0,
+					AT803X_DEBUG_RX_CLK_DLY_EN);
+}
+
+static inline int at803x_enable_tx_delay(struct phy_device *phydev)
+{
+	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0,
+					AT803X_DEBUG_TX_CLK_DLY_EN);
+}
+
 /* save relevant PHY registers to private copy */
 static void at803x_context_save(struct phy_device *phydev,
 				struct at803x_context *context)
@@ -217,14 +259,17 @@ static int at803x_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
-	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
-		ret = phy_write(phydev, AT803X_DEBUG_ADDR,
-				AT803X_DEBUG_SYSTEM_MODE_CTRL);
-		if (ret)
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+		ret = at803x_enable_rx_delay(phydev);
+		if (ret < 0)
 			return ret;
-		ret = phy_write(phydev, AT803X_DEBUG_DATA,
-				AT803X_DEBUG_RGMII_TX_CLK_DLY);
-		if (ret)
+	}
+
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
+			phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
+		ret = at803x_enable_tx_delay(phydev);
+		if (ret < 0)
 			return ret;
 	}
 
-- 
2.7.0

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

* [PATCHv2 3/4] net: phy: at803x: Clean up duplicate register definitions
  2016-01-15  0:55 [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 2/4] net: phy: at803x: Allow specifying the RGMII RX clock delay via phy mode Martin Blumenstingl
@ 2016-01-15  0:55 ` Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 4/4] net: phy: at803x: Add the interrupt register bit definitions Martin Blumenstingl
  2016-01-18  0:17 ` [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2016-01-15  0:55 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, daniel, festevam, mans, Martin Blumenstingl

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
v2: refreshed patch

 drivers/net/phy/at803x.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 333c1bc..f2c4e8d 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -20,9 +20,12 @@
 #include <linux/gpio/consumer.h>
 
 #define AT803X_INTR_ENABLE			0x12
+#define AT803X_INTR_ENABLE_INIT			0xec00
 #define AT803X_INTR_STATUS			0x13
+
 #define AT803X_SMART_SPEED			0x14
 #define AT803X_LED_CONTROL			0x18
+
 #define AT803X_WOL_ENABLE			0x01
 #define AT803X_DEVICE_ADDR			0x03
 #define AT803X_LOC_MAC_ADDR_0_15_OFFSET		0x804C
@@ -31,13 +34,13 @@
 #define AT803X_MMD_ACCESS_CONTROL		0x0D
 #define AT803X_MMD_ACCESS_CONTROL_DATA		0x0E
 #define AT803X_FUNC_DATA			0x4003
-#define AT803X_INER				0x0012
-#define AT803X_INER_INIT			0xec00
-#define AT803X_INSR				0x0013
+
 #define AT803X_DEBUG_ADDR			0x1D
 #define AT803X_DEBUG_DATA			0x1E
+
 #define AT803X_DEBUG_REG_0			0x00
 #define AT803X_DEBUG_RX_CLK_DLY_EN		BIT(15)
+
 #define AT803X_DEBUG_REG_5			0x05
 #define AT803X_DEBUG_TX_CLK_DLY_EN		BIT(8)
 
@@ -280,7 +283,7 @@ static int at803x_ack_interrupt(struct phy_device *phydev)
 {
 	int err;
 
-	err = phy_read(phydev, AT803X_INSR);
+	err = phy_read(phydev, AT803X_INTR_STATUS);
 
 	return (err < 0) ? err : 0;
 }
@@ -290,13 +293,13 @@ static int at803x_config_intr(struct phy_device *phydev)
 	int err;
 	int value;
 
-	value = phy_read(phydev, AT803X_INER);
+	value = phy_read(phydev, AT803X_INTR_ENABLE);
 
 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
-		err = phy_write(phydev, AT803X_INER,
-				value | AT803X_INER_INIT);
+		err = phy_write(phydev, AT803X_INTR_ENABLE,
+				value | AT803X_INTR_ENABLE_INIT);
 	else
-		err = phy_write(phydev, AT803X_INER, 0);
+		err = phy_write(phydev, AT803X_INTR_ENABLE, 0);
 
 	return err;
 }
-- 
2.7.0

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

* [PATCHv2 4/4] net: phy: at803x: Add the interrupt register bit definitions
  2016-01-15  0:55 [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 2/4] net: phy: at803x: Allow specifying the RGMII RX clock delay via phy mode Martin Blumenstingl
  2016-01-15  0:55 ` [PATCHv2 3/4] net: phy: at803x: Clean up duplicate register definitions Martin Blumenstingl
@ 2016-01-15  0:55 ` Martin Blumenstingl
  2016-01-18  0:17 ` [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2016-01-15  0:55 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, daniel, festevam, mans, Martin Blumenstingl

Also use them instead of a magic value when enabling the interrupts.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
v2: refreshed patch

 drivers/net/phy/at803x.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index f2c4e8d..2174ec9 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -20,13 +20,21 @@
 #include <linux/gpio/consumer.h>
 
 #define AT803X_INTR_ENABLE			0x12
-#define AT803X_INTR_ENABLE_INIT			0xec00
+#define AT803X_INTR_ENABLE_AUTONEG_ERR		BIT(15)
+#define AT803X_INTR_ENABLE_SPEED_CHANGED	BIT(14)
+#define AT803X_INTR_ENABLE_DUPLEX_CHANGED	BIT(13)
+#define AT803X_INTR_ENABLE_PAGE_RECEIVED	BIT(12)
+#define AT803X_INTR_ENABLE_LINK_FAIL		BIT(11)
+#define AT803X_INTR_ENABLE_LINK_SUCCESS		BIT(10)
+#define AT803X_INTR_ENABLE_WIRESPEED_DOWNGRADE	BIT(5)
+#define AT803X_INTR_ENABLE_POLARITY_CHANGED	BIT(1)
+#define AT803X_INTR_ENABLE_WOL			BIT(0)
+
 #define AT803X_INTR_STATUS			0x13
 
 #define AT803X_SMART_SPEED			0x14
 #define AT803X_LED_CONTROL			0x18
 
-#define AT803X_WOL_ENABLE			0x01
 #define AT803X_DEVICE_ADDR			0x03
 #define AT803X_LOC_MAC_ADDR_0_15_OFFSET		0x804C
 #define AT803X_LOC_MAC_ADDR_16_31_OFFSET	0x804B
@@ -164,14 +172,14 @@ static int at803x_set_wol(struct phy_device *phydev,
 		}
 
 		value = phy_read(phydev, AT803X_INTR_ENABLE);
-		value |= AT803X_WOL_ENABLE;
+		value |= AT803X_INTR_ENABLE_WOL;
 		ret = phy_write(phydev, AT803X_INTR_ENABLE, value);
 		if (ret)
 			return ret;
 		value = phy_read(phydev, AT803X_INTR_STATUS);
 	} else {
 		value = phy_read(phydev, AT803X_INTR_ENABLE);
-		value &= (~AT803X_WOL_ENABLE);
+		value &= (~AT803X_INTR_ENABLE_WOL);
 		ret = phy_write(phydev, AT803X_INTR_ENABLE, value);
 		if (ret)
 			return ret;
@@ -190,7 +198,7 @@ static void at803x_get_wol(struct phy_device *phydev,
 	wol->wolopts = 0;
 
 	value = phy_read(phydev, AT803X_INTR_ENABLE);
-	if (value & AT803X_WOL_ENABLE)
+	if (value & AT803X_INTR_ENABLE_WOL)
 		wol->wolopts |= WAKE_MAGIC;
 }
 
@@ -202,7 +210,7 @@ static int at803x_suspend(struct phy_device *phydev)
 	mutex_lock(&phydev->lock);
 
 	value = phy_read(phydev, AT803X_INTR_ENABLE);
-	wol_enabled = value & AT803X_WOL_ENABLE;
+	wol_enabled = value & AT803X_INTR_ENABLE_WOL;
 
 	value = phy_read(phydev, MII_BMCR);
 
@@ -295,9 +303,15 @@ static int at803x_config_intr(struct phy_device *phydev)
 
 	value = phy_read(phydev, AT803X_INTR_ENABLE);
 
-	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
-		err = phy_write(phydev, AT803X_INTR_ENABLE,
-				value | AT803X_INTR_ENABLE_INIT);
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
+		value |= AT803X_INTR_ENABLE_AUTONEG_ERR;
+		value |= AT803X_INTR_ENABLE_SPEED_CHANGED;
+		value |= AT803X_INTR_ENABLE_DUPLEX_CHANGED;
+		value |= AT803X_INTR_ENABLE_LINK_FAIL;
+		value |= AT803X_INTR_ENABLE_LINK_SUCCESS;
+
+		err = phy_write(phydev, AT803X_INTR_ENABLE, value);
+	}
 	else
 		err = phy_write(phydev, AT803X_INTR_ENABLE, 0);
 
-- 
2.7.0

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

* Re: [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy
  2016-01-15  0:55 [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy Martin Blumenstingl
                   ` (2 preceding siblings ...)
  2016-01-15  0:55 ` [PATCHv2 4/4] net: phy: at803x: Add the interrupt register bit definitions Martin Blumenstingl
@ 2016-01-18  0:17 ` David Miller
  2016-01-18  0:24   ` Martin Blumenstingl
  3 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2016-01-18  0:17 UTC (permalink / raw)
  To: martin.blumenstingl; +Cc: netdev, f.fainelli, daniel, festevam, mans

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Date: Fri, 15 Jan 2016 01:55:21 +0100

> The 8030 is only a "RMII Fast Ethernet PHY", thus it must not have the
> SUPPORTED_1000* bits set.
> 
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> v2: refreshed patch

Series applied, but this is not the proper way to send a patch series.

A patch series describes a logically related group of changes, therefore
you must submit first a "[PATCH 0/N] ..." posting that clearly and fully
describes what the patch series is doing at a high level, and why.

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

* Re: [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy
  2016-01-18  0:17 ` [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy David Miller
@ 2016-01-18  0:24   ` Martin Blumenstingl
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2016-01-18  0:24 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, f.fainelli, daniel, Fabio Estevam, mans

On Mon, Jan 18, 2016 at 1:17 AM, David Miller <davem@davemloft.net> wrote:
> Series applied, but this is not the proper way to send a patch series.
Thanks!

> A patch series describes a logically related group of changes, therefore
> you must submit first a "[PATCH 0/N] ..." posting that clearly and fully
> describes what the patch series is doing at a high level, and why.
Noted. I initially did this for v1 but forgot it for v2 - sorry.

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

end of thread, other threads:[~2016-01-18  0:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15  0:55 [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy Martin Blumenstingl
2016-01-15  0:55 ` [PATCHv2 2/4] net: phy: at803x: Allow specifying the RGMII RX clock delay via phy mode Martin Blumenstingl
2016-01-15  0:55 ` [PATCHv2 3/4] net: phy: at803x: Clean up duplicate register definitions Martin Blumenstingl
2016-01-15  0:55 ` [PATCHv2 4/4] net: phy: at803x: Add the interrupt register bit definitions Martin Blumenstingl
2016-01-18  0:17 ` [PATCHv2 1/4] net: phy: at803x: Don't set gbit features for the AR8030 phy David Miller
2016-01-18  0:24   ` Martin Blumenstingl

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