microchip_t1: Add driver for Microchip LAN87XX T1 PHYs
PATCH 1/1 microchip_t1: Add driver for Microchip LAN87XX T1 PHYs
Add driver for Microchip LAN87XX T1 PHYs
This patch support driver for Microchp T1 PHYs.
There will be followup patches to this driver to support T1 PHY features such as cable diagnostics, signal quality indicator(SQI), sleep and wakeup (TC10) support.
---
v0 - v1:
* Rename microchipT1phy.c file to microchip_t1.c
* Remove microchipT1phy.h include file
* Add SPDX license identifier
* Remove remove probe and remove functions
* Update LAN87XX_INTERRUPT_MASK write as suggested
--- drivers/net/phy/Kconfig | 5 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/microchip_t1.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/net/phy/microchip_t1.c
drivers/net/phy/Kconfig +5 -0
@@ -354,6 +354,11 @@ config MICROCHIP_PHY help Supports the LAN88XX PHYs. +config MICROCHIP_T1_PHY + tristate "Microchip T1 PHYs" + ---help--- + Supports the LAN87XX PHYs. + config MICROSEMI_PHY tristate "Microsemi PHYs" ---help---
drivers/net/phy/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o 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.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o
drivers/net/phy/microchip_t1.c new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.14.1
Quoted 7 lines · Nisar Sayed
Add driver for Microchip LAN87XX T1 PHYs
This patch support driver for Microchp T1 PHYs.
There will be followup patches to this driver to support T1 PHY features such as cable diagnostics, signal quality indicator(SQI), sleep and wakeup (TC10) support.
Quoted 8 lines
Signed-off-by Nisar Sayed <[email protected]>---
v0 - v1:
* RenamemicrochipT1phy.cfile tomicrochip_t1.c
* RemovemicrochipT1phy.hinclude file
* Add SPDX license identifier
* Remove remove probe and remove functions
* UpdateLAN87XX_INTERRUPT_MASKwrite as suggested
This does look better, small comments below.
Quoted 41 lines
--- drivers/net/phy/Kconfig | 5 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/microchip_t1.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/net/phy/microchip_t1.cdrivers/net/phy/Kconfig +5
-0@@ -354,6 +354,11 @@ config MICROCHIP_PHY help Supports the LAN88XX PHYs. +config MICROCHIP_T1_PHY + tristate "Microchip T1 PHYs" + ---help--- + Supports the LAN87XX PHYs. + config MICROSEMI_PHY tristate "Microsemi PHYs" ---help---drivers/net/phy/Makefile +1
-0@@ -70,6 +70,7 @@ obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o 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.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_QSEMI_PHY) += qsemi.odrivers/net/phy/microchip_t1.c new file +0
-0
drivers/net/phy/microchip_t1.c line 1
Quoted 1 line
drivers/net/phy/microchip_t1.c new file +1
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */
This is not the standard comment for a .c file, it should be: // (C++ style)
Quoted 5 lines
drivers/net/phy/microchip_t1.c new file +5
-0+/* +* Copyright (C) 2018 Microchip Technology +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License
drivers/net/phy/microchip_t1.c line 16
Quoted 10 lines
drivers/net/phy/microchip_t1.c new file +10
-0+* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>.
That needs to go away now that you used SPDX
Quoted 16 lines
drivers/net/phy/microchip_t1.c new file +16
-0+*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mii.h> +#include <linux/phy.h> + +/* Interrupt Source Register */ +#define LAN87XX_INTERRUPT_SOURCE (0x18) + +/* Interrupt Mask Register */ +#define LAN87XX_INTERRUPT_MASK (0x19) +#define LAN87XX_MASK_LINK_UP (0x0004) +#define LAN87XX_MASK_LINK_DOWN (0x0002) + +#define DRIVER_AUTHOR "Nisar Sayed <[email protected]>" +#define DRIVER_DESC "Microchip LAN87XX T1 PHY driver"
drivers/net/phy/microchip_t1.c line 42
Quoted 10 lines
drivers/net/phy/microchip_t1.c new file +10
-0+ +static int lan87xx_phy_config_intr (struct phy_device *phydev) +{ +int rc, val =0 ; + +if (phydev->interrupts ==PHY_INTERRUPT_ENABLED ) { +/* unmask all source and clear them before enable */ + rc =phy_write (phydev,LAN87XX_INTERRUPT_MASK ,0x7FFF ); + rc =phy_read (phydev,LAN87XX_INTERRUPT_SOURCE ); + val = (LAN87XX_MASK_LINK_UP |LAN87XX_MASK_LINK_DOWN );
The parenthesis are not necessary here.
Quoted 9 lines
drivers/net/phy/microchip_t1.c new file +9
-0+ } + + rc =phy_write (phydev,LAN87XX_INTERRUPT_MASK , val); + +return rc <0 ? rc :0 ; +} + +static int lan87xx_phy_ack_interrupt (struct phy_device *phydev) +{
drivers/net/phy/microchip_t1.c line 61
Quoted 10 lines
drivers/net/phy/microchip_t1.c new file +10
-0+int rc =phy_read (phydev,LAN87XX_INTERRUPT_SOURCE ); + +return rc <0 ? rc :0 ; +} + +static struct phy_driver microchip_t1_phy_driver[] = { + { + .phy_id =0x0007c150 , + .phy_id_mask =0xfffffff0 , + .name ="Microchip LAN87xx" ,
Would you want to name this "Microchip LAN87xx T1"?
Signature · 1 line
Florian
Hi Florian
Quoted 10 lines
drivers/net/phy/microchip_t1.c line 1
Quoted 7 lines
(quoted diff) +0
-0
b/drivers/net/phy/microchip_t1.cnew file mode 100644 index 0000000..1f6f299drivers/net/phy/microchip_t1.c new file +1
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ This is not the standard comment for a .c file, it should be: // (C++ style)
Thanks, will update it.
Quoted 16 lines
Quoted 5 lines
drivers/net/phy/microchip_t1.c new file +5
-0+/* +* Copyright (C) 2018 Microchip Technology +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License drivers/net/phy/microchip_t1.c line 16
Quoted 10 lines
drivers/net/phy/microchip_t1.c new file +10
-0+* 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>.
Quoted 2 lines
That needs to go away now that you used SPDX
Ok fine will remove it.
Quoted 24 lines
Quoted 13 lines
drivers/net/phy/microchip_t1.c new file +13
-0+*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mii.h> +#include <linux/phy.h> + +/* Interrupt Source Register */ +#define LAN87XX_INTERRUPT_SOURCE (0x18) + +/* Interrupt Mask Register */ +#define LAN87XX_INTERRUPT_MASK (0x19) +#define LAN87XX_MASK_LINK_UP (0x0004) +#define LAN87XX_MASK_LINK_DOWN (0x0002)drivers/net/phy/microchip_t1.c
Quoted 10 lines
drivers/net/phy/microchip_t1.c new file +10
-0+ +#define DRIVER_AUTHOR "Nisar Sayed <[email protected]>" +#define DRIVER_DESC "Microchip LAN87XX T1 PHY driver" + +static int lan87xx_phy_config_intr (struct phy_device *phydev) { +int rc, val =0 ; + +if (phydev->interrupts ==PHY_INTERRUPT_ENABLED ) { +/* unmask all source and clear them before enable */ + rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK,
0x7FFF);
Quoted 5 lines
drivers/net/phy/microchip_t1.c line 41
Quoted 2 lines
drivers/net/phy/microchip_t1.c new file +2
-0+ rc =phy_read (phydev,LAN87XX_INTERRUPT_SOURCE ); + val = (LAN87XX_MASK_LINK_UP |
LAN87XX_MASK_LINK_DOWN);The parenthesis are not necessary here.
Thanks, will remove as suggested.
Quoted 13 lines
Quoted 13 lines
drivers/net/phy/microchip_t1.c new file +12
-0+ } + + rc =phy_write (phydev,LAN87XX_INTERRUPT_MASK , val); + +return rc <0 ? rc :0 ; +} + +static int lan87xx_phy_ack_interrupt (struct phy_device *phydev) { +int rc =phy_read (phydev,LAN87XX_INTERRUPT_SOURCE ); + +return rc <0 ? rc :0 ; +}
Quoted 8 lines
drivers/net/phy/microchip_t1.c line 61
Quoted 6 lines
drivers/net/phy/microchip_t1.c new file +6
-0+ +static struct phy_driver microchip_t1_phy_driver[] = { + { + .phy_id =0x0007c150 , + .phy_id_mask =0xfffffff0 , + .name ="Microchip LAN87xx" ,Would you want to name this "Microchip LAN87xx T1"?
Thanks, yes it's good to mention, will update and send v2
- Nisar