Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0+
  2/*
  3 * drivers/net/phy/smsc.c
  4 *
  5 * Driver for SMSC PHYs
  6 *
  7 * Author: Herbert Valerio Riedel
  8 *
  9 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
 10 *
 11 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@shawell.net
 12 *
 13 */
 14
 15#include <linux/clk.h>
 16#include <linux/kernel.h>
 17#include <linux/module.h>
 18#include <linux/mii.h>
 19#include <linux/ethtool.h>
 20#include <linux/of.h>
 21#include <linux/phy.h>
 22#include <linux/netdevice.h>
 23#include <linux/crc16.h>
 24#include <linux/etherdevice.h>
 25#include <linux/smscphy.h>
 26
 27/* Vendor-specific PHY Definitions */
 28/* EDPD NLP / crossover time configuration */
 29#define PHY_EDPD_CONFIG			16
 30#define PHY_EDPD_CONFIG_EXT_CROSSOVER_	0x0001
 31
 32/* Control/Status Indication Register */
 33#define SPECIAL_CTRL_STS		27
 34#define SPECIAL_CTRL_STS_OVRRD_AMDIX_	0x8000
 35#define SPECIAL_CTRL_STS_AMDIX_ENABLE_	0x4000
 36#define SPECIAL_CTRL_STS_AMDIX_STATE_	0x2000
 37
 38#define EDPD_MAX_WAIT_DFLT_MS		640
 39/* interval between phylib state machine runs in ms */
 40#define PHY_STATE_MACH_MS		1000
 41
 42struct smsc_hw_stat {
 43	const char *string;
 44	u8 reg;
 45	u8 bits;
 46};
 47
 48static struct smsc_hw_stat smsc_hw_stats[] = {
 49	{ "phy_symbol_errors", 26, 16},
 50};
 51
 52struct smsc_phy_priv {
 53	unsigned int edpd_enable:1;
 54	unsigned int edpd_mode_set_by_user:1;
 55	unsigned int edpd_max_wait_ms;
 56	bool wol_arp;
 57};
 58
 59static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 60{
 61	int rc = phy_read(phydev, MII_LAN83C185_ISF);
 62
 63	return rc < 0 ? rc : 0;
 64}
 65
 66int smsc_phy_config_intr(struct phy_device *phydev)
 67{
 
 
 68	int rc;
 69
 70	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
 71		rc = smsc_phy_ack_interrupt(phydev);
 72		if (rc)
 73			return rc;
 74
 75		rc = phy_write(phydev, MII_LAN83C185_IM,
 76			       MII_LAN83C185_ISF_INT_PHYLIB_EVENTS);
 
 
 77	} else {
 78		rc = phy_write(phydev, MII_LAN83C185_IM, 0);
 79		if (rc)
 80			return rc;
 81
 82		rc = smsc_phy_ack_interrupt(phydev);
 83	}
 84
 85	return rc < 0 ? rc : 0;
 86}
 87EXPORT_SYMBOL_GPL(smsc_phy_config_intr);
 88
 89static int smsc_phy_config_edpd(struct phy_device *phydev)
 90{
 91	struct smsc_phy_priv *priv = phydev->priv;
 92
 93	if (priv->edpd_enable)
 94		return phy_set_bits(phydev, MII_LAN83C185_CTRL_STATUS,
 95				    MII_LAN83C185_EDPWRDOWN);
 96	else
 97		return phy_clear_bits(phydev, MII_LAN83C185_CTRL_STATUS,
 98				      MII_LAN83C185_EDPWRDOWN);
 99}
100
101irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
102{
103	int irq_status;
 
 
104
105	irq_status = phy_read(phydev, MII_LAN83C185_ISF);
106	if (irq_status < 0) {
107		if (irq_status != -ENODEV)
108			phy_error(phydev);
109
110		return IRQ_NONE;
111	}
112
113	if (!(irq_status & MII_LAN83C185_ISF_INT_PHYLIB_EVENTS))
114		return IRQ_NONE;
115
116	phy_trigger_machine(phydev);
117
118	return IRQ_HANDLED;
119}
120EXPORT_SYMBOL_GPL(smsc_phy_handle_interrupt);
121
122int smsc_phy_config_init(struct phy_device *phydev)
123{
124	struct smsc_phy_priv *priv = phydev->priv;
 
125
126	if (!priv)
127		return 0;
128
129	/* don't use EDPD in irq mode except overridden by user */
130	if (!priv->edpd_mode_set_by_user && phydev->irq != PHY_POLL)
131		priv->edpd_enable = false;
 
 
 
 
 
 
 
132
133	return smsc_phy_config_edpd(phydev);
134}
135EXPORT_SYMBOL_GPL(smsc_phy_config_init);
136
137static int smsc_phy_reset(struct phy_device *phydev)
138{
139	int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
140	if (rc < 0)
141		return rc;
142
143	/* If the SMSC PHY is in power down mode, then set it
144	 * in all capable mode before using it.
145	 */
146	if ((rc & MII_LAN83C185_MODE_MASK) == MII_LAN83C185_MODE_POWERDOWN) {
147		/* set "all capable" mode */
148		rc |= MII_LAN83C185_MODE_ALL;
149		phy_write(phydev, MII_LAN83C185_SPECIAL_MODES, rc);
150	}
151
152	/* reset the phy */
153	return genphy_soft_reset(phydev);
154}
155
 
 
 
 
 
