diff options
Diffstat (limited to 'drivers/net/ethernet/freescale/fsl_pq_mdio.c')
-rw-r--r-- | drivers/net/ethernet/freescale/fsl_pq_mdio.c | 53 |
1 files changed, 8 insertions, 45 deletions
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c index 52f4e8ad48e7..4d9f84b8ab97 100644 --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c | |||
@@ -183,28 +183,10 @@ void fsl_pq_mdio_bus_name(char *name, struct device_node *np) | |||
183 | } | 183 | } |
184 | EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); | 184 | EXPORT_SYMBOL_GPL(fsl_pq_mdio_bus_name); |
185 | 185 | ||
186 | /* Scan the bus in reverse, looking for an empty spot */ | ||
187 | static int fsl_pq_mdio_find_free(struct mii_bus *new_bus) | ||
188 | { | ||
189 | int i; | ||
190 | |||
191 | for (i = PHY_MAX_ADDR; i > 0; i--) { | ||
192 | u32 phy_id; | ||
193 | |||
194 | if (get_phy_id(new_bus, i, &phy_id)) | ||
195 | return -1; | ||
196 | |||
197 | if (phy_id == 0xffffffff) | ||
198 | break; | ||
199 | } | ||
200 | |||
201 | return i; | ||
202 | } | ||
203 | |||
204 | 186 | ||
205 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
206 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) | 187 | static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) |
207 | { | 188 | { |
189 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
208 | struct gfar __iomem *enet_regs; | 190 | struct gfar __iomem *enet_regs; |
209 | 191 | ||
210 | /* | 192 | /* |
@@ -220,15 +202,15 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi | |||
220 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || | 202 | } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || |
221 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { | 203 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { |
222 | return of_iomap(np, 1); | 204 | return of_iomap(np, 1); |
223 | } else | 205 | } |
224 | return NULL; | ||
225 | } | ||
226 | #endif | 206 | #endif |
207 | return NULL; | ||
208 | } | ||
227 | 209 | ||
228 | 210 | ||
229 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
230 | static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) | 211 | static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) |
231 | { | 212 | { |
213 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
232 | struct device_node *np = NULL; | 214 | struct device_node *np = NULL; |
233 | int err = 0; | 215 | int err = 0; |
234 | 216 | ||
@@ -261,9 +243,10 @@ static int get_ucc_id_for_range(u64 start, u64 end, u32 *ucc_id) | |||
261 | return err; | 243 | return err; |
262 | else | 244 | else |
263 | return -EINVAL; | 245 | return -EINVAL; |
264 | } | 246 | #else |
247 | return -ENODEV; | ||
265 | #endif | 248 | #endif |
266 | 249 | } | |
267 | 250 | ||
268 | static int fsl_pq_mdio_probe(struct platform_device *ofdev) | 251 | static int fsl_pq_mdio_probe(struct platform_device *ofdev) |
269 | { | 252 | { |
@@ -339,19 +322,13 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
339 | of_device_is_compatible(np, "fsl,etsec2-mdio") || | 322 | of_device_is_compatible(np, "fsl,etsec2-mdio") || |
340 | of_device_is_compatible(np, "fsl,etsec2-tbi") || | 323 | of_device_is_compatible(np, "fsl,etsec2-tbi") || |
341 | of_device_is_compatible(np, "gianfar")) { | 324 | of_device_is_compatible(np, "gianfar")) { |
342 | #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE) | ||
343 | tbipa = get_gfar_tbipa(regs, np); | 325 | tbipa = get_gfar_tbipa(regs, np); |
344 | if (!tbipa) { | 326 | if (!tbipa) { |
345 | err = -EINVAL; | 327 | err = -EINVAL; |
346 | goto err_free_irqs; | 328 | goto err_free_irqs; |
347 | } | 329 | } |
348 | #else | ||
349 | err = -ENODEV; | ||
350 | goto err_free_irqs; | ||
351 | #endif | ||
352 | } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || | 330 | } else if (of_device_is_compatible(np, "fsl,ucc-mdio") || |
353 | of_device_is_compatible(np, "ucc_geth_phy")) { | 331 | of_device_is_compatible(np, "ucc_geth_phy")) { |
354 | #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE) | ||
355 | u32 id; | 332 | u32 id; |
356 | static u32 mii_mng_master; | 333 | static u32 mii_mng_master; |
357 | 334 | ||
@@ -364,10 +341,6 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
364 | mii_mng_master = id; | 341 | mii_mng_master = id; |
365 | ucc_set_qe_mux_mii_mng(id - 1); | 342 | ucc_set_qe_mux_mii_mng(id - 1); |
366 | } | 343 | } |
367 | #else | ||
368 | err = -ENODEV; | ||
369 | goto err_free_irqs; | ||
370 | #endif | ||
371 | } else { | 344 | } else { |
372 | err = -ENODEV; | 345 | err = -ENODEV; |
373 | goto err_free_irqs; | 346 | goto err_free_irqs; |
@@ -386,16 +359,6 @@ static int fsl_pq_mdio_probe(struct platform_device *ofdev) | |||
386 | } | 359 | } |
387 | 360 | ||
388 | if (tbiaddr == -1) { | 361 | if (tbiaddr == -1) { |
389 | out_be32(tbipa, 0); | ||
390 | |||
391 | tbiaddr = fsl_pq_mdio_find_free(new_bus); | ||
392 | } | ||
393 | |||
394 | /* | ||
395 | * We define TBIPA at 0 to be illegal, opting to fail for boards that | ||
396 | * have PHYs at 1-31, rather than change tbipa and rescan. | ||
397 | */ | ||
398 | if (tbiaddr == 0) { | ||
399 | err = -EBUSY; | 362 | err = -EBUSY; |
400 | 363 | ||
401 | goto err_free_irqs; | 364 | goto err_free_irqs; |