aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/pasemi/gpio_mdio.c32
1 files changed, 5 insertions, 27 deletions
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;
39struct gpio_priv { 39struct 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
288out_free_irq: 268out_free_irq:
289 kfree(new_bus->irq);
290out_free_bus:
291 kfree(new_bus); 269 kfree(new_bus);
292out_free_priv: 270out_free_priv:
293 kfree(priv); 271 kfree(priv);