otg_fsm.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (C) 2014 Freescale Semiconductor, Inc.
  3. *
  4. * Author: Jun Li
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
  11. #define __DRIVERS_USB_CHIPIDEA_OTG_FSM_H
  12. #include <linux/usb/otg-fsm.h>
  13. /*
  14. * A-DEVICE timing constants
  15. */
  16. /* Wait for VBUS Rise */
  17. #define TA_WAIT_VRISE (100) /* a_wait_vrise: section 7.1.2
  18. * a_wait_vrise_tmr: section 7.4.5.1
  19. * TA_VBUS_RISE <= 100ms, section 4.4
  20. * Table 4-1: Electrical Characteristics
  21. * ->DC Electrical Timing
  22. */
  23. /* Wait for VBUS Fall */
  24. #define TA_WAIT_VFALL (1000) /* a_wait_vfall: section 7.1.7
  25. * a_wait_vfall_tmr: section: 7.4.5.2
  26. */
  27. /* Wait for B-Connect */
  28. #define TA_WAIT_BCON (10000) /* a_wait_bcon: section 7.1.3
  29. * TA_WAIT_BCON: should be between 1100
  30. * and 30000 ms, section 5.5, Table 5-1
  31. */
  32. /* A-Idle to B-Disconnect */
  33. #define TA_AIDL_BDIS (5000) /* a_suspend min 200 ms, section 5.2.1
  34. * TA_AIDL_BDIS: section 5.5, Table 5-1
  35. */
  36. /* B-Idle to A-Disconnect */
  37. #define TA_BIDL_ADIS (500) /* TA_BIDL_ADIS: section 5.2.1
  38. * 500ms is used for B switch to host
  39. * for safe
  40. */
  41. /*
  42. * B-device timing constants
  43. */
  44. /* Data-Line Pulse Time*/
  45. #define TB_DATA_PLS (10) /* b_srp_init,continue 5~10ms
  46. * section:5.1.3
  47. */
  48. /* SRP Fail Time */
  49. #define TB_SRP_FAIL (6000) /* b_srp_init,fail time 5~6s
  50. * section:5.1.6
  51. */
  52. /* A-SE0 to B-Reset */
  53. #define TB_ASE0_BRST (155) /* minimum 155 ms, section:5.3.1 */
  54. /* SE0 Time Before SRP */
  55. #define TB_SE0_SRP (1000) /* b_idle,minimum 1s, section:5.1.2 */
  56. /* SSEND time before SRP */
  57. #define TB_SSEND_SRP (1500) /* minimum 1.5 sec, section:5.1.2 */
  58. #define TB_SESS_VLD (1000)
  59. enum ci_otg_fsm_timer_index {
  60. /*
  61. * CI specific timers, start from the end
  62. * of standard and auxiliary OTG timers
  63. */
  64. B_DATA_PLS = NUM_OTG_FSM_TIMERS,
  65. B_SSEND_SRP,
  66. B_SESS_VLD,
  67. NUM_CI_OTG_FSM_TIMERS,
  68. };
  69. struct ci_otg_fsm_timer {
  70. unsigned long expires; /* Number of count increase to timeout */
  71. unsigned long count; /* Tick counter */
  72. void (*function)(void *, unsigned long); /* Timeout function */
  73. unsigned long data; /* Data passed to function */
  74. struct list_head list;
  75. };
  76. struct ci_otg_fsm_timer_list {
  77. struct ci_otg_fsm_timer *timer_list[NUM_CI_OTG_FSM_TIMERS];
  78. struct list_head active_timers;
  79. };
  80. #ifdef CONFIG_USB_OTG_FSM
  81. int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
  82. int ci_otg_fsm_work(struct ci_hdrc *ci);
  83. irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci);
  84. void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci);
  85. void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci);
  86. #else
  87. static inline int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
  88. {
  89. return 0;
  90. }
  91. static inline int ci_otg_fsm_work(struct ci_hdrc *ci)
  92. {
  93. return -ENXIO;
  94. }
  95. static inline irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
  96. {
  97. return IRQ_NONE;
  98. }
  99. static inline void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
  100. {
  101. }
  102. static inline void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
  103. {
  104. }
  105. #endif
  106. #endif /* __DRIVERS_USB_CHIPIDEA_OTG_FSM_H */