Skip to contentSkip to conversation

net: phy: Add DP83825I to the DP83822 driver

PATCH Superseded Dan Murphy 2 participants 3 messages Mar 19, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dan Murphy

author
#0 lore raw

PATCH 1/1 net: phy: Add DP83825I to the DP83822 driver

Add the DP83825I ethernet PHY to the DP83822 driver. These devices share the same WoL register bits and addresses.

The phy_driver init was made into a macro as there may be future devices appended to this driver that will share the register space.

http://www.ti.com/lit/gpn/dp83825i

---
 drivers/net/phy/dp83822.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/phy/dp83822.c +22 -14
index bbd8c22067f3..02dc05b86326 100644
@@ -15,6 +15,8 @@
 #include <linux/netdevice.h>
 
 #define DP83822_PHY_ID	        0x2000a240
+#define DP83825I_PHY_ID		0x2000a150
+
 #define DP83822_DEVADDR		0x1f
 
 #define MII_DP83822_PHYSCR	0x11
@@ -304,26 +306,32 @@ static int dp83822_resume(struct phy_device *phydev)
 	return 0;
 }
 
+#define DP83822_PHY_DRIVER(_id, _name)				\
+	{							\
+		.phy_id		= _id,				\
+		.phy_id_mask	= 0xfffffff0,			\
+		.name		= _name,			\
+		.features	= PHY_BASIC_FEATURES,		\
+								\
+		.soft_reset	= dp83822_phy_reset,		\
+		.config_init	= dp83822_config_init,		\
+		.get_wol = dp83822_get_wol,			\
+		.set_wol = dp83822_set_wol,			\
+		.ack_interrupt = dp83822_ack_interrupt,		\
+		.config_intr = dp83822_config_intr,		\
+		.suspend = dp83822_suspend,			\
+		.resume = dp83822_resume,			\
+	}
+
 static struct phy_driver dp83822_driver[] = {
-	{
-		.phy_id = DP83822_PHY_ID,
-		.phy_id_mask = 0xfffffff0,
-		.name = "TI DP83822",
-		.features = PHY_BASIC_FEATURES,
-		.config_init = dp83822_config_init,
-		.soft_reset = dp83822_phy_reset,
-		.get_wol = dp83822_get_wol,
-		.set_wol = dp83822_set_wol,
-		.ack_interrupt = dp83822_ack_interrupt,
-		.config_intr = dp83822_config_intr,
-		.suspend = dp83822_suspend,
-		.resume = dp83822_resume,
-	 },
+	DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"),
+	DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"),
 };
 module_phy_driver(dp83822_driver);
 
 static struct mdio_device_id __maybe_unused dp83822_tbl[] = {
 	{ DP83822_PHY_ID, 0xfffffff0 },
+	{ DP83825I_PHY_ID, 0xfffffff0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(mdio, dp83822_tbl);
Signature · 1 line
2.20.1.390.gb5101f9297
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dan Murphy

Add the DP83825I ethernet PHY to the DP83822 driver. These devices share the same WoL register bits and addresses.

The phy_driver init was made into a macro as there may be future devices appended to this driver that will share the register space.

http://www.ti.com/lit/gpn/dp83825i

Looks good, just a few nitpits below:

Quoted 18 lines
---
 drivers/net/phy/dp83822.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/phy/dp83822.c +2 -0
index bbd8c22067f3..02dc05b86326 100644
@@ -15,6 +15,8 @@
 #include <linux/netdevice.h>
 
 #define DP83822_PHY_ID	        0x2000a240
+#define DP83825I_PHY_ID		0x2000a150
+
 #define DP83822_DEVADDR		0x1f
 
 #define MII_DP83822_PHYSCR	0x11

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 311

Quoted 6 lines
drivers/net/phy/dp83822.c +3 -0
@@ -304,26 +306,32 @@ static int dp83822_resume(struct phy_device *phydev)
 	return 0;
 }
 
+#define DP83822_PHY_DRIVER(_id, _name)				\
+	{							\
+		.phy_id		= _id,				\

I would put the _id argument between parenthesis to guarantee evaluation order in case you need to do smart things about the ID in the future.

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 312

Quoted 1 line
drivers/net/phy/dp83822.c +1 -0
+		.phy_id_mask	= 0xfffffff0,			\

You can replace those two lines with PHY_ID_MATCH_MODEL()

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 313

Quoted 1 line
drivers/net/phy/dp83822.c +1 -0
+		.name		= _name,			\

Likewise

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 315

Quoted 2 lines
drivers/net/phy/dp83822.c +2 -0
+		.features	= PHY_BASIC_FEATURES,		\
+								\

Looks like you have an extra newline here.

With that fixed:

Quoted 37 lines
drivers/net/phy/dp83822.c +13 -14
+		.soft_reset	= dp83822_phy_reset,		\
+		.config_init	= dp83822_config_init,		\
+		.get_wol = dp83822_get_wol,			\
+		.set_wol = dp83822_set_wol,			\
+		.ack_interrupt = dp83822_ack_interrupt,		\
+		.config_intr = dp83822_config_intr,		\
+		.suspend = dp83822_suspend,			\
+		.resume = dp83822_resume,			\
+	}
+
 static struct phy_driver dp83822_driver[] = {
-	{
-		.phy_id = DP83822_PHY_ID,
-		.phy_id_mask = 0xfffffff0,
-		.name = "TI DP83822",
-		.features = PHY_BASIC_FEATURES,
-		.config_init = dp83822_config_init,
-		.soft_reset = dp83822_phy_reset,
-		.get_wol = dp83822_get_wol,
-		.set_wol = dp83822_set_wol,
-		.ack_interrupt = dp83822_ack_interrupt,
-		.config_intr = dp83822_config_intr,
-		.suspend = dp83822_suspend,
-		.resume = dp83822_resume,
-	 },
+	DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"),
+	DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"),
 };
 module_phy_driver(dp83822_driver);
 
 static struct mdio_device_id __maybe_unused dp83822_tbl[] = {
 	{ DP83822_PHY_ID, 0xfffffff0 },
+	{ DP83825I_PHY_ID, 0xfffffff0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(mdio, dp83822_tbl);
Signature · 1 line
Florian
author
#2 lore raw

Florian

Thanks for the quick review

Quoted 41 lines · Florian Fainelli
Quoted 9 lines · Dan Murphy

Add the DP83825I ethernet PHY to the DP83822 driver. These devices share the same WoL register bits and addresses.

The phy_driver init was made into a macro as there may be future devices appended to this driver that will share the register space.

http://www.ti.com/lit/gpn/dp83825i

Looks good, just a few nitpits below:

Quoted 18 lines
---
 drivers/net/phy/dp83822.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/phy/dp83822.c +2 -0
index bbd8c22067f3..02dc05b86326 100644
@@ -15,6 +15,8 @@
 #include <linux/netdevice.h>
 
 #define DP83822_PHY_ID	        0x2000a240
+#define DP83825I_PHY_ID		0x2000a150
+
 #define DP83822_DEVADDR		0x1f
 
 #define MII_DP83822_PHYSCR	0x11

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 311

Quoted 6 lines
drivers/net/phy/dp83822.c +3 -0
@@ -304,26 +306,32 @@ static int dp83822_resume(struct phy_device *phydev)
 	return 0;
 }
 
+#define DP83822_PHY_DRIVER(_id, _name)				\
+	{							\
+		.phy_id		= _id,				\

I would put the _id argument between parenthesis to guarantee evaluation order in case you need to do smart things about the ID in the future.

Quoted 4 lines

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 312

Quoted 1 line
drivers/net/phy/dp83822.c +1 -0
+		.phy_id_mask	= 0xfffffff0,			\

You can replace those two lines with PHY_ID_MATCH_MODEL()

Ack to both above. I will replace this with the macro. I assume I don't have to wrap _id in additional parenthesis when using the macro.

Quoted 4 lines

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 313

Quoted 1 line
drivers/net/phy/dp83822.c +1 -0
+		.name		= _name,			\

Likewise

Ack to adding parenthesis around the _name

Quoted 5 lines

drivers/net/phy/dp83822.c static int dp83822_resume(struct phy_device *phydev) · line 315

Quoted 2 lines
drivers/net/phy/dp83822.c +2 -0
+		.features	= PHY_BASIC_FEATURES,		\
+								\

Looks like you have an extra newline here.

Ack

Quoted 43 lines

With that fixed:

Quoted 37 lines
drivers/net/phy/dp83822.c +13 -14
+		.soft_reset	= dp83822_phy_reset,		\
+		.config_init	= dp83822_config_init,		\
+		.get_wol = dp83822_get_wol,			\
+		.set_wol = dp83822_set_wol,			\
+		.ack_interrupt = dp83822_ack_interrupt,		\
+		.config_intr = dp83822_config_intr,		\
+		.suspend = dp83822_suspend,			\
+		.resume = dp83822_resume,			\
+	}
+
 static struct phy_driver dp83822_driver[] = {
-	{
-		.phy_id = DP83822_PHY_ID,
-		.phy_id_mask = 0xfffffff0,
-		.name = "TI DP83822",
-		.features = PHY_BASIC_FEATURES,
-		.config_init = dp83822_config_init,
-		.soft_reset = dp83822_phy_reset,
-		.get_wol = dp83822_get_wol,
-		.set_wol = dp83822_set_wol,
-		.ack_interrupt = dp83822_ack_interrupt,
-		.config_intr = dp83822_config_intr,
-		.suspend = dp83822_suspend,
-		.resume = dp83822_resume,
-	 },
+	DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"),
+	DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"),
 };
 module_phy_driver(dp83822_driver);
 
 static struct mdio_device_id __maybe_unused dp83822_tbl[] = {
 	{ DP83822_PHY_ID, 0xfffffff0 },
+	{ DP83825I_PHY_ID, 0xfffffff0 },
 	{ },
 };
 MODULE_DEVICE_TABLE(mdio, dp83822_tbl);
Signature · 2 lines
------------------
Dan Murphy