aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2009-04-25 08:53:07 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-27 05:53:48 -0400
commit324931ba21858c34787dee7d222388ef3fb41ee0 (patch)
treea9aa45387e2e771d09135625b28e1a4c37cddd74 /drivers
parentca816d98170942371535b3e862813b0aba9b7d90 (diff)
net: rework fsl_pq_mdio driver to use of_mdio infrastructure
This patch simplifies the driver by making use of more common code. Tested on Freescale MPC8349emitxgp eval board Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Andy Fleming <afleming@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fsl_pq_mdio.c51
1 files changed, 3 insertions, 48 deletions
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index aa1eb88c21f..b01daa1e3ad 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -34,6 +34,7 @@
34#include <linux/mii.h> 34#include <linux/mii.h>
35#include <linux/phy.h> 35#include <linux/phy.h>
36#include <linux/of.h> 36#include <linux/of.h>
37#include <linux/of_mdio.h>
37#include <linux/of_platform.h> 38#include <linux/of_platform.h>
38 39
39#include <asm/io.h> 40#include <asm/io.h>
@@ -154,44 +155,6 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
154 return 0; 155 return 0;
155} 156}
156 157
157/* Allocate an array which provides irq #s for each PHY on the given bus */
158static int *create_irq_map(struct device_node *np)
159{
160 int *irqs;
161 int i;
162 struct device_node *child = NULL;
163
164 irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
165
166 if (!irqs)
167 return NULL;
168
169 for (i = 0; i < PHY_MAX_ADDR; i++)
170 irqs[i] = PHY_POLL;
171
172 while ((child = of_get_next_child(np, child)) != NULL) {
173 int irq = irq_of_parse_and_map(child, 0);
174 const u32 *id;
175
176 if (irq == NO_IRQ)
177 continue;
178
179 id = of_get_property(child, "reg", NULL);
180
181 if (!id)
182 continue;
183
184 if (*id < PHY_MAX_ADDR && *id >= 0)
185 irqs[*id] = irq;
186 else
187 printk(KERN_WARNING "%s: "
188 "%d is not a valid PHY address\n",
189 np->full_name, *id);
190 }
191
192 return irqs;
193}
194
195void fsl_pq_mdio_bus_name(char *name, struct device_node *np) 158void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
196{ 159{
197 const u32 *addr; 160 const u32 *addr;
@@ -315,7 +278,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
315 278
316 new_bus->priv = (void __force *)regs; 279 new_bus->priv = (void __force *)regs;
317 280
318 new_bus->irq = create_irq_map(np); 281 new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
319 282
320 if (NULL == new_bus->irq) { 283 if (NULL == new_bus->irq) {
321 err = -ENOMEM; 284 err = -ENOMEM;
@@ -384,15 +347,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
384 347
385 out_be32(tbipa, tbiaddr); 348 out_be32(tbipa, tbiaddr);
386 349
387 /* 350 err = of_mdiobus_register(new_bus, np);
388 * The TBIPHY-only buses will find PHYs at every address,
389 * so we mask them all but the TBI
390 */
391 if (of_device_is_compatible(np, "fsl,gianfar-tbi"))
392 new_bus->phy_mask = ~(1 << tbiaddr);
393
394 err = mdiobus_register(new_bus);
395
396 if (err) { 351 if (err) {
397 printk (KERN_ERR "%s: Cannot register as MDIO bus\n", 352 printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
398 new_bus->name); 353 new_bus->name);