Skip to content

Commit 513588d

Browse files
JassiBrardavem330
authored andcommitted
net: phy: realtek: add RTL8201F phy-id and functions
Add RTL8201F phy-id and the related functions to the driver. The original patch is as follows: https://patchwork.kernel.org/patch/2538341/ Signed-off-by: Jongsung Kim <[email protected]> Signed-off-by: Jassi Brar <[email protected]> Signed-off-by: Kunihiko Hayashi <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 013955a commit 513588d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

drivers/net/phy/realtek.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,22 @@
2929
#define RTL8211F_INSR 0x1d
3030
#define RTL8211F_TX_DELAY 0x100
3131

32+
#define RTL8201F_ISR 0x1e
33+
#define RTL8201F_IER 0x13
34+
3235
MODULE_DESCRIPTION("Realtek PHY driver");
3336
MODULE_AUTHOR("Johnson Leung");
3437
MODULE_LICENSE("GPL");
3538

39+
static int rtl8201_ack_interrupt(struct phy_device *phydev)
40+
{
41+
int err;
42+
43+
err = phy_read(phydev, RTL8201F_ISR);
44+
45+
return (err < 0) ? err : 0;
46+
}
47+
3648
static int rtl821x_ack_interrupt(struct phy_device *phydev)
3749
{
3850
int err;
@@ -54,6 +66,25 @@ static int rtl8211f_ack_interrupt(struct phy_device *phydev)
5466
return (err < 0) ? err : 0;
5567
}
5668

69+
static int rtl8201_config_intr(struct phy_device *phydev)
70+
{
71+
int err;
72+
73+
/* switch to page 7 */
74+
phy_write(phydev, RTL821x_PAGE_SELECT, 0x7);
75+
76+
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
77+
err = phy_write(phydev, RTL8201F_IER,
78+
BIT(13) | BIT(12) | BIT(11));
79+
else
80+
err = phy_write(phydev, RTL8201F_IER, 0);
81+
82+
/* restore to default page 0 */
83+
phy_write(phydev, RTL821x_PAGE_SELECT, 0x0);
84+
85+
return err;
86+
}
87+
5788
static int rtl8211b_config_intr(struct phy_device *phydev)
5889
{
5990
int err;
@@ -128,6 +159,18 @@ static struct phy_driver realtek_drvs[] = {
128159
.flags = PHY_HAS_INTERRUPT,
129160
.config_aneg = &genphy_config_aneg,
130161
.read_status = &genphy_read_status,
162+
}, {
163+
.phy_id = 0x001cc816,
164+
.name = "RTL8201F 10/100Mbps Ethernet",
165+
.phy_id_mask = 0x001fffff,
166+
.features = PHY_BASIC_FEATURES,
167+
.flags = PHY_HAS_INTERRUPT,
168+
.config_aneg = &genphy_config_aneg,
169+
.read_status = &genphy_read_status,
170+
.ack_interrupt = &rtl8201_ack_interrupt,
171+
.config_intr = &rtl8201_config_intr,
172+
.suspend = genphy_suspend,
173+
.resume = genphy_resume,
131174
}, {
132175
.phy_id = 0x001cc912,
133176
.name = "RTL8211B Gigabit Ethernet",
@@ -181,6 +224,7 @@ static struct phy_driver realtek_drvs[] = {
181224
module_phy_driver(realtek_drvs);
182225

183226
static struct mdio_device_id __maybe_unused realtek_tbl[] = {
227+
{ 0x001cc816, 0x001fffff },
184228
{ 0x001cc912, 0x001fffff },
185229
{ 0x001cc914, 0x001fffff },
186230
{ 0x001cc915, 0x001fffff },

0 commit comments

Comments
 (0)