Lines Matching refs: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) {
134 if (ci->platdata->flags & CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS)
135 usb_gadget_vbus_connect(&ci->gadget);
139 if (hw_read_otgsc(ci, OTGSC_BSV) && !ci->vbus_active)
140 usb_gadget_vbus_connect(&ci->gadget);
141 else if (!hw_read_otgsc(ci, OTGSC_BSV) && ci->vbus_active)
142 usb_gadget_vbus_disconnect(&ci->gadget);
150 * @ci: the controller
154 static int hw_wait_vbus_lower_bsv(struct ci_hdrc *ci)
159 while (hw_read_otgsc(ci, mask)) {
161 dev_err(ci->dev, "timeout waiting for %08x in OTGSC\n",
171 void ci_handle_id_switch(struct ci_hdrc *ci)
175 mutex_lock(&ci->mutex);
176 role = ci_otg_role(ci);
177 if (role != ci->role) {
178 dev_dbg(ci->dev, "switching from %s to %s\n",
179 ci_role(ci)->name, ci->roles[role]->name);
181 if (ci->vbus_active && ci->role == CI_ROLE_GADGET)
186 usb_gadget_vbus_disconnect(&ci->gadget);
188 ci_role_stop(ci);
191 IS_ERR(ci->platdata->vbus_extcon.edev))
199 hw_wait_vbus_lower_bsv(ci);
201 ci_role_start(ci, role);
204 ci_handle_vbus_change(ci);
206 mutex_unlock(&ci->mutex);
214 struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
216 if (ci_otg_is_fsm_mode(ci) && !ci_otg_fsm_work(ci)) {
217 enable_irq(ci->irq);
221 pm_runtime_get_sync(ci->dev);
223 if (ci->id_event) {
224 ci->id_event = false;
225 ci_handle_id_switch(ci);
228 if (ci->b_sess_valid_event) {
229 ci->b_sess_valid_event = false;
230 ci_handle_vbus_change(ci);
233 pm_runtime_put_sync(ci->dev);
235 enable_irq(ci->irq);
241 * @ci: the controller
243 int ci_hdrc_otg_init(struct ci_hdrc *ci)
245 INIT_WORK(&ci->work, ci_otg_work);
246 ci->wq = create_freezable_workqueue("ci_otg");
247 if (!ci->wq) {
248 dev_err(ci->dev, "can't create workqueue\n");
252 if (ci_otg_is_fsm_mode(ci))
253 return ci_hdrc_otg_fsm_init(ci);
260 * @ci: the controller
262 void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
264 if (ci->wq)
265 destroy_workqueue(ci->wq);
268 hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS,
270 if (ci_otg_is_fsm_mode(ci))
271 ci_hdrc_otg_fsm_remove(ci);