blob: 68fc67c4ef652ecaf33d19b50e96473663ea6852 [file] [log] [blame]
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +05301/* linux/include/asm-arm/arch-msm/hsusb.h
2 *
3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
Pavankumar Kondetid8608522011-05-04 10:19:47 +05305 * Copyright (c) 2009-2011, Code Aurora Forum. 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>
22#include <linux/usb/otg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/wakelock.h>
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +053024#include <linux/pm_qos_params.h>
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053025
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 */
34enum 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 */
51enum otg_control_type {
52 OTG_NO_CONTROL = 0,
53 OTG_PHY_CONTROL,
54 OTG_PMIC_CONTROL,
55 OTG_USER_CONTROL,
56};
57
58/**
Pavankumar Kondetid8608522011-05-04 10:19:47 +053059 * 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 */
66enum 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 Huntsman3f2bc4d2011-08-16 17:27:22 -070073#define IDEV_CHG_MIN 500
Pavankumar Kondetid8608522011-05-04 10:19:47 +053074#define IUNIT 100
75
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +053076#define IDEV_ACA_CHG_MAX 1500
77#define IDEV_ACA_CHG_LIMIT 500
78
Pavankumar Kondetid8608522011-05-04 10:19:47 +053079/**
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 */
93enum 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 Huntsman3f2bc4d2011-08-16 17:27:22 -0700111 * 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 Kondetid8608522011-05-04 10:19:47 +0530122 */
123enum usb_chg_type {
124 USB_INVALID_CHARGER = 0,
125 USB_SDP_CHARGER,
126 USB_DCP_CHARGER,
127 USB_CDP_CHARGER,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128 USB_ACA_A_CHARGER,
129 USB_ACA_B_CHARGER,
130 USB_ACA_C_CHARGER,
131 USB_ACA_DOCK_CHARGER,
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530132};
133
134/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530135 * struct msm_otg_platform_data - platform device data
Pavankumar Kondetidfb21302011-03-04 22:45:02 +0530136 * for msm_otg driver.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530137 * @phy_init_seq: PHY configuration sequence. val, reg pairs
138 * terminated by -1.
139 * @vbus_power: VBUS power on/off routine.
140 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
141 * @mode: Supported mode (OTG/peripheral/host).
142 * @otg_control: OTG switch controlled by user/Id pin
143 * @default_mode: Default operational mode. Applicable only if
144 * OTG switch is controller by user.
Anji jonnala0f73cac2011-05-04 10:19:46 +0530145 * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
146 * dfab_usb_hs_clk in case of 8660 and 8960.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 * @pmic_id_irq: IRQ number assigned for PMIC USB ID line.
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530148 * @mhl_enable: indicates MHL connector or not.
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +0530149 * @swfi_latency: miminum latency to allow swfi.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530150 */
151struct msm_otg_platform_data {
152 int *phy_init_seq;
153 void (*vbus_power)(bool on);
154 unsigned power_budget;
155 enum usb_mode_type mode;
156 enum otg_control_type otg_control;
157 enum usb_mode_type default_mode;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530158 enum msm_usb_phy_type phy_type;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530159 void (*setup_gpio)(enum usb_otg_state state);
Pavankumar Kondetieaea7fe2011-10-27 14:46:45 +0530160 const char *pclk_src_name;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161 int pmic_id_irq;
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530162 bool mhl_enable;
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +0530163 u32 swfi_latency;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530164};
165
166/**
167 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
168 * @otg: USB OTG Transceiver structure.
169 * @pdata: otg device platform data.
170 * @irq: IRQ number assigned for HSUSB controller.
171 * @clk: clock struct of usb_hs_clk.
172 * @pclk: clock struct of usb_hs_pclk.
Anji jonnala0f73cac2011-05-04 10:19:46 +0530173 * @pclk_src: pclk source for voting.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530174 * @phy_reset_clk: clock struct of usb_phy_clk.
175 * @core_clk: clock struct of usb_hs_core_clk.
Amit Blay02eff132011-09-21 16:46:24 +0300176 * @system_clk: clock struct of usb_system_clk.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530177 * @regs: ioremapped register base address.
178 * @inputs: OTG state machine inputs(Id, SessValid etc).
179 * @sm_work: OTG state machine work.
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530180 * @in_lpm: indicates low power mode (LPM) state.
181 * @async_int: Async interrupt arrived.
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530182 * @cur_power: The amount of mA available from downstream port.
183 * @chg_work: Charger detection work.
184 * @chg_state: The state of charger detection process.
185 * @chg_type: The type of charger attached.
186 * @dcd_retires: The retry count used to track Data contact
187 * detection process.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188 * @wlock: Wake lock struct to prevent system suspend when
189 * USB is active.
190 * @usbdev_nb: The notifier block used to know about the B-device
191 * connected. Useful only when ACA_A charger is
192 * connected.
193 * @mA_port: The amount of current drawn by the attached B-device.
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +0530194 * @pm_qos_req_dma: miminum DMA latency to vote against idle power
195 collapse when cable is connected.
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530196 * @id_timer: The timer used for polling ID line to detect ACA states.
Anji jonnala7da3f262011-12-02 17:22:14 -0800197 * @xo_handle: TCXO buffer handle
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530198 */
199struct msm_otg {
200 struct otg_transceiver otg;
201 struct msm_otg_platform_data *pdata;
202 int irq;
203 struct clk *clk;
204 struct clk *pclk;
Anji jonnala0f73cac2011-05-04 10:19:46 +0530205 struct clk *pclk_src;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530206 struct clk *phy_reset_clk;
207 struct clk *core_clk;
Amit Blay02eff132011-09-21 16:46:24 +0300208 struct clk *system_clk;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530209 void __iomem *regs;
210#define ID 0
211#define B_SESS_VLD 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212#define ID_A 2
213#define ID_B 3
214#define ID_C 4
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530215 unsigned long inputs;
216 struct work_struct sm_work;
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530217 atomic_t in_lpm;
218 int async_int;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530219 unsigned cur_power;
220 struct delayed_work chg_work;
221 enum usb_chg_state chg_state;
222 enum usb_chg_type chg_type;
223 u8 dcd_retries;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700224 struct wake_lock wlock;
225 struct notifier_block usbdev_nb;
226 unsigned mA_port;
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530227 struct timer_list id_timer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700228 unsigned long caps;
Anji jonnala7da3f262011-12-02 17:22:14 -0800229 struct msm_xo_voter *xo_handle;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230 /*
231 * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v
232 * analog regulators while going to low power mode.
233 * Currently only 8960(28nm PHY) has the support to allowing PHY
234 * power collapse since it doesn't have leakage currents while
235 * turning off the power rails.
236 */
237#define ALLOW_PHY_POWER_COLLAPSE BIT(0)
238 /*
239 * Allow PHY RETENTION mode before turning off the digital
240 * voltage regulator(VDDCX).
241 */
242#define ALLOW_PHY_RETENTION BIT(1)
243 /*
244 * Disable the OTG comparators to save more power
245 * if depends on PMIC for VBUS and ID interrupts.
246 */
247#define ALLOW_PHY_COMP_DISABLE BIT(2)
248 unsigned long lpm_flags;
249#define PHY_PWR_COLLAPSED BIT(0)
250#define PHY_RETENTIONED BIT(1)
251#define PHY_OTG_COMP_DISABLED BIT(2)
Anji jonnalaa7c1c5c2011-12-12 12:20:36 +0530252 struct pm_qos_request_list pm_qos_req_dma;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530253};
254
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530255struct msm_hsic_host_platform_data {
256 unsigned strobe;
257 unsigned data;
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +0530258 unsigned hub_reset;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530259};
260
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530261#endif