* [PATCH v4 0/2] net: phy: Support managed Cortina phys @ 2017-05-29 9:11 Bogdan Purcareata 2017-05-29 9:11 ` [PATCH v4 1/2] net: phy: Add Cortina CS4340 driver Bogdan Purcareata ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Bogdan Purcareata @ 2017-05-29 9:11 UTC (permalink / raw) To: andrew, f.fainelli, netdev, devicetree, linux-kernel So far, the Cortina family phys (CS4340 in this particular case) are only supported in fixed link mode (via fixed_phy_register). The generic 10G phy driver does not work well with the phylib state machine, when the phy is registered via of_phy_connect. This prohibits the user from describing the phy nodes in the device tree. In order to support this scenario, and to properly describe the board device tree, add a minimal Cortina driver that reads the status from the right register. With the generic 10G C45 driver, the kernel will print messages like: [ 0.226521] mdio_bus 8b96000: Error while reading PHY16 reg at 1.6 [ 0.232780] mdio_bus 8b96000: Error while reading PHY16 reg at 1.5 v3 -> v4: - Add trademark info. - Minor documentation entry consistency nit. v2 -> v3: - Add documentation entry. v1 -> v2: - Change approach for getting the phy_id from hacking get_phy_c45_ids to describing the device in the device tree via ethernet-phy-id. More patch version changes per individual patches. Bogdan Purcareata (2): net: phy: Add Cortina CS4340 driver dt-bindings: net: Add Cortina device tree bindings Documentation/devicetree/bindings/net/cortina.txt | 21 ++++ drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/cortina.c | 118 ++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/cortina.txt create mode 100644 drivers/net/phy/cortina.c -- 1.9.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 1/2] net: phy: Add Cortina CS4340 driver 2017-05-29 9:11 [PATCH v4 0/2] net: phy: Support managed Cortina phys Bogdan Purcareata @ 2017-05-29 9:11 ` Bogdan Purcareata [not found] ` <1496049091-4637-2-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> [not found] ` <1496049091-4637-1-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 2017-05-30 16:42 ` [PATCH v4 0/2] net: phy: Support managed Cortina phys David Miller 2 siblings, 1 reply; 7+ messages in thread From: Bogdan Purcareata @ 2017-05-29 9:11 UTC (permalink / raw) To: andrew, f.fainelli, netdev, devicetree, linux-kernel Add basic support for Cortina PHY drivers. Support only CS4340 for now. The phys are not compatible with IEEE 802.3 clause 22/45 registers. Implement proper read_status support. The generic 10G phy driver causes bus register access errors. The driver should be described using the "ethernet-phy-id" device tree compatible. Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com> --- v3 -> v4: - Add CORTINA trademark info. - Change id_lsb and id_msb from u32 to int to cover error checking. v2 -> v3: - Add probe function to check the device we're talking with is the same as the one described in the device tree. - Change the link status (GPIO interrupt status) register and validate that the read is done from the right place (cable plug-in / plug-out). - Some functions + Kconfig entry renaming. v1 -> v2: - Rename "mdio-cortina.c" to "cortina.c" since it's a phy driver. - Test probing based on the "ethernet-phy-id" compatible. In the previous version, getting the phy_id via get_phy_c45_ids() involved an additional hack. Drop that approach and document probing in the commit message. drivers/net/phy/Kconfig | 5 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/cortina.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/net/phy/cortina.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 22dea7f..12c033c 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -240,6 +240,11 @@ config CICADA_PHY ---help--- Currently supports the cis8204 +config CORTINA_PHY + tristate "Cortina EDC CDR 10G Ethernet PHY" + ---help--- + Currently supports the CS4340 phy. + config DAVICOM_PHY tristate "Davicom PHYs" ---help--- diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 79365be..0de3e20 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_BCM_CYGNUS_PHY) += bcm-cygnus.o obj-$(CONFIG_BCM_NET_PHYLIB) += bcm-phy-lib.o obj-$(CONFIG_BROADCOM_PHY) += broadcom.o obj-$(CONFIG_CICADA_PHY) += cicada.o +obj-$(CONFIG_CORTINA_PHY) += cortina.o obj-$(CONFIG_DAVICOM_PHY) += davicom.o obj-$(CONFIG_DP83640_PHY) += dp83640.o obj-$(CONFIG_DP83848_PHY) += dp83848.o diff --git a/drivers/net/phy/cortina.c b/drivers/net/phy/cortina.c new file mode 100644 index 0000000..72f4228 --- /dev/null +++ b/drivers/net/phy/cortina.c @@ -0,0 +1,118 @@ +/* + * Copyright 2017 NXP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * CORTINA is a registered trademark of Cortina Systems, Inc. + * + */ +#include <linux/module.h> +#include <linux/phy.h> + +#define PHY_ID_CS4340 0x13e51002 + +#define VILLA_GLOBAL_CHIP_ID_LSB 0x0 +#define VILLA_GLOBAL_CHIP_ID_MSB 0x1 + +#define VILLA_GLOBAL_GPIO_1_INTS 0x017 + +static int cortina_read_reg(struct phy_device *phydev, u16 regnum) +{ + return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, + MII_ADDR_C45 | regnum); +} + +static int cortina_config_aneg(struct phy_device *phydev) +{ + phydev->supported = SUPPORTED_10000baseT_Full; + phydev->advertising = SUPPORTED_10000baseT_Full; + + return 0; +} + +static int cortina_read_status(struct phy_device *phydev) +{ + int gpio_int_status, ret = 0; + + gpio_int_status = cortina_read_reg(phydev, VILLA_GLOBAL_GPIO_1_INTS); + if (gpio_int_status < 0) { + ret = gpio_int_status; + goto err; + } + + if (gpio_int_status & 0x8) { + /* up when edc_convergedS set */ + phydev->speed = SPEED_10000; + phydev->duplex = DUPLEX_FULL; + phydev->link = 1; + } else { + phydev->link = 0; + } + +err: + return ret; +} + +static int cortina_soft_reset(struct phy_device *phydev) +{ + return 0; +} + +static int cortina_probe(struct phy_device *phydev) +{ + u32 phy_id = 0; + int id_lsb = 0, id_msb = 0; + + /* Read device id from phy registers. */ + id_lsb = cortina_read_reg(phydev, VILLA_GLOBAL_CHIP_ID_LSB); + if (id_lsb < 0) + return -ENXIO; + + phy_id = id_lsb << 16; + + id_msb = cortina_read_reg(phydev, VILLA_GLOBAL_CHIP_ID_MSB); + if (id_msb < 0) + return -ENXIO; + + phy_id |= id_msb; + + /* Make sure the device tree binding matched the driver with the + * right device. + */ + if (phy_id != phydev->drv->phy_id) { + phydev_err(phydev, "Error matching phy with %s driver\n", + phydev->drv->name); + return -ENODEV; + } + + return 0; +} + +static struct phy_driver cortina_driver[] = { +{ + .phy_id = PHY_ID_CS4340, + .phy_id_mask = 0xffffffff, + .name = "Cortina CS4340", + .config_aneg = cortina_config_aneg, + .read_status = cortina_read_status, + .soft_reset = cortina_soft_reset, + .probe = cortina_probe, +}, +}; + +module_phy_driver(cortina_driver); + +static struct mdio_device_id __maybe_unused cortina_tbl[] = { + { PHY_ID_CS4340, 0xffffffff}, + {}, +}; + +MODULE_DEVICE_TABLE(mdio, cortina_tbl); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1496049091-4637-2-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org>]
* Re: [PATCH v4 1/2] net: phy: Add Cortina CS4340 driver [not found] ` <1496049091-4637-2-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> @ 2017-05-29 20:28 ` Florian Fainelli 0 siblings, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2017-05-29 20:28 UTC (permalink / raw) To: Bogdan Purcareata, andrew-g2DYL2Zd6BY, netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Le 05/29/17 à 02:11, Bogdan Purcareata a écrit : > Add basic support for Cortina PHY drivers. Support only CS4340 for now. > The phys are not compatible with IEEE 802.3 clause 22/45 registers. > > Implement proper read_status support. The generic 10G phy driver causes > bus register access errors. > > The driver should be described using the "ethernet-phy-id" device tree > compatible. > > Signed-off-by: Bogdan Purcareata <bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> Reviewed-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> -- Florian -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1496049091-4637-1-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org>]
* [PATCH v4 2/2] dt-bindings: net: Add Cortina device tree bindings [not found] ` <1496049091-4637-1-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> @ 2017-05-29 9:11 ` Bogdan Purcareata 2017-05-29 20:30 ` Florian Fainelli [not found] ` <1496049091-4637-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 0 siblings, 2 replies; 7+ messages in thread From: Bogdan Purcareata @ 2017-05-29 9:11 UTC (permalink / raw) To: andrew-g2DYL2Zd6BY, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Add device tree description info for Cortina 10G phy devices. Signed-off-by: Bogdan Purcareata <bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> --- v3 -> v4: - Consistency nit between phy label and reg value. - Add CORTINNA trademark info. Patch introduced in v3 of the patchset. Documentation/devicetree/bindings/net/cortina.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/cortina.txt diff --git a/Documentation/devicetree/bindings/net/cortina.txt b/Documentation/devicetree/bindings/net/cortina.txt new file mode 100644 index 0000000..40d0bd9 --- /dev/null +++ b/Documentation/devicetree/bindings/net/cortina.txt @@ -0,0 +1,21 @@ +Cortina Phy Driver Device Tree Bindings +--------------------------------------- + +CORTINA is a registered trademark of Cortina Systems, Inc. + +The driver supports the Cortina Electronic Dispersion Compensation (EDC) +devices, equipped with clock and data recovery (CDR) circuits. These +devices make use of registers that are not compatible with Clause 45 or +Clause 22, therefore they need to be described using the +"ethernet-phy-id" compatible. + +Since the driver only implements polling mode support, interrupts info +can be skipped. + +Example (CS4340 phy): + mdio { + cs4340_phy@10 { + compatible = "ethernet-phy-id13e5.1002"; + reg = <0x10>; + }; + }; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/2] dt-bindings: net: Add Cortina device tree bindings 2017-05-29 9:11 ` [PATCH v4 2/2] dt-bindings: net: Add Cortina device tree bindings Bogdan Purcareata @ 2017-05-29 20:30 ` Florian Fainelli [not found] ` <1496049091-4637-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 1 sibling, 0 replies; 7+ messages in thread From: Florian Fainelli @ 2017-05-29 20:30 UTC (permalink / raw) To: Bogdan Purcareata, andrew, netdev, devicetree, linux-kernel Le 05/29/17 à 02:11, Bogdan Purcareata a écrit : > Add device tree description info for Cortina 10G phy devices. > > Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> -- Florian ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <1496049091-4637-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org>]
* Re: [PATCH v4 2/2] dt-bindings: net: Add Cortina device tree bindings [not found] ` <1496049091-4637-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> @ 2017-05-31 21:27 ` Rob Herring 0 siblings, 0 replies; 7+ messages in thread From: Rob Herring @ 2017-05-31 21:27 UTC (permalink / raw) To: Bogdan Purcareata Cc: andrew-g2DYL2Zd6BY, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Mon, May 29, 2017 at 09:11:31AM +0000, Bogdan Purcareata wrote: > Add device tree description info for Cortina 10G phy devices. > > Signed-off-by: Bogdan Purcareata <bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> > --- > v3 -> v4: > - Consistency nit between phy label and reg value. > - Add CORTINNA trademark info. > > Patch introduced in v3 of the patchset. > > Documentation/devicetree/bindings/net/cortina.txt | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > create mode 100644 Documentation/devicetree/bindings/net/cortina.txt Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 0/2] net: phy: Support managed Cortina phys 2017-05-29 9:11 [PATCH v4 0/2] net: phy: Support managed Cortina phys Bogdan Purcareata 2017-05-29 9:11 ` [PATCH v4 1/2] net: phy: Add Cortina CS4340 driver Bogdan Purcareata [not found] ` <1496049091-4637-1-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> @ 2017-05-30 16:42 ` David Miller 2 siblings, 0 replies; 7+ messages in thread From: David Miller @ 2017-05-30 16:42 UTC (permalink / raw) To: bogdan.purcareata; +Cc: andrew, f.fainelli, netdev, devicetree, linux-kernel From: Bogdan Purcareata <bogdan.purcareata@nxp.com> Date: Mon, 29 May 2017 09:11:29 +0000 > So far, the Cortina family phys (CS4340 in this particular case) are only > supported in fixed link mode (via fixed_phy_register). The generic 10G > phy driver does not work well with the phylib state machine, when the phy > is registered via of_phy_connect. This prohibits the user from describing the > phy nodes in the device tree. > > In order to support this scenario, and to properly describe the board > device tree, add a minimal Cortina driver that reads the status from the > right register. With the generic 10G C45 driver, the kernel will print > messages like: > [ 0.226521] mdio_bus 8b96000: Error while reading PHY16 reg at 1.6 > [ 0.232780] mdio_bus 8b96000: Error while reading PHY16 reg at 1.5 ... Series applied, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-31 21:27 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-29 9:11 [PATCH v4 0/2] net: phy: Support managed Cortina phys Bogdan Purcareata 2017-05-29 9:11 ` [PATCH v4 1/2] net: phy: Add Cortina CS4340 driver Bogdan Purcareata [not found] ` <1496049091-4637-2-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 2017-05-29 20:28 ` Florian Fainelli [not found] ` <1496049091-4637-1-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 2017-05-29 9:11 ` [PATCH v4 2/2] dt-bindings: net: Add Cortina device tree bindings Bogdan Purcareata 2017-05-29 20:30 ` Florian Fainelli [not found] ` <1496049091-4637-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org> 2017-05-31 21:27 ` Rob Herring 2017-05-30 16:42 ` [PATCH v4 0/2] net: phy: Support managed Cortina phys David Miller
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).