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 diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
15 index d55932a..a5d2c2d 100644
16 --- a/drivers/net/phy/Kconfig
17 +++ b/drivers/net/phy/Kconfig
18 @@ -56,6 +56,12 @@ config BROADCOM_PHY
19 Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481
23 + tristate "Drivers for Broadcom 63xx SOCs internal PHY"
26 + Currently supports the 6348 and 6358 PHYs.
29 tristate "Drivers for ICPlus PHYs"
31 diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
32 index eee329f..0d43f58 100644
33 --- a/drivers/net/phy/Makefile
34 +++ b/drivers/net/phy/Makefile
35 @@ -11,6 +11,7 @@ obj-$(CONFIG_QSEMI_PHY) += qsemi.o
36 obj-$(CONFIG_SMSC_PHY) += smsc.o
37 obj-$(CONFIG_VITESSE_PHY) += vitesse.o
38 obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
39 +obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
40 obj-$(CONFIG_ICPLUS_PHY) += icplus.o
41 obj-$(CONFIG_REALTEK_PHY) += realtek.o
42 obj-$(CONFIG_FIXED_PHY) += fixed.o
43 diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
45 index 0000000..4fed95e
47 +++ b/drivers/net/phy/bcm63xx.c
50 + * Driver for Broadcom 63xx SOCs integrated PHYs
52 + * This program is free software; you can redistribute it and/or
53 + * modify it under the terms of the GNU General Public License
54 + * as published by the Free Software Foundation; either version
55 + * 2 of the License, or (at your option) any later version.
57 +#include <linux/module.h>
58 +#include <linux/phy.h>
60 +#define MII_BCM63XX_IR 0x1a /* interrupt register */
61 +#define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
62 +#define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */
63 +#define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */
64 +#define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
65 +#define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
67 +MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
68 +MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
69 +MODULE_LICENSE("GPL");
71 +static int bcm63xx_config_init(struct phy_device *phydev)
75 + reg = phy_read(phydev, MII_BCM63XX_IR);
79 + /* Mask interrupts globally. */
80 + reg |= MII_BCM63XX_IR_GMASK;
81 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
85 + /* Unmask events we are interested in */
86 + reg = ~(MII_BCM63XX_IR_DUPLEX |
87 + MII_BCM63XX_IR_SPEED |
88 + MII_BCM63XX_IR_LINK) |
90 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
96 +static int bcm63xx_ack_interrupt(struct phy_device *phydev)
100 + /* Clear pending interrupts. */
101 + reg = phy_read(phydev, MII_BCM63XX_IR);
108 +static int bcm63xx_config_intr(struct phy_device *phydev)
112 + reg = phy_read(phydev, MII_BCM63XX_IR);
116 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
117 + reg &= ~MII_BCM63XX_IR_GMASK;
119 + reg |= MII_BCM63XX_IR_GMASK;
121 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
125 +static struct phy_driver bcm63xx_1_driver = {
126 + .phy_id = 0x00406000,
127 + .phy_id_mask = 0xfffffc00,
128 + .name = "Broadcom BCM63XX (1)",
129 + /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
130 + .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
131 + .flags = PHY_HAS_INTERRUPT,
132 + .config_init = bcm63xx_config_init,
133 + .config_aneg = genphy_config_aneg,
134 + .read_status = genphy_read_status,
135 + .ack_interrupt = bcm63xx_ack_interrupt,
136 + .config_intr = bcm63xx_config_intr,
137 + .driver = { .owner = THIS_MODULE },
140 +/* same phy as above, with just a different OUI */
141 +static struct phy_driver bcm63xx_2_driver = {
142 + .phy_id = 0x002bdc00,
143 + .phy_id_mask = 0xfffffc00,
144 + .name = "Broadcom BCM63XX (2)",
145 + .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
146 + .flags = PHY_HAS_INTERRUPT,
147 + .config_init = bcm63xx_config_init,
148 + .config_aneg = genphy_config_aneg,
149 + .read_status = genphy_read_status,
150 + .ack_interrupt = bcm63xx_ack_interrupt,
151 + .config_intr = bcm63xx_config_intr,
152 + .driver = { .owner = THIS_MODULE },
155 +static int __init bcm63xx_phy_init(void)
159 + ret = phy_driver_register(&bcm63xx_1_driver);
162 + ret = phy_driver_register(&bcm63xx_2_driver);
168 + phy_driver_unregister(&bcm63xx_1_driver);
173 +static void __exit bcm63xx_phy_exit(void)
175 + phy_driver_unregister(&bcm63xx_1_driver);
176 + phy_driver_unregister(&bcm63xx_2_driver);
179 +module_init(bcm63xx_phy_init);
180 +module_exit(bcm63xx_phy_exit);