15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <linux/string.h>
19 #include <linux/ptrace.h>
20 #include <linux/errno.h>
22 #include <linux/slab.h>
26 #include <linux/netdevice.h>
30 #include <linux/mii.h>
31 #include <linux/ethtool.h>
32 #include <linux/bitops.h>
36 #include <asm/pgtable.h>
38 #include <asm/uaccess.h>
46 #define mk_mii_read(REG) (0x60020000 | ((REG & 0x1f) << 18))
47 #define mk_mii_write(REG, VAL) (0x50020000 | ((REG & 0x1f) << 18) | (VAL & 0xffff))
50 #define FEC_MII_LOOPS 10000
54 struct fec_info*
fec = bus->
priv;
55 struct fec __iomem *fecp = fec->fecp;
67 if (i < FEC_MII_LOOPS) {
69 ret =
in_be32(&fecp->fec_mii_data) & 0xffff;
77 struct fec_info*
fec = bus->
priv;
78 struct fec
__iomem *fecp = fec->fecp;
91 if (i < FEC_MII_LOOPS)
98 static int fs_enet_fec_mii_reset(
struct mii_bus *bus)
110 struct fec_info *
fec;
117 get_bus_freq = match->
data;
119 new_bus = mdiobus_alloc();
123 fec = kzalloc(
sizeof(
struct fec_info),
GFP_KERNEL);
128 new_bus->
name =
"FEC MII Bus";
129 new_bus->
read = &fs_enet_fec_mii_read;
130 new_bus->
write = &fs_enet_fec_mii_write;
131 new_bus->
reset = &fs_enet_fec_mii_reset;
146 clock = get_bus_freq(ofdev->
dev.of_node);
149 dev_warn(&ofdev->
dev,
"could not determine IPS clock\n");
150 clock = 0x3F * 5000000;
159 speed = (clock + 4999999) / 5000000;
163 "MII clock (%d Hz) exceeds max (2.5 MHz)\n",
167 fec->mii_speed = speed << 1;
173 clrsetbits_be32(&fec->fecp->fec_mii_speed, 0x7E, fec->mii_speed);
208 struct fec_info *fec = bus->
priv;
222 .compatible =
"fsl,pq1-fec-mdio",
224 #if defined(CONFIG_PPC_MPC512x)
226 .compatible =
"fsl,mpc5121-fec-mdio",
236 .name =
"fsl-fec-mdio",
238 .of_match_table = fs_enet_mdio_fec_match,
240 .probe = fs_enet_mdio_probe,
241 .remove = fs_enet_mdio_remove,