Commit Graph

40 Commits

Author SHA1 Message Date
msaitoh 9589449d9e Retry autonegotiation every mii_anegticks seconds instead of mii_anegticks+1. 2023-02-22 08:09:09 +00:00
riastradh 03dbe12f0c urlphy(4): Fix missing mii locking in urlphy_attach. 2022-01-08 17:35:05 +00:00
msaitoh 1d6d3e383e Remove extra PHY_RESET(sc) in the MII_TICK path because it's not requierd
to just restart autonego.
2020-08-24 04:49:05 +00:00
msaitoh 600be1acda Don't do full initialization for autonego when just restarting autonego
because it's not required.

 This change reduce extra initialization which include PHY_RESET() which
caused long delay(max 500ms).
2020-08-24 04:23:41 +00:00
msaitoh d245628f58 - Remove the waitfor argument from mii_phy_auto().
- Whitespace fix.
2020-07-07 08:44:12 +00:00
msaitoh 509697f3cf - Simplify sc->mii_anegticks setting. Same as FreeBSD.
Don't set the default value not in the attach function. Instead, set the
  default value (MII_ANEGTICKS) first in the beginning of the
  mii_phy_add_media(). The function already has the code to change the value to
  MII_ANEGTICKS_GIGE if it's gigabit capable.

- Remove extra pmf_device_register() call. It's done in mii_phy_add_media().
2019-11-27 10:19:20 +00:00
msaitoh 8e65e83118 KNF. No functional change. 2019-03-25 09:20:46 +00:00
msaitoh a5cdd4b441 Change MII PHY read/write API from:
int (*mii_readreg_t)(device_t, int, int);
	void (*mii_writereg_t)(device_t, int, int, int);
to:

	int (*mii_readreg_t)(device_t, int, int, uint16_t *);
	int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

 In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

 Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

	arm/at91/at91emac.c
	arm/ep93xx/epe.c
	arm/omap/omapl1x_emac.c
	mips/ralink/ralink_eth.c
	arch/powerpc/booke/dev/pq3etsec.c(read)
	dev/cadence/if_cemac.c <- hkenken
	dev/ic/lan9118.c


Tested with the following device:

	axe+ukphy
	axe+rgephy
	axen+rgephy	(tested by Andrius V)
	wm+atphy
	wm+ukphy
	wm+igphy
	wm+ihphy
	wm+makphy
	sk+makphy
	sk+brgphy
	sk+gentbi
	msk+makphy
	sip+icsphy
	sip+ukphy
	re+rgephy
	bge+brgphy
	bnx+brgphy
	gsip+gphyter
	rtk+rlphy
	fxp+inphy	(tested by Andrius V)
	tlp+acphy
	ex+exphy
	epic+qsphy
	vge+ciphy	(tested by Andrius V)
	vr+ukphy	(tested by Andrius V)
	vte+ukphy	(tested by Andrius V)

Not tested (MAC):
	arm:at91emac
	arm:cemac
	arm:epe
	arm:geminigmac
	arm:enet
	arm:cpsw
	arm:emac(omac)
	arm:emac(sunxi)
	arm:npe
	evbppc:temac
	macppc:bm
	macppc:gm
	mips:aumac
	mips:ae
	mips:cnmac
	mips:reth
	mips:sbmac
	playstation2:smap
	powerpc:tsec
	powerpc:emac(ibm4xx)
	sgimips:mec
	sparc:be
	sf
	ne(ax88190, dl10019)
	awge
	ep
	gem
	hme
	smsh
	mtd
	sm
	age
	alc
	ale
	bce
	cas
	et
	jme
	lii
	nfe
	pcn
	ste
	stge
	tl
	xi
	aue
	mue
	smsc
	udav
	url

Not tested (PHY):
	amhphy
	bmtphy
	dmphy
	etphy
	glxtphy
	ikphy
	iophy
	lxtphy
	nsphyter
	pnaphy
	rdcphy
	sqphy
	tlphy
	tqphy
	urlphy
