~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to arch/powerpc/platforms/pasemi/gpio_mdio.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <linux/ioport.h>
30
30
#include <linux/interrupt.h>
31
31
#include <linux/phy.h>
32
 
#include <linux/platform_device.h>
 
32
#include <linux/of_mdio.h>
33
33
#include <linux/of_platform.h>
34
34
 
35
35
#define DELAY 1
39
39
struct gpio_priv {
40
40
        int mdc_pin;
41
41
        int mdio_pin;
 
42
        int mdio_irqs[PHY_MAX_ADDR];
42
43
};
43
44
 
44
45
#define MDC_PIN(bus)    (((struct gpio_priv *)bus->priv)->mdc_pin)
218
219
                                     const struct of_device_id *match)
219
220
{
220
221
        struct device *dev = &ofdev->dev;
221
 
        struct device_node *phy_dn, *np = ofdev->node;
 
222
        struct device_node *np = ofdev->node;
222
223
        struct mii_bus *new_bus;
223
224
        struct gpio_priv *priv;
224
225
        const unsigned int *prop;
225
226
        int err;
226
 
        int i;
227
227
 
228
228
        err = -ENOMEM;
229
229
        priv = kzalloc(sizeof(struct gpio_priv), GFP_KERNEL);
244
244
        snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", *prop);
245
245
        new_bus->priv = priv;
246
246
 
247
 
        new_bus->phy_mask = 0;
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
 
        }
 
247
        new_bus->irq = priv->mdio_irqs;
268
248
 
269
249
        prop = of_get_property(np, "mdc-pin", NULL);
270
250
        priv->mdc_pin = *prop;
275
255
        new_bus->parent = dev;
276
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
260
        if (err != 0) {
281
261
                printk(KERN_ERR "%s: Cannot register as MDIO bus, err %d\n",
286
266
        return 0;
287
267
 
288
268
out_free_irq:
289
 
        kfree(new_bus->irq);
290
 
out_free_bus:
291
269
        kfree(new_bus);
292
270
out_free_priv:
293
271
        kfree(priv);