[kernel] update to 2.6.25.20, 2.6.26.8, 2.6.27.5 and refresh patches
[openwrt.git] / target / linux / brcm63xx / patches-2.6.27 / 010-add_integrated_ethernet_phy_support.patch
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.
5
6 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
7 ---
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
13
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
18 and BCM5482 PHYs.
19
20 +config BCM63XX_PHY
21 + tristate "Drivers for Broadcom 63xx SOCs internal PHY"
22 + depends on BCM63XX
23 + ---help---
24 + Currently supports the 6348 and 6358 PHYs.
25 +
26 config ICPLUS_PHY
27 tristate "Drivers for ICPlus PHYs"
28 ---help---
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
39 --- /dev/null
40 +++ b/drivers/net/phy/bcm63xx.c
41 @@ -0,0 +1,132 @@
42 +/*
43 + * Driver for Broadcom 63xx SOCs integrated PHYs
44 + *
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.
49 + */
50 +#include <linux/module.h>
51 +#include <linux/phy.h>
52 +
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 */
59 +
60 +MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
61 +MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
62 +MODULE_LICENSE("GPL");
63 +
64 +static int bcm63xx_config_init(struct phy_device *phydev)
65 +{
66 + int reg, err;
67 +
68 + reg = phy_read(phydev, MII_BCM63XX_IR);
69 + if (reg < 0)
70 + return reg;
71 +
72 + /* Mask interrupts globally. */
73 + reg |= MII_BCM63XX_IR_GMASK;
74 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
75 + if (err < 0)
76 + return err;
77 +
78 + /* Unmask events we are interested in */
79 + reg = ~(MII_BCM63XX_IR_DUPLEX |
80 + MII_BCM63XX_IR_SPEED |
81 + MII_BCM63XX_IR_LINK) |
82 + MII_BCM63XX_IR_EN;
83 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
84 + if (err < 0)
85 + return err;
86 + return 0;
87 +}
88 +
89 +static int bcm63xx_ack_interrupt(struct phy_device *phydev)
90 +{
91 + int reg;
92 +
93 + /* Clear pending interrupts. */
94 + reg = phy_read(phydev, MII_BCM63XX_IR);
95 + if (reg < 0)
96 + return reg;
97 +
98 + return 0;
99 +}
100 +
101 +static int bcm63xx_config_intr(struct phy_device *phydev)
102 +{
103 + int reg, err;
104 +
105 + reg = phy_read(phydev, MII_BCM63XX_IR);
106 + if (reg < 0)
107 + return reg;
108 +
109 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
110 + reg &= ~MII_BCM63XX_IR_GMASK;
111 + else
112 + reg |= MII_BCM63XX_IR_GMASK;
113 +
114 + err = phy_write(phydev, MII_BCM63XX_IR, reg);
115 + return err;
116 +}
117 +
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 },
131 +};
132 +
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 },
146 +};
147 +
148 +static int __init bcm63xx_phy_init(void)
149 +{
150 + int ret;
151 +
152 + ret = phy_driver_register(&bcm63xx_1_driver);
153 + if (ret)
154 + goto out_63xx_1;
155 + ret = phy_driver_register(&bcm63xx_2_driver);
156 + if (ret)
157 + goto out_63xx_2;
158 + return ret;
159 +
160 +out_63xx_2:
161 + phy_driver_unregister(&bcm63xx_1_driver);
162 +out_63xx_1:
163 + return ret;
164 +}
165 +
166 +static void __exit bcm63xx_phy_exit(void)
167 +{
168 + phy_driver_unregister(&bcm63xx_1_driver);
169 + phy_driver_unregister(&bcm63xx_2_driver);
170 +}
171 +
172 +module_init(bcm63xx_phy_init);
173 +module_exit(bcm63xx_phy_exit);
This page took 0.046897 seconds and 5 git commands to generate.