msm_hsusb.h 5.2 KB

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