Skip to content

Commit dbb7a95

Browse files
Chaithrika U Sdavem330
authored andcommitted
phy: Add LSI ET1011C PHY driver
Adds LSI ET1011C PHY driver. This driver is used by TI DM646x EVM. Signed-off-by: Chaithrika U S <chaithrika@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e19caae commit dbb7a95

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

drivers/net/phy/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ config STE10XP
7777
---help---
7878
This is the driver for the STe100p and STe101p PHYs.
7979

80+
config LSI_ET1011C_PHY
81+
tristate "Driver for LSI ET1011C PHY"
82+
---help---
83+
Supports the LSI ET1011C PHY.
84+
8085
config FIXED_PHY
8186
bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
8287
depends on PHYLIB=y

drivers/net/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-$(CONFIG_VITESSE_PHY) += vitesse.o
1313
obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
1414
obj-$(CONFIG_ICPLUS_PHY) += icplus.o
1515
obj-$(CONFIG_REALTEK_PHY) += realtek.o
16+
obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o
1617
obj-$(CONFIG_FIXED_PHY) += fixed.o
1718
obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
1819
obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o

drivers/net/phy/et1011c.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* drivers/net/phy/et1011c.c
3+
*
4+
* Driver for LSI ET1011C PHYs
5+
*
6+
* Author: Chaithrika U S
7+
*
8+
* Copyright (c) 2008 Texas Instruments
9+
*
10+
* This program is free software; you can redistribute it and/or modify it
11+
* under the terms of the GNU General Public License as published by the
12+
* Free Software Foundation; either version 2 of the License, or (at your
13+
* option) any later version.
14+
*
15+
*/
16+
#include <linux/kernel.h>
17+
#include <linux/string.h>
18+
#include <linux/errno.h>
19+
#include <linux/unistd.h>
20+
#include <linux/slab.h>
21+
#include <linux/interrupt.h>
22+
#include <linux/init.h>
23+
#include <linux/delay.h>
24+
#include <linux/netdevice.h>
25+
#include <linux/etherdevice.h>
26+
#include <linux/skbuff.h>
27+
#include <linux/spinlock.h>
28+
#include <linux/mm.h>
29+
#include <linux/module.h>
30+
#include <linux/mii.h>
31+
#include <linux/ethtool.h>
32+
#include <linux/phy.h>
33+
#include <linux/io.h>
34+
#include <linux/uaccess.h>
35+
#include <asm/irq.h>
36+
37+
#define ET1011C_STATUS_REG (0x1A)
38+
#define ET1011C_CONFIG_REG (0x16)
39+
#define ET1011C_SPEED_MASK (0x0300)
40+
#define ET1011C_GIGABIT_SPEED (0x0200)
41+
#define ET1011C_TX_FIFO_MASK (0x3000)
42+
#define ET1011C_TX_FIFO_DEPTH_8 (0x0000)
43+
#define ET1011C_TX_FIFO_DEPTH_16 (0x1000)
44+
#define ET1011C_INTERFACE_MASK (0x0007)
45+
#define ET1011C_GMII_INTERFACE (0x0002)
46+
#define ET1011C_SYS_CLK_EN (0x01 << 4)
47+
48+
49+
MODULE_DESCRIPTION("LSI ET1011C PHY driver");
50+
MODULE_AUTHOR("Chaithrika U S");
51+
MODULE_LICENSE("GPL");
52+
53+
static int et1011c_config_aneg(struct phy_device *phydev)
54+
{
55+
int ctl = 0;
56+
ctl = phy_read(phydev, MII_BMCR);
57+
if (ctl < 0)
58+
return ctl;
59+
ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_SPEED1000 |
60+
BMCR_ANENABLE);
61+
/* First clear the PHY */
62+
phy_write(phydev, MII_BMCR, ctl | BMCR_RESET);
63+
64+
return genphy_config_aneg(phydev);
65+
}
66+
67+
static int et1011c_read_status(struct phy_device *phydev)
68+
{
69+
int ret;
70+
u32 val;
71+
static int speed;
72+
ret = genphy_read_status(phydev);
73+
74+
if (speed != phydev->speed) {
75+
speed = phydev->speed;
76+
val = phy_read(phydev, ET1011C_STATUS_REG);
77+
if ((val & ET1011C_SPEED_MASK) ==
78+
ET1011C_GIGABIT_SPEED) {
79+
val = phy_read(phydev, ET1011C_CONFIG_REG);
80+
val &= ~ET1011C_TX_FIFO_MASK;
81+
phy_write(phydev, ET1011C_CONFIG_REG, val\
82+
| ET1011C_GMII_INTERFACE\
83+
| ET1011C_SYS_CLK_EN\
84+
| ET1011C_TX_FIFO_DEPTH_16);
85+
86+
}
87+
}
88+
return ret;
89+
}
90+
91+
static struct phy_driver et1011c_driver = {
92+
.phy_id = 0x0282f014,
93+
.name = "ET1011C",
94+
.phy_id_mask = 0xfffffff0,
95+
.features = (PHY_BASIC_FEATURES | SUPPORTED_1000baseT_Full),
96+
.flags = PHY_POLL,
97+
.config_aneg = et1011c_config_aneg,
98+
.read_status = et1011c_read_status,
99+
.driver = { .owner = THIS_MODULE,},
100+
};
101+
102+
static int __init et1011c_init(void)
103+
{
104+
return phy_driver_register(&et1011c_driver);
105+
}
106+
107+
static void __exit et1011c_exit(void)
108+
{
109+
phy_driver_unregister(&et1011c_driver);
110+
}
111+
112+
module_init(et1011c_init);
113+
module_exit(et1011c_exit);

0 commit comments

Comments
 (0)