Lines Matching refs:ci

31 u32 hw_read_otgsc(struct ci_hdrc *ci, u32 mask)  in hw_read_otgsc()  argument
34 u32 val = hw_read(ci, OP_OTGSC, mask); in hw_read_otgsc()
40 cable = &ci->platdata->vbus_extcon; in hw_read_otgsc()
55 cable = &ci->platdata->id_extcon; in hw_read_otgsc()
78 void hw_write_otgsc(struct ci_hdrc *ci, u32 mask, u32 data) in hw_write_otgsc() argument
80 hw_write(ci, OP_OTGSC, mask | OTGSC_INT_STATUS_BITS, data); in hw_write_otgsc()
87 enum ci_role ci_otg_role(struct ci_hdrc *ci) in ci_otg_role() argument
89 enum ci_role role = hw_read_otgsc(ci, OTGSC_ID) in ci_otg_role()
96 void ci_handle_vbus_change(struct ci_hdrc *ci) in ci_handle_vbus_change() argument
98 if (!ci->is_otg) in ci_handle_vbus_change()
101 if (hw_read_otgsc(ci, OTGSC_BSV)) in ci_handle_vbus_change()
102 usb_gadget_vbus_connect(&ci->gadget); in ci_handle_vbus_change()
104 usb_gadget_vbus_disconnect(&ci->gadget); in ci_handle_vbus_change()
108 static void ci_handle_id_switch(struct ci_hdrc *ci) in ci_handle_id_switch() argument
110 enum ci_role role = ci_otg_role(ci); in ci_handle_id_switch()
112 if (role != ci->role) { in ci_handle_id_switch()
113 dev_dbg(ci->dev, "switching from %s to %s\n", in ci_handle_id_switch()
114 ci_role(ci)->name, ci->roles[role]->name); in ci_handle_id_switch()
116 ci_role_stop(ci); in ci_handle_id_switch()
120 hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0, in ci_handle_id_switch()
123 ci_role_start(ci, role); in ci_handle_id_switch()
132 struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work); in ci_otg_work() local
134 if (ci_otg_is_fsm_mode(ci) && !ci_otg_fsm_work(ci)) { in ci_otg_work()
135 enable_irq(ci->irq); in ci_otg_work()
139 pm_runtime_get_sync(ci->dev); in ci_otg_work()
140 if (ci->id_event) { in ci_otg_work()
141 ci->id_event = false; in ci_otg_work()
142 ci_handle_id_switch(ci); in ci_otg_work()
143 } else if (ci->b_sess_valid_event) { in ci_otg_work()
144 ci->b_sess_valid_event = false; in ci_otg_work()
145 ci_handle_vbus_change(ci); in ci_otg_work()
147 dev_err(ci->dev, "unexpected event occurs at %s\n", __func__); in ci_otg_work()
148 pm_runtime_put_sync(ci->dev); in ci_otg_work()
150 enable_irq(ci->irq); in ci_otg_work()
158 int ci_hdrc_otg_init(struct ci_hdrc *ci) in ci_hdrc_otg_init() argument
160 INIT_WORK(&ci->work, ci_otg_work); in ci_hdrc_otg_init()
161 ci->wq = create_freezable_workqueue("ci_otg"); in ci_hdrc_otg_init()
162 if (!ci->wq) { in ci_hdrc_otg_init()
163 dev_err(ci->dev, "can't create workqueue\n"); in ci_hdrc_otg_init()
167 if (ci_otg_is_fsm_mode(ci)) in ci_hdrc_otg_init()
168 return ci_hdrc_otg_fsm_init(ci); in ci_hdrc_otg_init()
177 void ci_hdrc_otg_destroy(struct ci_hdrc *ci) in ci_hdrc_otg_destroy() argument
179 if (ci->wq) { in ci_hdrc_otg_destroy()
180 flush_workqueue(ci->wq); in ci_hdrc_otg_destroy()
181 destroy_workqueue(ci->wq); in ci_hdrc_otg_destroy()
184 hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS, in ci_hdrc_otg_destroy()
186 if (ci_otg_is_fsm_mode(ci)) in ci_hdrc_otg_destroy()
187 ci_hdrc_otg_fsm_remove(ci); in ci_hdrc_otg_destroy()