Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 1 | /* linux/include/asm-arm/arch-msm/hsusb.h |
| 2 | * |
| 3 | * Copyright (C) 2008 Google, Inc. |
| 4 | * Author: Brian Swetland <swetland@google.com> |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 5 | * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 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 | |
| 18 | #ifndef __ASM_ARCH_MSM_HSUSB_H |
| 19 | #define __ASM_ARCH_MSM_HSUSB_H |
| 20 | |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/usb/otg.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | #include <linux/wakelock.h> |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Supported USB modes |
| 27 | * |
| 28 | * USB_PERIPHERAL Only peripheral mode is supported. |
| 29 | * USB_HOST Only host mode is supported. |
| 30 | * USB_OTG OTG mode is supported. |
| 31 | * |
| 32 | */ |
| 33 | enum usb_mode_type { |
| 34 | USB_NONE = 0, |
| 35 | USB_PERIPHERAL, |
| 36 | USB_HOST, |
| 37 | USB_OTG, |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * OTG control |
| 42 | * |
| 43 | * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host |
| 44 | * only configuration. |
| 45 | * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY. |
| 46 | * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware. |
| 47 | * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs. |
| 48 | * |
| 49 | */ |
| 50 | enum otg_control_type { |
| 51 | OTG_NO_CONTROL = 0, |
| 52 | OTG_PHY_CONTROL, |
| 53 | OTG_PMIC_CONTROL, |
| 54 | OTG_USER_CONTROL, |
| 55 | }; |
| 56 | |
| 57 | /** |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 58 | * PHY used in |
| 59 | * |
| 60 | * INVALID_PHY Unsupported PHY |
| 61 | * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY |
| 62 | * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY |
| 63 | * |
| 64 | */ |
| 65 | enum msm_usb_phy_type { |
| 66 | INVALID_PHY = 0, |
| 67 | CI_45NM_INTEGRATED_PHY, |
| 68 | SNPS_28NM_INTEGRATED_PHY, |
| 69 | }; |
| 70 | |
| 71 | #define IDEV_CHG_MAX 1500 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 72 | #define IDEV_CHG_MIN 500 |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 73 | #define IUNIT 100 |
| 74 | |
| 75 | /** |
| 76 | * Different states involved in USB charger detection. |
| 77 | * |
| 78 | * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection |
| 79 | * process is not yet started. |
| 80 | * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact. |
| 81 | * USB_CHG_STATE_DCD_DONE Data pin contact is detected. |
| 82 | * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects |
| 83 | * between SDP and DCP/CDP). |
| 84 | * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects |
| 85 | * between DCP and CDP). |
| 86 | * USB_CHG_STATE_DETECTED USB charger type is determined. |
| 87 | * |
| 88 | */ |
| 89 | enum usb_chg_state { |
| 90 | USB_CHG_STATE_UNDEFINED = 0, |
| 91 | USB_CHG_STATE_WAIT_FOR_DCD, |
| 92 | USB_CHG_STATE_DCD_DONE, |
| 93 | USB_CHG_STATE_PRIMARY_DONE, |
| 94 | USB_CHG_STATE_SECONDARY_DONE, |
| 95 | USB_CHG_STATE_DETECTED, |
| 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * USB charger types |
| 100 | * |
| 101 | * USB_INVALID_CHARGER Invalid USB charger. |
| 102 | * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port |
| 103 | * on USB2.0 compliant host/hub. |
| 104 | * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). |
| 105 | * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and |
| 106 | * IDEV_CHG_MAX can be drawn irrespective of USB state. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | * USB_ACA_A_CHARGER B-device is connected on accessory port with charger |
| 108 | * connected on charging port. This configuration allows |
| 109 | * charging in host mode. |
| 110 | * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on |
| 111 | * accessory port with charger connected on charging port. |
| 112 | * USB_ACA_C_CHARGER A-device (with VBUS) is connected on |
| 113 | * accessory port with charger connected on charging port. |
| 114 | * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one |
| 115 | * or more downstream ports. Capable of supplying |
| 116 | * IDEV_CHG_MAX irrespective of devices connected on |
| 117 | * accessory ports. |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 118 | */ |
| 119 | enum usb_chg_type { |
| 120 | USB_INVALID_CHARGER = 0, |
| 121 | USB_SDP_CHARGER, |
| 122 | USB_DCP_CHARGER, |
| 123 | USB_CDP_CHARGER, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 124 | USB_ACA_A_CHARGER, |
| 125 | USB_ACA_B_CHARGER, |
| 126 | USB_ACA_C_CHARGER, |
| 127 | USB_ACA_DOCK_CHARGER, |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | /** |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 131 | * struct msm_otg_platform_data - platform device data |
Pavankumar Kondeti | dfb2130 | 2011-03-04 22:45:02 +0530 | [diff] [blame] | 132 | * for msm_otg driver. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 133 | * @phy_init_seq: PHY configuration sequence. val, reg pairs |
| 134 | * terminated by -1. |
| 135 | * @vbus_power: VBUS power on/off routine. |
| 136 | * @power_budget: VBUS power budget in mA (0 will be treated as 500mA). |
| 137 | * @mode: Supported mode (OTG/peripheral/host). |
| 138 | * @otg_control: OTG switch controlled by user/Id pin |
| 139 | * @default_mode: Default operational mode. Applicable only if |
| 140 | * OTG switch is controller by user. |
Anji jonnala | 0f73cac | 2011-05-04 10:19:46 +0530 | [diff] [blame] | 141 | * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k |
| 142 | * dfab_usb_hs_clk in case of 8660 and 8960. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 143 | * @pmic_id_irq: IRQ number assigned for PMIC USB ID line. |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame^] | 144 | * @mhl_enable: indicates MHL connector or not. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 145 | */ |
| 146 | struct msm_otg_platform_data { |
| 147 | int *phy_init_seq; |
| 148 | void (*vbus_power)(bool on); |
| 149 | unsigned power_budget; |
| 150 | enum usb_mode_type mode; |
| 151 | enum otg_control_type otg_control; |
| 152 | enum usb_mode_type default_mode; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 153 | enum msm_usb_phy_type phy_type; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 154 | void (*setup_gpio)(enum usb_otg_state state); |
Anji jonnala | 0f73cac | 2011-05-04 10:19:46 +0530 | [diff] [blame] | 155 | char *pclk_src_name; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 156 | int pmic_id_irq; |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame^] | 157 | bool mhl_enable; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | /** |
| 161 | * struct msm_otg: OTG driver data. Shared by HCD and DCD. |
| 162 | * @otg: USB OTG Transceiver structure. |
| 163 | * @pdata: otg device platform data. |
| 164 | * @irq: IRQ number assigned for HSUSB controller. |
| 165 | * @clk: clock struct of usb_hs_clk. |
| 166 | * @pclk: clock struct of usb_hs_pclk. |
Anji jonnala | 0f73cac | 2011-05-04 10:19:46 +0530 | [diff] [blame] | 167 | * @pclk_src: pclk source for voting. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 168 | * @phy_reset_clk: clock struct of usb_phy_clk. |
| 169 | * @core_clk: clock struct of usb_hs_core_clk. |
Amit Blay | 02eff13 | 2011-09-21 16:46:24 +0300 | [diff] [blame] | 170 | * @system_clk: clock struct of usb_system_clk. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 171 | * @regs: ioremapped register base address. |
| 172 | * @inputs: OTG state machine inputs(Id, SessValid etc). |
| 173 | * @sm_work: OTG state machine work. |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 174 | * @in_lpm: indicates low power mode (LPM) state. |
| 175 | * @async_int: Async interrupt arrived. |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 176 | * @cur_power: The amount of mA available from downstream port. |
| 177 | * @chg_work: Charger detection work. |
| 178 | * @chg_state: The state of charger detection process. |
| 179 | * @chg_type: The type of charger attached. |
| 180 | * @dcd_retires: The retry count used to track Data contact |
| 181 | * detection process. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 182 | * @wlock: Wake lock struct to prevent system suspend when |
| 183 | * USB is active. |
| 184 | * @usbdev_nb: The notifier block used to know about the B-device |
| 185 | * connected. Useful only when ACA_A charger is |
| 186 | * connected. |
| 187 | * @mA_port: The amount of current drawn by the attached B-device. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 188 | */ |
| 189 | struct msm_otg { |
| 190 | struct otg_transceiver otg; |
| 191 | struct msm_otg_platform_data *pdata; |
| 192 | int irq; |
| 193 | struct clk *clk; |
| 194 | struct clk *pclk; |
Anji jonnala | 0f73cac | 2011-05-04 10:19:46 +0530 | [diff] [blame] | 195 | struct clk *pclk_src; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 196 | struct clk *phy_reset_clk; |
| 197 | struct clk *core_clk; |
Amit Blay | 02eff13 | 2011-09-21 16:46:24 +0300 | [diff] [blame] | 198 | struct clk *system_clk; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 199 | void __iomem *regs; |
| 200 | #define ID 0 |
| 201 | #define B_SESS_VLD 1 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 202 | #define ID_A 2 |
| 203 | #define ID_B 3 |
| 204 | #define ID_C 4 |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 205 | unsigned long inputs; |
| 206 | struct work_struct sm_work; |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 207 | atomic_t in_lpm; |
| 208 | int async_int; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 209 | unsigned cur_power; |
| 210 | struct delayed_work chg_work; |
| 211 | enum usb_chg_state chg_state; |
| 212 | enum usb_chg_type chg_type; |
| 213 | u8 dcd_retries; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 214 | struct wake_lock wlock; |
| 215 | struct notifier_block usbdev_nb; |
| 216 | unsigned mA_port; |
| 217 | unsigned long caps; |
| 218 | /* |
| 219 | * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v |
| 220 | * analog regulators while going to low power mode. |
| 221 | * Currently only 8960(28nm PHY) has the support to allowing PHY |
| 222 | * power collapse since it doesn't have leakage currents while |
| 223 | * turning off the power rails. |
| 224 | */ |
| 225 | #define ALLOW_PHY_POWER_COLLAPSE BIT(0) |
| 226 | /* |
| 227 | * Allow PHY RETENTION mode before turning off the digital |
| 228 | * voltage regulator(VDDCX). |
| 229 | */ |
| 230 | #define ALLOW_PHY_RETENTION BIT(1) |
| 231 | /* |
| 232 | * Disable the OTG comparators to save more power |
| 233 | * if depends on PMIC for VBUS and ID interrupts. |
| 234 | */ |
| 235 | #define ALLOW_PHY_COMP_DISABLE BIT(2) |
| 236 | unsigned long lpm_flags; |
| 237 | #define PHY_PWR_COLLAPSED BIT(0) |
| 238 | #define PHY_RETENTIONED BIT(1) |
| 239 | #define PHY_OTG_COMP_DISABLED BIT(2) |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 240 | }; |
| 241 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 242 | struct msm_hsic_host_platform_data { |
| 243 | unsigned strobe; |
| 244 | unsigned data; |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 245 | unsigned hub_reset; |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 246 | }; |
| 247 | |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 248 | #endif |