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 "bcm-phy-lib.h"
10 #include <linux/module.h>
11 #include <linux/phy.h>
13 #define MII_BCM63XX_IR 0x1a /* interrupt register */
14 #define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
15 #define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
16 #define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
17 #define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
18 #define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
20 MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
21 MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
22 MODULE_LICENSE("GPL");
24 static int bcm63xx_config_intr(struct phy_device
*phydev
)
28 reg
= phy_read(phydev
, MII_BCM63XX_IR
);
32 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
)
33 reg
&= ~MII_BCM63XX_IR_GMASK
;
35 reg
|= MII_BCM63XX_IR_GMASK
;
37 err
= phy_write(phydev
, MII_BCM63XX_IR
, reg
);
41 static int bcm63xx_config_init(struct phy_device
*phydev
)
45 /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
46 phydev
->supported
|= SUPPORTED_Pause
;
48 reg
= phy_read(phydev
, MII_BCM63XX_IR
);
52 /* Mask interrupts globally. */
53 reg
|= MII_BCM63XX_IR_GMASK
;
54 err
= phy_write(phydev
, MII_BCM63XX_IR
, reg
);
58 /* Unmask events we are interested in */
59 reg
= ~(MII_BCM63XX_IR_DUPLEX
|
60 MII_BCM63XX_IR_SPEED
|
61 MII_BCM63XX_IR_LINK
) |
63 return phy_write(phydev
, MII_BCM63XX_IR
, reg
);
66 static struct phy_driver bcm63xx_driver
[] = {
69 .phy_id_mask
= 0xfffffc00,
70 .name
= "Broadcom BCM63XX (1)",
71 .features
= PHY_BASIC_FEATURES
,
72 .flags
= PHY_HAS_INTERRUPT
| PHY_IS_INTERNAL
,
73 .config_init
= bcm63xx_config_init
,
74 .ack_interrupt
= bcm_phy_ack_intr
,
75 .config_intr
= bcm63xx_config_intr
,
77 /* same phy as above, with just a different OUI */
79 .phy_id_mask
= 0xfffffc00,
80 .features
= PHY_BASIC_FEATURES
,
81 .flags
= PHY_HAS_INTERRUPT
| PHY_IS_INTERNAL
,
82 .config_init
= bcm63xx_config_init
,
83 .ack_interrupt
= bcm_phy_ack_intr
,
84 .config_intr
= bcm63xx_config_intr
,
87 module_phy_driver(bcm63xx_driver
);
89 static struct mdio_device_id __maybe_unused bcm63xx_tbl
[] = {
90 { 0x00406000, 0xfffffc00 },
91 { 0x002bdc00, 0xfffffc00 },
95 MODULE_DEVICE_TABLE(mdio
, bcm63xx_tbl
);