2 * Driver for Broadcom 63xx SOCs integrated PHYs
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 #include <linux/module.h>
10 #include <linux/phy.h>
12 #define MII_BCM63XX_IR 0x1a /* interrupt register */
13 #define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
14 #define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
15 #define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
16 #define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
17 #define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
19 MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
20 MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
21 MODULE_LICENSE("GPL");
23 static int bcm63xx_config_init(struct phy_device *phydev)
27 reg = phy_read(phydev, MII_BCM63XX_IR);
31 /* Mask interrupts globally. */
32 reg |= MII_BCM63XX_IR_GMASK;
33 err = phy_write(phydev, MII_BCM63XX_IR, reg);
37 /* Unmask events we are interested in */
38 reg = ~(MII_BCM63XX_IR_DUPLEX |
39 MII_BCM63XX_IR_SPEED |
40 MII_BCM63XX_IR_LINK) |
42 return phy_write(phydev, MII_BCM63XX_IR, reg);
45 static int bcm63xx_ack_interrupt(struct phy_device *phydev)
49 /* Clear pending interrupts. */
50 reg = phy_read(phydev, MII_BCM63XX_IR);
57 static int bcm63xx_config_intr(struct phy_device *phydev)
61 reg = phy_read(phydev, MII_BCM63XX_IR);
65 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
66 reg &= ~MII_BCM63XX_IR_GMASK;
68 reg |= MII_BCM63XX_IR_GMASK;
70 err = phy_write(phydev, MII_BCM63XX_IR, reg);
74 static struct phy_driver bcm63xx_1_driver = {
76 .phy_id_mask = 0xfffffc00,
77 .name = "Broadcom BCM63XX (1)",
78 /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
79 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
80 .flags = PHY_HAS_INTERRUPT,
81 .config_init = bcm63xx_config_init,
82 .config_aneg = genphy_config_aneg,
83 .read_status = genphy_read_status,
84 .ack_interrupt = bcm63xx_ack_interrupt,
85 .config_intr = bcm63xx_config_intr,
86 .driver = { .owner = THIS_MODULE },
89 /* same phy as above, with just a different OUI */
90 static struct phy_driver bcm63xx_2_driver = {
92 .phy_id_mask = 0xfffffc00,
93 .name = "Broadcom BCM63XX (2)",
94 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
95 .flags = PHY_HAS_INTERRUPT,
96 .config_init = bcm63xx_config_init,
97 .config_aneg = genphy_config_aneg,
98 .read_status = genphy_read_status,
99 .ack_interrupt = bcm63xx_ack_interrupt,
100 .config_intr = bcm63xx_config_intr,
101 .driver = { .owner = THIS_MODULE },
104 static int __init bcm63xx_phy_init(void)
108 ret = phy_driver_register(&bcm63xx_1_driver);
111 ret = phy_driver_register(&bcm63xx_2_driver);
117 phy_driver_unregister(&bcm63xx_1_driver);
122 static void __exit bcm63xx_phy_exit(void)
124 phy_driver_unregister(&bcm63xx_1_driver);
125 phy_driver_unregister(&bcm63xx_2_driver);
128 module_init(bcm63xx_phy_init);
129 module_exit(bcm63xx_phy_exit);
131 static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
132 { 0x00406000, 0xfffffc00 },
133 { 0x002bdc00, 0xfffffc00 },
137 MODULE_DEVICE_TABLE(mdio, bcm63xx_tbl);