2019-01-22 03:42:24 +00:00
msaitoh ad7b332eaf Pass flags correctly. See also:
http://mail-index.netbsd.org/source-changes/2002/03/25/msg100515.html
2019-01-16 10:10:49 +00:00
msaitoh 8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
msaitoh b211437b51 IFM_FDX and IFM_HDX use different bit, so set IFM_HDX bit if it's not full
duplex. For many drivers, it recognize half duplex if IFM_FDX isn't set,
but not for others. Same as {Free|Open}BSD.
2014-06-16 16:48:16 +00:00
msaitoh d060f6e507 Fix a bug in last commit that mii_ticks isn't inclemented. 2013-06-09 09:56:17 +00:00
msaitoh 307e621cc0 Update link status quickly. This change is a part of FreeBSD's mii_physubr.c
r158649.
2013-06-09 09:31:32 +00:00
msaitoh d2c936ef4d Don't "return" but "break" in MII_TICK when the interface isn't doing
autonegotiaton or the link is up to update the status.
2013-06-09 09:15:51 +00:00
msaitoh 5cbe9dd2fb Fix a bug that the auto negotiation timer isn't cleard as we expected.
To not to forget clearing the timer and to reduce the code duplication,
clear mii_ticks in *mii_phy_auto().
2013-06-06 03:10:48 +00:00
hira 104ce1db3a Fix typo in comment (OUT -> OUI). 2009-01-31 05:44:05 +00:00
dyoung ddbd8176f9 Reduce code duplication: most PHY drivers call mii_phy_add_media()
when they attach to the device tree, so call pmf_device_register(9)
once there instead of once in more than twenty drivers.
2008-11-17 03:04:27 +00:00
xtraeme 7db0e57765 device_t/softc split for all mii(4) devices, and other related
cosmetic changes.
2008-05-04 17:06:09 +00:00
cegger cf417aad7e use aprint_*_dev and device_xname 2008-04-08 20:08:49 +00:00
dyoung 401b2c3477 Remove the device_is_active() check from each individual PHY's
service routine.  Add a wrapper for PHY_SERVICE(), called phy_service(),
and check device_is_active() there.  Make the mii_*() routines call
the PHY service routines thorugh phy_service() instead of PHY_SERVICE().

In mii_phy_resume(), restore a PHY's state after resetting it by
sending a MII_MEDIACHG command.  This change makes bnx(4) resume
more reliably and more quickly; it should help other NICs to resume,
too, if they attach PHYs through MII.
2007-12-29 19:34:55 +00:00
perry 9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
christos 5e16b7787c - don't hardcode 5, 10 define and use MII_ANEGTICKS{,_GIGE}
- instead of != limit, use <= limit (conservative)
2006-11-16 21:24:06 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
thorpej 838ee1e0d9 Use device_private(). 2006-03-29 06:51:47 +00:00
kleink e9b4cd552f Fix inverted device_is_a() use logic in previous. 2006-02-28 22:40:15 +00:00
thorpej d1f18238ca Use device_is_a(). 2006-02-27 02:59:24 +00:00
thorpej 3ddf26777f Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
2006-02-20 16:50:36 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
thorpej 1efb3da0fb Make use of static. 2004-08-23 06:16:06 +00:00
tsutsui 4189ddf652 Remove advertising clauses from code written by Shingo WATANABE.
He has kindly consented it.
2003-09-04 15:17:38 +00:00
thorpej c31f87a5cb Use aprint*(). 2003-04-29 01:49:33 +00:00
kristerw b8943cbf89 Save some text segment space by not defining URLPHY_DEBUG. 2003-04-04 22:21:39 +00:00
thorpej c9b3657ce9 Add trailing ; to CFATTACH_DECL. 2002-10-02 16:33:28 +00:00
thorpej 71adb76f75 Use CFATTACH_DECL(). 2002-09-30 21:57:46 +00:00
thorpej f818766afe Declare all cfattach structures const. 2002-09-27 20:31:45 +00:00
thorpej d1ad2ac4f2 Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver.  The cfdriver is then looked
up in a list which is built at run-time.
2002-09-27 02:24:06 +00:00
simonb c19a094675 Don't include <malloc.h> - no memory management style functions are use
in any of the MII drivers.
2002-07-03 06:25:49 +00:00
ichiro 8e2f0b253e Add a driver for the Realtek RL8150L Ethernet PHY. 2002-03-28 21:07:53 +00:00