[PATCH 28/41] net: phy: ti: Convert to U_BOOT_PHY_DRIVER()

Marek Vasut marek.vasut+renesas at mailbox.org
Sun Mar 19 18:03:04 CET 2023


Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init call.

Converted using sed
"s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"

This particular PHY driver is slightly more spread out across additional
source files. Since the phy_register() calls are no longer necessary, all
the registration calls across those source files is dropped. Furthermore,
the Makefile can now be updated to only compile generic TI PHY support if
matching Kconfig symbol is enabled and the ifdeffery in the generic TI PHY
driver can be dropped.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: "Ariel D'Alessandro" <ariel.dalessandro at collabora.com>
Cc: "Cédric Le Goater" <clg at kaod.org>
Cc: "Marek Behún" <kabel at kernel.org>
Cc: Alex Nemirovsky <alex.nemirovsky at cortina-access.com>
Cc: Haolin Li <li.haolin at qq.com>
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Joel Stanley <joel at jms.id.au>
Cc: Josua Mayer <josua at solid-run.com>
Cc: Marek Vasut <marek.vasut+renesas at mailbox.org>
Cc: Michael Trimarchi <michael at amarulasolutions.com>
Cc: Michal Simek <michal.simek at amd.com>
Cc: Nate Drude <nate.d at variscite.com>
Cc: Neil Armstrong <neil.armstrong at linaro.org>
Cc: Radu Pirea <radu-nicolae.pirea at oss.nxp.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Samuel Mendoza-Jonas <sam at mendozajonas.com>
Cc: Stefan Roese <sr at denx.de>
Cc: T Karthik Reddy <t.karthik.reddy at xilinx.com>
Cc: Tim Harvey <tharvey at gateworks.com>
Cc: Vladimir Oltean <vladimir.oltean at nxp.com>
Cc: u-boot-amlogic at groups.io
---
 drivers/net/phy/Makefile      |  2 +-
 drivers/net/phy/dp83867.c     |  8 +-------
 drivers/net/phy/dp83869.c     |  8 +-------
 drivers/net/phy/phy.c         |  3 ---
 drivers/net/phy/ti_phy_init.c | 38 +++++++----------------------------
 include/phy.h                 |  1 -
 6 files changed, 10 insertions(+), 50 deletions(-)

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index d38e99e7171..963d96e2bcb 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -29,7 +29,7 @@ obj-$(CONFIG_PHY_NXP_TJA11XX) += nxp-tja11xx.o
 obj-$(CONFIG_PHY_REALTEK) += realtek.o
 obj-$(CONFIG_PHY_SMSC) += smsc.o
 obj-$(CONFIG_PHY_TERANETICS) += teranetics.o
-obj-$(CONFIG_PHY_TI) += ti_phy_init.o
+obj-$(CONFIG_PHY_TI_GENERIC) += ti_phy_init.o
 obj-$(CONFIG_PHY_TI_DP83867) += dp83867.o
 obj-$(CONFIG_PHY_TI_DP83869) += dp83869.o
 obj-$(CONFIG_PHY_XILINX) += xilinx_phy.o
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index a45152bddc9..b861bf7cef3 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -409,7 +409,7 @@ static int dp83867_probe(struct phy_device *phydev)
 	return 0;
 }
 
