Lines Matching +full:bus +full:- +full:err
2 * Driver for the MPC5200 Fast Ethernet Controller - MDIO bus driver
29 static int mpc52xx_fec_mdio_transfer(struct mii_bus *bus, int phy_id, in mpc52xx_fec_mdio_transfer() argument
32 struct mpc52xx_fec_mdio_priv *priv = bus->priv; in mpc52xx_fec_mdio_transfer()
33 struct mpc52xx_fec __iomem *fec = priv->regs; in mpc52xx_fec_mdio_transfer()
39 out_be32(&fec->ievent, FEC_IEVENT_MII); in mpc52xx_fec_mdio_transfer()
40 out_be32(&fec->mii_data, value); in mpc52xx_fec_mdio_transfer()
43 while (!(in_be32(&fec->ievent) & FEC_IEVENT_MII) && --tries) in mpc52xx_fec_mdio_transfer()
47 return -ETIMEDOUT; in mpc52xx_fec_mdio_transfer()
50 in_be32(&fec->mii_data) & FEC_MII_DATA_DATAMSK : 0; in mpc52xx_fec_mdio_transfer()
53 static int mpc52xx_fec_mdio_read(struct mii_bus *bus, int phy_id, int reg) in mpc52xx_fec_mdio_read() argument
55 return mpc52xx_fec_mdio_transfer(bus, phy_id, reg, FEC_MII_READ_FRAME); in mpc52xx_fec_mdio_read()
58 static int mpc52xx_fec_mdio_write(struct mii_bus *bus, int phy_id, int reg, in mpc52xx_fec_mdio_write() argument
61 return mpc52xx_fec_mdio_transfer(bus, phy_id, reg, in mpc52xx_fec_mdio_write()
67 struct device *dev = &of->dev; in mpc52xx_fec_mdio_probe()
68 struct device_node *np = of->dev.of_node; in mpc52xx_fec_mdio_probe()
69 struct mii_bus *bus; in mpc52xx_fec_mdio_probe() local
72 int err; in mpc52xx_fec_mdio_probe() local
74 bus = mdiobus_alloc(); in mpc52xx_fec_mdio_probe()
75 if (bus == NULL) in mpc52xx_fec_mdio_probe()
76 return -ENOMEM; in mpc52xx_fec_mdio_probe()
79 err = -ENOMEM; in mpc52xx_fec_mdio_probe()
83 bus->name = "mpc52xx MII bus"; in mpc52xx_fec_mdio_probe()
84 bus->read = mpc52xx_fec_mdio_read; in mpc52xx_fec_mdio_probe()
85 bus->write = mpc52xx_fec_mdio_write; in mpc52xx_fec_mdio_probe()
88 err = of_address_to_resource(np, 0, &res); in mpc52xx_fec_mdio_probe()
89 if (err) in mpc52xx_fec_mdio_probe()
91 priv->regs = ioremap(res.start, resource_size(&res)); in mpc52xx_fec_mdio_probe()
92 if (priv->regs == NULL) { in mpc52xx_fec_mdio_probe()
93 err = -ENOMEM; in mpc52xx_fec_mdio_probe()
97 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); in mpc52xx_fec_mdio_probe()
98 bus->priv = priv; in mpc52xx_fec_mdio_probe()
100 bus->parent = dev; in mpc52xx_fec_mdio_probe()
101 dev_set_drvdata(dev, bus); in mpc52xx_fec_mdio_probe()
104 out_be32(&priv->regs->mii_speed, ((mpc5xxx_get_bus_frequency(dev) >> 20) / 5) << 1); in mpc52xx_fec_mdio_probe()
106 err = of_mdiobus_register(bus, np); in mpc52xx_fec_mdio_probe()
107 if (err) in mpc52xx_fec_mdio_probe()
113 iounmap(priv->regs); in mpc52xx_fec_mdio_probe()
116 mdiobus_free(bus); in mpc52xx_fec_mdio_probe()
118 return err; in mpc52xx_fec_mdio_probe()
123 struct mii_bus *bus = platform_get_drvdata(of); in mpc52xx_fec_mdio_remove() local
124 struct mpc52xx_fec_mdio_priv *priv = bus->priv; in mpc52xx_fec_mdio_remove()
126 mdiobus_unregister(bus); in mpc52xx_fec_mdio_remove()
127 iounmap(priv->regs); in mpc52xx_fec_mdio_remove()
129 mdiobus_free(bus); in mpc52xx_fec_mdio_remove()
133 { .compatible = "fsl,mpc5200b-mdio", },
134 { .compatible = "fsl,mpc5200-mdio", },
135 { .compatible = "mpc5200b-fec-phy", },
142 .name = "mpc5200b-fec-phy",