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 | 355270a | 2012-12-21 16:52:50 +0530 | [diff] [blame] | 5 | * Copyright (c) 2009-2013, The Linux Foundation. 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> |
Ido Shayevitz | 9fb8345 | 2012-04-01 17:45:58 +0300 | [diff] [blame] | 22 | #include <linux/usb/ch9.h> |
| 23 | #include <linux/usb/gadget.h> |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 24 | #include <linux/usb/otg.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | #include <linux/wakelock.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 26 | #include <linux/pm_qos.h> |
Ido Shayevitz | 5a6178b | 2012-06-10 16:31:13 +0300 | [diff] [blame] | 27 | #include <linux/hrtimer.h> |
David Keitel | 272ce52 | 2012-08-17 16:25:24 -0700 | [diff] [blame] | 28 | #include <linux/power_supply.h> |
Ido Shayevitz | d1cb16c | 2012-03-28 18:57:47 +0200 | [diff] [blame] | 29 | /* |
| 30 | * The following are bit fields describing the usb_request.udc_priv word. |
| 31 | * These bit fields are set by function drivers that wish to queue |
| 32 | * usb_requests with sps/bam parameters. |
| 33 | */ |
| 34 | #define MSM_PIPE_ID_MASK (0x1F) |
| 35 | #define MSM_TX_PIPE_ID_OFS (16) |
| 36 | #define MSM_SPS_MODE BIT(5) |
| 37 | #define MSM_IS_FINITE_TRANSFER BIT(6) |
| 38 | #define MSM_PRODUCER BIT(7) |
| 39 | #define MSM_DISABLE_WB BIT(8) |
| 40 | #define MSM_ETD_IOC BIT(9) |
| 41 | #define MSM_INTERNAL_MEM BIT(10) |
| 42 | #define MSM_VENDOR_ID BIT(16) |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Supported USB modes |
| 46 | * |
| 47 | * USB_PERIPHERAL Only peripheral mode is supported. |
| 48 | * USB_HOST Only host mode is supported. |
| 49 | * USB_OTG OTG mode is supported. |
| 50 | * |
| 51 | */ |
| 52 | enum usb_mode_type { |
| 53 | USB_NONE = 0, |
| 54 | USB_PERIPHERAL, |
| 55 | USB_HOST, |
| 56 | USB_OTG, |
| 57 | }; |
| 58 | |
| 59 | /** |
| 60 | * OTG control |
| 61 | * |
| 62 | * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host |
| 63 | * only configuration. |
| 64 | * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY. |
| 65 | * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware. |
| 66 | * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs. |
| 67 | * |
| 68 | */ |
| 69 | enum otg_control_type { |
| 70 | OTG_NO_CONTROL = 0, |
| 71 | OTG_PHY_CONTROL, |
| 72 | OTG_PMIC_CONTROL, |
| 73 | OTG_USER_CONTROL, |
| 74 | }; |
| 75 | |
| 76 | /** |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 77 | * PHY used in |
| 78 | * |
| 79 | * INVALID_PHY Unsupported PHY |
| 80 | * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY |
| 81 | * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY |
| 82 | * |
| 83 | */ |
| 84 | enum msm_usb_phy_type { |
| 85 | INVALID_PHY = 0, |
| 86 | CI_45NM_INTEGRATED_PHY, |
| 87 | SNPS_28NM_INTEGRATED_PHY, |
| 88 | }; |
| 89 | |
| 90 | #define IDEV_CHG_MAX 1500 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | #define IDEV_CHG_MIN 500 |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 92 | #define IUNIT 100 |
| 93 | |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 94 | #define IDEV_ACA_CHG_MAX 1500 |
| 95 | #define IDEV_ACA_CHG_LIMIT 500 |
| 96 | |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 97 | /** |
| 98 | * Different states involved in USB charger detection. |
| 99 | * |
| 100 | * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection |
| 101 | * process is not yet started. |
| 102 | * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact. |
| 103 | * USB_CHG_STATE_DCD_DONE Data pin contact is detected. |
| 104 | * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects |
| 105 | * between SDP and DCP/CDP). |
| 106 | * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects |
| 107 | * between DCP and CDP). |
| 108 | * USB_CHG_STATE_DETECTED USB charger type is determined. |
| 109 | * |
| 110 | */ |
| 111 | enum usb_chg_state { |
| 112 | USB_CHG_STATE_UNDEFINED = 0, |
| 113 | USB_CHG_STATE_WAIT_FOR_DCD, |
| 114 | USB_CHG_STATE_DCD_DONE, |
| 115 | USB_CHG_STATE_PRIMARY_DONE, |
| 116 | USB_CHG_STATE_SECONDARY_DONE, |
| 117 | USB_CHG_STATE_DETECTED, |
| 118 | }; |
| 119 | |
| 120 | /** |
| 121 | * USB charger types |
| 122 | * |
| 123 | * USB_INVALID_CHARGER Invalid USB charger. |
| 124 | * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port |
| 125 | * on USB2.0 compliant host/hub. |
| 126 | * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). |
| 127 | * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and |
| 128 | * IDEV_CHG_MAX can be drawn irrespective of USB state. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 129 | * USB_ACA_A_CHARGER B-device is connected on accessory port with charger |
| 130 | * connected on charging port. This configuration allows |
| 131 | * charging in host mode. |
| 132 | * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on |
| 133 | * accessory port with charger connected on charging port. |
| 134 | * USB_ACA_C_CHARGER A-device (with VBUS) is connected on |
| 135 | * accessory port with charger connected on charging port. |
| 136 | * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one |
| 137 | * or more downstream ports. Capable of supplying |
| 138 | * IDEV_CHG_MAX irrespective of devices connected on |
| 139 | * accessory ports. |
Pavankumar Kondeti | 9ec21d3 | 2012-05-07 15:50:23 +0530 | [diff] [blame] | 140 | * USB_PROPRIETARY_CHARGER A proprietary charger pull DP and DM to specific |
| 141 | * voltages between 2.0-3.3v for identification. |
| 142 | * |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 143 | */ |
| 144 | enum usb_chg_type { |
| 145 | USB_INVALID_CHARGER = 0, |
| 146 | USB_SDP_CHARGER, |
| 147 | USB_DCP_CHARGER, |
| 148 | USB_CDP_CHARGER, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 149 | USB_ACA_A_CHARGER, |
| 150 | USB_ACA_B_CHARGER, |
| 151 | USB_ACA_C_CHARGER, |
| 152 | USB_ACA_DOCK_CHARGER, |
Pavankumar Kondeti | 9ec21d3 | 2012-05-07 15:50:23 +0530 | [diff] [blame] | 153 | USB_PROPRIETARY_CHARGER, |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | /** |
Mayank Rana | 248698c | 2012-04-19 00:03:16 +0530 | [diff] [blame] | 157 | * Used different VDDCX voltage voting mechnism |
| 158 | * VDDCX_CORNER Vote for VDDCX Corner voltage |
| 159 | * VDDCX Vote for VDDCX Absolute voltage |
| 160 | */ |
| 161 | enum usb_vdd_type { |
| 162 | VDDCX_CORNER = 0, |
| 163 | VDDCX, |
| 164 | VDD_TYPE_MAX, |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | /** |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 168 | * Used different VDDCX voltage values |
| 169 | */ |
| 170 | enum usb_vdd_value { |
| 171 | VDD_NONE = 0, |
| 172 | VDD_MIN, |
| 173 | VDD_MAX, |
| 174 | VDD_VAL_MAX, |
| 175 | }; |
| 176 | |
| 177 | /** |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 178 | * struct msm_otg_platform_data - platform device data |
Pavankumar Kondeti | dfb2130 | 2011-03-04 22:45:02 +0530 | [diff] [blame] | 179 | * for msm_otg driver. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 180 | * @phy_init_seq: PHY configuration sequence. val, reg pairs |
| 181 | * terminated by -1. |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 182 | * @vbus_power: VBUS power on/off routine.It should return result |
| 183 | * as success(zero value) or failure(non-zero value). |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 184 | * @power_budget: VBUS power budget in mA (0 will be treated as 500mA). |
| 185 | * @mode: Supported mode (OTG/peripheral/host). |
| 186 | * @otg_control: OTG switch controlled by user/Id pin |
| 187 | * @default_mode: Default operational mode. Applicable only if |
| 188 | * OTG switch is controller by user. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 189 | * @pmic_id_irq: IRQ number assigned for PMIC USB ID line. |
Jack Pham | 87f202f | 2012-08-06 00:24:22 -0700 | [diff] [blame] | 190 | * @mpm_otgsessvld_int: MPM wakeup pin assigned for OTG SESSVLD |
| 191 | * interrupt. Used when .otg_control == OTG_PHY_CONTROL. |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame] | 192 | * @mhl_enable: indicates MHL connector or not. |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 193 | * @disable_reset_on_disconnect: perform USB PHY and LINK reset |
| 194 | * on USB cable disconnection. |
Manu Gautam | 0ddbd92 | 2012-09-21 17:17:38 +0530 | [diff] [blame] | 195 | * @pnoc_errata_fix: workaround needed for PNOC hardware bug that |
| 196 | * affects USB performance. |
Amit Blay | 6fa647a | 2012-05-24 14:12:08 +0300 | [diff] [blame] | 197 | * @enable_lpm_on_suspend: Enable the USB core to go into Low |
| 198 | * Power Mode, when USB bus is suspended but cable |
| 199 | * is connected. |
Amit Blay | 9b6e58b | 2012-06-18 13:12:49 +0300 | [diff] [blame] | 200 | * @core_clk_always_on_workaround: Don't disable core_clk when |
| 201 | * USB enters LPM. |
Amit Blay | d6f3828 | 2012-10-29 13:13:46 +0200 | [diff] [blame] | 202 | * @delay_lpm_on_disconnect: Use a delay before entering LPM |
| 203 | * upon USB cable disconnection. |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 204 | * @bus_scale_table: parameters for bus bandwidth requirements |
Pavankumar Kondeti | 2aec9f3 | 2012-06-13 09:06:03 +0530 | [diff] [blame] | 205 | * @mhl_dev_name: MHL device name used to register with MHL driver. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 206 | */ |
| 207 | struct msm_otg_platform_data { |
| 208 | int *phy_init_seq; |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 209 | int (*vbus_power)(bool on); |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 210 | unsigned power_budget; |
| 211 | enum usb_mode_type mode; |
| 212 | enum otg_control_type otg_control; |
| 213 | enum usb_mode_type default_mode; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 214 | enum msm_usb_phy_type phy_type; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 215 | void (*setup_gpio)(enum usb_otg_state state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 216 | int pmic_id_irq; |
Jack Pham | 87f202f | 2012-08-06 00:24:22 -0700 | [diff] [blame] | 217 | unsigned int mpm_otgsessvld_int; |
Vijayavardhan Vennapusa | fc464f0 | 2011-11-04 21:54:00 +0530 | [diff] [blame] | 218 | bool mhl_enable; |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 219 | bool disable_reset_on_disconnect; |
Manu Gautam | 0ddbd92 | 2012-09-21 17:17:38 +0530 | [diff] [blame] | 220 | bool pnoc_errata_fix; |
Amit Blay | 6fa647a | 2012-05-24 14:12:08 +0300 | [diff] [blame] | 221 | bool enable_lpm_on_dev_suspend; |
Amit Blay | 9b6e58b | 2012-06-18 13:12:49 +0300 | [diff] [blame] | 222 | bool core_clk_always_on_workaround; |
Amit Blay | d6f3828 | 2012-10-29 13:13:46 +0200 | [diff] [blame] | 223 | bool delay_lpm_on_disconnect; |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 224 | struct msm_bus_scale_pdata *bus_scale_table; |
Pavankumar Kondeti | 2aec9f3 | 2012-06-13 09:06:03 +0530 | [diff] [blame] | 225 | const char *mhl_dev_name; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 226 | }; |
| 227 | |
Vijayavardhan Vennapusa | a315203 | 2012-03-05 16:29:30 +0530 | [diff] [blame] | 228 | /* Timeout (in msec) values (min - max) associated with OTG timers */ |
| 229 | |
| 230 | #define TA_WAIT_VRISE 100 /* ( - 100) */ |
| 231 | #define TA_WAIT_VFALL 500 /* ( - 1000) */ |
| 232 | |
| 233 | /* |
| 234 | * This option is set for embedded hosts or OTG devices in which leakage |
| 235 | * currents are very minimal. |
| 236 | */ |
| 237 | #ifdef CONFIG_USB_OTG |
| 238 | #define TA_WAIT_BCON 30000 /* (1100 - 30000) */ |
| 239 | #else |
| 240 | #define TA_WAIT_BCON -1 |
| 241 | #endif |
| 242 | |
| 243 | #define TA_AIDL_BDIS 500 /* (200 - ) */ |
| 244 | #define TA_BIDL_ADIS 155 /* (155 - 200) */ |
| 245 | #define TB_SRP_FAIL 6000 /* (5000 - 6000) */ |
| 246 | #define TB_ASE0_BRST 200 /* (155 - ) */ |
| 247 | |
| 248 | /* TB_SSEND_SRP and TB_SE0_SRP are combined */ |
| 249 | #define TB_SRP_INIT 2000 /* (1500 - ) */ |
| 250 | |
| 251 | #define TA_TST_MAINT 10100 /* (9900 - 10100) */ |
| 252 | #define TB_TST_SRP 3000 /* ( - 5000) */ |
| 253 | #define TB_TST_CONFIG 300 |
| 254 | |
| 255 | /* Timeout variables */ |
| 256 | |
| 257 | #define A_WAIT_VRISE 0 |
| 258 | #define A_WAIT_VFALL 1 |
| 259 | #define A_WAIT_BCON 2 |
| 260 | #define A_AIDL_BDIS 3 |
| 261 | #define A_BIDL_ADIS 4 |
| 262 | #define B_SRP_FAIL 5 |
| 263 | #define B_ASE0_BRST 6 |
| 264 | #define A_TST_MAINT 7 |
| 265 | #define B_TST_SRP 8 |
| 266 | #define B_TST_CONFIG 9 |
| 267 | |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 268 | /** |
| 269 | * struct msm_otg: OTG driver data. Shared by HCD and DCD. |
| 270 | * @otg: USB OTG Transceiver structure. |
| 271 | * @pdata: otg device platform data. |
| 272 | * @irq: IRQ number assigned for HSUSB controller. |
Manu Gautam | f8c4564 | 2012-08-10 10:20:56 -0700 | [diff] [blame] | 273 | * @async_irq: IRQ number used by some controllers during low power state |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 274 | * @clk: clock struct of alt_core_clk. |
| 275 | * @pclk: clock struct of iface_clk. |
| 276 | * @phy_reset_clk: clock struct of phy_clk. |
| 277 | * @core_clk: clock struct of core_bus_clk. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 278 | * @regs: ioremapped register base address. |
| 279 | * @inputs: OTG state machine inputs(Id, SessValid etc). |
| 280 | * @sm_work: OTG state machine work. |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 281 | * @in_lpm: indicates low power mode (LPM) state. |
Manu Gautam | f8c4564 | 2012-08-10 10:20:56 -0700 | [diff] [blame] | 282 | * @async_int: IRQ line on which ASYNC interrupt arrived in LPM. |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 283 | * @cur_power: The amount of mA available from downstream port. |
| 284 | * @chg_work: Charger detection work. |
| 285 | * @chg_state: The state of charger detection process. |
| 286 | * @chg_type: The type of charger attached. |
| 287 | * @dcd_retires: The retry count used to track Data contact |
| 288 | * detection process. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 289 | * @wlock: Wake lock struct to prevent system suspend when |
| 290 | * USB is active. |
| 291 | * @usbdev_nb: The notifier block used to know about the B-device |
| 292 | * connected. Useful only when ACA_A charger is |
| 293 | * connected. |
| 294 | * @mA_port: The amount of current drawn by the attached B-device. |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 295 | * @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] | 296 | * @xo_handle: TCXO buffer handle |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 297 | * @bus_perf_client: Bus performance client handle to request BUS bandwidth |
Pavankumar Kondeti | 2aec9f3 | 2012-06-13 09:06:03 +0530 | [diff] [blame] | 298 | * @mhl_enabled: MHL driver registration successful and MHL enabled. |
Pavankumar Kondeti | 458d879 | 2012-09-28 14:45:18 +0530 | [diff] [blame] | 299 | * @chg_check_timer: The timer used to implement the workaround to detect |
| 300 | * very slow plug in of wall charger. |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 301 | */ |
| 302 | struct msm_otg { |
Heikki Krogerus | 1d4c929 | 2012-02-13 13:24:09 +0200 | [diff] [blame] | 303 | struct usb_phy phy; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 304 | struct msm_otg_platform_data *pdata; |
| 305 | int irq; |
Manu Gautam | f8c4564 | 2012-08-10 10:20:56 -0700 | [diff] [blame] | 306 | int async_irq; |
Vijayavardhan Vennapusa | 0cab617 | 2013-02-20 19:51:15 +0530 | [diff] [blame] | 307 | struct clk *xo_clk; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 308 | struct clk *clk; |
| 309 | struct clk *pclk; |
| 310 | struct clk *phy_reset_clk; |
| 311 | struct clk *core_clk; |
| 312 | void __iomem *regs; |
| 313 | #define ID 0 |
| 314 | #define B_SESS_VLD 1 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 315 | #define ID_A 2 |
| 316 | #define ID_B 3 |
| 317 | #define ID_C 4 |
Vijayavardhan Vennapusa | a315203 | 2012-03-05 16:29:30 +0530 | [diff] [blame] | 318 | #define A_BUS_DROP 5 |
| 319 | #define A_BUS_REQ 6 |
| 320 | #define A_SRP_DET 7 |
| 321 | #define A_VBUS_VLD 8 |
| 322 | #define B_CONN 9 |
| 323 | #define ADP_CHANGE 10 |
| 324 | #define POWER_UP 11 |
| 325 | #define A_CLR_ERR 12 |
| 326 | #define A_BUS_RESUME 13 |
| 327 | #define A_BUS_SUSPEND 14 |
| 328 | #define A_CONN 15 |
| 329 | #define B_BUS_REQ 16 |
Pavankumar Kondeti | 2aec9f3 | 2012-06-13 09:06:03 +0530 | [diff] [blame] | 330 | #define MHL 17 |
Pavankumar Kondeti | 458d879 | 2012-09-28 14:45:18 +0530 | [diff] [blame] | 331 | #define B_FALSE_SDP 18 |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 332 | unsigned long inputs; |
| 333 | struct work_struct sm_work; |
Jack Pham | 5ca279b | 2012-05-14 18:42:54 -0700 | [diff] [blame] | 334 | bool sm_work_pending; |
| 335 | atomic_t pm_suspended; |
Pavankumar Kondeti | 87c0104 | 2010-12-07 17:53:58 +0530 | [diff] [blame] | 336 | atomic_t in_lpm; |
| 337 | int async_int; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 338 | unsigned cur_power; |
| 339 | struct delayed_work chg_work; |
Vijayavardhan Vennapusa | 68d55cf | 2012-06-27 20:06:12 +0530 | [diff] [blame] | 340 | struct delayed_work pmic_id_status_work; |
Amit Blay | d0fe07b | 2012-09-05 16:42:09 +0300 | [diff] [blame] | 341 | struct delayed_work suspend_work; |
Pavankumar Kondeti | d860852 | 2011-05-04 10:19:47 +0530 | [diff] [blame] | 342 | enum usb_chg_state chg_state; |
| 343 | enum usb_chg_type chg_type; |
Pavankumar Kondeti | ebb4a2d | 2013-01-04 12:28:10 +0530 | [diff] [blame] | 344 | unsigned dcd_time; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 345 | struct wake_lock wlock; |
| 346 | struct notifier_block usbdev_nb; |
| 347 | unsigned mA_port; |
Pavankumar Kondeti | aa449e1 | 2011-11-04 11:09:26 +0530 | [diff] [blame] | 348 | struct timer_list id_timer; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 349 | unsigned long caps; |
Stephen Boyd | 30ad10b | 2012-03-01 14:51:04 -0800 | [diff] [blame] | 350 | struct msm_xo_voter *xo_handle; |
Manu Gautam | cd82e9d | 2011-12-20 14:17:28 +0530 | [diff] [blame] | 351 | uint32_t bus_perf_client; |
Pavankumar Kondeti | 2aec9f3 | 2012-06-13 09:06:03 +0530 | [diff] [blame] | 352 | bool mhl_enabled; |
Pavankumar Kondeti | 458d879 | 2012-09-28 14:45:18 +0530 | [diff] [blame] | 353 | struct timer_list chg_check_timer; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 354 | /* |
| 355 | * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v |
| 356 | * analog regulators while going to low power mode. |
Amit Blay | 81801aa | 2012-09-19 12:08:12 +0200 | [diff] [blame] | 357 | * Currently only 28nm PHY has the support to allowing PHY |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 358 | * power collapse since it doesn't have leakage currents while |
| 359 | * turning off the power rails. |
| 360 | */ |
| 361 | #define ALLOW_PHY_POWER_COLLAPSE BIT(0) |
| 362 | /* |
| 363 | * Allow PHY RETENTION mode before turning off the digital |
| 364 | * voltage regulator(VDDCX). |
| 365 | */ |
| 366 | #define ALLOW_PHY_RETENTION BIT(1) |
Amit Blay | 6fa647a | 2012-05-24 14:12:08 +0300 | [diff] [blame] | 367 | /* |
| 368 | * Allow putting the core in Low Power mode, when |
| 369 | * USB bus is suspended but cable is connected. |
| 370 | */ |
Amit Blay | 81801aa | 2012-09-19 12:08:12 +0200 | [diff] [blame] | 371 | #define ALLOW_LPM_ON_DEV_SUSPEND BIT(2) |
| 372 | /* |
| 373 | * Allowing PHY regulators LPM puts the HSUSB 3.3v and 1.8v |
| 374 | * analog regulators into LPM while going to USB low power mode. |
| 375 | */ |
| 376 | #define ALLOW_PHY_REGULATORS_LPM BIT(3) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 377 | unsigned long lpm_flags; |
| 378 | #define PHY_PWR_COLLAPSED BIT(0) |
| 379 | #define PHY_RETENTIONED BIT(1) |
Vijayavardhan Vennapusa | bbdd608 | 2012-06-06 14:14:25 +0530 | [diff] [blame] | 380 | #define XO_SHUTDOWN BIT(2) |
Ido Shayevitz | c5c0f57 | 2012-07-31 13:58:45 +0300 | [diff] [blame] | 381 | #define CLOCKS_DOWN BIT(3) |
Amit Blay | 81801aa | 2012-09-19 12:08:12 +0200 | [diff] [blame] | 382 | #define PHY_REGULATORS_LPM BIT(4) |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 383 | int reset_counter; |
Vijayavardhan Vennapusa | a315203 | 2012-03-05 16:29:30 +0530 | [diff] [blame] | 384 | unsigned long b_last_se0_sess; |
| 385 | unsigned long tmouts; |
| 386 | u8 active_tmout; |
| 387 | struct hrtimer timer; |
Mayank Rana | 248698c | 2012-04-19 00:03:16 +0530 | [diff] [blame] | 388 | enum usb_vdd_type vdd_type; |
David Keitel | 272ce52 | 2012-08-17 16:25:24 -0700 | [diff] [blame] | 389 | struct power_supply usb_psy; |
| 390 | unsigned int online; |
| 391 | unsigned int host_mode; |
| 392 | unsigned int current_max; |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 393 | }; |
| 394 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 395 | struct msm_hsic_host_platform_data { |
| 396 | unsigned strobe; |
| 397 | unsigned data; |
Manu Gautam | 863b7413 | 2012-11-21 14:30:04 +0530 | [diff] [blame] | 398 | bool ignore_cal_pad_config; |
| 399 | int strobe_pad_offset; |
| 400 | int data_pad_offset; |
| 401 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 402 | struct msm_bus_scale_pdata *bus_scale_table; |
Hemant Kumar | 30d361c | 2012-08-20 14:44:40 -0700 | [diff] [blame] | 403 | unsigned log2_irq_thresh; |
Hemant Kumar | bc8bdf6 | 2012-10-17 12:29:51 -0700 | [diff] [blame] | 404 | |
| 405 | /*swfi latency is required while driving resume on to the bus */ |
Pavankumar Kondeti | 4f5dc3b | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 406 | u32 swfi_latency; |
Hemant Kumar | bc8bdf6 | 2012-10-17 12:29:51 -0700 | [diff] [blame] | 407 | |
| 408 | /*standalone latency is required when HSCI is active*/ |
| 409 | u32 standalone_latency; |
Shimrit Malichi | 36a0c85 | 2013-03-10 11:39:10 +0200 | [diff] [blame] | 410 | bool pool_64_bit_align; |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 411 | }; |
| 412 | |
Manu Gautam | 91223e0 | 2011-11-08 15:27:22 +0530 | [diff] [blame] | 413 | struct msm_usb_host_platform_data { |
| 414 | unsigned int power_budget; |
Vijayavardhan Vennapusa | 4fa1369 | 2012-08-02 14:35:03 +0530 | [diff] [blame] | 415 | int pmic_gpio_dp_irq; |
Hemant Kumar | 5692535 | 2012-02-13 16:59:52 -0800 | [diff] [blame] | 416 | unsigned int dock_connect_irq; |
Vijayavardhan Vennapusa | 1f5da0b | 2013-01-08 20:03:57 +0530 | [diff] [blame] | 417 | bool use_sec_phy; |
Manu Gautam | 91223e0 | 2011-11-08 15:27:22 +0530 | [diff] [blame] | 418 | }; |
| 419 | |
Amit Blay | 9b6e58b | 2012-06-18 13:12:49 +0300 | [diff] [blame] | 420 | /** |
| 421 | * struct msm_hsic_peripheral_platform_data: HSIC peripheral |
| 422 | * platform data. |
| 423 | * @core_clk_always_on_workaround: Don't disable core_clk when |
| 424 | * HSIC enters LPM. |
| 425 | */ |
Amit Blay | 4d57d36 | 2012-04-28 11:00:21 +0300 | [diff] [blame] | 426 | struct msm_hsic_peripheral_platform_data { |
Amit Blay | 9b6e58b | 2012-06-18 13:12:49 +0300 | [diff] [blame] | 427 | bool core_clk_always_on_workaround; |
Amit Blay | 4d57d36 | 2012-04-28 11:00:21 +0300 | [diff] [blame] | 428 | }; |
| 429 | |
Manu Gautam | 6afd587 | 2012-07-25 09:16:55 +0530 | [diff] [blame] | 430 | enum usb_pipe_mem_type { |
| 431 | SPS_PIPE_MEM = 0, /* Default, SPS dedicated pipe memory */ |
| 432 | USB_PRIVATE_MEM, /* USB's private memory */ |
| 433 | SYSTEM_MEM, /* System RAM, requires allocation */ |
| 434 | }; |
| 435 | |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 436 | /** |
| 437 | * struct usb_bam_pipe_connect: pipe connection information |
| 438 | * between USB/HSIC BAM and another BAM. USB/HSIC BAM can be |
| 439 | * either src BAM or dst BAM |
| 440 | * @src_phy_addr: src bam physical address. |
| 441 | * @src_pipe_index: src bam pipe index. |
| 442 | * @dst_phy_addr: dst bam physical address. |
| 443 | * @dst_pipe_index: dst bam pipe index. |
Manu Gautam | 6afd587 | 2012-07-25 09:16:55 +0530 | [diff] [blame] | 444 | * @mem_type: type of memory used for BAM FIFOs |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 445 | * @data_fifo_base_offset: data fifo offset. |
| 446 | * @data_fifo_size: data fifo size. |
| 447 | * @desc_fifo_base_offset: descriptor fifo offset. |
| 448 | * @desc_fifo_size: descriptor fifo size. |
| 449 | */ |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 450 | struct usb_bam_pipe_connect { |
| 451 | u32 src_phy_addr; |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 452 | u32 src_pipe_index; |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 453 | u32 dst_phy_addr; |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 454 | u32 dst_pipe_index; |
Manu Gautam | 6afd587 | 2012-07-25 09:16:55 +0530 | [diff] [blame] | 455 | enum usb_pipe_mem_type mem_type; |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 456 | u32 data_fifo_base_offset; |
| 457 | u32 data_fifo_size; |
| 458 | u32 desc_fifo_base_offset; |
| 459 | u32 desc_fifo_size; |
| 460 | }; |
| 461 | |
Manu Gautam | 355270a | 2012-12-21 16:52:50 +0530 | [diff] [blame] | 462 | enum usb_bam { |
| 463 | SSUSB_BAM = 0, |
| 464 | HSUSB_BAM, |
| 465 | HSIC_BAM, |
| 466 | MAX_BAMS, |
| 467 | }; |
| 468 | |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 469 | /** |
| 470 | * struct msm_usb_bam_platform_data: pipe connection information |
| 471 | * between USB/HSIC BAM and another BAM. USB/HSIC BAM can be |
| 472 | * either src BAM or dst BAM |
| 473 | * @connections: holds all pipe connections data. |
| 474 | * @usb_active_bam: set USB or HSIC as the active BAM. |
| 475 | * @usb_bam_num_pipes: max number of pipes to use. |
| 476 | * @active_conn_num: number of active pipe connections. |
| 477 | * @usb_base_address: BAM physical address. |
Manu Gautam | d21e228 | 2012-08-23 13:38:50 -0700 | [diff] [blame] | 478 | * @ignore_core_reset_ack: BAM can ignore ACK from USB core during PIPE RESET |
repo sync | 985819e | 2013-01-16 19:37:05 +0200 | [diff] [blame] | 479 | * @disable_clk_gating: Disable clock gating |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 480 | */ |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 481 | struct msm_usb_bam_platform_data { |
| 482 | struct usb_bam_pipe_connect *connections; |
Ofir Cohen | 010009b | 2012-01-26 16:49:17 +0200 | [diff] [blame] | 483 | int usb_active_bam; |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 484 | int usb_bam_num_pipes; |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 485 | u32 total_bam_num; |
| 486 | u32 usb_base_address; |
Manu Gautam | d21e228 | 2012-08-23 13:38:50 -0700 | [diff] [blame] | 487 | bool ignore_core_reset_ack; |
Manu Gautam | 355270a | 2012-12-21 16:52:50 +0530 | [diff] [blame] | 488 | bool reset_on_connect[MAX_BAMS]; |
repo sync | 985819e | 2013-01-16 19:37:05 +0200 | [diff] [blame] | 489 | bool disable_clk_gating; |
Ofir Cohen | 010009b | 2012-01-26 16:49:17 +0200 | [diff] [blame] | 490 | }; |
Ido Shayevitz | d1cb16c | 2012-03-28 18:57:47 +0200 | [diff] [blame] | 491 | |
Jack Pham | fadd643 | 2012-12-07 19:03:41 -0800 | [diff] [blame] | 492 | /** |
| 493 | * struct usb_ext_notification: event notification structure |
| 494 | * @notify: pointer to client function to call when ID event is detected. |
| 495 | * The last parameter is provided by driver to be called back when |
| 496 | * external client indicates it is done using the USB. This function |
| 497 | * should return 0 if handled successfully, otherise an error code. |
| 498 | * @ctxt: client-specific context pointer |
| 499 | * |
| 500 | * This structure should be used by clients wishing to register (via |
| 501 | * msm_register_usb_ext_notification) for event notification whenever a USB |
| 502 | * cable is plugged in and ID pin status changes. Clients must provide a |
| 503 | * callback function pointer. If this callback returns 0, the USB driver will |
| 504 | * assume the client is "taking over" the connection, and will relinquish any |
| 505 | * further processing until its callback (passed via the third parameter) is |
| 506 | * called with the online parameter set to false. |
| 507 | */ |
| 508 | struct usb_ext_notification { |
| 509 | int (*notify)(void *, int, void (*)(int online)); |
| 510 | void *ctxt; |
| 511 | }; |
| 512 | |
Amit Blay | 1572b49 | 2012-11-27 16:45:32 +0200 | [diff] [blame] | 513 | #ifdef CONFIG_USB_CI13XXX_MSM |
| 514 | void msm_hw_bam_disable(bool bam_disable); |
| 515 | |
| 516 | #else |
| 517 | static inline void msm_hw_bam_disable(bool bam_disable) |
| 518 | { |
| 519 | } |
| 520 | #endif |
| 521 | |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 522 | #ifdef CONFIG_USB_DWC3_MSM |
Ido Shayevitz | 9fb8345 | 2012-04-01 17:45:58 +0300 | [diff] [blame] | 523 | int msm_ep_config(struct usb_ep *ep); |
| 524 | int msm_ep_unconfig(struct usb_ep *ep); |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 525 | int msm_data_fifo_config(struct usb_ep *ep, u32 addr, u32 size, |
| 526 | u8 dst_pipe_idx); |
Ido Shayevitz | 9fb8345 | 2012-04-01 17:45:58 +0300 | [diff] [blame] | 527 | |
Manu Gautam | 6eb13e3 | 2013-02-01 15:19:15 +0530 | [diff] [blame] | 528 | void msm_dwc3_restart_usb_session(void); |
Jack Pham | fadd643 | 2012-12-07 19:03:41 -0800 | [diff] [blame] | 529 | |
Manu Gautam | 6eb13e3 | 2013-02-01 15:19:15 +0530 | [diff] [blame] | 530 | int msm_register_usb_ext_notification(struct usb_ext_notification *info); |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 531 | #else |
| 532 | static inline int msm_data_fifo_config(struct usb_ep *ep, u32 addr, u32 size, |
| 533 | u8 dst_pipe_idx) |
| 534 | { |
| 535 | return -ENODEV; |
| 536 | } |
| 537 | |
| 538 | static inline int msm_ep_config(struct usb_ep *ep) |
| 539 | { |
| 540 | return -ENODEV; |
| 541 | } |
| 542 | |
| 543 | static inline int msm_ep_unconfig(struct usb_ep *ep) |
| 544 | { |
| 545 | return -ENODEV; |
| 546 | } |
Jack Pham | fadd643 | 2012-12-07 19:03:41 -0800 | [diff] [blame] | 547 | |
Manu Gautam | 6eb13e3 | 2013-02-01 15:19:15 +0530 | [diff] [blame] | 548 | static inline void msm_dwc3_restart_usb_session(void) |
| 549 | { |
| 550 | return; |
| 551 | } |
| 552 | |
Jack Pham | fadd643 | 2012-12-07 19:03:41 -0800 | [diff] [blame] | 553 | static inline int msm_register_usb_ext_notification( |
| 554 | struct usb_ext_notification *info) |
| 555 | { |
| 556 | return -ENODEV; |
| 557 | } |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 558 | #endif |
Pavankumar Kondeti | e0c201f | 2010-12-07 17:53:55 +0530 | [diff] [blame] | 559 | #endif |