Skip to content

Commit 3e50d2d

Browse files
nisar-mchpdavem330
authored andcommitted
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. Signed-off-by: Nisar Sayed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent db1617a commit 3e50d2d

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

drivers/net/phy/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ config MICROCHIP_PHY
360360
help
361361
Supports the LAN88XX PHYs.
362362

363+
config MICROCHIP_T1_PHY
364+
tristate "Microchip T1 PHYs"
365+
---help---
366+
Supports the LAN87XX PHYs.
367+
363368
config MICROSEMI_PHY
364369
tristate "Microsemi PHYs"
365370
---help---

drivers/net/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o
7171
obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o
7272
obj-$(CONFIG_MICREL_PHY) += micrel.o
7373
obj-$(CONFIG_MICROCHIP_PHY) += microchip.o
74+
obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o
7475
obj-$(CONFIG_MICROSEMI_PHY) += mscc.o
7576
obj-$(CONFIG_NATIONAL_PHY) += national.o
7677
obj-$(CONFIG_QSEMI_PHY) += qsemi.o

drivers/net/phy/microchip_t1.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 <[email protected]>"
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 = SUPPORTED_100baseT_Full,
50+
.flags = PHY_HAS_INTERRUPT,
51+
52+
.config_init = genphy_config_init,
53+
.config_aneg = genphy_config_aneg,
54+
55+
.ack_interrupt = lan87xx_phy_ack_interrupt,
56+
.config_intr = lan87xx_phy_config_intr,
57+
58+
.suspend = genphy_suspend,
59+
.resume = genphy_resume,
60+
}
61+
};
62+
63+
module_phy_driver(microchip_t1_phy_driver);
64+
65+
static struct mdio_device_id __maybe_unused microchip_t1_tbl[] = {
66+
{ 0x0007c150, 0xfffffff0 },
67+
{ }
68+
};
69+
70+
MODULE_DEVICE_TABLE(mdio, microchip_t1_tbl);
71+
72+
MODULE_AUTHOR(DRIVER_AUTHOR);
73+
MODULE_DESCRIPTION(DRIVER_DESC);
74+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)