Lines Matching +full:cpm2 +full:- +full:mdio +full:- +full:bitbang

1 // SPDX-License-Identifier: GPL-2.0
3 * Bitbanged MDIO support.
8 * Based on CPM2 MDIO code which is:
18 #include <linux/mdio-bitbang.h>
43 /* MDIO must already be configured as output. */
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()
55 /* MDIO must already be configured as input. */
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()
68 /* MDIO must already be configured as output. */
73 for (i = bits - 1; i >= 0; i--) in mdiobb_send_num()
77 /* MDIO must already be configured as input. */
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()
144 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_cmd_addr()
150 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_common()
153 ctrl->ops->set_mdio_dir(ctrl, 0); 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()
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()
186 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_c45()
197 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_common()
205 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_write_common()
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()
222 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_c45()
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()
258 struct mdiobb_ctrl *ctrl = bus->priv; in free_mdio_bitbang()
260 module_put(ctrl->ops->owner); in free_mdio_bitbang()
266 MODULE_DESCRIPTION("Bitbanged MDIO buses");