2 * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
4 * Copyright (C) 2014 Freescale Semiconductor, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 * This file mainly handles OTG fsm, it includes OTG fsm operations
22 #include <linux/usb/otg.h>
23 #include <linux/usb/gadget.h>
24 #include <linux/usb/hcd.h>
25 #include <linux/usb/chipidea.h>
26 #include <linux/regulator/consumer.h>
33 static struct ci_otg_fsm_timer *otg_timer_initializer
34 (struct ci_hdrc *ci, void (*function)(void *, unsigned long),
35 unsigned long expires, unsigned long data)
37 struct ci_otg_fsm_timer *timer;
39 timer = devm_kzalloc(ci->dev, sizeof(struct ci_otg_fsm_timer),
43 timer->function = function;
44 timer->expires = expires;
49 /* Add for otg: interact with user space app */
51 get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
55 struct ci_hdrc *ci = dev_get_drvdata(dev);
59 t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_req);
63 return PAGE_SIZE - size;
67 set_a_bus_req(struct device *dev, struct device_attribute *attr,
68 const char *buf, size_t count)
70 struct ci_hdrc *ci = dev_get_drvdata(dev);
75 mutex_lock(&ci->fsm.lock);
77 ci->fsm.a_bus_req = 0;
78 } else if (buf[0] == '1') {
79 /* If a_bus_drop is TRUE, a_bus_req can't be set */
80 if (ci->fsm.a_bus_drop) {
81 mutex_unlock(&ci->fsm.lock);
84 ci->fsm.a_bus_req = 1;
87 ci_otg_queue_work(ci);
88 mutex_unlock(&ci->fsm.lock);
92 static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUSR, get_a_bus_req, set_a_bus_req);
95 get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
99 struct ci_hdrc *ci = dev_get_drvdata(dev);
103 t = scnprintf(next, size, "%d\n", ci->fsm.a_bus_drop);
107 return PAGE_SIZE - size;
111 set_a_bus_drop(struct device *dev, struct device_attribute *attr,
112 const char *buf, size_t count)
114 struct ci_hdrc *ci = dev_get_drvdata(dev);
119 mutex_lock(&ci->fsm.lock);
121 ci->fsm.a_bus_drop = 0;
122 } else if (buf[0] == '1') {
123 ci->fsm.a_bus_drop = 1;
124 ci->fsm.a_bus_req = 0;
127 ci_otg_queue_work(ci);
128 mutex_unlock(&ci->fsm.lock);
132 static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUSR, get_a_bus_drop,
136 get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
140 struct ci_hdrc *ci = dev_get_drvdata(dev);
144 t = scnprintf(next, size, "%d\n", ci->fsm.b_bus_req);
148 return PAGE_SIZE - size;
152 set_b_bus_req(struct device *dev, struct device_attribute *attr,
153 const char *buf, size_t count)
155 struct ci_hdrc *ci = dev_get_drvdata(dev);
160 mutex_lock(&ci->fsm.lock);
162 ci->fsm.b_bus_req = 0;
163 else if (buf[0] == '1')
164 ci->fsm.b_bus_req = 1;
166 ci_otg_queue_work(ci);
167 mutex_unlock(&ci->fsm.lock);
171 static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUSR, get_b_bus_req, set_b_bus_req);
174 set_a_clr_err(struct device *dev, struct device_attribute *attr,
175 const char *buf, size_t count)
177 struct ci_hdrc *ci = dev_get_drvdata(dev);
182 mutex_lock(&ci->fsm.lock);
184 ci->fsm.a_clr_err = 1;
186 ci_otg_queue_work(ci);
187 mutex_unlock(&ci->fsm.lock);
191 static DEVICE_ATTR(a_clr_err, S_IWUSR, NULL, set_a_clr_err);
193 static struct attribute *inputs_attrs[] = {
194 &dev_attr_a_bus_req.attr,
195 &dev_attr_a_bus_drop.attr,
196 &dev_attr_b_bus_req.attr,
197 &dev_attr_a_clr_err.attr,
201 static struct attribute_group inputs_attr_group = {
203 .attrs = inputs_attrs,
207 * Add timer to active timer list
209 static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
211 struct ci_otg_fsm_timer *tmp_timer;
212 struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
213 struct list_head *active_timers = &ci->fsm_timer->active_timers;
215 if (t >= NUM_CI_OTG_FSM_TIMERS)
219 * Check if the timer is already in the active list,
220 * if so update timer count
222 list_for_each_entry(tmp_timer, active_timers, list)
223 if (tmp_timer == timer) {
224 timer->count = timer->expires;
228 if (list_empty(active_timers))
229 pm_runtime_get(ci->dev);
231 timer->count = timer->expires;
232 list_add_tail(&timer->list, active_timers);
235 if (!(hw_read_otgsc(ci, OTGSC_1MSIE)))
236 hw_write_otgsc(ci, OTGSC_1MSIE, OTGSC_1MSIE);
240 * Remove timer from active timer list
242 static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
244 struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
245 struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
246 struct list_head *active_timers = &ci->fsm_timer->active_timers;
249 if (t >= NUM_CI_OTG_FSM_TIMERS)
252 list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list)
253 if (tmp_timer == timer) {
254 list_del(&timer->list);
258 /* Disable 1ms irq if there is no any active timer */
259 if (list_empty(active_timers) && (flag == 1)) {
260 hw_write_otgsc(ci, OTGSC_1MSIE, 0);
261 pm_runtime_put(ci->dev);
266 * Reduce timer count by 1, and find timeout conditions.
267 * Called by otg 1ms timer interrupt
269 static inline int ci_otg_tick_timer(struct ci_hdrc *ci)
271 struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
272 struct list_head *active_timers = &ci->fsm_timer->active_timers;
275 list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) {
277 /* check if timer expires */
278 if (!tmp_timer->count) {
279 list_del(&tmp_timer->list);
280 tmp_timer->function(ci, tmp_timer->data);
285 /* disable 1ms irq if there is no any timer active */
286 if ((expired == 1) && list_empty(active_timers)) {
287 hw_write_otgsc(ci, OTGSC_1MSIE, 0);
288 pm_runtime_put(ci->dev);
294 /* The timeout callback function to set time out bit */
295 static void set_tmout(void *ptr, unsigned long indicator)
297 *(int *)indicator = 1;
300 static void set_tmout_and_fsm(void *ptr, unsigned long indicator)
302 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
304 set_tmout(ci, indicator);
306 ci_otg_queue_work(ci);
309 static void a_wait_vfall_tmout_func(void *ptr, unsigned long indicator)
311 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
313 set_tmout(ci, indicator);
314 /* Disable port power */
315 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP, 0);
316 /* Clear existing DP irq */
317 hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
318 /* Enable data pulse irq */
319 hw_write_otgsc(ci, OTGSC_DPIE, OTGSC_DPIE);
320 ci_otg_queue_work(ci);
323 static void b_ase0_brst_tmout_func(void *ptr, unsigned long indicator)
325 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
327 set_tmout(ci, indicator);
328 if (!hw_read_otgsc(ci, OTGSC_BSV))
329 ci->fsm.b_sess_vld = 0;
331 ci_otg_queue_work(ci);
334 static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
336 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
338 set_tmout(ci, indicator);
340 /* only vbus fall below B_sess_vld in b_idle state */
341 if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
342 ci_otg_queue_work(ci);
345 static void b_sess_vld_tmout_func(void *ptr, unsigned long indicator)
347 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
349 /* Check if A detached */
350 if (!(hw_read_otgsc(ci, OTGSC_BSV))) {
351 ci->fsm.b_sess_vld = 0;
352 ci_otg_add_timer(ci, B_SSEND_SRP);
353 ci_otg_queue_work(ci);
357 static void b_data_pulse_end(void *ptr, unsigned long indicator)
359 struct ci_hdrc *ci = (struct ci_hdrc *)ptr;
361 ci->fsm.b_srp_done = 1;
362 ci->fsm.b_bus_req = 0;
363 if (ci->fsm.power_up)
364 ci->fsm.power_up = 0;
366 hw_write_otgsc(ci, OTGSC_HABA, 0);
368 ci_otg_queue_work(ci);
371 /* Initialize timers */
372 static int ci_otg_init_timers(struct ci_hdrc *ci)
374 struct otg_fsm *fsm = &ci->fsm;
376 /* FSM used timers */
377 ci->fsm_timer->timer_list[A_WAIT_VRISE] =
378 otg_timer_initializer(ci, &set_tmout_and_fsm, TA_WAIT_VRISE,
379 (unsigned long)&fsm->a_wait_vrise_tmout);
380 if (ci->fsm_timer->timer_list[A_WAIT_VRISE] == NULL)
383 ci->fsm_timer->timer_list[A_WAIT_VFALL] =
384 otg_timer_initializer(ci, &a_wait_vfall_tmout_func,
385 TA_WAIT_VFALL, (unsigned long)&fsm->a_wait_vfall_tmout);
386 if (ci->fsm_timer->timer_list[A_WAIT_VFALL] == NULL)
389 ci->fsm_timer->timer_list[A_WAIT_BCON] =
390 otg_timer_initializer(ci, &set_tmout_and_fsm, TA_WAIT_BCON,
391 (unsigned long)&fsm->a_wait_bcon_tmout);
392 if (ci->fsm_timer->timer_list[A_WAIT_BCON] == NULL)
395 ci->fsm_timer->timer_list[A_AIDL_BDIS] =
396 otg_timer_initializer(ci, &set_tmout_and_fsm, TA_AIDL_BDIS,
397 (unsigned long)&fsm->a_aidl_bdis_tmout);
398 if (ci->fsm_timer->timer_list[A_AIDL_BDIS] == NULL)
401 ci->fsm_timer->timer_list[A_BIDL_ADIS] =
402 otg_timer_initializer(ci, &set_tmout_and_fsm, TA_BIDL_ADIS,
403 (unsigned long)&fsm->a_bidl_adis_tmout);
404 if (ci->fsm_timer->timer_list[A_BIDL_ADIS] == NULL)
407 ci->fsm_timer->timer_list[B_ASE0_BRST] =
408 otg_timer_initializer(ci, &b_ase0_brst_tmout_func, TB_ASE0_BRST,
409 (unsigned long)&fsm->b_ase0_brst_tmout);
410 if (ci->fsm_timer->timer_list[B_ASE0_BRST] == NULL)
413 ci->fsm_timer->timer_list[B_SE0_SRP] =
414 otg_timer_initializer(ci, &set_tmout_and_fsm, TB_SE0_SRP,
415 (unsigned long)&fsm->b_se0_srp);
416 if (ci->fsm_timer->timer_list[B_SE0_SRP] == NULL)
419 ci->fsm_timer->timer_list[B_SSEND_SRP] =
420 otg_timer_initializer(ci, &b_ssend_srp_tmout_func, TB_SSEND_SRP,
421 (unsigned long)&fsm->b_ssend_srp);
422 if (ci->fsm_timer->timer_list[B_SSEND_SRP] == NULL)
425 ci->fsm_timer->timer_list[B_SRP_FAIL] =
426 otg_timer_initializer(ci, &set_tmout, TB_SRP_FAIL,
427 (unsigned long)&fsm->b_srp_done);
428 if (ci->fsm_timer->timer_list[B_SRP_FAIL] == NULL)
431 ci->fsm_timer->timer_list[B_DATA_PLS] =
432 otg_timer_initializer(ci, &b_data_pulse_end, TB_DATA_PLS, 0);
433 if (ci->fsm_timer->timer_list[B_DATA_PLS] == NULL)
436 ci->fsm_timer->timer_list[B_SESS_VLD] = otg_timer_initializer(ci,
437 &b_sess_vld_tmout_func, TB_SESS_VLD, 0);
438 if (ci->fsm_timer->timer_list[B_SESS_VLD] == NULL)
444 /* -------------------------------------------------------------*/
445 /* Operations that will be called from OTG Finite State Machine */
446 /* -------------------------------------------------------------*/
447 static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
449 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
451 if (t < NUM_OTG_FSM_TIMERS)
452 ci_otg_add_timer(ci, t);
456 static void ci_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
458 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
460 if (t < NUM_OTG_FSM_TIMERS)
461 ci_otg_del_timer(ci, t);
466 * A-device drive vbus: turn on vbus regulator and enable port power
467 * Data pulse irq should be disabled while vbus is on.
469 static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
472 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
475 /* Enable power power */
476 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP,
478 if (ci->platdata->reg_vbus) {
479 ret = regulator_enable(ci->platdata->reg_vbus);
482 "Failed to enable vbus regulator, ret=%d\n",
487 /* Disable data pulse irq */
488 hw_write_otgsc(ci, OTGSC_DPIE, 0);
493 if (ci->platdata->reg_vbus)
494 regulator_disable(ci->platdata->reg_vbus);
502 * Control data line by Run Stop bit.
504 static void ci_otg_loc_conn(struct otg_fsm *fsm, int on)
506 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
509 hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
511 hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
515 * Generate SOF by host.
516 * This is controlled through suspend/resume the port.
517 * In host mode, controller will automatically send SOF.
518 * Suspend will block the data on the port.
520 static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
522 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
525 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_FPR,
528 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_SUSP,
533 * Start SRP pulsing by data-line pulsing,
534 * no v-bus pulsing followed
536 static void ci_otg_start_pulse(struct otg_fsm *fsm)
538 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
540 /* Hardware Assistant Data pulse */
541 hw_write_otgsc(ci, OTGSC_HADP, OTGSC_HADP);
543 ci_otg_add_timer(ci, B_DATA_PLS);
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);
550 mutex_unlock(&fsm->lock);
553 ci_role_start(ci, CI_ROLE_HOST);
557 ci_role_start(ci, CI_ROLE_GADGET);
559 mutex_lock(&fsm->lock);
563 static int ci_otg_start_gadget(struct otg_fsm *fsm, int on)
565 struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
567 mutex_unlock(&fsm->lock);
569 usb_gadget_vbus_connect(&ci->gadget);
571 usb_gadget_vbus_disconnect(&ci->gadget);
572 mutex_lock(&fsm->lock);
577 static struct otg_fsm_ops ci_otg_ops = {
578 .drv_vbus = ci_otg_drv_vbus,
579 .loc_conn = ci_otg_loc_conn,
580 .loc_sof = ci_otg_loc_sof,
581 .start_pulse = ci_otg_start_pulse,
582 .add_timer = ci_otg_fsm_add_timer,
583 .del_timer = ci_otg_fsm_del_timer,
584 .start_host = ci_otg_start_host,
585 .start_gadget = ci_otg_start_gadget,
588 int ci_otg_fsm_work(struct ci_hdrc *ci)
591 * Don't do fsm transition for B device
592 * when there is no gadget class driver
594 if (ci->fsm.id && !(ci->driver) &&
595 ci->fsm.otg->state < OTG_STATE_A_IDLE)
598 pm_runtime_get_sync(ci->dev);
599 if (otg_statemachine(&ci->fsm)) {
600 if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
602 * Further state change for cases:
603 * a_idle to b_idle; or
604 * a_idle to a_wait_vrise due to ID change(1->0), so
605 * B-dev becomes A-dev can try to start new session
607 * a_idle to a_wait_vrise when power up
609 if ((ci->fsm.id) || (ci->id_event) ||
611 ci_otg_queue_work(ci);
613 ci->id_event = false;
614 } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
615 if (ci->fsm.b_sess_vld) {
616 ci->fsm.power_up = 0;
618 * Further transite to b_periphearl state
619 * when register gadget driver with vbus on
621 ci_otg_queue_work(ci);
623 } else if (ci->fsm.otg->state == OTG_STATE_A_HOST) {
624 pm_runtime_mark_last_busy(ci->dev);
625 pm_runtime_put_autosuspend(ci->dev);
629 pm_runtime_put_sync(ci->dev);
634 * Update fsm variables in each state if catching expected interrupts,
635 * called by otg fsm isr.
637 static void ci_otg_fsm_event(struct ci_hdrc *ci)
639 u32 intr_sts, otg_bsess_vld, port_conn;
640 struct otg_fsm *fsm = &ci->fsm;
642 intr_sts = hw_read_intr_status(ci);
643 otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
644 port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);
646 switch (ci->fsm.otg->state) {
647 case OTG_STATE_A_WAIT_BCON:
651 ci_otg_queue_work(ci);
654 case OTG_STATE_B_IDLE:
655 if (otg_bsess_vld && (intr_sts & USBi_PCI) && port_conn) {
657 ci_otg_queue_work(ci);
660 case OTG_STATE_B_PERIPHERAL:
661 if ((intr_sts & USBi_SLI) && port_conn && otg_bsess_vld) {
662 fsm->a_bus_suspend = 1;
663 ci_otg_queue_work(ci);
664 } else if (intr_sts & USBi_PCI) {
665 if (fsm->a_bus_suspend == 1)
666 fsm->a_bus_suspend = 0;
669 case OTG_STATE_B_HOST:
670 if ((intr_sts & USBi_PCI) && !port_conn) {
673 ci_otg_queue_work(ci);
674 ci_otg_add_timer(ci, B_SESS_VLD);
677 case OTG_STATE_A_PERIPHERAL:
678 if (intr_sts & USBi_SLI) {
679 fsm->b_bus_suspend = 1;
681 * Init a timer to know how long this suspend
682 * will continue, if time out, indicates B no longer
683 * wants to be host role
685 ci_otg_add_timer(ci, A_BIDL_ADIS);
688 if (intr_sts & USBi_URI)
689 ci_otg_del_timer(ci, A_BIDL_ADIS);
691 if (intr_sts & USBi_PCI) {
692 if (fsm->b_bus_suspend == 1) {
693 ci_otg_del_timer(ci, A_BIDL_ADIS);
694 fsm->b_bus_suspend = 0;
698 case OTG_STATE_A_SUSPEND:
699 if ((intr_sts & USBi_PCI) && !port_conn) {
702 /* if gadget driver is binded */
704 /* A device to be peripheral mode */
705 ci->gadget.is_a_peripheral = 1;
707 ci_otg_queue_work(ci);
710 case OTG_STATE_A_HOST:
711 if ((intr_sts & USBi_PCI) && !port_conn) {
713 ci_otg_queue_work(ci);
716 case OTG_STATE_B_WAIT_ACON:
717 if ((intr_sts & USBi_PCI) && port_conn) {
719 ci_otg_queue_work(ci);
728 * ci_otg_irq - otg fsm related irq handling
729 * and also update otg fsm variable by monitoring usb host and udc
730 * state change interrupts.
733 irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
735 irqreturn_t retval = IRQ_NONE;
736 u32 otgsc, otg_int_src = 0;
737 struct otg_fsm *fsm = &ci->fsm;
739 otgsc = hw_read_otgsc(ci, ~0);
740 otg_int_src = otgsc & OTGSC_INT_STATUS_BITS & (otgsc >> 8);
741 fsm->id = (otgsc & OTGSC_ID) ? 1 : 0;
744 if (otg_int_src & OTGSC_1MSIS) {
745 hw_write_otgsc(ci, OTGSC_1MSIS, OTGSC_1MSIS);
746 retval = ci_otg_tick_timer(ci);
748 } else if (otg_int_src & OTGSC_DPIS) {
749 hw_write_otgsc(ci, OTGSC_DPIS, OTGSC_DPIS);
752 } else if (otg_int_src & OTGSC_IDIS) {
753 hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS);
759 } else if (otg_int_src & OTGSC_BSVIS) {
760 hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
761 if (otgsc & OTGSC_BSV) {
763 ci_otg_del_timer(ci, B_SSEND_SRP);
764 ci_otg_del_timer(ci, B_SRP_FAIL);
765 fsm->b_ssend_srp = 0;
769 ci_otg_add_timer(ci, B_SSEND_SRP);
771 } else if (otg_int_src & OTGSC_AVVIS) {
772 hw_write_otgsc(ci, OTGSC_AVVIS, OTGSC_AVVIS);
773 if (otgsc & OTGSC_AVV) {
780 ci_otg_queue_work(ci);
784 ci_otg_fsm_event(ci);
789 void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
791 ci_otg_queue_work(ci);
794 int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
799 ci->otg.phy = ci->phy;
801 ci->otg.usb_phy = ci->usb_phy;
803 ci->otg.gadget = &ci->gadget;
804 ci->fsm.otg = &ci->otg;
805 ci->fsm.power_up = 1;
806 ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
807 ci->fsm.otg->state = OTG_STATE_UNDEFINED;
808 ci->fsm.ops = &ci_otg_ops;
810 mutex_init(&ci->fsm.lock);
812 ci->fsm_timer = devm_kzalloc(ci->dev,
813 sizeof(struct ci_otg_fsm_timer_list), GFP_KERNEL);
817 INIT_LIST_HEAD(&ci->fsm_timer->active_timers);
818 retval = ci_otg_init_timers(ci);
820 dev_err(ci->dev, "Couldn't init OTG timers\n");
824 retval = sysfs_create_group(&ci->dev->kobj, &inputs_attr_group);
827 "Can't register sysfs attr group: %d\n", retval);
831 /* Enable A vbus valid irq */
832 hw_write_otgsc(ci, OTGSC_AVVIE, OTGSC_AVVIE);
835 ci->fsm.b_ssend_srp =
836 hw_read_otgsc(ci, OTGSC_BSV) ? 0 : 1;
838 hw_read_otgsc(ci, OTGSC_BSV) ? 1 : 0;
840 hw_write_otgsc(ci, OTGSC_BSVIE, OTGSC_BSVIE);
846 void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
848 sysfs_remove_group(&ci->dev->kobj, &inputs_attr_group);