156static int lan87xx_config_aneg(struct phy_device *phydev)
157{
158	int rc;
159	int val;
160
161	switch (phydev->mdix_ctrl) {
162	case ETH_TP_MDI:
163		val = SPECIAL_CTRL_STS_OVRRD_AMDIX_;
164		break;
165	case ETH_TP_MDI_X:
166		val = SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
167			SPECIAL_CTRL_STS_AMDIX_STATE_;
168		break;
169	case ETH_TP_MDI_AUTO:
170		val = SPECIAL_CTRL_STS_AMDIX_ENABLE_;
171		break;
172	default:
173		return genphy_config_aneg(phydev);
174	}
175
176	rc = phy_read(phydev, SPECIAL_CTRL_STS);
177	if (rc < 0)
178		return rc;
179
180	rc &= ~(SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
181		SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
182		SPECIAL_CTRL_STS_AMDIX_STATE_);
183	rc |= val;
184	phy_write(phydev, SPECIAL_CTRL_STS, rc);
185
186	phydev->mdix = phydev->mdix_ctrl;
187	return genphy_config_aneg(phydev);
188}
189
190static int lan95xx_config_aneg_ext(struct phy_device *phydev)
191{
192	if (phydev->phy_id == 0x0007c0f0) { /* LAN9500A or LAN9505A */
193		/* Extend Manual AutoMDIX timer */
194		int rc = phy_set_bits(phydev, PHY_EDPD_CONFIG,
195				      PHY_EDPD_CONFIG_EXT_CROSSOVER_);
196
197		if (rc < 0)
198			return rc;
199	}
 
 
 
 
200
 
 
201	return lan87xx_config_aneg(phydev);
202}
203
204/*
205 * The LAN87xx suffers from rare absence of the ENERGYON-bit when Ethernet cable
206 * plugs in while LAN87xx is in Energy Detect Power-Down mode. This leads to
207 * unstable detection of plugging in Ethernet cable.
208 * This workaround disables Energy Detect Power-Down mode and waiting for
209 * response on link pulses to detect presence of plugged Ethernet cable.
210 * The Energy Detect Power-Down mode is enabled again in the end of procedure to
211 * save approximately 220 mW of power if cable is unplugged.
212 * The workaround is only applicable to poll mode. Energy Detect Power-Down may
213 * not be used in interrupt mode lest link change detection becomes unreliable.
214 */
215int lan87xx_read_status(struct phy_device *phydev)
216{
217	struct smsc_phy_priv *priv = phydev->priv;
218	int err;
219
220	err = genphy_read_status(phydev);
221	if (err)
222		return err;
223
224	if (!phydev->link && priv && priv->edpd_enable &&
225	    priv->edpd_max_wait_ms) {
226		unsigned int max_wait = priv->edpd_max_wait_ms * 1000;
227		int rc;
228
 
229		/* Disable EDPD to wake up PHY */
230		rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
231		if (rc < 0)
232			return rc;
233
234		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
235			       rc & ~MII_LAN83C185_EDPWRDOWN);
236		if (rc < 0)
237			return rc;
238
239		/* Wait max 640 ms to detect energy and the timeout is not
240		 * an actual error.
241		 */
242		read_poll_timeout(phy_read, rc,
243				  rc & MII_LAN83C185_ENERGYON || rc < 0,
244				  10000, max_wait, true, phydev,
245				  MII_LAN83C185_CTRL_STATUS);
246		if (rc < 0)
247			return rc;
248
249		/* Re-enable EDPD */
250		rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
251		if (rc < 0)
252			return rc;
253
254		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
255			       rc | MII_LAN83C185_EDPWRDOWN);
256		if (rc < 0)
257			return rc;
258	}
259
260	return err;
261}
262EXPORT_SYMBOL_GPL(lan87xx_read_status);
263
264static int lan874x_phy_config_init(struct phy_device *phydev)
265{
266	u16 val;
267	int rc;
268
269	/* Setup LED2/nINT/nPME pin to function as nPME.  May need user option
270	 * to use LED1/nINT/nPME.
271	 */
272	val = MII_LAN874X_PHY_PME2_SET;
273
274	/* The bits MII_LAN874X_PHY_WOL_PFDA_FR, MII_LAN874X_PHY_WOL_WUFR,
275	 * MII_LAN874X_PHY_WOL_MPR, and MII_LAN874X_PHY_WOL_BCAST_FR need to
276	 * be cleared to de-assert PME signal after a WoL event happens, but
277	 * using PME auto clear gets around that.
278	 */
279	val |= MII_LAN874X_PHY_PME_SELF_CLEAR;
280	rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR,
281			   val);
282	if (rc < 0)
283		return rc;
284
285	/* set nPME self clear delay time */
286	rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_MCFGR,
287			   MII_LAN874X_PHY_PME_SELF_CLEAR_DELAY);
288	if (rc < 0)
289		return rc;
290
291	return smsc_phy_config_init(phydev);
292}
293
294static void lan874x_get_wol(struct phy_device *phydev,
295			    struct ethtool_wolinfo *wol)
296{
297	struct smsc_phy_priv *priv = phydev->priv;
298	int rc;
299
300	wol->supported = (WAKE_UCAST | WAKE_BCAST | WAKE_MAGIC |
301			  WAKE_ARP | WAKE_MCAST);
302	wol->wolopts = 0;
303
304	rc = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR);
305	if (rc < 0)
306		return;
307
308	if (rc & MII_LAN874X_PHY_WOL_PFDAEN)
309		wol->wolopts |= WAKE_UCAST;
310
311	if (rc & MII_LAN874X_PHY_WOL_BCSTEN)
312		wol->wolopts |= WAKE_BCAST;
313
314	if (rc & MII_LAN874X_PHY_WOL_MPEN)
315		wol->wolopts |= WAKE_MAGIC;
316
317	if (rc & MII_LAN874X_PHY_WOL_WUEN) {
318		if (priv->wol_arp)
319			wol->wolopts |= WAKE_ARP;
320		else
321			wol->wolopts |= WAKE_MCAST;
322	}
323}
324
325static u16 smsc_crc16(const u8 *buffer, size_t len)
326{
327	return bitrev16(crc16(0xFFFF, buffer, len));
328}
329
330static int lan874x_chk_wol_pattern(const u8 pattern[], const u16 *mask,
331				   u8 len, u8 *data, u8 *datalen)
332{
333	size_t i, j, k;
334	int ret = 0;
335	u16 bits;
336
337	/* Pattern filtering can match up to 128 bytes of frame data.  There
338	 * are 8 registers to program the 16-bit masks, where each bit means
339	 * the byte will be compared.  The frame data will then go through a
340	 * CRC16 calculation for hardware comparison.  This helper function
341	 * makes sure only relevant frame data are included in this
342	 * calculation.  It provides a warning when the masks and expected
343	 * data size do not match.
344	 */
345	i = 0;
346	k = 0;
347	while (len > 0) {
348		bits = *mask;
349		for (j = 0; j < 16; j++, i++, len--) {
350			/* No more pattern. */
351			if (!len) {
352				/* The rest of bitmap is not empty. */
353				if (bits)
354					ret = i + 1;
355				break;
356			}
357			if (bits & 1)
358				data[k++] = pattern[i];
359			bits >>= 1;
360		}
361		mask++;
362	}
363	*datalen = k;
364	return ret;
365}
366
367static int lan874x_set_wol_pattern(struct phy_device *phydev, u16 val,
368				   const u8 data[], u8 datalen,
369				   const u16 *mask, u8 masklen)
370{
371	u16 crc, reg;
372	int rc;
373
374	/* Starting pattern offset is set before calling this function. */
375	val |= MII_LAN874X_PHY_WOL_FILTER_EN;
376	rc = phy_write_mmd(phydev, MDIO_MMD_PCS,
377			   MII_LAN874X_PHY_MMD_WOL_WUF_CFGA, val);
378	if (rc < 0)
379		return rc;
380
381	crc = smsc_crc16(data, datalen);
382	rc = phy_write_mmd(phydev, MDIO_MMD_PCS,
383			   MII_LAN874X_PHY_MMD_WOL_WUF_CFGB, crc);
384	if (rc < 0)
385		return rc;
386
387	masklen = (masklen + 15) & ~0xf;
388	reg = MII_LAN874X_PHY_MMD_WOL_WUF_MASK7;
389	while (masklen >= 16) {
390		rc = phy_write_mmd(phydev, MDIO_MMD_PCS, reg, *mask);
391		if (rc < 0)
392			return rc;
393		reg--;
394		mask++;
395		masklen -= 16;
396	}
397
398	/* Clear out the rest of mask registers. */
399	while (reg != MII_LAN874X_PHY_MMD_WOL_WUF_MASK0) {
400		phy_write_mmd(phydev, MDIO_MMD_PCS, reg, 0);
401		reg--;
402	}
403	return rc;
404}
405
406static int lan874x_set_wol(struct phy_device *phydev,
407			   struct ethtool_wolinfo *wol)
408{
409	struct net_device *ndev = phydev->attached_dev;
410	struct smsc_phy_priv *priv = phydev->priv;
411	u16 val, val_wucsr;
412	u8 data[128];
413	u8 datalen;
414	int rc;
415
416	/* lan874x has only one WoL filter pattern */
417	if ((wol->wolopts & (WAKE_ARP | WAKE_MCAST)) ==
418	    (WAKE_ARP | WAKE_MCAST)) {
419		phydev_info(phydev,
420			    "lan874x WoL supports one of ARP|MCAST at a time\n");
421		return -EOPNOTSUPP;
422	}
423
424	rc = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR);
425	if (rc < 0)
426		return rc;
427
428	val_wucsr = rc;
429
430	if (wol->wolopts & WAKE_UCAST)
431		val_wucsr |= MII_LAN874X_PHY_WOL_PFDAEN;
432	else
433		val_wucsr &= ~MII_LAN874X_PHY_WOL_PFDAEN;
434
435	if (wol->wolopts & WAKE_BCAST)
436		val_wucsr |= MII_LAN874X_PHY_WOL_BCSTEN;
437	else
438		val_wucsr &= ~MII_LAN874X_PHY_WOL_BCSTEN;
439
440	if (wol->wolopts & WAKE_MAGIC)
441		val_wucsr |= MII_LAN874X_PHY_WOL_MPEN;
442	else
443		val_wucsr &= ~MII_LAN874X_PHY_WOL_MPEN;
444
445	/* Need to use pattern matching */
446	if (wol->wolopts & (WAKE_ARP | WAKE_MCAST))
447		val_wucsr |= MII_LAN874X_PHY_WOL_WUEN;
448	else
449		val_wucsr &= ~MII_LAN874X_PHY_WOL_WUEN;
450
451	if (wol->wolopts & WAKE_ARP) {
452		const u8 pattern[2] = { 0x08, 0x06 };
453		const u16 mask[1] = { 0x0003 };
454
455		rc = lan874x_chk_wol_pattern(pattern, mask, 2, data,
456					     &datalen);
457		if (rc)
458			phydev_dbg(phydev, "pattern not valid at %d\n", rc);
459
460		/* Need to match broadcast destination address and provided
461		 * data pattern at offset 12.
462		 */
463		val = 12 | MII_LAN874X_PHY_WOL_FILTER_BCSTEN;
464		rc = lan874x_set_wol_pattern(phydev, val, data, datalen, mask,
465					     2);
466		if (rc < 0)
467			return rc;
468		priv->wol_arp = true;
469	}
470
471	if (wol->wolopts & WAKE_MCAST) {
472		/* Need to match multicast destination address. */
473		val = MII_LAN874X_PHY_WOL_FILTER_MCASTTEN;
474		rc = lan874x_set_wol_pattern(phydev, val, data, 0, NULL, 0);
475		if (rc < 0)
476			return rc;
477		priv->wol_arp = false;
478	}
479
480	if (wol->wolopts & (WAKE_MAGIC | WAKE_UCAST)) {
481		const u8 *mac = (const u8 *)ndev->dev_addr;
482		int i, reg;
483
484		reg = MII_LAN874X_PHY_MMD_WOL_RX_ADDRC;
485		for (i = 0; i < 6; i += 2, reg--) {
486			rc = phy_write_mmd(phydev, MDIO_MMD_PCS, reg,
487					   ((mac[i + 1] << 8) | mac[i]));
488			if (rc < 0)
489				return rc;
490		}
491	}
492
493	rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR,
494			   val_wucsr);
495	if (rc < 0)
496		return rc;
497
498	return 0;
499}
500
501static int smsc_get_sset_count(struct phy_device *phydev)
502{
503	return ARRAY_SIZE(smsc_hw_stats);
504}
505
506static void smsc_get_strings(struct phy_device *phydev, u8 *data)
507{
508	int i;
509
510	for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++)
511		ethtool_puts(&data, smsc_hw_stats[i].string);
 
 
512}
513
514static u64 smsc_get_stat(struct phy_device *phydev, int i)
515{
516	struct smsc_hw_stat stat = smsc_hw_stats[i];
517	int val;
518	u64 ret;
519
520	val = phy_read(phydev, stat.reg);
521	if (val < 0)
522		ret = U64_MAX;
523	else
524		ret = val;
525
526	return ret;
527}
528
529static void smsc_get_stats(struct phy_device *phydev,
530			   struct ethtool_stats *stats, u64 *data)
531{
532	int i;
533
534	for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++)
535		data[i] = smsc_get_stat(phydev, i);
536}
537
538static int smsc_phy_get_edpd(struct phy_device *phydev, u16 *edpd)
539{
540	struct smsc_phy_priv *priv = phydev->priv;
541
542	if (!priv)
543		return -EOPNOTSUPP;
544
545	if (!priv->edpd_enable)
546		*edpd = ETHTOOL_PHY_EDPD_DISABLE;
547	else if (!priv->edpd_max_wait_ms)
548		*edpd = ETHTOOL_PHY_EDPD_NO_TX;
549	else
550		*edpd = PHY_STATE_MACH_MS + priv->edpd_max_wait_ms;
551
552	return 0;
553}
554
555static int smsc_phy_set_edpd(struct phy_device *phydev, u16 edpd)
556{
557	struct smsc_phy_priv *priv = phydev->priv;
558
559	if (!priv)
560		return -EOPNOTSUPP;
561
562	switch (edpd) {
563	case ETHTOOL_PHY_EDPD_DISABLE:
564		priv->edpd_enable = false;
565		break;
566	case ETHTOOL_PHY_EDPD_NO_TX:
567		priv->edpd_enable = true;
568		priv->edpd_max_wait_ms = 0;
569		break;
570	case ETHTOOL_PHY_EDPD_DFLT_TX_MSECS:
571		edpd = PHY_STATE_MACH_MS + EDPD_MAX_WAIT_DFLT_MS;
572		fallthrough;
573	default:
574		if (phydev->irq != PHY_POLL)
575			return -EOPNOTSUPP;
576		if (edpd < PHY_STATE_MACH_MS || edpd > PHY_STATE_MACH_MS + 1000)
577			return -EINVAL;
578		priv->edpd_enable = true;
579		priv->edpd_max_wait_ms = edpd - PHY_STATE_MACH_MS;
580	}
581
582	priv->edpd_mode_set_by_user = true;
583
584	return smsc_phy_config_edpd(phydev);
585}
586
587int smsc_phy_get_tunable(struct phy_device *phydev,
588			 struct ethtool_tunable *tuna, void *data)
589{
590	switch (tuna->id) {
591	case ETHTOOL_PHY_EDPD:
592		return smsc_phy_get_edpd(phydev, data);
593	default:
594		return -EOPNOTSUPP;
595	}
596}
597EXPORT_SYMBOL_GPL(smsc_phy_get_tunable);
598
599int smsc_phy_set_tunable(struct phy_device *phydev,
600			 struct ethtool_tunable *tuna, const void *data)
601{
602	switch (tuna->id) {
603	case ETHTOOL_PHY_EDPD:
604		return smsc_phy_set_edpd(phydev, *(u16 *)data);
605	default:
606		return -EOPNOTSUPP;
607	}
608}
609EXPORT_SYMBOL_GPL(smsc_phy_set_tunable);
610
611int smsc_phy_probe(struct phy_device *phydev)
612{
613	struct device *dev = &phydev->mdio.dev;
 
614	struct smsc_phy_priv *priv;
615	struct clk *refclk;
616
617	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
618	if (!priv)
619		return -ENOMEM;
620
621	priv->edpd_enable = true;
622	priv->edpd_max_wait_ms = EDPD_MAX_WAIT_DFLT_MS;
623
624	if (device_property_present(dev, "smsc,disable-energy-detect"))
625		priv->edpd_enable = false;
626
627	phydev->priv = priv;
628
629	/* Make clk optional to keep DTB backward compatibility. */
630	refclk = devm_clk_get_optional_enabled(dev, NULL);
631	if (IS_ERR(refclk))
632		return dev_err_probe(dev, PTR_ERR(refclk),
633				     "Failed to request clock\n");
634
635	return clk_set_rate(refclk, 50 * 1000 * 1000);
 
 
 
 
 
 
 
 
 
 
636}
637EXPORT_SYMBOL_GPL(smsc_phy_probe);
638
639static struct phy_driver smsc_phy_driver[] = {
640{
641	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
642	.phy_id_mask	= 0xfffffff0,
643	.name		= "SMSC LAN83C185",
644
645	/* PHY_BASIC_FEATURES */
646
647	.probe		= smsc_phy_probe,
648
649	/* basic functions */
650	.config_init	= smsc_phy_config_init,
651	.soft_reset	= smsc_phy_reset,
652
653	/* IRQ related */
654	.config_intr	= smsc_phy_config_intr,
655	.handle_interrupt = smsc_phy_handle_interrupt,
656
657	.suspend	= genphy_suspend,
658	.resume		= genphy_resume,
659}, {
660	.phy_id		= 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
661	.phy_id_mask	= 0xfffffff0,
662	.name		= "SMSC LAN8187",
663
664	/* PHY_BASIC_FEATURES */
665
666	.probe		= smsc_phy_probe,
667
668	/* basic functions */
669	.config_init	= smsc_phy_config_init,
670	.soft_reset	= smsc_phy_reset,
671
672	/* IRQ related */
673	.config_intr	= smsc_phy_config_intr,
674	.handle_interrupt = smsc_phy_handle_interrupt,
675
676	/* Statistics */
677	.get_sset_count = smsc_get_sset_count,
678	.get_strings	= smsc_get_strings,
679	.get_stats	= smsc_get_stats,
680
681	.suspend	= genphy_suspend,
682	.resume		= genphy_resume,
683}, {
684	/* This covers internal PHY (phy_id: 0x0007C0C3) for
685	 * LAN9500 (PID: 0x9500), LAN9514 (PID: 0xec00), LAN9505 (PID: 0x9505)
686	 */
687	.phy_id		= 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
688	.phy_id_mask	= 0xfffffff0,
689	.name		= "SMSC LAN8700",
690
691	/* PHY_BASIC_FEATURES */
692
693	.probe		= smsc_phy_probe,
694
695	/* basic functions */
696	.read_status	= lan87xx_read_status,
697	.config_init	= smsc_phy_config_init,
698	.soft_reset	= smsc_phy_reset,
699	.config_aneg	= lan87xx_config_aneg,
700
701	/* IRQ related */
702	.config_intr	= smsc_phy_config_intr,
703	.handle_interrupt = smsc_phy_handle_interrupt,
704
705	/* Statistics */
706	.get_sset_count = smsc_get_sset_count,
707	.get_strings	= smsc_get_strings,
708	.get_stats	= smsc_get_stats,
709
710	.get_tunable	= smsc_phy_get_tunable,
711	.set_tunable	= smsc_phy_set_tunable,
712
713	.suspend	= genphy_suspend,
714	.resume		= genphy_resume,
715}, {
716	.phy_id		= 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
717	.phy_id_mask	= 0xfffffff0,
718	.name		= "SMSC LAN911x Internal PHY",
719
720	/* PHY_BASIC_FEATURES */
721
722	.probe		= smsc_phy_probe,
723
 
 
 
724	/* IRQ related */
725	.config_intr	= smsc_phy_config_intr,
726	.handle_interrupt = smsc_phy_handle_interrupt,
727
728	.suspend	= genphy_suspend,
729	.resume		= genphy_resume,
730}, {
731	/* This covers internal PHY (phy_id: 0x0007C0F0) for
732	 * LAN9500A (PID: 0x9E00), LAN9505A (PID: 0x9E01)
733	 */
734	.phy_id		= 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
735	.phy_id_mask	= 0xfffffff0,
736	.name		= "SMSC LAN8710/LAN8720",
737
738	/* PHY_BASIC_FEATURES */
739
740	.probe		= smsc_phy_probe,
 
741
742	/* basic functions */
743	.read_status	= lan87xx_read_status,
744	.config_init	= smsc_phy_config_init,
745	.soft_reset	= smsc_phy_reset,
746	.config_aneg	= lan95xx_config_aneg_ext,
747
748	/* IRQ related */
749	.config_intr	= smsc_phy_config_intr,
750	.handle_interrupt = smsc_phy_handle_interrupt,
751
752	/* Statistics */
753	.get_sset_count = smsc_get_sset_count,
754	.get_strings	= smsc_get_strings,
755	.get_stats	= smsc_get_stats,
756
757	.get_tunable	= smsc_phy_get_tunable,
758	.set_tunable	= smsc_phy_set_tunable,
759
760	.suspend	= genphy_suspend,
761	.resume		= genphy_resume,
762}, {
763	.phy_id		= 0x0007c110,
764	.phy_id_mask	= 0xfffffff0,
765	.name		= "SMSC LAN8740",
766
767	/* PHY_BASIC_FEATURES */
768	.flags		= PHY_RST_AFTER_CLK_EN,
769
770	.probe		= smsc_phy_probe,
771
772	/* basic functions */
773	.read_status	= lan87xx_read_status,
774	.config_init	= lan874x_phy_config_init,
775	.soft_reset	= smsc_phy_reset,
776
777	/* IRQ related */
778	.config_intr	= smsc_phy_config_intr,
779	.handle_interrupt = smsc_phy_handle_interrupt,
780
781	/* Statistics */
782	.get_sset_count = smsc_get_sset_count,
783	.get_strings	= smsc_get_strings,
784	.get_stats	= smsc_get_stats,
785
786	.get_tunable	= smsc_phy_get_tunable,
787	.set_tunable	= smsc_phy_set_tunable,
788
789	/* WoL */
790	.set_wol	= lan874x_set_wol,
791	.get_wol	= lan874x_get_wol,
792
793	.suspend	= genphy_suspend,
794	.resume		= genphy_resume,
795}, {
796	.phy_id		= 0x0007c130,	/* 0x0007c130 and 0x0007c131 */
797	/* This mask (0xfffffff2) is to differentiate from
798	 * LAN88xx (phy_id 0x0007c132)
799	 * and allows future phy_id revisions.
800	 */
801	.phy_id_mask	= 0xfffffff2,
802	.name		= "Microchip LAN8742",
803
804	/* PHY_BASIC_FEATURES */
805	.flags		= PHY_RST_AFTER_CLK_EN,
806
807	.probe		= smsc_phy_probe,
808
809	/* basic functions */
810	.read_status	= lan87xx_read_status,
811	.config_init	= lan874x_phy_config_init,
812	.soft_reset	= smsc_phy_reset,
813
814	/* IRQ related */
815	.config_intr	= smsc_phy_config_intr,
816	.handle_interrupt = smsc_phy_handle_interrupt,
817
818	/* Statistics */
819	.get_sset_count = smsc_get_sset_count,
820	.get_strings	= smsc_get_strings,
821	.get_stats	= smsc_get_stats,
822
823	.get_tunable	= smsc_phy_get_tunable,
824	.set_tunable	= smsc_phy_set_tunable,
825
826	/* WoL */
827	.set_wol	= lan874x_set_wol,
828	.get_wol	= lan874x_get_wol,
829
830	.suspend	= genphy_suspend,
831	.resume		= genphy_resume,
832} };
833
834module_phy_driver(smsc_phy_driver);
835
836MODULE_DESCRIPTION("SMSC PHY driver");
837MODULE_AUTHOR("Herbert Valerio Riedel");
838MODULE_LICENSE("GPL");
839
840static struct mdio_device_id __maybe_unused smsc_tbl[] = {
841	{ 0x0007c0a0, 0xfffffff0 },
842	{ 0x0007c0b0, 0xfffffff0 },
843	{ 0x0007c0c0, 0xfffffff0 },
844	{ 0x0007c0d0, 0xfffffff0 },
845	{ 0x0007c0f0, 0xfffffff0 },
846	{ 0x0007c110, 0xfffffff0 },
847	{ 0x0007c130, 0xfffffff2 },
848	{ }
849};
850
851MODULE_DEVICE_TABLE(mdio, smsc_tbl);
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0+
  2/*
  3 * drivers/net/phy/smsc.c
  4 *
  5 * Driver for SMSC PHYs
  6 *
  7 * Author: Herbert Valerio Riedel
  8 *
  9 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
 10 *
 11 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@shawell.net
 12 *
 13 */
 14
 15#include <linux/clk.h>
 16#include <linux/kernel.h>
 17#include <linux/module.h>
 18#include <linux/mii.h>
 19#include <linux/ethtool.h>
 20#include <linux/of.h>
 21#include <linux/phy.h>
 22#include <linux/netdevice.h>
 
 
 23#include <linux/smscphy.h>
 24
 25/* Vendor-specific PHY Definitions */
 26/* EDPD NLP / crossover time configuration */
 27#define PHY_EDPD_CONFIG			16
 28#define PHY_EDPD_CONFIG_EXT_CROSSOVER_	0x0001
 29
 30/* Control/Status Indication Register */
 31#define SPECIAL_CTRL_STS		27
 32#define SPECIAL_CTRL_STS_OVRRD_AMDIX_	0x8000
 33#define SPECIAL_CTRL_STS_AMDIX_ENABLE_	0x4000
 34#define SPECIAL_CTRL_STS_AMDIX_STATE_	0x2000
 35
 
 
 
 
 36struct smsc_hw_stat {
 37	const char *string;
 38	u8 reg;
 39	u8 bits;
 40};
 41
 42static struct smsc_hw_stat smsc_hw_stats[] = {
 43	{ "phy_symbol_errors", 26, 16},
 44};
 45
 46struct smsc_phy_priv {
 47	bool energy_enable;
 48	struct clk *refclk;
 
 
 49};
 50
 51static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 52{
 53	int rc = phy_read(phydev, MII_LAN83C185_ISF);
 54
 55	return rc < 0 ? rc : 0;
 56}
 57
 58static int smsc_phy_config_intr(struct phy_device *phydev)
 59{
 60	struct smsc_phy_priv *priv = phydev->priv;
 61	u16 intmask = 0;
 62	int rc;
 63
 64	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
 65		rc = smsc_phy_ack_interrupt(phydev);
 66		if (rc)
 67			return rc;
 68
 69		intmask = MII_LAN83C185_ISF_INT4 | MII_LAN83C185_ISF_INT6;
 70		if (priv->energy_enable)
 71			intmask |= MII_LAN83C185_ISF_INT7;
 72		rc = phy_write(phydev, MII_LAN83C185_IM, intmask);
 73	} else {
 74		rc = phy_write(phydev, MII_LAN83C185_IM, intmask);
 75		if (rc)
 76			return rc;
 77
 78		rc = smsc_phy_ack_interrupt(phydev);
 79	}
 80
 81	return rc < 0 ? rc : 0;
 82}
 
 83
 84static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
 85{
 86	int irq_status, irq_enabled;
 
 
 
 
 
 
 
 
 87
 88	irq_enabled = phy_read(phydev, MII_LAN83C185_IM);
 89	if (irq_enabled < 0) {
 90		phy_error(phydev);
 91		return IRQ_NONE;
 92	}
 93
 94	irq_status = phy_read(phydev, MII_LAN83C185_ISF);
 95	if (irq_status < 0) {
 96		phy_error(phydev);
 
 
 97		return IRQ_NONE;
 98	}
 99
100	if (!(irq_status & irq_enabled))
101		return IRQ_NONE;
102
103	phy_trigger_machine(phydev);
104
105	return IRQ_HANDLED;
106}
 
