#include <linux/kernel.h> #include <linux/sched.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/unistd.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/delay.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/mm.h> #include <linux/module.h> #include <linux/mii.h> #include <linux/ethtool.h> #include <linux/phy.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/uaccess.h> /* BCM5421S control register */ #define MII_BCM5421S_CONTROL 0x00 #define MII_BCM5421S_CONTROL_RESET 0x00008000 #define MII_BCM5421S_CONTROL_INIT 0x00001140 #define MII_BCM5421S_ANEN 0x00001000 #define MII_BCM5421S_CR 0x00 #define MII_BCM5421S_CR_RST 0x00008000 #define MII_BCM5421S_CR_INIT 0x00001000 #define MII_BCM5421S_STATUS 0x1 #define MII_BCM5421S_STATUS_AN_DONE 0x00000020 #define MII_BCM5421S_STATUS_LINK 0x0004 #define MII_BCM5421S_PHYIR1 0x2 #define MII_BCM5421S_PHYIR2 0x3 #define MII_BCM5421S_ANLPBPA 0x5 #define MII_BCM5421S_ANLPBPA_HALF 0x00000040 #define MII_BCM5421S_ANLPBPA_FULL 0x00000020 #define MII_BCM5421S_ANEX 0x6 #define MII_BCM5421S_ANEX_NP 0x00000004 #define MII_BCM5421S_ANEX_PRX 0x00000002 MODULE_DESCRIPTION("Broadcom PHY driver"); MODULE_AUTHOR("Amy Fong"); MODULE_LICENSE("GPL"); static int bcm5421s_config_aneg(struct phy_device *phydev) { int err; /* Write the appropriate value to the PHY reg */ if (phydev->supported & SUPPORTED_1000baseT_Full) err = phy_write(phydev, MII_BCM5421S_CONTROL, MII_BCM5421S_CONTROL_INIT); else err = phy_write(phydev, MII_BCM5421S_CONTROL, MII_BCM5421S_CR_INIT); if (err < 0) return err; /* doesn't have phy interrupt */ phydev->interrupts = PHY_INTERRUPT_DISABLED; return 0; } static struct phy_driver bcm5421s_driver = { .phy_id = 0x002060e1, .phy_id_mask = 0x00ffffff, .name = "Broadcom BCM5421S", .features = PHY_GBIT_FEATURES, .config_aneg = bcm5421s_config_aneg, .read_status = genphy_read_status, .driver = { .owner = THIS_MODULE,}, }; /* Glossy description on Broadcom's site seems to hint that the 5461 should be a drop-in for the 5421.... */ static struct phy_driver bcm5461s_driver = { .phy_id = 0x002060c1, .phy_id_mask = 0x00ffffff, .name = "Broadcom BCM5461S", .features = PHY_GBIT_FEATURES, .config_aneg = bcm5421s_config_aneg, .read_status = genphy_read_status, .driver = { .owner = THIS_MODULE,}, }; static int __init broadcom_init(void) { int ret; ret = phy_driver_register(&bcm5421s_driver); if (!ret) { ret = phy_driver_register(&bcm5461s_driver); if (ret) phy_driver_unregister(&bcm5421s_driver); } return ret; } static void __exit broadcom_exit(void) { phy_driver_unregister(&bcm5421s_driver); phy_driver_unregister(&bcm5461s_driver); } module_init(broadcom_init); module_exit(broadcom_exit); |