Lines Matching defs:ci

19 #include "ci.h"
26 * @ci: the controller
29 u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)
32 u32 val = hw_read(ci, OP_OTGSC, mask);
38 cable = &ci->platdata->vbus_extcon;
39 if (!IS_ERR(cable->edev) || ci->role_switch) {
56 cable = &ci->platdata->id_extcon;
57 if (!IS_ERR(cable->edev) || ci->role_switch) {
79 * @ci: the controller
83 void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data)
87 cable = &ci->platdata->vbus_extcon;
88 if (!IS_ERR(cable->edev) || ci->role_switch) {
101 cable = &ci->platdata->id_extcon;
102 if (!IS_ERR(cable->edev) || ci->role_switch) {
115 hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data);
120 * @ci: the controller
122 enum ci_role ci_otg_role(struct ci_hdrc *ci)
124 enum ci_role role = hw_read_otgsc(ci, OTGSC_ID)
131 void ci_handle_vbus_change(struct ci_hdrc *ci)
133 if (!ci->is_otg)
136 if (hw_read_otgsc(ci, OTGSC_BSV) && !ci->vbus_active)
137 usb_gadget_vbus_connect(&ci->gadget);
138 else if (!hw_read_otgsc(ci, OTGSC_BSV) && ci->vbus_active)
139 usb_gadget_vbus_disconnect(&ci->gadget);
147 * @ci: the controller
151 static int hw_wait_vbus_lower_bsv(struct ci_hdrc *ci)
156 while (hw_read_otgsc(ci, mask)) {
158 dev_err(ci->dev, "timeout waiting for %08x in OTGSC\n",
168 void ci_handle_id_switch(struct ci_hdrc *ci)
172 mutex_lock(&ci->mutex);
173 role = ci_otg_role(ci);
174 if (role != ci->role) {
175 dev_dbg(ci->dev, "switching from %s to %s\n",
176 ci_role(ci)->name, ci->roles[role]->name);
178 if (ci->vbus_active && ci->role == CI_ROLE_GADGET)
183 usb_gadget_vbus_disconnect(&ci->gadget);
185 ci_role_stop(ci);
188 IS_ERR(ci->platdata->vbus_extcon.edev))
196 hw_wait_vbus_lower_bsv(ci);
198 ci_role_start(ci, role);
201 ci_handle_vbus_change(ci);
203 mutex_unlock(&ci->mutex);
211 struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
213 if (ci_otg_is_fsm_mode(ci) && !ci_otg_fsm_work(ci)) {
214 enable_irq(ci->irq);
218 pm_runtime_get_sync(ci->dev);
220 if (ci->id_event) {
221 ci->id_event = false;
222 ci_handle_id_switch(ci);
225 if (ci->b_sess_valid_event) {
226 ci->b_sess_valid_event = false;
227 ci_handle_vbus_change(ci);
230 pm_runtime_put_sync(ci->dev);
232 enable_irq(ci->irq);
238 * @ci: the controller
240 int ci_hdrc_otg_init(struct ci_hdrc *ci)
242 INIT_WORK(&ci->work, ci_otg_work);
243 ci->wq = create_freezable_workqueue("ci_otg");
244 if (!ci->wq) {
245 dev_err(ci->dev, "can't create workqueue\n");
249 if (ci_otg_is_fsm_mode(ci))
250 return ci_hdrc_otg_fsm_init(ci);
257 * @ci: the controller
259 void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
261 if (ci->wq)
262 destroy_workqueue(ci->wq);
265 hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
267 if (ci_otg_is_fsm_mode(ci))
268 ci_hdrc_otg_fsm_remove(ci);