blob: aba4e4c1f75c660b01a15b3a8dee56bb9ee8d831 [file] [log] [blame]
Andrew Lunn5f857572019-01-21 19:10:19 +01001// SPDX-License-Identifier: GPL-2.0
Dan Murphy753c66e2020-09-03 14:51:12 -05002/* Driver for the Texas Instruments DP83867 PHY
Dan Murphy2a101542015-06-02 09:34:37 -05003 *
4 * Copyright (C) 2015 Texas Instruments Inc.
Dan Murphy2a101542015-06-02 09:34:37 -05005 */
6
7#include <linux/ethtool.h>
8#include <linux/kernel.h>
9#include <linux/mii.h>
10#include <linux/module.h>
11#include <linux/of.h>
12#include <linux/phy.h>
Max Uvarov72a7d452019-02-25 12:15:10 +030013#include <linux/delay.h>
Thomas Haemmerlecaabee52019-10-28 08:08:14 +000014#include <linux/netdevice.h>
15#include <linux/etherdevice.h>
Dan Murphycd26d722020-02-18 08:11:30 -060016#include <linux/bitfield.h>
Dan Murphy2a101542015-06-02 09:34:37 -050017
18#include <dt-bindings/net/ti-dp83867.h>
19
20#define DP83867_PHY_ID 0x2000a231
21#define DP83867_DEVADDR 0x1f
22
23#define MII_DP83867_PHYCTRL 0x10
Dan Murphycd26d722020-02-18 08:11:30 -060024#define MII_DP83867_PHYSTS 0x11
Dan Murphy2a101542015-06-02 09:34:37 -050025#define MII_DP83867_MICR 0x12
26#define MII_DP83867_ISR 0x13
Thomas Haemmerlecaabee52019-10-28 08:08:14 +000027#define DP83867_CFG2 0x14
Grygorii Strashko5ca7d1c2017-01-05 14:48:07 -060028#define DP83867_CFG3 0x1e
Thomas Haemmerlecaabee52019-10-28 08:08:14 +000029#define DP83867_CTRL 0x1f
Dan Murphy2a101542015-06-02 09:34:37 -050030
31/* Extended Registers */
Grygorii Strashko749f6f62020-03-17 20:04:54 +020032#define DP83867_FLD_THR_CFG 0x002e
33#define DP83867_CFG4 0x0031
Max Uvarov1a97a472019-05-28 13:00:50 +030034#define DP83867_CFG4_SGMII_ANEG_MASK (BIT(5) | BIT(6))
35#define DP83867_CFG4_SGMII_ANEG_TIMER_11MS (3 << 5)
36#define DP83867_CFG4_SGMII_ANEG_TIMER_800US (2 << 5)
37#define DP83867_CFG4_SGMII_ANEG_TIMER_2US (1 << 5)
38#define DP83867_CFG4_SGMII_ANEG_TIMER_16MS (0 << 5)
39
Dan Murphy2a101542015-06-02 09:34:37 -050040#define DP83867_RGMIICTL 0x0032
Lukasz Majewskiac6e0582017-02-07 06:20:24 +010041#define DP83867_STRAP_STS1 0x006E
Trent Piephoc11669a2019-05-22 18:43:23 +000042#define DP83867_STRAP_STS2 0x006f
Dan Murphy2a101542015-06-02 09:34:37 -050043#define DP83867_RGMIIDCTL 0x0086
Thomas Haemmerlecaabee52019-10-28 08:08:14 +000044#define DP83867_RXFCFG 0x0134
45#define DP83867_RXFPMD1 0x0136
46#define DP83867_RXFPMD2 0x0137
47#define DP83867_RXFPMD3 0x0138
48#define DP83867_RXFSOP1 0x0139
49#define DP83867_RXFSOP2 0x013A
50#define DP83867_RXFSOP3 0x013B
Mugunthan V Ned838fe2016-10-18 16:50:18 +053051#define DP83867_IO_MUX_CFG 0x0170
Vitaly Gaiduk507ddd52019-09-09 20:19:24 +030052#define DP83867_SGMIICTL 0x00D3
Max Uvarov333061b2019-05-28 13:00:49 +030053#define DP83867_10M_SGMII_CFG 0x016F
54#define DP83867_10M_SGMII_RATE_ADAPT_MASK BIT(7)
Dan Murphy2a101542015-06-02 09:34:37 -050055
56#define DP83867_SW_RESET BIT(15)
57#define DP83867_SW_RESTART BIT(14)
58
59/* MICR Interrupt bits */
60#define MII_DP83867_MICR_AN_ERR_INT_EN BIT(15)
61#define MII_DP83867_MICR_SPEED_CHNG_INT_EN BIT(14)
62#define MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN BIT(13)
63#define MII_DP83867_MICR_PAGE_RXD_INT_EN BIT(12)
64#define MII_DP83867_MICR_AUTONEG_COMP_INT_EN BIT(11)
65#define MII_DP83867_MICR_LINK_STS_CHNG_INT_EN BIT(10)
66#define MII_DP83867_MICR_FALSE_CARRIER_INT_EN BIT(8)
67#define MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN BIT(4)
68#define MII_DP83867_MICR_WOL_INT_EN BIT(3)
69#define MII_DP83867_MICR_XGMII_ERR_INT_EN BIT(2)
70#define MII_DP83867_MICR_POL_CHNG_INT_EN BIT(1)
71#define MII_DP83867_MICR_JABBER_INT_EN BIT(0)
72
73/* RGMIICTL bits */
74#define DP83867_RGMII_TX_CLK_DELAY_EN BIT(1)
75#define DP83867_RGMII_RX_CLK_DELAY_EN BIT(0)
76
Vitaly Gaiduk507ddd52019-09-09 20:19:24 +030077/* SGMIICTL bits */
78#define DP83867_SGMII_TYPE BIT(14)
79
Thomas Haemmerlecaabee52019-10-28 08:08:14 +000080/* RXFCFG bits*/
81#define DP83867_WOL_MAGIC_EN BIT(0)
82#define DP83867_WOL_BCAST_EN BIT(2)
83#define DP83867_WOL_UCAST_EN BIT(4)
84#define DP83867_WOL_SEC_EN BIT(5)
85#define DP83867_WOL_ENH_MAC BIT(7)
86
Lukasz Majewskiac6e0582017-02-07 06:20:24 +010087/* STRAP_STS1 bits */
88#define DP83867_STRAP_STS1_RESERVED BIT(11)
89
Trent Piephoc11669a2019-05-22 18:43:23 +000090/* STRAP_STS2 bits */
91#define DP83867_STRAP_STS2_CLK_SKEW_TX_MASK GENMASK(6, 4)
92#define DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT 4
93#define DP83867_STRAP_STS2_CLK_SKEW_RX_MASK GENMASK(2, 0)
94#define DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT 0
95#define DP83867_STRAP_STS2_CLK_SKEW_NONE BIT(2)
Grygorii Strashko749f6f62020-03-17 20:04:54 +020096#define DP83867_STRAP_STS2_STRAP_FLD BIT(10)
Trent Piephoc11669a2019-05-22 18:43:23 +000097
Dan Murphy2a101542015-06-02 09:34:37 -050098/* PHY CTRL bits */
Dan Murphye02d1812019-12-09 14:10:25 -060099#define DP83867_PHYCR_TX_FIFO_DEPTH_SHIFT 14
100#define DP83867_PHYCR_RX_FIFO_DEPTH_SHIFT 12
Trent Piephof8bbf412019-05-22 18:43:26 +0000101#define DP83867_PHYCR_FIFO_DEPTH_MAX 0x03
Dan Murphye02d1812019-12-09 14:10:25 -0600102#define DP83867_PHYCR_TX_FIFO_DEPTH_MASK GENMASK(15, 14)
103#define DP83867_PHYCR_RX_FIFO_DEPTH_MASK GENMASK(13, 12)
Lukasz Majewskiac6e0582017-02-07 06:20:24 +0100104#define DP83867_PHYCR_RESERVED_MASK BIT(11)
Michael Grzeschik86ffe922020-01-16 14:16:31 +0100105#define DP83867_PHYCR_FORCE_LINK_GOOD BIT(10)
Dan Murphy2a101542015-06-02 09:34:37 -0500106
107/* RGMIIDCTL bits */
Trent Piephoc11669a2019-05-22 18:43:23 +0000108#define DP83867_RGMII_TX_CLK_DELAY_MAX 0xf
Dan Murphy2a101542015-06-02 09:34:37 -0500109#define DP83867_RGMII_TX_CLK_DELAY_SHIFT 4
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200110#define DP83867_RGMII_TX_CLK_DELAY_INV (DP83867_RGMII_TX_CLK_DELAY_MAX + 1)
Trent Piephoc11669a2019-05-22 18:43:23 +0000111#define DP83867_RGMII_RX_CLK_DELAY_MAX 0xf
112#define DP83867_RGMII_RX_CLK_DELAY_SHIFT 0
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200113#define DP83867_RGMII_RX_CLK_DELAY_INV (DP83867_RGMII_RX_CLK_DELAY_MAX + 1)
114
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530115/* IO_MUX_CFG bits */
Trent Piepho27708eb2019-05-22 18:43:25 +0000116#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK 0x1f
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530117#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0
118#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f
Trent Piepho13c83cf2019-05-22 18:43:22 +0000119#define DP83867_IO_MUX_CFG_CLK_O_DISABLE BIT(6)
Wadim Egorov9708fb62018-02-14 17:07:11 +0100120#define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK (0x1f << 8)
121#define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT 8
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530122
Dan Murphycd26d722020-02-18 08:11:30 -0600123/* PHY STS bits */
124#define DP83867_PHYSTS_1000 BIT(15)
125#define DP83867_PHYSTS_100 BIT(14)
126#define DP83867_PHYSTS_DUPLEX BIT(13)
127#define DP83867_PHYSTS_LINK BIT(10)
128
129/* CFG2 bits */
130#define DP83867_DOWNSHIFT_EN (BIT(8) | BIT(9))
131#define DP83867_DOWNSHIFT_ATTEMPT_MASK (BIT(10) | BIT(11))
132#define DP83867_DOWNSHIFT_1_COUNT_VAL 0
133#define DP83867_DOWNSHIFT_2_COUNT_VAL 1
134#define DP83867_DOWNSHIFT_4_COUNT_VAL 2
135#define DP83867_DOWNSHIFT_8_COUNT_VAL 3
136#define DP83867_DOWNSHIFT_1_COUNT 1
137#define DP83867_DOWNSHIFT_2_COUNT 2
138#define DP83867_DOWNSHIFT_4_COUNT 4
139#define DP83867_DOWNSHIFT_8_COUNT 8
140
Grygorii Strashko5a7f08c2019-10-23 17:48:45 +0300141/* CFG3 bits */
142#define DP83867_CFG3_INT_OE BIT(7)
143#define DP83867_CFG3_ROBUST_AUTO_MDIX BIT(9)
144
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100145/* CFG4 bits */
146#define DP83867_CFG4_PORT_MIRROR_EN BIT(0)
147
Grygorii Strashko749f6f62020-03-17 20:04:54 +0200148/* FLD_THR_CFG */
149#define DP83867_FLD_THR_CFG_ENERGY_LOST_THR_MASK 0x7
150
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100151enum {
152 DP83867_PORT_MIRROING_KEEP,
153 DP83867_PORT_MIRROING_EN,
154 DP83867_PORT_MIRROING_DIS,
155};
156
Dan Murphy2a101542015-06-02 09:34:37 -0500157struct dp83867_private {
Trent Piepho1b9b2952019-05-22 18:43:24 +0000158 u32 rx_id_delay;
159 u32 tx_id_delay;
Dan Murphye02d1812019-12-09 14:10:25 -0600160 u32 tx_fifo_depth;
161 u32 rx_fifo_depth;
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530162 int io_impedance;
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100163 int port_mirroring;
Murali Karicheri37144472017-07-04 16:23:24 +0530164 bool rxctrl_strap_quirk;
Trent Piepho13c83cf2019-05-22 18:43:22 +0000165 bool set_clk_output;
166 u32 clk_output_sel;
Vitaly Gaiduk507ddd52019-09-09 20:19:24 +0300167 bool sgmii_ref_clk_en;
Dan Murphy2a101542015-06-02 09:34:37 -0500168};
169
170static int dp83867_ack_interrupt(struct phy_device *phydev)
171{
172 int err = phy_read(phydev, MII_DP83867_ISR);
173
174 if (err < 0)
175 return err;
176
177 return 0;
178}
179
Thomas Haemmerlecaabee52019-10-28 08:08:14 +0000180static int dp83867_set_wol(struct phy_device *phydev,
181 struct ethtool_wolinfo *wol)
182{
183 struct net_device *ndev = phydev->attached_dev;
184 u16 val_rxcfg, val_micr;
185 u8 *mac;
186
187 val_rxcfg = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG);
188 val_micr = phy_read(phydev, MII_DP83867_MICR);
189
190 if (wol->wolopts & (WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_UCAST |
191 WAKE_BCAST)) {
192 val_rxcfg |= DP83867_WOL_ENH_MAC;
193 val_micr |= MII_DP83867_MICR_WOL_INT_EN;
194
195 if (wol->wolopts & WAKE_MAGIC) {
196 mac = (u8 *)ndev->dev_addr;
197
198 if (!is_valid_ether_addr(mac))
199 return -EINVAL;
200
201 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFPMD1,
202 (mac[1] << 8 | mac[0]));
203 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFPMD2,
204 (mac[3] << 8 | mac[2]));
205 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFPMD3,
206 (mac[5] << 8 | mac[4]));
207
208 val_rxcfg |= DP83867_WOL_MAGIC_EN;
209 } else {
210 val_rxcfg &= ~DP83867_WOL_MAGIC_EN;
211 }
212
213 if (wol->wolopts & WAKE_MAGICSECURE) {
214 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP1,
215 (wol->sopass[1] << 8) | wol->sopass[0]);
Dan Murphy8b4a11c2020-09-02 14:27:04 -0500216 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP2,
Thomas Haemmerlecaabee52019-10-28 08:08:14 +0000217 (wol->sopass[3] << 8) | wol->sopass[2]);
Dan Murphy8b4a11c2020-09-02 14:27:04 -0500218 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP3,
Thomas Haemmerlecaabee52019-10-28 08:08:14 +0000219 (wol->sopass[5] << 8) | wol->sopass[4]);
220
221 val_rxcfg |= DP83867_WOL_SEC_EN;
222 } else {
223 val_rxcfg &= ~DP83867_WOL_SEC_EN;
224 }
225
226 if (wol->wolopts & WAKE_UCAST)
227 val_rxcfg |= DP83867_WOL_UCAST_EN;
228 else
229 val_rxcfg &= ~DP83867_WOL_UCAST_EN;
230
231 if (wol->wolopts & WAKE_BCAST)
232 val_rxcfg |= DP83867_WOL_BCAST_EN;
233 else
234 val_rxcfg &= ~DP83867_WOL_BCAST_EN;
235 } else {
236 val_rxcfg &= ~DP83867_WOL_ENH_MAC;
237 val_micr &= ~MII_DP83867_MICR_WOL_INT_EN;
238 }
239
240 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG, val_rxcfg);
241 phy_write(phydev, MII_DP83867_MICR, val_micr);
242
243 return 0;
244}
245
246static void dp83867_get_wol(struct phy_device *phydev,
247 struct ethtool_wolinfo *wol)
248{
249 u16 value, sopass_val;
250
251 wol->supported = (WAKE_UCAST | WAKE_BCAST | WAKE_MAGIC |
252 WAKE_MAGICSECURE);
253 wol->wolopts = 0;
254
255 value = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RXFCFG);
256
257 if (value & DP83867_WOL_UCAST_EN)
258 wol->wolopts |= WAKE_UCAST;
259
260 if (value & DP83867_WOL_BCAST_EN)
261 wol->wolopts |= WAKE_BCAST;
262
263 if (value & DP83867_WOL_MAGIC_EN)
264 wol->wolopts |= WAKE_MAGIC;
265
266 if (value & DP83867_WOL_SEC_EN) {
267 sopass_val = phy_read_mmd(phydev, DP83867_DEVADDR,
268 DP83867_RXFSOP1);
269 wol->sopass[0] = (sopass_val & 0xff);
270 wol->sopass[1] = (sopass_val >> 8);
271
272 sopass_val = phy_read_mmd(phydev, DP83867_DEVADDR,
273 DP83867_RXFSOP2);
274 wol->sopass[2] = (sopass_val & 0xff);
275 wol->sopass[3] = (sopass_val >> 8);
276
277 sopass_val = phy_read_mmd(phydev, DP83867_DEVADDR,
278 DP83867_RXFSOP3);
279 wol->sopass[4] = (sopass_val & 0xff);
280 wol->sopass[5] = (sopass_val >> 8);
281
282 wol->wolopts |= WAKE_MAGICSECURE;
283 }
284
285 if (!(value & DP83867_WOL_ENH_MAC))
286 wol->wolopts = 0;
287}
288
Dan Murphy2a101542015-06-02 09:34:37 -0500289static int dp83867_config_intr(struct phy_device *phydev)
290{
291 int micr_status;
292
293 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
294 micr_status = phy_read(phydev, MII_DP83867_MICR);
295 if (micr_status < 0)
296 return micr_status;
297
298 micr_status |=
299 (MII_DP83867_MICR_AN_ERR_INT_EN |
300 MII_DP83867_MICR_SPEED_CHNG_INT_EN |
Grygorii Strashko5ca7d1c2017-01-05 14:48:07 -0600301 MII_DP83867_MICR_AUTONEG_COMP_INT_EN |
302 MII_DP83867_MICR_LINK_STS_CHNG_INT_EN |
Dan Murphy2a101542015-06-02 09:34:37 -0500303 MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN |
304 MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN);
305
306 return phy_write(phydev, MII_DP83867_MICR, micr_status);
307 }
308
309 micr_status = 0x0;
310 return phy_write(phydev, MII_DP83867_MICR, micr_status);
311}
312
Ioana Ciornei1d1ae3c2020-11-23 17:38:13 +0200313static irqreturn_t dp83867_handle_interrupt(struct phy_device *phydev)
314{
315 int irq_status, irq_enabled;
316
317 irq_status = phy_read(phydev, MII_DP83867_ISR);
318 if (irq_status < 0) {
319 phy_error(phydev);
320 return IRQ_NONE;
321 }
322
323 irq_enabled = phy_read(phydev, MII_DP83867_MICR);
324 if (irq_enabled < 0) {
325 phy_error(phydev);
326 return IRQ_NONE;
327 }
328
329 if (!(irq_status & irq_enabled))
330 return IRQ_NONE;
331
332 phy_trigger_machine(phydev);
333
334 return IRQ_HANDLED;
335}
336
Dan Murphycd26d722020-02-18 08:11:30 -0600337static int dp83867_read_status(struct phy_device *phydev)
338{
339 int status = phy_read(phydev, MII_DP83867_PHYSTS);
340 int ret;
341
342 ret = genphy_read_status(phydev);
343 if (ret)
344 return ret;
345
346 if (status < 0)
347 return status;
348
349 if (status & DP83867_PHYSTS_DUPLEX)
350 phydev->duplex = DUPLEX_FULL;
351 else
352 phydev->duplex = DUPLEX_HALF;
353
354 if (status & DP83867_PHYSTS_1000)
355 phydev->speed = SPEED_1000;
356 else if (status & DP83867_PHYSTS_100)
357 phydev->speed = SPEED_100;
358 else
359 phydev->speed = SPEED_10;
360
361 return 0;
362}
363
364static int dp83867_get_downshift(struct phy_device *phydev, u8 *data)
365{
366 int val, cnt, enable, count;
367
368 val = phy_read(phydev, DP83867_CFG2);
369 if (val < 0)
370 return val;
371
372 enable = FIELD_GET(DP83867_DOWNSHIFT_EN, val);
373 cnt = FIELD_GET(DP83867_DOWNSHIFT_ATTEMPT_MASK, val);
374
375 switch (cnt) {
376 case DP83867_DOWNSHIFT_1_COUNT_VAL:
377 count = DP83867_DOWNSHIFT_1_COUNT;
378 break;
379 case DP83867_DOWNSHIFT_2_COUNT_VAL:
380 count = DP83867_DOWNSHIFT_2_COUNT;
381 break;
382 case DP83867_DOWNSHIFT_4_COUNT_VAL:
383 count = DP83867_DOWNSHIFT_4_COUNT;
384 break;
385 case DP83867_DOWNSHIFT_8_COUNT_VAL:
386 count = DP83867_DOWNSHIFT_8_COUNT;
387 break;
388 default:
389 return -EINVAL;
Zheng Bindce38b72020-04-24 17:08:50 +0800390 }
Dan Murphycd26d722020-02-18 08:11:30 -0600391
392 *data = enable ? count : DOWNSHIFT_DEV_DISABLE;
393
394 return 0;
395}
396
397static int dp83867_set_downshift(struct phy_device *phydev, u8 cnt)
398{
399 int val, count;
400
401 if (cnt > DP83867_DOWNSHIFT_8_COUNT)
402 return -E2BIG;
403
404 if (!cnt)
405 return phy_clear_bits(phydev, DP83867_CFG2,
406 DP83867_DOWNSHIFT_EN);
407
408 switch (cnt) {
Dan Murphy753c66e2020-09-03 14:51:12 -0500409 case DP83867_DOWNSHIFT_1_COUNT:
410 count = DP83867_DOWNSHIFT_1_COUNT_VAL;
411 break;
412 case DP83867_DOWNSHIFT_2_COUNT:
413 count = DP83867_DOWNSHIFT_2_COUNT_VAL;
414 break;
415 case DP83867_DOWNSHIFT_4_COUNT:
416 count = DP83867_DOWNSHIFT_4_COUNT_VAL;
417 break;
418 case DP83867_DOWNSHIFT_8_COUNT:
419 count = DP83867_DOWNSHIFT_8_COUNT_VAL;
420 break;
421 default:
422 phydev_err(phydev,
423 "Downshift count must be 1, 2, 4 or 8\n");
424 return -EINVAL;
Zheng Bindce38b72020-04-24 17:08:50 +0800425 }
Dan Murphycd26d722020-02-18 08:11:30 -0600426
427 val = DP83867_DOWNSHIFT_EN;
428 val |= FIELD_PREP(DP83867_DOWNSHIFT_ATTEMPT_MASK, count);
429
430 return phy_modify(phydev, DP83867_CFG2,
431 DP83867_DOWNSHIFT_EN | DP83867_DOWNSHIFT_ATTEMPT_MASK,
432 val);
433}
434
435static int dp83867_get_tunable(struct phy_device *phydev,
Dan Murphy753c66e2020-09-03 14:51:12 -0500436 struct ethtool_tunable *tuna, void *data)
Dan Murphycd26d722020-02-18 08:11:30 -0600437{
438 switch (tuna->id) {
439 case ETHTOOL_PHY_DOWNSHIFT:
440 return dp83867_get_downshift(phydev, data);
441 default:
442 return -EOPNOTSUPP;
443 }
444}
445
446static int dp83867_set_tunable(struct phy_device *phydev,
Dan Murphy753c66e2020-09-03 14:51:12 -0500447 struct ethtool_tunable *tuna, const void *data)
Dan Murphycd26d722020-02-18 08:11:30 -0600448{
449 switch (tuna->id) {
450 case ETHTOOL_PHY_DOWNSHIFT:
451 return dp83867_set_downshift(phydev, *(const u8 *)data);
452 default:
453 return -EOPNOTSUPP;
454 }
455}
456
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100457static int dp83867_config_port_mirroring(struct phy_device *phydev)
458{
459 struct dp83867_private *dp83867 =
460 (struct dp83867_private *)phydev->priv;
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100461
462 if (dp83867->port_mirroring == DP83867_PORT_MIRROING_EN)
Heiner Kallweitb52c0182019-02-06 07:38:43 +0100463 phy_set_bits_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4,
464 DP83867_CFG4_PORT_MIRROR_EN);
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100465 else
Heiner Kallweitb52c0182019-02-06 07:38:43 +0100466 phy_clear_bits_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4,
467 DP83867_CFG4_PORT_MIRROR_EN);
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100468 return 0;
469}
470
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200471static int dp83867_verify_rgmii_cfg(struct phy_device *phydev)
472{
473 struct dp83867_private *dp83867 = phydev->priv;
474
475 /* Existing behavior was to use default pin strapping delay in rgmii
476 * mode, but rgmii should have meant no delay. Warn existing users.
477 */
478 if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
479 const u16 val = phy_read_mmd(phydev, DP83867_DEVADDR,
480 DP83867_STRAP_STS2);
481 const u16 txskew = (val & DP83867_STRAP_STS2_CLK_SKEW_TX_MASK) >>
482 DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT;
483 const u16 rxskew = (val & DP83867_STRAP_STS2_CLK_SKEW_RX_MASK) >>
484 DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT;
485
486 if (txskew != DP83867_STRAP_STS2_CLK_SKEW_NONE ||
487 rxskew != DP83867_STRAP_STS2_CLK_SKEW_NONE)
488 phydev_warn(phydev,
489 "PHY has delays via pin strapping, but phy-mode = 'rgmii'\n"
490 "Should be 'rgmii-id' to use internal delays txskew:%x rxskew:%x\n",
491 txskew, rxskew);
492 }
493
494 /* RX delay *must* be specified if internal delay of RX is used. */
495 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
496 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) &&
497 dp83867->rx_id_delay == DP83867_RGMII_RX_CLK_DELAY_INV) {
498 phydev_err(phydev, "ti,rx-internal-delay must be specified\n");
499 return -EINVAL;
500 }
501
502 /* TX delay *must* be specified if internal delay of TX is used. */
503 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
504 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) &&
505 dp83867->tx_id_delay == DP83867_RGMII_TX_CLK_DELAY_INV) {
506 phydev_err(phydev, "ti,tx-internal-delay must be specified\n");
507 return -EINVAL;
508 }
509
510 return 0;
511}
512
Dan Murphy506de002020-06-05 09:01:05 -0500513#if IS_ENABLED(CONFIG_OF_MDIO)
Dan Murphy2a101542015-06-02 09:34:37 -0500514static int dp83867_of_init(struct phy_device *phydev)
515{
516 struct dp83867_private *dp83867 = phydev->priv;
Andrew Lunne5a03bf2016-01-06 20:11:16 +0100517 struct device *dev = &phydev->mdio.dev;
Dan Murphy2a101542015-06-02 09:34:37 -0500518 struct device_node *of_node = dev->of_node;
519 int ret;
520
Andrew Lunn7bf9ae02015-12-07 04:38:58 +0100521 if (!of_node)
Dan Murphy2a101542015-06-02 09:34:37 -0500522 return -ENODEV;
523
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530524 /* Optional configuration */
Wadim Egorov9708fb62018-02-14 17:07:11 +0100525 ret = of_property_read_u32(of_node, "ti,clk-output-sel",
526 &dp83867->clk_output_sel);
Trent Piepho13c83cf2019-05-22 18:43:22 +0000527 /* If not set, keep default */
528 if (!ret) {
529 dp83867->set_clk_output = true;
530 /* Valid values are 0 to DP83867_CLK_O_SEL_REF_CLK or
531 * DP83867_CLK_O_SEL_OFF.
Wadim Egorov9708fb62018-02-14 17:07:11 +0100532 */
Trent Piepho13c83cf2019-05-22 18:43:22 +0000533 if (dp83867->clk_output_sel > DP83867_CLK_O_SEL_REF_CLK &&
534 dp83867->clk_output_sel != DP83867_CLK_O_SEL_OFF) {
535 phydev_err(phydev, "ti,clk-output-sel value %u out of range\n",
536 dp83867->clk_output_sel);
537 return -EINVAL;
538 }
539 }
Wadim Egorov9708fb62018-02-14 17:07:11 +0100540
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530541 if (of_property_read_bool(of_node, "ti,max-output-impedance"))
542 dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
543 else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
544 dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN;
Trent Piepho27708eb2019-05-22 18:43:25 +0000545 else
546 dp83867->io_impedance = -1; /* leave at default */
Mugunthan V Ned838fe2016-10-18 16:50:18 +0530547
Murali Karicheri37144472017-07-04 16:23:24 +0530548 dp83867->rxctrl_strap_quirk = of_property_read_bool(of_node,
Dan Murphy753c66e2020-09-03 14:51:12 -0500549 "ti,dp83867-rxctrl-strap-quirk");
Murali Karicheri37144472017-07-04 16:23:24 +0530550
Vitaly Gaiduk507ddd52019-09-09 20:19:24 +0300551 dp83867->sgmii_ref_clk_en = of_property_read_bool(of_node,
Dan Murphy753c66e2020-09-03 14:51:12 -0500552 "ti,sgmii-ref-clock-output-enable");
Dan Murphy2a101542015-06-02 09:34:37 -0500553
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200554 dp83867->rx_id_delay = DP83867_RGMII_RX_CLK_DELAY_INV;
555 ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
556 &dp83867->rx_id_delay);
557 if (!ret && dp83867->rx_id_delay > DP83867_RGMII_RX_CLK_DELAY_MAX) {
558 phydev_err(phydev,
559 "ti,rx-internal-delay value of %u out of range\n",
560 dp83867->rx_id_delay);
561 return -EINVAL;
Trent Piephoc11669a2019-05-22 18:43:23 +0000562 }
563
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200564 dp83867->tx_id_delay = DP83867_RGMII_TX_CLK_DELAY_INV;
565 ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
566 &dp83867->tx_id_delay);
567 if (!ret && dp83867->tx_id_delay > DP83867_RGMII_TX_CLK_DELAY_MAX) {
568 phydev_err(phydev,
569 "ti,tx-internal-delay value of %u out of range\n",
570 dp83867->tx_id_delay);
571 return -EINVAL;
Trent Piephoc11669a2019-05-22 18:43:23 +0000572 }
Dan Murphy2a101542015-06-02 09:34:37 -0500573
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100574 if (of_property_read_bool(of_node, "enet-phy-lane-swap"))
575 dp83867->port_mirroring = DP83867_PORT_MIRROING_EN;
576
577 if (of_property_read_bool(of_node, "enet-phy-lane-no-swap"))
578 dp83867->port_mirroring = DP83867_PORT_MIRROING_DIS;
579
Trent Piephof8bbf412019-05-22 18:43:26 +0000580 ret = of_property_read_u32(of_node, "ti,fifo-depth",
Dan Murphye02d1812019-12-09 14:10:25 -0600581 &dp83867->tx_fifo_depth);
Trent Piephof8bbf412019-05-22 18:43:26 +0000582 if (ret) {
Dan Murphye02d1812019-12-09 14:10:25 -0600583 ret = of_property_read_u32(of_node, "tx-fifo-depth",
584 &dp83867->tx_fifo_depth);
585 if (ret)
586 dp83867->tx_fifo_depth =
587 DP83867_PHYCR_FIFO_DEPTH_4_B_NIB;
Trent Piephof8bbf412019-05-22 18:43:26 +0000588 }
Dan Murphye02d1812019-12-09 14:10:25 -0600589
590 if (dp83867->tx_fifo_depth > DP83867_PHYCR_FIFO_DEPTH_MAX) {
591 phydev_err(phydev, "tx-fifo-depth value %u out of range\n",
592 dp83867->tx_fifo_depth);
Trent Piephof8bbf412019-05-22 18:43:26 +0000593 return -EINVAL;
594 }
Dan Murphye02d1812019-12-09 14:10:25 -0600595
596 ret = of_property_read_u32(of_node, "rx-fifo-depth",
597 &dp83867->rx_fifo_depth);
598 if (ret)
599 dp83867->rx_fifo_depth = DP83867_PHYCR_FIFO_DEPTH_4_B_NIB;
600
601 if (dp83867->rx_fifo_depth > DP83867_PHYCR_FIFO_DEPTH_MAX) {
602 phydev_err(phydev, "rx-fifo-depth value %u out of range\n",
603 dp83867->rx_fifo_depth);
604 return -EINVAL;
605 }
606
Trent Piephof8bbf412019-05-22 18:43:26 +0000607 return 0;
Dan Murphy2a101542015-06-02 09:34:37 -0500608}
609#else
610static int dp83867_of_init(struct phy_device *phydev)
611{
612 return 0;
613}
614#endif /* CONFIG_OF_MDIO */
615
Trent Piepho565d9d22019-05-22 18:43:27 +0000616static int dp83867_probe(struct phy_device *phydev)
Dan Murphy2a101542015-06-02 09:34:37 -0500617{
618 struct dp83867_private *dp83867;
Trent Piepho565d9d22019-05-22 18:43:27 +0000619
620 dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867),
621 GFP_KERNEL);
622 if (!dp83867)
623 return -ENOMEM;
624
625 phydev->priv = dp83867;
626
Grygorii Strashkoef87f7d2019-10-23 17:48:46 +0300627 return dp83867_of_init(phydev);
Trent Piepho565d9d22019-05-22 18:43:27 +0000628}
629
630static int dp83867_config_init(struct phy_device *phydev)
631{
632 struct dp83867_private *dp83867 = phydev->priv;
Lukasz Majewskiac6e0582017-02-07 06:20:24 +0100633 int ret, val, bs;
Stefan Hauserb291c412016-07-01 22:35:03 +0200634 u16 delay;
Dan Murphy2a101542015-06-02 09:34:37 -0500635
Dan Murphycd26d722020-02-18 08:11:30 -0600636 /* Force speed optimization for the PHY even if it strapped */
637 ret = phy_modify(phydev, DP83867_CFG2, DP83867_DOWNSHIFT_EN,
638 DP83867_DOWNSHIFT_EN);
639 if (ret)
640 return ret;
641
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200642 ret = dp83867_verify_rgmii_cfg(phydev);
643 if (ret)
644 return ret;
645
Murali Karicheri37144472017-07-04 16:23:24 +0530646 /* RX_DV/RX_CTRL strapped in mode 1 or mode 2 workaround */
Heiner Kallweitb52c0182019-02-06 07:38:43 +0100647 if (dp83867->rxctrl_strap_quirk)
648 phy_clear_bits_mmd(phydev, DP83867_DEVADDR, DP83867_CFG4,
649 BIT(7));
Murali Karicheri37144472017-07-04 16:23:24 +0530650
Grygorii Strashko749f6f62020-03-17 20:04:54 +0200651 bs = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_STRAP_STS2);
652 if (bs & DP83867_STRAP_STS2_STRAP_FLD) {
653 /* When using strap to enable FLD, the ENERGY_LOST_FLD_THR will
654 * be set to 0x2. This may causes the PHY link to be unstable -
655 * the default value 0x1 need to be restored.
656 */
657 ret = phy_modify_mmd(phydev, DP83867_DEVADDR,
658 DP83867_FLD_THR_CFG,
659 DP83867_FLD_THR_CFG_ENERGY_LOST_THR_MASK,
660 0x1);
661 if (ret)
662 return ret;
663 }
664
Dan Murphye02d1812019-12-09 14:10:25 -0600665 if (phy_interface_is_rgmii(phydev) ||
666 phydev->interface == PHY_INTERFACE_MODE_SGMII) {
667 val = phy_read(phydev, MII_DP83867_PHYCTRL);
668 if (val < 0)
669 return val;
670
671 val &= ~DP83867_PHYCR_TX_FIFO_DEPTH_MASK;
672 val |= (dp83867->tx_fifo_depth <<
673 DP83867_PHYCR_TX_FIFO_DEPTH_SHIFT);
674
675 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
676 val &= ~DP83867_PHYCR_RX_FIFO_DEPTH_MASK;
677 val |= (dp83867->rx_fifo_depth <<
678 DP83867_PHYCR_RX_FIFO_DEPTH_SHIFT);
679 }
680
681 ret = phy_write(phydev, MII_DP83867_PHYCTRL, val);
682 if (ret)
683 return ret;
684 }
685
Dan Murphy2a101542015-06-02 09:34:37 -0500686 if (phy_interface_is_rgmii(phydev)) {
Stefan Hauserb291c412016-07-01 22:35:03 +0200687 val = phy_read(phydev, MII_DP83867_PHYCTRL);
688 if (val < 0)
689 return val;
Lukasz Majewskiac6e0582017-02-07 06:20:24 +0100690
691 /* The code below checks if "port mirroring" N/A MODE4 has been
692 * enabled during power on bootstrap.
693 *
694 * Such N/A mode enabled by mistake can put PHY IC in some
695 * internal testing mode and disable RGMII transmission.
696 *
697 * In this particular case one needs to check STRAP_STS1
698 * register's bit 11 (marked as RESERVED).
699 */
700
Russell Kinga6d99fc2017-03-21 16:36:53 +0000701 bs = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_STRAP_STS1);
Lukasz Majewskiac6e0582017-02-07 06:20:24 +0100702 if (bs & DP83867_STRAP_STS1_RESERVED)
703 val &= ~DP83867_PHYCR_RESERVED_MASK;
704
Stefan Hauserb291c412016-07-01 22:35:03 +0200705 ret = phy_write(phydev, MII_DP83867_PHYCTRL, val);
Dan Murphy2a101542015-06-02 09:34:37 -0500706 if (ret)
707 return ret;
Dan Murphy2a101542015-06-02 09:34:37 -0500708
David S. Millerb4b12b02019-05-31 10:49:43 -0700709 /* If rgmii mode with no internal delay is selected, we do NOT use
710 * aligned mode as one might expect. Instead we use the PHY's default
711 * based on pin strapping. And the "mode 0" default is to *use*
712 * internal delay with a value of 7 (2.00 ns).
713 *
714 * Set up RGMII delays
715 */
Russell Kinga6d99fc2017-03-21 16:36:53 +0000716 val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIICTL);
Dan Murphy2a101542015-06-02 09:34:37 -0500717
Trent Piephoc11669a2019-05-22 18:43:23 +0000718 val &= ~(DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN);
Dan Murphy2a101542015-06-02 09:34:37 -0500719 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
720 val |= (DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN);
721
722 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
723 val |= DP83867_RGMII_TX_CLK_DELAY_EN;
724
725 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
726 val |= DP83867_RGMII_RX_CLK_DELAY_EN;
727
Russell Kinga6d99fc2017-03-21 16:36:53 +0000728 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIICTL, val);
Dan Murphy2a101542015-06-02 09:34:37 -0500729
Grygorii Strashkofafc5db2019-12-06 14:34:32 +0200730 delay = 0;
731 if (dp83867->rx_id_delay != DP83867_RGMII_RX_CLK_DELAY_INV)
732 delay |= dp83867->rx_id_delay;
733 if (dp83867->tx_id_delay != DP83867_RGMII_TX_CLK_DELAY_INV)
734 delay |= dp83867->tx_id_delay <<
735 DP83867_RGMII_TX_CLK_DELAY_SHIFT;
Dan Murphy2a101542015-06-02 09:34:37 -0500736
Russell Kinga6d99fc2017-03-21 16:36:53 +0000737 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIIDCTL,
738 delay);
Dan Murphy2a101542015-06-02 09:34:37 -0500739 }
740
Trent Piepho27708eb2019-05-22 18:43:25 +0000741 /* If specified, set io impedance */
742 if (dp83867->io_impedance >= 0)
743 phy_modify_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG,
744 DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK,
745 dp83867->io_impedance);
746
Max Uvarov333061b2019-05-28 13:00:49 +0300747 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
748 /* For support SPEED_10 in SGMII mode
749 * DP83867_10M_SGMII_RATE_ADAPT bit
750 * has to be cleared by software. That
751 * does not affect SPEED_100 and
752 * SPEED_1000.
753 */
754 ret = phy_modify_mmd(phydev, DP83867_DEVADDR,
755 DP83867_10M_SGMII_CFG,
756 DP83867_10M_SGMII_RATE_ADAPT_MASK,
757 0);
758 if (ret)
759 return ret;
Max Uvarov1a97a472019-05-28 13:00:50 +0300760
761 /* After reset SGMII Autoneg timer is set to 2us (bits 6 and 5
762 * are 01). That is not enough to finalize autoneg on some
763 * devices. Increase this timer duration to maximum 16ms.
764 */
765 ret = phy_modify_mmd(phydev, DP83867_DEVADDR,
766 DP83867_CFG4,
767 DP83867_CFG4_SGMII_ANEG_MASK,
768 DP83867_CFG4_SGMII_ANEG_TIMER_16MS);
769
770 if (ret)
771 return ret;
Vitaly Gaiduk507ddd52019-09-09 20:19:24 +0300772
773 val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_SGMIICTL);
774 /* SGMII type is set to 4-wire mode by default.
775 * If we place appropriate property in dts (see above)
776 * switch on 6-wire mode.
777 */
778 if (dp83867->sgmii_ref_clk_en)
779 val |= DP83867_SGMII_TYPE;
780 else
781 val &= ~DP83867_SGMII_TYPE;
782 phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_SGMIICTL, val);
Max Uvarov333061b2019-05-28 13:00:49 +0300783 }
784
Grygorii Strashko5a7f08c2019-10-23 17:48:45 +0300785 val = phy_read(phydev, DP83867_CFG3);
Grygorii Strashko5ca7d1c2017-01-05 14:48:07 -0600786 /* Enable Interrupt output INT_OE in CFG3 register */
Grygorii Strashko5a7f08c2019-10-23 17:48:45 +0300787 if (phy_interrupt_is_valid(phydev))
788 val |= DP83867_CFG3_INT_OE;
789
790 val |= DP83867_CFG3_ROBUST_AUTO_MDIX;
791 phy_write(phydev, DP83867_CFG3, val);
Grygorii Strashko5ca7d1c2017-01-05 14:48:07 -0600792
Lukasz Majewskifc6d39c2017-02-07 06:20:23 +0100793 if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
794 dp83867_config_port_mirroring(phydev);
795
Wadim Egorov9708fb62018-02-14 17:07:11 +0100796 /* Clock output selection if muxing property is set */
Trent Piepho13c83cf2019-05-22 18:43:22 +0000797 if (dp83867->set_clk_output) {
798 u16 mask = DP83867_IO_MUX_CFG_CLK_O_DISABLE;
799
800 if (dp83867->clk_output_sel == DP83867_CLK_O_SEL_OFF) {
801 val = DP83867_IO_MUX_CFG_CLK_O_DISABLE;
802 } else {
803 mask |= DP83867_IO_MUX_CFG_CLK_O_SEL_MASK;
804 val = dp83867->clk_output_sel <<
805 DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT;
806 }
807
Heiner Kallweitb52c0182019-02-06 07:38:43 +0100808 phy_modify_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG,
Trent Piepho13c83cf2019-05-22 18:43:22 +0000809 mask, val);
810 }
Wadim Egorov9708fb62018-02-14 17:07:11 +0100811
Dan Murphy2a101542015-06-02 09:34:37 -0500812 return 0;
813}
814
815static int dp83867_phy_reset(struct phy_device *phydev)
816{
817 int err;
818
819 err = phy_write(phydev, DP83867_CTRL, DP83867_SW_RESET);
820 if (err < 0)
821 return err;
822
Max Uvarov72a7d452019-02-25 12:15:10 +0300823 usleep_range(10, 20);
824
Michael Grzeschik86ffe922020-01-16 14:16:31 +0100825 /* After reset FORCE_LINK_GOOD bit is set. Although the
826 * default value should be unset. Disable FORCE_LINK_GOOD
827 * for the phy to work properly.
828 */
829 return phy_modify(phydev, MII_DP83867_PHYCTRL,
830 DP83867_PHYCR_FORCE_LINK_GOOD, 0);
Dan Murphy2a101542015-06-02 09:34:37 -0500831}
832
833static struct phy_driver dp83867_driver[] = {
834 {
835 .phy_id = DP83867_PHY_ID,
836 .phy_id_mask = 0xfffffff0,
837 .name = "TI DP83867",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200838 /* PHY_GBIT_FEATURES */
Dan Murphy2a101542015-06-02 09:34:37 -0500839
Trent Piepho565d9d22019-05-22 18:43:27 +0000840 .probe = dp83867_probe,
Dan Murphy2a101542015-06-02 09:34:37 -0500841 .config_init = dp83867_config_init,
842 .soft_reset = dp83867_phy_reset,
843
Dan Murphycd26d722020-02-18 08:11:30 -0600844 .read_status = dp83867_read_status,
845 .get_tunable = dp83867_get_tunable,
846 .set_tunable = dp83867_set_tunable,
847
Thomas Haemmerlecaabee52019-10-28 08:08:14 +0000848 .get_wol = dp83867_get_wol,
849 .set_wol = dp83867_set_wol,
850
Dan Murphy2a101542015-06-02 09:34:37 -0500851 /* IRQ related */
852 .ack_interrupt = dp83867_ack_interrupt,
853 .config_intr = dp83867_config_intr,
Ioana Ciornei1d1ae3c2020-11-23 17:38:13 +0200854 .handle_interrupt = dp83867_handle_interrupt,
Dan Murphy2a101542015-06-02 09:34:37 -0500855
Dan Murphy2a101542015-06-02 09:34:37 -0500856 .suspend = genphy_suspend,
857 .resume = genphy_resume,
Dan Murphy2a101542015-06-02 09:34:37 -0500858 },
859};
860module_phy_driver(dp83867_driver);
861
862static struct mdio_device_id __maybe_unused dp83867_tbl[] = {
863 { DP83867_PHY_ID, 0xfffffff0 },
864 { }
865};
866
867MODULE_DEVICE_TABLE(mdio, dp83867_tbl);
868
869MODULE_DESCRIPTION("Texas Instruments DP83867 PHY driver");
870MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com");
Andrew Lunn5f857572019-01-21 19:10:19 +0100871MODULE_LICENSE("GPL v2");