msm_hsusb.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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/extcon.h>
  20. #include <linux/types.h>
  21. #include <linux/usb/otg.h>
  22. #include <linux/clk.h>
  23. /**
  24. * OTG control
  25. *
  26. * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
  27. * only configuration.
  28. * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
  29. * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
  30. * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
  31. *
  32. */
  33. enum otg_control_type {
  34. OTG_NO_CONTROL = 0,
  35. OTG_PHY_CONTROL,
  36. OTG_PMIC_CONTROL,
  37. OTG_USER_CONTROL,
  38. };
  39. /**
  40. * PHY used in
  41. *
  42. * INVALID_PHY Unsupported PHY
  43. * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
  44. * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
  45. *
  46. */
  47. enum msm_usb_phy_type {
  48. INVALID_PHY = 0,
  49. CI_45NM_INTEGRATED_PHY,
  50. SNPS_28NM_INTEGRATED_PHY,
  51. };
  52. #define IDEV_CHG_MAX 1500
  53. #define IUNIT 100
  54. /**
  55. * Different states involved in USB charger detection.
  56. *
  57. * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
  58. * process is not yet started.
  59. * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
  60. * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
  61. * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
  62. * between SDP and DCP/CDP).
  63. * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
  64. * between DCP and CDP).
  65. * USB_CHG_STATE_DETECTED USB charger type is determined.
  66. *
  67. */
  68. enum usb_chg_state {
  69. USB_CHG_STATE_UNDEFINED = 0,
  70. USB_CHG_STATE_WAIT_FOR_DCD,
  71. USB_CHG_STATE_DCD_DONE,
  72. USB_CHG_STATE_PRIMARY_DONE,
  73. USB_CHG_STATE_SECONDARY_DONE,
  74. USB_CHG_STATE_DETECTED,
  75. };
  76. /**
  77. * USB charger types
  78. *
  79. * USB_INVALID_CHARGER Invalid USB charger.
  80. * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
  81. * on USB2.0 compliant host/hub.
  82. * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
  83. * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
  84. * IDEV_CHG_MAX can be drawn irrespective of USB state.
  85. *
  86. */
  87. enum usb_chg_type {
  88. USB_INVALID_CHARGER = 0,
  89. USB_SDP_CHARGER,
  90. USB_DCP_CHARGER,
  91. USB_CDP_CHARGER,
  92. };
  93. /**
  94. * struct msm_otg_platform_data - platform device data
  95. * for msm_otg driver.
  96. * @phy_init_seq: PHY configuration sequence values. Value of -1 is reserved as
  97. * "do not overwrite default vaule at this address".
  98. * @phy_init_sz: PHY configuration sequence size.
  99. * @vbus_power: VBUS power on/off routine.
  100. * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  101. * @mode: Supported mode (OTG/peripheral/host).
  102. * @otg_control: OTG switch controlled by user/Id pin
  103. */
  104. struct msm_otg_platform_data {
  105. int *phy_init_seq;
  106. int phy_init_sz;
  107. void (*vbus_power)(bool on);
  108. unsigned power_budget;
  109. enum usb_dr_mode mode;
  110. enum otg_control_type otg_control;
  111. enum msm_usb_phy_type phy_type;
  112. void (*setup_gpio)(enum usb_otg_state state);
  113. };
  114. /**
  115. * struct msm_usb_cable - structure for exteternal connector cable
  116. * state tracking
  117. * @nb: hold event notification callback
  118. * @conn: used for notification registration
  119. */
  120. struct msm_usb_cable {
  121. struct notifier_block nb;
  122. struct extcon_dev *extcon;
  123. };
  124. /**
  125. * struct msm_otg: OTG driver data. Shared by HCD and DCD.
  126. * @otg: USB OTG Transceiver structure.
  127. * @pdata: otg device platform data.
  128. * @irq: IRQ number assigned for HSUSB controller.
  129. * @clk: clock struct of usb_hs_clk.
  130. * @pclk: clock struct of usb_hs_pclk.
  131. * @core_clk: clock struct of usb_hs_core_clk.
  132. * @regs: ioremapped register base address.
  133. * @inputs: OTG state machine inputs(Id, SessValid etc).
  134. * @sm_work: OTG state machine work.
  135. * @in_lpm: indicates low power mode (LPM) state.
  136. * @async_int: Async interrupt arrived.
  137. * @cur_power: The amount of mA available from downstream port.
  138. * @chg_work: Charger detection work.
  139. * @chg_state: The state of charger detection process.
  140. * @chg_type: The type of charger attached.
  141. * @dcd_retires: The retry count used to track Data contact
  142. * detection process.
  143. * @manual_pullup: true if VBUS is not routed to USB controller/phy
  144. * and controller driver therefore enables pull-up explicitly before
  145. * starting controller using usbcmd run/stop bit.
  146. * @vbus: VBUS signal state trakining, using extcon framework
  147. * @id: ID signal state trakining, using extcon framework
  148. * @switch_gpio: Descriptor for GPIO used to control external Dual
  149. * SPDT USB Switch.
  150. * @reboot: Used to inform the driver to route USB D+/D- line to Device
  151. * connector
  152. */
  153. struct msm_otg {
  154. struct usb_phy phy;
  155. struct msm_otg_platform_data *pdata;
  156. int irq;
  157. struct clk *clk;
  158. struct clk *pclk;
  159. struct clk *core_clk;
  160. void __iomem *regs;
  161. #define ID 0
  162. #define B_SESS_VLD 1
  163. unsigned long inputs;
  164. struct work_struct sm_work;
  165. atomic_t in_lpm;
  166. int async_int;
  167. unsigned cur_power;
  168. int phy_number;
  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. struct regulator *v3p3;
  174. struct regulator *v1p8;
  175. struct regulator *vddcx;
  176. struct reset_control *phy_rst;
  177. struct reset_control *link_rst;
  178. int vdd_levels[3];
  179. bool manual_pullup;
  180. struct msm_usb_cable vbus;
  181. struct msm_usb_cable id;
  182. struct gpio_desc *switch_gpio;
  183. struct notifier_block reboot;
  184. };
  185. #endif