Lines Matching full:cphy
5 #include "cphy.h"
18 static void mdio_set_bit(struct cphy *cphy, int reg, u32 bitval) in mdio_set_bit() argument
22 (void) simple_mdio_read(cphy, reg, &val); in mdio_set_bit()
23 (void) simple_mdio_write(cphy, reg, val | bitval); in mdio_set_bit()
29 static void mdio_clear_bit(struct cphy *cphy, int reg, u32 bitval) in mdio_clear_bit() argument
33 (void) simple_mdio_read(cphy, reg, &val); in mdio_clear_bit()
34 (void) simple_mdio_write(cphy, reg, val & ~bitval); in mdio_clear_bit()
43 * PARAMS: cphy - Pointer to PHY instance data.
48 static int mv88e1xxx_reset(struct cphy *cphy, int wait) in mv88e1xxx_reset() argument
53 mdio_set_bit(cphy, MII_BMCR, BMCR_RESET); in mv88e1xxx_reset()
56 (void) simple_mdio_read(cphy, MII_BMCR, &ctl); in mv88e1xxx_reset()
65 static int mv88e1xxx_interrupt_enable(struct cphy *cphy) in mv88e1xxx_interrupt_enable() argument
68 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER, in mv88e1xxx_interrupt_enable()
72 if (t1_is_asic(cphy->adapter)) { in mv88e1xxx_interrupt_enable()
75 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); in mv88e1xxx_interrupt_enable()
77 if (is_T2(cphy->adapter)) in mv88e1xxx_interrupt_enable()
79 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); in mv88e1xxx_interrupt_enable()
84 static int mv88e1xxx_interrupt_disable(struct cphy *cphy) in mv88e1xxx_interrupt_disable() argument
87 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER, 0); in mv88e1xxx_interrupt_disable()
90 if (t1_is_asic(cphy->adapter)) { in mv88e1xxx_interrupt_disable()
93 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); in mv88e1xxx_interrupt_disable()
95 if (is_T2(cphy->adapter)) in mv88e1xxx_interrupt_disable()
97 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); in mv88e1xxx_interrupt_disable()
102 static int mv88e1xxx_interrupt_clear(struct cphy *cphy) in mv88e1xxx_interrupt_clear() argument
107 (void) simple_mdio_read(cphy, in mv88e1xxx_interrupt_clear()
111 if (t1_is_asic(cphy->adapter)) { in mv88e1xxx_interrupt_clear()
112 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer); in mv88e1xxx_interrupt_clear()
114 if (is_T2(cphy->adapter)) in mv88e1xxx_interrupt_clear()
116 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer); in mv88e1xxx_interrupt_clear()
125 static int mv88e1xxx_set_speed_duplex(struct cphy *phy, int speed, int duplex) in mv88e1xxx_set_speed_duplex()
148 static int mv88e1xxx_crossover_set(struct cphy *cphy, int crossover) in mv88e1xxx_crossover_set() argument
152 (void) simple_mdio_read(cphy, in mv88e1xxx_crossover_set()
156 (void) simple_mdio_write(cphy, in mv88e1xxx_crossover_set()
161 static int mv88e1xxx_autoneg_enable(struct cphy *cphy) in mv88e1xxx_autoneg_enable() argument
165 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_AUTO); in mv88e1xxx_autoneg_enable()
167 (void) simple_mdio_read(cphy, MII_BMCR, &ctl); in mv88e1xxx_autoneg_enable()
170 (void) simple_mdio_write(cphy, MII_BMCR, ctl); in mv88e1xxx_autoneg_enable()
174 static int mv88e1xxx_autoneg_disable(struct cphy *cphy) in mv88e1xxx_autoneg_disable() argument
182 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_MDI); in mv88e1xxx_autoneg_disable()
188 (void) simple_mdio_read(cphy, MII_BMCR, &ctl); in mv88e1xxx_autoneg_disable()
190 (void) simple_mdio_write(cphy, MII_BMCR, ctl | BMCR_ANRESTART); in mv88e1xxx_autoneg_disable()
194 static int mv88e1xxx_autoneg_restart(struct cphy *cphy) in mv88e1xxx_autoneg_restart() argument
196 mdio_set_bit(cphy, MII_BMCR, BMCR_ANRESTART); in mv88e1xxx_autoneg_restart()
200 static int mv88e1xxx_advertise(struct cphy *phy, unsigned int advertise_map) in mv88e1xxx_advertise()
232 static int mv88e1xxx_set_loopback(struct cphy *cphy, int on) in mv88e1xxx_set_loopback() argument
235 mdio_set_bit(cphy, MII_BMCR, BMCR_LOOPBACK); in mv88e1xxx_set_loopback()
237 mdio_clear_bit(cphy, MII_BMCR, BMCR_LOOPBACK); in mv88e1xxx_set_loopback()
241 static int mv88e1xxx_get_link_status(struct cphy *cphy, int *link_ok, in mv88e1xxx_get_link_status() argument
247 (void) simple_mdio_read(cphy, in mv88e1xxx_get_link_status()
274 static int mv88e1xxx_downshift_set(struct cphy *cphy, int downshift_enable) in mv88e1xxx_downshift_set() argument
278 (void) simple_mdio_read(cphy, in mv88e1xxx_downshift_set()
289 (void) simple_mdio_write(cphy, in mv88e1xxx_downshift_set()
294 static int mv88e1xxx_interrupt_handler(struct cphy *cphy) in mv88e1xxx_interrupt_handler() argument
305 (void) simple_mdio_read(cphy, in mv88e1xxx_interrupt_handler()
313 (void) simple_mdio_read(cphy, in mv88e1xxx_interrupt_handler()
317 cphy->state |= PHY_LINK_UP; in mv88e1xxx_interrupt_handler()
319 cphy->state &= ~PHY_LINK_UP; in mv88e1xxx_interrupt_handler()
320 if (cphy->state & PHY_AUTONEG_EN) in mv88e1xxx_interrupt_handler()
321 cphy->state &= ~PHY_AUTONEG_RDY; in mv88e1xxx_interrupt_handler()
327 cphy->state |= PHY_AUTONEG_RDY; in mv88e1xxx_interrupt_handler()
329 if ((cphy->state & (PHY_LINK_UP | PHY_AUTONEG_RDY)) == in mv88e1xxx_interrupt_handler()
336 static void mv88e1xxx_destroy(struct cphy *cphy) in mv88e1xxx_destroy() argument
338 kfree(cphy); in mv88e1xxx_destroy()
357 static struct cphy *mv88e1xxx_phy_create(struct net_device *dev, int phy_addr, in mv88e1xxx_phy_create()
361 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL); in mv88e1xxx_phy_create() local
363 if (!cphy) in mv88e1xxx_phy_create()
366 cphy_init(cphy, dev, phy_addr, &mv88e1xxx_ops, mdio_ops); in mv88e1xxx_phy_create()
374 (void) simple_mdio_write(cphy, in mv88e1xxx_phy_create()
376 (void) simple_mdio_write(cphy, in mv88e1xxx_phy_create()
379 (void) mv88e1xxx_downshift_set(cphy, 1); /* Enable downshift */ in mv88e1xxx_phy_create()
383 (void) simple_mdio_write(cphy, in mv88e1xxx_phy_create()
387 return cphy; in mv88e1xxx_phy_create()