diff options
author | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-03-22 20:18:36 +0000 |
---|---|---|
committer | nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-03-22 20:18:36 +0000 |
commit | a285220c588bf91537659eb4f2a8b3a15fa3b53d (patch) | |
tree | 7c51074470ae7bda3ea8c2f1bd42ee59e589bb30 /target/linux | |
parent | b730e774733c0ed40ef5fe40332be1152f14a8e1 (diff) |
mvswitch,adm6996: use phy fixups instead of a nonstandard patch for hardware detection
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@14977 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r-- | target/linux/generic-2.6/files/drivers/net/phy/adm6996.c | 41 | ||||
-rw-r--r-- | target/linux/generic-2.6/files/drivers/net/phy/mvswitch.c | 51 |
2 files changed, 40 insertions, 52 deletions
diff --git a/target/linux/generic-2.6/files/drivers/net/phy/adm6996.c b/target/linux/generic-2.6/files/drivers/net/phy/adm6996.c index 3033813ec..972d20c6d 100644 --- a/target/linux/generic-2.6/files/drivers/net/phy/adm6996.c +++ b/target/linux/generic-2.6/files/drivers/net/phy/adm6996.c @@ -105,6 +105,24 @@ static int adm6996_config_aneg(struct phy_device *phydev) return 0; } +static int adm6996_fixup(struct phy_device *dev) +{ + struct mii_bus *bus = dev->bus; + u16 reg; + + /* look for the switch on the bus */ + reg = bus->read(bus, PHYADDR(ADM_SIG0)) & ADM_SIG0_MASK; + if (reg != ADM_SIG0_VAL) + return 0; + + reg = bus->read(bus, PHYADDR(ADM_SIG1)) & ADM_SIG1_MASK; + if (reg != ADM_SIG1_VAL) + return 0; + + dev->phy_id = (ADM_SIG0_VAL << 16) | ADM_SIG1_VAL; + return 0; +} + static int adm6996_probe(struct phy_device *pdev) { struct adm6996_priv *priv; @@ -124,30 +142,12 @@ static void adm6996_remove(struct phy_device *pdev) kfree(pdev->priv); } -static bool adm6996_detect(struct mii_bus *bus, int addr) -{ - u16 reg; - - /* we only attach to phy id 0 */ - if (addr != 0) - return false; - - /* look for the switch on the bus */ - reg = bus->read(bus, PHYADDR(ADM_SIG0)) & ADM_SIG0_MASK; - if (reg != ADM_SIG0_VAL) - return false; - - reg = bus->read(bus, PHYADDR(ADM_SIG1)) & ADM_SIG1_MASK; - if (reg != ADM_SIG1_VAL) - return false; - - return true; -} static struct phy_driver adm6996_driver = { .name = "Infineon ADM6996", + .phy_id = (ADM_SIG0_VAL << 16) | ADM_SIG1_VAL, + .phy_id_mask = 0xffffffff, .features = PHY_BASIC_FEATURES, - .detect = adm6996_detect, .probe = adm6996_probe, .remove = adm6996_remove, .config_init = &adm6996_config_init, @@ -158,6 +158,7 @@ static struct phy_driver adm6996_driver = { static int __init adm6996_init(void) { + phy_register_fixup_for_id(PHY_ANY_ID, adm6996_fixup); return phy_driver_register(&adm6996_driver); } diff --git a/target/linux/generic-2.6/files/drivers/net/phy/mvswitch.c b/target/linux/generic-2.6/files/drivers/net/phy/mvswitch.c index f5a292a80..427bad405 100644 --- a/target/linux/generic-2.6/files/drivers/net/phy/mvswitch.c +++ b/target/linux/generic-2.6/files/drivers/net/phy/mvswitch.c @@ -38,6 +38,8 @@ MODULE_DESCRIPTION("Marvell 88E6060 Switch driver"); MODULE_AUTHOR("Felix Fietkau"); MODULE_LICENSE("GPL"); +#define MVSWITCH_MAGIC 0x88E6060 + struct mvswitch_priv { /* the driver's tx function */ int (*hardstart)(struct sk_buff *skb, struct net_device *dev); @@ -401,37 +403,6 @@ mvswitch_remove(struct phy_device *pdev) kfree(priv); } -static bool -mvswitch_detect(struct mii_bus *bus, int addr) -{ - u16 reg; - int i; - - /* we attach to phy id 31 to make sure that the late probe works */ - if (addr != 31) - return false; - - /* look for the switch on the bus */ - reg = bus->read(bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK; - if (reg != MV_IDENT_VALUE) - return false; - - /* - * Now that we've established that the switch actually exists, let's - * get rid of the competition :) - */ - for (i = 0; i < 31; i++) { - if (!bus->phy_map[i]) - continue; - - device_unregister(&bus->phy_map[i]->dev); - kfree(bus->phy_map[i]); - bus->phy_map[i] = NULL; - } - - return true; -} - static int mvswitch_probe(struct phy_device *pdev) { @@ -446,11 +417,26 @@ mvswitch_probe(struct phy_device *pdev) return 0; } +static int +mvswitch_fixup(struct phy_device *dev) +{ + u16 reg; + + /* look for the switch on the bus */ + reg = dev->bus->read(dev->bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK; + if (reg != MV_IDENT_VALUE) + return 0; + + dev->phy_id = MVSWITCH_MAGIC; + return 0; +} + static struct phy_driver mvswitch_driver = { .name = "Marvell 88E6060", + .phy_id = MVSWITCH_MAGIC, + .phy_id_mask = 0xffffffff, .features = PHY_BASIC_FEATURES, - .detect = &mvswitch_detect, .probe = &mvswitch_probe, .remove = &mvswitch_remove, .config_init = &mvswitch_config_init, @@ -462,6 +448,7 @@ static struct phy_driver mvswitch_driver = { static int __init mvswitch_init(void) { + phy_register_fixup_for_id(PHY_ANY_ID, mvswitch_fixup); return phy_driver_register(&mvswitch_driver); } |