diff options
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/82xx/ep8248e.c | 9 | ||||
-rw-r--r-- | arch/powerpc/platforms/pasemi/gpio_mdio.c | 32 |
2 files changed, 8 insertions, 33 deletions
diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c index 0eb6d7f62241..51fcae41f08a 100644 --- a/arch/powerpc/platforms/82xx/ep8248e.c +++ b/arch/powerpc/platforms/82xx/ep8248e.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/fsl_devices.h> | 15 | #include <linux/fsl_devices.h> |
16 | #include <linux/mdio-bitbang.h> | 16 | #include <linux/mdio-bitbang.h> |
17 | #include <linux/of_mdio.h> | ||
17 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
18 | 19 | ||
19 | #include <asm/io.h> | 20 | #include <asm/io.h> |
@@ -115,7 +116,7 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, | |||
115 | struct mii_bus *bus; | 116 | struct mii_bus *bus; |
116 | struct resource res; | 117 | struct resource res; |
117 | struct device_node *node; | 118 | struct device_node *node; |
118 | int ret, i; | 119 | int ret; |
119 | 120 | ||
120 | node = of_get_parent(ofdev->node); | 121 | node = of_get_parent(ofdev->node); |
121 | of_node_put(node); | 122 | of_node_put(node); |
@@ -130,17 +131,13 @@ static int __devinit ep8248e_mdio_probe(struct of_device *ofdev, | |||
130 | if (!bus) | 131 | if (!bus) |
131 | return -ENOMEM; | 132 | return -ENOMEM; |
132 | 133 | ||
133 | bus->phy_mask = 0; | ||
134 | bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); | 134 | bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); |
135 | 135 | ||
136 | for (i = 0; i < PHY_MAX_ADDR; i++) | ||
137 | bus->irq[i] = -1; | ||
138 | |||
139 | bus->name = "ep8248e-mdio-bitbang"; | 136 | bus->name = "ep8248e-mdio-bitbang"; |
140 | bus->parent = &ofdev->dev; | 137 | bus->parent = &ofdev->dev; |
141 | snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); | 138 | snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); |
142 | 139 | ||
143 | return mdiobus_register(bus); | 140 | return of_mdiobus_register(bus, ofdev->node); |
144 | } | 141 | } |
145 | 142 | ||
146 | static int ep8248e_mdio_remove(struct of_device *ofdev) | 143 | static int ep8248e_mdio_remove(struct of_device *ofdev) |
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c index 75cc165d5bee..3bf546797cbb 100644 --- a/arch/powerpc/platforms/pasemi/gpio_mdio.c +++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/phy.h> | 31 | #include <linux/phy.h> |
32 | #include <linux/platform_device.h> | 32 | #include <linux/of_mdio.h> |
33 | #include <linux/of_platform.h> | 33 | #include <linux/of_platform.h> |
34 | 34 | ||
35 | #define DELAY 1 | 35 | #define DELAY 1 |
@@ -39,6 +39,7 @@ static void __iomem *gpio_regs; | |||
39 | struct gpio_priv { | 39 | struct gpio_priv { |
40 | int mdc_pin; | 40 | int mdc_pin; |
41 | int mdio_pin; | 41 | int mdio_pin; |
42 | int mdio_irqs[PHY_MAX_ADDR]; | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | #define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin) | 45 | #define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin) |
@@ -218,12 +219,11 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev, | |||
218 | const struct of_device_id *match) | 219 | const struct of_device_id *match) |
219 | { | 220 | { |
220 | struct device *dev = &ofdev->dev; | 221 | struct device *dev = &ofdev->dev; |
221 | struct device_node *phy_dn, *np = ofdev->node; | 222 | struct device_node *np = ofdev->node; |
222 | struct mii_bus *new_bus; | 223 | struct mii_bus *new_bus; |
223 | struct gpio_priv *priv; | 224 | struct gpio_priv *priv; |
224 | const unsigned int *prop; | 225 | const unsigned int *prop; |
225 | int err; | 226 | int err; |
226 | int i; | ||
227 | 227 | ||
228 | err = -ENOMEM; | 228 | err = -ENOMEM; |
229 | priv = kzalloc(sizeof(struct gpio_priv), GFP_KERNEL); | 229 | priv = kzalloc(sizeof(struct gpio_priv), GFP_KERNEL); |
@@ -244,27 +244,7 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev, | |||
244 | snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop); | 244 | snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop); |
245 | new_bus->priv = priv; | 245 | new_bus->priv = priv; |
246 | 246 | ||
247 | new_bus->phy_mask = 0; | 247 | new_bus->irq = priv->mdio_irqs; |
248 | |||
249 | new_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); | ||
250 | |||
251 | if (!new_bus->irq) | ||
252 | goto out_free_bus; | ||
253 | |||
254 | for (i = 0; i < PHY_MAX_ADDR; i++) | ||
255 | new_bus->irq[i] = NO_IRQ; | ||
256 | |||
257 | for (phy_dn = of_get_next_child(np, NULL); | ||
258 | phy_dn != NULL; | ||
259 | phy_dn = of_get_next_child(np, phy_dn)) { | ||
260 | const unsigned int *ip, *regp; | ||
261 | |||
262 | ip = of_get_property(phy_dn, "interrupts", NULL); | ||
263 | regp = of_get_property(phy_dn, "reg", NULL); | ||
264 | if (!ip || !regp || *regp >= PHY_MAX_ADDR) | ||
265 | continue; | ||
266 | new_bus->irq[*regp] = irq_create_mapping(NULL, *ip); | ||
267 | } | ||
268 | 248 | ||
269 | prop = of_get_property(np, "mdc-pin", NULL); | 249 | prop = of_get_property(np, "mdc-pin", NULL); |
270 | priv->mdc_pin = *prop; | 250 | priv->mdc_pin = *prop; |
@@ -275,7 +255,7 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev, | |||
275 | new_bus->parent = dev; | 255 | new_bus->parent = dev; |
276 | dev_set_drvdata(dev, new_bus); | 256 | dev_set_drvdata(dev, new_bus); |
277 | 257 | ||
278 | err = mdiobus_register(new_bus); | 258 | err = of_mdiobus_register(new_bus, np); |
279 | 259 | ||
280 | if (err != 0) { | 260 | if (err != 0) { |
281 | printk(KERN_ERR "%s: Cannot register as MDIO bus, err %d\n", | 261 | printk(KERN_ERR "%s: Cannot register as MDIO bus, err %d\n", |
@@ -286,8 +266,6 @@ static int __devinit gpio_mdio_probe(struct of_device *ofdev, | |||
286 | return 0; | 266 | return 0; |
287 | 267 | ||
288 | out_free_irq: | 268 | out_free_irq: |
289 | kfree(new_bus->irq); | ||
290 | out_free_bus: | ||
291 | kfree(new_bus); | 269 | kfree(new_bus); |
292 | out_free_priv: | 270 | out_free_priv: |
293 | kfree(priv); | 271 | kfree(priv); |