History log of /drivers/net/phy/phy_device.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
37f07023d30708b5da091fe6d6be9b60783c6d82 17-Nov-2011 Matt Carlson <mcarlson@broadcom.com> net: Change mii to ethtool advertisement function names

This patch implements advice by Ben Hutchings to change the mii side of
the function names to look more like the register whose values they
convert. New LPA translation functions have been added as well.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
28011cf19b75df9d3f35489a7599a97ec0b3f1a0 17-Nov-2011 Matt Carlson <mcarlson@broadcom.com> net: Add ethtool to mii advertisment conversion helpers

Translating between ethtool advertisement settings and MII
advertisements are common operations for ethernet drivers. This patch
adds a set of helper functions that implements the conversion. The
patch then modifies a couple of the drivers to use the new functions.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
6fe3264945ee63292cdfb27b6e95bc52c603bb09 30-Sep-2011 David Daney <david.daney@cavium.com> netdev/phy: Use mdiobus_read() so that proper locks are taken.

Accesses to the mdio busses must be done with the mdio_lock to ensure
proper operation. Conveniently we have the helper function
mdiobus_read() to do that for us. Lets use it in get_phy_id() instead
of accessing the bus without the lock held.

Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
42933bac11e811f02200c944d8562a15f8ec4ff0 07-Apr-2011 Linus Torvalds <torvalds@linux-foundation.org> Merge branch 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6

* 'for-linus2' of git://git.profusion.mobi/users/lucas/linux-2.6:
Fix common misspellings
25985edcedea6396277003854657b5f3cb31a628 31-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi> Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
/drivers/net/phy/phy_device.c
d005a09edf8b12dd1bec651b2cf94caa0e7bb1be 28-Mar-2011 Marc Kleine-Budde <mkl@pengutronix.de> phylib: phy_attach_direct: phy_init_hw can fail, add cleanup

The function phy_attach_direct attaches the phy and calls phy_init_hw.
phy_init_hw can fail, but the phy is still marked as attached. Successive
calls to phy_attach_direct will fail because the phy is busy.

[ 1.020000] eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=1:00, irq=-1)
[ 1.030000] eth1: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=1:01, irq=-1)
[ 2.050000] Sending DHCP requests .
[ 3.020000] PHY: 1:00 - Link is Up - 100/Full
[ 5.110000] ..... timed out!
[ 87.660000] IP-Config: Reopening network devices...
[ 88.190000] FEC: MDIO read timeout
[ 88.190000] eth0: could not attach to PHY
[ 88.190000] IP-Config: Failed to open eth0
[ 88.210000] FEC: MDIO read timeout
[ 88.210000] eth1: could not attach to PHY
[ 88.210000] IP-Config: Failed to open eth1
[ 88.220000] IP-Config: No network devices available.
[ 88.220000] Freeing init memory: 6968K

[...]

starting network interfaces...
ip: RTNETLINK answers: File exists
[ 94.000000] net eth0: PHY already attached
[ 94.010000] eth0: could not attach to PHY
ip: SIOCSIFFLAGS: Device or resource busy

This patch adds phy_detach to clean up if phy_init_hw fails.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
89ff05ec553f3e70b8773c501da01bf7ad952cab 21-Oct-2010 stephen hemminger <shemminger@vyatta.com> phylib: make local function static

The following functions are not used directly by any drivers:
phy_attach_direct
phy_device_create
phy_prepare_link
genphy_config_advert
genphy_setup_forced
phy_config_interrupt
phy_clear_interrypt
phy_sanitize_settings
phy_enable_interrupts
phy_disable_interrupts

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
ef24b16b5d67c815874ed2d0e2581db629661ba3 24-Aug-2010 Anton Vorontsov <avorontsov@mvista.com> phylib: Fix race between returning phydev and calling adjust_link

It is possible that phylib will call adjust_link before returning
from {,of_}phy_connect(), which may cause the following [very rare,
though] oops upon reopening the device:

