]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
microchip_t1: Add driver for Microchip LAN87XX T1 PHYs
authorNisar Sayed <Nisar.Sayed@microchip.com>
Wed, 2 May 2018 15:39:17 +0000 (21:09 +0530)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 May 2018 18:16:36 +0000 (14:16 -0400)
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.

Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/microchip_t1.c [new file with mode: 0644]

index edb8b9ab827fb2a7d42d0f32908b5c796dae8a74..ae2d69170dc3d9d727065f1e4173a029ba63ffcc 100644 (file)
@@ -360,6 +360,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---
index 701ca0b8717e6ab72a7de80fa7ba1f80e845b8ea..22183b9d7e088846a433a4bf78d59f0deb0e4638 100644 (file)
@@ -71,6 +71,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
diff --git a/drivers/net/phy/microchip_t1.c b/drivers/net/phy/microchip_t1.c
new file mode 100644 (file)
index 0000000..b1917dd
--- /dev/null
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Microchip Technology
+
+#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 <nisar.sayed@microchip.com>"
+#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);
+               rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
+               val = LAN87XX_MASK_LINK_UP | LAN87XX_MASK_LINK_DOWN;
+       }
+
+       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;
+}
+
+static struct phy_driver microchip_t1_phy_driver[] = {
+       {
+               .phy_id         = 0x0007c150,
+               .phy_id_mask    = 0xfffffff0,
+               .name           = "Microchip LAN87xx T1",
+
+               .features       = SUPPORTED_100baseT_Full,
+               .flags          = PHY_HAS_INTERRUPT,
+
+               .config_init    = genphy_config_init,
+               .config_aneg    = genphy_config_aneg,
+
+               .ack_interrupt  = lan87xx_phy_ack_interrupt,
+               .config_intr    = lan87xx_phy_config_intr,
+
+               .suspend        = genphy_suspend,
+               .resume         = genphy_resume,
+       }
+};
+
+module_phy_driver(microchip_t1_phy_driver);
+
+static struct mdio_device_id __maybe_unused microchip_t1_tbl[] = {
+       { 0x0007c150, 0xfffffff0 },
+       { }
+};
+
+MODULE_DEVICE_TABLE(mdio, microchip_t1_tbl);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");