blob: b0a39243295a326665de913b38b6857c209e7a19 [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>
Ivan T. Ivanov5146d772013-12-30 13:15:27 -080023#include <linux/clk.h>
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053024
25/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +053026 * OTG control
27 *
28 * OTG_NO_CONTROL Id/VBUS notifications not required. Useful in host
29 * only configuration.
30 * OTG_PHY_CONTROL Id/VBUS notifications comes form USB PHY.
31 * OTG_PMIC_CONTROL Id/VBUS notifications comes from PMIC hardware.
32 * OTG_USER_CONTROL Id/VBUS notifcations comes from User via sysfs.
33 *
34 */
35enum otg_control_type {
36 OTG_NO_CONTROL = 0,
37 OTG_PHY_CONTROL,
38 OTG_PMIC_CONTROL,
39 OTG_USER_CONTROL,
40};
41
42/**
Pavankumar Kondetid8608522011-05-04 10:19:47 +053043 * PHY used in
44 *
45 * INVALID_PHY Unsupported PHY
46 * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
47 * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
48 *
49 */
50enum msm_usb_phy_type {
51 INVALID_PHY = 0,
52 CI_45NM_INTEGRATED_PHY,
53 SNPS_28NM_INTEGRATED_PHY,
54};
55
56#define IDEV_CHG_MAX 1500
57#define IUNIT 100
58
59/**
60 * Different states involved in USB charger detection.
61 *
62 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
63 * process is not yet started.
64 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
65 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
66 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
67 * between SDP and DCP/CDP).
68 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
69 * between DCP and CDP).
70 * USB_CHG_STATE_DETECTED USB charger type is determined.
71 *
72 */
73enum usb_chg_state {
74 USB_CHG_STATE_UNDEFINED = 0,
75 USB_CHG_STATE_WAIT_FOR_DCD,
76 USB_CHG_STATE_DCD_DONE,
77 USB_CHG_STATE_PRIMARY_DONE,
78 USB_CHG_STATE_SECONDARY_DONE,
79 USB_CHG_STATE_DETECTED,
80};
81
82/**
83 * USB charger types
84 *
85 * USB_INVALID_CHARGER Invalid USB charger.
86 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
87 * on USB2.0 compliant host/hub.
88 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
89 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
90 * IDEV_CHG_MAX can be drawn irrespective of USB state.
91 *
92 */
93enum usb_chg_type {
94 USB_INVALID_CHARGER = 0,
95 USB_SDP_CHARGER,
96 USB_DCP_CHARGER,
97 USB_CDP_CHARGER,
98};
99
100/**
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530101 * struct msm_otg_platform_data - platform device data
Pavankumar Kondetidfb21302011-03-04 22:45:02 +0530102 * for msm_otg driver.
Ivan T. Ivanov8364f9a2014-04-28 16:34:15 +0300103 * @phy_init_seq: PHY configuration sequence values. Value of -1 is reserved as
104 * "do not overwrite default vaule at this address".
105 * @phy_init_sz: PHY configuration sequence size.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530106 * @vbus_power: VBUS power on/off routine.
107 * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
108 * @mode: Supported mode (OTG/peripheral/host).
109 * @otg_control: OTG switch controlled by user/Id pin
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530110 */
111struct msm_otg_platform_data {
112 int *phy_init_seq;
Ivan T. Ivanov8364f9a2014-04-28 16:34:15 +0300113 int phy_init_sz;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530114 void (*vbus_power)(bool on);
115 unsigned power_budget;
Ivan T. Ivanov971232c2014-04-28 16:34:11 +0300116 enum usb_dr_mode mode;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530117 enum otg_control_type otg_control;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530118 enum msm_usb_phy_type phy_type;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530119 void (*setup_gpio)(enum usb_otg_state state);
Ivan T. Ivanov5146d772013-12-30 13:15:27 -0800120 int (*link_clk_reset)(struct clk *link_clk, bool assert);
121 int (*phy_clk_reset)(struct clk *phy_clk);
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530122};
123
124/**
125 * struct msm_otg: OTG driver data. Shared by HCD and DCD.
126 * @otg: USB OTG Transceiver structure.
127 * @pdata: otg device platform data.
128 * @irq: IRQ number assigned for HSUSB controller.
129 * @clk: clock struct of usb_hs_clk.
130 * @pclk: clock struct of usb_hs_pclk.
131 * @phy_reset_clk: clock struct of usb_phy_clk.
132 * @core_clk: clock struct of usb_hs_core_clk.
133 * @regs: ioremapped register base address.
134 * @inputs: OTG state machine inputs(Id, SessValid etc).
135 * @sm_work: OTG state machine work.
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530136 * @in_lpm: indicates low power mode (LPM) state.
137 * @async_int: Async interrupt arrived.
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530138 * @cur_power: The amount of mA available from downstream port.
139 * @chg_work: Charger detection work.
140 * @chg_state: The state of charger detection process.
141 * @chg_type: The type of charger attached.
142 * @dcd_retires: The retry count used to track Data contact
143 * detection process.
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530144 */
145struct msm_otg {
Heikki Krogerus1d4c9292012-02-13 13:24:09 +0200146 struct usb_phy phy;
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530147 struct msm_otg_platform_data *pdata;
148 int irq;
149 struct clk *clk;
150 struct clk *pclk;
151 struct clk *phy_reset_clk;
152 struct clk *core_clk;
153 void __iomem *regs;
154#define ID 0
155#define B_SESS_VLD 1
156 unsigned long inputs;
157 struct work_struct sm_work;
Pavankumar Kondeti87c01042010-12-07 17:53:58 +0530158 atomic_t in_lpm;
159 int async_int;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530160 unsigned cur_power;
Ivan T. Ivanovcfa3ff52014-04-28 16:34:17 +0300161 int phy_number;
Pavankumar Kondetid8608522011-05-04 10:19:47 +0530162 struct delayed_work chg_work;
163 enum usb_chg_state chg_state;
164 enum usb_chg_type chg_type;
165 u8 dcd_retries;
Ivan T. Ivanov37cfdaf2014-04-28 16:34:06 +0300166 struct regulator *v3p3;
167 struct regulator *v1p8;
168 struct regulator *vddcx;
Ivan T. Ivanova2734542014-04-28 16:34:16 +0300169
170 struct reset_control *phy_rst;
171 struct reset_control *link_rst;
Ivan T. Ivanov01799b62014-04-28 16:34:22 +0300172 int vdd_levels[3];
Pavankumar Kondetie0c201f2010-12-07 17:53:55 +0530173};
174
175#endif