Unable to handle kernel paging request for data at address 0x0000024c
Oops: Kernel access of bad area, sig: 11 [#1]
PREEMPT SMP NR_CPUS=2 LTT NESTING LEVEL : 0
P1021 RDB
Modules linked in:
NIP: c0345dac LR: c0345dac CTR: c0345d84
TASK = dffab6b0[30] 'events/0' THREAD: c0d24000 CPU: 0
[...]
NIP [c0345dac] adjust_link+0x28/0x19c
LR [c0345dac] adjust_link+0x28/0x19c
Call Trace:
[c0d25f00] [000045e1] 0x45e1 (unreliable)
[c0d25f30] [c036c158] phy_state_machine+0x3ac/0x554
[...]

Here is why. Drivers store phydev in their private structures, e.g.
gianfar driver:

static int init_phy(struct net_device *dev)
{
...
priv->phydev = of_phy_connect(...);
...
}

So that adjust_link could retrieve it back:

static void adjust_link(struct net_device *dev)
{
...
struct phy_device *phydev = priv->phydev;
...
}

If the device has been opened before, then phydev->state is set to
PHY_HALTED (or undefined if the driver didn't call phy_stop()).

Now, phy_connect starts the PHY state machine before returning phydev to
the driver:

phy_start_machine(phydev, NULL);

if (phydev->irq > 0)
phy_start_interrupts(phydev);

return phydev;

The time between 'phy_start_machine()' and 'return phydev' is undefined.
The start machine routine delays execution for 1 second, which is enough
for most cases. But under heavy load, or if you're unlucky, it is quite
possible that PHY state machine will execute before phy_connect()
returns, and so adjust_link callback will try to dereference phydev,
which is not yet ready.

To fix the issue, simply initialize the PHY's state to PHY_READY during
phy_attach(). This will ensure that phylib won't call adjust_link before
phy_start().

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
c1f19b51d1d87f3e3bb7e6648f43f7d57ed2da6b 17-Jul-2010 Richard Cochran <richardcochran@gmail.com> net: support time stamping in phy devices.

This patch adds a new networking option to allow hardware time stamps
from PHY devices. When enabled, likely candidates among incoming and
outgoing network packets are offered to the PHY driver for possible
time stamping. When accepted by the PHY driver, incoming packets are
deferred for later delivery by the driver.

The patch also adds phylib driver methods for the SIOCSHWTSTAMP ioctl
and callbacks for transmit and receive time stamping. Drivers may
optionally implement these functions.

Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
8626d3b4328061f5b82b11ae1d6918a0c3602f42 02-Apr-2010 David Woodhouse <dwmw2@infradead.org> phylib: Support phy module autoloading

We don't use the normal hotplug mechanism because it doesn't work. It will
load the module some time after the device appears, but that's not good
enough for us -- we need the driver loaded _immediately_ because otherwise
the NIC driver may just abort and then the phy 'device' goes away.

[bwh: s/phy/mdio/ in module alias, kerneldoc for struct mdio_device_id]

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
f8f76db1db369f3a130ac3fd33e2eee5f1610d9c 04-Feb-2010 Jiri Pirko <jpirko@redhat.com> libphy: add phy_find_first function

Many drivers do this in them manually. Now they can use this function.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
4f9c85a1b03bfa5c0a0d8488a3a7766f3c9fb756 18-Jan-2010 Anton Vorontsov <avorontsov@ru.mvista.com> phylib: Move workqueue initialization to a proper place

commit 541cd3ee00a4fe975b22fac6a3bc846bacef37f7 ("phylib: Fix deadlock
on resume") caused TI DaVinci EMAC ethernet driver to oops upon resume:

PM: resume of devices complete after 237.098 msecs
Restarting tasks ... done.
kernel BUG at kernel/workqueue.c:354!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
[...]
Backtrace:
[<c002c598>] (__bug+0x0/0x2c) from [<c0052a54>] (queue_delayed_work_on+0x74/0xf8)
[<c00529e0>] (queue_delayed_work_on+0x0/0xf8) from [<c0052b30>] (queue_delayed_work+0x2c/0x30)

The oops pops up because TI DaVinci EMAC driver detaches PHY on
suspend and attaches it back on resume. Attaching makes phylib call
phy_start_machine() that initializes a workqueue. On the other hand,
PHY's resume routine will call phy_start_machine() again, and that
will cause the oops since we just destroyed the already scheduled
workqueue.

This patch fixes the issue by moving workqueue initialization to
phy_device_create().

p.s. We don't see this oops with ucc_geth and gianfar drivers because
they perform a fine-grained suspend, i.e. they just stop the PHYs
without detaching.

Reported-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Tested-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
2f5cb43406d0b29b96248f5328a14a6f6abf8ae6 30-Dec-2009 Anton Vorontsov <avorontsov@ru.mvista.com> phylib: Properly reinitialize PHYs after hibernation

Since hibernation assumes power loss, we should fully reinitialize
PHYs (including platform fixups), as if PHYs were just attached.

This patch factors phy_init_hw() out of phy_attach_direct(), then
converts mdio_bus to dev_pm_ops and adds an appropriate restore()
callback.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
bc23283c7bc90958927abe26eedc562701743a88 13-Jul-2009 Jiri Slaby <jirislaby@gmail.com> NET: phy_device, fix lock imbalance

Don't forget to unlock a mutex in phy_scan_fixups on a fail path.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
1d4ac5d5ef9dd965ae211ebe8acbf83dc4d9571b 16-Jun-2009 Randy Dunlap <randy.dunlap@oracle.com> phy_device: fix parameter name in kernel-doc

Fix kernel-doc parameter name in phy_device.c.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
fa94f6d93c5382810ff41f010f12ca8698fc775e 25-Apr-2009 Grant Likely <grant.likely@secretlab.ca> phylib: add *_direct() variants of phy_connect and phy_attach functions

Add phy_connect_direct() and phy_attach_direct() functions so that
drivers can use a pointer to the phy_device instead of trying to determine
the phy's bus_id string.

This patch is useful for OF device tree descriptions of phy devices where
the driver doesn't need or know what the bus_id value in order to get a
phy_device pointer.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
4dea547fef1ba23f9d23f5e7f5218187a7dcf1b3 25-Apr-2009 Grant Likely <grant.likely@secretlab.ca> phylib: rework to prepare for OF registration of PHYs

This patch makes changes in preparation for supporting open firmware
device tree descriptions of MDIO busses. Changes include:
- Cleanup handling of phy_map[] entries; they are already NULLed when
registering and so don't need to be re-cleared, and it is good practice
to clear them out when unregistering.
- Split phy_device registration out into a new function so that the
OF helpers can do two stage registration (separate allocation and
registration steps).

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
f0d44ae310bc8eb0b6694e257015d8b24e1a357c 14-Jan-2009 Anton Vorontsov <avorontsov@ru.mvista.com> phylib: Fix Freescale TBI PHY detection

Freescale on-chip TBI PHYs reports PHY ID as 0x0, but as of

commit 3ee82383f0098a2e13acc8cf1be8e47512f41e5a
Author: Giulio Benetti <giulio.benetti@micronovasrl.com>
Date: Thu Nov 13 21:53:13 2008 +0000

phy: fix phy address bug

PHYID returns 0xffff and not 0xffffffff when not found and in some
case(at91sam9263) 0x0. Maybe this patch could be useful.

phy_device.c treats PHY ID == 0x0 as bogus IDs, and that results in
gianfar driver failure to see the TBI PHYs. This code snippet triggers:

if (!priv->tbiphy) {
printk(KERN_WARNING "SGMII mode requires that the device "
"tree specify a tbi-handle\n");
return;
}

Although tbi-handle is specified in the device tree.

Btw, technically PHY ID == 0x0 is a valid ID (if we ever see a PHY
manufactured by Xerox :-).

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
161c8d2f50109b44b664eaf23831ea1587979a61 26-Dec-2008 Krzysztof Halasa <khc@pm.waw.pl> net: PHYLIB mdio fixes #2

The PHYLIB mdio code has more problems in error paths:
- mdiobus_release can be called before bus->state is set to
MDIOBUS_REGISTERED
- mdiobus_scan allocates resources which need to be freed
- the comment is wrong, the resistors used are actually pull-ups.

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
f162e97d778ec29492be8eb9bbecb65be976b7c8 17-Dec-2008 Andy Fleming <afleming@freescale.com> phylib: Remove unnecessary "reset" fixups in genphy_setup_forced

genphy_setup_forced hasn't actually reset the PHY for a long time,
but a comment to that effect remained in the code, so code continued
to act as if it *had* reset the PHY, and called the necessary fixup
functions to respond to a PHY reset. With no reset, those functions
are no longer needed, so we remove them.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
0f0ca340e57bd7446855fefd07a64249acf81223 29-Nov-2008 Giuseppe Cavallaro <peppe.cavallaro@st.com> phy: power management support

This patch adds the power management support into the physical
abstraction layer.

Suspend and resume functions respectively turns on/off the bit 11
into the PHY Basic mode control register.
Generic PHY device starts supporting PM.

In order to support the wake-on LAN and avoid to put in power down
the PHY device, the MDIO is aware of what the Ethernet device wants to do.

Voluntary, no CONFIG_PM defines were added into the sources.
Also generic suspend/resume functions are exported to allow
other drivers use them (such as genphy_config_aneg etc.).

Within the phy_driver_register function, we need to remove the
memset. It overrides the device driver owner and it is not good.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
5b9ab2ec04ec1e1e53939768805612ac191d7ba2 27-Nov-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/hp-plus.c
drivers/net/wireless/ath5k/base.c
drivers/net/wireless/ath9k/recv.c
net/wireless/reg.c
6436cbcd735a11fc93bf3353c68914bc545e6d1e 21-Nov-2008 Giuseppe Cavallaro <peppe.cavallaro@st.com> phy: fix phy_id detection also for broken hardware.

This patch fixes the case when the phy_ids is mostly Fs and in some case 0x0
due to broken hardware.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
6ab33d51713d6d60c7677c0d020910a8cb37e513 21-Nov-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/net/ixgbe/ixgbe_main.c
include/net/mac80211.h
net/phonet/af_phonet.c
de339c2aa7fea18410b1abeab5674bfbd4073a63 20-Nov-2008 Trent Piepho <tpiepho@freescale.com> phylib: Fix auto-negotiation restart avoidance

A previous patch, 51e2a3846eab18711f4eb59cd0a4c33054e2980a, made
genphy_config_aneg() not restart aneg by calling genphy_restart_aneg() if
the advertisement hadn't changed.

But, genphy_restart_aneg() doesn't just restart aneg, it may also *enable*
aneg or un-isolate the PHY from the MII (those functions are controlled by
the same register). The code to avoid calling genphy_restart_aneg() didn't
consider this.

So, modify genphy_config_aneg() to also check if the PHY needs to have aneg
enabled or be un-isolated before deciding not to restart aneg.

This caused a problem with certain Davicom PHYs, as that driver isolates
the PHY (why?) before calling genphy_config_aneg() and expects the PHY to
be un-isolated by that function.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Reported-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
198d6ba4d7f48c94f990f4604f0b3d73925e0ded 19-Nov-2008 David S. Miller <davem@davemloft.net> Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

Conflicts:

drivers/isdn/i4l/isdn_net.c
fs/cifs/connect.c
3ee82383f0098a2e13acc8cf1be8e47512f41e5a 13-Nov-2008 Giulio Benetti <giulio.benetti@micronovasrl.com> phy: fix phy address bug

PHYID returns 0xffff and not 0xffffffff when not found and in some
case(at91sam9263) 0x0. Maybe this patch could be useful.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
fb28ad35906af2f042c94e2f9c0f898ef9acfa37 10-Nov-2008 Kay Sievers <kay.sievers@vrfy.org> net: struct device - replace bus_id with dev_name(), dev_set_name()

Acked-by: Marcel Holtmann <marcel@holtmann.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
26853ab6f9a4c482be4b638477335704724d4854 27-Jan-2008 Greg Kroah-Hartman <gregkh@suse.de> NET: convert the phy_device file to use bus_find_device_by_name

The driver core now has this helper function, so might as well use it
instead of forcing the phy code to roll their own version.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/net/phy/phy_device.c
892871dcc39c23d3e30f8c317a5bfbab74084a40 14-Oct-2008 Adrian Bunk <bunk@kernel.org> net: export genphy_restart_aneg

This patch fixes the following build error caused by
commit ed94493fb38a665cebcf750dfabe8a6dd13e136f
(mv643xx_eth: convert to phylib):

<-- snip -->

...
Building modules, stage 2.
MODPOST 1280 modules
ERROR: "genphy_restart_aneg" [drivers/net/mv643xx_eth.ko] undefined!
...
make[2]: *** [__modpost] Error 1

<-- snip -->

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
51e2a3846eab18711f4eb59cd0a4c33054e2980a 24-Sep-2008 Trent Piepho <tpiepho@freescale.com> PHY: Avoid unnecessary aneg restarts

The PHY's aneg is configured and restarted whenever the link is brought up,
e.g. when DHCP is started after the kernel has booted. This can take the
link down for several seconds while auto-negotiation is redone.

If the advertised features haven't changed, then it shouldn't be necessary
to bring down the link and start auto-negotiation over again.

genphy_config_advert() is enhanced to return 0 when the advertised features
haven't been changed and >0 when they have been.

genphy_config_aneg() then uses this information to not call
genphy_restart_aneg() if there has been no change.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
a01b3d766c0ad3e63978b0f6faf4004688f13522 22-May-2008 Paul Gortmaker <paul.gortmaker@windriver.com> phylib: do EXPORT_SYMBOL on get_phy_id

Commit cac1f3c8 factored out the code for get_phy_id so that it
could be reused in multiple places. Turns out that some of the
users can be modular, so we need to export this symbol as well.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
/drivers/net/phy/phy_device.c
5d12b132bc0bfb10d3f8d81f92606719b5032dcb 28-Apr-2008 Randy Dunlap <randy.dunlap@oracle.com> drivers/net/phy: fix kernel-doc notation

Fix kernel-doc warning:
Warning(linux-2.6.25-git11//drivers/net/phy/phy_device.c:275): No
description found for parameter 'bus_id'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
/drivers/net/phy/phy_device.c
f62220d3a9ccb879c3f90f845ae57b724b7bbb62 19-Apr-2008 Andy Fleming <afleming@freescale.com> phylib: Add support for board-level PHY fixups

Sometimes the specific interaction between the platform and the PHY
requires special handling. For instance, to change where the PHY's
clock input is, or to add a delay to account for latency issues in the
data path. We add a mechanism for registering a callback with the PHY
Lib to be called on matching PHYs when they are brought up, or reset.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
/drivers/net/phy/phy_device.c
cac1f3c8a80f3fc0b4489d1d3ba29214677ffab2 15-Apr-2008 Paul Gortmaker <paul.gortmaker@windriver.com> phylib: factor out get_phy_id from within get_phy_device

We were already doing what amounts to a get_phy_id from within
get_phy_device, and rather than duplicate this for the TBIPA
probing, we might as well just factor it out and make it available
instead.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
/drivers/net/phy/phy_device.c
35b5f6b1a82b5c586e0b24c711dc6ba944e88ef1 29-Jan-2008 Nate Case <ncase@xes-inc.com> PHYLIB: Locking fixes for PHY I/O potentially sleeping

PHY read/write functions can potentially sleep (e.g., a PHY accessed
via I2C). The following changes were made to account for this:

* Change spin locks to mutex locks
* Add a BUG_ON() to phy_read() phy_write() to warn against
calling them from an interrupt context.
* Use work queue for PHY state machine handling since
it can potentially sleep
* Change phydev lock from spinlock to mutex

Signed-off-by: Nate Case <ncase@xes-inc.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/net/phy/phy_device.c
6f4a7f4183bdbd02741dcd8edbd10b8628acc5d5 04-Dec-2007 Anton Vorontsov <avorontsov@ru.mvista.com> PHY: Add the phy_device_release device method.

Lately I've got this nice badness on mdio bus removal:

Device 'e0103120:06' does not have a release() function, it is broken and must be fixed.
------------[ cut here ]------------
Badness at drivers/base/core.c:107
NIP: c015c1a8 LR: c015c1a8 CTR: c0157488
REGS: c34bdcf0 TRAP: 0700 Not tainted (2.6.23-rc5-g9ebadfbb-dirty)
MSR: 00029032 <EE,ME,IR,DR> CR: 24088422 XER: 00000000
...
[c34bdda0] [c015c1a8] device_release+0x78/0x80 (unreliable)
[c34bddb0] [c01354cc] kobject_cleanup+0x80/0xbc
[c34bddd0] [c01365f0] kref_put+0x54/0x6c
[c34bdde0] [c013543c] kobject_put+0x24/0x34
[c34bddf0] [c015c384] put_device+0x1c/0x2c
[c34bde00] [c0180e84] mdiobus_unregister+0x2c/0x58
...

Though actually there is nothing broken, it just device
subsystem core expects another "pattern" of resource managment.

This patch implement phy device's release function, thus
we're getting rid of this badness.

Also small hidden bug fixed, hope none other introduced. ;-)

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
f2511f13daaf00fdd206bee7b108f75923a613c6 04-Nov-2007 Olof Johansson <olof@lixom.net> phylib: Silence driver registration

It gets quite verbose to see every single PHY driver being registered
by default.

Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
9ff8c68b3c722f732c7a13d6631b149cca8c7091 29-Sep-2007 Maciej W. Rozycki <macro@linux-mips.org> PHYLIB: Spinlock fixes for softirqs

Use spin_lock_bh()/spin_unlock_bh() for the phydev lock throughout as it
is used in phy_timer() that is called as a softirq and all the other
operations may happen in the user context.

There has been a change recently that did such a conversion for some of the
operations on the lock, but some have been left intact. Many of them,
perhaps all, may be called in the user context and I was able to trigger
recursive spinlock acquisition indeed, so I think for the sake of long-term
maintenance it is best to convert them all, even if unnecessarily for one
or two -- better safe than sorry.

Perhaps one in phy_timer() could actually be skipped as only called as a
softirq -- I can send an update if that sounds like a good idea.

Checked with checkpatch.pl and at the runtime.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
026d7917e592f91063861e002adf1c806d7756ae 31-Aug-2007 Hans-Jürgen Koch <hjk@linutronix.de> Fix a lock problem in generic phy code

Lock debugging finds a problem in phy.c and phy_device.c,
this patch fixes it. Tested on an AT91SAM9263-EK board,
kernel 2.6.23-rc4.

Signed-off-by: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
bc1e0a095e9b8c4df4a2eedd7dc6a9d470a0e6b7 17-Aug-2007 Domen Puncer <domen.puncer@telargo.com> phy layer: fix genphy_setup_forced (don't reset)

Writing BMCR_RESET bit will reset MII_BMCR to default values. This is
clearly not what we want.

Signed-off-by: Domen Puncer <domen.puncer@telargo.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
b3df0da886ffdb3e70c3197f589e959e5f8c9c04 06-Mar-2007 Randy Dunlap <randy.dunlap@oracle.com> phy layer: add kernel-doc + DocBook

Convert function documentation in drivers/net/phy/ to kernel-doc
and add it to DocBook.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
87aebe078e450795d336d20304d01095251ff9fa 09-Apr-2007 Greg Kroah-Hartman <gregkh@suse.de> PHY: remove rwsem use from phy core

The subsystem rwsem is not used by the driver core at all, so the use of
it in the phy code doesn't make any sense. They might possibly
want to use a local lock, but I am unsure about that.

Cc: netdev <netdev@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
/drivers/net/phy/phy_device.c
f630fe2817601314b2eb7ca5ddc23c7834646731 17-Feb-2007 Jeff Garzik <jeff@garzik.org> Merge branch 'master' into upstream
cd354f1ae75e6466a7e31b727faede57a1f89ca5 14-Feb-2007 Tim Schmielau <tim@physik3.uni-rostock.de> [PATCH] remove many unneeded #includes of sched.h

After Al Viro (finally) succeeded in removing the sched.h #include in module.h
recently, it makes sense again to remove other superfluous sched.h includes.
There are quite a lot of files which include it but don't actually need
anything defined in there. Presumably these includes were once needed for
macros that used to live in sched.h, but moved to other header files in the
course of cleaning it up.

To ease the pain, this time I did not fiddle with any header files and only
removed #includes from .c-files, which tend to cause less trouble.

Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
configs in arch/arm/configs on arm. I also checked that no new warnings were
introduced by the patch (actually, some warnings are removed that were emitted
by unnecessarily included header files).

Signed-off-by: Tim Schmielau <tim@physik3.uni-rostock.de>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/drivers/net/phy/phy_device.c
1a1689344add3333d28d1b5495d8043a3877d01c 05-Feb-2007 Randy Dunlap <randy.dunlap@oracle.com> phy devices: use same arg types

sparse complains about differing types from prototype to
definition, so change the u32 to phy_interface_t:

drivers/net/phy/phy_device.c:140:19: error: symbol 'phy_connect' redeclared with different type (originally declared at include/linux/phy.h:362) - incompatible argument 5 (different signedness)
drivers/net/phy/phy_device.c:190:19: error: symbol 'phy_attach' redeclared with different type (originally declared at include/linux/phy.h:360) - incompatible argument 4 (different signedness)

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
cd86128088554d64fea1679191509f00e6353c5b 13-Dec-2006 Robert P. J. Day <rpjday@mindspring.com> [PATCH] Fix numerous kcalloc() calls, convert to kzalloc()

All kcalloc() calls of the form "kcalloc(1,...)" are converted to the
equivalent kzalloc() calls, and a few kcalloc() calls with the incorrect
ordering of the first two arguments are fixed.

Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Greg KH <greg@kroah.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/net/phy/phy_device.c
e8a2b6a4207332a2d59628a12cece9e8c1d769e4 01-Dec-2006 Andy Fleming <afleming@freescale.com> [PATCH] PHY: Add support for configuring the PHY connection interface

Most PHYs connect to an ethernet controller over a GMII or MII
interface. However, a growing number are connected over
different interfaces, such as RGMII or SGMII.

The ethernet driver will tell the PHY what type of connection it
is by setting it manually, or passing it in through phy_connect
(or phy_attach).

Changes include:
* Updates to documentation
* Updates to PHY Lib consumers
* Changes to PHY Lib to add interface support
* Some minor changes to whitespace in phy.h
* gianfar driver now detects interface and passes appropriate
value to PHY Lib
Signed-off-by: Andrew Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
6b655529c3d817ed1b69cf2dd29e2c3ce5148a2b 16-Oct-2006 Andy Fleming <afleming@freescale.com> [PATCH] Fixed a number of bugs in the PHY Layer

* genphy_update_link is now exported
* Added a fix from ncase@xes-inc.com which changes forcing so it
only updates the link. Otherwise, it never tries the lower
values, since it is always overwriting the speed/duplex values
with the current ones, rather than the intended ones.
* Fixed a bug where bringing up a PHY with no link caused it to
timeout, and enter forcing mode. Once in forcing mode,
plugging in the link didn't autonegotiate. Now the AN state
detects the lack of link, and enters the NO_LINK state. AN
only times out if the link is up and AN fails
* Cleaned up the PHY_AN case, reducing one level of indentation
for the timeout code.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
b7a00ecd557859c4037b6465fdd6c9a49b1fa649 01-Oct-2006 Jeff Garzik <jeff@garzik.org> [netdrvr] phy: Fix bugs in error handling

The recent __must_check stuff flagged some error handling bugs.

phy/fixed.c:
* handle device_bind_driver() failure

phy/phy_device.c:
* handle device_bind_driver() failure
* release rwsem upon failure

Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
84c22d7901f793bd267b5f79270080964b252826 26-Sep-2006 Eric Sesterhenn <snakebyte@gmx.de> [PATCH] Signedness issue in drivers/net/phy/phy_device.c

While checking gcc 4.1 -Wextra warnings, I stumbled across the following
two warnings:

drivers/net/phy/phy_device.c:528: warning: comparison of unsigned expression < 0 is always false
drivers/net/phy/phy_device.c:546: warning: comparison of unsigned expression < 0 is always false

Since phy_read() returns an integer and can return negative values, it seems
to me the best way to get proper error handling working again is to make val
an int. Currently it is an u32, so the < 0 check always fails.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
11b0bacd717c285c94dbb56505a28434b34f0639 15-Aug-2006 Vitaly Bordug <vbordug@ru.mvista.com> [PATCH] PAL: Support of the fixed PHY

This makes it possible for HW PHY-less boards to utilize PAL goodies. Generic
routines to connect to fixed PHY are provided, as well as ability to specify
software callback that fills up link, speed, etc. information into PHY
descriptor (the latter feature not tested so far).

Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
/drivers/net/phy/phy_device.c
6ab3d5624e172c553004ecc862bfeac16d9d68b7 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de> Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
/drivers/net/phy/phy_device.c
afcceaa3c7b7fbf7e2b95c5f0dd43547b03292d2 14-Dec-2005 Olaf Hering <olh@suse.de> [PATCH] missing license for libphy.ko

Andy,

libphy has no license tag. Something like the attached (untested!) patch
is needed. Hopefully such a change finds its way into 2.6.15.

filename: /lib/modules/2.6.15-rc5-3-ppc64/kernel/drivers/net/phy/libphy.ko
vermagic: 2.6.15-rc5-3-ppc64 SMP gcc-4.1
depends:
srcversion: ACC921B5E82701BE1E6F603

drivers/net/phy/phy_device.c | 4 ++++
1 files changed, 4 insertions(+)

Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
/drivers/net/phy/phy_device.c
a10b5aacea01d59152b9d003a14476ee99d394d8 06-Nov-2005 Jeff Garzik <jgarzik@pobox.com> Remove linux/version.h include from drivers/net/phy/* and net/ieee80211/*.

Unused, and causes the files to be needlessly rebuilt in some cases.
/drivers/net/phy/phy_device.c
8cee0cd5bec53b78dd3c43a73b27821a688133e6 24-Sep-2005 Jeff Garzik <jgarzik@pobox.com> [netdrvr] delete CONFIG_PHYCONTROL
/drivers/net/phy/phy_device.c
e13934563db047043ccead26412f552375cea90c 25-Aug-2005 Andy Fleming <afleming@freescale.com> [PATCH] PHY Layer fixup

This patch adds back the code that was taken out, thus re-enabling:

* The PHY Layer to initialize without crashing
* Drivers to actually connect to PHYs
* The entire PHY Control Layer

This patch is used by the gianfar driver, and other drivers which are in
development.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
/drivers/net/phy/phy_device.c
2bf69b5fe90b3246ab50064c5a690a363e8c53e2 11-Aug-2005 Jeff Garzik <jgarzik@pobox.com> phy subsystem: more cleanups

- unexport symbols never used outside of home module
- remove dead code
- remove CONFIG_PHYCONTROL, make it unconditionally enabled
/drivers/net/phy/phy_device.c
67c4f3fa25502ce7ed82fb0307e09cf36f1f81da 11-Aug-2005 Jeff Garzik <jgarzik@pobox.com> Fix numerous minor problems with new phy subsystem.

Includes fixes for problems noted by Adrian Bunk, Andrew Morton,
and one other person lost in the annals of history (and email folders).
/drivers/net/phy/phy_device.c
00db8189d984d6c51226dafbbe4a667ce9b7d5da 31-Jul-2005 Andy Fleming <afleming@freescale.com> This patch adds a PHY Abstraction Layer to the Linux Kernel, enabling
ethernet drivers to remain as ignorant as is reasonable of the connected
PHY's design and operation details.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
/drivers/net/phy/phy_device.c