Lines Matching refs:mpcs

29 	bool (*link_check)(struct marvell_c22_pcs *mpcs);
38 static int marvell_c22_pcs_set_fiber_page(struct marvell_c22_pcs *mpcs) in marvell_c22_pcs_set_fiber_page() argument
43 mutex_lock(&mpcs->mdio.bus->mdio_lock); in marvell_c22_pcs_set_fiber_page()
45 err = __mdiodev_read(&mpcs->mdio, MII_MARVELL_PHY_PAGE); in marvell_c22_pcs_set_fiber_page()
47 dev_err(mpcs->mdio.dev.parent, in marvell_c22_pcs_set_fiber_page()
49 mpcs->name, ERR_PTR(err)); in marvell_c22_pcs_set_fiber_page()
55 err = __mdiodev_write(&mpcs->mdio, MII_MARVELL_PHY_PAGE, in marvell_c22_pcs_set_fiber_page()
58 dev_err(mpcs->mdio.dev.parent, in marvell_c22_pcs_set_fiber_page()
60 mpcs->name, ERR_PTR(err)); in marvell_c22_pcs_set_fiber_page()
67 static int marvell_c22_pcs_restore_page(struct marvell_c22_pcs *mpcs, in marvell_c22_pcs_restore_page() argument
73 err = __mdiodev_write(&mpcs->mdio, MII_MARVELL_PHY_PAGE, in marvell_c22_pcs_restore_page()
76 dev_err(mpcs->mdio.dev.parent, in marvell_c22_pcs_restore_page()
78 mpcs->name, ERR_PTR(err)); in marvell_c22_pcs_restore_page()
84 mutex_unlock(&mpcs->mdio.bus->mdio_lock); in marvell_c22_pcs_restore_page()
91 struct marvell_c22_pcs *mpcs = dev_id; in marvell_c22_pcs_handle_irq() local
95 oldpage = marvell_c22_pcs_set_fiber_page(mpcs); in marvell_c22_pcs_handle_irq()
99 err = __mdiodev_read(&mpcs->mdio, MII_M1011_IEVENT); in marvell_c22_pcs_handle_irq()
101 phylink_pcs_change(&mpcs->phylink_pcs, true); in marvell_c22_pcs_handle_irq()
106 marvell_c22_pcs_restore_page(mpcs, oldpage, 0); in marvell_c22_pcs_handle_irq()
111 static int marvell_c22_pcs_modify(struct marvell_c22_pcs *mpcs, u8 reg, in marvell_c22_pcs_modify() argument
116 oldpage = marvell_c22_pcs_set_fiber_page(mpcs); in marvell_c22_pcs_modify()
118 err = __mdiodev_modify(&mpcs->mdio, reg, mask, val); in marvell_c22_pcs_modify()
120 return marvell_c22_pcs_restore_page(mpcs, oldpage, err); in marvell_c22_pcs_modify()
123 static int marvell_c22_pcs_power(struct marvell_c22_pcs *mpcs, in marvell_c22_pcs_power() argument
128 return marvell_c22_pcs_modify(mpcs, MII_BMCR, BMCR_PDOWN, val); in marvell_c22_pcs_power()
131 static int marvell_c22_pcs_control_irq(struct marvell_c22_pcs *mpcs, in marvell_c22_pcs_control_irq() argument
136 return marvell_c22_pcs_modify(mpcs, MII_M1011_IMASK, in marvell_c22_pcs_control_irq()
142 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_enable() local
145 err = marvell_c22_pcs_power(mpcs, true); in marvell_c22_pcs_enable()
149 return marvell_c22_pcs_control_irq(mpcs, !!mpcs->irq); in marvell_c22_pcs_enable()
154 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_disable() local
156 marvell_c22_pcs_control_irq(mpcs, false); in marvell_c22_pcs_disable()
157 marvell_c22_pcs_power(mpcs, false); in marvell_c22_pcs_disable()
163 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_get_state() local
168 if (mpcs->link_check && !mpcs->link_check(mpcs)) in marvell_c22_pcs_get_state()
171 oldpage = marvell_c22_pcs_set_fiber_page(mpcs); in marvell_c22_pcs_get_state()
173 bmsr = __mdiodev_read(&mpcs->mdio, MII_BMSR); in marvell_c22_pcs_get_state()
174 lpa = __mdiodev_read(&mpcs->mdio, MII_LPA); in marvell_c22_pcs_get_state()
175 status = __mdiodev_read(&mpcs->mdio, MII_M1011_PHY_STATUS); in marvell_c22_pcs_get_state()
178 if (marvell_c22_pcs_restore_page(mpcs, oldpage, 0) >= 0 && in marvell_c22_pcs_get_state()
180 mv88e6xxx_pcs_decode_state(mpcs->mdio.dev.parent, bmsr, lpa, in marvell_c22_pcs_get_state()
190 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_config() local
200 oldpage = marvell_c22_pcs_set_fiber_page(mpcs); in marvell_c22_pcs_config()
204 err = __mdiodev_modify_changed(&mpcs->mdio, MII_ADVERTISE, 0xffff, adv); in marvell_c22_pcs_config()
209 err = __mdiodev_modify_changed(&mpcs->mdio, MII_BMCR, BMCR_ANENABLE, in marvell_c22_pcs_config()
223 return marvell_c22_pcs_restore_page(mpcs, oldpage, ret); in marvell_c22_pcs_config()
228 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_an_restart() local
230 marvell_c22_pcs_modify(mpcs, MII_BMCR, BMCR_ANRESTART, BMCR_ANRESTART); in marvell_c22_pcs_an_restart()
237 struct marvell_c22_pcs *mpcs = pcs_to_marvell_c22_pcs(pcs); in marvell_c22_pcs_link_up() local
246 err = marvell_c22_pcs_modify(mpcs, MII_BMCR, BMCR_SPEED100 | in marvell_c22_pcs_link_up()
249 dev_err(mpcs->mdio.dev.parent, in marvell_c22_pcs_link_up()
250 "%s: failed to configure mpcs: %pe\n", mpcs->name, in marvell_c22_pcs_link_up()
267 struct marvell_c22_pcs *mpcs; in marvell_c22_pcs_alloc() local
269 mpcs = kzalloc(sizeof(*mpcs), GFP_KERNEL); in marvell_c22_pcs_alloc()
270 if (!mpcs) in marvell_c22_pcs_alloc()
273 mpcs->mdio.dev.parent = dev; in marvell_c22_pcs_alloc()
274 mpcs->mdio.bus = bus; in marvell_c22_pcs_alloc()
275 mpcs->mdio.addr = addr; in marvell_c22_pcs_alloc()
276 mpcs->phylink_pcs.ops = &marvell_c22_pcs_ops; in marvell_c22_pcs_alloc()
277 mpcs->phylink_pcs.neg_mode = true; in marvell_c22_pcs_alloc()
279 return mpcs; in marvell_c22_pcs_alloc()
282 static int marvell_c22_pcs_setup_irq(struct marvell_c22_pcs *mpcs, in marvell_c22_pcs_setup_irq() argument
287 mpcs->phylink_pcs.poll = !irq; in marvell_c22_pcs_setup_irq()
288 mpcs->irq = irq; in marvell_c22_pcs_setup_irq()
293 IRQF_ONESHOT, mpcs->name, mpcs); in marvell_c22_pcs_setup_irq()
303 static bool mv88e6352_pcs_link_check(struct marvell_c22_pcs *mpcs) in mv88e6352_pcs_link_check() argument
305 struct mv88e6xxx_port *port = mpcs->port; in mv88e6352_pcs_link_check()
323 struct marvell_c22_pcs *mpcs; in mv88e6352_pcs_init() local
339 mpcs = marvell_c22_pcs_alloc(dev, bus, MV88E6352_ADDR_SERDES); in mv88e6352_pcs_init()
340 if (!mpcs) in mv88e6352_pcs_init()
343 snprintf(mpcs->name, sizeof(mpcs->name), in mv88e6352_pcs_init()
346 mpcs->link_check = mv88e6352_pcs_link_check; in mv88e6352_pcs_init()
347 mpcs->port = &chip->ports[port]; in mv88e6352_pcs_init()
349 err = marvell_c22_pcs_setup_irq(mpcs, irq); in mv88e6352_pcs_init()
351 kfree(mpcs); in mv88e6352_pcs_init()
355 chip->ports[port].pcs_private = &mpcs->phylink_pcs; in mv88e6352_pcs_init()
362 struct marvell_c22_pcs *mpcs; in mv88e6352_pcs_teardown() local
369 mpcs = pcs_to_marvell_c22_pcs(pcs); in mv88e6352_pcs_teardown()
371 if (mpcs->irq) in mv88e6352_pcs_teardown()
372 free_irq(mpcs->irq, mpcs); in mv88e6352_pcs_teardown()
374 kfree(mpcs); in mv88e6352_pcs_teardown()