Lines Matching +full:bus +full:- +full:turnaround +full:- +full:ns

1 // SPDX-License-Identifier: GPL-2.0
18 #include <linux/mdio-bitbang.h>
33 /* Minimum MDC period is 400 ns, plus some margin for error. MDIO_DELAY
38 /* The PHY may take up to 300 ns to produce data, plus some margin
46 const struct mdiobb_ops *ops = ctrl->ops; in mdiobb_send_bit()
48 ops->set_mdio_data(ctrl, val); in mdiobb_send_bit()
50 ops->set_mdc(ctrl, 1); in mdiobb_send_bit()
52 ops->set_mdc(ctrl, 0); in mdiobb_send_bit()
58 const struct mdiobb_ops *ops = ctrl->ops; in mdiobb_get_bit()
61 ops->set_mdc(ctrl, 1); in mdiobb_get_bit()
63 ops->set_mdc(ctrl, 0); in mdiobb_get_bit()
65 return ops->get_mdio_data(ctrl); in mdiobb_get_bit()
73 for (i = bits - 1; i >= 0; i--) in mdiobb_send_num()
83 for (i = bits - 1; i >= 0; i--) { in mdiobb_get_num()
96 const struct mdiobb_ops *ops = ctrl->ops; in mdiobb_cmd()
99 ops->set_mdio_dir(ctrl, 1); in mdiobb_cmd()
131 devices can exist on the same bus. Normal devices should ignore the MDIO_ADDR
138 /* send the turnaround (10) */ in mdiobb_cmd_addr()
144 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_cmd_addr()
148 static int mdiobb_read_common(struct mii_bus *bus, int phy) in mdiobb_read_common() argument
150 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_common()
153 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_read_common()
155 /* check the turnaround bit: the PHY should be driving it to zero, if this in mdiobb_read_common()
159 !(bus->phy_ignore_ta_mask & (1 << phy))) { in mdiobb_read_common()
160 /* PHY didn't drive TA low -- flush any bits it in mdiobb_read_common()
174 int mdiobb_read_c22(struct mii_bus *bus, int phy, int reg) in mdiobb_read_c22() argument
176 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_c22()
178 mdiobb_cmd(ctrl, ctrl->op_c22_read, phy, reg); in mdiobb_read_c22()
180 return mdiobb_read_common(bus, phy); in mdiobb_read_c22()
184 int mdiobb_read_c45(struct mii_bus *bus, int phy, int devad, int reg) in mdiobb_read_c45() argument
186 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_c45()
191 return mdiobb_read_common(bus, phy); in mdiobb_read_c45()
195 static int mdiobb_write_common(struct mii_bus *bus, u16 val) in mdiobb_write_common() argument
197 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_common()
199 /* send the turnaround (10) */ in mdiobb_write_common()
205 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_write_common()
210 int mdiobb_write_c22(struct mii_bus *bus, int phy, int reg, u16 val) in mdiobb_write_c22() argument
212 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_c22()
214 mdiobb_cmd(ctrl, ctrl->op_c22_write, phy, reg); in mdiobb_write_c22()
216 return mdiobb_write_common(bus, val); in mdiobb_write_c22()
220 int mdiobb_write_c45(struct mii_bus *bus, int phy, int devad, int reg, u16 val) in mdiobb_write_c45() argument
222 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_c45()
227 return mdiobb_write_common(bus, val); in mdiobb_write_c45()
233 struct mii_bus *bus; in alloc_mdio_bitbang() local
235 bus = mdiobus_alloc(); in alloc_mdio_bitbang()
236 if (!bus) in alloc_mdio_bitbang()
239 __module_get(ctrl->ops->owner); in alloc_mdio_bitbang()
241 bus->read = mdiobb_read_c22; in alloc_mdio_bitbang()
242 bus->write = mdiobb_write_c22; in alloc_mdio_bitbang()
243 bus->read_c45 = mdiobb_read_c45; in alloc_mdio_bitbang()
244 bus->write_c45 = mdiobb_write_c45; in alloc_mdio_bitbang()
246 bus->priv = ctrl; in alloc_mdio_bitbang()
247 if (!ctrl->override_op_c22) { in alloc_mdio_bitbang()
248 ctrl->op_c22_read = MDIO_READ; in alloc_mdio_bitbang()
249 ctrl->op_c22_write = MDIO_WRITE; in alloc_mdio_bitbang()
252 return bus; in alloc_mdio_bitbang()
256 void free_mdio_bitbang(struct mii_bus *bus) in free_mdio_bitbang() argument
258 struct mdiobb_ctrl *ctrl = bus->priv; in free_mdio_bitbang()
260 module_put(ctrl->ops->owner); in free_mdio_bitbang()
261 mdiobus_free(bus); in free_mdio_bitbang()