blob: 1b3985cdc64c0a8eddb762d3db33440b0830ae52 [file] [log] [blame]
David J. Choid0507002010-04-29 06:12:41 +00001/*
2 * drivers/net/phy/micrel.c
3 *
4 * Driver for Micrel PHYs
5 *
6 * Author: David J. Choi
7 *
David J. Choi7ab59dc2013-01-23 14:05:15 +00008 * Copyright (c) 2010-2013 Micrel, Inc.
David J. Choid0507002010-04-29 06:12:41 +00009 *
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 *
David J. Choi7ab59dc2013-01-23 14:05:15 +000015 * Support : Micrel Phys:
16 * Giga phys: ksz9021, ksz9031
17 * 100/10 Phys : ksz8001, ksz8721, ksz8737, ksz8041
18 * ksz8021, ksz8031, ksz8051,
19 * ksz8081, ksz8091,
20 * ksz8061,
21 * Switch : ksz8873, ksz886x
David J. Choid0507002010-04-29 06:12:41 +000022 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/phy.h>
Baruch Siachd606ef32011-02-14 02:05:33 +000027#include <linux/micrel_phy.h>
Sean Cross954c3962013-08-21 01:46:12 +000028#include <linux/of.h>
Sascha Hauer1fadee02014-10-10 09:48:05 +020029#include <linux/clk.h>
David J. Choid0507002010-04-29 06:12:41 +000030
Marek Vasut212ea992012-09-23 16:58:49 +000031/* Operation Mode Strap Override */
32#define MII_KSZPHY_OMSO 0x16
Johan Hovold00aee092014-11-11 20:00:09 +010033#define KSZPHY_OMSO_B_CAST_OFF BIT(9)
34#define KSZPHY_OMSO_RMII_OVERRIDE BIT(1)
35#define KSZPHY_OMSO_MII_OVERRIDE BIT(0)
Marek Vasut212ea992012-09-23 16:58:49 +000036
Choi, David51f932c2010-06-28 15:23:41 +000037/* general Interrupt control/status reg in vendor specific block. */
38#define MII_KSZPHY_INTCS 0x1B
Johan Hovold00aee092014-11-11 20:00:09 +010039#define KSZPHY_INTCS_JABBER BIT(15)
40#define KSZPHY_INTCS_RECEIVE_ERR BIT(14)
41#define KSZPHY_INTCS_PAGE_RECEIVE BIT(13)
42#define KSZPHY_INTCS_PARELLEL BIT(12)
43#define KSZPHY_INTCS_LINK_PARTNER_ACK BIT(11)
44#define KSZPHY_INTCS_LINK_DOWN BIT(10)
45#define KSZPHY_INTCS_REMOTE_FAULT BIT(9)
46#define KSZPHY_INTCS_LINK_UP BIT(8)
Choi, David51f932c2010-06-28 15:23:41 +000047#define KSZPHY_INTCS_ALL (KSZPHY_INTCS_LINK_UP |\
48 KSZPHY_INTCS_LINK_DOWN)
49
50/* general PHY control reg in vendor specific block. */
51#define MII_KSZPHY_CTRL 0x1F
52/* bitmap of PHY register to set interrupt mode */
Johan Hovold00aee092014-11-11 20:00:09 +010053#define KSZPHY_CTRL_INT_ACTIVE_HIGH BIT(9)
54#define KSZ9021_CTRL_INT_ACTIVE_HIGH BIT(14)
55#define KS8737_CTRL_INT_ACTIVE_HIGH BIT(14)
56#define KSZ8051_RMII_50MHZ_CLK BIT(7)
Choi, David51f932c2010-06-28 15:23:41 +000057
Sean Cross954c3962013-08-21 01:46:12 +000058/* Write/read to/from extended registers */
59#define MII_KSZPHY_EXTREG 0x0b
60#define KSZPHY_EXTREG_WRITE 0x8000
61
62#define MII_KSZPHY_EXTREG_WRITE 0x0c
63#define MII_KSZPHY_EXTREG_READ 0x0d
64
65/* Extended registers */
66#define MII_KSZPHY_CLK_CONTROL_PAD_SKEW 0x104
67#define MII_KSZPHY_RX_DATA_PAD_SKEW 0x105
68#define MII_KSZPHY_TX_DATA_PAD_SKEW 0x106
69
70#define PS_TO_REG 200
71
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +000072static int ksz_config_flags(struct phy_device *phydev)
73{
74 int regval;
75
Sascha Hauer1fadee02014-10-10 09:48:05 +020076 if (phydev->dev_flags & (MICREL_PHY_50MHZ_CLK | MICREL_PHY_25MHZ_CLK)) {
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +000077 regval = phy_read(phydev, MII_KSZPHY_CTRL);
Sascha Hauer1fadee02014-10-10 09:48:05 +020078 if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK)
79 regval |= KSZ8051_RMII_50MHZ_CLK;
80 else
81 regval &= ~KSZ8051_RMII_50MHZ_CLK;
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +000082 return phy_write(phydev, MII_KSZPHY_CTRL, regval);
83 }
84 return 0;
85}
86
Sean Cross954c3962013-08-21 01:46:12 +000087static int kszphy_extended_write(struct phy_device *phydev,
Florian Fainelli756b5082013-12-17 21:38:11 -080088 u32 regnum, u16 val)
Sean Cross954c3962013-08-21 01:46:12 +000089{
90 phy_write(phydev, MII_KSZPHY_EXTREG, KSZPHY_EXTREG_WRITE | regnum);
91 return phy_write(phydev, MII_KSZPHY_EXTREG_WRITE, val);
92}
93
94static int kszphy_extended_read(struct phy_device *phydev,
Florian Fainelli756b5082013-12-17 21:38:11 -080095 u32 regnum)
Sean Cross954c3962013-08-21 01:46:12 +000096{
97 phy_write(phydev, MII_KSZPHY_EXTREG, regnum);
98 return phy_read(phydev, MII_KSZPHY_EXTREG_READ);
99}
100
Choi, David51f932c2010-06-28 15:23:41 +0000101static int kszphy_ack_interrupt(struct phy_device *phydev)
102{
103 /* bit[7..0] int status, which is a read and clear register. */
104 int rc;
105
106 rc = phy_read(phydev, MII_KSZPHY_INTCS);
107
108 return (rc < 0) ? rc : 0;
109}
110
111static int kszphy_set_interrupt(struct phy_device *phydev)
112{
113 int temp;
114 temp = (PHY_INTERRUPT_ENABLED == phydev->interrupts) ?
115 KSZPHY_INTCS_ALL : 0;
116 return phy_write(phydev, MII_KSZPHY_INTCS, temp);
117}
118
119static int kszphy_config_intr(struct phy_device *phydev)
120{
121 int temp, rc;
122
123 /* set the interrupt pin active low */
124 temp = phy_read(phydev, MII_KSZPHY_CTRL);
Johan Hovold5bb8fc02014-11-11 20:00:08 +0100125 if (temp < 0)
126 return temp;
Choi, David51f932c2010-06-28 15:23:41 +0000127 temp &= ~KSZPHY_CTRL_INT_ACTIVE_HIGH;
128 phy_write(phydev, MII_KSZPHY_CTRL, temp);
129 rc = kszphy_set_interrupt(phydev);
130 return rc < 0 ? rc : 0;
131}
132
133static int ksz9021_config_intr(struct phy_device *phydev)
134{
135 int temp, rc;
136
137 /* set the interrupt pin active low */
138 temp = phy_read(phydev, MII_KSZPHY_CTRL);
Johan Hovold5bb8fc02014-11-11 20:00:08 +0100139 if (temp < 0)
140 return temp;
Choi, David51f932c2010-06-28 15:23:41 +0000141 temp &= ~KSZ9021_CTRL_INT_ACTIVE_HIGH;
142 phy_write(phydev, MII_KSZPHY_CTRL, temp);
143 rc = kszphy_set_interrupt(phydev);
144 return rc < 0 ? rc : 0;
145}
146
147static int ks8737_config_intr(struct phy_device *phydev)
148{
149 int temp, rc;
150
151 /* set the interrupt pin active low */
152 temp = phy_read(phydev, MII_KSZPHY_CTRL);
Johan Hovold5bb8fc02014-11-11 20:00:08 +0100153 if (temp < 0)
154 return temp;
Choi, David51f932c2010-06-28 15:23:41 +0000155 temp &= ~KS8737_CTRL_INT_ACTIVE_HIGH;
156 phy_write(phydev, MII_KSZPHY_CTRL, temp);
157 rc = kszphy_set_interrupt(phydev);
158 return rc < 0 ? rc : 0;
159}
David J. Choid0507002010-04-29 06:12:41 +0000160
Ben Dooks20d84352014-02-26 11:48:00 +0000161static int kszphy_setup_led(struct phy_device *phydev,
162 unsigned int reg, unsigned int shift)
163{
164
165 struct device *dev = &phydev->dev;
166 struct device_node *of_node = dev->of_node;
167 int rc, temp;
168 u32 val;
169
170 if (!of_node && dev->parent->of_node)
171 of_node = dev->parent->of_node;
172
173 if (of_property_read_u32(of_node, "micrel,led-mode", &val))
174 return 0;
175
Johan Hovold86205462014-11-11 20:00:12 +0100176 if (val > 3) {
177 dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", val);
178 return -EINVAL;
179 }
180
Ben Dooks20d84352014-02-26 11:48:00 +0000181 temp = phy_read(phydev, reg);
182 if (temp < 0)
183 return temp;
184
Sergei Shtylyov28bdc492014-03-19 02:58:16 +0300185 temp &= ~(3 << shift);
Ben Dooks20d84352014-02-26 11:48:00 +0000186 temp |= val << shift;
187 rc = phy_write(phydev, reg, temp);
188
189 return rc < 0 ? rc : 0;
190}
191
Johan Hovoldbde15122014-11-11 20:00:10 +0100192/* Disable PHY address 0 as the broadcast address, so that it can be used as a
193 * unique (non-broadcast) address on a shared bus.
194 */
195static int kszphy_broadcast_disable(struct phy_device *phydev)
196{
197 int ret;
198
199 ret = phy_read(phydev, MII_KSZPHY_OMSO);
200 if (ret < 0)
201 goto out;
202
203 ret = phy_write(phydev, MII_KSZPHY_OMSO, ret | KSZPHY_OMSO_B_CAST_OFF);
204out:
205 if (ret)
206 dev_err(&phydev->dev, "failed to disable broadcast address\n");
207
208 return ret;
209}
210
David J. Choid0507002010-04-29 06:12:41 +0000211static int kszphy_config_init(struct phy_device *phydev)
212{
213 return 0;
214}
215
Ben Dooks20d84352014-02-26 11:48:00 +0000216static int kszphy_config_init_led8041(struct phy_device *phydev)
217{
218 /* single led control, register 0x1e bits 15..14 */
219 return kszphy_setup_led(phydev, 0x1e, 14);
220}
221
Marek Vasut212ea992012-09-23 16:58:49 +0000222static int ksz8021_config_init(struct phy_device *phydev)
223{
Ben Dooks20d84352014-02-26 11:48:00 +0000224 int rc;
225
226 rc = kszphy_setup_led(phydev, 0x1f, 4);
227 if (rc)
228 dev_err(&phydev->dev, "failed to set led mode\n");
229
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000230 rc = ksz_config_flags(phydev);
Bruno Thomsenb838b4a2014-10-09 16:48:14 +0200231 if (rc < 0)
232 return rc;
Johan Hovoldbde15122014-11-11 20:00:10 +0100233
234 rc = kszphy_broadcast_disable(phydev);
235
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000236 return rc < 0 ? rc : 0;
Marek Vasut212ea992012-09-23 16:58:49 +0000237}
238
Baruch Siachd606ef32011-02-14 02:05:33 +0000239static int ks8051_config_init(struct phy_device *phydev)
240{
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000241 int rc;
Baruch Siachd606ef32011-02-14 02:05:33 +0000242
Ben Dooks20d84352014-02-26 11:48:00 +0000243 rc = kszphy_setup_led(phydev, 0x1f, 4);
244 if (rc)
245 dev_err(&phydev->dev, "failed to set led mode\n");
246
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000247 rc = ksz_config_flags(phydev);
248 return rc < 0 ? rc : 0;
Baruch Siachd606ef32011-02-14 02:05:33 +0000249}
250
Johan Hovold57a38ef2014-11-11 20:00:11 +0100251static int ksz8081_config_init(struct phy_device *phydev)
252{
253 kszphy_broadcast_disable(phydev);
254
255 return 0;
256}
257
Sean Cross954c3962013-08-21 01:46:12 +0000258static int ksz9021_load_values_from_of(struct phy_device *phydev,
259 struct device_node *of_node, u16 reg,
260 char *field1, char *field2,
261 char *field3, char *field4)
262{
263 int val1 = -1;
264 int val2 = -2;
265 int val3 = -3;
266 int val4 = -4;
267 int newval;
268 int matches = 0;
269
270 if (!of_property_read_u32(of_node, field1, &val1))
271 matches++;
272
273 if (!of_property_read_u32(of_node, field2, &val2))
274 matches++;
275
276 if (!of_property_read_u32(of_node, field3, &val3))
277 matches++;
278
279 if (!of_property_read_u32(of_node, field4, &val4))
280 matches++;
281
282 if (!matches)
283 return 0;
284
285 if (matches < 4)
286 newval = kszphy_extended_read(phydev, reg);
287 else
288 newval = 0;
289
290 if (val1 != -1)
291 newval = ((newval & 0xfff0) | ((val1 / PS_TO_REG) & 0xf) << 0);
292
Hubert Chaumette6a119742014-04-22 15:01:04 +0200293 if (val2 != -2)
Sean Cross954c3962013-08-21 01:46:12 +0000294 newval = ((newval & 0xff0f) | ((val2 / PS_TO_REG) & 0xf) << 4);
295
Hubert Chaumette6a119742014-04-22 15:01:04 +0200296 if (val3 != -3)
Sean Cross954c3962013-08-21 01:46:12 +0000297 newval = ((newval & 0xf0ff) | ((val3 / PS_TO_REG) & 0xf) << 8);
298
Hubert Chaumette6a119742014-04-22 15:01:04 +0200299 if (val4 != -4)
Sean Cross954c3962013-08-21 01:46:12 +0000300 newval = ((newval & 0x0fff) | ((val4 / PS_TO_REG) & 0xf) << 12);
301
302 return kszphy_extended_write(phydev, reg, newval);
303}
304
305static int ksz9021_config_init(struct phy_device *phydev)
306{
307 struct device *dev = &phydev->dev;
308 struct device_node *of_node = dev->of_node;
309
310 if (!of_node && dev->parent->of_node)
311 of_node = dev->parent->of_node;
312
313 if (of_node) {
314 ksz9021_load_values_from_of(phydev, of_node,
315 MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
316 "txen-skew-ps", "txc-skew-ps",
317 "rxdv-skew-ps", "rxc-skew-ps");
318 ksz9021_load_values_from_of(phydev, of_node,
319 MII_KSZPHY_RX_DATA_PAD_SKEW,
320 "rxd0-skew-ps", "rxd1-skew-ps",
321 "rxd2-skew-ps", "rxd3-skew-ps");
322 ksz9021_load_values_from_of(phydev, of_node,
323 MII_KSZPHY_TX_DATA_PAD_SKEW,
324 "txd0-skew-ps", "txd1-skew-ps",
325 "txd2-skew-ps", "txd3-skew-ps");
326 }
327 return 0;
328}
329
Hubert Chaumette6e4b8272014-05-06 09:40:17 +0200330#define MII_KSZ9031RN_MMD_CTRL_REG 0x0d
331#define MII_KSZ9031RN_MMD_REGDATA_REG 0x0e
332#define OP_DATA 1
333#define KSZ9031_PS_TO_REG 60
334
335/* Extended registers */
336#define MII_KSZ9031RN_CONTROL_PAD_SKEW 4
337#define MII_KSZ9031RN_RX_DATA_PAD_SKEW 5
338#define MII_KSZ9031RN_TX_DATA_PAD_SKEW 6
339#define MII_KSZ9031RN_CLK_PAD_SKEW 8
340
341static int ksz9031_extended_write(struct phy_device *phydev,
342 u8 mode, u32 dev_addr, u32 regnum, u16 val)
343{
344 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr);
345 phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum);
346 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr);
347 return phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, val);
348}
349
350static int ksz9031_extended_read(struct phy_device *phydev,
351 u8 mode, u32 dev_addr, u32 regnum)
352{
353 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr);
354 phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum);
355 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr);
356 return phy_read(phydev, MII_KSZ9031RN_MMD_REGDATA_REG);
357}
358
359static int ksz9031_of_load_skew_values(struct phy_device *phydev,
360 struct device_node *of_node,
361 u16 reg, size_t field_sz,
362 char *field[], u8 numfields)
363{
364 int val[4] = {-1, -2, -3, -4};
365 int matches = 0;
366 u16 mask;
367 u16 maxval;
368 u16 newval;
369 int i;
370
371 for (i = 0; i < numfields; i++)
372 if (!of_property_read_u32(of_node, field[i], val + i))
373 matches++;
374
375 if (!matches)
376 return 0;
377
378 if (matches < numfields)
379 newval = ksz9031_extended_read(phydev, OP_DATA, 2, reg);
380 else
381 newval = 0;
382
383 maxval = (field_sz == 4) ? 0xf : 0x1f;
384 for (i = 0; i < numfields; i++)
385 if (val[i] != -(i + 1)) {
386 mask = 0xffff;
387 mask ^= maxval << (field_sz * i);
388 newval = (newval & mask) |
389 (((val[i] / KSZ9031_PS_TO_REG) & maxval)
390 << (field_sz * i));
391 }
392
393 return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval);
394}
395
396static int ksz9031_config_init(struct phy_device *phydev)
397{
398 struct device *dev = &phydev->dev;
399 struct device_node *of_node = dev->of_node;
400 char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"};
401 char *rx_data_skews[4] = {
402 "rxd0-skew-ps", "rxd1-skew-ps",
403 "rxd2-skew-ps", "rxd3-skew-ps"
404 };
405 char *tx_data_skews[4] = {
406 "txd0-skew-ps", "txd1-skew-ps",
407 "txd2-skew-ps", "txd3-skew-ps"
408 };
409 char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
410
411 if (!of_node && dev->parent->of_node)
412 of_node = dev->parent->of_node;
413
414 if (of_node) {
415 ksz9031_of_load_skew_values(phydev, of_node,
416 MII_KSZ9031RN_CLK_PAD_SKEW, 5,
417 clk_skews, 2);
418
419 ksz9031_of_load_skew_values(phydev, of_node,
420 MII_KSZ9031RN_CONTROL_PAD_SKEW, 4,
421 control_skews, 2);
422
423 ksz9031_of_load_skew_values(phydev, of_node,
424 MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4,
425 rx_data_skews, 4);
426
427 ksz9031_of_load_skew_values(phydev, of_node,
428 MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4,
429 tx_data_skews, 4);
430 }
431 return 0;
432}
433
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000434#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
Johan Hovold00aee092014-11-11 20:00:09 +0100435#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX BIT(6)
436#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED BIT(4)
Jingoo Han32d73b12013-08-06 17:29:35 +0900437static int ksz8873mll_read_status(struct phy_device *phydev)
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000438{
439 int regval;
440
441 /* dummy read */
442 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
443
444 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
445
446 if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX)
447 phydev->duplex = DUPLEX_HALF;
448 else
449 phydev->duplex = DUPLEX_FULL;
450
451 if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_SPEED)
452 phydev->speed = SPEED_10;
453 else
454 phydev->speed = SPEED_100;
455
456 phydev->link = 1;
457 phydev->pause = phydev->asym_pause = 0;
458
459 return 0;
460}
461
462static int ksz8873mll_config_aneg(struct phy_device *phydev)
463{
464 return 0;
465}
466
Vince Bridgers19936942014-07-29 15:19:58 -0500467/* This routine returns -1 as an indication to the caller that the
468 * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE
469 * MMD extended PHY registers.
470 */
471static int
472ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum,
473 int regnum)
474{
475 return -1;
476}
477
478/* This routine does nothing since the Micrel ksz9021 does not support
479 * standard IEEE MMD extended PHY registers.
480 */
481static void
482ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum,
483 int regnum, u32 val)
484{
485}
486
Sascha Hauer1fadee02014-10-10 09:48:05 +0200487static int ksz8021_probe(struct phy_device *phydev)
488{
489 struct clk *clk;
490
491 clk = devm_clk_get(&phydev->dev, "rmii-ref");
492 if (!IS_ERR(clk)) {
493 unsigned long rate = clk_get_rate(clk);
494
495 if (rate > 24500000 && rate < 25500000) {
496 phydev->dev_flags |= MICREL_PHY_25MHZ_CLK;
497 } else if (rate > 49500000 && rate < 50500000) {
498 phydev->dev_flags |= MICREL_PHY_50MHZ_CLK;
499 } else {
500 dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate);
501 return -EINVAL;
502 }
503 }
504
505 return 0;
506}
507
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000508static struct phy_driver ksphy_driver[] = {
509{
Choi, David51f932c2010-06-28 15:23:41 +0000510 .phy_id = PHY_ID_KS8737,
David J. Choid0507002010-04-29 06:12:41 +0000511 .phy_id_mask = 0x00fffff0,
Choi, David51f932c2010-06-28 15:23:41 +0000512 .name = "Micrel KS8737",
513 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
514 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
David J. Choid0507002010-04-29 06:12:41 +0000515 .config_init = kszphy_config_init,
516 .config_aneg = genphy_config_aneg,
517 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000518 .ack_interrupt = kszphy_ack_interrupt,
519 .config_intr = ks8737_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200520 .suspend = genphy_suspend,
521 .resume = genphy_resume,
David J. Choid0507002010-04-29 06:12:41 +0000522 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000523}, {
Marek Vasut212ea992012-09-23 16:58:49 +0000524 .phy_id = PHY_ID_KSZ8021,
525 .phy_id_mask = 0x00ffffff,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000526 .name = "Micrel KSZ8021 or KSZ8031",
Marek Vasut212ea992012-09-23 16:58:49 +0000527 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause |
528 SUPPORTED_Asym_Pause),
529 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sascha Hauer1fadee02014-10-10 09:48:05 +0200530 .probe = ksz8021_probe,
Marek Vasut212ea992012-09-23 16:58:49 +0000531 .config_init = ksz8021_config_init,
532 .config_aneg = genphy_config_aneg,
533 .read_status = genphy_read_status,
534 .ack_interrupt = kszphy_ack_interrupt,
535 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200536 .suspend = genphy_suspend,
537 .resume = genphy_resume,
Marek Vasut212ea992012-09-23 16:58:49 +0000538 .driver = { .owner = THIS_MODULE,},
539}, {
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000540 .phy_id = PHY_ID_KSZ8031,
541 .phy_id_mask = 0x00ffffff,
542 .name = "Micrel KSZ8031",
543 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause |
544 SUPPORTED_Asym_Pause),
545 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sascha Hauer1fadee02014-10-10 09:48:05 +0200546 .probe = ksz8021_probe,
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000547 .config_init = ksz8021_config_init,
548 .config_aneg = genphy_config_aneg,
549 .read_status = genphy_read_status,
550 .ack_interrupt = kszphy_ack_interrupt,
551 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200552 .suspend = genphy_suspend,
553 .resume = genphy_resume,
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000554 .driver = { .owner = THIS_MODULE,},
555}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000556 .phy_id = PHY_ID_KSZ8041,
David J. Choid0507002010-04-29 06:12:41 +0000557 .phy_id_mask = 0x00fffff0,
Marek Vasut510d5732012-09-23 16:58:50 +0000558 .name = "Micrel KSZ8041",
Choi, David51f932c2010-06-28 15:23:41 +0000559 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
560 | SUPPORTED_Asym_Pause),
561 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000562 .config_init = kszphy_config_init_led8041,
David J. Choid0507002010-04-29 06:12:41 +0000563 .config_aneg = genphy_config_aneg,
564 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000565 .ack_interrupt = kszphy_ack_interrupt,
566 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200567 .suspend = genphy_suspend,
568 .resume = genphy_resume,
Choi, David51f932c2010-06-28 15:23:41 +0000569 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000570}, {
Sergei Shtylyov4bd7b512013-12-10 02:20:41 +0300571 .phy_id = PHY_ID_KSZ8041RNLI,
572 .phy_id_mask = 0x00fffff0,
573 .name = "Micrel KSZ8041RNLI",
574 .features = PHY_BASIC_FEATURES |
575 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
576 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000577 .config_init = kszphy_config_init_led8041,
Sergei Shtylyov4bd7b512013-12-10 02:20:41 +0300578 .config_aneg = genphy_config_aneg,
579 .read_status = genphy_read_status,
580 .ack_interrupt = kszphy_ack_interrupt,
581 .config_intr = kszphy_config_intr,
582 .suspend = genphy_suspend,
583 .resume = genphy_resume,
584 .driver = { .owner = THIS_MODULE,},
585}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000586 .phy_id = PHY_ID_KSZ8051,
Choi, David51f932c2010-06-28 15:23:41 +0000587 .phy_id_mask = 0x00fffff0,
Marek Vasut510d5732012-09-23 16:58:50 +0000588 .name = "Micrel KSZ8051",
Choi, David51f932c2010-06-28 15:23:41 +0000589 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
590 | SUPPORTED_Asym_Pause),
591 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Baruch Siachd606ef32011-02-14 02:05:33 +0000592 .config_init = ks8051_config_init,
Choi, David51f932c2010-06-28 15:23:41 +0000593 .config_aneg = genphy_config_aneg,
594 .read_status = genphy_read_status,
595 .ack_interrupt = kszphy_ack_interrupt,
596 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200597 .suspend = genphy_suspend,
598 .resume = genphy_resume,
Choi, David51f932c2010-06-28 15:23:41 +0000599 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000600}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000601 .phy_id = PHY_ID_KSZ8001,
602 .name = "Micrel KSZ8001 or KS8721",
Jason Wang48d7d0a2012-06-17 22:52:09 +0000603 .phy_id_mask = 0x00ffffff,
Choi, David51f932c2010-06-28 15:23:41 +0000604 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
605 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000606 .config_init = kszphy_config_init_led8041,
Choi, David51f932c2010-06-28 15:23:41 +0000607 .config_aneg = genphy_config_aneg,
608 .read_status = genphy_read_status,
609 .ack_interrupt = kszphy_ack_interrupt,
610 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200611 .suspend = genphy_suspend,
612 .resume = genphy_resume,
David J. Choid0507002010-04-29 06:12:41 +0000613 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000614}, {
David J. Choi7ab59dc2013-01-23 14:05:15 +0000615 .phy_id = PHY_ID_KSZ8081,
616 .name = "Micrel KSZ8081 or KSZ8091",
617 .phy_id_mask = 0x00fffff0,
618 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
619 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Johan Hovold57a38ef2014-11-11 20:00:11 +0100620 .config_init = ksz8081_config_init,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000621 .config_aneg = genphy_config_aneg,
622 .read_status = genphy_read_status,
623 .ack_interrupt = kszphy_ack_interrupt,
624 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200625 .suspend = genphy_suspend,
626 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000627 .driver = { .owner = THIS_MODULE,},
628}, {
629 .phy_id = PHY_ID_KSZ8061,
630 .name = "Micrel KSZ8061",
631 .phy_id_mask = 0x00fffff0,
632 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
633 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
634 .config_init = kszphy_config_init,
635 .config_aneg = genphy_config_aneg,
636 .read_status = genphy_read_status,
637 .ack_interrupt = kszphy_ack_interrupt,
638 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200639 .suspend = genphy_suspend,
640 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000641 .driver = { .owner = THIS_MODULE,},
642}, {
David J. Choid0507002010-04-29 06:12:41 +0000643 .phy_id = PHY_ID_KSZ9021,
Jason Wang48d7d0a2012-06-17 22:52:09 +0000644 .phy_id_mask = 0x000ffffe,
David J. Choid0507002010-04-29 06:12:41 +0000645 .name = "Micrel KSZ9021 Gigabit PHY",
Vlastimil Kosar32fcafb2013-02-28 08:45:22 +0000646 .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
Choi, David51f932c2010-06-28 15:23:41 +0000647 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sean Cross954c3962013-08-21 01:46:12 +0000648 .config_init = ksz9021_config_init,
David J. Choid0507002010-04-29 06:12:41 +0000649 .config_aneg = genphy_config_aneg,
650 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000651 .ack_interrupt = kszphy_ack_interrupt,
652 .config_intr = ksz9021_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200653 .suspend = genphy_suspend,
654 .resume = genphy_resume,
Vince Bridgers19936942014-07-29 15:19:58 -0500655 .read_mmd_indirect = ksz9021_rd_mmd_phyreg,
656 .write_mmd_indirect = ksz9021_wr_mmd_phyreg,
David J. Choid0507002010-04-29 06:12:41 +0000657 .driver = { .owner = THIS_MODULE, },
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000658}, {
David J. Choi7ab59dc2013-01-23 14:05:15 +0000659 .phy_id = PHY_ID_KSZ9031,
660 .phy_id_mask = 0x00fffff0,
661 .name = "Micrel KSZ9031 Gigabit PHY",
Mike Looijmans95e8b102014-09-15 12:06:33 +0200662 .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
David J. Choi7ab59dc2013-01-23 14:05:15 +0000663 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Hubert Chaumette6e4b8272014-05-06 09:40:17 +0200664 .config_init = ksz9031_config_init,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000665 .config_aneg = genphy_config_aneg,
666 .read_status = genphy_read_status,
667 .ack_interrupt = kszphy_ack_interrupt,
668 .config_intr = ksz9021_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200669 .suspend = genphy_suspend,
670 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000671 .driver = { .owner = THIS_MODULE, },
672}, {
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000673 .phy_id = PHY_ID_KSZ8873MLL,
674 .phy_id_mask = 0x00fffff0,
675 .name = "Micrel KSZ8873MLL Switch",
676 .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
677 .flags = PHY_HAS_MAGICANEG,
678 .config_init = kszphy_config_init,
679 .config_aneg = ksz8873mll_config_aneg,
680 .read_status = ksz8873mll_read_status,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200681 .suspend = genphy_suspend,
682 .resume = genphy_resume,
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000683 .driver = { .owner = THIS_MODULE, },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000684}, {
685 .phy_id = PHY_ID_KSZ886X,
686 .phy_id_mask = 0x00fffff0,
687 .name = "Micrel KSZ886X Switch",
688 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
689 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
690 .config_init = kszphy_config_init,
691 .config_aneg = genphy_config_aneg,
692 .read_status = genphy_read_status,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200693 .suspend = genphy_suspend,
694 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000695 .driver = { .owner = THIS_MODULE, },
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000696} };
David J. Choid0507002010-04-29 06:12:41 +0000697
Johan Hovold50fd7152014-11-11 19:45:59 +0100698module_phy_driver(ksphy_driver);
David J. Choid0507002010-04-29 06:12:41 +0000699
700MODULE_DESCRIPTION("Micrel PHY driver");
701MODULE_AUTHOR("David J. Choi");
702MODULE_LICENSE("GPL");
David S. Miller52a60ed2010-05-03 15:48:29 -0700703
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +0000704static struct mdio_device_id __maybe_unused micrel_tbl[] = {
Jason Wang48d7d0a2012-06-17 22:52:09 +0000705 { PHY_ID_KSZ9021, 0x000ffffe },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000706 { PHY_ID_KSZ9031, 0x00fffff0 },
Marek Vasut510d5732012-09-23 16:58:50 +0000707 { PHY_ID_KSZ8001, 0x00ffffff },
Choi, David51f932c2010-06-28 15:23:41 +0000708 { PHY_ID_KS8737, 0x00fffff0 },
Marek Vasut212ea992012-09-23 16:58:49 +0000709 { PHY_ID_KSZ8021, 0x00ffffff },
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000710 { PHY_ID_KSZ8031, 0x00ffffff },
Marek Vasut510d5732012-09-23 16:58:50 +0000711 { PHY_ID_KSZ8041, 0x00fffff0 },
712 { PHY_ID_KSZ8051, 0x00fffff0 },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000713 { PHY_ID_KSZ8061, 0x00fffff0 },
714 { PHY_ID_KSZ8081, 0x00fffff0 },
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000715 { PHY_ID_KSZ8873MLL, 0x00fffff0 },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000716 { PHY_ID_KSZ886X, 0x00fffff0 },
David S. Miller52a60ed2010-05-03 15:48:29 -0700717 { }
718};
719
720MODULE_DEVICE_TABLE(mdio, micrel_tbl);