aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/msm_hsusb.h
diff options
context:
space:
mode:
authorPavankumar Kondeti <pkondeti@codeaurora.org>2011-05-04 00:49:47 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-06 21:27:48 -0400
commitd860852e087eed7eadbea64f1a8db9a231c5e9b3 (patch)
tree792b7c6d3cfe769983929699bbd385e8985b668e /include/linux/usb/msm_hsusb.h
parent0f73cac8e41723d600c91a0f5b481dc3202f4f82 (diff)
USB: OTG: msm: Implement charger detection
Implement good battery algorithm defined in the battery charging V1.2 spec for detecting different charging ports. USB hardware is put into low power mode when connected to a dedicated charging port. vbus_draw and set_power methods are implemented for determining the allowed current from Host in different states (un-configured/suspend/configured). The charger block is implemented using vendor specific registers and the PHY used in MSM8960(28nm PHY) different from older targets like MSM8x60 and MSM7x30(45nm PHY). The PHY vendor and product id registers are not implemented in the above chipsets. Hence PHY type is passed via platform data. Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/usb/msm_hsusb.h')
-rw-r--r--include/linux/usb/msm_hsusb.h72
1 files changed, 71 insertions, 1 deletions
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 31ef1853f93c..00311fe9d0df 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright (C) 2008 Google, Inc. 3 * Copyright (C) 2008 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com> 4 * Author: Brian Swetland <swetland@google.com>
5 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved. 5 * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
6 * 6 *
7 * This software is licensed under the terms of the GNU General Public 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 8 * License version 2, as published by the Free Software Foundation, and
@@ -54,6 +54,64 @@ enum otg_control_type {
54}; 54};
55 55
56/** 56/**
57 * PHY used in
58 *
59 * INVALID_PHY Unsupported PHY
60 * CI_45NM_INTEGRATED_PHY Chipidea 45nm integrated PHY
61 * SNPS_28NM_INTEGRATED_PHY Synopsis 28nm integrated PHY
62 *
63 */
64enum msm_usb_phy_type {
65 INVALID_PHY = 0,
66 CI_45NM_INTEGRATED_PHY,
67 SNPS_28NM_INTEGRATED_PHY,
68};
69
70#define IDEV_CHG_MAX 1500
71#define IUNIT 100
72
73/**
74 * Different states involved in USB charger detection.
75 *
76 * USB_CHG_STATE_UNDEFINED USB charger is not connected or detection
77 * process is not yet started.
78 * USB_CHG_STATE_WAIT_FOR_DCD Waiting for Data pins contact.
79 * USB_CHG_STATE_DCD_DONE Data pin contact is detected.
80 * USB_CHG_STATE_PRIMARY_DONE Primary detection is completed (Detects
81 * between SDP and DCP/CDP).
82 * USB_CHG_STATE_SECONDARY_DONE Secondary detection is completed (Detects
83 * between DCP and CDP).
84 * USB_CHG_STATE_DETECTED USB charger type is determined.
85 *
86 */
87enum usb_chg_state {
88 USB_CHG_STATE_UNDEFINED = 0,
89 USB_CHG_STATE_WAIT_FOR_DCD,
90 USB_CHG_STATE_DCD_DONE,
91 USB_CHG_STATE_PRIMARY_DONE,
92 USB_CHG_STATE_SECONDARY_DONE,
93 USB_CHG_STATE_DETECTED,
94};
95
96/**
97 * USB charger types
98 *
99 * USB_INVALID_CHARGER Invalid USB charger.
100 * USB_SDP_CHARGER Standard downstream port. Refers to a downstream port
101 * on USB2.0 compliant host/hub.
102 * USB_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
103 * USB_CDP_CHARGER Charging downstream port. Enumeration can happen and
104 * IDEV_CHG_MAX can be drawn irrespective of USB state.
105 *
106 */
107enum usb_chg_type {
108 USB_INVALID_CHARGER = 0,
109 USB_SDP_CHARGER,
110 USB_DCP_CHARGER,
111 USB_CDP_CHARGER,
112};
113
114/**
57 * struct msm_otg_platform_data - platform device data 115 * struct msm_otg_platform_data - platform device data
58 * for msm_otg driver. 116 * for msm_otg driver.
59 * @phy_init_seq: PHY configuration sequence. val, reg pairs 117 * @phy_init_seq: PHY configuration sequence. val, reg pairs
@@ -74,6 +132,7 @@ struct msm_otg_platform_data {
74 enum usb_mode_type mode; 132 enum usb_mode_type mode;
75 enum otg_control_type otg_control; 133 enum otg_control_type otg_control;
76 enum usb_mode_type default_mode; 134 enum usb_mode_type default_mode;
135 enum msm_usb_phy_type phy_type;
77 void (*setup_gpio)(enum usb_otg_state state); 136 void (*setup_gpio)(enum usb_otg_state state);
78 char *pclk_src_name; 137 char *pclk_src_name;
79}; 138};
@@ -93,6 +152,12 @@ struct msm_otg_platform_data {
93 * @sm_work: OTG state machine work. 152 * @sm_work: OTG state machine work.
94 * @in_lpm: indicates low power mode (LPM) state. 153 * @in_lpm: indicates low power mode (LPM) state.
95 * @async_int: Async interrupt arrived. 154 * @async_int: Async interrupt arrived.
155 * @cur_power: The amount of mA available from downstream port.
156 * @chg_work: Charger detection work.
157 * @chg_state: The state of charger detection process.
158 * @chg_type: The type of charger attached.
159 * @dcd_retires: The retry count used to track Data contact
160 * detection process.
96 */ 161 */
97struct msm_otg { 162struct msm_otg {
98 struct otg_transceiver otg; 163 struct otg_transceiver otg;
@@ -110,6 +175,11 @@ struct msm_otg {
110 struct work_struct sm_work; 175 struct work_struct sm_work;
111 atomic_t in_lpm; 176 atomic_t in_lpm;
112 int async_int; 177 int async_int;
178 unsigned cur_power;
179 struct delayed_work chg_work;
180 enum usb_chg_state chg_state;
181 enum usb_chg_type chg_type;
182 u8 dcd_retries;
113}; 183};
114 184
115#endif 185#endif