-static struct phy_driver DP83867_driver = {
+U_BOOT_PHY_DRIVER(dp83867) = {
 	.name = "TI DP83867",
 	.uid = 0x2000a231,
 	.mask = 0xfffffff0,
@@ -419,9 +419,3 @@ static struct phy_driver DP83867_driver = {
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,
 };
-
-int phy_dp83867_init(void)
-{
-	phy_register(&DP83867_driver);
-	return 0;
-}
diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c
index 23dbf42b68c..8d32d73b07f 100644
--- a/drivers/net/phy/dp83869.c
+++ b/drivers/net/phy/dp83869.c
@@ -473,7 +473,7 @@ static int dp83869_probe(struct phy_device *phydev)
 	return 0;
 }
 
-static struct phy_driver DP83869_driver = {
+U_BOOT_PHY_DRIVER(dp83869) = {
 	.name = "TI DP83869",
 	.uid = 0x2000a0f1,
 	.mask = 0xfffffff0,
@@ -485,9 +485,3 @@ static struct phy_driver DP83869_driver = {
 	.readext = dp83869_readext,
 	.writeext = dp83869_writeext
 };
-
-int phy_dp83869_init(void)
-{
-	phy_register(&DP83869_driver);
-	return 0;
-}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b76cc51cbfb..404d61c5ab3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -514,9 +514,6 @@ int phy_init(void)
 		phy_drv_reloc(drv);
 #endif
 
-#ifdef CONFIG_PHY_TI
-	phy_ti_init();
-#endif
 #ifdef CONFIG_PHY_VITESSE
 	phy_vitesse_init();
 #endif
diff --git a/drivers/net/phy/ti_phy_init.c b/drivers/net/phy/ti_phy_init.c
index 075b19a39f0..a0878193ac0 100644
--- a/drivers/net/phy/ti_phy_init.c
+++ b/drivers/net/phy/ti_phy_init.c
@@ -10,8 +10,7 @@
 #include <phy.h>
 #include "ti_phy_init.h"
 
-#ifdef CONFIG_PHY_TI_GENERIC
-static struct phy_driver dp83822_driver = {
+U_BOOT_PHY_DRIVER(dp83822) = {
 	.name = "TI DP83822",
 	.uid = 0x2000a240,
 	.mask = 0xfffffff0,
@@ -21,7 +20,7 @@ static struct phy_driver dp83822_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83826nc_driver = {
+U_BOOT_PHY_DRIVER(dp83826nc) = {
 	.name = "TI DP83826NC",
 	.uid = 0x2000a110,
 	.mask = 0xfffffff0,
@@ -31,7 +30,7 @@ static struct phy_driver dp83826nc_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83826c_driver = {
+U_BOOT_PHY_DRIVER(dp83826c) = {
 	.name = "TI DP83826C",
 	.uid = 0x2000a130,
 	.mask = 0xfffffff0,
@@ -41,7 +40,7 @@ static struct phy_driver dp83826c_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83825s_driver = {
+U_BOOT_PHY_DRIVER(dp83825s) = {
 	.name = "TI DP83825S",
 	.uid = 0x2000a140,
 	.mask = 0xfffffff0,
@@ -51,7 +50,7 @@ static struct phy_driver dp83825s_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83825i_driver = {
+U_BOOT_PHY_DRIVER(dp83825i) = {
 	.name = "TI DP83825I",
 	.uid = 0x2000a150,
 	.mask = 0xfffffff0,
@@ -61,7 +60,7 @@ static struct phy_driver dp83825i_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83825m_driver = {
+U_BOOT_PHY_DRIVER(dp83825m) = {
 	.name = "TI DP83825M",
 	.uid = 0x2000a160,
 	.mask = 0xfffffff0,
@@ -71,7 +70,7 @@ static struct phy_driver dp83825m_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
-static struct phy_driver dp83825cs_driver = {
+U_BOOT_PHY_DRIVER(dp83825cs) = {
 	.name = "TI DP83825CS",
 	.uid = 0x2000a170,
 	.mask = 0xfffffff0,
@@ -80,26 +79,3 @@ static struct phy_driver dp83825cs_driver = {
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,
 };
-#endif /* CONFIG_PHY_TI_GENERIC */
-
-int phy_ti_init(void)
-{
-#ifdef CONFIG_PHY_TI_DP83867
-	phy_dp83867_init();
-#endif
-
-#ifdef CONFIG_PHY_TI_DP83869
-	phy_dp83869_init();
-#endif
-
-#ifdef CONFIG_PHY_TI_GENERIC
-	phy_register(&dp83822_driver);
-	phy_register(&dp83825s_driver);
-	phy_register(&dp83825i_driver);
-	phy_register(&dp83825m_driver);
-	phy_register(&dp83825cs_driver);
-	phy_register(&dp83826c_driver);
-	phy_register(&dp83826nc_driver);
-#endif
-	return 0;
-}
diff --git a/include/phy.h b/include/phy.h
index 2c6e167f26e..e6508a132d0 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
 int gen10g_shutdown(struct phy_device *phydev);
 int gen10g_discover_mmds(struct phy_device *phydev);
 
-int phy_ti_init(void);
 int phy_vitesse_init(void);
 int phy_xilinx_init(void);
 int phy_xway_init(void);
-- 
2.39.2



More information about the U-Boot mailing list