blob: f462b64671c03d9022629e90da36d6ce2e34de83 [file] [log] [blame]
Shimrit Malichidbf43d72013-03-16 03:32:27 +02001/* include/linux/usb/msm_hsusb.h
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +05302 *
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
Manu Gautam355270a2012-12-21 16:52:50 +05305 * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +05306 *
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 Shayevitz9fb83452012-04-01 17:45:58 +030022#include <linux/usb/ch9.h>
23#include <linux/usb/gadget.h>
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053024#include <linux/usb/otg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025#include <linux/wakelock.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070026#include <linux/pm_qos.h>
Ido Shayevitz5a6178b2012-06-10 16:31:13 +030027#include <linux/hrtimer.h>
David Keitel272ce522012-08-17 16:25:24 -070028#include <linux/power_supply.h>
Pavankumar Kondetif1ffbdd2013-06-27 13:31:36 +053029#include <linux/cdev.h>
Ido Shayevitzd1cb16c2012-03-28 18:57:47 +020030/*
31 * The following are bit fields describing the usb_request.udc_priv word.
32 * These bit fields are set by function drivers that wish to queue
33 * usb_requests with sps/bam parameters.
34 */
35#define MSM_PIPE_ID_MASK (0x1F)
36#define MSM_TX_PIPE_ID_OFS (16)
37#define MSM_SPS_MODE BIT(5)
38#define MSM_IS_FINITE_TRANSFER BIT(6)
39#define MSM_PRODUCER BIT(7)
40#define MSM_DISABLE_WB BIT(8)
41#define MSM_ETD_IOC BIT(9)
42#define MSM_INTERNAL_MEM BIT(10)
43#define MSM_VENDOR_ID BIT(16)
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053044
45/**
Manu Gautame3a39082013-06-11 10:42:56 +053046 * Requested USB votes for BUS bandwidth
47 *
48 * USB_NO_PERF_VOTE BUS Vote for inactive USB session or disconnect
49 * USB_MAX_PERF_VOTE Maximum BUS bandwidth vote
50 * USB_MIN_PERF_VOTE Minimum BUS bandwidth vote (for some hw same as NO_PERF)
51 *
52 */
53enum usb_bus_vote {
54 USB_NO_PERF_VOTE = 0,
55 USB_MAX_PERF_VOTE,
56 USB_MIN_PERF_VOTE,
57};
58
59/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053060 * Supported USB modes
61 *
62 * USB_PERIPHERAL Only peripheral mode is supported.
63 * USB_HOST Only host mode is supported.
64 * USB_OTG OTG mode is supported.
65 *
66 */
67enum usb_mode_type {
68 USB_NONE = 0,
69 USB_PERIPHERAL,
70 USB_HOST,
71 USB_OTG,
72};
73
74/**
75 * OTG control
76 *
77 * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
78 * only configuration.
79 * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
80 * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
81 * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
82 *
83 */
84enum otg_control_type {
85 OTG_NO_CONTROL = 0,
86 OTG_PHY_CONTROL,
87 OTG_PMIC_CONTROL,
88 OTG_USER_CONTROL,
89};
90
91/**
Pavankumar Kondetid8608522011-05-04 10:19:47 +053092 * PHY used in
93 *
94 * INVALID_PHY Unsupported PHY
95 * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
96 * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
97 *
98 */
99enum msm_usb_phy_type {
100 INVALID_PHY = 0,
101 CI_45NM_INTEGRATED_PHY,
102 SNPS_28NM_INTEGRATED_PHY,
103};
104
105#define IDEV_CHG_MAX 1500
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106#define IDEV_CHG_MIN 500
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530107#define IUNIT 100
108
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530109#define IDEV_ACA_CHG_MAX 1500
110#define IDEV_ACA_CHG_LIMIT 500
111
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530112/**
113 * Different states involved in USB charger detection.
114 *
115 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
116 * process is not yet started.
117 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
118 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
119 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
120 * between SDP and DCP/CDP).
121 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
122 * between DCP and CDP).
123 * USB_CHG_STATE_DETECTED USB charger type is determined.
124 *
125 */
126enum usb_chg_state {
127 USB_CHG_STATE_UNDEFINED = 0,
128 USB_CHG_STATE_WAIT_FOR_DCD,
129 USB_CHG_STATE_DCD_DONE,
130 USB_CHG_STATE_PRIMARY_DONE,
131 USB_CHG_STATE_SECONDARY_DONE,
132 USB_CHG_STATE_DETECTED,
133};
134
135/**
136 * USB charger types
137 *
138 * USB_INVALID_CHARGER Invalid USB charger.
139 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
140 * on USB2.0 compliant host/hub.
141 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
142 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
143 * IDEV_CHG_MAX can be drawn irrespective of USB state.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144 * USB_ACA_A_CHARGER B-device is connected on accessory port with charger
145 * connected on charging port. This configuration allows
146 * charging in host mode.
147 * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on
148 * accessory port with charger connected on charging port.
149 * USB_ACA_C_CHARGER A-device (with VBUS) is connected on
150 * accessory port with charger connected on charging port.
151 * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one
152 * or more downstream ports. Capable of supplying
153 * IDEV_CHG_MAX irrespective of devices connected on
154 * accessory ports.
Pavankumar Kondeti9ec21d32012-05-07 15:50:23 +0530155 * USB_PROPRIETARY_CHARGER A proprietary charger pull DP and DM to specific
156 * voltages between 2.0-3.3v for identification.
157 *
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530158 */
159enum usb_chg_type {
160 USB_INVALID_CHARGER = 0,
161 USB_SDP_CHARGER,
162 USB_DCP_CHARGER,
163 USB_CDP_CHARGER,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164 USB_ACA_A_CHARGER,
165 USB_ACA_B_CHARGER,
166 USB_ACA_C_CHARGER,
167 USB_ACA_DOCK_CHARGER,
Pavankumar Kondeti9ec21d32012-05-07 15:50:23 +0530168 USB_PROPRIETARY_CHARGER,
zhenhuahb6d5edc2013-06-19 14:37:32 +0800169 USB_FLOATED_CHARGER,
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530170};
171
172/**
Mayank Rana248698c2012-04-19 00:03:16 +0530173 * Used different VDDCX voltage voting mechnism
174 * VDDCX_CORNER Vote for VDDCX Corner voltage
175 * VDDCX Vote for VDDCX Absolute voltage
176 */
177enum usb_vdd_type {
178 VDDCX_CORNER = 0,
179 VDDCX,
180 VDD_TYPE_MAX,
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530181};
182
183/**
Amit Blayd6ea6102012-06-07 16:26:24 +0300184 * Used different VDDCX voltage values
185 */
186enum usb_vdd_value {
187 VDD_NONE = 0,
188 VDD_MIN,
189 VDD_MAX,
190 VDD_VAL_MAX,
191};
192
193/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530194 * struct msm_otg_platform_data - platform device data
Pavankumar Kondetidfb21302011-03-04 22:45:02 +0530195 * for msm_otg driver.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530196 * @phy_init_seq: PHY configuration sequence. val, reg pairs
197 * terminated by -1.
Mayank Rana8549e632012-01-23 12:49:54 +0530198 * @vbus_power: VBUS power on/off routine.It should return result
199 * as success(zero value) or failure(non-zero value).
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530200 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
201 * @mode: Supported mode (OTG/peripheral/host).
202 * @otg_control: OTG switch controlled by user/Id pin
203 * @default_mode: Default operational mode. Applicable only if
204 * OTG switch is controller by user.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700205 * @pmic_id_irq: IRQ number assigned for PMIC USB ID line.
Jack Pham87f202f2012-08-06 00:24:22 -0700206 * @mpm_otgsessvld_int: MPM wakeup pin assigned for OTG SESSVLD
207 * interrupt. Used when .otg_control == OTG_PHY_CONTROL.
Vijayavardhan Vennapusa2239b2b2013-06-28 13:16:29 +0530208 * @mpm_dpshv_int: MPM wakeup pin assigned for DP SHV interrupt.
209 * Used during host bus suspend.
210 * @mpm_dmshv_int: MPM wakeup pin assigned for DM SHV interrupt.
211 * Used during host bus suspend.
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530212 * @mhl_enable: indicates MHL connector or not.
Ofir Cohen4da266f2012-01-03 10:19:29 +0200213 * @disable_reset_on_disconnect: perform USB PHY and LINK reset
214 * on USB cable disconnection.
Manu Gautam0ddbd922012-09-21 17:17:38 +0530215 * @pnoc_errata_fix: workaround needed for PNOC hardware bug that
216 * affects USB performance.
Amit Blay6fa647a2012-05-24 14:12:08 +0300217 * @enable_lpm_on_suspend: Enable the USB core to go into Low
218 * Power Mode, when USB bus is suspended but cable
219 * is connected.
Amit Blay9b6e58b2012-06-18 13:12:49 +0300220 * @core_clk_always_on_workaround: Don't disable core_clk when
221 * USB enters LPM.
Amit Blayd6f38282012-10-29 13:13:46 +0200222 * @delay_lpm_on_disconnect: Use a delay before entering LPM
223 * upon USB cable disconnection.
Manu Gautam0fd2d0e2013-03-26 18:09:11 +0530224 * @enable_sec_phy: Use second HSPHY with USB2 core
Manu Gautamcd82e9d2011-12-20 14:17:28 +0530225 * @bus_scale_table: parameters for bus bandwidth requirements
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +0530226 * @mhl_dev_name: MHL device name used to register with MHL driver.
Amit Blayb4f14532013-06-17 22:33:57 +0300227 * @log2_itc: value of 2^(log2_itc-1) will be used as the
228 * interrupt threshold (ITC), when log2_itc is
229 * between 1 to 7.
Shimrit Malichi5a2d5b52013-06-20 19:04:28 +0300230 * @l1_supported: enable link power management support.
Vijayavardhan Vennapusa8997e332013-07-15 09:53:51 +0530231 * @dpdm_pulldown_added: Indicates whether pull down resistors are
232 connected on data lines or not.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530233 */
234struct msm_otg_platform_data {
235 int *phy_init_seq;
Mayank Rana8549e632012-01-23 12:49:54 +0530236 int (*vbus_power)(bool on);
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530237 unsigned power_budget;
238 enum usb_mode_type mode;
239 enum otg_control_type otg_control;
240 enum usb_mode_type default_mode;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530241 enum msm_usb_phy_type phy_type;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530242 void (*setup_gpio)(enum usb_otg_state state);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243 int pmic_id_irq;
Jack Pham87f202f2012-08-06 00:24:22 -0700244 unsigned int mpm_otgsessvld_int;
Vijayavardhan Vennapusa2239b2b2013-06-28 13:16:29 +0530245 unsigned int mpm_dpshv_int;
246 unsigned int mpm_dmshv_int;
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530247 bool mhl_enable;
Ofir Cohen4da266f2012-01-03 10:19:29 +0200248 bool disable_reset_on_disconnect;
Manu Gautam0ddbd922012-09-21 17:17:38 +0530249 bool pnoc_errata_fix;
Amit Blay6fa647a2012-05-24 14:12:08 +0300250 bool enable_lpm_on_dev_suspend;
Amit Blay9b6e58b2012-06-18 13:12:49 +0300251 bool core_clk_always_on_workaround;
Amit Blayd6f38282012-10-29 13:13:46 +0200252 bool delay_lpm_on_disconnect;
Lena Salmanabde35d2013-04-25 15:29:43 +0300253 bool delay_lpm_hndshk_on_disconnect;
Vamsi Krishna1a1684b2013-03-02 16:14:52 -0800254 bool dp_manual_pullup;
Manu Gautam0fd2d0e2013-03-26 18:09:11 +0530255 bool enable_sec_phy;
Manu Gautamcd82e9d2011-12-20 14:17:28 +0530256 struct msm_bus_scale_pdata *bus_scale_table;
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +0530257 const char *mhl_dev_name;
Amit Blayb4f14532013-06-17 22:33:57 +0300258 int log2_itc;
Shimrit Malichi5a2d5b52013-06-20 19:04:28 +0300259 bool l1_supported;
Vijayavardhan Vennapusa8997e332013-07-15 09:53:51 +0530260 bool dpdm_pulldown_added;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530261};
262
Vamsi Krishna1a1684b2013-03-02 16:14:52 -0800263/* phy related flags */
264#define ENABLE_DP_MANUAL_PULLUP BIT(0)
Manu Gautam0fd2d0e2013-03-26 18:09:11 +0530265#define ENABLE_SECONDARY_PHY BIT(1)
Vamsi Krishna1a1684b2013-03-02 16:14:52 -0800266
Vijayavardhan Vennapusaa3152032012-03-05 16:29:30 +0530267/* Timeout (in msec) values (min - max) associated with OTG timers */
268
269#define TA_WAIT_VRISE 100 /* ( - 100) */
270#define TA_WAIT_VFALL 500 /* ( - 1000) */
271
272/*
273 * This option is set for embedded hosts or OTG devices in which leakage
274 * currents are very minimal.
275 */
276#ifdef CONFIG_USB_OTG
277#define TA_WAIT_BCON 30000 /* (1100 - 30000) */
278#else
279#define TA_WAIT_BCON -1
280#endif
281
282#define TA_AIDL_BDIS 500 /* (200 - ) */
283#define TA_BIDL_ADIS 155 /* (155 - 200) */
284#define TB_SRP_FAIL 6000 /* (5000 - 6000) */
285#define TB_ASE0_BRST 200 /* (155 - ) */
286
287/* TB_SSEND_SRP and TB_SE0_SRP are combined */
288#define TB_SRP_INIT 2000 /* (1500 - ) */
289
290#define TA_TST_MAINT 10100 /* (9900 - 10100) */
291#define TB_TST_SRP 3000 /* ( - 5000) */
292#define TB_TST_CONFIG 300
293
294/* Timeout variables */
295
296#define A_WAIT_VRISE 0
297#define A_WAIT_VFALL 1
298#define A_WAIT_BCON 2
299#define A_AIDL_BDIS 3
300#define A_BIDL_ADIS 4
301#define B_SRP_FAIL 5
302#define B_ASE0_BRST 6
303#define A_TST_MAINT 7
304#define B_TST_SRP 8
305#define B_TST_CONFIG 9
306
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530307/**
308 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
309 * @otg: USB OTG Transceiver structure.
310 * @pdata: otg device platform data.
311 * @irq: IRQ number assigned for HSUSB controller.
Manu Gautamf8c45642012-08-10 10:20:56 -0700312 * @async_irq: IRQ number used by some controllers during low power state
Manu Gautam5143b252012-01-05 19:25:23 -0800313 * @clk: clock struct of alt_core_clk.
314 * @pclk: clock struct of iface_clk.
Manu Gautam5143b252012-01-05 19:25:23 -0800315 * @core_clk: clock struct of core_bus_clk.
Mayank Ranadd1f1dc2013-07-24 17:02:45 +0530316 * @sleep_clk: clock struct of sleep_clk for USB PHY.
Mayank Rana3eaf28d2013-03-27 14:04:04 +0530317 * @core_clk_rate: core clk max frequency
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530318 * @regs: ioremapped register base address.
319 * @inputs: OTG state machine inputs(Id, SessValid etc).
320 * @sm_work: OTG state machine work.
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530321 * @in_lpm: indicates low power mode (LPM) state.
Manu Gautamf8c45642012-08-10 10:20:56 -0700322 * @async_int: IRQ line on which ASYNC interrupt arrived in LPM.
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530323 * @cur_power: The amount of mA available from downstream port.
324 * @chg_work: Charger detection work.
325 * @chg_state: The state of charger detection process.
326 * @chg_type: The type of charger attached.
327 * @dcd_retires: The retry count used to track Data contact
328 * detection process.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329 * @wlock: Wake lock struct to prevent system suspend when
330 * USB is active.
331 * @usbdev_nb: The notifier block used to know about the B-device
332 * connected. Useful only when ACA_A charger is
333 * connected.
334 * @mA_port: The amount of current drawn by the attached B-device.
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530335 * @id_timer: The timer used for polling ID line to detect ACA states.
Anji jonnala7da3f262011-12-02 17:22:14 -0800336 * @xo_handle: TCXO buffer handle
Manu Gautamcd82e9d2011-12-20 14:17:28 +0530337 * @bus_perf_client: Bus performance client handle to request BUS bandwidth
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +0530338 * @mhl_enabled: MHL driver registration successful and MHL enabled.
Vijayavardhan Vennapusa2239b2b2013-06-28 13:16:29 +0530339 * @host_bus_suspend: indicates host bus suspend or not.
Pavankumar Kondeti458d8792012-09-28 14:45:18 +0530340 * @chg_check_timer: The timer used to implement the workaround to detect
341 * very slow plug in of wall charger.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530342 */
343struct msm_otg {
Heikki Krogerus1d4c9292012-02-13 13:24:09 +0200344 struct usb_phy phy;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530345 struct msm_otg_platform_data *pdata;
346 int irq;
Manu Gautamf8c45642012-08-10 10:20:56 -0700347 int async_irq;
Vijayavardhan Vennapusa0cab6172013-02-20 19:51:15 +0530348 struct clk *xo_clk;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530349 struct clk *clk;
350 struct clk *pclk;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530351 struct clk *core_clk;
Mayank Ranadd1f1dc2013-07-24 17:02:45 +0530352 struct clk *sleep_clk;
Mayank Rana3eaf28d2013-03-27 14:04:04 +0530353 long core_clk_rate;
Pavankumar Kondetif1ffbdd2013-06-27 13:31:36 +0530354 struct resource *io_res;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530355 void __iomem *regs;
356#define ID 0
357#define B_SESS_VLD 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700358#define ID_A 2
359#define ID_B 3
360#define ID_C 4
Vijayavardhan Vennapusaa3152032012-03-05 16:29:30 +0530361#define A_BUS_DROP 5
362#define A_BUS_REQ 6
363#define A_SRP_DET 7
364#define A_VBUS_VLD 8
365#define B_CONN 9
366#define ADP_CHANGE 10
367#define POWER_UP 11
368#define A_CLR_ERR 12
369#define A_BUS_RESUME 13
370#define A_BUS_SUSPEND 14
371#define A_CONN 15
372#define B_BUS_REQ 16
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +0530373#define MHL 17
Pavankumar Kondeti458d8792012-09-28 14:45:18 +0530374#define B_FALSE_SDP 18
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530375 unsigned long inputs;
376 struct work_struct sm_work;
Jack Pham5ca279b2012-05-14 18:42:54 -0700377 bool sm_work_pending;
378 atomic_t pm_suspended;
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530379 atomic_t in_lpm;
380 int async_int;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530381 unsigned cur_power;
382 struct delayed_work chg_work;
Vijayavardhan Vennapusa68d55cf2012-06-27 20:06:12 +0530383 struct delayed_work pmic_id_status_work;
Amit Blayd0fe07b2012-09-05 16:42:09 +0300384 struct delayed_work suspend_work;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530385 enum usb_chg_state chg_state;
386 enum usb_chg_type chg_type;
Pavankumar Kondetiebb4a2d2013-01-04 12:28:10 +0530387 unsigned dcd_time;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388 struct wake_lock wlock;
389 struct notifier_block usbdev_nb;
390 unsigned mA_port;
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530391 struct timer_list id_timer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700392 unsigned long caps;
Stephen Boyd30ad10b2012-03-01 14:51:04 -0800393 struct msm_xo_voter *xo_handle;
Manu Gautamcd82e9d2011-12-20 14:17:28 +0530394 uint32_t bus_perf_client;
Pavankumar Kondeti2aec9f32012-06-13 09:06:03 +0530395 bool mhl_enabled;
Vijayavardhan Vennapusa2239b2b2013-06-28 13:16:29 +0530396 bool host_bus_suspend;
Pavankumar Kondeti458d8792012-09-28 14:45:18 +0530397 struct timer_list chg_check_timer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700398 /*
399 * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v
400 * analog regulators while going to low power mode.
Amit Blay81801aa2012-09-19 12:08:12 +0200401 * Currently only 28nm PHY has the support to allowing PHY
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700402 * power collapse since it doesn't have leakage currents while
403 * turning off the power rails.
404 */
405#define ALLOW_PHY_POWER_COLLAPSE BIT(0)
406 /*
407 * Allow PHY RETENTION mode before turning off the digital
408 * voltage regulator(VDDCX).
409 */
410#define ALLOW_PHY_RETENTION BIT(1)
Amit Blay6fa647a2012-05-24 14:12:08 +0300411 /*
412 * Allow putting the core in Low Power mode, when
413 * USB bus is suspended but cable is connected.
414 */
Amit Blay81801aa2012-09-19 12:08:12 +0200415#define ALLOW_LPM_ON_DEV_SUSPEND BIT(2)
416 /*
417 * Allowing PHY regulators LPM puts the HSUSB 3.3v and 1.8v
418 * analog regulators into LPM while going to USB low power mode.
419 */
420#define ALLOW_PHY_REGULATORS_LPM BIT(3)
Vijayavardhan Vennapusa2239b2b2013-06-28 13:16:29 +0530421 /*
422 * Allow PHY RETENTION mode before turning off the digital
423 * voltage regulator(VDDCX) during host mode.
424 */
425#define ALLOW_HOST_PHY_RETENTION BIT(4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700426 unsigned long lpm_flags;
427#define PHY_PWR_COLLAPSED BIT(0)
428#define PHY_RETENTIONED BIT(1)
Vijayavardhan Vennapusabbdd6082012-06-06 14:14:25 +0530429#define XO_SHUTDOWN BIT(2)
Ido Shayevitzc5c0f572012-07-31 13:58:45 +0300430#define CLOCKS_DOWN BIT(3)
Amit Blay81801aa2012-09-19 12:08:12 +0200431#define PHY_REGULATORS_LPM BIT(4)
Ofir Cohen4da266f2012-01-03 10:19:29 +0200432 int reset_counter;
Vijayavardhan Vennapusaa3152032012-03-05 16:29:30 +0530433 unsigned long b_last_se0_sess;
434 unsigned long tmouts;
435 u8 active_tmout;
436 struct hrtimer timer;
Mayank Rana248698c2012-04-19 00:03:16 +0530437 enum usb_vdd_type vdd_type;
David Keitel272ce522012-08-17 16:25:24 -0700438 struct power_supply usb_psy;
439 unsigned int online;
440 unsigned int host_mode;
Pavankumar Kondeti254e38d2013-07-16 11:13:05 +0530441 unsigned int voltage_max;
David Keitel272ce522012-08-17 16:25:24 -0700442 unsigned int current_max;
Pavankumar Kondetif1ffbdd2013-06-27 13:31:36 +0530443
444 dev_t ext_chg_dev;
445 struct cdev ext_chg_cdev;
446 struct class *ext_chg_class;
447 struct device *ext_chg_device;
448 bool ext_chg_opened;
449 bool ext_chg_active;
450 struct completion ext_chg_wait;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530451};
452
Amit Blayb4f14532013-06-17 22:33:57 +0300453struct ci13xxx_platform_data {
454 u8 usb_core_id;
455 /*
456 * value of 2^(log2_itc-1) will be used as the interrupt threshold
457 * (ITC), when log2_itc is between 1 to 7.
458 */
459 int log2_itc;
460 void *prv_data;
Shimrit Malichi5a2d5b52013-06-20 19:04:28 +0300461 bool l1_supported;
Amit Blayb4f14532013-06-17 22:33:57 +0300462};
463
Manu Gautamcaa99d42013-07-25 12:01:02 +0530464/**
465 * struct msm_hsic_host_platform_data - platform device data
466 * for msm_hsic_host driver.
467 * @phy_sof_workaround: Enable ALL PHY SOF bug related workarounds for
468 SUSPEND, RESET and RESUME.
469 * @phy_susp_sof_workaround: Enable PHY SOF workaround only for SUSPEND.
470 *
471 */
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530472struct msm_hsic_host_platform_data {
473 unsigned strobe;
474 unsigned data;
Manu Gautam863b74132012-11-21 14:30:04 +0530475 bool ignore_cal_pad_config;
Manu Gautam3c598392013-03-22 16:59:10 +0530476 bool phy_sof_workaround;
Manu Gautamcaa99d42013-07-25 12:01:02 +0530477 bool phy_susp_sof_workaround;
Ming-yi Lin9eed5e02013-07-18 14:06:24 +0800478 u32 reset_delay;
Manu Gautam863b74132012-11-21 14:30:04 +0530479 int strobe_pad_offset;
480 int data_pad_offset;
481
Hemant Kumare6275972012-02-29 20:06:21 -0800482 struct msm_bus_scale_pdata *bus_scale_table;
Hemant Kumar30d361c2012-08-20 14:44:40 -0700483 unsigned log2_irq_thresh;
Hemant Kumarbc8bdf62012-10-17 12:29:51 -0700484
Vamsi Krishnabef91832013-03-11 14:10:20 -0700485 /* gpio used to resume peripheral */
486 unsigned resume_gpio;
487
Hemant Kumarbc8bdf62012-10-17 12:29:51 -0700488 /*swfi latency is required while driving resume on to the bus */
Pavankumar Kondeti4f5dc3b2012-09-07 15:33:09 +0530489 u32 swfi_latency;
Hemant Kumarbc8bdf62012-10-17 12:29:51 -0700490
491 /*standalone latency is required when HSCI is active*/
492 u32 standalone_latency;
Shimrit Malichi36a0c852013-03-10 11:39:10 +0200493 bool pool_64_bit_align;
Shimrit Malichi82d7cbc2013-03-12 15:36:54 +0200494 bool enable_hbm;
Shimrit Malichi08f07342013-04-24 13:09:12 +0300495 bool disable_park_mode;
Ido Shayevitzaa165c52013-05-12 16:01:28 +0200496 bool consider_ipa_handshake;
Amit Blay1dfbbcc2013-05-26 17:33:13 +0300497 bool ahb_async_bridge_bypass;
Vamsi Krishna4f66c2c2013-06-21 11:33:59 -0700498 bool disable_cerr;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530499};
500
Manu Gautam91223e02011-11-08 15:27:22 +0530501struct msm_usb_host_platform_data {
502 unsigned int power_budget;
Vijayavardhan Vennapusa4fa13692012-08-02 14:35:03 +0530503 int pmic_gpio_dp_irq;
Hemant Kumar56925352012-02-13 16:59:52 -0800504 unsigned int dock_connect_irq;
Vijayavardhan Vennapusa1f5da0b2013-01-08 20:03:57 +0530505 bool use_sec_phy;
Hemant Kumarb8fc9592013-04-17 19:29:39 -0700506 bool no_selective_suspend;
Hemant Kumara7d531d2013-06-18 22:12:18 -0700507 int resume_gpio;
Manu Gautam91223e02011-11-08 15:27:22 +0530508};
509
Amit Blay9b6e58b2012-06-18 13:12:49 +0300510/**
511 * struct msm_hsic_peripheral_platform_data: HSIC peripheral
512 * platform data.
513 * @core_clk_always_on_workaround: Don't disable core_clk when
514 * HSIC enters LPM.
515 */
Amit Blay4d57d362012-04-28 11:00:21 +0300516struct msm_hsic_peripheral_platform_data {
Amit Blay9b6e58b2012-06-18 13:12:49 +0300517 bool core_clk_always_on_workaround;
Amit Blay4d57d362012-04-28 11:00:21 +0300518};
519
Jack Phamfadd6432012-12-07 19:03:41 -0800520/**
521 * struct usb_ext_notification: event notification structure
522 * @notify: pointer to client function to call when ID event is detected.
Jack Phamb7209152013-07-03 17:04:53 -0700523 * The function parameter is provided by driver to be called back when
Jack Phamfadd6432012-12-07 19:03:41 -0800524 * external client indicates it is done using the USB. This function
525 * should return 0 if handled successfully, otherise an error code.
526 * @ctxt: client-specific context pointer
527 *
528 * This structure should be used by clients wishing to register (via
529 * msm_register_usb_ext_notification) for event notification whenever a USB
530 * cable is plugged in and ID pin status changes. Clients must provide a
531 * callback function pointer. If this callback returns 0, the USB driver will
532 * assume the client is "taking over" the connection, and will relinquish any
533 * further processing until its callback (passed via the third parameter) is
534 * called with the online parameter set to false.
535 */
536struct usb_ext_notification {
Jack Phamb7209152013-07-03 17:04:53 -0700537 int (*notify)(void *, int, void (*)(void *, int online), void *);
Jack Phamfadd6432012-12-07 19:03:41 -0800538 void *ctxt;
539};
Lena Salmanabde35d2013-04-25 15:29:43 +0300540#ifdef CONFIG_USB_BAM
541bool msm_bam_lpm_ok(void);
Ido Shayevitz44ca03c2013-07-09 15:57:21 +0300542void msm_bam_notify_lpm_resume(void);
Ido Shayevitzaa165c52013-05-12 16:01:28 +0200543void msm_bam_set_hsic_host_dev(struct device *dev);
544void msm_bam_wait_for_hsic_prod_granted(void);
545bool msm_bam_hsic_lpm_ok(void);
546void msm_bam_hsic_notify_on_resume(void);
Lena Salmanabde35d2013-04-25 15:29:43 +0300547#else
548static inline bool msm_bam_lpm_ok(void) { return true; }
Ido Shayevitz44ca03c2013-07-09 15:57:21 +0300549static inline void msm_bam_notify_lpm_resume(void) {}
Ido Shayevitzaa165c52013-05-12 16:01:28 +0200550static inline void msm_bam_set_hsic_host_dev(struct device *dev) {}
551static inline void msm_bam_wait_for_hsic_prod_granted(void) {}
552static inline bool msm_bam_hsic_lpm_ok(void) { return true; }
553static inline void msm_bam_hsic_notify_on_resume(void) {}
Lena Salmanabde35d2013-04-25 15:29:43 +0300554#endif
Amit Blay1572b492012-11-27 16:45:32 +0200555#ifdef CONFIG_USB_CI13XXX_MSM
556void msm_hw_bam_disable(bool bam_disable);
Amit Blay1572b492012-11-27 16:45:32 +0200557#else
558static inline void msm_hw_bam_disable(bool bam_disable)
559{
560}
561#endif
562
Shimrit Malichi255b5342012-08-02 21:01:43 +0300563#ifdef CONFIG_USB_DWC3_MSM
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300564int msm_ep_config(struct usb_ep *ep);
565int msm_ep_unconfig(struct usb_ep *ep);
Vijayavardhan Vennapusafc3db602013-08-20 17:54:54 +0530566void dwc3_tx_fifo_resize_request(struct usb_ep *ep, bool qdss_enable);
Shimrit Malichi255b5342012-08-02 21:01:43 +0300567int msm_data_fifo_config(struct usb_ep *ep, u32 addr, u32 size,
568 u8 dst_pipe_idx);
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300569
Jack Pham62c19a42013-07-09 17:55:09 -0700570void msm_dwc3_restart_usb_session(struct usb_gadget *gadget);
Jack Phamfadd6432012-12-07 19:03:41 -0800571
Manu Gautam6eb13e32013-02-01 15:19:15 +0530572int msm_register_usb_ext_notification(struct usb_ext_notification *info);
Shimrit Malichi255b5342012-08-02 21:01:43 +0300573#else
574static inline int msm_data_fifo_config(struct usb_ep *ep, u32 addr, u32 size,
575 u8 dst_pipe_idx)
576{
577 return -ENODEV;
578}
579
580static inline int msm_ep_config(struct usb_ep *ep)
581{
582 return -ENODEV;
583}
584
585static inline int msm_ep_unconfig(struct usb_ep *ep)
586{
587 return -ENODEV;
588}
Jack Phamfadd6432012-12-07 19:03:41 -0800589
Vijayavardhan Vennapusafc3db602013-08-20 17:54:54 +0530590static inline void dwc3_tx_fifo_resize_request(
591 struct usb_ep *ep, bool qdss_enable)
592{
593 return;
594}
595
Jack Pham62c19a42013-07-09 17:55:09 -0700596static inline void msm_dwc3_restart_usb_session(struct usb_gadget *gadget)
Manu Gautam6eb13e32013-02-01 15:19:15 +0530597{
598 return;
599}
600
Jack Phamfadd6432012-12-07 19:03:41 -0800601static inline int msm_register_usb_ext_notification(
602 struct usb_ext_notification *info)
603{
604 return -ENODEV;
605}
Shimrit Malichi255b5342012-08-02 21:01:43 +0300606#endif
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530607#endif