1 From 7eefcb968019804e024c8243e28afb1eebd674a2 Mon Sep 17 00:00:00 2001
2 From: Maxime Bizon <mbizon@freebox.fr>
3 Date: Sun, 21 Sep 2008 02:20:53 +0200
4 Subject: [PATCH] [MIPS] BCM63XX: Add integrated ethernet PHY support for phylib.
6 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
8 drivers/net/phy/Kconfig | 6 ++
9 drivers/net/phy/Makefile | 1 +
10 drivers/net/phy/bcm63xx.c | 132 +++++++++++++++++++++++++++++++++++++++++++++
11 3 files changed, 139 insertions(+), 0 deletions(-)
12 create mode 100644 drivers/net/phy/bcm63xx.c
14 --- a/drivers/net/phy/Kconfig
15 +++ b/drivers/net/phy/Kconfig
16 @@ -62,6 +62,12 @@ config BROADCOM_PHY
17 Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481
21 + tristate "Drivers for Broadcom 63xx SOCs internal PHY"
24 + Currently supports the 6348 and 6358 PHYs.
27 tristate "Drivers for ICPlus PHYs"
29 --- a/drivers/net/phy/Makefile
30 +++ b/drivers/net/phy/Makefile
31 @@ -12,6 +12,7 @@ obj-$(CONFIG_QSEMI_PHY) += qsemi.o
32 obj-$(CONFIG_SMSC_PHY) += smsc.o
33 obj-$(CONFIG_VITESSE_PHY) += vitesse.o
34 obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
35 +obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
36 obj-$(CONFIG_ICPLUS_PHY) += icplus.o
37 obj-$(CONFIG_ADM6996_PHY) += adm6996.o
38 obj-$(CONFIG_MVSWITCH_PHY) += mvswitch.o
40 +++ b/drivers/net/phy/bcm63xx.c
43 + * Driver for Broadcom 63xx SOCs integrated PHYs
45 + * This program is free software; you can redistribute it and/or
46 + * modify it under the terms of the GNU General Public License
47 + * as published by the Free Software Foundation; either version
48 + * 2 of the License, or (at your option) any later version.
50 +#include <linux/module.h>
51 +#include <linux/phy.h>
53 +#define MII_BCM63XX_IR 0x1a /* interrupt register */
54 +#define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
55 +#define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
56 +#define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
57 +#define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
58 +#define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
60 +MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
61 +MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
62 +MODULE_LICENSE("GPL");
64 +static int bcm63xx_config_init(struct phy_device *phydev)
68 + reg = phy_read(phydev, MII_BCM63XX_IR);
72 + /* Mask interrupts globally. */
73 + reg |= MII_BCM63XX_IR_GMASK;
74 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
78 + /* Unmask events we are interested in */
79 + reg = ~(MII_BCM63XX_IR_DUPLEX |
80 + MII_BCM63XX_IR_SPEED |
81 + MII_BCM63XX_IR_LINK) |
83 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
89 +static int bcm63xx_ack_interrupt(struct phy_device *phydev)
93 + /* Clear pending interrupts. */
94 + reg = phy_read(phydev, MII_BCM63XX_IR);
101 +static int bcm63xx_config_intr(struct phy_device *phydev)
105 + reg = phy_read(phydev, MII_BCM63XX_IR);
109 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
110 + reg &= ~MII_BCM63XX_IR_GMASK;
112 + reg |= MII_BCM63XX_IR_GMASK;
114 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
118 +static struct phy_driver bcm63xx_1_driver = {
119 + .phy_id = 0x00406000,
120 + .phy_id_mask = 0xfffffc00,
121 + .name = "Broadcom BCM63XX (1)",
122 + /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
123 + .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
124 + .flags = PHY_HAS_INTERRUPT,
125 + .config_init = bcm63xx_config_init,
126 + .config_aneg = genphy_config_aneg,
127 + .read_status = genphy_read_status,
128 + .ack_interrupt = bcm63xx_ack_interrupt,
129 + .config_intr = bcm63xx_config_intr,
130 + .driver = { .owner = THIS_MODULE },
133 +/* same phy as above, with just a different OUI */
134 +static struct phy_driver bcm63xx_2_driver = {
135 + .phy_id = 0x002bdc00,
136 + .phy_id_mask = 0xfffffc00,
137 + .name = "Broadcom BCM63XX (2)",
138 + .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
139 + .flags = PHY_HAS_INTERRUPT,
140 + .config_init = bcm63xx_config_init,
141 + .config_aneg = genphy_config_aneg,
142 + .read_status = genphy_read_status,
143 + .ack_interrupt = bcm63xx_ack_interrupt,
144 + .config_intr = bcm63xx_config_intr,
145 + .driver = { .owner = THIS_MODULE },
148 +static int __init bcm63xx_phy_init(void)
152 + ret = phy_driver_register(&bcm63xx_1_driver);
155 + ret = phy_driver_register(&bcm63xx_2_driver);
161 + phy_driver_unregister(&bcm63xx_1_driver);
166 +static void __exit bcm63xx_phy_exit(void)
168 + phy_driver_unregister(&bcm63xx_1_driver);
169 + phy_driver_unregister(&bcm63xx_2_driver);
172 +module_init(bcm63xx_phy_init);
173 +module_exit(bcm63xx_phy_exit);