19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/errno.h>
22 #include <linux/slab.h>
25 #include <linux/module.h>
26 #include <linux/mii.h>
36 #define MIIMIND_BUSY 0x00000001
37 #define MIIMIND_NOTVALID 0x00000004
38 #define MIIMCFG_INIT_VALUE 0x00000007
39 #define MIIMCFG_RESET 0x80000000
41 #define MII_READ_COMMAND 0x00000001
66 #define MII_TIMEOUT 1000
101 static int fsl_pq_mdio_write(
struct mii_bus *
bus,
int mii_id,
int regnum,
131 static int fsl_pq_mdio_read(
struct mii_bus *
bus,
int mii_id,
int regnum)
155 dev_dbg(&bus->
dev,
"read %04x from address %x/%x\n", value, mii_id, regnum);
160 static int fsl_pq_mdio_reset(
struct mii_bus *bus)
181 dev_err(&bus->
dev,
"timeout waiting for MII bus\n");
188 #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
198 return &enet_regs->
tbipa;
210 #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
234 static bool found_mii_master;
237 if (found_mii_master)
240 for_each_compatible_node(np,
NULL,
"ucc_geth") {
248 pr_debug(
"fsl-pq-mdio: no address range in node %s\n",
254 if ((start <
res.start) || (end >
res.end))
261 pr_debug(
"fsl-pq-mdio: no UCC ID in node %s\n",
274 pr_debug(
"fsl-pq-mdio: invalid UCC ID in node %s\n",
279 pr_debug(
"fsl-pq-mdio: setting node UCC%u to MII master\n",
id);
280 found_mii_master =
true;
287 #if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
289 .compatible =
"fsl,gianfar-tbi",
292 .get_tbipa = get_gfar_tbipa,
296 .compatible =
"fsl,gianfar-mdio",
299 .get_tbipa = get_gfar_tbipa,
304 .compatible =
"gianfar",
307 .get_tbipa = get_gfar_tbipa,
311 .compatible =
"fsl,etsec2-tbi",
314 .get_tbipa = get_etsec_tbipa,
318 .compatible =
"fsl,etsec2-mdio",
321 .get_tbipa = get_etsec_tbipa,
325 #if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
327 .compatible =
"fsl,ucc-mdio",
330 .get_tbipa = get_ucc_tbipa,
337 .compatible =
"ucc_geth_phy",
340 .get_tbipa = get_ucc_tbipa,
347 .compatible =
"fsl,fman-mdio",
376 priv = new_bus->
priv;
377 new_bus->
name =
"Freescale PowerQUICC MII Bus",
378 new_bus->
read = &fsl_pq_mdio_read;
379 new_bus->
write = &fsl_pq_mdio_write;
380 new_bus->
reset = &fsl_pq_mdio_reset;
385 dev_err(&pdev->
dev,
"could not obtain address information\n");
390 (
unsigned long long)
res.start);
405 dev_err(&pdev->
dev,
"invalid register map\n");
417 dev_dbg(&pdev->
dev,
"found TBI PHY node %s\n",
429 "missing 'reg' property in node %s\n",
446 dev_err(&pdev->
dev,
"cannot register %s as MDIO bus\n",
481 .name =
"fsl-pq_mdio",
483 .of_match_table = fsl_pq_mdio_match,
485 .probe = fsl_pq_mdio_probe,
486 .remove = fsl_pq_mdio_remove,