diff options
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/Kconfig | 13 | ||||
-rw-r--r-- | drivers/net/phy/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/phy/dp83640.c | 2 | ||||
-rw-r--r-- | drivers/net/phy/lxt.c | 127 | ||||
-rw-r--r-- | drivers/net/phy/mdio-gpio.c | 132 | ||||
-rw-r--r-- | drivers/net/phy/mdio-mux-mmioreg.c | 171 | ||||
-rw-r--r-- | drivers/net/phy/phy.c | 74 |
7 files changed, 360 insertions, 160 deletions
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 3090dc65a6f1..983bbf4d5ef6 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -159,6 +159,19 @@ config MDIO_BUS_MUX_GPIO | |||
159 | several child MDIO busses to a parent bus. Child bus | 159 | several child MDIO busses to a parent bus. Child bus |
160 | selection is under the control of GPIO lines. | 160 | selection is under the control of GPIO lines. |
161 | 161 | ||
162 | config MDIO_BUS_MUX_MMIOREG | ||
163 | tristate "Support for MMIO device-controlled MDIO bus multiplexers" | ||
164 | depends on OF_MDIO | ||
165 | select MDIO_BUS_MUX | ||
166 | help | ||
167 | This module provides a driver for MDIO bus multiplexers that | ||
168 | are controlled via a simple memory-mapped device, like an FPGA. | ||
169 | The multiplexer connects one of several child MDIO busses to a | ||
170 | parent bus. Child bus selection is under the control of one of | ||
171 | the FPGA's registers. | ||
172 | |||
173 | Currently, only 8-bit registers are supported. | ||
174 | |||
162 | endif # PHYLIB | 175 | endif # PHYLIB |
163 | 176 | ||
164 | config MICREL_KS8995MA | 177 | config MICREL_KS8995MA |
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 6d2dc6c94f2e..426674debae4 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile | |||
@@ -28,3 +28,4 @@ obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o | |||
28 | obj-$(CONFIG_AMD_PHY) += amd.o | 28 | obj-$(CONFIG_AMD_PHY) += amd.o |
29 | obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o | 29 | obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o |
30 | obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o | 30 | obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o |
31 | obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o | ||
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index b0da0226661f..24e05c43bff8 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c | |||
@@ -980,7 +980,7 @@ static int dp83640_probe(struct phy_device *phydev) | |||
980 | 980 | ||
981 | if (choose_this_phy(clock, phydev)) { | 981 | if (choose_this_phy(clock, phydev)) { |
982 | clock->chosen = dp83640; | 982 | clock->chosen = dp83640; |
983 | clock->ptp_clock = ptp_clock_register(&clock->caps); | 983 | clock->ptp_clock = ptp_clock_register(&clock->caps, &phydev->dev); |
984 | if (IS_ERR(clock->ptp_clock)) { | 984 | if (IS_ERR(clock->ptp_clock)) { |
985 | err = PTR_ERR(clock->ptp_clock); | 985 | err = PTR_ERR(clock->ptp_clock); |
986 | goto no_register; | 986 | goto no_register; |
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c index 6d1e3fcc43e2..ec40ba882f61 100644 --- a/drivers/net/phy/lxt.c +++ b/drivers/net/phy/lxt.c | |||
@@ -122,6 +122,123 @@ static int lxt971_config_intr(struct phy_device *phydev) | |||
122 | return err; | 122 | return err; |
123 | } | 123 | } |
124 | 124 | ||
125 | /* | ||
126 | * A2 version of LXT973 chip has an ERRATA: it randomly return the contents | ||
127 | * of the previous even register when you read a odd register regularly | ||
128 | */ | ||
129 | |||
130 | static int lxt973a2_update_link(struct phy_device *phydev) | ||
131 | { | ||
132 | int status; | ||
133 | int control; | ||
134 | int retry = 8; /* we try 8 times */ | ||
135 | |||
136 | /* Do a fake read */ | ||
137 | status = phy_read(phydev, MII_BMSR); | ||
138 | |||
139 | if (status < 0) | ||
140 | return status; | ||
141 | |||
142 | control = phy_read(phydev, MII_BMCR); | ||
143 | if (control < 0) | ||
144 | return control; | ||
145 | |||
146 | do { | ||
147 | /* Read link and autonegotiation status */ | ||
148 | status = phy_read(phydev, MII_BMSR); | ||
149 | } while (status >= 0 && retry-- && status == control); | ||
150 | |||
151 | if (status < 0) | ||
152 | return status; | ||
153 | |||
154 | if ((status & BMSR_LSTATUS) == 0) | ||
155 | phydev->link = 0; | ||
156 | else | ||
157 | phydev->link = 1; | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | int lxt973a2_read_status(struct phy_device *phydev) | ||
163 | { | ||
164 | int adv; | ||
165 | int err; | ||
166 | int lpa; | ||
167 | int lpagb = 0; | ||
168 | |||
169 | /* Update the link, but return if there was an error */ | ||
170 | err = lxt973a2_update_link(phydev); | ||
171 | if (err) | ||
172 | return err; | ||
173 | |||
174 | if (AUTONEG_ENABLE == phydev->autoneg) { | ||
175 | int retry = 1; | ||
176 | |||
177 | adv = phy_read(phydev, MII_ADVERTISE); | ||
178 | |||
179 | if (adv < 0) | ||
180 | return adv; | ||
181 | |||
182 | do { | ||
183 | lpa = phy_read(phydev, MII_LPA); | ||
184 | |||
185 | if (lpa < 0) | ||
186 | return lpa; | ||
187 | |||
188 | /* If both registers are equal, it is suspect but not | ||
189 | * impossible, hence a new try | ||
190 | */ | ||
191 | } while (lpa == adv && retry--); | ||
192 | |||
193 | lpa &= adv; | ||
194 | |||
195 | phydev->speed = SPEED_10; | ||
196 | phydev->duplex = DUPLEX_HALF; | ||
197 | phydev->pause = phydev->asym_pause = 0; | ||
198 | |||
199 | if (lpagb & (LPA_1000FULL | LPA_1000HALF)) { | ||
200 | phydev->speed = SPEED_1000; | ||
201 | |||
202 | if (lpagb & LPA_1000FULL) | ||
203 | phydev->duplex = DUPLEX_FULL; | ||
204 | } else if (lpa & (LPA_100FULL | LPA_100HALF)) { | ||
205 | phydev->speed = SPEED_100; | ||
206 | |||
207 | if (lpa & LPA_100FULL) | ||
208 | phydev->duplex = DUPLEX_FULL; | ||
209 | } else { | ||
210 | if (lpa & LPA_10FULL) | ||
211 | phydev->duplex = DUPLEX_FULL; | ||
212 | } | ||
213 | |||
214 | if (phydev->duplex == DUPLEX_FULL) { | ||
215 | phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0; | ||
216 | phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0; | ||
217 | } | ||
218 | } else { | ||
219 | int bmcr = phy_read(phydev, MII_BMCR); | ||
220 | |||
221 | if (bmcr < 0) | ||
222 | return bmcr; | ||
223 | |||
224 | if (bmcr & BMCR_FULLDPLX) | ||
225 | phydev->duplex = DUPLEX_FULL; | ||
226 | else | ||
227 | phydev->duplex = DUPLEX_HALF; | ||
228 | |||
229 | if (bmcr & BMCR_SPEED1000) | ||
230 | phydev->speed = SPEED_1000; | ||
231 | else if (bmcr & BMCR_SPEED100) | ||
232 | phydev->speed = SPEED_100; | ||
233 | else | ||
234 | phydev->speed = SPEED_10; | ||
235 | |||
236 | phydev->pause = phydev->asym_pause = 0; | ||
237 | } | ||
238 | |||
239 | return 0; | ||
240 | } | ||
241 | |||
125 | static int lxt973_probe(struct phy_device *phydev) | 242 | static int lxt973_probe(struct phy_device *phydev) |
126 | { | 243 | { |
127 | int val = phy_read(phydev, MII_LXT973_PCR); | 244 | int val = phy_read(phydev, MII_LXT973_PCR); |
@@ -175,6 +292,16 @@ static struct phy_driver lxt97x_driver[] = { | |||
175 | .driver = { .owner = THIS_MODULE,}, | 292 | .driver = { .owner = THIS_MODULE,}, |
176 | }, { | 293 | }, { |
177 | .phy_id = 0x00137a10, | 294 | .phy_id = 0x00137a10, |
295 | .name = "LXT973-A2", | ||
296 | .phy_id_mask = 0xffffffff, | ||
297 | .features = PHY_BASIC_FEATURES, | ||
298 | .flags = 0, | ||
299 | .probe = lxt973_probe, | ||
300 | .config_aneg = lxt973_config_aneg, | ||
301 | .read_status = lxt973a2_read_status, | ||
302 | .driver = { .owner = THIS_MODULE,}, | ||
303 | }, { | ||
304 | .phy_id = 0x00137a10, | ||
178 | .name = "LXT973", | 305 | .name = "LXT973", |
179 | .phy_id_mask = 0xfffffff0, | 306 | .phy_id_mask = 0xfffffff0, |
180 | .features = PHY_BASIC_FEATURES, | 307 | .features = PHY_BASIC_FEATURES, |
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index 7189adf54bd1..899274f2f9b1 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c | |||
@@ -28,17 +28,38 @@ | |||
28 | #include <linux/gpio.h> | 28 | #include <linux/gpio.h> |
29 | #include <linux/mdio-gpio.h> | 29 | #include <linux/mdio-gpio.h> |
30 | 30 | ||
31 | #ifdef CONFIG_OF_GPIO | ||
32 | #include <linux/of_gpio.h> | 31 | #include <linux/of_gpio.h> |
33 | #include <linux/of_mdio.h> | 32 | #include <linux/of_mdio.h> |
34 | #include <linux/of_platform.h> | ||
35 | #endif | ||
36 | 33 | ||
37 | struct mdio_gpio_info { | 34 | struct mdio_gpio_info { |
38 | struct mdiobb_ctrl ctrl; | 35 | struct mdiobb_ctrl ctrl; |
39 | int mdc, mdio; | 36 | int mdc, mdio; |
40 | }; | 37 | }; |
41 | 38 | ||
39 | static void *mdio_gpio_of_get_data(struct platform_device *pdev) | ||
40 | { | ||
41 | struct device_node *np = pdev->dev.of_node; | ||
42 | struct mdio_gpio_platform_data *pdata; | ||
43 | int ret; | ||
44 | |||
45 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
46 | if (!pdata) | ||
47 | return NULL; | ||
48 | |||
49 | ret = of_get_gpio(np, 0); | ||
50 | if (ret < 0) | ||
51 | return NULL; | ||
52 | |||
53 | pdata->mdc = ret; | ||
54 | |||
55 | ret = of_get_gpio(np, 1); | ||
56 | if (ret < 0) | ||
57 | return NULL; | ||
58 | pdata->mdio = ret; | ||
59 | |||
60 | return pdata; | ||
61 | } | ||
62 | |||
42 | static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir) | 63 | static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir) |
43 | { | 64 | { |
44 | struct mdio_gpio_info *bitbang = | 65 | struct mdio_gpio_info *bitbang = |
@@ -162,10 +183,15 @@ static void __devexit mdio_gpio_bus_destroy(struct device *dev) | |||
162 | 183 | ||
163 | static int __devinit mdio_gpio_probe(struct platform_device *pdev) | 184 | static int __devinit mdio_gpio_probe(struct platform_device *pdev) |
164 | { | 185 | { |
165 | struct mdio_gpio_platform_data *pdata = pdev->dev.platform_data; | 186 | struct mdio_gpio_platform_data *pdata; |
166 | struct mii_bus *new_bus; | 187 | struct mii_bus *new_bus; |
167 | int ret; | 188 | int ret; |
168 | 189 | ||
190 | if (pdev->dev.of_node) | ||
191 | pdata = mdio_gpio_of_get_data(pdev); | ||
192 | else | ||
193 | pdata = pdev->dev.platform_data; | ||
194 | |||
169 | if (!pdata) | 195 | if (!pdata) |
170 | return -ENODEV; | 196 | return -ENODEV; |
171 | 197 | ||
@@ -173,7 +199,11 @@ static int __devinit mdio_gpio_probe(struct platform_device *pdev) | |||
173 | if (!new_bus) | 199 | if (!new_bus) |
174 | return -ENODEV; | 200 | return -ENODEV; |
175 | 201 | ||
176 | ret = mdiobus_register(new_bus); | 202 | if (pdev->dev.of_node) |
203 | ret = of_mdiobus_register(new_bus, pdev->dev.of_node); | ||
204 | else | ||
205 | ret = mdiobus_register(new_bus); | ||
206 | |||
177 | if (ret) | 207 | if (ret) |
178 | mdio_gpio_bus_deinit(&pdev->dev); | 208 | mdio_gpio_bus_deinit(&pdev->dev); |
179 | 209 | ||
@@ -187,112 +217,30 @@ static int __devexit mdio_gpio_remove(struct platform_device *pdev) | |||
187 | return 0; | 217 | return 0; |
188 | } | 218 | } |
189 | 219 | ||
190 | #ifdef CONFIG_OF_GPIO | 220 | static struct of_device_id mdio_gpio_of_match[] = { |
191 | 221 | { .compatible = "virtual,mdio-gpio", }, | |
192 | static int __devinit mdio_ofgpio_probe(struct platform_device *ofdev) | 222 | { /* sentinel */ } |
193 | { | ||
194 | struct mdio_gpio_platform_data *pdata; | ||
195 | struct mii_bus *new_bus; | ||
196 | int ret; | ||
197 | |||
198 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | ||
199 | if (!pdata) | ||
200 | return -ENOMEM; | ||
201 | |||
202 | ret = of_get_gpio(ofdev->dev.of_node, 0); | ||
203 | if (ret < 0) | ||
204 | goto out_free; | ||
205 | pdata->mdc = ret; | ||
206 | |||
207 | ret = of_get_gpio(ofdev->dev.of_node, 1); | ||
208 | if (ret < 0) | ||
209 | goto out_free; | ||
210 | pdata->mdio = ret; | ||
211 | |||
212 | new_bus = mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc); | ||
213 | if (!new_bus) | ||
214 | goto out_free; | ||
215 | |||
216 | ret = of_mdiobus_register(new_bus, ofdev->dev.of_node); | ||
217 | if (ret) | ||
218 | mdio_gpio_bus_deinit(&ofdev->dev); | ||
219 | |||
220 | return ret; | ||
221 | |||
222 | out_free: | ||
223 | kfree(pdata); | ||
224 | return -ENODEV; | ||
225 | } | ||
226 | |||
227 | static int __devexit mdio_ofgpio_remove(struct platform_device *ofdev) | ||
228 | { | ||
229 | mdio_gpio_bus_destroy(&ofdev->dev); | ||
230 | kfree(ofdev->dev.platform_data); | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | static struct of_device_id mdio_ofgpio_match[] = { | ||
236 | { | ||
237 | .compatible = "virtual,mdio-gpio", | ||
238 | }, | ||
239 | {}, | ||
240 | }; | ||
241 | MODULE_DEVICE_TABLE(of, mdio_ofgpio_match); | ||
242 | |||
243 | static struct platform_driver mdio_ofgpio_driver = { | ||
244 | .driver = { | ||
245 | .name = "mdio-ofgpio", | ||
246 | .owner = THIS_MODULE, | ||
247 | .of_match_table = mdio_ofgpio_match, | ||
248 | }, | ||
249 | .probe = mdio_ofgpio_probe, | ||
250 | .remove = __devexit_p(mdio_ofgpio_remove), | ||
251 | }; | 223 | }; |
252 | 224 | ||
253 | static inline int __init mdio_ofgpio_init(void) | ||
254 | { | ||
255 | return platform_driver_register(&mdio_ofgpio_driver); | ||
256 | } | ||
257 | |||
258 | static inline void mdio_ofgpio_exit(void) | ||
259 | { | ||
260 | platform_driver_unregister(&mdio_ofgpio_driver); | ||
261 | } | ||
262 | #else | ||
263 | static inline int __init mdio_ofgpio_init(void) { return 0; } | ||
264 | static inline void mdio_ofgpio_exit(void) { } | ||
265 | #endif /* CONFIG_OF_GPIO */ | ||
266 | |||
267 | static struct platform_driver mdio_gpio_driver = { | 225 | static struct platform_driver mdio_gpio_driver = { |
268 | .probe = mdio_gpio_probe, | 226 | .probe = mdio_gpio_probe, |
269 | .remove = __devexit_p(mdio_gpio_remove), | 227 | .remove = __devexit_p(mdio_gpio_remove), |
270 | .driver = { | 228 | .driver = { |
271 | .name = "mdio-gpio", | 229 | .name = "mdio-gpio", |
272 | .owner = THIS_MODULE, | 230 | .owner = THIS_MODULE, |
231 | .of_match_table = mdio_gpio_of_match, | ||
273 | }, | 232 | }, |
274 | }; | 233 | }; |
275 | 234 | ||
276 | static int __init mdio_gpio_init(void) | 235 | static int __init mdio_gpio_init(void) |
277 | { | 236 | { |
278 | int ret; | 237 | return platform_driver_register(&mdio_gpio_driver); |
279 | |||
280 | ret = mdio_ofgpio_init(); | ||
281 | if (ret) | ||
282 | return ret; | ||
283 | |||
284 | ret = platform_driver_register(&mdio_gpio_driver); | ||
285 | if (ret) | ||
286 | mdio_ofgpio_exit(); | ||
287 | |||
288 | return ret; | ||
289 | } | 238 | } |
290 | module_init(mdio_gpio_init); | 239 | module_init(mdio_gpio_init); |
291 | 240 | ||
292 | static void __exit mdio_gpio_exit(void) | 241 | static void __exit mdio_gpio_exit(void) |
293 | { | 242 | { |
294 | platform_driver_unregister(&mdio_gpio_driver); | 243 | platform_driver_unregister(&mdio_gpio_driver); |
295 | mdio_ofgpio_exit(); | ||
296 | } | 244 | } |
297 | module_exit(mdio_gpio_exit); | 245 | module_exit(mdio_gpio_exit); |
298 | 246 | ||
diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c new file mode 100644 index 000000000000..9061ba622ac4 --- /dev/null +++ b/drivers/net/phy/mdio-mux-mmioreg.c | |||
@@ -0,0 +1,171 @@ | |||
1 | /* | ||
2 | * Simple memory-mapped device MDIO MUX driver | ||
3 | * | ||
4 | * Author: Timur Tabi <timur@freescale.com> | ||
5 | * | ||
6 | * Copyright 2012 Freescale Semiconductor, Inc. | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public License | ||
9 | * version 2. This program is licensed "as is" without any warranty of any | ||
10 | * kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/of_address.h> | ||
16 | #include <linux/of_mdio.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/phy.h> | ||
20 | #include <linux/mdio-mux.h> | ||
21 | |||
22 | struct mdio_mux_mmioreg_state { | ||
23 | void *mux_handle; | ||
24 | phys_addr_t phys; | ||
25 | uint8_t mask; | ||
26 | }; | ||
27 | |||
28 | /* | ||
29 | * MDIO multiplexing switch function | ||
30 | * | ||
31 | * This function is called by the mdio-mux layer when it thinks the mdio bus | ||
32 | * multiplexer needs to switch. | ||
33 | * | ||
34 | * 'current_child' is the current value of the mux register (masked via | ||
35 | * s->mask). | ||
36 | * | ||
37 | * 'desired_child' is the value of the 'reg' property of the target child MDIO | ||
38 | * node. | ||
39 | * | ||
40 | * The first time this function is called, current_child == -1. | ||
41 | * | ||
42 | * If current_child == desired_child, then the mux is already set to the | ||
43 | * correct bus. | ||
44 | */ | ||
45 | static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child, | ||
46 | void *data) | ||
47 | { | ||
48 | struct mdio_mux_mmioreg_state *s = data; | ||
49 | |||
50 | if (current_child ^ desired_child) { | ||
51 | void *p = ioremap(s->phys, 1); | ||
52 | uint8_t x, y; | ||
53 | |||
54 | if (!p) | ||
55 | return -ENOMEM; | ||
56 | |||
57 | x = ioread8(p); | ||
58 | y = (x & ~s->mask) | desired_child; | ||
59 | if (x != y) { | ||
60 | iowrite8((x & ~s->mask) | desired_child, p); | ||
61 | pr_debug("%s: %02x -> %02x\n", __func__, x, y); | ||
62 | } | ||
63 | |||
64 | iounmap(p); | ||
65 | } | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int __devinit mdio_mux_mmioreg_probe(struct platform_device *pdev) | ||
71 | { | ||
72 | struct device_node *np2, *np = pdev->dev.of_node; | ||
73 | struct mdio_mux_mmioreg_state *s; | ||
74 | struct resource res; | ||
75 | const __be32 *iprop; | ||
76 | int len, ret; | ||
77 | |||
78 | dev_dbg(&pdev->dev, "probing node %s\n", np->full_name); | ||
79 | |||
80 | s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL); | ||
81 | if (!s) | ||
82 | return -ENOMEM; | ||
83 | |||
84 | ret = of_address_to_resource(np, 0, &res); | ||
85 | if (ret) { | ||
86 | dev_err(&pdev->dev, "could not obtain memory map for node %s\n", | ||
87 | np->full_name); | ||
88 | return ret; | ||
89 | } | ||
90 | s->phys = res.start; | ||
91 | |||
92 | if (resource_size(&res) != sizeof(uint8_t)) { | ||
93 | dev_err(&pdev->dev, "only 8-bit registers are supported\n"); | ||
94 | return -EINVAL; | ||
95 | } | ||
96 | |||
97 | iprop = of_get_property(np, "mux-mask", &len); | ||
98 | if (!iprop || len != sizeof(uint32_t)) { | ||
99 | dev_err(&pdev->dev, "missing or invalid mux-mask property\n"); | ||
100 | return -ENODEV; | ||
101 | } | ||
102 | if (be32_to_cpup(iprop) > 255) { | ||
103 | dev_err(&pdev->dev, "only 8-bit registers are supported\n"); | ||
104 | return -EINVAL; | ||
105 | } | ||
106 | s->mask = be32_to_cpup(iprop); | ||
107 | |||
108 | /* | ||
109 | * Verify that the 'reg' property of each child MDIO bus does not | ||
110 | * set any bits outside of the 'mask'. | ||
111 | */ | ||
112 | for_each_available_child_of_node(np, np2) { | ||
113 | iprop = of_get_property(np2, "reg", &len); | ||
114 | if (!iprop || len != sizeof(uint32_t)) { | ||
115 | dev_err(&pdev->dev, "mdio-mux child node %s is " | ||
116 | "missing a 'reg' property\n", np2->full_name); | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | if (be32_to_cpup(iprop) & ~s->mask) { | ||
120 | dev_err(&pdev->dev, "mdio-mux child node %s has " | ||
121 | "a 'reg' value with unmasked bits\n", | ||
122 | np2->full_name); | ||
123 | return -ENODEV; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | ret = mdio_mux_init(&pdev->dev, mdio_mux_mmioreg_switch_fn, | ||
128 | &s->mux_handle, s); | ||
129 | if (ret) { | ||
130 | dev_err(&pdev->dev, "failed to register mdio-mux bus %s\n", | ||
131 | np->full_name); | ||
132 | return ret; | ||
133 | } | ||
134 | |||
135 | pdev->dev.platform_data = s; | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static int __devexit mdio_mux_mmioreg_remove(struct platform_device *pdev) | ||
141 | { | ||
142 | struct mdio_mux_mmioreg_state *s = dev_get_platdata(&pdev->dev); | ||
143 | |||
144 | mdio_mux_uninit(s->mux_handle); | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static struct of_device_id mdio_mux_mmioreg_match[] = { | ||
150 | { | ||
151 | .compatible = "mdio-mux-mmioreg", | ||
152 | }, | ||
153 | {}, | ||
154 | }; | ||
155 | MODULE_DEVICE_TABLE(of, mdio_mux_mmioreg_match); | ||
156 | |||
157 | static struct platform_driver mdio_mux_mmioreg_driver = { | ||
158 | .driver = { | ||
159 | .name = "mdio-mux-mmioreg", | ||
160 | .owner = THIS_MODULE, | ||
161 | .of_match_table = mdio_mux_mmioreg_match, | ||
162 | }, | ||
163 | .probe = mdio_mux_mmioreg_probe, | ||
164 | .remove = __devexit_p(mdio_mux_mmioreg_remove), | ||
165 | }; | ||
166 | |||
167 | module_platform_driver(mdio_mux_mmioreg_driver); | ||
168 | |||
169 | MODULE_AUTHOR("Timur Tabi <timur@freescale.com>"); | ||
170 | MODULE_DESCRIPTION("Memory-mapped device MDIO MUX driver"); | ||
171 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 7ca2ff97c368..ef9ea9248223 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -1035,66 +1035,6 @@ static void phy_write_mmd_indirect(struct mii_bus *bus, int prtad, int devad, | |||
1035 | bus->write(bus, addr, MII_MMD_DATA, data); | 1035 | bus->write(bus, addr, MII_MMD_DATA, data); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | static u32 phy_eee_to_adv(u16 eee_adv) | ||
1039 | { | ||
1040 | u32 adv = 0; | ||
1041 | |||
1042 | if (eee_adv & MDIO_EEE_100TX) | ||
1043 | adv |= ADVERTISED_100baseT_Full; | ||
1044 | if (eee_adv & MDIO_EEE_1000T) | ||
1045 | adv |= ADVERTISED_1000baseT_Full; | ||
1046 | if (eee_adv & MDIO_EEE_10GT) | ||
1047 | adv |= ADVERTISED_10000baseT_Full; | ||
1048 | if (eee_adv & MDIO_EEE_1000KX) | ||
1049 | adv |= ADVERTISED_1000baseKX_Full; | ||
1050 | if (eee_adv & MDIO_EEE_10GKX4) | ||
1051 | adv |= ADVERTISED_10000baseKX4_Full; | ||
1052 | if (eee_adv & MDIO_EEE_10GKR) | ||
1053 | adv |= ADVERTISED_10000baseKR_Full; | ||
1054 | |||
1055 | return adv; | ||
1056 | } | ||
1057 | |||
1058 | static u32 phy_eee_to_supported(u16 eee_caported) | ||
1059 | { | ||
1060 | u32 supported = 0; | ||
1061 | |||
1062 | if (eee_caported & MDIO_EEE_100TX) | ||
1063 | supported |= SUPPORTED_100baseT_Full; | ||
1064 | if (eee_caported & MDIO_EEE_1000T) | ||
1065 | supported |= SUPPORTED_1000baseT_Full; | ||
1066 | if (eee_caported & MDIO_EEE_10GT) | ||
1067 | supported |= SUPPORTED_10000baseT_Full; | ||
1068 | if (eee_caported & MDIO_EEE_1000KX) | ||
1069 | supported |= SUPPORTED_1000baseKX_Full; | ||
1070 | if (eee_caported & MDIO_EEE_10GKX4) | ||
1071 | supported |= SUPPORTED_10000baseKX4_Full; | ||
1072 | if (eee_caported & MDIO_EEE_10GKR) | ||
1073 | supported |= SUPPORTED_10000baseKR_Full; | ||
1074 | |||
1075 | return supported; | ||
1076 | } | ||
1077 | |||
1078 | static u16 phy_adv_to_eee(u32 adv) | ||
1079 | { | ||
1080 | u16 reg = 0; | ||
1081 | |||
1082 | if (adv & ADVERTISED_100baseT_Full) | ||
1083 | reg |= MDIO_EEE_100TX; | ||
1084 | if (adv & ADVERTISED_1000baseT_Full) | ||
1085 | reg |= MDIO_EEE_1000T; | ||
1086 | if (adv & ADVERTISED_10000baseT_Full) | ||
1087 | reg |= MDIO_EEE_10GT; | ||
1088 | if (adv & ADVERTISED_1000baseKX_Full) | ||
1089 | reg |= MDIO_EEE_1000KX; | ||
1090 | if (adv & ADVERTISED_10000baseKX4_Full) | ||
1091 | reg |= MDIO_EEE_10GKX4; | ||
1092 | if (adv & ADVERTISED_10000baseKR_Full) | ||
1093 | reg |= MDIO_EEE_10GKR; | ||
1094 | |||
1095 | return reg; | ||
1096 | } | ||
1097 | |||
1098 | /** | 1038 | /** |
1099 | * phy_init_eee - init and check the EEE feature | 1039 | * phy_init_eee - init and check the EEE feature |
1100 | * @phydev: target phy_device struct | 1040 | * @phydev: target phy_device struct |
@@ -1132,7 +1072,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) | |||
1132 | if (eee_cap < 0) | 1072 | if (eee_cap < 0) |
1133 | return eee_cap; | 1073 | return eee_cap; |
1134 | 1074 | ||
1135 | cap = phy_eee_to_supported(eee_cap); | 1075 | cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); |
1136 | if (!cap) | 1076 | if (!cap) |
1137 | goto eee_exit; | 1077 | goto eee_exit; |
1138 | 1078 | ||
@@ -1149,8 +1089,8 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable) | |||
1149 | if (eee_adv < 0) | 1089 | if (eee_adv < 0) |
1150 | return eee_adv; | 1090 | return eee_adv; |
1151 | 1091 | ||
1152 | adv = phy_eee_to_adv(eee_adv); | 1092 | adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); |
1153 | lp = phy_eee_to_adv(eee_lp); | 1093 | lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); |
1154 | idx = phy_find_setting(phydev->speed, phydev->duplex); | 1094 | idx = phy_find_setting(phydev->speed, phydev->duplex); |
1155 | if ((lp & adv & settings[idx].setting)) | 1095 | if ((lp & adv & settings[idx].setting)) |
1156 | goto eee_exit; | 1096 | goto eee_exit; |
@@ -1210,21 +1150,21 @@ int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data) | |||
1210 | MDIO_MMD_PCS, phydev->addr); | 1150 | MDIO_MMD_PCS, phydev->addr); |
1211 | if (val < 0) | 1151 | if (val < 0) |
1212 | return val; | 1152 | return val; |
1213 | data->supported = phy_eee_to_supported(val); | 1153 | data->supported = mmd_eee_cap_to_ethtool_sup_t(val); |
1214 | 1154 | ||
1215 | /* Get advertisement EEE */ | 1155 | /* Get advertisement EEE */ |
1216 | val = phy_read_mmd_indirect(phydev->bus, MDIO_AN_EEE_ADV, | 1156 | val = phy_read_mmd_indirect(phydev->bus, MDIO_AN_EEE_ADV, |
1217 | MDIO_MMD_AN, phydev->addr); | 1157 | MDIO_MMD_AN, phydev->addr); |
1218 | if (val < 0) | 1158 | if (val < 0) |
1219 | return val; | 1159 | return val; |
1220 | data->advertised = phy_eee_to_adv(val); | 1160 | data->advertised = mmd_eee_adv_to_ethtool_adv_t(val); |
1221 | 1161 | ||
1222 | /* Get LP advertisement EEE */ | 1162 | /* Get LP advertisement EEE */ |
1223 | val = phy_read_mmd_indirect(phydev->bus, MDIO_AN_EEE_LPABLE, | 1163 | val = phy_read_mmd_indirect(phydev->bus, MDIO_AN_EEE_LPABLE, |
1224 | MDIO_MMD_AN, phydev->addr); | 1164 | MDIO_MMD_AN, phydev->addr); |
1225 | if (val < 0) | 1165 | if (val < 0) |
1226 | return val; | 1166 | return val; |
1227 | data->lp_advertised = phy_eee_to_adv(val); | 1167 | data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); |
1228 | 1168 | ||
1229 | return 0; | 1169 | return 0; |
1230 | } | 1170 | } |
@@ -1241,7 +1181,7 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data) | |||
1241 | { | 1181 | { |
1242 | int val; | 1182 | int val; |
1243 | 1183 | ||
1244 | val = phy_adv_to_eee(data->advertised); | 1184 | val = ethtool_adv_to_mmd_eee_adv_t(data->advertised); |
1245 | phy_write_mmd_indirect(phydev->bus, MDIO_AN_EEE_ADV, MDIO_MMD_AN, | 1185 | phy_write_mmd_indirect(phydev->bus, MDIO_AN_EEE_ADV, MDIO_MMD_AN, |
1246 | phydev->addr, val); | 1186 | phydev->addr, val); |
1247 | 1187 | ||