Linux 3.4.102
[linux/fpc-iii.git] / drivers / net / phy / smsc.c
blobfc3e7e96c88c64a3c9979a96596a6f0e016778ab
1 /*
2 * drivers/net/phy/smsc.c
4 * Driver for SMSC PHYs
6 * Author: Herbert Valerio Riedel
8 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
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.
15 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@smsc.com
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/mii.h>
22 #include <linux/ethtool.h>
23 #include <linux/phy.h>
24 #include <linux/netdevice.h>
25 #include <linux/smscphy.h>
27 static int smsc_phy_config_intr(struct phy_device *phydev)
29 int rc = phy_write (phydev, MII_LAN83C185_IM,
30 ((PHY_INTERRUPT_ENABLED == phydev->interrupts)
31 ? MII_LAN83C185_ISF_INT_PHYLIB_EVENTS
32 : 0));
34 return rc < 0 ? rc : 0;
37 static int smsc_phy_ack_interrupt(struct phy_device *phydev)
39 int rc = phy_read (phydev, MII_LAN83C185_ISF);
41 return rc < 0 ? rc : 0;
44 static int smsc_phy_config_init(struct phy_device *phydev)
46 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
47 if (rc < 0)
48 return rc;
50 /* Enable energy detect mode for this SMSC Transceivers */
51 rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
52 rc | MII_LAN83C185_EDPWRDOWN);
53 if (rc < 0)
54 return rc;
56 return smsc_phy_ack_interrupt (phydev);
59 static int lan911x_config_init(struct phy_device *phydev)
61 return smsc_phy_ack_interrupt(phydev);
64 static struct phy_driver lan83c185_driver = {
65 .phy_id = 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
66 .phy_id_mask = 0xfffffff0,
67 .name = "SMSC LAN83C185",
69 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
70 | SUPPORTED_Asym_Pause),
71 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
73 /* basic functions */
74 .config_aneg = genphy_config_aneg,
75 .read_status = genphy_read_status,
76 .config_init = smsc_phy_config_init,
78 /* IRQ related */
79 .ack_interrupt = smsc_phy_ack_interrupt,
80 .config_intr = smsc_phy_config_intr,
82 .suspend = genphy_suspend,
83 .resume = genphy_resume,
85 .driver = { .owner = THIS_MODULE, }
88 static struct phy_driver lan8187_driver = {
89 .phy_id = 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
90 .phy_id_mask = 0xfffffff0,
91 .name = "SMSC LAN8187",
93 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
94 | SUPPORTED_Asym_Pause),
95 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
97 /* basic functions */
98 .config_aneg = genphy_config_aneg,
99 .read_status = genphy_read_status,
100 .config_init = smsc_phy_config_init,
102 /* IRQ related */
103 .ack_interrupt = smsc_phy_ack_interrupt,
104 .config_intr = smsc_phy_config_intr,
106 .suspend = genphy_suspend,
107 .resume = genphy_resume,
109 .driver = { .owner = THIS_MODULE, }
112 static struct phy_driver lan8700_driver = {
113 .phy_id = 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
114 .phy_id_mask = 0xfffffff0,
115 .name = "SMSC LAN8700",
117 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
118 | SUPPORTED_Asym_Pause),
119 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
121 /* basic functions */
122 .config_aneg = genphy_config_aneg,
123 .read_status = genphy_read_status,
124 .config_init = smsc_phy_config_init,
126 /* IRQ related */
127 .ack_interrupt = smsc_phy_ack_interrupt,
128 .config_intr = smsc_phy_config_intr,
130 .suspend = genphy_suspend,
131 .resume = genphy_resume,
133 .driver = { .owner = THIS_MODULE, }
136 static struct phy_driver lan911x_int_driver = {
137 .phy_id = 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
138 .phy_id_mask = 0xfffffff0,
139 .name = "SMSC LAN911x Internal PHY",
141 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
142 | SUPPORTED_Asym_Pause),
143 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
145 /* basic functions */
146 .config_aneg = genphy_config_aneg,
147 .read_status = genphy_read_status,
148 .config_init = lan911x_config_init,
150 /* IRQ related */
151 .ack_interrupt = smsc_phy_ack_interrupt,
152 .config_intr = smsc_phy_config_intr,
154 .suspend = genphy_suspend,
155 .resume = genphy_resume,
157 .driver = { .owner = THIS_MODULE, }
160 static struct phy_driver lan8710_driver = {
161 .phy_id = 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
162 .phy_id_mask = 0xfffffff0,
163 .name = "SMSC LAN8710/LAN8720",
165 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
166 | SUPPORTED_Asym_Pause),
167 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
169 /* basic functions */
170 .config_aneg = genphy_config_aneg,
171 .read_status = genphy_read_status,
172 .config_init = smsc_phy_config_init,
174 /* IRQ related */
175 .ack_interrupt = smsc_phy_ack_interrupt,
176 .config_intr = smsc_phy_config_intr,
178 .suspend = genphy_suspend,
179 .resume = genphy_resume,
181 .driver = { .owner = THIS_MODULE, }
184 static int __init smsc_init(void)
186 int ret;
188 ret = phy_driver_register (&lan83c185_driver);
189 if (ret)
190 goto err1;
192 ret = phy_driver_register (&lan8187_driver);
193 if (ret)
194 goto err2;
196 ret = phy_driver_register (&lan8700_driver);
197 if (ret)
198 goto err3;
200 ret = phy_driver_register (&lan911x_int_driver);
201 if (ret)
202 goto err4;
204 ret = phy_driver_register (&lan8710_driver);
205 if (ret)
206 goto err5;
208 return 0;
210 err5:
211 phy_driver_unregister (&lan911x_int_driver);
212 err4:
213 phy_driver_unregister (&lan8700_driver);
214 err3:
215 phy_driver_unregister (&lan8187_driver);
216 err2:
217 phy_driver_unregister (&lan83c185_driver);
218 err1:
219 return ret;
222 static void __exit smsc_exit(void)
224 phy_driver_unregister (&lan8710_driver);
225 phy_driver_unregister (&lan911x_int_driver);
226 phy_driver_unregister (&lan8700_driver);
227 phy_driver_unregister (&lan8187_driver);
228 phy_driver_unregister (&lan83c185_driver);
231 MODULE_DESCRIPTION("SMSC PHY driver");
232 MODULE_AUTHOR("Herbert Valerio Riedel");
233 MODULE_LICENSE("GPL");
235 module_init(smsc_init);
236 module_exit(smsc_exit);
238 static struct mdio_device_id __maybe_unused smsc_tbl[] = {
239 { 0x0007c0a0, 0xfffffff0 },
240 { 0x0007c0b0, 0xfffffff0 },
241 { 0x0007c0c0, 0xfffffff0 },
242 { 0x0007c0d0, 0xfffffff0 },
243 { 0x0007c0f0, 0xfffffff0 },
247 MODULE_DEVICE_TABLE(mdio, smsc_tbl);