blob: f5f890fa5dc7b5ff00bb6d036a0d4ffba518cbec [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* linux/include/mach/hsusb.h
2 *
3 * Copyright (C) 2008 Google, Inc.
Duy Truong790f06d2013-02-13 16:38:12 -08004 * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005 * Author: Brian Swetland <swetland@google.com>
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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070022#include <linux/pm_qos.h>
Ido Shayevitz9fb83452012-04-01 17:45:58 +030023#include <linux/usb/ch9.h>
24#include <linux/usb/gadget.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025
26#define PHY_TYPE_MASK 0x0F
27#define PHY_TYPE_MODE 0xF0
28#define PHY_MODEL_MASK 0xFF00
29#define PHY_TYPE(x) ((x) & PHY_TYPE_MASK)
30#define PHY_MODEL(x) ((x) & PHY_MODEL_MASK)
31
32#define USB_PHY_MODEL_65NM 0x100
33#define USB_PHY_MODEL_180NM 0x200
34#define USB_PHY_MODEL_45NM 0x400
35#define USB_PHY_UNDEFINED 0x00
36#define USB_PHY_INTEGRATED 0x01
37#define USB_PHY_EXTERNAL 0x02
38#define USB_PHY_SERIAL_PMIC 0x04
39
40#define REQUEST_STOP 0
41#define REQUEST_START 1
42#define REQUEST_RESUME 2
43#define REQUEST_HNP_SUSPEND 3
44#define REQUEST_HNP_RESUME 4
45
46/* Flags required to read ID state of PHY for ACA */
47#define PHY_ID_MASK 0xB0
48#define PHY_ID_GND 0
49#define PHY_ID_C 0x10
50#define PHY_ID_B 0x30
51#define PHY_ID_A 0x90
52
53#define phy_id_state(ints) ((ints) & PHY_ID_MASK)
Pavankumar Kondeti9e49ea92011-07-13 17:51:40 +053054#define phy_id_state_gnd(ints) (phy_id_state((ints)) == PHY_ID_GND)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#define phy_id_state_a(ints) (phy_id_state((ints)) == PHY_ID_A)
Pavankumar Kondeti9e49ea92011-07-13 17:51:40 +053056/* RID_B and RID_C states does not exist with standard ACA */
57#ifdef CONFIG_USB_MSM_STANDARD_ACA
58#define phy_id_state_b(ints) 0
59#define phy_id_state_c(ints) 0
60#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#define phy_id_state_b(ints) (phy_id_state((ints)) == PHY_ID_B)
62#define phy_id_state_c(ints) (phy_id_state((ints)) == PHY_ID_C)
Pavankumar Kondeti9e49ea92011-07-13 17:51:40 +053063#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064
Ido Shayevitzd1cb16c2012-03-28 18:57:47 +020065/*
66 * The following are bit fields describing the usb_request.udc_priv word.
67 * These bit fields are set by function drivers that wish to queue
68 * usb_requests with sps/bam parameters.
69 */
70#define MSM_PIPE_ID_MASK (0x1F)
71#define MSM_TX_PIPE_ID_OFS (16)
72#define MSM_SPS_MODE BIT(5)
73#define MSM_IS_FINITE_TRANSFER BIT(6)
74#define MSM_PRODUCER BIT(7)
75#define MSM_DISABLE_WB BIT(8)
76#define MSM_ETD_IOC BIT(9)
77#define MSM_INTERNAL_MEM BIT(10)
78#define MSM_VENDOR_ID BIT(16)
79
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080/* used to detect the OTG Mode */
81enum otg_mode {
82 OTG_ID = 0, /* ID pin detection */
83 OTG_USER_CONTROL, /* User configurable */
84 OTG_VCHG, /* Based on VCHG interrupt */
85};
86
87/* used to configure the default mode,if otg_mode is USER_CONTROL */
88enum usb_mode {
89 USB_HOST_MODE,
90 USB_PERIPHERAL_MODE,
91};
92
93enum chg_type {
94 USB_CHG_TYPE__SDP,
95 USB_CHG_TYPE__CARKIT,
96 USB_CHG_TYPE__WALLCHARGER,
97 USB_CHG_TYPE__INVALID
98};
99
100enum pre_emphasis_level {
101 PRE_EMPHASIS_DEFAULT,
102 PRE_EMPHASIS_DISABLE,
103 PRE_EMPHASIS_WITH_10_PERCENT = (1 << 5),
104 PRE_EMPHASIS_WITH_20_PERCENT = (3 << 4),
105};
106enum cdr_auto_reset {
107 CDR_AUTO_RESET_DEFAULT,
108 CDR_AUTO_RESET_ENABLE,
109 CDR_AUTO_RESET_DISABLE,
110};
111
112enum se1_gate_state {
113 SE1_GATING_DEFAULT,
114 SE1_GATING_ENABLE,
115 SE1_GATING_DISABLE,
116};
117
118enum hs_drv_amplitude {
119 HS_DRV_AMPLITUDE_DEFAULT,
120 HS_DRV_AMPLITUDE_ZERO_PERCENT,
121 HS_DRV_AMPLITUDE_25_PERCENTI = (1 << 2),
122 HS_DRV_AMPLITUDE_5_PERCENT = (1 << 3),
123 HS_DRV_AMPLITUDE_75_PERCENT = (3 << 2),
124};
125
126#define HS_DRV_SLOPE_DEFAULT (-1)
127
128/* used to configure the analog switch to select b/w host and peripheral */
129enum usb_switch_control {
130 USB_SWITCH_PERIPHERAL = 0, /* Configure switch in peripheral mode*/
131 USB_SWITCH_HOST, /* Host mode */
132 USB_SWITCH_DISABLE, /* No mode selected, shutdown power */
133};
134
135struct msm_hsusb_gadget_platform_data {
136 int *phy_init_seq;
137 void (*phy_reset)(void);
138
139 int self_powered;
140 int is_phy_status_timer_on;
Rajkumar Raghupathyc0e14a42012-09-17 16:35:47 +0530141 bool prop_chg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142};
143
144struct msm_otg_platform_data {
145 int (*rpc_connect)(int);
146 int (*phy_reset)(void __iomem *);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 int pmic_vbus_irq;
Anji jonnalaeb9e60d2011-10-05 12:19:46 +0530148 int pmic_id_irq;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149 /* if usb link is in sps there is no need for
150 * usb pclk as dayatona fabric clock will be
151 * used instead
152 */
153 int usb_in_sps;
154 enum pre_emphasis_level pemp_level;
155 enum cdr_auto_reset cdr_autoreset;
156 enum hs_drv_amplitude drv_ampl;
157 enum se1_gate_state se1_gating;
158 int hsdrvslope;
159 int phy_reset_sig_inverted;
160 int phy_can_powercollapse;
161 int pclk_required_during_lpm;
Chandra Devireddyb3fc78c2011-08-30 17:25:55 +0530162 int bam_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163 /* HSUSB core in 8660 has the capability to gate the
164 * pclk when not being used. Though this feature is
165 * now being disabled because of H/w issues
166 */
167 int pclk_is_hw_gated;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168
169 int (*ldo_init) (int init);
170 int (*ldo_enable) (int enable);
171 int (*ldo_set_voltage) (int mV);
172
173 u32 swfi_latency;
174 /* pmic notfications apis */
175 int (*pmic_vbus_notif_init) (void (*callback)(int online), int init);
176 int (*pmic_id_notif_init) (void (*callback)(int online), int init);
Anji jonnalaae745e92011-11-14 18:34:31 +0530177 int (*phy_id_setup_init) (int init);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178 int (*pmic_register_vbus_sn) (void (*callback)(int online));
179 void (*pmic_unregister_vbus_sn) (void (*callback)(int online));
180 int (*pmic_enable_ldo) (int);
181 int (*init_gpio)(int on);
182 void (*setup_gpio)(enum usb_switch_control mode);
183 u8 otg_mode;
184 u8 usb_mode;
185 void (*vbus_power) (unsigned phy_info, int on);
186
187 /* charger notification apis */
188 void (*chg_connected)(enum chg_type chg_type);
189 void (*chg_vbus_draw)(unsigned ma);
190 int (*chg_init)(int init);
191 int (*config_vddcx)(int high);
192 int (*init_vddcx)(int init);
193
Steve Mucklef132c6c2012-06-06 18:30:57 -0700194 struct pm_qos_request pm_qos_req_dma;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700195};
196
197struct msm_usb_host_platform_data {
198 unsigned phy_info;
199 unsigned int power_budget;
200 void (*config_gpio)(unsigned int config);
201 void (*vbus_power) (unsigned phy_info, int on);
202 int (*vbus_init)(int init);
203 struct clk *ebi1_clk;
204};
205
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700206#endif