25 #include <linux/module.h>
26 #include <linux/types.h>
27 #include <linux/slab.h>
28 #include <linux/sched.h>
29 #include <linux/errno.h>
46 #define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin)
47 #define MDIO_PIN(bus) (((struct gpio_priv *)bus->priv)->mdio_pin)
49 static inline void mdio_lo(
struct mii_bus *
bus)
54 static inline void mdio_hi(
struct mii_bus *
bus)
59 static inline void mdc_lo(
struct mii_bus *bus)
64 static inline void mdc_hi(
struct mii_bus *bus)
69 static inline void mdio_active(
struct mii_bus *bus)
74 static inline void mdio_tristate(
struct mii_bus *bus)
79 static inline int mdio_read(
struct mii_bus *bus)
84 static void clock_out(
struct mii_bus *bus,
int bit)
103 for (i = 0; i < 40; i++) {
111 clock_out(bus, read);
112 clock_out(bus, !read);
115 for (i = 0; i < 5; i++) {
116 clock_out(bus, (addr & 0x10) != 0);
121 for (i = 0; i < 5; i++) {
122 clock_out(bus, (reg & 0x10) != 0);
131 u8 addr = phy_id & 0xff;
132 u8 reg = location & 0xff;
134 bitbang_pre(bus, 1, addr, reg);
145 for (i = 0; i < 16; i++) {
153 rdreg |= mdio_read(bus);
166 static int gpio_mdio_write(
struct mii_bus *bus,
int phy_id,
int location,
u16 val)
170 u8 addr = phy_id & 0xff;
171 u8 reg = location & 0xff;
174 bitbang_pre(bus, 0, addr, reg);
189 for (i = 0; i < 16; i++) {
212 static int gpio_mdio_reset(
struct mii_bus *bus)
225 const unsigned int *prop;
233 new_bus = mdiobus_alloc();
238 new_bus->
name =
"pasemi gpio mdio bus";
239 new_bus->
read = &gpio_mdio_read;
240 new_bus->
write = &gpio_mdio_write;
241 new_bus->
reset = &gpio_mdio_reset;
295 .compatible =
"gpio-mdio",
303 .probe = gpio_mdio_probe,
304 .remove = gpio_mdio_remove,
306 .name =
"gpio-mdio-bitbang",
308 .of_match_table = gpio_mdio_match,
319 "pasemi,pwrficient-gpio");