net: phy: remove calls to genphy_config_init
[platform/kernel/linux-rpi.git] / drivers / net / phy / microchip_t1.c
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2018 Microchip Technology
3
4 #include <linux/kernel.h>
5 #include <linux/module.h>
6 #include <linux/mii.h>
7 #include <linux/phy.h>
8
9 /* Interrupt Source Register */
10 #define LAN87XX_INTERRUPT_SOURCE                (0x18)
11
12 /* Interrupt Mask Register */
13 #define LAN87XX_INTERRUPT_MASK                  (0x19)
14 #define LAN87XX_MASK_LINK_UP                    (0x0004)
15 #define LAN87XX_MASK_LINK_DOWN                  (0x0002)
16
17 #define DRIVER_AUTHOR   "Nisar Sayed <nisar.sayed@microchip.com>"
18 #define DRIVER_DESC     "Microchip LAN87XX T1 PHY driver"
19
20 static int lan87xx_phy_config_intr(struct phy_device *phydev)
21 {
22         int rc, val = 0;
23
24         if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
25                 /* unmask all source and clear them before enable */
26                 rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, 0x7FFF);
27                 rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
28                 val = LAN87XX_MASK_LINK_UP | LAN87XX_MASK_LINK_DOWN;
29         }
30
31         rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val);
32
33         return rc < 0 ? rc : 0;
34 }
35
36 static int lan87xx_phy_ack_interrupt(struct phy_device *phydev)
37 {
38         int rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE);
39
40         return rc < 0 ? rc : 0;
41 }
42
43 static struct phy_driver microchip_t1_phy_driver[] = {
44         {
45                 .phy_id         = 0x0007c150,
46                 .phy_id_mask    = 0xfffffff0,
47                 .name           = "Microchip LAN87xx T1",
48
49                 .features       = PHY_BASIC_T1_FEATURES,
50
51                 .config_aneg    = genphy_config_aneg,
52
53                 .ack_interrupt  = lan87xx_phy_ack_interrupt,
54                 .config_intr    = lan87xx_phy_config_intr,
55
56                 .suspend        = genphy_suspend,
57                 .resume         = genphy_resume,
58         }
59 };
60
61 module_phy_driver(microchip_t1_phy_driver);
62
63 static struct mdio_device_id __maybe_unused microchip_t1_tbl[] = {
64         { 0x0007c150, 0xfffffff0 },
65         { }
66 };
67
68 MODULE_DEVICE_TABLE(mdio, microchip_t1_tbl);
69
70 MODULE_AUTHOR(DRIVER_AUTHOR);
71 MODULE_DESCRIPTION(DRIVER_DESC);
72 MODULE_LICENSE("GPL");