net: phy: add Maxlinear GPY115/21x/24x driver
Subsystems (4)
Xu Liang
maintainerPATCH v2 1/1 net: phy: add Maxlinear GPY115/21x/24x driver
Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.
---
v2 changes:
Fix format warning from checkpath and some comments. Use smaller PHY ID mask.
Split FWV register mask.
Call phy_trigger_machine if necessary when clear interrupt.
MAINTAINERS | 6 + drivers/net/phy/Kconfig | 6 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mxl-gpy.c | 545 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 558 insertions(+) create mode 100644 drivers/net/phy/mxl-gpy.c
MAINTAINERS +6 -0
@@ -11167,6 +11167,12 @@ W: https://linuxtv.org T: git git://linuxtv.org/media_tree.git F: drivers/media/radio/radio-maxiradio* +MAXLINEAR ETHERNET PHY DRIVER +M: Xu Liang <[email protected]> +L: [email protected] +S: Supported +F: drivers/net/phy/mxl-gpy.c + MCAN MMIO DEVICE DRIVER M: Chandrasekar Ramakrishnan <[email protected]> L: [email protected]
drivers/net/phy/Kconfig +6 -0
@@ -207,6 +207,12 @@ config MARVELL_88X2222_PHY Support for the Marvell 88X2222 Dual-port Multi-speed Ethernet Transceiver. +config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs. + config MICREL_PHY tristate "Micrel 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_MXL_GPHY) += mxl-gpy.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/mxl-gpy.c new file +545 -0
545 lines not on this page · raw message
Signature · 1 line
2.17.1
Russell King (Oracle)
reviewerHi,
drivers/net/phy/Makefile obj-$(CONFIG_MICREL_PHY) += micrel.o · line 73
Quoted 9 lines · Xu Liang
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_MXL_GPHY) += mxl-gpy.o
This should use tab(s) to align indentation rather than spaces.
drivers/net/phy/Makefile obj-$(CONFIG_MICREL_PHY) += micrel.o
Quoted 11 lines
drivers/net/phy/Makefile +11
-0+static int gpy_config_init(struct phy_device *phydev) +{ + int ret, fw_ver; + + /* Show GPY PHY FW version in dmesg */ + fw_ver = phy_read(phydev, PHY_FWV); + if (fw_ver < 0) + return fw_ver; + + phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n", fw_ver, + (fw_ver & PHY_FWV_REL_MASK) ? "release" : "test");
Does this need to print the firmware version each time config_init() is called? Is it likely to change beyond? Would it be more sensible to print it in the probe() method?
drivers/net/phy/Makefile
Quoted 10 lines
drivers/net/phy/Makefile +10
-0+static int gpy_config_aneg(struct phy_device *phydev) +{ + bool changed = false; + u32 adv; + int ret; + + if (phydev->autoneg == AUTONEG_DISABLE) { + return phydev->duplex != DUPLEX_FULL + ? genphy_setup_forced(phydev) + : genphy_c45_pma_setup_forced(phydev);
I think this needs a comment to describe what is going on here to explain why the duplex setting influences whether we program the PHY via C22 or C45.
Quoted 8 lines
drivers/net/phy/Makefile +8
-0+static void gpy_update_interface(struct phy_device *phydev) +{ + int ret; + + /* Interface mode is fixed for USXGMII and integrated PHY */ + if (phydev->interface == PHY_INTERFACE_MODE_USXGMII || + phydev->interface == PHY_INTERFACE_MODE_INTERNAL) + return;
drivers/net/phy/Makefile
Quoted 10 lines
drivers/net/phy/Makefile +10
-0+ + /* Automatically switch SERDES interface between SGMII and 2500-BaseX + * according to speed. Disable ANEG in 2500-BaseX mode. + */ + switch (phydev->speed) { + case SPEED_2500: + phydev->interface = PHY_INTERFACE_MODE_2500BASEX; + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, + VSPEC1_SGMII_CTRL, + VSPEC1_SGMII_CTRL_ANEN, 0);
Do you need to know if the bit was changed? It doesn't appear so, so please consider using phy_modify_mmd() here and in the other part of this switch block.
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!
Liang Xu
maintainerQuoted 16 lines
drivers/net/phy/mxl-gpy.c line 207
Quoted 11 lines
drivers/net/phy/mxl-gpy.c new file +10
-0+static int gpy_config_aneg (struct phy_device *phydev) +{ +bool changed = false; +u32 adv; +int ret; + +if (phydev->autoneg ==AUTONEG_DISABLE ) { +return phydev->duplex !=DUPLEX_FULL + ?genphy_setup_forced (phydev) + :genphy_c45_pma_setup_forced (phydev);I think this needs a comment to describe what is going on here to explain why the duplex setting influences whether we program the PHY via C22 or C45.
Thank you for review.
We support half/full duplex for 10/100/1000 and full duplex only for 2500.
genphy_c45_pma_setup_forced supports full duplex only.
So in half duplex, I use genphy_setup_forced.
Is there recommended way to handle this situation?
Or I should keep this code and put a comment.
Liang Xu
maintainerQuoted 16 lines · Russell King (Oracle)
drivers/net/phy/mxl-gpy.c line 126
Quoted 12 lines
drivers/net/phy/mxl-gpy.c new file +11
-0+static int gpy_config_init (struct phy_device *phydev) +{ +int ret, fw_ver; + +/* Show GPY PHY FW version in dmesg */ + fw_ver =phy_read (phydev,PHY_FWV ); +if (fw_ver <0 ) +return fw_ver; + +phydev_info (phydev,"Firmware Version: 0x%04X (%s)\n" , fw_ver, + (fw_ver &PHY_FWV_REL_MASK ) ?"release" :"test" );Does this need to print the firmware version each time
config_init()is called? Is it likely to change beyond? Would it be more sensible to print it in theprobe()method?
The firmware version can change in device with different firmware loading mechanism.
I moved the print to probe and tested a few devices, found in some cases it did not print the active version number.
So I'm thinking to keep it here to cover all scenarios.
Andrew Lunn
maintainerQuoted 18 lines · Liang Xu
Quoted 16 lines · Russell King (Oracle)
drivers/net/phy/mxl-gpy.c line 126
Quoted 12 lines
drivers/net/phy/mxl-gpy.c new file +11
-0+static int gpy_config_init (struct phy_device *phydev) +{ +int ret, fw_ver; + +/* Show GPY PHY FW version in dmesg */ + fw_ver =phy_read (phydev,PHY_FWV ); +if (fw_ver <0 ) +return fw_ver; + +phydev_info (phydev,"Firmware Version: 0x%04X (%s)\n" , fw_ver, + (fw_ver &PHY_FWV_REL_MASK ) ?"release" :"test" );Does this need to print the firmware version each time
config_init()is called? Is it likely to change beyond? Would it be more sensible to print it in theprobe()method?
Quoted 5 lines
The firmware version can change in device with different firmware loading mechanism.
I moved the print to probe and tested a few devices, found in some cases it did not print the active version number.
That actually sounds like a real problem. If it is still in the bootloader when the driver is probed, the driver should not be writing any configuration registers until the real image is running. So it sounds like you need a probe function which checks if the PHY has finished booting, and if not, wait for the real firmware to start running.
Andrew
Liang Xu
maintainerQuoted 24 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 15 lines · Liang Xu
Quoted 6 lines · Russell King (Oracle)
Quoted 6 lines
drivers/net/phy/mxl-gpy.c new file +6
-0+static int gpy_config_init (struct phy_device *phydev) +{ +int ret, fw_ver; + +/* Show GPY PHY FW version in dmesg */ + fw_ver =phy_read (phydev,PHY_FWV );Quoted 8 lines
Quoted 5 lines
+ if (
fw_ver< 0)
+ returnfw_ver;
+
+ phydev_info(phydev, "Firmware Version: 0x%04X (%s)\n",fw_ver,
+ (fw_ver&PHY_FWV_REL_MASK) ? "release" : "test");Does this need to print the firmware version each time
config_init()is called? Is it likely to change beyond? Would it be more sensible to print it in theprobe()method?Quoted 5 lines
The firmware version can change in device with different firmware loading mechanism.
I moved the print to probe and tested a few devices, found in some cases it did not print the active version number.
Quoted 9 lines
That actually sounds like a real problem. If it is still in the bootloader when the driver is probed, the driver should not be writing any configuration registers until the real image is running. So it sounds like you need a probe function which checks if the PHY has finished booting, and if not, wait for the real firmware to start running.
Andrew
I think my word was misleading.
The device always has valid firmware running.
The firmware version can change because of switch of the firmware during running time.
Andrew Lunn
maintainerQuoted 2 lines
The firmware version can change because of switch of the firmware during running time.
Please could you explain this some more. What happens if i initialize the PHY and then it decided to switch its firmware. Is the configuration kept? Does it need reconfiguring?
Andrew
Liang Xu
maintainerQuoted 11 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 2 lines
The firmware version can change because of switch of the firmware during running time.
Please could you explain this some more. What happens if i initialize the PHY and then it decided to switch its firmware. Is the configuration kept? Does it need reconfiguring?
Andrew
In one of our product (in developing), the NIC driver can decide to switch to 2nd firmware.
The switch happens when network interface is down.
After the switch, when the network interface is up, phy_init_hw is triggered to init the phy.
The PHY device itself won't decide to switch firmware.
Andrew Lunn
maintainerQuoted 2 lines
In one of our product (in developing), the NIC driver can decide to switch to 2nd firmware.
There are currently no systems like this in Linux. So this is going to need new support. Ideally, we don't want the MAC involved in this switch, because then you need to teach every MAC driver in linux about how your PHY is special.
I would say, for the moment, forget about this setup. When you submit support for it, we can look at the bigger picture, and see how best to support it.
So please put the firmware version print in the driver probe function. That should work for the devices the driver currently supports.
Andrew
Liang Xu
maintainerQuoted 14 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 2 lines
In one of our product (in developing), the NIC driver can decide to switch to 2nd firmware.
There are currently no systems like this in Linux. So this is going to need new support. Ideally, we don't want the MAC involved in this switch, because then you need to teach every MAC driver in linux about how your PHY is special.
I would say, for the moment, forget about this setup. When you submit support for it, we can look at the bigger picture, and see how best to support it.
Quoted 6 lines
So please put the firmware version print in the driver probe function. That should work for the devices the driver currently supports.
Andrew
OK
Andrew Lunn
maintainerdrivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.
Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct phy_driver for each product, and the mask is used to match on all the revisions of the product.
Andrew
Liang Xu
maintainerQuoted 11 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
drivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
Quoted 7 lines
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct
phy_driverfor each product, and the mask is used to match on all the revisions of the product.Andrew
Register 2, Register 3 bit 10~15 - OUI
Register 3 bit 4~9 - product number
Register 3 bit 0~3 - revision number
These PHYs have same ID in register 2 and 3.
Andrew Lunn
maintainerQuoted 19 lines · Liang Xu
Quoted 11 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
drivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
Quoted 7 lines
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct
phy_driverfor each product, and the mask is used to match on all the revisions of the product.Andrew
Quoted 7 lines
Register 2, Register 3 bit 10~15 - OUI
Register 3 bit 4~9 - product number
Register 3 bit 0~3 - revision number
These PHYs have same ID in register 2 and 3.
O.K, that is pretty normal. Please add a phy_device for each individual PHY. There are macros to help you do this.
Andrew
Liang Xu
maintainerQuoted 27 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 23 lines · Liang Xu
Quoted 11 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
drivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
Quoted 7 lines
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct
phy_driverfor each product, and the mask is used to match on all the revisions of the product.Andrew
Register 2, Register 3 bit 10~15 - OUI
Register 3 bit 4~9 - product number
Quoted 8 lines
Quoted 3 lines
Register 3 bit 0~3 - revision number
These PHYs have same ID in register 2 and 3.
O.K, that is pretty normal. Please add a
phy_devicefor each individual PHY. There are macros to help you do this.Andrew
Sorry, I didn't get the point.
Do you mean create the MDIO device for each PHY like below?
static struct mdio_device_id __maybe_unused gpy_tbl[] = {
{PHY_ID_MATCH_MODEL(PHY_ID_GPY)},
{ }
};MODULE_DEVICE_TABLE(mdio, gpy_tbl);
These PHYs have same ID and no difference OUI, product number, revision number.
Please give me more guidance if my understanding is wrong.
Thank you.
Andrew Lunn
maintainerQuoted 26 lines · Liang Xu
Quoted 25 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 21 lines · Liang Xu
Quoted 11 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
drivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
Quoted 7 lines
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct
phy_driverfor each product, and the mask is used to match on all the revisions of the product.Andrew
Register 2, Register 3 bit 10~15 - OUI
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Register 3 bit 4~9 - product number
Register 3 bit 0~3 - revision number
These PHYs have same ID and no difference OUI, product number, revision number.
Are you saying GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 all have the same product number?
Normally, each PHY has its own product ID, and so we have:
/* Vitesse 82xx */
static struct phy_driver vsc82xx_driver[] = {
{
.phy_id = PHY_ID_VSC8234,
.name = "Vitesse VSC8234",
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = &vsc824x_config_init,
.config_aneg = &vsc82x4_config_aneg,
.config_intr = &vsc82xx_config_intr,
.handle_interrupt = &vsc82xx_handle_interrupt,
}, {
.phy_id = PHY_ID_VSC8244,
.name = "Vitesse VSC8244",
.phy_id_mask = 0x000fffc0,
/* PHY_GBIT_FEATURES */
.config_init = &vsc824x_config_init,
.config_aneg = &vsc82x4_config_aneg,
.config_intr = &vsc82xx_config_intr,
.handle_interrupt = &vsc82xx_handle_interrupt,
}, {
.phy_id = PHY_ID_VSC8572,
.name = "Vitesse VSC8572",
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = &vsc824x_config_init,
.config_aneg = &vsc82x4_config_aneg,
.config_intr = &vsc82xx_config_intr,
.handle_interrupt = &vsc82xx_handle_interrupt,
}, {one entry to describe one PHY.
Andrew
Liang Xu
maintainerQuoted 72 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 24 lines · Liang Xu
Quoted 23 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 19 lines · Liang Xu
Quoted 18 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
drivers/net/phy/Kconfig config MARVELL_88X2222_PHY · line 214
Quoted 5 lines
drivers/net/phy/Kconfig +5
-0+config MXL_GPHY + tristate "Maxlinear PHYs" + help + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs.Do these PHYs have unique IDs in register 2 and 3? What is the format of these IDs?
The OUI is fixed. But often the rest is split into two. The higher part indicates the product, and the lower part is the revision. We then have a struct
phy_driverfor each product, and the mask is used to match on all the revisions of the product.Andrew
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Register 2, Register 3 bit 10~15 - OUI
Register 3 bit 4~9 - product number
Register 3 bit 0~3 - revision number
These PHYs have same ID and no difference OUI, product number, revision number.
Are you saying GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 all have the same product number?
Normally, each PHY has its own product ID, and so we have:
/* Vitesse 82xx */
static structphy_drivervsc82xx_driver[] = {{ .phy_id = PHY_ID_VSC8234, .name = "Vitesse VSC8234", .phy_id_mask = 0x000ffff0, /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC8244, .name = "Vitesse VSC8244", .phy_id_mask = 0x000fffc0, /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC8572, .name = "Vitesse VSC8572", .phy_id_mask = 0x000ffff0, /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, {
Quoted 4 lines
one entry to describe one PHY.
Andrew
Yes, they all have same product number.
They are one IP.
The difference is feature set it's enabled by fusing in silicon.
For example, GPY115 has 10/100/1000Mbps support, so in the ability register 2.5G capable is 0.
GPY211 has 10/100/1000/2500Mbps support, so in the capability register 2.5G capable is 1.
Andrew Lunn
maintainerQuoted 3 lines
Yes, they all have same product number.
They are one IP.
O.K, this is the sort of information which is useful to have in the commit message. Basically anything which is odd about your PHY it is good to mention, because reviewers are probably going to notice and ask.
Quoted 7 lines
The difference is feature set it's enabled by fusing in silicon.
For example, GPY115 has 10/100/1000Mbps support, so in the ability register 2.5G capable is 0.
GPY211 has 10/100/1000/2500Mbps support, so in the capability register 2.5G capable is 1.
I assume it is more than just the capability register? Linux could easily ignore that and make use of 2.5G if it still actually works.
Andrew
Liang Xu
maintainerQuoted 10 lines · Andrew Lunn
This email was sent from outside of MaxLinear.
Quoted 3 lines
Yes, they all have same product number.
They are one IP.
O.K, this is the sort of information which is useful to have in the commit message. Basically anything which is odd about your PHY it is good to mention, because reviewers are probably going to notice and ask.
Thanks, will update.
Quoted 11 lines
Quoted 7 lines
The difference is feature set it's enabled by fusing in silicon.
For example, GPY115 has 10/100/1000Mbps support, so in the ability register 2.5G capable is 0.
GPY211 has 10/100/1000/2500Mbps support, so in the capability register 2.5G capable is 1.
I assume it is more than just the capability register? Linux could easily ignore that and make use of 2.5G if it still actually works.
Andrew
You are right, not only capability register. The 2.5G function including relative
registers/bit-fields do not work.