blob: 62ca9613a5141b1f86ca2eab661ea3bc055cf621 [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
33#define KSZPHY_OMSO_B_CAST_OFF (1 << 9)
34#define KSZPHY_OMSO_RMII_OVERRIDE (1 << 1)
35#define KSZPHY_OMSO_MII_OVERRIDE (1 << 0)
36
Choi, David51f932c2010-06-28 15:23:41 +000037/* general Interrupt control/status reg in vendor specific block. */
38#define MII_KSZPHY_INTCS 0x1B
39#define KSZPHY_INTCS_JABBER (1 << 15)
40#define KSZPHY_INTCS_RECEIVE_ERR (1 << 14)
41#define KSZPHY_INTCS_PAGE_RECEIVE (1 << 13)
42#define KSZPHY_INTCS_PARELLEL (1 << 12)
43#define KSZPHY_INTCS_LINK_PARTNER_ACK (1 << 11)
44#define KSZPHY_INTCS_LINK_DOWN (1 << 10)
45#define KSZPHY_INTCS_REMOTE_FAULT (1 << 9)
46#define KSZPHY_INTCS_LINK_UP (1 << 8)
47#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 */
53#define KSZPHY_CTRL_INT_ACTIVE_HIGH (1 << 9)
54#define KSZ9021_CTRL_INT_ACTIVE_HIGH (1 << 14)
55#define KS8737_CTRL_INT_ACTIVE_HIGH (1 << 14)
Baruch Siachd606ef32011-02-14 02:05:33 +000056#define KSZ8051_RMII_50MHZ_CLK (1 << 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
176 temp = phy_read(phydev, reg);
177 if (temp < 0)
178 return temp;
179
Sergei Shtylyov28bdc492014-03-19 02:58:16 +0300180 temp &= ~(3 << shift);
Ben Dooks20d84352014-02-26 11:48:00 +0000181 temp |= val << shift;
182 rc = phy_write(phydev, reg, temp);
183
184 return rc < 0 ? rc : 0;
185}
186
David J. Choid0507002010-04-29 06:12:41 +0000187static int kszphy_config_init(struct phy_device *phydev)
188{
189 return 0;
190}
191
Ben Dooks20d84352014-02-26 11:48:00 +0000192static int kszphy_config_init_led8041(struct phy_device *phydev)
193{
194 /* single led control, register 0x1e bits 15..14 */
195 return kszphy_setup_led(phydev, 0x1e, 14);
196}
197
Marek Vasut212ea992012-09-23 16:58:49 +0000198static int ksz8021_config_init(struct phy_device *phydev)
199{
200 const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE;
Ben Dooks20d84352014-02-26 11:48:00 +0000201 int rc;
202
203 rc = kszphy_setup_led(phydev, 0x1f, 4);
204 if (rc)
205 dev_err(&phydev->dev, "failed to set led mode\n");
206
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000207 rc = ksz_config_flags(phydev);
Bruno Thomsenb838b4a2014-10-09 16:48:14 +0200208 if (rc < 0)
209 return rc;
210 rc = phy_write(phydev, MII_KSZPHY_OMSO, val);
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000211 return rc < 0 ? rc : 0;
Marek Vasut212ea992012-09-23 16:58:49 +0000212}
213
Baruch Siachd606ef32011-02-14 02:05:33 +0000214static int ks8051_config_init(struct phy_device *phydev)
215{
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000216 int rc;
Baruch Siachd606ef32011-02-14 02:05:33 +0000217
Ben Dooks20d84352014-02-26 11:48:00 +0000218 rc = kszphy_setup_led(phydev, 0x1f, 4);
219 if (rc)
220 dev_err(&phydev->dev, "failed to set led mode\n");
221
Hector Palaciosb6bb4dfc2013-03-10 22:50:03 +0000222 rc = ksz_config_flags(phydev);
223 return rc < 0 ? rc : 0;
Baruch Siachd606ef32011-02-14 02:05:33 +0000224}
225
Sean Cross954c3962013-08-21 01:46:12 +0000226static int ksz9021_load_values_from_of(struct phy_device *phydev,
227 struct device_node *of_node, u16 reg,
228 char *field1, char *field2,
229 char *field3, char *field4)
230{
231 int val1 = -1;
232 int val2 = -2;
233 int val3 = -3;
234 int val4 = -4;
235 int newval;
236 int matches = 0;
237
238 if (!of_property_read_u32(of_node, field1, &val1))
239 matches++;
240
241 if (!of_property_read_u32(of_node, field2, &val2))
242 matches++;
243
244 if (!of_property_read_u32(of_node, field3, &val3))
245 matches++;
246
247 if (!of_property_read_u32(of_node, field4, &val4))
248 matches++;
249
250 if (!matches)
251 return 0;
252
253 if (matches < 4)
254 newval = kszphy_extended_read(phydev, reg);
255 else
256 newval = 0;
257
258 if (val1 != -1)
259 newval = ((newval & 0xfff0) | ((val1 / PS_TO_REG) & 0xf) << 0);
260
Hubert Chaumette6a119742014-04-22 15:01:04 +0200261 if (val2 != -2)
Sean Cross954c3962013-08-21 01:46:12 +0000262 newval = ((newval & 0xff0f) | ((val2 / PS_TO_REG) & 0xf) << 4);
263
Hubert Chaumette6a119742014-04-22 15:01:04 +0200264 if (val3 != -3)
Sean Cross954c3962013-08-21 01:46:12 +0000265 newval = ((newval & 0xf0ff) | ((val3 / PS_TO_REG) & 0xf) << 8);
266
Hubert Chaumette6a119742014-04-22 15:01:04 +0200267 if (val4 != -4)
Sean Cross954c3962013-08-21 01:46:12 +0000268 newval = ((newval & 0x0fff) | ((val4 / PS_TO_REG) & 0xf) << 12);
269
270 return kszphy_extended_write(phydev, reg, newval);
271}
272
273static int ksz9021_config_init(struct phy_device *phydev)
274{
275 struct device *dev = &phydev->dev;
276 struct device_node *of_node = dev->of_node;
277
278 if (!of_node && dev->parent->of_node)
279 of_node = dev->parent->of_node;
280
281 if (of_node) {
282 ksz9021_load_values_from_of(phydev, of_node,
283 MII_KSZPHY_CLK_CONTROL_PAD_SKEW,
284 "txen-skew-ps", "txc-skew-ps",
285 "rxdv-skew-ps", "rxc-skew-ps");
286 ksz9021_load_values_from_of(phydev, of_node,
287 MII_KSZPHY_RX_DATA_PAD_SKEW,
288 "rxd0-skew-ps", "rxd1-skew-ps",
289 "rxd2-skew-ps", "rxd3-skew-ps");
290 ksz9021_load_values_from_of(phydev, of_node,
291 MII_KSZPHY_TX_DATA_PAD_SKEW,
292 "txd0-skew-ps", "txd1-skew-ps",
293 "txd2-skew-ps", "txd3-skew-ps");
294 }
295 return 0;
296}
297
Hubert Chaumette6e4b8272014-05-06 09:40:17 +0200298#define MII_KSZ9031RN_MMD_CTRL_REG 0x0d
299#define MII_KSZ9031RN_MMD_REGDATA_REG 0x0e
300#define OP_DATA 1
301#define KSZ9031_PS_TO_REG 60
302
303/* Extended registers */
304#define MII_KSZ9031RN_CONTROL_PAD_SKEW 4
305#define MII_KSZ9031RN_RX_DATA_PAD_SKEW 5
306#define MII_KSZ9031RN_TX_DATA_PAD_SKEW 6
307#define MII_KSZ9031RN_CLK_PAD_SKEW 8
308
309static int ksz9031_extended_write(struct phy_device *phydev,
310 u8 mode, u32 dev_addr, u32 regnum, u16 val)
311{
312 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr);
313 phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum);
314 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr);
315 return phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, val);
316}
317
318static int ksz9031_extended_read(struct phy_device *phydev,
319 u8 mode, u32 dev_addr, u32 regnum)
320{
321 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, dev_addr);
322 phy_write(phydev, MII_KSZ9031RN_MMD_REGDATA_REG, regnum);
323 phy_write(phydev, MII_KSZ9031RN_MMD_CTRL_REG, (mode << 14) | dev_addr);
324 return phy_read(phydev, MII_KSZ9031RN_MMD_REGDATA_REG);
325}
326
327static int ksz9031_of_load_skew_values(struct phy_device *phydev,
328 struct device_node *of_node,
329 u16 reg, size_t field_sz,
330 char *field[], u8 numfields)
331{
332 int val[4] = {-1, -2, -3, -4};
333 int matches = 0;
334 u16 mask;
335 u16 maxval;
336 u16 newval;
337 int i;
338
339 for (i = 0; i < numfields; i++)
340 if (!of_property_read_u32(of_node, field[i], val + i))
341 matches++;
342
343 if (!matches)
344 return 0;
345
346 if (matches < numfields)
347 newval = ksz9031_extended_read(phydev, OP_DATA, 2, reg);
348 else
349 newval = 0;
350
351 maxval = (field_sz == 4) ? 0xf : 0x1f;
352 for (i = 0; i < numfields; i++)
353 if (val[i] != -(i + 1)) {
354 mask = 0xffff;
355 mask ^= maxval << (field_sz * i);
356 newval = (newval & mask) |
357 (((val[i] / KSZ9031_PS_TO_REG) & maxval)
358 << (field_sz * i));
359 }
360
361 return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval);
362}
363
364static int ksz9031_config_init(struct phy_device *phydev)
365{
366 struct device *dev = &phydev->dev;
367 struct device_node *of_node = dev->of_node;
368 char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"};
369 char *rx_data_skews[4] = {
370 "rxd0-skew-ps", "rxd1-skew-ps",
371 "rxd2-skew-ps", "rxd3-skew-ps"
372 };
373 char *tx_data_skews[4] = {
374 "txd0-skew-ps", "txd1-skew-ps",
375 "txd2-skew-ps", "txd3-skew-ps"
376 };
377 char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"};
378
379 if (!of_node && dev->parent->of_node)
380 of_node = dev->parent->of_node;
381
382 if (of_node) {
383 ksz9031_of_load_skew_values(phydev, of_node,
384 MII_KSZ9031RN_CLK_PAD_SKEW, 5,
385 clk_skews, 2);
386
387 ksz9031_of_load_skew_values(phydev, of_node,
388 MII_KSZ9031RN_CONTROL_PAD_SKEW, 4,
389 control_skews, 2);
390
391 ksz9031_of_load_skew_values(phydev, of_node,
392 MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4,
393 rx_data_skews, 4);
394
395 ksz9031_of_load_skew_values(phydev, of_node,
396 MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4,
397 tx_data_skews, 4);
398 }
399 return 0;
400}
401
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000402#define KSZ8873MLL_GLOBAL_CONTROL_4 0x06
403#define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6)
404#define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4)
Jingoo Han32d73b12013-08-06 17:29:35 +0900405static int ksz8873mll_read_status(struct phy_device *phydev)
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000406{
407 int regval;
408
409 /* dummy read */
410 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
411
412 regval = phy_read(phydev, KSZ8873MLL_GLOBAL_CONTROL_4);
413
414 if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX)
415 phydev->duplex = DUPLEX_HALF;
416 else
417 phydev->duplex = DUPLEX_FULL;
418
419 if (regval & KSZ8873MLL_GLOBAL_CONTROL_4_SPEED)
420 phydev->speed = SPEED_10;
421 else
422 phydev->speed = SPEED_100;
423
424 phydev->link = 1;
425 phydev->pause = phydev->asym_pause = 0;
426
427 return 0;
428}
429
430static int ksz8873mll_config_aneg(struct phy_device *phydev)
431{
432 return 0;
433}
434
Vince Bridgers19936942014-07-29 15:19:58 -0500435/* This routine returns -1 as an indication to the caller that the
436 * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE
437 * MMD extended PHY registers.
438 */
439static int
440ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum,
441 int regnum)
442{
443 return -1;
444}
445
446/* This routine does nothing since the Micrel ksz9021 does not support
447 * standard IEEE MMD extended PHY registers.
448 */
449static void
450ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int ptrad, int devnum,
451 int regnum, u32 val)
452{
453}
454
Sascha Hauer1fadee02014-10-10 09:48:05 +0200455static int ksz8021_probe(struct phy_device *phydev)
456{
457 struct clk *clk;
458
459 clk = devm_clk_get(&phydev->dev, "rmii-ref");
460 if (!IS_ERR(clk)) {
461 unsigned long rate = clk_get_rate(clk);
462
463 if (rate > 24500000 && rate < 25500000) {
464 phydev->dev_flags |= MICREL_PHY_25MHZ_CLK;
465 } else if (rate > 49500000 && rate < 50500000) {
466 phydev->dev_flags |= MICREL_PHY_50MHZ_CLK;
467 } else {
468 dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate);
469 return -EINVAL;
470 }
471 }
472
473 return 0;
474}
475
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000476static struct phy_driver ksphy_driver[] = {
477{
Choi, David51f932c2010-06-28 15:23:41 +0000478 .phy_id = PHY_ID_KS8737,
David J. Choid0507002010-04-29 06:12:41 +0000479 .phy_id_mask = 0x00fffff0,
Choi, David51f932c2010-06-28 15:23:41 +0000480 .name = "Micrel KS8737",
481 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
482 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
David J. Choid0507002010-04-29 06:12:41 +0000483 .config_init = kszphy_config_init,
484 .config_aneg = genphy_config_aneg,
485 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000486 .ack_interrupt = kszphy_ack_interrupt,
487 .config_intr = ks8737_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200488 .suspend = genphy_suspend,
489 .resume = genphy_resume,
David J. Choid0507002010-04-29 06:12:41 +0000490 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000491}, {
Marek Vasut212ea992012-09-23 16:58:49 +0000492 .phy_id = PHY_ID_KSZ8021,
493 .phy_id_mask = 0x00ffffff,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000494 .name = "Micrel KSZ8021 or KSZ8031",
Marek Vasut212ea992012-09-23 16:58:49 +0000495 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause |
496 SUPPORTED_Asym_Pause),
497 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sascha Hauer1fadee02014-10-10 09:48:05 +0200498 .probe = ksz8021_probe,
Marek Vasut212ea992012-09-23 16:58:49 +0000499 .config_init = ksz8021_config_init,
500 .config_aneg = genphy_config_aneg,
501 .read_status = genphy_read_status,
502 .ack_interrupt = kszphy_ack_interrupt,
503 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200504 .suspend = genphy_suspend,
505 .resume = genphy_resume,
Marek Vasut212ea992012-09-23 16:58:49 +0000506 .driver = { .owner = THIS_MODULE,},
507}, {
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000508 .phy_id = PHY_ID_KSZ8031,
509 .phy_id_mask = 0x00ffffff,
510 .name = "Micrel KSZ8031",
511 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause |
512 SUPPORTED_Asym_Pause),
513 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sascha Hauer1fadee02014-10-10 09:48:05 +0200514 .probe = ksz8021_probe,
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000515 .config_init = ksz8021_config_init,
516 .config_aneg = genphy_config_aneg,
517 .read_status = genphy_read_status,
518 .ack_interrupt = kszphy_ack_interrupt,
519 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200520 .suspend = genphy_suspend,
521 .resume = genphy_resume,
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000522 .driver = { .owner = THIS_MODULE,},
523}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000524 .phy_id = PHY_ID_KSZ8041,
David J. Choid0507002010-04-29 06:12:41 +0000525 .phy_id_mask = 0x00fffff0,
Marek Vasut510d5732012-09-23 16:58:50 +0000526 .name = "Micrel KSZ8041",
Choi, David51f932c2010-06-28 15:23:41 +0000527 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
528 | SUPPORTED_Asym_Pause),
529 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000530 .config_init = kszphy_config_init_led8041,
David J. Choid0507002010-04-29 06:12:41 +0000531 .config_aneg = genphy_config_aneg,
532 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000533 .ack_interrupt = kszphy_ack_interrupt,
534 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200535 .suspend = genphy_suspend,
536 .resume = genphy_resume,
Choi, David51f932c2010-06-28 15:23:41 +0000537 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000538}, {
Sergei Shtylyov4bd7b512013-12-10 02:20:41 +0300539 .phy_id = PHY_ID_KSZ8041RNLI,
540 .phy_id_mask = 0x00fffff0,
541 .name = "Micrel KSZ8041RNLI",
542 .features = PHY_BASIC_FEATURES |
543 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
544 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000545 .config_init = kszphy_config_init_led8041,
Sergei Shtylyov4bd7b512013-12-10 02:20:41 +0300546 .config_aneg = genphy_config_aneg,
547 .read_status = genphy_read_status,
548 .ack_interrupt = kszphy_ack_interrupt,
549 .config_intr = kszphy_config_intr,
550 .suspend = genphy_suspend,
551 .resume = genphy_resume,
552 .driver = { .owner = THIS_MODULE,},
553}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000554 .phy_id = PHY_ID_KSZ8051,
Choi, David51f932c2010-06-28 15:23:41 +0000555 .phy_id_mask = 0x00fffff0,
Marek Vasut510d5732012-09-23 16:58:50 +0000556 .name = "Micrel KSZ8051",
Choi, David51f932c2010-06-28 15:23:41 +0000557 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
558 | SUPPORTED_Asym_Pause),
559 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Baruch Siachd606ef32011-02-14 02:05:33 +0000560 .config_init = ks8051_config_init,
Choi, David51f932c2010-06-28 15:23:41 +0000561 .config_aneg = genphy_config_aneg,
562 .read_status = genphy_read_status,
563 .ack_interrupt = kszphy_ack_interrupt,
564 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200565 .suspend = genphy_suspend,
566 .resume = genphy_resume,
Choi, David51f932c2010-06-28 15:23:41 +0000567 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000568}, {
Marek Vasut510d5732012-09-23 16:58:50 +0000569 .phy_id = PHY_ID_KSZ8001,
570 .name = "Micrel KSZ8001 or KS8721",
Jason Wang48d7d0a2012-06-17 22:52:09 +0000571 .phy_id_mask = 0x00ffffff,
Choi, David51f932c2010-06-28 15:23:41 +0000572 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
573 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Ben Dooks20d84352014-02-26 11:48:00 +0000574 .config_init = kszphy_config_init_led8041,
Choi, David51f932c2010-06-28 15:23:41 +0000575 .config_aneg = genphy_config_aneg,
576 .read_status = genphy_read_status,
577 .ack_interrupt = kszphy_ack_interrupt,
578 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200579 .suspend = genphy_suspend,
580 .resume = genphy_resume,
David J. Choid0507002010-04-29 06:12:41 +0000581 .driver = { .owner = THIS_MODULE,},
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000582}, {
David J. Choi7ab59dc2013-01-23 14:05:15 +0000583 .phy_id = PHY_ID_KSZ8081,
584 .name = "Micrel KSZ8081 or KSZ8091",
585 .phy_id_mask = 0x00fffff0,
586 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
587 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
588 .config_init = kszphy_config_init,
589 .config_aneg = genphy_config_aneg,
590 .read_status = genphy_read_status,
591 .ack_interrupt = kszphy_ack_interrupt,
592 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200593 .suspend = genphy_suspend,
594 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000595 .driver = { .owner = THIS_MODULE,},
596}, {
597 .phy_id = PHY_ID_KSZ8061,
598 .name = "Micrel KSZ8061",
599 .phy_id_mask = 0x00fffff0,
600 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
601 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
602 .config_init = kszphy_config_init,
603 .config_aneg = genphy_config_aneg,
604 .read_status = genphy_read_status,
605 .ack_interrupt = kszphy_ack_interrupt,
606 .config_intr = kszphy_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200607 .suspend = genphy_suspend,
608 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000609 .driver = { .owner = THIS_MODULE,},
610}, {
David J. Choid0507002010-04-29 06:12:41 +0000611 .phy_id = PHY_ID_KSZ9021,
Jason Wang48d7d0a2012-06-17 22:52:09 +0000612 .phy_id_mask = 0x000ffffe,
David J. Choid0507002010-04-29 06:12:41 +0000613 .name = "Micrel KSZ9021 Gigabit PHY",
Vlastimil Kosar32fcafb2013-02-28 08:45:22 +0000614 .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
Choi, David51f932c2010-06-28 15:23:41 +0000615 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Sean Cross954c3962013-08-21 01:46:12 +0000616 .config_init = ksz9021_config_init,
David J. Choid0507002010-04-29 06:12:41 +0000617 .config_aneg = genphy_config_aneg,
618 .read_status = genphy_read_status,
Choi, David51f932c2010-06-28 15:23:41 +0000619 .ack_interrupt = kszphy_ack_interrupt,
620 .config_intr = ksz9021_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200621 .suspend = genphy_suspend,
622 .resume = genphy_resume,
Vince Bridgers19936942014-07-29 15:19:58 -0500623 .read_mmd_indirect = ksz9021_rd_mmd_phyreg,
624 .write_mmd_indirect = ksz9021_wr_mmd_phyreg,
David J. Choid0507002010-04-29 06:12:41 +0000625 .driver = { .owner = THIS_MODULE, },
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000626}, {
David J. Choi7ab59dc2013-01-23 14:05:15 +0000627 .phy_id = PHY_ID_KSZ9031,
628 .phy_id_mask = 0x00fffff0,
629 .name = "Micrel KSZ9031 Gigabit PHY",
Mike Looijmans95e8b102014-09-15 12:06:33 +0200630 .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause),
David J. Choi7ab59dc2013-01-23 14:05:15 +0000631 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
Hubert Chaumette6e4b8272014-05-06 09:40:17 +0200632 .config_init = ksz9031_config_init,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000633 .config_aneg = genphy_config_aneg,
634 .read_status = genphy_read_status,
635 .ack_interrupt = kszphy_ack_interrupt,
636 .config_intr = ksz9021_config_intr,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200637 .suspend = genphy_suspend,
638 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000639 .driver = { .owner = THIS_MODULE, },
640}, {
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000641 .phy_id = PHY_ID_KSZ8873MLL,
642 .phy_id_mask = 0x00fffff0,
643 .name = "Micrel KSZ8873MLL Switch",
644 .features = (SUPPORTED_Pause | SUPPORTED_Asym_Pause),
645 .flags = PHY_HAS_MAGICANEG,
646 .config_init = kszphy_config_init,
647 .config_aneg = ksz8873mll_config_aneg,
648 .read_status = ksz8873mll_read_status,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200649 .suspend = genphy_suspend,
650 .resume = genphy_resume,
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000651 .driver = { .owner = THIS_MODULE, },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000652}, {
653 .phy_id = PHY_ID_KSZ886X,
654 .phy_id_mask = 0x00fffff0,
655 .name = "Micrel KSZ886X Switch",
656 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
657 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
658 .config_init = kszphy_config_init,
659 .config_aneg = genphy_config_aneg,
660 .read_status = genphy_read_status,
Patrice Vilchez1a5465f2013-09-19 19:40:48 +0200661 .suspend = genphy_suspend,
662 .resume = genphy_resume,
David J. Choi7ab59dc2013-01-23 14:05:15 +0000663 .driver = { .owner = THIS_MODULE, },
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000664} };
David J. Choid0507002010-04-29 06:12:41 +0000665
Johan Hovold50fd7152014-11-11 19:45:59 +0100666module_phy_driver(ksphy_driver);
David J. Choid0507002010-04-29 06:12:41 +0000667
668MODULE_DESCRIPTION("Micrel PHY driver");
669MODULE_AUTHOR("David J. Choi");
670MODULE_LICENSE("GPL");
David S. Miller52a60ed2010-05-03 15:48:29 -0700671
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +0000672static struct mdio_device_id __maybe_unused micrel_tbl[] = {
Jason Wang48d7d0a2012-06-17 22:52:09 +0000673 { PHY_ID_KSZ9021, 0x000ffffe },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000674 { PHY_ID_KSZ9031, 0x00fffff0 },
Marek Vasut510d5732012-09-23 16:58:50 +0000675 { PHY_ID_KSZ8001, 0x00ffffff },
Choi, David51f932c2010-06-28 15:23:41 +0000676 { PHY_ID_KS8737, 0x00fffff0 },
Marek Vasut212ea992012-09-23 16:58:49 +0000677 { PHY_ID_KSZ8021, 0x00ffffff },
Hector Palaciosb818d1a2013-03-10 22:50:02 +0000678 { PHY_ID_KSZ8031, 0x00ffffff },
Marek Vasut510d5732012-09-23 16:58:50 +0000679 { PHY_ID_KSZ8041, 0x00fffff0 },
680 { PHY_ID_KSZ8051, 0x00fffff0 },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000681 { PHY_ID_KSZ8061, 0x00fffff0 },
682 { PHY_ID_KSZ8081, 0x00fffff0 },
Jean-Christophe PLAGNIOL-VILLARD93272e02012-11-21 05:38:07 +0000683 { PHY_ID_KSZ8873MLL, 0x00fffff0 },
David J. Choi7ab59dc2013-01-23 14:05:15 +0000684 { PHY_ID_KSZ886X, 0x00fffff0 },
David S. Miller52a60ed2010-05-03 15:48:29 -0700685 { }
686};
687
688MODULE_DEVICE_TABLE(mdio, micrel_tbl);