langwell_otg.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Intel Langwell USB OTG transceiver driver
  3. * Copyright (C) 2008 - 2010, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. #ifndef __LANGWELL_OTG_H
  20. #define __LANGWELL_OTG_H
  21. #include <linux/usb/intel_mid_otg.h>
  22. #define CI_USBCMD 0x30
  23. # define USBCMD_RST BIT(1)
  24. # define USBCMD_RS BIT(0)
  25. #define CI_USBSTS 0x34
  26. # define USBSTS_SLI BIT(8)
  27. # define USBSTS_URI BIT(6)
  28. # define USBSTS_PCI BIT(2)
  29. #define CI_PORTSC1 0x74
  30. # define PORTSC_PP BIT(12)
  31. # define PORTSC_LS (BIT(11) | BIT(10))
  32. # define PORTSC_SUSP BIT(7)
  33. # define PORTSC_CCS BIT(0)
  34. #define CI_HOSTPC1 0xb4
  35. # define HOSTPC1_PHCD BIT(22)
  36. #define CI_OTGSC 0xf4
  37. # define OTGSC_DPIE BIT(30)
  38. # define OTGSC_1MSE BIT(29)
  39. # define OTGSC_BSEIE BIT(28)
  40. # define OTGSC_BSVIE BIT(27)
  41. # define OTGSC_ASVIE BIT(26)
  42. # define OTGSC_AVVIE BIT(25)
  43. # define OTGSC_IDIE BIT(24)
  44. # define OTGSC_DPIS BIT(22)
  45. # define OTGSC_1MSS BIT(21)
  46. # define OTGSC_BSEIS BIT(20)
  47. # define OTGSC_BSVIS BIT(19)
  48. # define OTGSC_ASVIS BIT(18)
  49. # define OTGSC_AVVIS BIT(17)
  50. # define OTGSC_IDIS BIT(16)
  51. # define OTGSC_DPS BIT(14)
  52. # define OTGSC_1MST BIT(13)
  53. # define OTGSC_BSE BIT(12)
  54. # define OTGSC_BSV BIT(11)
  55. # define OTGSC_ASV BIT(10)
  56. # define OTGSC_AVV BIT(9)
  57. # define OTGSC_ID BIT(8)
  58. # define OTGSC_HABA BIT(7)
  59. # define OTGSC_HADP BIT(6)
  60. # define OTGSC_IDPU BIT(5)
  61. # define OTGSC_DP BIT(4)
  62. # define OTGSC_OT BIT(3)
  63. # define OTGSC_HAAR BIT(2)
  64. # define OTGSC_VC BIT(1)
  65. # define OTGSC_VD BIT(0)
  66. # define OTGSC_INTEN_MASK (0x7f << 24)
  67. # define OTGSC_INT_MASK (0x5f << 24)
  68. # define OTGSC_INTSTS_MASK (0x7f << 16)
  69. #define CI_USBMODE 0xf8
  70. # define USBMODE_CM (BIT(1) | BIT(0))
  71. # define USBMODE_IDLE 0
  72. # define USBMODE_DEVICE 0x2
  73. # define USBMODE_HOST 0x3
  74. #define USBCFG_ADDR 0xff10801c
  75. #define USBCFG_LEN 4
  76. # define USBCFG_VBUSVAL BIT(14)
  77. # define USBCFG_AVALID BIT(13)
  78. # define USBCFG_BVALID BIT(12)
  79. # define USBCFG_SESEND BIT(11)
  80. #define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
  81. enum langwell_otg_timer_type {
  82. TA_WAIT_VRISE_TMR,
  83. TA_WAIT_BCON_TMR,
  84. TA_AIDL_BDIS_TMR,
  85. TB_ASE0_BRST_TMR,
  86. TB_SE0_SRP_TMR,
  87. TB_SRP_INIT_TMR,
  88. TB_SRP_FAIL_TMR,
  89. TB_BUS_SUSPEND_TMR
  90. };
  91. #define TA_WAIT_VRISE 100
  92. #define TA_WAIT_BCON 30000
  93. #define TA_AIDL_BDIS 15000
  94. #define TB_ASE0_BRST 5000
  95. #define TB_SE0_SRP 2
  96. #define TB_SRP_INIT 100
  97. #define TB_SRP_FAIL 5500
  98. #define TB_BUS_SUSPEND 500
  99. struct langwell_otg_timer {
  100. unsigned long expires; /* Number of count increase to timeout */
  101. unsigned long count; /* Tick counter */
  102. void (*function)(unsigned long); /* Timeout function */
  103. unsigned long data; /* Data passed to function */
  104. struct list_head list;
  105. };
  106. struct langwell_otg {
  107. struct intel_mid_otg_xceiv iotg;
  108. struct device *dev;
  109. void __iomem *usbcfg; /* SCCBUSB config Reg */
  110. unsigned region;
  111. unsigned cfg_region;
  112. struct work_struct work;
  113. struct workqueue_struct *qwork;
  114. struct timer_list hsm_timer;
  115. spinlock_t lock;
  116. spinlock_t wq_lock;
  117. struct notifier_block iotg_notifier;
  118. };
  119. static inline
  120. struct langwell_otg *mid_xceiv_to_lnw(struct intel_mid_otg_xceiv *iotg)
  121. {
  122. return container_of(iotg, struct langwell_otg, iotg);
  123. }
  124. #endif /* __LANGWELL_OTG_H__ */