107
108static int smsc_phy_config_init(struct phy_device *phydev)
109{
110	struct smsc_phy_priv *priv = phydev->priv;
111	int rc;
112
113	if (!priv->energy_enable)
114		return 0;
115
116	rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
117
118	if (rc < 0)
119		return rc;
120
121	/* Enable energy detect mode for this SMSC Transceivers */
122	rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
123		       rc | MII_LAN83C185_EDPWRDOWN);
124	if (rc < 0)
125		return rc;
126
127	return smsc_phy_ack_interrupt(phydev);
128}
 
129
130static int smsc_phy_reset(struct phy_device *phydev)
131{
132	int rc = phy_read(phydev, MII_LAN83C185_SPECIAL_MODES);
133	if (rc < 0)
134		return rc;
135
136	/* If the SMSC PHY is in power down mode, then set it
137	 * in all capable mode before using it.
138	 */
139	if ((rc & MII_LAN83C185_MODE_MASK) == MII_LAN83C185_MODE_POWERDOWN) {
140		/* set "all capable" mode */
141		rc |= MII_LAN83C185_MODE_ALL;
142		phy_write(phydev, MII_LAN83C185_SPECIAL_MODES, rc);
143	}
144
145	/* reset the phy */
146	return genphy_soft_reset(phydev);
147}
148
149static int lan911x_config_init(struct phy_device *phydev)
150{
151	return smsc_phy_ack_interrupt(phydev);
152}
153
154static int lan87xx_config_aneg(struct phy_device *phydev)
155{
156	int rc;
157	int val;
158
159	switch (phydev->mdix_ctrl) {
160	case ETH_TP_MDI:
161		val = SPECIAL_CTRL_STS_OVRRD_AMDIX_;
162		break;
163	case ETH_TP_MDI_X:
164		val = SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
165			SPECIAL_CTRL_STS_AMDIX_STATE_;
166		break;
167	case ETH_TP_MDI_AUTO:
168		val = SPECIAL_CTRL_STS_AMDIX_ENABLE_;
169		break;
170	default:
171		return genphy_config_aneg(phydev);
172	}
173
174	rc = phy_read(phydev, SPECIAL_CTRL_STS);
175	if (rc < 0)
176		return rc;
177
178	rc &= ~(SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
179		SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
180		SPECIAL_CTRL_STS_AMDIX_STATE_);
181	rc |= val;
182	phy_write(phydev, SPECIAL_CTRL_STS, rc);
183
184	phydev->mdix = phydev->mdix_ctrl;
185	return genphy_config_aneg(phydev);
186}
187
188static int lan95xx_config_aneg_ext(struct phy_device *phydev)
189{
190	int rc;
 
 
 
191
192	if (phydev->phy_id != 0x0007c0f0) /* not (LAN9500A or LAN9505A) */
193		return lan87xx_config_aneg(phydev);
194
195	/* Extend Manual AutoMDIX timer */
196	rc = phy_read(phydev, PHY_EDPD_CONFIG);
197	if (rc < 0)
198		return rc;
199
200	rc |= PHY_EDPD_CONFIG_EXT_CROSSOVER_;
201	phy_write(phydev, PHY_EDPD_CONFIG, rc);
202	return lan87xx_config_aneg(phydev);
203}
204
205/*
206 * The LAN87xx suffers from rare absence of the ENERGYON-bit when Ethernet cable
207 * plugs in while LAN87xx is in Energy Detect Power-Down mode. This leads to
208 * unstable detection of plugging in Ethernet cable.
209 * This workaround disables Energy Detect Power-Down mode and waiting for
210 * response on link pulses to detect presence of plugged Ethernet cable.
211 * The Energy Detect Power-Down mode is enabled again in the end of procedure to
212 * save approximately 220 mW of power if cable is unplugged.
 
 
213 */
214static int lan87xx_read_status(struct phy_device *phydev)
215{
216	struct smsc_phy_priv *priv = phydev->priv;
 
217
218	int err = genphy_read_status(phydev);
 
 
 
 
 
 
 
219
220	if (!phydev->link && priv->energy_enable) {
221		/* Disable EDPD to wake up PHY */
222		int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
223		if (rc < 0)
224			return rc;
225
226		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
227			       rc & ~MII_LAN83C185_EDPWRDOWN);
228		if (rc < 0)
229			return rc;
230
231		/* Wait max 640 ms to detect energy and the timeout is not
232		 * an actual error.
233		 */
234		read_poll_timeout(phy_read, rc,
235				  rc & MII_LAN83C185_ENERGYON || rc < 0,
236				  10000, 640000, true, phydev,
237				  MII_LAN83C185_CTRL_STATUS);
238		if (rc < 0)
239			return rc;
240
241		/* Re-enable EDPD */
242		rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
243		if (rc < 0)
244			return rc;
245
246		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
247			       rc | MII_LAN83C185_EDPWRDOWN);
248		if (rc < 0)
249			return rc;
250	}
251
252	return err;
253}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
255static int smsc_get_sset_count(struct phy_device *phydev)
256{
257	return ARRAY_SIZE(smsc_hw_stats);
258}
259
260static void smsc_get_strings(struct phy_device *phydev, u8 *data)
261{
262	int i;
263
264	for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++) {
265		strncpy(data + i * ETH_GSTRING_LEN,
266		       smsc_hw_stats[i].string, ETH_GSTRING_LEN);
267	}
268}
269
270static u64 smsc_get_stat(struct phy_device *phydev, int i)
271{
272	struct smsc_hw_stat stat = smsc_hw_stats[i];
273	int val;
274	u64 ret;
275
276	val = phy_read(phydev, stat.reg);
277	if (val < 0)
278		ret = U64_MAX;
279	else
280		ret = val;
281
282	return ret;
283}
284
285static void smsc_get_stats(struct phy_device *phydev,
286			   struct ethtool_stats *stats, u64 *data)
287{
288	int i;
289
290	for (i = 0; i < ARRAY_SIZE(smsc_hw_stats); i++)
291		data[i] = smsc_get_stat(phydev, i);
292}
293
294static void smsc_phy_remove(struct phy_device *phydev)
295{
296	struct smsc_phy_priv *priv = phydev->priv;
297
298	clk_disable_unprepare(priv->refclk);
299	clk_put(priv->refclk);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300}
301
302static int smsc_phy_probe(struct phy_device *phydev)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303{
304	struct device *dev = &phydev->mdio.dev;
305	struct device_node *of_node = dev->of_node;
306	struct smsc_phy_priv *priv;
307	int ret;
308
309	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
310	if (!priv)
311		return -ENOMEM;
312
313	priv->energy_enable = true;
 
314
315	if (of_property_read_bool(of_node, "smsc,disable-energy-detect"))
316		priv->energy_enable = false;
317
318	phydev->priv = priv;
319
320	/* Make clk optional to keep DTB backward compatibility. */
321	priv->refclk = clk_get_optional(dev, NULL);
322	if (IS_ERR(priv->refclk))
323		return dev_err_probe(dev, PTR_ERR(priv->refclk),
324				     "Failed to request clock\n");
325
326	ret = clk_prepare_enable(priv->refclk);
327	if (ret)
328		return ret;
329
330	ret = clk_set_rate(priv->refclk, 50 * 1000 * 1000);
331	if (ret) {
332		clk_disable_unprepare(priv->refclk);
333		return ret;
334	}
335
336	return 0;
337}
 
