Lines Matching refs:fsm

11  * This file mainly handles OTG fsm, it includes OTG fsm operations
40 t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_req);
56 mutex_lock(&ci->fsm.lock);
58 ci->fsm.a_bus_req = 0;
61 if (ci->fsm.a_bus_drop) {
62 mutex_unlock(&ci->fsm.lock);
65 ci->fsm.a_bus_req = 1;
66 if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) {
68 mutex_unlock(&ci->fsm.lock);
74 mutex_unlock(&ci->fsm.lock);
89 t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_drop);
105 mutex_lock(&ci->fsm.lock);
107 ci->fsm.a_bus_drop = 0;
109 ci->fsm.a_bus_drop = 1;
110 ci->fsm.a_bus_req = 0;
114 mutex_unlock(&ci->fsm.lock);
129 t = scnprintf(next, size, "%d\n", ci->fsm.b_bus_req);
145 mutex_lock(&ci->fsm.lock);
147 ci->fsm.b_bus_req = 0;
149 ci->fsm.b_bus_req = 1;
150 if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) {
152 mutex_unlock(&ci->fsm.lock);
158 mutex_unlock(&ci->fsm.lock);
173 mutex_lock(&ci->fsm.lock);
175 ci->fsm.a_clr_err = 1;
178 mutex_unlock(&ci->fsm.lock);
199 * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h
288 ci->fsm.a_wait_vrise_tmout = 1;
294 ci->fsm.a_wait_vfall_tmout = 1;
300 ci->fsm.a_wait_bcon_tmout = 1;
306 ci->fsm.a_aidl_bdis_tmout = 1;
312 ci->fsm.b_ase0_brst_tmout = 1;
318 ci->fsm.a_bidl_adis_tmout = 1;
324 ci->fsm.a_bus_suspend = 1;
330 ci->fsm.b_se0_srp = 1;
336 ci->fsm.b_srp_done = 1;
342 ci->fsm.b_srp_done = 1;
343 ci->fsm.b_bus_req = 0;
344 if (ci->fsm.power_up)
345 ci->fsm.power_up = 0;
353 ci->fsm.b_ssend_srp = 1;
355 if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
363 * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h
436 static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
438 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
445 static void ci_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
447 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
458 static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
461 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
479 fsm->a_srp_det = 0;
480 fsm->power_up = 0;
485 fsm->a_bus_drop = 1;
486 fsm->a_bus_req = 0;
493 static void ci_otg_loc_conn(struct otg_fsm *fsm, int on)
495 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
512 static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
516 if (!fsm->otg->host)
519 udev = usb_hub_find_child(fsm->otg->host->root_hub, 1);
535 static void ci_otg_start_pulse(struct otg_fsm *fsm)
537 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
546 static int ci_otg_start_host(struct otg_fsm *fsm, int on)
548 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
560 static int ci_otg_start_gadget(struct otg_fsm *fsm, int on)
562 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
586 * Don't do fsm transition for B device
589 if (ci->fsm.id && !(ci->driver) &&
590 ci->fsm.otg->state < OTG_STATE_A_IDLE)
594 if (otg_statemachine(&ci->fsm)) {
595 if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
604 if ((ci->fsm.id) || (ci->id_event) ||
605 (ci->fsm.power_up)) {
616 } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
617 if (ci->fsm.b_sess_vld) {
618 ci->fsm.power_up = 0;
625 } else if (ci->fsm.otg->state == OTG_STATE_A_HOST) {
636 * Update fsm variables in each state if catching expected interrupts,
637 * called by otg fsm isr.
642 struct otg_fsm *fsm = &ci->fsm;
648 switch (ci->fsm.otg->state) {
651 fsm->b_conn = 1;
652 fsm->a_bus_req = 1;
658 fsm->b_sess_vld = 1;
667 if (fsm->a_bus_suspend == 1)
668 fsm->a_bus_suspend = 0;
673 fsm->a_conn = 0;
674 fsm->b_bus_req = 0;
680 fsm->b_bus_suspend = 1;
693 if (fsm->b_bus_suspend == 1) {
695 fsm->b_bus_suspend = 0;
701 fsm->b_conn = 0;
713 fsm->b_conn = 0;
719 fsm->a_conn = 1;
729 * ci_otg_irq - otg fsm related irq handling
730 * and also update otg fsm variable by monitoring usb host and udc
738 struct otg_fsm *fsm = &ci->fsm;
742 fsm->id = (otgsc & OTGSC_ID) ? 1 : 0;
747 fsm->a_srp_det = 1;
748 fsm->a_bus_drop = 0;
751 if (fsm->id == 0) {
752 fsm->a_bus_drop = 0;
753 fsm->a_bus_req = 1;
759 fsm->b_sess_vld = 1;
762 fsm->b_ssend_srp = 0;
764 fsm->b_sess_vld = 0;
765 if (fsm->id)
771 fsm->a_vbus_vld = 1;
773 fsm->a_vbus_vld = 0;
774 fsm->b_conn = 0;
801 ci->fsm.otg = &ci->otg;
802 ci->fsm.power_up = 1;
803 ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
804 ci->fsm.otg->state = OTG_STATE_UNDEFINED;
805 ci->fsm.ops = &ci_otg_ops;
807 ci->fsm.host_req_flag = devm_kzalloc(ci->dev, 1, GFP_KERNEL);
808 if (!ci->fsm.host_req_flag)
811 mutex_init(&ci->fsm.lock);
831 if (ci->fsm.id) {
832 ci->fsm.b_ssend_srp =
834 ci->fsm.b_sess_vld =