blob: 2ee66328fd4273b0c1a7c74361d9be99fa4c64a1 [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>
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053024
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 */
33enum 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 */
50enum otg_control_type {
51 OTG_NO_CONTROL = 0,
52 OTG_PHY_CONTROL,
53 OTG_PMIC_CONTROL,
54 OTG_USER_CONTROL,
55};
56
57/**
Pavankumar Kondetid8608522011-05-04 10:19:47 +053058 * 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 */
65enum 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 Huntsman3f2bc4d2011-08-16 17:27:22 -070072#define IDEV_CHG_MIN 500
Pavankumar Kondetid8608522011-05-04 10:19:47 +053073#define IUNIT 100
74
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +053075#define IDEV_ACA_CHG_MAX 1500
76#define IDEV_ACA_CHG_LIMIT 500
77
Pavankumar Kondetid8608522011-05-04 10:19:47 +053078/**
79 * Different states involved in USB charger detection.
80 *
81 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
82 * process is not yet started.
83 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
84 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
85 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
86 * between SDP and DCP/CDP).
87 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
88 * between DCP and CDP).
89 * USB_CHG_STATE_DETECTED USB charger type is determined.
90 *
91 */
92enum usb_chg_state {
93 USB_CHG_STATE_UNDEFINED = 0,
94 USB_CHG_STATE_WAIT_FOR_DCD,
95 USB_CHG_STATE_DCD_DONE,
96 USB_CHG_STATE_PRIMARY_DONE,
97 USB_CHG_STATE_SECONDARY_DONE,
98 USB_CHG_STATE_DETECTED,
99};
100
101/**
102 * USB charger types
103 *
104 * USB_INVALID_CHARGER Invalid USB charger.
105 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
106 * on USB2.0 compliant host/hub.
107 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
108 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
109 * IDEV_CHG_MAX can be drawn irrespective of USB state.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110 * USB_ACA_A_CHARGER B-device is connected on accessory port with charger
111 * connected on charging port. This configuration allows
112 * charging in host mode.
113 * USB_ACA_B_CHARGER No device (or A-device without VBUS) is connected on
114 * accessory port with charger connected on charging port.
115 * USB_ACA_C_CHARGER A-device (with VBUS) is connected on
116 * accessory port with charger connected on charging port.
117 * USB_ACA_DOCK_CHARGER A docking station that has one upstream port and one
118 * or more downstream ports. Capable of supplying
119 * IDEV_CHG_MAX irrespective of devices connected on
120 * accessory ports.
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530121 */
122enum usb_chg_type {
123 USB_INVALID_CHARGER = 0,
124 USB_SDP_CHARGER,
125 USB_DCP_CHARGER,
126 USB_CDP_CHARGER,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127 USB_ACA_A_CHARGER,
128 USB_ACA_B_CHARGER,
129 USB_ACA_C_CHARGER,
130 USB_ACA_DOCK_CHARGER,
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530131};
132
133/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530134 * struct msm_otg_platform_data - platform device data
Pavankumar Kondetidfb21302011-03-04 22:45:02 +0530135 * for msm_otg driver.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530136 * @phy_init_seq: PHY configuration sequence. val, reg pairs
137 * terminated by -1.
138 * @vbus_power: VBUS power on/off routine.
139 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
140 * @mode: Supported mode (OTG/peripheral/host).
141 * @otg_control: OTG switch controlled by user/Id pin
142 * @default_mode: Default operational mode. Applicable only if
143 * OTG switch is controller by user.
Anji jonnala0f73cac2011-05-04 10:19:46 +0530144 * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
145 * dfab_usb_hs_clk in case of 8660 and 8960.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146 * @pmic_id_irq: IRQ number assigned for PMIC USB ID line.
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530147 * @mhl_enable: indicates MHL connector or not.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530148 */
149struct msm_otg_platform_data {
150 int *phy_init_seq;
151 void (*vbus_power)(bool on);
152 unsigned power_budget;
153 enum usb_mode_type mode;
154 enum otg_control_type otg_control;
155 enum usb_mode_type default_mode;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530156 enum msm_usb_phy_type phy_type;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530157 void (*setup_gpio)(enum usb_otg_state state);
Anji jonnala0f73cac2011-05-04 10:19:46 +0530158 char *pclk_src_name;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159 int pmic_id_irq;
Vijayavardhan Vennapusafc464f02011-11-04 21:54:00 +0530160 bool mhl_enable;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530161};
162
163/**
164 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
165 * @otg: USB OTG Transceiver structure.
166 * @pdata: otg device platform data.
167 * @irq: IRQ number assigned for HSUSB controller.
168 * @clk: clock struct of usb_hs_clk.
169 * @pclk: clock struct of usb_hs_pclk.
Anji jonnala0f73cac2011-05-04 10:19:46 +0530170 * @pclk_src: pclk source for voting.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530171 * @phy_reset_clk: clock struct of usb_phy_clk.
172 * @core_clk: clock struct of usb_hs_core_clk.
Amit Blay02eff132011-09-21 16:46:24 +0300173 * @system_clk: clock struct of usb_system_clk.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530174 * @regs: ioremapped register base address.
175 * @inputs: OTG state machine inputs(Id, SessValid etc).
176 * @sm_work: OTG state machine work.
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530177 * @in_lpm: indicates low power mode (LPM) state.
178 * @async_int: Async interrupt arrived.
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530179 * @cur_power: The amount of mA available from downstream port.
180 * @chg_work: Charger detection work.
181 * @chg_state: The state of charger detection process.
182 * @chg_type: The type of charger attached.
183 * @dcd_retires: The retry count used to track Data contact
184 * detection process.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185 * @wlock: Wake lock struct to prevent system suspend when
186 * USB is active.
187 * @usbdev_nb: The notifier block used to know about the B-device
188 * connected. Useful only when ACA_A charger is
189 * connected.
190 * @mA_port: The amount of current drawn by the attached B-device.
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530191 * @id_timer: The timer used for polling ID line to detect ACA states.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530192 */
193struct msm_otg {
194 struct otg_transceiver otg;
195 struct msm_otg_platform_data *pdata;
196 int irq;
197 struct clk *clk;
198 struct clk *pclk;
Anji jonnala0f73cac2011-05-04 10:19:46 +0530199 struct clk *pclk_src;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530200 struct clk *phy_reset_clk;
201 struct clk *core_clk;
Amit Blay02eff132011-09-21 16:46:24 +0300202 struct clk *system_clk;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530203 void __iomem *regs;
204#define ID 0
205#define B_SESS_VLD 1
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700206#define ID_A 2
207#define ID_B 3
208#define ID_C 4
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530209 unsigned long inputs;
210 struct work_struct sm_work;
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530211 atomic_t in_lpm;
212 int async_int;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530213 unsigned cur_power;
214 struct delayed_work chg_work;
215 enum usb_chg_state chg_state;
216 enum usb_chg_type chg_type;
217 u8 dcd_retries;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700218 struct wake_lock wlock;
219 struct notifier_block usbdev_nb;
220 unsigned mA_port;
Pavankumar Kondetiaa449e12011-11-04 11:09:26 +0530221 struct timer_list id_timer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222 unsigned long caps;
223 /*
224 * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v
225 * analog regulators while going to low power mode.
226 * Currently only 8960(28nm PHY) has the support to allowing PHY
227 * power collapse since it doesn't have leakage currents while
228 * turning off the power rails.
229 */
230#define ALLOW_PHY_POWER_COLLAPSE BIT(0)
231 /*
232 * Allow PHY RETENTION mode before turning off the digital
233 * voltage regulator(VDDCX).
234 */
235#define ALLOW_PHY_RETENTION BIT(1)
236 /*
237 * Disable the OTG comparators to save more power
238 * if depends on PMIC for VBUS and ID interrupts.
239 */
240#define ALLOW_PHY_COMP_DISABLE BIT(2)
241 unsigned long lpm_flags;
242#define PHY_PWR_COLLAPSED BIT(0)
243#define PHY_RETENTIONED BIT(1)
244#define PHY_OTG_COMP_DISABLED BIT(2)
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530245};
246
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530247struct msm_hsic_host_platform_data {
248 unsigned strobe;
249 unsigned data;
Vijayavardhan Vennapusa2b592824f2011-11-02 19:51:32 +0530250 unsigned hub_reset;
Vijayavardhan Vennapusae3316a12011-10-15 06:05:17 +0530251};
252
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530253#endif