Lines Matching full:ctrl
44 static void mdiobb_send_bit(struct mdiobb_ctrl *ctrl, int val) in mdiobb_send_bit() argument
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()
56 static int mdiobb_get_bit(struct mdiobb_ctrl *ctrl) in mdiobb_get_bit() argument
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()
69 static void mdiobb_send_num(struct mdiobb_ctrl *ctrl, u16 val, int bits) in mdiobb_send_num() argument
74 mdiobb_send_bit(ctrl, (val >> i) & 1); in mdiobb_send_num()
78 static u16 mdiobb_get_num(struct mdiobb_ctrl *ctrl, int bits) in mdiobb_get_num() argument
85 ret |= mdiobb_get_bit(ctrl); in mdiobb_get_num()
94 static void mdiobb_cmd(struct mdiobb_ctrl *ctrl, int op, u8 phy, u8 reg) in mdiobb_cmd() argument
96 const struct mdiobb_ops *ops = ctrl->ops; in mdiobb_cmd()
99 ops->set_mdio_dir(ctrl, 1); in mdiobb_cmd()
111 mdiobb_send_bit(ctrl, 1); in mdiobb_cmd()
116 mdiobb_send_bit(ctrl, 0); in mdiobb_cmd()
118 mdiobb_send_bit(ctrl, 0); in mdiobb_cmd()
120 mdiobb_send_bit(ctrl, 1); in mdiobb_cmd()
121 mdiobb_send_bit(ctrl, (op >> 1) & 1); in mdiobb_cmd()
122 mdiobb_send_bit(ctrl, (op >> 0) & 1); in mdiobb_cmd()
124 mdiobb_send_num(ctrl, phy, 5); in mdiobb_cmd()
125 mdiobb_send_num(ctrl, reg, 5); in mdiobb_cmd()
133 static void mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, int dev_addr, in mdiobb_cmd_addr() argument
136 mdiobb_cmd(ctrl, MDIO_C45_ADDR, phy, dev_addr); in mdiobb_cmd_addr()
139 mdiobb_send_bit(ctrl, 1); in mdiobb_cmd_addr()
140 mdiobb_send_bit(ctrl, 0); in mdiobb_cmd_addr()
142 mdiobb_send_num(ctrl, reg, 16); in mdiobb_cmd_addr()
144 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_cmd_addr()
145 mdiobb_get_bit(ctrl); in mdiobb_cmd_addr()
150 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_common() local
153 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_read_common()
158 if (mdiobb_get_bit(ctrl) != 0 && in mdiobb_read_common()
164 mdiobb_get_bit(ctrl); in mdiobb_read_common()
169 ret = mdiobb_get_num(ctrl, 16); in mdiobb_read_common()
170 mdiobb_get_bit(ctrl); in mdiobb_read_common()
176 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read_c22() local
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() local
188 mdiobb_cmd_addr(ctrl, phy, devad, reg); in mdiobb_read_c45()
189 mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad); in mdiobb_read_c45()
197 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_common() local
200 mdiobb_send_bit(ctrl, 1); in mdiobb_write_common()
201 mdiobb_send_bit(ctrl, 0); in mdiobb_write_common()
203 mdiobb_send_num(ctrl, val, 16); in mdiobb_write_common()
205 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_write_common()
206 mdiobb_get_bit(ctrl); in mdiobb_write_common()
212 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write_c22() local
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() local
224 mdiobb_cmd_addr(ctrl, phy, devad, reg); in mdiobb_write_c45()
225 mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, devad); in mdiobb_write_c45()
231 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) in alloc_mdio_bitbang() argument
239 __module_get(ctrl->ops->owner); 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() local
260 module_put(ctrl->ops->owner); in free_mdio_bitbang()