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> |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 5 | * Copyright (c) 2009-2012, 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> |
Anji jonnala | a7c1c5c | 2011-12-12 12:20:36 +0530 | [diff] [blame] | 24 | #include <linux/pm_qos_params.h> |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Supported USB modes |
| 28 | * |
| 29 | * USB_PERIPHERAL Only peripheral mode is supported. |
| 30 | * USB_HOST Only host mode is supported. |
| 31 | * USB_OTG OTG mode is supported. |
| 32 | * |
| 33 | */ |
| 34 | enum usb_mode_type { |
| 35 | USB_NONE = 0, |
| 36 | USB_PERIPHERAL, |
| 37 | USB_HOST, |
| 38 | USB_OTG, |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * OTG control |
| 43 | * |
| 44 | * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host |
| 45 | * only configuration. |
| 46 | * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY. |
| 47 | * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware. |
| 48 | * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs. |
| 49 | * |
| 50 | */ |
| 51 | enum otg_control_type { |
| 52 | OTG_NO_CONTROL = 0, |
| 53 | OTG_PHY_CONTROL, |
| 54 | OTG_PMIC_CONTROL, |
| 55 | OTG_USER_CONTROL, |
| 56 | }; |
| 57 | |
| 58 | /** |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 59 | * PHY used in |
| 60 | * |
| 61 | * INVALID_PHY Unsupported PHY |
| 62 | * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY |
| 63 | * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY |
| 64 | * |
| 65 | */ |
| 66 | enum msm_usb_phy_type { |
| 67 | INVALID_PHY = 0, |
| 68 | CI_45NM_INTEGRATED_PHY, |
| 69 | SNPS_28NM_INTEGRATED_PHY, |
| 70 | }; |
| 71 | |
| 72 | #define IDEV_CHG_MAX 1500 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | #define IDEV_CHG_MIN 500 |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 74 | #define IUNIT 100 |
| 75 | |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 76 | #define IDEV_ACA_CHG_MAX 1500 |
| 77 | #define IDEV_ACA_CHG_LIMIT 500 |
| 78 | |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 79 | /** |
| 80 | * Different states involved in USB charger detection. |
| 81 | * |
| 82 | * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection |
| 83 | * process is not yet started. |
| 84 | * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact. |
| 85 | * USB_CHG_STATE_DCD_DONE Data pin contact is detected. |
| 86 | * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects |
| 87 | * between SDP and DCP/CDP). |
| 88 | * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects |
| 89 | * between DCP and CDP). |
| 90 | * USB_CHG_STATE_DETECTED USB charger type is determined. |
| 91 | * |
| 92 | */ |
| 93 | enum usb_chg_state { |
| 94 | USB_CHG_STATE_UNDEFINED = 0, |
| 95 | USB_CHG_STATE_WAIT_FOR_DCD, |
| 96 | USB_CHG_STATE_DCD_DONE, |
| 97 | USB_CHG_STATE_PRIMARY_DONE, |
| 98 | USB_CHG_STATE_SECONDARY_DONE, |
| 99 | USB_CHG_STATE_DETECTED, |
| 100 | }; |
| 101 | |
| 102 | /** |
| 103 | * USB charger types |
| 104 | * |
| 105 | * USB_INVALID_CHARGER Invalid USB charger. |
| 106 | * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port |
| 107 | * on USB2.0 compliant host/hub. |
| 108 | * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). |
| 109 | * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and |
| 110 | * IDEV_CHG_MAX can be drawn irrespective of USB state. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 111 | * USB_ACA_A_CHARGER B-device is connected on accessory port with charger |
| 112 | * connected on charging port. This configuration allows |
| 113 | * charging in host mode. |
| 114 | * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on |
| 115 | * accessory port with charger connected on charging port. |
| 116 | * USB_ACA_C_CHARGER A-device (with VBUS) is connected on |
| 117 | * accessory port with charger connected on charging port. |
| 118 | * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one |
| 119 | * or more downstream ports. Capable of supplying |
| 120 | * IDEV_CHG_MAX irrespective of devices connected on |
| 121 | * accessory ports. |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 122 | */ |
| 123 | enum usb_chg_type { |
| 124 | USB_INVALID_CHARGER = 0, |
| 125 | USB_SDP_CHARGER, |
| 126 | USB_DCP_CHARGER, |
| 127 | USB_CDP_CHARGER, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 128 | USB_ACA_A_CHARGER, |
| 129 | USB_ACA_B_CHARGER, |
| 130 | USB_ACA_C_CHARGER, |
| 131 | USB_ACA_DOCK_CHARGER, |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | /** |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 135 | * SPS Pipes direction. |
| 136 | * |
| 137 | * USB_TO_PEER_PERIPHERAL USB (as Producer) to other |
| 138 | * peer peripheral. |
| 139 | * PEER_PERIPHERAL_TO_USB Other Peripheral to |
| 140 | * USB (as consumer). |
| 141 | */ |
| 142 | enum usb_bam_pipe_dir { |
| 143 | USB_TO_PEER_PERIPHERAL, |
| 144 | PEER_PERIPHERAL_TO_USB, |
| 145 | }; |
| 146 | |
| 147 | /** |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 148 | * struct msm_otg_platform_data - platform device data |
Pavankumar Kondeti | dfb2130 | 2011-03-04 22:45:02 +0530 | [diff] [blame] | 149 | * for msm_otg driver. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 150 | * @phy_init_seq: PHY configuration sequence. val, reg pairs |
| 151 | * terminated by -1. |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 152 | * @vbus_power: VBUS power on/off routine.It should return result |
| 153 | * as success(zero value) or failure(non-zero value). |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 154 | * @power_budget: VBUS power budget in mA (0 will be treated as 500mA). |
| 155 | * @mode: Supported mode (OTG/peripheral/host). |
| 156 | * @otg_control: OTG switch controlled by user/Id pin |
| 157 | * @default_mode: Default operational mode. Applicable only if |
| 158 | * OTG switch is controller by user. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 159 | * @pmic_id_irq: IRQ number assigned for PMIC USB ID line. |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame] | 160 | * @mhl_enable: indicates MHL connector or not. |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 161 | * @disable_reset_on_disconnect: perform USB PHY and LINK reset |
| 162 | * on USB cable disconnection. |
Anji jonnala | a7c1c5c | 2011-12-12 12:20:36 +0530 | [diff] [blame] | 163 | * @swfi_latency: miminum latency to allow swfi. |
Pavankumar Kondeti | 2d09e5f | 2012-01-16 08:56:57 +0530 | [diff] [blame] | 164 | * @enable_dcd: Enable Data Contact Detection circuit. if not set |
| 165 | * wait for 600msec before proceeding to primary |
| 166 | * detection. |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 167 | * @bus_scale_table: parameters for bus bandwidth requirements |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 168 | */ |
| 169 | struct msm_otg_platform_data { |
| 170 | int *phy_init_seq; |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 171 | int (*vbus_power)(bool on); |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 172 | unsigned power_budget; |
| 173 | enum usb_mode_type mode; |
| 174 | enum otg_control_type otg_control; |
| 175 | enum usb_mode_type default_mode; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 176 | enum msm_usb_phy_type phy_type; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 177 | void (*setup_gpio)(enum usb_otg_state state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 178 | int pmic_id_irq; |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame] | 179 | bool mhl_enable; |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 180 | bool disable_reset_on_disconnect; |
Anji jonnala | a7c1c5c | 2011-12-12 12:20:36 +0530 | [diff] [blame] | 181 | u32 swfi_latency; |
Pavankumar Kondeti | 2d09e5f | 2012-01-16 08:56:57 +0530 | [diff] [blame] | 182 | bool enable_dcd; |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 183 | struct msm_bus_scale_pdata *bus_scale_table; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 184 | }; |
| 185 | |
| 186 | /** |
| 187 | * struct msm_otg: OTG driver data. Shared by HCD and DCD. |
| 188 | * @otg: USB OTG Transceiver structure. |
| 189 | * @pdata: otg device platform data. |
| 190 | * @irq: IRQ number assigned for HSUSB controller. |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 191 | * @clk: clock struct of alt_core_clk. |
| 192 | * @pclk: clock struct of iface_clk. |
| 193 | * @phy_reset_clk: clock struct of phy_clk. |
| 194 | * @core_clk: clock struct of core_bus_clk. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 195 | * @regs: ioremapped register base address. |
| 196 | * @inputs: OTG state machine inputs(Id, SessValid etc). |
| 197 | * @sm_work: OTG state machine work. |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 198 | * @in_lpm: indicates low power mode (LPM) state. |
| 199 | * @async_int: Async interrupt arrived. |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 200 | * @cur_power: The amount of mA available from downstream port. |
| 201 | * @chg_work: Charger detection work. |
| 202 | * @chg_state: The state of charger detection process. |
| 203 | * @chg_type: The type of charger attached. |
| 204 | * @dcd_retires: The retry count used to track Data contact |
| 205 | * detection process. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 206 | * @wlock: Wake lock struct to prevent system suspend when |
| 207 | * USB is active. |
| 208 | * @usbdev_nb: The notifier block used to know about the B-device |
| 209 | * connected. Useful only when ACA_A charger is |
| 210 | * connected. |
| 211 | * @mA_port: The amount of current drawn by the attached B-device. |
Anji jonnala | a7c1c5c | 2011-12-12 12:20:36 +0530 | [diff] [blame] | 212 | * @pm_qos_req_dma: miminum DMA latency to vote against idle power |
| 213 | collapse when cable is connected. |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 214 | * @id_timer: The timer used for polling ID line to detect ACA states. |
Anji jonnala | 7da3f26 | 2011-12-02 17:22:14 -0800 | [diff] [blame] | 215 | * @xo_handle: TCXO buffer handle |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 216 | * @bus_perf_client: Bus performance client handle to request BUS bandwidth |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 217 | */ |
| 218 | struct msm_otg { |
| 219 | struct otg_transceiver otg; |
| 220 | struct msm_otg_platform_data *pdata; |
| 221 | int irq; |
| 222 | struct clk *clk; |
| 223 | struct clk *pclk; |
| 224 | struct clk *phy_reset_clk; |
| 225 | struct clk *core_clk; |
| 226 | void __iomem *regs; |
| 227 | #define ID 0 |
| 228 | #define B_SESS_VLD 1 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 229 | #define ID_A 2 |
| 230 | #define ID_B 3 |
| 231 | #define ID_C 4 |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 232 | unsigned long inputs; |
| 233 | struct work_struct sm_work; |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 234 | atomic_t in_lpm; |
| 235 | int async_int; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 236 | unsigned cur_power; |
| 237 | struct delayed_work chg_work; |
| 238 | enum usb_chg_state chg_state; |
| 239 | enum usb_chg_type chg_type; |
| 240 | u8 dcd_retries; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 241 | struct wake_lock wlock; |
| 242 | struct notifier_block usbdev_nb; |
| 243 | unsigned mA_port; |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 244 | struct timer_list id_timer; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 245 | unsigned long caps; |
Stephen Boyd | 7dd2266 | 2012-01-26 16:09:31 -0800 | [diff] [blame] | 246 | struct clk *xo_handle; |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 247 | uint32_t bus_perf_client; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 248 | /* |
| 249 | * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v |
| 250 | * analog regulators while going to low power mode. |
| 251 | * Currently only 8960(28nm PHY) has the support to allowing PHY |
| 252 | * power collapse since it doesn't have leakage currents while |
| 253 | * turning off the power rails. |
| 254 | */ |
| 255 | #define ALLOW_PHY_POWER_COLLAPSE BIT(0) |
| 256 | /* |
| 257 | * Allow PHY RETENTION mode before turning off the digital |
| 258 | * voltage regulator(VDDCX). |
| 259 | */ |
| 260 | #define ALLOW_PHY_RETENTION BIT(1) |
| 261 | /* |
| 262 | * Disable the OTG comparators to save more power |
| 263 | * if depends on PMIC for VBUS and ID interrupts. |
| 264 | */ |
| 265 | #define ALLOW_PHY_COMP_DISABLE BIT(2) |
| 266 | unsigned long lpm_flags; |
| 267 | #define PHY_PWR_COLLAPSED BIT(0) |
| 268 | #define PHY_RETENTIONED BIT(1) |
| 269 | #define PHY_OTG_COMP_DISABLED BIT(2) |
Anji jonnala | a7c1c5c | 2011-12-12 12:20:36 +0530 | [diff] [blame] | 270 | struct pm_qos_request_list pm_qos_req_dma; |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 271 | int reset_counter; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 272 | }; |
| 273 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 274 | struct msm_hsic_host_platform_data { |
| 275 | unsigned strobe; |
| 276 | unsigned data; |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 277 | unsigned hub_reset; |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 278 | }; |
| 279 | |
Manu Gautam | 91223e0 | 2011-11-08 15:27:22 +0530 | [diff] [blame^] | 280 | struct msm_usb_host_platform_data { |
| 281 | unsigned int power_budget; |
| 282 | }; |
| 283 | |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 284 | struct usb_bam_pipe_connect { |
| 285 | u32 src_phy_addr; |
| 286 | int src_pipe_index; |
| 287 | u32 dst_phy_addr; |
| 288 | int dst_pipe_index; |
| 289 | u32 data_fifo_base_offset; |
| 290 | u32 data_fifo_size; |
| 291 | u32 desc_fifo_base_offset; |
| 292 | u32 desc_fifo_size; |
| 293 | }; |
| 294 | |
| 295 | struct msm_usb_bam_platform_data { |
| 296 | struct usb_bam_pipe_connect *connections; |
Ofir Cohen | 010009b | 2012-01-26 16:49:17 +0200 | [diff] [blame] | 297 | int usb_active_bam; |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 298 | int usb_bam_num_pipes; |
| 299 | }; |
Ofir Cohen | 010009b | 2012-01-26 16:49:17 +0200 | [diff] [blame] | 300 | |
| 301 | enum usb_bam { |
| 302 | HSUSB_BAM = 0, |
| 303 | HSIC_BAM, |
| 304 | }; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 305 | #endif |