]> git.karo-electronics.de Git - linux-beck.git/commitdiff
BECK: Add TLK106L phy driver
authorOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Wed, 8 Mar 2017 14:59:47 +0000 (15:59 +0100)
committerOle Reinhardt <ole.reinhardt@kernelconcepts.de>
Mon, 13 Mar 2017 13:25:56 +0000 (14:25 +0100)
drivers/net/phy/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/tlk106l.c [new file with mode: 0644]

index 2651c8d8de2f8ae96ab867756a8a05e0c1e608a7..efad34bc5854721bcc35270b5cbc21e3b5c548b1 100644 (file)
@@ -236,6 +236,11 @@ config FIXED_PHY
 
          Currently tested with mpc866ads and mpc8349e-mitx.
 
+config TLK106L_PHY
+       tristate "TI TLK106L PHY"
+       ---help---
+         Supports the TI TLK106L PHY.
+
 config ICPLUS_PHY
        tristate "ICPlus PHYs"
        ---help---
index e58667d111e7f7e08916fd8c6ec2a784b9cee1b1..fc8567fae61ec71da3c573eea60d17ce8ecdb3a6 100644 (file)
@@ -36,6 +36,7 @@ obj-$(CONFIG_DP83640_PHY)     += dp83640.o
 obj-$(CONFIG_DP83848_PHY)      += dp83848.o
 obj-$(CONFIG_DP83867_PHY)      += dp83867.o
 obj-$(CONFIG_FIXED_PHY)                += fixed_phy.o
+obj-$(CONFIG_TLK106L_PHY)      += tlk106l.o
 obj-$(CONFIG_ICPLUS_PHY)       += icplus.o
 obj-$(CONFIG_INTEL_XWAY_PHY)   += intel-xway.o
 obj-$(CONFIG_LSI_ET1011C_PHY)  += et1011c.o
diff --git a/drivers/net/phy/tlk106l.c b/drivers/net/phy/tlk106l.c
new file mode 100644 (file)
index 0000000..e5b1019
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * drivers/net/phy/tlk106l.c
+ *
+ * Driver for Texas Instruments TLK106L and compatible PHYs
+ *
+ * Author: Beck IPC GmbH
+ *
+ * Copyright (c) 2016-2017 Beck IPC GmbH
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/phy.h>
+
+#define TLK106L_REGCR           0x0D    /* PHY Register for Extended Addressing */
+#define TLK106L_ADDAR           0x0E    /* PHY Register for Extended Addressing */
+#define TLK106L_MLED                   0x25    /* PHY Specific Multi LED Control Register */
+
+#define TLK106L_PHY_ID_MASK    0xFFFFFFF0
+#define PHY_ID_TLK106L         0x2000A210
+#define PHY_ID_DP83822      0x2000A240
+
+static int tlk106l_extended_write(struct phy_device *phydev, u16 regnum, u16 val)
+{
+       int err = phy_write(phydev, TLK106L_REGCR, 0x1F);
+    err |= phy_write(phydev, TLK106L_ADDAR, regnum);
+    err |= phy_write(phydev, TLK106L_REGCR, 0x401F);
+    err |= phy_write(phydev, TLK106L_ADDAR, val);
+       return err;
+}
+
+static int tlk106l_config_init(struct phy_device *phydev)
+{
+       /* Enable MLED on pin 29 with RX/TX activity functionality */
+       return tlk106l_extended_write(phydev, TLK106L_MLED, 0x408);
+}
+
+static struct phy_driver tlk106l_driver[] = {
+{
+       .phy_id                 = PHY_ID_TLK106L,
+       .phy_id_mask    = TLK106L_PHY_ID_MASK,
+       .name                   = "Texas Instruments TLK106L PHY",
+       .features               = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+       .flags                  = PHY_HAS_MAGICANEG,
+       .config_init    = tlk106l_config_init,
+       .config_aneg    = genphy_config_aneg,
+       .read_status    = genphy_read_status,
+       .suspend                = genphy_suspend,
+       .resume                 = genphy_resume,
+}
+};
+
+static int __init tlk106l_init(void)
+{
+       int ret;
+
+       ret = phy_drivers_register(tlk106l_driver, ARRAY_SIZE(tlk106l_driver), THIS_MODULE);
+       if (ret)
+               phy_drivers_unregister(tlk106l_driver, ARRAY_SIZE(tlk106l_driver));
+               
+       return ret;
+}
+
+static void __exit tlk106l_exit(void)
+{
+       phy_drivers_unregister(tlk106l_driver, ARRAY_SIZE(tlk106l_driver));
+}
+
+module_init(tlk106l_init);
+module_exit(tlk106l_exit);
+
+MODULE_DESCRIPTION("TLK106L PHY driver");
+MODULE_AUTHOR("Beck IPC GmbH");
+MODULE_LICENSE("GPL");
+
+static struct mdio_device_id __maybe_unused tlk106_tbl[] = {
+       { PHY_ID_TLK106L, TLK106L_PHY_ID_MASK },
+       { }
+};
+
+MODULE_DEVICE_TABLE(mdio, tlk106l_tbl);