Skip to content

Commit

Permalink
[PATCH] PHY Layer fixup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Fleming authored and Jeff Garzik committed Aug 29, 2005
1 parent 86f0cd5 commit e139345
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 102 deletions.
8 changes: 8 additions & 0 deletions drivers/net/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ config PHYLIB
devices. This option provides infrastructure for
managing PHY devices.

config PHYCONTROL
bool " Support for automatically handling PHY state changes"
depends on PHYLIB
help
Adds code to perform all the work for keeping PHY link
state (speed/duplex/etc) up-to-date. Also handles
interrupts.

comment "MII PHY device drivers"
depends on PHYLIB

Expand Down
11 changes: 6 additions & 5 deletions drivers/net/phy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

libphy-objs := phy.o phy_device.o mdio_bus.o

obj-$(CONFIG_MARVELL_PHY) += libphy.o marvell.o
obj-$(CONFIG_DAVICOM_PHY) += libphy.o davicom.o
obj-$(CONFIG_CICADA_PHY) += libphy.o cicada.o
obj-$(CONFIG_LXT_PHY) += libphy.o lxt.o
obj-$(CONFIG_QSEMI_PHY) += libphy.o qsemi.o
obj-$(CONFIG_PHYLIB) += libphy.o
obj-$(CONFIG_MARVELL_PHY) += marvell.o
obj-$(CONFIG_DAVICOM_PHY) += davicom.o
obj-$(CONFIG_CICADA_PHY) += cicada.o
obj-$(CONFIG_LXT_PHY) += lxt.o
obj-$(CONFIG_QSEMI_PHY) += qsemi.o
79 changes: 78 additions & 1 deletion drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,80 @@
#include <asm/irq.h>
#include <asm/uaccess.h>

/* mdiobus_register
*
* description: Called by a bus driver to bring up all the PHYs
* on a given bus, and attach them to the bus
*/
int mdiobus_register(struct mii_bus *bus)
{
int i;
int err = 0;

spin_lock_init(&bus->mdio_lock);

if (NULL == bus || NULL == bus->name ||
NULL == bus->read ||
NULL == bus->write)
return -EINVAL;

if (bus->reset)
bus->reset(bus);

for (i = 0; i < PHY_MAX_ADDR; i++) {
struct phy_device *phydev;

phydev = get_phy_device(bus, i);

if (IS_ERR(phydev))
return PTR_ERR(phydev);

/* There's a PHY at this address
* We need to set:
* 1) IRQ
* 2) bus_id
* 3) parent
* 4) bus
* 5) mii_bus
* And, we need to register it */
if (phydev) {
phydev->irq = bus->irq[i];

phydev->dev.parent = bus->dev;
phydev->dev.bus = &mdio_bus_type;
sprintf(phydev->dev.bus_id, "phy%d:%d", bus->id, i);

phydev->bus = bus;

err = device_register(&phydev->dev);

if (err)
printk(KERN_ERR "phy %d failed to register\n",
i);
}

bus->phy_map[i] = phydev;
}

pr_info("%s: probed\n", bus->name);

return err;
}
EXPORT_SYMBOL(mdiobus_register);

void mdiobus_unregister(struct mii_bus *bus)
{
int i;

for (i = 0; i < PHY_MAX_ADDR; i++) {
if (bus->phy_map[i]) {
device_unregister(&bus->phy_map[i]->dev);
kfree(bus->phy_map[i]);
}
}
}
EXPORT_SYMBOL(mdiobus_unregister);

/* mdio_bus_match
*
* description: Given a PHY device, and a PHY driver, return 1 if
Expand Down Expand Up @@ -96,4 +170,7 @@ int __init mdio_bus_init(void)
return bus_register(&mdio_bus_type);
}


void __exit mdio_bus_exit(void)
{
bus_unregister(&mdio_bus_type);
}
Loading

0 comments on commit e139345

Please sign in to comment.