msm_hsusb.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* linux/include/asm-arm/arch-msm/hsusb.h
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Author: Brian Swetland <swetland@google.com>
  5. * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef __ASM_ARCH_MSM_HSUSB_H
  18. #define __ASM_ARCH_MSM_HSUSB_H
  19. #include <linux/types.h>
  20. #include <linux/usb/otg.h>
  21. /**
  22. * Supported USB modes
  23. *
  24. * USB_PERIPHERAL Only peripheral mode is supported.
  25. * USB_HOST Only host mode is supported.
  26. * USB_OTG OTG mode is supported.
  27. *
  28. */
  29. enum usb_mode_type {
  30. USB_NONE = 0,
  31. USB_PERIPHERAL,
  32. USB_HOST,
  33. USB_OTG,
  34. };
  35. /**
  36. * OTG control
  37. *
  38. * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
  39. * only configuration.
  40. * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
  41. * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
  42. * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
  43. *
  44. */
  45. enum otg_control_type {
  46. OTG_NO_CONTROL = 0,
  47. OTG_PHY_CONTROL,
  48. OTG_PMIC_CONTROL,
  49. OTG_USER_CONTROL,
  50. };
  51. /**
  52. * PHY used in
  53. *
  54. * INVALID_PHY Unsupported PHY
  55. * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
  56. * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
  57. *
  58. */
  59. enum msm_usb_phy_type {
  60. INVALID_PHY = 0,
  61. CI_45NM_INTEGRATED_PHY,
  62. SNPS_28NM_INTEGRATED_PHY,
  63. };
  64. #define IDEV_CHG_MAX 1500
  65. #define IUNIT 100
  66. /**
  67. * Different states involved in USB charger detection.
  68. *
  69. * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
  70. * process is not yet started.
  71. * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
  72. * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
  73. * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
  74. * between SDP and DCP/CDP).
  75. * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
  76. * between DCP and CDP).
  77. * USB_CHG_STATE_DETECTED USB charger type is determined.
  78. *
  79. */
  80. enum usb_chg_state {
  81. USB_CHG_STATE_UNDEFINED = 0,
  82. USB_CHG_STATE_WAIT_FOR_DCD,
  83. USB_CHG_STATE_DCD_DONE,
  84. USB_CHG_STATE_PRIMARY_DONE,
  85. USB_CHG_STATE_SECONDARY_DONE,
  86. USB_CHG_STATE_DETECTED,
  87. };
  88. /**
  89. * USB charger types
  90. *
  91. * USB_INVALID_CHARGER Invalid USB charger.
  92. * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
  93. * on USB2.0 compliant host/hub.
  94. * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
  95. * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
  96. * IDEV_CHG_MAX can be drawn irrespective of USB state.
  97. *
  98. */
  99. enum usb_chg_type {
  100. USB_INVALID_CHARGER = 0,
  101. USB_SDP_CHARGER,
  102. USB_DCP_CHARGER,
  103. USB_CDP_CHARGER,
  104. };
  105. /**
  106. * struct msm_otg_platform_data - platform device data
  107. * for msm_otg driver.
  108. * @phy_init_seq: PHY configuration sequence. val, reg pairs
  109. * terminated by -1.
  110. * @vbus_power: VBUS power on/off routine.
  111. * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  112. * @mode: Supported mode (OTG/peripheral/host).
  113. * @otg_control: OTG switch controlled by user/Id pin
  114. * @default_mode: Default operational mode. Applicable only if
  115. * OTG switch is controller by user.
  116. * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
  117. * dfab_usb_hs_clk in case of 8660 and 8960.
  118. */
  119. struct msm_otg_platform_data {
  120. int *phy_init_seq;
  121. void (*vbus_power)(bool on);
  122. unsigned power_budget;
  123. enum usb_mode_type mode;
  124. enum otg_control_type otg_control;
  125. enum usb_mode_type default_mode;
  126. enum msm_usb_phy_type phy_type;
  127. void (*setup_gpio)(enum usb_otg_state state);
  128. char *pclk_src_name;
  129. };
  130. /**
  131. * struct msm_otg: OTG driver data. Shared by HCD and DCD.
  132. * @otg: USB OTG Transceiver structure.
  133. * @pdata: otg device platform data.
  134. * @irq: IRQ number assigned for HSUSB controller.
  135. * @clk: clock struct of usb_hs_clk.
  136. * @pclk: clock struct of usb_hs_pclk.
  137. * @pclk_src: pclk source for voting.
  138. * @phy_reset_clk: clock struct of usb_phy_clk.
  139. * @core_clk: clock struct of usb_hs_core_clk.
  140. * @regs: ioremapped register base address.
  141. * @inputs: OTG state machine inputs(Id, SessValid etc).
  142. * @sm_work: OTG state machine work.
  143. * @in_lpm: indicates low power mode (LPM) state.
  144. * @async_int: Async interrupt arrived.
  145. * @cur_power: The amount of mA available from downstream port.
  146. * @chg_work: Charger detection work.
  147. * @chg_state: The state of charger detection process.
  148. * @chg_type: The type of charger attached.
  149. * @dcd_retires: The retry count used to track Data contact
  150. * detection process.
  151. */
  152. struct msm_otg {
  153. struct usb_phy phy;
  154. struct msm_otg_platform_data *pdata;
  155. int irq;
  156. struct clk *clk;
  157. struct clk *pclk;
  158. struct clk *pclk_src;
  159. struct clk *phy_reset_clk;
  160. struct clk *core_clk;
  161. void __iomem *regs;
  162. #define ID 0
  163. #define B_SESS_VLD 1
  164. unsigned long inputs;
  165. struct work_struct sm_work;
  166. atomic_t in_lpm;
  167. int async_int;
  168. unsigned cur_power;
  169. struct delayed_work chg_work;
  170. enum usb_chg_state chg_state;
  171. enum usb_chg_type chg_type;
  172. u8 dcd_retries;
  173. };
  174. #endif