338
339static struct phy_driver smsc_phy_driver[] = {
340{
341	.phy_id		= 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
342	.phy_id_mask	= 0xfffffff0,
343	.name		= "SMSC LAN83C185",
344
345	/* PHY_BASIC_FEATURES */
346
347	.probe		= smsc_phy_probe,
348
349	/* basic functions */
350	.config_init	= smsc_phy_config_init,
351	.soft_reset	= smsc_phy_reset,
352
353	/* IRQ related */
354	.config_intr	= smsc_phy_config_intr,
355	.handle_interrupt = smsc_phy_handle_interrupt,
356
357	.suspend	= genphy_suspend,
358	.resume		= genphy_resume,
359}, {
360	.phy_id		= 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
361	.phy_id_mask	= 0xfffffff0,
362	.name		= "SMSC LAN8187",
363
364	/* PHY_BASIC_FEATURES */
365
366	.probe		= smsc_phy_probe,
367
368	/* basic functions */
369	.config_init	= smsc_phy_config_init,
370	.soft_reset	= smsc_phy_reset,
371
372	/* IRQ related */
373	.config_intr	= smsc_phy_config_intr,
374	.handle_interrupt = smsc_phy_handle_interrupt,
375
376	/* Statistics */
377	.get_sset_count = smsc_get_sset_count,
378	.get_strings	= smsc_get_strings,
379	.get_stats	= smsc_get_stats,
380
381	.suspend	= genphy_suspend,
382	.resume		= genphy_resume,
383}, {
384	/* This covers internal PHY (phy_id: 0x0007C0C3) for
385	 * LAN9500 (PID: 0x9500), LAN9514 (PID: 0xec00), LAN9505 (PID: 0x9505)
386	 */
387	.phy_id		= 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
388	.phy_id_mask	= 0xfffffff0,
389	.name		= "SMSC LAN8700",
390
391	/* PHY_BASIC_FEATURES */
392
393	.probe		= smsc_phy_probe,
394
395	/* basic functions */
396	.read_status	= lan87xx_read_status,
397	.config_init	= smsc_phy_config_init,
398	.soft_reset	= smsc_phy_reset,
399	.config_aneg	= lan87xx_config_aneg,
400
401	/* IRQ related */
402	.config_intr	= smsc_phy_config_intr,
403	.handle_interrupt = smsc_phy_handle_interrupt,
404
405	/* Statistics */
406	.get_sset_count = smsc_get_sset_count,
407	.get_strings	= smsc_get_strings,
408	.get_stats	= smsc_get_stats,
409
 
 
 
410	.suspend	= genphy_suspend,
411	.resume		= genphy_resume,
412}, {
413	.phy_id		= 0x0007c0d0, /* OUI=0x00800f, Model#=0x0d */
414	.phy_id_mask	= 0xfffffff0,
415	.name		= "SMSC LAN911x Internal PHY",
416
417	/* PHY_BASIC_FEATURES */
418
419	.probe		= smsc_phy_probe,
420
421	/* basic functions */
422	.config_init	= lan911x_config_init,
423
424	/* IRQ related */
425	.config_intr	= smsc_phy_config_intr,
426	.handle_interrupt = smsc_phy_handle_interrupt,
427
428	.suspend	= genphy_suspend,
429	.resume		= genphy_resume,
430}, {
431	/* This covers internal PHY (phy_id: 0x0007C0F0) for
432	 * LAN9500A (PID: 0x9E00), LAN9505A (PID: 0x9E01)
433	 */
434	.phy_id		= 0x0007c0f0, /* OUI=0x00800f, Model#=0x0f */
435	.phy_id_mask	= 0xfffffff0,
436	.name		= "SMSC LAN8710/LAN8720",
437
438	/* PHY_BASIC_FEATURES */
439
440	.probe		= smsc_phy_probe,
441	.remove		= smsc_phy_remove,
442
443	/* basic functions */
444	.read_status	= lan87xx_read_status,
445	.config_init	= smsc_phy_config_init,
446	.soft_reset	= smsc_phy_reset,
447	.config_aneg	= lan95xx_config_aneg_ext,
448
449	/* IRQ related */
450	.config_intr	= smsc_phy_config_intr,
451	.handle_interrupt = smsc_phy_handle_interrupt,
452
453	/* Statistics */
454	.get_sset_count = smsc_get_sset_count,
455	.get_strings	= smsc_get_strings,
456	.get_stats	= smsc_get_stats,
457
 
 
 
458	.suspend	= genphy_suspend,
459	.resume		= genphy_resume,
460}, {
461	.phy_id		= 0x0007c110,
462	.phy_id_mask	= 0xfffffff0,
463	.name		= "SMSC LAN8740",
464
465	/* PHY_BASIC_FEATURES */
466	.flags		= PHY_RST_AFTER_CLK_EN,
467
468	.probe		= smsc_phy_probe,
469
470	/* basic functions */
471	.read_status	= lan87xx_read_status,
472	.config_init	= smsc_phy_config_init,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473	.soft_reset	= smsc_phy_reset,
474
475	/* IRQ related */
476	.config_intr	= smsc_phy_config_intr,
477	.handle_interrupt = smsc_phy_handle_interrupt,
478
479	/* Statistics */
480	.get_sset_count = smsc_get_sset_count,
481	.get_strings	= smsc_get_strings,
482	.get_stats	= smsc_get_stats,
483
 
 
 
 
 
 
 
484	.suspend	= genphy_suspend,
485	.resume		= genphy_resume,
486} };
487
488module_phy_driver(smsc_phy_driver);
489
490MODULE_DESCRIPTION("SMSC PHY driver");
491MODULE_AUTHOR("Herbert Valerio Riedel");
492MODULE_LICENSE("GPL");
493
494static struct mdio_device_id __maybe_unused smsc_tbl[] = {
495	{ 0x0007c0a0, 0xfffffff0 },
496	{ 0x0007c0b0, 0xfffffff0 },
497	{ 0x0007c0c0, 0xfffffff0 },
498	{ 0x0007c0d0, 0xfffffff0 },
499	{ 0x0007c0f0, 0xfffffff0 },
500	{ 0x0007c110, 0xfffffff0 },
 
501	{ }
502};
503
504MODULE_DEVICE_TABLE(mdio, smsc_tbl);