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()
134 static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr) in mdiobb_cmd_addr() argument
138 mdiobb_cmd(ctrl, MDIO_C45_ADDR, phy, dev_addr); in mdiobb_cmd_addr()
141 mdiobb_send_bit(ctrl, 1); in mdiobb_cmd_addr()
142 mdiobb_send_bit(ctrl, 0); in mdiobb_cmd_addr()
144 mdiobb_send_num(ctrl, reg, 16); in mdiobb_cmd_addr()
146 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_cmd_addr()
147 mdiobb_get_bit(ctrl); in mdiobb_cmd_addr()
154 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_read() local
158 reg = mdiobb_cmd_addr(ctrl, phy, reg); in mdiobb_read()
159 mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg); in mdiobb_read()
161 mdiobb_cmd(ctrl, ctrl->op_c22_read, phy, reg); in mdiobb_read()
163 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_read()
168 if (mdiobb_get_bit(ctrl) != 0 && in mdiobb_read()
174 mdiobb_get_bit(ctrl); in mdiobb_read()
179 ret = mdiobb_get_num(ctrl, 16); in mdiobb_read()
180 mdiobb_get_bit(ctrl); in mdiobb_read()
187 struct mdiobb_ctrl *ctrl = bus->priv; in mdiobb_write() local
190 reg = mdiobb_cmd_addr(ctrl, phy, reg); in mdiobb_write()
191 mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg); in mdiobb_write()
193 mdiobb_cmd(ctrl, ctrl->op_c22_write, phy, reg); in mdiobb_write()
196 mdiobb_send_bit(ctrl, 1); in mdiobb_write()
197 mdiobb_send_bit(ctrl, 0); in mdiobb_write()
199 mdiobb_send_num(ctrl, val, 16); in mdiobb_write()
201 ctrl->ops->set_mdio_dir(ctrl, 0); in mdiobb_write()
202 mdiobb_get_bit(ctrl); in mdiobb_write()
207 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) in alloc_mdio_bitbang() argument
215 __module_get(ctrl->ops->owner); in alloc_mdio_bitbang()
219 bus->priv = ctrl; in alloc_mdio_bitbang()
220 if (!ctrl->override_op_c22) { in alloc_mdio_bitbang()
221 ctrl->op_c22_read = MDIO_READ; in alloc_mdio_bitbang()
222 ctrl->op_c22_write = MDIO_WRITE; in alloc_mdio_bitbang()
231 struct mdiobb_ctrl *ctrl = bus->priv; in free_mdio_bitbang() local
233 module_put(ctrl->ops->owner); in free_mdio_bitbang()