net: phy: add driver for Motorcomm yt8511 phy
Subsystems (5)
PATCH 1/1 net: phy: add driver for Motorcomm yt8511 phy
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.
--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c
MAINTAINERS +6 -0
@@ -12388,6 +12388,12 @@ F: Documentation/userspace-api/media/drivers/meye* F: drivers/media/pci/meye/ F: include/uapi/linux/meye.h +MOTORCOMM PHY DRIVER +M: Peter Geis <[email protected]> +L: [email protected] +S: Maintained +F: drivers/net/phy/motorcomm.c + MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD S: Orphan F: Documentation/driver-api/serial/moxa-smartio.rst
drivers/net/phy/Kconfig +6 -0
@@ -229,6 +229,12 @@ config MICROSEMI_PHY help Currently supports VSC8514, VSC8530, VSC8531, VSC8540 and VSC8541 PHYs +config MOTORCOMM_PHY + tristate "Motorcomm PHYs" + help + Enables support for Motorcomm network PHYs. + Currently supports the YT8511 gigabit PHY. + config NATIONAL_PHY tristate "National Semiconductor PHYs" help
drivers/net/phy/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_MICREL_PHY) += micrel.o obj-$(CONFIG_MICROCHIP_PHY) += microchip.o obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o obj-$(CONFIG_MICROSEMI_PHY) += mscc/ +obj-$(CONFIG_MOTORCOMM_PHY) += motorcomm.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_NXP_C45_TJA11XX_PHY) += nxp-c45-tja11xx.o obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o
drivers/net/phy/motorcomm.c new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
2.25.1
Russell King - ARM Linux admin
reviewerHi,
drivers/net/phy/motorcomm.c line 47
Quoted 12 lines · Peter Geis
drivers/net/phy/motorcomm.c new file +12
-0+static int yt8511_config_init (struct phy_device *phydev) +{ +int ret, val, oldpage; + +/* set clock mode to 125mhz */ + oldpage =phy_select_page (phydev,YT8511_EXT_CLK_GATE ); +if (oldpage <0 ) + goto err_restore_page; + + val =__phy_read (phydev,YT8511_PAGE ); + val |= (YT8511_CLK_125M ); + ret =__phy_write (phydev,YT8511_PAGE , val);
Please consider __phy_modify(), and handle any error it returns.
drivers/net/phy/motorcomm.c line 50
Quoted 3 lines
drivers/net/phy/motorcomm.c new file +3
-0+ +/* disable auto sleep */ + ret =__phy_write (phydev,YT8511_PAGE_SELECT ,YT8511_EXT_SLEEP_CTRL );
Please consider handling a failure to write here.
drivers/net/phy/motorcomm.c line 53
Quoted 3 lines
drivers/net/phy/motorcomm.c new file +3
-0+ val =__phy_read (phydev,YT8511_PAGE ); + val &= (~BIT (15 )); + ret =__phy_write (phydev,YT8511_PAGE , val);
Also a use for __phy_modify().
drivers/net/phy/motorcomm.c line 63
Quoted 10 lines
drivers/net/phy/motorcomm.c new file +10
-0+ +err_restore_page: +return phy_restore_page (phydev, oldpage, ret); +} + +static struct phy_driver motorcomm_phy_drvs[] = { + { +PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ), + .name ="YT8511 Gigabit Ethernet" , + .config_init = &yt8511_config_init,
Please drop the '&' here, it's unnecessary.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 4 lines · Russell King - ARM Linux admin
Hi,
On Tue, May 11, 2021 at 05:46:06PM -0400, Peter Geis wrote:
Quoted 14 lines
drivers/net/phy/motorcomm.c line 47
Quoted 12 lines
drivers/net/phy/motorcomm.c new file +12
-0+static int yt8511_config_init (struct phy_device *phydev) +{ +int ret, val, oldpage; + +/* set clock mode to 125mhz */ + oldpage =phy_select_page (phydev,YT8511_EXT_CLK_GATE ); +if (oldpage <0 ) + goto err_restore_page; + + val =__phy_read (phydev,YT8511_PAGE ); + val |= (YT8511_CLK_125M ); + ret =__phy_write (phydev,YT8511_PAGE , val);Please consider
__phy_modify(), and handle any error it returns.
Hey that's really neat, thanks!
Quoted 6 lines
drivers/net/phy/motorcomm.c line 50
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +3
-0+ +/* disable auto sleep */ + ret =__phy_write (phydev,YT8511_PAGE_SELECT ,YT8511_EXT_SLEEP_CTRL );Please consider handling a failure to write here.
Will do.
Quoted 7 lines
drivers/net/phy/motorcomm.c line 53
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +3
-0+ val =__phy_read (phydev,YT8511_PAGE ); + val &= (~BIT (15 )); + ret =__phy_write (phydev,YT8511_PAGE , val);Also a use for
__phy_modify().
Quoted 12 lines
drivers/net/phy/motorcomm.c line 63
Quoted 10 lines
drivers/net/phy/motorcomm.c new file +10
-0+ +err_restore_page: +return phy_restore_page (phydev, oldpage, ret); +} + +static struct phy_driver motorcomm_phy_drvs[] = { + { +PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ), + .name ="YT8511 Gigabit Ethernet" , + .config_init = &yt8511_config_init,Please drop the '&' here, it's unnecessary.
Will do, thank you.
Quoted 6 lines
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c
<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}
Why is this "__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.
The "__maybe_unused" is not needed in this case.
Thanks
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.
Quoted 1 line
The "
__maybe_unused" is not needed in this case.
I was simply following convention, for example the realtek.c, micrel.c, and smsc.c drivers all have this as well.
Quoted 2 lines
Thanks
Quoted 26 lines · Peter Geis
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.
Quoted 4 lines
Quoted 1 line
The "
__maybe_unused" is not needed in this case.I was simply following convention, for example the
realtek.c,micrel.c, andsmsc.cdrivers all have this as well.
Maybe they have a reason, but this specific driver doesn't have such.
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Heiner Kallweit
maintainerQuoted 27 lines · Leon Romanovsky
Quoted 26 lines · Peter Geis
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The "
__maybe_unused" is not needed in this case.I was simply following convention, for example the
realtek.c,micrel.c, andsmsc.cdrivers all have this as well.Maybe they have a reason, but this specific driver doesn't have such.
It's used like this:MODULE_DEVICE_TABLE(mdio, <mdio_device_id_tbl>);
And MODULE_DEVICE_TABLE is a no-op if MODULE isn't defined:
#ifdef MODULE
/* Creates an alias so file2alias.c can find device table. */
#define MODULE_DEVICE_TABLE(type, name) \
extern typeof(name) __mod_##type##__##name##_device_table \
__attribute__ ((unused, alias(__stringify(name))))
#else /* !MODULE */
#define MODULE_DEVICE_TABLE(type, name)
#endif
In this case the table is unused.
Quoted 5 lines
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Quoted 50 lines · Heiner Kallweit
Quoted 27 lines · Leon Romanovsky
Quoted 26 lines · Peter Geis
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The "
__maybe_unused" is not needed in this case.I was simply following convention, for example the
realtek.c,micrel.c, andsmsc.cdrivers all have this as well.Maybe they have a reason, but this specific driver doesn't have such.
It's used like this:
MODULE_DEVICE_TABLE(mdio, <mdio_device_id_tbl>);And
MODULE_DEVICE_TABLEis a no-op if MODULE isn't defined:#ifdef MODULE
/* Creates an alias sofile2alias.ccan find device table. */
#defineMODULE_DEVICE_TABLE(type, name)\
extern typeof(name) __mod_##type##__##name##_device_table \
__attribute__((unused, alias(__stringify(name))))
#else /* !MODULE */
#defineMODULE_DEVICE_TABLE(type, name)
#endif
Quoted 1 line
In this case the table is unused.
Do you see compilation warning for such scenario?
Thanks
Quoted 8 lines
Quoted 6 lines
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Quoted 52 lines · Leon Romanovsky
Quoted 50 lines · Heiner Kallweit
Quoted 27 lines · Leon Romanovsky
Quoted 26 lines · Peter Geis
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
drivers/net/phy/motorcomm.c
Quoted 4 lines
drivers/net/phy/motorcomm.c new file +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + {PHY_ID_MATCH_EXACT (PHY_ID_YT8511 ) }, + {/* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The "
__maybe_unused" is not needed in this case.I was simply following convention, for example the
realtek.c,micrel.c, andsmsc.cdrivers all have this as well.Maybe they have a reason, but this specific driver doesn't have such.
It's used like this:
MODULE_DEVICE_TABLE(mdio, <mdio_device_id_tbl>);And
MODULE_DEVICE_TABLEis a no-op if MODULE isn't defined:#ifdef MODULE
/* Creates an alias sofile2alias.ccan find device table. */
#defineMODULE_DEVICE_TABLE(type, name)\
extern typeof(name) __mod_##type##__##name##_device_table \
__attribute__((unused, alias(__stringify(name))))
#else /* !MODULE */
#defineMODULE_DEVICE_TABLE(type, name)
#endif
Quoted 3 lines
Quoted 1 line
In this case the table is unused.
Do you see compilation warning for such scenario?
The issue you are describing has been fixed since 2010:
commit cf93c94581bab447a5634c6d737c1cf38c080261
Author: Uwe Kleine-König <[email protected]> Date: Sun Oct 3 23:43:32 2010 +0000
net/phy: fix many "defined but unused" warnings
MODULE_DEVICE_TABLE only expands to something if it's compiled for a module. So when building-in support for the phys, the mdio_device_id tables are unused. Marking them with __maybe_unused fixes the following warnings:
There is a strong push to fix all warnings during build, including W=1 warnings. For fun I rebuilt without module support and confirmed that removing this does trigger a W=1 warning.
Quoted 11 lines
Thanks
Quoted 8 lines
Quoted 6 lines
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Quoted 65 lines · Peter Geis
Quoted 52 lines · Leon Romanovsky
Quoted 50 lines · Heiner Kallweit
Quoted 27 lines · Leon Romanovsky
Quoted 26 lines · Peter Geis
Quoted 25 lines · Leon Romanovsky
Quoted 12 lines · Peter Geis
Add a driver for the Motorcomm yt8511 phy that will be used in the production Pine64 rk3566-quartz64 development board.
It supports gigabit transfer speeds, rgmii, and 125mhz clk output.Signed-off-by Peter Geis <[email protected]>--- MAINTAINERS | 6 +++ drivers/net/phy/Kconfig | 6 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/motorcomm.c | 85 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/net/phy/motorcomm.c<...>
Review
Quoted 4 lines
(quoted diff) +4
-0+static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { + { PHY_ID_MATCH_EXACT(PHY_ID_YT8511) }, + { /* sentinal */ } +}Why is this "
__maybe_unused"? This *.c file doesn't have any compilation option to compile part of it.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
The "
__maybe_unused" is not needed in this case.I was simply following convention, for example the
realtek.c,micrel.c, andsmsc.cdrivers all have this as well.Maybe they have a reason, but this specific driver doesn't have such.
It's used like this:
MODULE_DEVICE_TABLE(mdio, <mdio_device_id_tbl>);And
MODULE_DEVICE_TABLEis a no-op if MODULE isn't defined:#ifdef MODULE
/* Creates an alias sofile2alias.ccan find device table. */
#defineMODULE_DEVICE_TABLE(type, name)\
extern typeof(name) __mod_##type##__##name##_device_table \
__attribute__((unused, alias(__stringify(name))))
#else /* !MODULE */
#defineMODULE_DEVICE_TABLE(type, name)
#endifQuoted 3 lines
Quoted 1 line
In this case the table is unused.
Do you see compilation warning for such scenario?
The issue you are describing has been fixed since 2010:
commit
cf93c94581bab447a5634c6d737c1cf38c080261Author: Uwe Kleine-König <[email protected]> Date: Sun Oct 3 23:43:32 2010 +0000net/phy: fix many "defined but unused" warnings
Quoted 8 lines
MODULE_DEVICE_TABLEonly expands to something if it's compiled for a module. So when building-in support for the phys, themdio_device_idtables are unused. Marking them with__maybe_unusedfixes the following warnings:There is a strong push to fix all warnings during build, including W=1 warnings. For fun I rebuilt without module support and confirmed that removing this does trigger a W=1 warning.
I'm sorry that I continue to ask, but is net/phy/* usable without MODULE? If not, the better fix is to require it in Kconfig instead of fixing all drivers.
Thanks for your answers.
Quoted 12 lines
Quoted 12 lines
Thanks
Quoted 8 lines
Quoted 6 lines
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Russell King (Oracle)
reviewerQuoted 1 line · Leon Romanovsky
I'm sorry that I continue to ask, but is
net/phy/*usable without MODULE?
Simple answer: it is.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Quoted 5 lines · Russell King (Oracle)
Quoted 1 line · Leon Romanovsky
I'm sorry that I continue to ask, but is
net/phy/*usable without MODULE?Simple answer: it is.
As far as I can tell, so correct me if I'm wrong, MODULE_DEVICE_TABLE is what permits the module system to automatically load the correct module for the device.
Quoted 4 lines
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!