Lines Matching +full:data +full:- +full:role

1 // SPDX-License-Identifier: GPL-2.0
3 * otg.c - ChipIdea USB IP core OTG driver
38 cable = &ci->platdata->vbus_extcon; in hw_read_otgsc()
39 if (!IS_ERR(cable->edev) || ci->role_switch) { in hw_read_otgsc()
40 if (cable->changed) in hw_read_otgsc()
45 if (cable->connected) in hw_read_otgsc()
50 if (cable->enabled) in hw_read_otgsc()
56 cable = &ci->platdata->id_extcon; in hw_read_otgsc()
57 if (!IS_ERR(cable->edev) || ci->role_switch) { in hw_read_otgsc()
58 if (cable->changed) in hw_read_otgsc()
63 if (cable->connected) in hw_read_otgsc()
68 if (cable->enabled) in hw_read_otgsc()
81 * @data: to be written
83 void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data) in hw_write_otgsc() argument
87 cable = &ci->platdata->vbus_extcon; in hw_write_otgsc()
88 if (!IS_ERR(cable->edev) || ci->role_switch) { in hw_write_otgsc()
89 if (data & mask & OTGSC_BSVIS) in hw_write_otgsc()
90 cable->changed = false; in hw_write_otgsc()
93 if (data & mask & OTGSC_BSVIE) { in hw_write_otgsc()
94 cable->enabled = true; in hw_write_otgsc()
95 data &= ~OTGSC_BSVIE; in hw_write_otgsc()
97 cable->enabled = false; in hw_write_otgsc()
101 cable = &ci->platdata->id_extcon; in hw_write_otgsc()
102 if (!IS_ERR(cable->edev) || ci->role_switch) { in hw_write_otgsc()
103 if (data & mask & OTGSC_IDIS) in hw_write_otgsc()
104 cable->changed = false; in hw_write_otgsc()
107 if (data & mask & OTGSC_IDIE) { in hw_write_otgsc()
108 cable->enabled = true; in hw_write_otgsc()
109 data &= ~OTGSC_IDIE; in hw_write_otgsc()
111 cable->enabled = false; in hw_write_otgsc()
115 hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data); in hw_write_otgsc()
119 * ci_otg_role - pick role based on ID pin state
124 enum ci_role role = hw_read_otgsc(ci, OTGSC_ID) in ci_otg_role() local
128 return role; in ci_otg_role()
133 if (!ci->is_otg) in ci_handle_vbus_change()
136 if (hw_read_otgsc(ci, OTGSC_BSV) && !ci->vbus_active) in ci_handle_vbus_change()
137 usb_gadget_vbus_connect(&ci->gadget); in ci_handle_vbus_change()
138 else if (!hw_read_otgsc(ci, OTGSC_BSV) && ci->vbus_active) in ci_handle_vbus_change()
139 usb_gadget_vbus_disconnect(&ci->gadget); in ci_handle_vbus_change()
157 dev_err(ci->dev, "timeout waiting for %08x in OTGSC\n", in hw_wait_vbus_lower_bsv()
159 return -ETIMEDOUT; in hw_wait_vbus_lower_bsv()
169 enum ci_role role = ci_otg_role(ci); in ci_handle_id_switch() local
171 if (role != ci->role) { in ci_handle_id_switch()
172 dev_dbg(ci->dev, "switching from %s to %s\n", in ci_handle_id_switch()
173 ci_role(ci)->name, ci->roles[role]->name); in ci_handle_id_switch()
175 if (ci->vbus_active && ci->role == CI_ROLE_GADGET) in ci_handle_id_switch()
177 * vbus disconnect event is lost due to role in ci_handle_id_switch()
180 usb_gadget_vbus_disconnect(&ci->gadget); in ci_handle_id_switch()
184 if (role == CI_ROLE_GADGET && in ci_handle_id_switch()
185 IS_ERR(ci->platdata->vbus_extcon.edev)) in ci_handle_id_switch()
195 ci_role_start(ci, role); in ci_handle_id_switch()
197 if (role == CI_ROLE_GADGET) in ci_handle_id_switch()
202 * ci_otg_work - perform otg (vbus/id) event handle
210 enable_irq(ci->irq); in ci_otg_work()
214 pm_runtime_get_sync(ci->dev); in ci_otg_work()
216 if (ci->id_event) { in ci_otg_work()
217 ci->id_event = false; in ci_otg_work()
221 if (ci->b_sess_valid_event) { in ci_otg_work()
222 ci->b_sess_valid_event = false; in ci_otg_work()
226 pm_runtime_put_sync(ci->dev); in ci_otg_work()
228 enable_irq(ci->irq); in ci_otg_work()
233 * ci_hdrc_otg_init - initialize otg struct
238 INIT_WORK(&ci->work, ci_otg_work); in ci_hdrc_otg_init()
239 ci->wq = create_freezable_workqueue("ci_otg"); in ci_hdrc_otg_init()
240 if (!ci->wq) { in ci_hdrc_otg_init()
241 dev_err(ci->dev, "can't create workqueue\n"); in ci_hdrc_otg_init()
242 return -ENODEV; in ci_hdrc_otg_init()
252 * ci_hdrc_otg_destroy - destroy otg struct
257 if (ci->wq) { in ci_hdrc_otg_destroy()
258 flush_workqueue(ci->wq); in ci_hdrc_otg_destroy()
259 destroy_workqueue(ci->wq); in ci_hdrc_otg_destroy()