Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1 | /* ehci-msm-hsic.c - HSUSB Host Controller Driver Implementation |
| 2 | * |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 3 | * Copyright (c) 2011-2013, Linux Foundation. All rights reserved. |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 4 | * |
| 5 | * Partly derived from ehci-fsl.c and ehci-hcd.c |
| 6 | * Copyright (c) 2000-2004 by David Brownell |
| 7 | * Copyright (c) 2005 MontaVista Software |
| 8 | * |
| 9 | * All source code in this file is licensed under the following license except |
| 10 | * where indicated. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License version 2 as published |
| 14 | * by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 19 | * |
| 20 | * See the GNU General Public License for more details. |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, you can find it at http://www.fsf.org |
| 23 | */ |
| 24 | |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/clk.h> |
| 27 | #include <linux/err.h> |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 28 | #include <linux/debugfs.h> |
| 29 | #include <linux/seq_file.h> |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 30 | #include <linux/wakelock.h> |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 31 | #include <linux/pm_runtime.h> |
| 32 | #include <linux/regulator/consumer.h> |
| 33 | |
| 34 | #include <linux/usb/msm_hsusb_hw.h> |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 35 | #include <linux/usb/msm_hsusb.h> |
| 36 | #include <linux/gpio.h> |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 37 | #include <linux/spinlock.h> |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 38 | #include <linux/kthread.h> |
| 39 | #include <linux/wait.h> |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 40 | #include <linux/pm_qos.h> |
Hemant Kumar | 5e38663 | 2012-08-30 14:23:38 -0700 | [diff] [blame] | 41 | #include <linux/irq.h> |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 42 | |
| 43 | #include <mach/msm_bus.h> |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 44 | #include <mach/clk.h> |
| 45 | #include <mach/msm_iomap.h> |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 46 | #include <mach/msm_xo.h> |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 47 | #include <linux/spinlock.h> |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 48 | #include <linux/cpu.h> |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 49 | #include <mach/rpm-regulator.h> |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 50 | |
| 51 | #define MSM_USB_BASE (hcd->regs) |
Hemant Kumar | 105d07f | 2012-07-02 15:33:07 -0700 | [diff] [blame] | 52 | #define USB_REG_START_OFFSET 0x90 |
| 53 | #define USB_REG_END_OFFSET 0x250 |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 54 | |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 55 | static struct workqueue_struct *ehci_wq; |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 56 | struct ehci_timer { |
| 57 | #define GPT_LD(p) ((p) & 0x00FFFFFF) |
| 58 | u32 gptimer0_ld; |
| 59 | #define GPT_RUN BIT(31) |
| 60 | #define GPT_RESET BIT(30) |
| 61 | #define GPT_MODE BIT(24) |
| 62 | #define GPT_CNT(p) ((p) & 0x00FFFFFF) |
| 63 | u32 gptimer0_ctrl; |
| 64 | |
| 65 | u32 gptimer1_ld; |
| 66 | u32 gptimer1_ctrl; |
| 67 | }; |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 68 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 69 | struct msm_hsic_hcd { |
| 70 | struct ehci_hcd ehci; |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 71 | spinlock_t wakeup_lock; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 72 | struct device *dev; |
| 73 | struct clk *ahb_clk; |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 74 | struct clk *core_clk; |
| 75 | struct clk *alt_core_clk; |
| 76 | struct clk *phy_clk; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 77 | struct clk *cal_clk; |
| 78 | struct regulator *hsic_vddcx; |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 79 | atomic_t async_int; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 80 | atomic_t in_lpm; |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 81 | struct wake_lock wlock; |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 82 | int peripheral_status_irq; |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 83 | int wakeup_irq; |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 84 | int wakeup_gpio; |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 85 | bool wakeup_irq_enabled; |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 86 | atomic_t pm_usage_cnt; |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 87 | uint32_t bus_perf_client; |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 88 | uint32_t wakeup_int_cnt; |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 89 | enum usb_vdd_type vdd_type; |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 90 | |
| 91 | struct work_struct bus_vote_w; |
| 92 | bool bus_vote; |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 93 | |
| 94 | /* gp timer */ |
| 95 | struct ehci_timer __iomem *timer; |
| 96 | struct completion gpt0_completion; |
| 97 | struct completion rt_completion; |
| 98 | int resume_status; |
| 99 | int resume_again; |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 100 | int bus_reset; |
| 101 | int reset_again; |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 102 | |
| 103 | struct pm_qos_request pm_qos_req_dma; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 104 | }; |
| 105 | |
Hemant Kumar | 105d07f | 2012-07-02 15:33:07 -0700 | [diff] [blame] | 106 | struct msm_hsic_hcd *__mehci; |
| 107 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 108 | static bool debug_bus_voting_enabled = true; |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 109 | |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 110 | static unsigned int enable_payload_log = 1; |
| 111 | module_param(enable_payload_log, uint, S_IRUGO | S_IWUSR); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 112 | static unsigned int enable_dbg_log = 1; |
| 113 | module_param(enable_dbg_log, uint, S_IRUGO | S_IWUSR); |
| 114 | /*by default log ep0 and efs sync ep*/ |
| 115 | static unsigned int ep_addr_rxdbg_mask = 9; |
| 116 | module_param(ep_addr_rxdbg_mask, uint, S_IRUGO | S_IWUSR); |
| 117 | static unsigned int ep_addr_txdbg_mask = 9; |
| 118 | module_param(ep_addr_txdbg_mask, uint, S_IRUGO | S_IWUSR); |
| 119 | |
| 120 | /* Maximum debug message length */ |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 121 | #define DBG_MSG_LEN 128UL |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 122 | |
| 123 | /* Maximum number of messages */ |
| 124 | #define DBG_MAX_MSG 256UL |
| 125 | |
| 126 | #define TIME_BUF_LEN 20 |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 127 | #define HEX_DUMP_LEN 72 |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 128 | |
| 129 | enum event_type { |
| 130 | EVENT_UNDEF = -1, |
| 131 | URB_SUBMIT, |
| 132 | URB_COMPLETE, |
| 133 | EVENT_NONE, |
| 134 | }; |
| 135 | |
| 136 | #define EVENT_STR_LEN 5 |
| 137 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 138 | static enum event_type str_to_event(const char *name) |
| 139 | { |
| 140 | if (!strncasecmp("S", name, EVENT_STR_LEN)) |
| 141 | return URB_SUBMIT; |
| 142 | if (!strncasecmp("C", name, EVENT_STR_LEN)) |
| 143 | return URB_COMPLETE; |
| 144 | if (!strncasecmp("", name, EVENT_STR_LEN)) |
| 145 | return EVENT_NONE; |
| 146 | |
| 147 | return EVENT_UNDEF; |
| 148 | } |
| 149 | |
| 150 | /*log ep0 activity*/ |
| 151 | static struct { |
| 152 | char (buf[DBG_MAX_MSG])[DBG_MSG_LEN]; /* buffer */ |
| 153 | unsigned idx; /* index */ |
| 154 | rwlock_t lck; /* lock */ |
| 155 | } dbg_hsic_ctrl = { |
| 156 | .idx = 0, |
| 157 | .lck = __RW_LOCK_UNLOCKED(lck) |
| 158 | }; |
| 159 | |
| 160 | static struct { |
| 161 | char (buf[DBG_MAX_MSG])[DBG_MSG_LEN]; /* buffer */ |
| 162 | unsigned idx; /* index */ |
| 163 | rwlock_t lck; /* lock */ |
| 164 | } dbg_hsic_data = { |
| 165 | .idx = 0, |
| 166 | .lck = __RW_LOCK_UNLOCKED(lck) |
| 167 | }; |
| 168 | |
| 169 | /** |
| 170 | * dbg_inc: increments debug event index |
| 171 | * @idx: buffer index |
| 172 | */ |
| 173 | static void dbg_inc(unsigned *idx) |
| 174 | { |
| 175 | *idx = (*idx + 1) & (DBG_MAX_MSG-1); |
| 176 | } |
| 177 | |
| 178 | /*get_timestamp - returns time of day in us */ |
| 179 | static char *get_timestamp(char *tbuf) |
| 180 | { |
| 181 | unsigned long long t; |
| 182 | unsigned long nanosec_rem; |
| 183 | |
| 184 | t = cpu_clock(smp_processor_id()); |
| 185 | nanosec_rem = do_div(t, 1000000000)/1000; |
| 186 | scnprintf(tbuf, TIME_BUF_LEN, "[%5lu.%06lu] ", (unsigned long)t, |
| 187 | nanosec_rem); |
| 188 | return tbuf; |
| 189 | } |
| 190 | |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 191 | static int allow_dbg_log(struct urb *urb, int ep_addr) |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 192 | { |
| 193 | int dir, num; |
| 194 | |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 195 | dir = usb_urb_dir_in(urb) ? USB_DIR_IN : USB_DIR_OUT; |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 196 | num = ep_addr & ~USB_DIR_IN; |
| 197 | num = 1 << num; |
| 198 | |
| 199 | if ((dir == USB_DIR_IN) && (num & ep_addr_rxdbg_mask)) |
| 200 | return 1; |
| 201 | if ((dir == USB_DIR_OUT) && (num & ep_addr_txdbg_mask)) |
| 202 | return 1; |
| 203 | |
| 204 | return 0; |
| 205 | } |
| 206 | |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 207 | static char * |
| 208 | get_hex_data(char *dbuf, struct urb *urb, int event, int status, size_t max_len) |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 209 | { |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 210 | char *ubuf = urb->transfer_buffer; |
| 211 | size_t len = event ? \ |
| 212 | urb->actual_length : urb->transfer_buffer_length; |
| 213 | |
| 214 | if (status == -EINPROGRESS) |
| 215 | status = 0; |
| 216 | |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 217 | /*Only dump ep in successful completions and epout submissions*/ |
| 218 | if (len && !status && ((usb_urb_dir_in(urb) && event) || |
| 219 | (usb_urb_dir_out(urb) && !event))) { |
| 220 | if (len >= max_len) |
| 221 | len = max_len; |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 222 | hex_dump_to_buffer(ubuf, len, 32, 4, dbuf, HEX_DUMP_LEN, 0); |
| 223 | } else { |
| 224 | dbuf = ""; |
| 225 | } |
| 226 | |
| 227 | return dbuf; |
| 228 | } |
| 229 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 230 | static void dbg_log_event(struct urb *urb, char * event, unsigned extra) |
| 231 | { |
| 232 | unsigned long flags; |
| 233 | int ep_addr; |
| 234 | char tbuf[TIME_BUF_LEN]; |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 235 | char dbuf[HEX_DUMP_LEN]; |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 236 | |
| 237 | if (!enable_dbg_log) |
| 238 | return; |
| 239 | |
| 240 | if (!urb) { |
| 241 | write_lock_irqsave(&dbg_hsic_ctrl.lck, flags); |
| 242 | scnprintf(dbg_hsic_ctrl.buf[dbg_hsic_ctrl.idx], DBG_MSG_LEN, |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 243 | "%s: %s : %u", get_timestamp(tbuf), event, extra); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 244 | dbg_inc(&dbg_hsic_ctrl.idx); |
| 245 | write_unlock_irqrestore(&dbg_hsic_ctrl.lck, flags); |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | ep_addr = urb->ep->desc.bEndpointAddress; |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 250 | if (!allow_dbg_log(urb, ep_addr)) |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 251 | return; |
| 252 | |
| 253 | if ((ep_addr & 0x0f) == 0x0) { |
| 254 | /*submit event*/ |
| 255 | if (!str_to_event(event)) { |
| 256 | write_lock_irqsave(&dbg_hsic_ctrl.lck, flags); |
| 257 | scnprintf(dbg_hsic_ctrl.buf[dbg_hsic_ctrl.idx], |
| 258 | DBG_MSG_LEN, "%s: [%s : %p]:[%s] " |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 259 | "%02x %02x %04x %04x %04x %u %d %s", |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 260 | get_timestamp(tbuf), event, urb, |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 261 | usb_urb_dir_in(urb) ? "in" : "out", |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 262 | urb->setup_packet[0], urb->setup_packet[1], |
| 263 | (urb->setup_packet[3] << 8) | |
| 264 | urb->setup_packet[2], |
| 265 | (urb->setup_packet[5] << 8) | |
| 266 | urb->setup_packet[4], |
| 267 | (urb->setup_packet[7] << 8) | |
| 268 | urb->setup_packet[6], |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 269 | urb->transfer_buffer_length, extra, |
| 270 | enable_payload_log ? get_hex_data(dbuf, urb, |
| 271 | str_to_event(event), extra, 16) : ""); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 272 | |
| 273 | dbg_inc(&dbg_hsic_ctrl.idx); |
| 274 | write_unlock_irqrestore(&dbg_hsic_ctrl.lck, flags); |
| 275 | } else { |
| 276 | write_lock_irqsave(&dbg_hsic_ctrl.lck, flags); |
| 277 | scnprintf(dbg_hsic_ctrl.buf[dbg_hsic_ctrl.idx], |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 278 | DBG_MSG_LEN, "%s: [%s : %p]:[%s] %u %d %s", |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 279 | get_timestamp(tbuf), event, urb, |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 280 | usb_urb_dir_in(urb) ? "in" : "out", |
| 281 | urb->actual_length, extra, |
| 282 | enable_payload_log ? get_hex_data(dbuf, urb, |
| 283 | str_to_event(event), extra, 16) : ""); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 284 | |
| 285 | dbg_inc(&dbg_hsic_ctrl.idx); |
| 286 | write_unlock_irqrestore(&dbg_hsic_ctrl.lck, flags); |
| 287 | } |
| 288 | } else { |
| 289 | write_lock_irqsave(&dbg_hsic_data.lck, flags); |
| 290 | scnprintf(dbg_hsic_data.buf[dbg_hsic_data.idx], DBG_MSG_LEN, |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 291 | "%s: [%s : %p]:ep%d[%s] %u %d %s", |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 292 | get_timestamp(tbuf), event, urb, ep_addr & 0x0f, |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 293 | usb_urb_dir_in(urb) ? "in" : "out", |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 294 | str_to_event(event) ? urb->actual_length : |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 295 | urb->transfer_buffer_length, extra, |
| 296 | enable_payload_log ? get_hex_data(dbuf, urb, |
Pavankumar Kondeti | a2953ed | 2013-03-22 15:26:50 +0530 | [diff] [blame] | 297 | str_to_event(event), extra, 32) : ""); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 298 | |
| 299 | dbg_inc(&dbg_hsic_data.idx); |
| 300 | write_unlock_irqrestore(&dbg_hsic_data.lck, flags); |
| 301 | } |
| 302 | } |
| 303 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 304 | static inline struct msm_hsic_hcd *hcd_to_hsic(struct usb_hcd *hcd) |
| 305 | { |
| 306 | return (struct msm_hsic_hcd *) (hcd->hcd_priv); |
| 307 | } |
| 308 | |
| 309 | static inline struct usb_hcd *hsic_to_hcd(struct msm_hsic_hcd *mehci) |
| 310 | { |
| 311 | return container_of((void *) mehci, struct usb_hcd, hcd_priv); |
| 312 | } |
| 313 | |
Hemant Kumar | 105d07f | 2012-07-02 15:33:07 -0700 | [diff] [blame] | 314 | static void dump_hsic_regs(struct usb_hcd *hcd) |
| 315 | { |
| 316 | int i; |
| 317 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 318 | |
| 319 | if (atomic_read(&mehci->in_lpm)) |
| 320 | return; |
| 321 | |
| 322 | for (i = USB_REG_START_OFFSET; i <= USB_REG_END_OFFSET; i += 0x10) |
| 323 | pr_info("%p: %08x\t%08x\t%08x\t%08x\n", hcd->regs + i, |
| 324 | readl_relaxed(hcd->regs + i), |
| 325 | readl_relaxed(hcd->regs + i + 4), |
| 326 | readl_relaxed(hcd->regs + i + 8), |
| 327 | readl_relaxed(hcd->regs + i + 0xc)); |
| 328 | } |
| 329 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 330 | #define ULPI_IO_TIMEOUT_USEC (10 * 1000) |
| 331 | |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 332 | #define USB_PHY_VDD_DIG_VOL_NONE 0 /*uV */ |
Hemant Kumar | 266d9d5 | 2012-10-17 13:48:10 -0700 | [diff] [blame] | 333 | #define USB_PHY_VDD_DIG_VOL_MIN 945000 /* uV */ |
Vamsi Krishna | 45d88fa | 2011-11-02 13:28:42 -0700 | [diff] [blame] | 334 | #define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */ |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 335 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 336 | #define HSIC_DBG1_REG 0x38 |
| 337 | |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 338 | static const int vdd_val[VDD_TYPE_MAX][VDD_VAL_MAX] = { |
| 339 | { /* VDD_CX CORNER Voting */ |
| 340 | [VDD_NONE] = RPM_VREG_CORNER_NONE, |
| 341 | [VDD_MIN] = RPM_VREG_CORNER_NOMINAL, |
| 342 | [VDD_MAX] = RPM_VREG_CORNER_HIGH, |
| 343 | }, |
| 344 | { /* VDD_CX Voltage Voting */ |
| 345 | [VDD_NONE] = USB_PHY_VDD_DIG_VOL_NONE, |
| 346 | [VDD_MIN] = USB_PHY_VDD_DIG_VOL_MIN, |
| 347 | [VDD_MAX] = USB_PHY_VDD_DIG_VOL_MAX, |
| 348 | }, |
| 349 | }; |
| 350 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 351 | static int msm_hsic_init_vddcx(struct msm_hsic_hcd *mehci, int init) |
| 352 | { |
| 353 | int ret = 0; |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 354 | int none_vol, min_vol, max_vol; |
| 355 | |
| 356 | if (!mehci->hsic_vddcx) { |
| 357 | mehci->vdd_type = VDDCX_CORNER; |
| 358 | mehci->hsic_vddcx = devm_regulator_get(mehci->dev, |
| 359 | "hsic_vdd_dig"); |
| 360 | if (IS_ERR(mehci->hsic_vddcx)) { |
| 361 | mehci->hsic_vddcx = devm_regulator_get(mehci->dev, |
| 362 | "HSIC_VDDCX"); |
| 363 | if (IS_ERR(mehci->hsic_vddcx)) { |
| 364 | dev_err(mehci->dev, "unable to get hsic vddcx\n"); |
| 365 | return PTR_ERR(mehci->hsic_vddcx); |
| 366 | } |
| 367 | mehci->vdd_type = VDDCX; |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | none_vol = vdd_val[mehci->vdd_type][VDD_NONE]; |
| 372 | min_vol = vdd_val[mehci->vdd_type][VDD_MIN]; |
| 373 | max_vol = vdd_val[mehci->vdd_type][VDD_MAX]; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 374 | |
| 375 | if (!init) |
| 376 | goto disable_reg; |
| 377 | |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 378 | ret = regulator_set_voltage(mehci->hsic_vddcx, min_vol, max_vol); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 379 | if (ret) { |
| 380 | dev_err(mehci->dev, "unable to set the voltage" |
| 381 | "for hsic vddcx\n"); |
Mayank Rana | 189ac05 | 2012-03-24 04:35:02 +0530 | [diff] [blame] | 382 | return ret; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 383 | } |
| 384 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 385 | ret = regulator_enable(mehci->hsic_vddcx); |
| 386 | if (ret) { |
| 387 | dev_err(mehci->dev, "unable to enable hsic vddcx\n"); |
| 388 | goto reg_enable_err; |
| 389 | } |
| 390 | |
| 391 | return 0; |
| 392 | |
| 393 | disable_reg: |
| 394 | regulator_disable(mehci->hsic_vddcx); |
| 395 | reg_enable_err: |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 396 | regulator_set_voltage(mehci->hsic_vddcx, none_vol, max_vol); |
| 397 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 398 | return ret; |
| 399 | |
| 400 | } |
| 401 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 402 | static int __maybe_unused ulpi_read(struct msm_hsic_hcd *mehci, u32 reg) |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 403 | { |
| 404 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
Devin Kim | 01e5a5b | 2012-08-30 02:52:45 -0700 | [diff] [blame] | 405 | int cnt = 0; |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 406 | |
| 407 | /* initiate read operation */ |
| 408 | writel_relaxed(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg), |
| 409 | USB_ULPI_VIEWPORT); |
| 410 | |
| 411 | /* wait for completion */ |
Devin Kim | 01e5a5b | 2012-08-30 02:52:45 -0700 | [diff] [blame] | 412 | while (cnt < ULPI_IO_TIMEOUT_USEC) { |
| 413 | if (!(readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_RUN)) |
| 414 | break; |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 415 | udelay(1); |
Devin Kim | 01e5a5b | 2012-08-30 02:52:45 -0700 | [diff] [blame] | 416 | cnt++; |
| 417 | } |
| 418 | |
| 419 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { |
| 420 | dev_err(mehci->dev, "ulpi_read: timeout ULPI_VIEWPORT: %08x\n", |
| 421 | readl_relaxed(USB_ULPI_VIEWPORT)); |
| 422 | dev_err(mehci->dev, "PORTSC: %08x USBCMD: %08x FRINDEX: %08x\n", |
| 423 | readl_relaxed(USB_PORTSC), |
| 424 | readl_relaxed(USB_USBCMD), |
| 425 | readl_relaxed(USB_FRINDEX)); |
| 426 | |
| 427 | /*frame counter increments afte 125us*/ |
| 428 | udelay(130); |
| 429 | dev_err(mehci->dev, "ulpi_read: FRINDEX: %08x\n", |
| 430 | readl_relaxed(USB_FRINDEX)); |
| 431 | return -ETIMEDOUT; |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | return ULPI_DATA_READ(readl_relaxed(USB_ULPI_VIEWPORT)); |
| 435 | } |
| 436 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 437 | static int ulpi_write(struct msm_hsic_hcd *mehci, u32 val, u32 reg) |
| 438 | { |
| 439 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
| 440 | int cnt = 0; |
| 441 | |
| 442 | /* initiate write operation */ |
| 443 | writel_relaxed(ULPI_RUN | ULPI_WRITE | |
| 444 | ULPI_ADDR(reg) | ULPI_DATA(val), |
| 445 | USB_ULPI_VIEWPORT); |
| 446 | |
| 447 | /* wait for completion */ |
| 448 | while (cnt < ULPI_IO_TIMEOUT_USEC) { |
| 449 | if (!(readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_RUN)) |
| 450 | break; |
| 451 | udelay(1); |
| 452 | cnt++; |
| 453 | } |
| 454 | |
| 455 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { |
Devin Kim | 01e5a5b | 2012-08-30 02:52:45 -0700 | [diff] [blame] | 456 | dev_err(mehci->dev, "ulpi_write: timeout ULPI_VIEWPORT: %08x\n", |
| 457 | readl_relaxed(USB_ULPI_VIEWPORT)); |
| 458 | dev_err(mehci->dev, "PORTSC: %08x USBCMD: %08x FRINDEX: %08x\n", |
| 459 | readl_relaxed(USB_PORTSC), |
| 460 | readl_relaxed(USB_USBCMD), |
| 461 | readl_relaxed(USB_FRINDEX)); |
| 462 | |
| 463 | /*frame counter increments afte 125us*/ |
| 464 | udelay(130); |
| 465 | dev_err(mehci->dev, "ulpi_write: FRINDEX: %08x\n", |
| 466 | readl_relaxed(USB_FRINDEX)); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 467 | return -ETIMEDOUT; |
| 468 | } |
| 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 473 | static int msm_hsic_config_gpios(struct msm_hsic_hcd *mehci, int gpio_en) |
| 474 | { |
| 475 | int rc = 0; |
| 476 | struct msm_hsic_host_platform_data *pdata; |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 477 | static int gpio_status; |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 478 | |
| 479 | pdata = mehci->dev->platform_data; |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 480 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 481 | if (!pdata || !pdata->strobe || !pdata->data) |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 482 | return rc; |
| 483 | |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 484 | if (gpio_status == gpio_en) |
| 485 | return 0; |
| 486 | |
| 487 | gpio_status = gpio_en; |
| 488 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 489 | if (!gpio_en) |
| 490 | goto free_gpio; |
| 491 | |
| 492 | rc = gpio_request(pdata->strobe, "HSIC_STROBE_GPIO"); |
| 493 | if (rc < 0) { |
| 494 | dev_err(mehci->dev, "gpio request failed for HSIC STROBE\n"); |
| 495 | return rc; |
| 496 | } |
| 497 | |
| 498 | rc = gpio_request(pdata->data, "HSIC_DATA_GPIO"); |
| 499 | if (rc < 0) { |
| 500 | dev_err(mehci->dev, "gpio request failed for HSIC DATA\n"); |
| 501 | goto free_strobe; |
| 502 | } |
| 503 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 504 | if (mehci->wakeup_gpio) { |
| 505 | rc = gpio_request(mehci->wakeup_gpio, "HSIC_WAKEUP_GPIO"); |
| 506 | if (rc < 0) { |
| 507 | dev_err(mehci->dev, "gpio request failed for HSIC WAKEUP\n"); |
| 508 | goto free_data; |
| 509 | } |
| 510 | } |
| 511 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 512 | return 0; |
| 513 | |
| 514 | free_gpio: |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 515 | if (mehci->wakeup_gpio) |
| 516 | gpio_free(mehci->wakeup_gpio); |
| 517 | free_data: |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 518 | gpio_free(pdata->data); |
| 519 | free_strobe: |
| 520 | gpio_free(pdata->strobe); |
| 521 | |
| 522 | return rc; |
| 523 | } |
| 524 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 525 | static void msm_hsic_clk_reset(struct msm_hsic_hcd *mehci) |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 526 | { |
| 527 | int ret; |
| 528 | |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 529 | ret = clk_reset(mehci->core_clk, CLK_RESET_ASSERT); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 530 | if (ret) { |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 531 | dev_err(mehci->dev, "hsic clk assert failed:%d\n", ret); |
| 532 | return; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 533 | } |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 534 | clk_disable(mehci->core_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 535 | |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 536 | ret = clk_reset(mehci->core_clk, CLK_RESET_DEASSERT); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 537 | if (ret) |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 538 | dev_err(mehci->dev, "hsic clk deassert failed:%d\n", ret); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 539 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 540 | usleep_range(10000, 12000); |
| 541 | |
| 542 | clk_enable(mehci->core_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 543 | } |
| 544 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 545 | #define HSIC_STROBE_GPIO_PAD_CTL (MSM_TLMM_BASE+0x20C0) |
| 546 | #define HSIC_DATA_GPIO_PAD_CTL (MSM_TLMM_BASE+0x20C4) |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 547 | #define HSIC_CAL_PAD_CTL (MSM_TLMM_BASE+0x20C8) |
| 548 | #define HSIC_LV_MODE 0x04 |
| 549 | #define HSIC_PAD_CALIBRATION 0xA8 |
| 550 | #define HSIC_GPIO_PAD_VAL 0x0A0AAA10 |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 551 | #define LINK_RESET_TIMEOUT_USEC (250 * 1000) |
| 552 | static int msm_hsic_reset(struct msm_hsic_hcd *mehci) |
| 553 | { |
| 554 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 555 | int ret; |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 556 | struct msm_hsic_host_platform_data *pdata = mehci->dev->platform_data; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 557 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 558 | msm_hsic_clk_reset(mehci); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 559 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 560 | /* select ulpi phy */ |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 561 | writel_relaxed(0x80000000, USB_PORTSC); |
| 562 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 563 | mb(); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 564 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 565 | /* HSIC init sequence when HSIC signals (Strobe/Data) are |
| 566 | routed via GPIOs */ |
| 567 | if (pdata && pdata->strobe && pdata->data) { |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 568 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 569 | /* Enable LV_MODE in HSIC_CAL_PAD_CTL register */ |
| 570 | writel_relaxed(HSIC_LV_MODE, HSIC_CAL_PAD_CTL); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 571 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 572 | mb(); |
| 573 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 574 | /*set periodic calibration interval to ~2.048sec in |
| 575 | HSIC_IO_CAL_REG */ |
| 576 | ulpi_write(mehci, 0xFF, 0x33); |
| 577 | |
| 578 | /* Enable periodic IO calibration in HSIC_CFG register */ |
| 579 | ulpi_write(mehci, HSIC_PAD_CALIBRATION, 0x30); |
| 580 | |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 581 | /* Configure GPIO pins for HSIC functionality mode */ |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 582 | ret = msm_hsic_config_gpios(mehci, 1); |
| 583 | if (ret) { |
| 584 | dev_err(mehci->dev, " gpio configuarion failed\n"); |
| 585 | return ret; |
| 586 | } |
Vamsi Krishna | 64b4861 | 2012-06-14 16:08:11 -0700 | [diff] [blame] | 587 | /* Set LV_MODE=0x1 and DCC=0x2 in HSIC_GPIO PAD_CTL register */ |
| 588 | writel_relaxed(HSIC_GPIO_PAD_VAL, HSIC_STROBE_GPIO_PAD_CTL); |
| 589 | writel_relaxed(HSIC_GPIO_PAD_VAL, HSIC_DATA_GPIO_PAD_CTL); |
| 590 | |
| 591 | mb(); |
| 592 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 593 | /* Enable HSIC mode in HSIC_CFG register */ |
| 594 | ulpi_write(mehci, 0x01, 0x31); |
| 595 | } else { |
| 596 | /* HSIC init sequence when HSIC signals (Strobe/Data) are routed |
| 597 | via dedicated I/O */ |
| 598 | |
| 599 | /* programmable length of connect signaling (33.2ns) */ |
| 600 | ret = ulpi_write(mehci, 3, HSIC_DBG1_REG); |
| 601 | if (ret) { |
| 602 | pr_err("%s: Unable to program length of connect " |
| 603 | "signaling\n", __func__); |
| 604 | } |
| 605 | |
| 606 | /*set periodic calibration interval to ~2.048sec in |
| 607 | HSIC_IO_CAL_REG */ |
| 608 | ulpi_write(mehci, 0xFF, 0x33); |
| 609 | |
| 610 | /* Enable HSIC mode in HSIC_CFG register */ |
| 611 | ulpi_write(mehci, 0xA9, 0x30); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 612 | } |
| 613 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 614 | /*disable auto resume*/ |
| 615 | ulpi_write(mehci, ULPI_IFC_CTRL_AUTORESUME, ULPI_CLR(ULPI_IFC_CTRL)); |
| 616 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | #define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000) |
| 621 | #define PHY_RESUME_TIMEOUT_USEC (100 * 1000) |
| 622 | |
| 623 | #ifdef CONFIG_PM_SLEEP |
| 624 | static int msm_hsic_suspend(struct msm_hsic_hcd *mehci) |
| 625 | { |
| 626 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 627 | int cnt = 0, ret; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 628 | u32 val; |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 629 | int none_vol, max_vol; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 630 | |
| 631 | if (atomic_read(&mehci->in_lpm)) { |
| 632 | dev_dbg(mehci->dev, "%s called in lpm\n", __func__); |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | disable_irq(hcd->irq); |
Jack Pham | be05fbb | 2012-05-16 10:56:26 -0700 | [diff] [blame] | 637 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 638 | /* make sure we don't race against a remote wakeup */ |
| 639 | if (test_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags) || |
Jack Pham | be05fbb | 2012-05-16 10:56:26 -0700 | [diff] [blame] | 640 | readl_relaxed(USB_PORTSC) & PORT_RESUME) { |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 641 | dev_dbg(mehci->dev, "wakeup pending, aborting suspend\n"); |
Jack Pham | be05fbb | 2012-05-16 10:56:26 -0700 | [diff] [blame] | 642 | enable_irq(hcd->irq); |
| 643 | return -EBUSY; |
| 644 | } |
| 645 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 646 | /* |
| 647 | * PHY may take some time or even fail to enter into low power |
| 648 | * mode (LPM). Hence poll for 500 msec and reset the PHY and link |
| 649 | * in failure case. |
| 650 | */ |
Hemant Kumar | 3dbc5b3 | 2012-05-09 15:36:11 -0700 | [diff] [blame] | 651 | val = readl_relaxed(USB_PORTSC); |
| 652 | val &= ~PORT_RWC_BITS; |
| 653 | val |= PORTSC_PHCD; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 654 | writel_relaxed(val, USB_PORTSC); |
| 655 | while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { |
| 656 | if (readl_relaxed(USB_PORTSC) & PORTSC_PHCD) |
| 657 | break; |
| 658 | udelay(1); |
| 659 | cnt++; |
| 660 | } |
| 661 | |
| 662 | if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) { |
| 663 | dev_err(mehci->dev, "Unable to suspend PHY\n"); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 664 | msm_hsic_config_gpios(mehci, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 665 | msm_hsic_reset(mehci); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | /* |
| 669 | * PHY has capability to generate interrupt asynchronously in low |
| 670 | * power mode (LPM). This interrupt is level triggered. So USB IRQ |
| 671 | * line must be disabled till async interrupt enable bit is cleared |
| 672 | * in USBCMD register. Assert STP (ULPI interface STOP signal) to |
Pavankumar Kondeti | 1c1d82b | 2013-01-28 21:37:59 +0530 | [diff] [blame] | 673 | * block data communication from PHY. Enable asynchronous interrupt |
| 674 | * only when wakeup gpio IRQ is not present. |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 675 | */ |
Pavankumar Kondeti | 1c1d82b | 2013-01-28 21:37:59 +0530 | [diff] [blame] | 676 | if (mehci->wakeup_irq) |
| 677 | writel_relaxed(readl_relaxed(USB_USBCMD) | |
| 678 | ULPI_STP_CTRL, USB_USBCMD); |
| 679 | else |
| 680 | writel_relaxed(readl_relaxed(USB_USBCMD) | ASYNC_INTR_CTRL | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 681 | ULPI_STP_CTRL, USB_USBCMD); |
| 682 | |
| 683 | /* |
| 684 | * Ensure that hardware is put in low power mode before |
| 685 | * clocks are turned OFF and VDD is allowed to minimize. |
| 686 | */ |
| 687 | mb(); |
| 688 | |
Manu Gautam | 28b1bac | 2012-01-30 16:43:06 +0530 | [diff] [blame] | 689 | clk_disable_unprepare(mehci->core_clk); |
| 690 | clk_disable_unprepare(mehci->phy_clk); |
| 691 | clk_disable_unprepare(mehci->cal_clk); |
| 692 | clk_disable_unprepare(mehci->ahb_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 693 | |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 694 | none_vol = vdd_val[mehci->vdd_type][VDD_NONE]; |
| 695 | max_vol = vdd_val[mehci->vdd_type][VDD_MAX]; |
| 696 | |
| 697 | ret = regulator_set_voltage(mehci->hsic_vddcx, none_vol, max_vol); |
Vamsi Krishna | 45d88fa | 2011-11-02 13:28:42 -0700 | [diff] [blame] | 698 | if (ret < 0) |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 699 | dev_err(mehci->dev, "unable to set vddcx voltage for VDD MIN\n"); |
Vamsi Krishna | 45d88fa | 2011-11-02 13:28:42 -0700 | [diff] [blame] | 700 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 701 | if (mehci->bus_perf_client && debug_bus_voting_enabled) { |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 702 | mehci->bus_vote = false; |
| 703 | queue_work(ehci_wq, &mehci->bus_vote_w); |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 704 | } |
| 705 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 706 | atomic_set(&mehci->in_lpm, 1); |
| 707 | enable_irq(hcd->irq); |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 708 | |
| 709 | mehci->wakeup_irq_enabled = 1; |
| 710 | enable_irq_wake(mehci->wakeup_irq); |
| 711 | enable_irq(mehci->wakeup_irq); |
| 712 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 713 | wake_unlock(&mehci->wlock); |
| 714 | |
Devin Kim | 476bbd7 | 2012-07-19 18:11:11 -0700 | [diff] [blame] | 715 | dev_dbg(mehci->dev, "HSIC-USB in low power mode\n"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 716 | |
| 717 | return 0; |
| 718 | } |
| 719 | |
| 720 | static int msm_hsic_resume(struct msm_hsic_hcd *mehci) |
| 721 | { |
| 722 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 723 | int cnt = 0, ret; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 724 | unsigned temp; |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 725 | int min_vol, max_vol; |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 726 | unsigned long flags; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 727 | |
| 728 | if (!atomic_read(&mehci->in_lpm)) { |
| 729 | dev_dbg(mehci->dev, "%s called in !in_lpm\n", __func__); |
| 730 | return 0; |
| 731 | } |
| 732 | |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 733 | /* Handles race with Async interrupt */ |
| 734 | disable_irq(hcd->irq); |
| 735 | |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 736 | spin_lock_irqsave(&mehci->wakeup_lock, flags); |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 737 | if (mehci->wakeup_irq_enabled) { |
| 738 | disable_irq_wake(mehci->wakeup_irq); |
| 739 | disable_irq_nosync(mehci->wakeup_irq); |
| 740 | mehci->wakeup_irq_enabled = 0; |
| 741 | } |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 742 | spin_unlock_irqrestore(&mehci->wakeup_lock, flags); |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 743 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 744 | wake_lock(&mehci->wlock); |
| 745 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 746 | if (mehci->bus_perf_client && debug_bus_voting_enabled) { |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 747 | mehci->bus_vote = true; |
| 748 | queue_work(ehci_wq, &mehci->bus_vote_w); |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 749 | } |
| 750 | |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 751 | min_vol = vdd_val[mehci->vdd_type][VDD_MIN]; |
| 752 | max_vol = vdd_val[mehci->vdd_type][VDD_MAX]; |
| 753 | |
| 754 | ret = regulator_set_voltage(mehci->hsic_vddcx, min_vol, max_vol); |
Vamsi Krishna | 45d88fa | 2011-11-02 13:28:42 -0700 | [diff] [blame] | 755 | if (ret < 0) |
Amit Blay | d6ea610 | 2012-06-07 16:26:24 +0300 | [diff] [blame] | 756 | dev_err(mehci->dev, "unable to set nominal vddcx voltage (no VDD MIN)\n"); |
Vamsi Krishna | 45d88fa | 2011-11-02 13:28:42 -0700 | [diff] [blame] | 757 | |
Manu Gautam | 28b1bac | 2012-01-30 16:43:06 +0530 | [diff] [blame] | 758 | clk_prepare_enable(mehci->core_clk); |
| 759 | clk_prepare_enable(mehci->phy_clk); |
| 760 | clk_prepare_enable(mehci->cal_clk); |
| 761 | clk_prepare_enable(mehci->ahb_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 762 | |
| 763 | temp = readl_relaxed(USB_USBCMD); |
| 764 | temp &= ~ASYNC_INTR_CTRL; |
| 765 | temp &= ~ULPI_STP_CTRL; |
| 766 | writel_relaxed(temp, USB_USBCMD); |
| 767 | |
| 768 | if (!(readl_relaxed(USB_PORTSC) & PORTSC_PHCD)) |
| 769 | goto skip_phy_resume; |
| 770 | |
Hemant Kumar | 3dbc5b3 | 2012-05-09 15:36:11 -0700 | [diff] [blame] | 771 | temp = readl_relaxed(USB_PORTSC); |
| 772 | temp &= ~(PORT_RWC_BITS | PORTSC_PHCD); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 773 | writel_relaxed(temp, USB_PORTSC); |
| 774 | while (cnt < PHY_RESUME_TIMEOUT_USEC) { |
| 775 | if (!(readl_relaxed(USB_PORTSC) & PORTSC_PHCD) && |
| 776 | (readl_relaxed(USB_ULPI_VIEWPORT) & ULPI_SYNC_STATE)) |
| 777 | break; |
| 778 | udelay(1); |
| 779 | cnt++; |
| 780 | } |
| 781 | |
| 782 | if (cnt >= PHY_RESUME_TIMEOUT_USEC) { |
| 783 | /* |
| 784 | * This is a fatal error. Reset the link and |
| 785 | * PHY to make hsic working. |
| 786 | */ |
| 787 | dev_err(mehci->dev, "Unable to resume USB. Reset the hsic\n"); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 788 | msm_hsic_config_gpios(mehci, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 789 | msm_hsic_reset(mehci); |
| 790 | } |
| 791 | |
| 792 | skip_phy_resume: |
| 793 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 794 | usb_hcd_resume_root_hub(hcd); |
| 795 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 796 | atomic_set(&mehci->in_lpm, 0); |
| 797 | |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 798 | if (atomic_read(&mehci->async_int)) { |
| 799 | atomic_set(&mehci->async_int, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 800 | pm_runtime_put_noidle(mehci->dev); |
Jack Pham | dd5ad79 | 2012-07-26 10:31:03 -0700 | [diff] [blame] | 801 | enable_irq(hcd->irq); |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 804 | if (atomic_read(&mehci->pm_usage_cnt)) { |
| 805 | atomic_set(&mehci->pm_usage_cnt, 0); |
| 806 | pm_runtime_put_noidle(mehci->dev); |
| 807 | } |
Jack Pham | dd5ad79 | 2012-07-26 10:31:03 -0700 | [diff] [blame] | 808 | |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 809 | enable_irq(hcd->irq); |
Devin Kim | 476bbd7 | 2012-07-19 18:11:11 -0700 | [diff] [blame] | 810 | dev_dbg(mehci->dev, "HSIC-USB exited from low power mode\n"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 811 | |
| 812 | return 0; |
| 813 | } |
| 814 | #endif |
| 815 | |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 816 | static void ehci_hsic_bus_vote_w(struct work_struct *w) |
| 817 | { |
| 818 | struct msm_hsic_hcd *mehci = |
| 819 | container_of(w, struct msm_hsic_hcd, bus_vote_w); |
| 820 | int ret; |
| 821 | |
| 822 | ret = msm_bus_scale_client_update_request(mehci->bus_perf_client, |
| 823 | mehci->bus_vote); |
| 824 | if (ret) |
| 825 | dev_err(mehci->dev, "%s: Failed to vote for bus bandwidth %d\n", |
| 826 | __func__, ret); |
| 827 | } |
| 828 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 829 | static int msm_hsic_reset_done(struct usb_hcd *hcd) |
| 830 | { |
| 831 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 832 | u32 __iomem *status_reg = &ehci->regs->port_status[0]; |
| 833 | int ret; |
| 834 | |
| 835 | ehci_writel(ehci, ehci_readl(ehci, status_reg) & ~(PORT_RWC_BITS | |
| 836 | PORT_RESET), status_reg); |
| 837 | |
| 838 | ret = handshake(ehci, status_reg, PORT_RESET, 0, 1 * 1000); |
| 839 | |
| 840 | if (ret) |
| 841 | pr_err("reset handshake failed in %s\n", __func__); |
| 842 | else |
| 843 | ehci_writel(ehci, ehci_readl(ehci, &ehci->regs->command) | |
| 844 | CMD_RUN, &ehci->regs->command); |
| 845 | |
| 846 | return ret; |
| 847 | } |
| 848 | |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 849 | #define STS_GPTIMER0_INTERRUPT BIT(24) |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 850 | static irqreturn_t msm_hsic_irq(struct usb_hcd *hcd) |
| 851 | { |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 852 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 853 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 854 | u32 status; |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 855 | int ret; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 856 | |
| 857 | if (atomic_read(&mehci->in_lpm)) { |
Hemant Kumar | 3dbc5b3 | 2012-05-09 15:36:11 -0700 | [diff] [blame] | 858 | dev_dbg(mehci->dev, "phy async intr\n"); |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 859 | dbg_log_event(NULL, "Async IRQ", 0); |
| 860 | ret = pm_runtime_get(mehci->dev); |
| 861 | if ((ret == 1) || (ret == -EINPROGRESS)) { |
| 862 | pm_runtime_put_noidle(mehci->dev); |
| 863 | } else { |
| 864 | disable_irq_nosync(hcd->irq); |
| 865 | atomic_set(&mehci->async_int, 1); |
| 866 | } |
| 867 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 868 | return IRQ_HANDLED; |
| 869 | } |
| 870 | |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 871 | status = ehci_readl(ehci, &ehci->regs->status); |
| 872 | |
| 873 | if (status & STS_GPTIMER0_INTERRUPT) { |
| 874 | int timeleft; |
| 875 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 876 | dbg_log_event(NULL, "FPR: gpt0_isr", mehci->bus_reset); |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 877 | |
| 878 | timeleft = GPT_CNT(ehci_readl(ehci, |
| 879 | &mehci->timer->gptimer1_ctrl)); |
| 880 | if (timeleft) { |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 881 | if (mehci->bus_reset) { |
| 882 | ret = msm_hsic_reset_done(hcd); |
| 883 | if (ret) { |
| 884 | mehci->reset_again = 1; |
| 885 | dbg_log_event(NULL, "RESET: fail", 0); |
| 886 | } |
| 887 | } else { |
| 888 | ehci_writel(ehci, ehci_readl(ehci, |
| 889 | &ehci->regs->command) | CMD_RUN, |
| 890 | &ehci->regs->command); |
| 891 | } |
| 892 | } else { |
| 893 | if (mehci->bus_reset) |
| 894 | mehci->reset_again = 1; |
| 895 | else |
| 896 | mehci->resume_again = 1; |
| 897 | } |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 898 | |
| 899 | dbg_log_event(NULL, "FPR: timeleft", timeleft); |
| 900 | |
| 901 | complete(&mehci->gpt0_completion); |
| 902 | ehci_writel(ehci, STS_GPTIMER0_INTERRUPT, &ehci->regs->status); |
| 903 | } |
| 904 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 905 | return ehci_irq(hcd); |
| 906 | } |
| 907 | |
| 908 | static int ehci_hsic_reset(struct usb_hcd *hcd) |
| 909 | { |
| 910 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 911 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 912 | int retval; |
| 913 | |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 914 | mehci->timer = USB_HS_GPTIMER_BASE; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 915 | ehci->caps = USB_CAPLENGTH; |
| 916 | ehci->regs = USB_CAPLENGTH + |
| 917 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); |
| 918 | dbg_hcs_params(ehci, "reset"); |
| 919 | dbg_hcc_params(ehci, "reset"); |
| 920 | |
| 921 | /* cache the data to minimize the chip reads*/ |
| 922 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); |
| 923 | |
| 924 | hcd->has_tt = 1; |
| 925 | ehci->sbrn = HCD_USB2; |
| 926 | |
| 927 | retval = ehci_halt(ehci); |
| 928 | if (retval) |
| 929 | return retval; |
| 930 | |
| 931 | /* data structure init */ |
| 932 | retval = ehci_init(hcd); |
| 933 | if (retval) |
| 934 | return retval; |
| 935 | |
| 936 | retval = ehci_reset(ehci); |
| 937 | if (retval) |
| 938 | return retval; |
| 939 | |
| 940 | /* bursts of unspecified length. */ |
| 941 | writel_relaxed(0, USB_AHBBURST); |
| 942 | /* Use the AHB transactor */ |
Vijayavardhan Vennapusa | 5f32d7a | 2012-03-14 16:30:26 +0530 | [diff] [blame] | 943 | writel_relaxed(0x08, USB_AHBMODE); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 944 | /* Disable streaming mode and select host mode */ |
| 945 | writel_relaxed(0x13, USB_USBMODE); |
| 946 | |
| 947 | ehci_port_power(ehci, 1); |
| 948 | return 0; |
| 949 | } |
| 950 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 951 | #define RESET_RETRY_LIMIT 3 |
| 952 | #define RESET_SIGNAL_TIME_SOF_USEC (50 * 1000) |
| 953 | #define RESET_SIGNAL_TIME_USEC (20 * 1000) |
| 954 | static void ehci_hsic_reset_sof_bug_handler(struct usb_hcd *hcd, u32 val) |
| 955 | { |
| 956 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 957 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 958 | struct msm_hsic_host_platform_data *pdata = mehci->dev->platform_data; |
| 959 | u32 __iomem *status_reg = &ehci->regs->port_status[0]; |
Pavankumar Kondeti | 3749363 | 2013-03-05 09:43:22 +0530 | [diff] [blame] | 960 | u32 cmd; |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 961 | unsigned long flags; |
| 962 | int retries = 0, ret, cnt = RESET_SIGNAL_TIME_USEC; |
| 963 | |
| 964 | if (pdata && pdata->swfi_latency) |
| 965 | pm_qos_update_request(&mehci->pm_qos_req_dma, |
| 966 | pdata->swfi_latency + 1); |
| 967 | |
| 968 | mehci->bus_reset = 1; |
Pavankumar Kondeti | 3749363 | 2013-03-05 09:43:22 +0530 | [diff] [blame] | 969 | |
| 970 | /* Halt the controller */ |
| 971 | cmd = ehci_readl(ehci, &ehci->regs->command); |
| 972 | cmd &= ~CMD_RUN; |
| 973 | ehci_writel(ehci, cmd, &ehci->regs->command); |
| 974 | ret = handshake(ehci, &ehci->regs->status, STS_HALT, |
| 975 | STS_HALT, 16 * 125); |
| 976 | if (ret) { |
| 977 | pr_err("halt handshake fatal error\n"); |
| 978 | dbg_log_event(NULL, "HALT: fatal", 0); |
| 979 | goto fail; |
| 980 | } |
| 981 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 982 | retry: |
| 983 | retries++; |
| 984 | dbg_log_event(NULL, "RESET: start", retries); |
| 985 | pr_debug("reset begin %d\n", retries); |
| 986 | mehci->reset_again = 0; |
| 987 | spin_lock_irqsave(&ehci->lock, flags); |
| 988 | ehci_writel(ehci, val, status_reg); |
| 989 | ehci_writel(ehci, GPT_LD(RESET_SIGNAL_TIME_USEC - 1), |
| 990 | &mehci->timer->gptimer0_ld); |
| 991 | ehci_writel(ehci, GPT_RESET | GPT_RUN, |
| 992 | &mehci->timer->gptimer0_ctrl); |
| 993 | ehci_writel(ehci, INTR_MASK | STS_GPTIMER0_INTERRUPT, |
| 994 | &ehci->regs->intr_enable); |
| 995 | |
| 996 | ehci_writel(ehci, GPT_LD(RESET_SIGNAL_TIME_SOF_USEC - 1), |
| 997 | &mehci->timer->gptimer1_ld); |
| 998 | ehci_writel(ehci, GPT_RESET | GPT_RUN, |
| 999 | &mehci->timer->gptimer1_ctrl); |
| 1000 | |
| 1001 | spin_unlock_irqrestore(&ehci->lock, flags); |
| 1002 | wait_for_completion(&mehci->gpt0_completion); |
| 1003 | |
| 1004 | if (!mehci->reset_again) |
| 1005 | goto done; |
| 1006 | |
| 1007 | if (handshake(ehci, status_reg, PORT_RESET, 0, 10 * 1000)) { |
| 1008 | pr_err("reset handshake fatal error\n"); |
| 1009 | dbg_log_event(NULL, "RESET: fatal", retries); |
| 1010 | goto fail; |
| 1011 | } |
| 1012 | |
| 1013 | if (retries < RESET_RETRY_LIMIT) |
| 1014 | goto retry; |
| 1015 | |
| 1016 | /* complete reset in tight loop */ |
| 1017 | pr_info("RESET in tight loop\n"); |
| 1018 | dbg_log_event(NULL, "RESET: tight", 0); |
| 1019 | |
| 1020 | spin_lock_irqsave(&ehci->lock, flags); |
| 1021 | ehci_writel(ehci, val, status_reg); |
| 1022 | while (cnt--) |
| 1023 | udelay(1); |
| 1024 | ret = msm_hsic_reset_done(hcd); |
| 1025 | spin_unlock_irqrestore(&ehci->lock, flags); |
| 1026 | if (ret) { |
| 1027 | pr_err("RESET in tight loop failed\n"); |
| 1028 | dbg_log_event(NULL, "RESET: tight failed", 0); |
| 1029 | goto fail; |
| 1030 | } |
| 1031 | |
| 1032 | done: |
| 1033 | dbg_log_event(NULL, "RESET: done", retries); |
| 1034 | pr_debug("reset completed\n"); |
| 1035 | fail: |
| 1036 | mehci->bus_reset = 0; |
| 1037 | if (pdata && pdata->swfi_latency) |
| 1038 | pm_qos_update_request(&mehci->pm_qos_req_dma, |
| 1039 | PM_QOS_DEFAULT_VALUE); |
| 1040 | } |
| 1041 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1042 | static int ehci_hsic_bus_suspend(struct usb_hcd *hcd) |
| 1043 | { |
Pavankumar Kondeti | 3c13739 | 2012-09-14 14:02:36 +0530 | [diff] [blame] | 1044 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1045 | |
| 1046 | if (!(readl_relaxed(USB_PORTSC) & PORT_PE)) { |
| 1047 | dbg_log_event(NULL, "RH suspend attempt failed", 0); |
| 1048 | dev_dbg(mehci->dev, "%s:port is not enabled skip suspend\n", |
| 1049 | __func__); |
| 1050 | return -EAGAIN; |
| 1051 | } |
| 1052 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1053 | dbg_log_event(NULL, "Suspend RH", 0); |
| 1054 | return ehci_bus_suspend(hcd); |
| 1055 | } |
| 1056 | |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1057 | #define RESUME_RETRY_LIMIT 3 |
Pavankumar Kondeti | c91a92a | 2013-01-29 19:08:12 +0530 | [diff] [blame] | 1058 | #define RESUME_SIGNAL_TIME_USEC (21 * 1000) |
| 1059 | #define RESUME_SIGNAL_TIME_SOF_USEC (23 * 1000) |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1060 | static int msm_hsic_resume_thread(void *data) |
| 1061 | { |
| 1062 | struct msm_hsic_hcd *mehci = data; |
| 1063 | struct usb_hcd *hcd = hsic_to_hcd(mehci); |
| 1064 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 1065 | u32 temp; |
| 1066 | unsigned long resume_needed = 0; |
| 1067 | int retry_cnt = 0; |
| 1068 | int tight_resume = 0; |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1069 | struct msm_hsic_host_platform_data *pdata = mehci->dev->platform_data; |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1070 | |
| 1071 | dbg_log_event(NULL, "Resume RH", 0); |
| 1072 | |
| 1073 | /* keep delay between bus states */ |
| 1074 | if (time_before(jiffies, ehci->next_statechange)) |
| 1075 | usleep_range(5000, 5000); |
| 1076 | |
| 1077 | spin_lock_irq(&ehci->lock); |
| 1078 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
| 1079 | spin_unlock_irq(&ehci->lock); |
| 1080 | mehci->resume_status = -ESHUTDOWN; |
| 1081 | complete(&mehci->rt_completion); |
| 1082 | return 0; |
| 1083 | } |
| 1084 | |
| 1085 | if (unlikely(ehci->debug)) { |
| 1086 | if (!dbgp_reset_prep()) |
| 1087 | ehci->debug = NULL; |
| 1088 | else |
| 1089 | dbgp_external_startup(); |
| 1090 | } |
| 1091 | |
| 1092 | /* at least some APM implementations will try to deliver |
| 1093 | * IRQs right away, so delay them until we're ready. |
| 1094 | */ |
| 1095 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); |
| 1096 | |
| 1097 | /* re-init operational registers */ |
| 1098 | ehci_writel(ehci, 0, &ehci->regs->segment); |
| 1099 | ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list); |
| 1100 | ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next); |
| 1101 | |
| 1102 | /*CMD_RUN will be set after, PORT_RESUME gets cleared*/ |
| 1103 | if (ehci->resume_sof_bug) |
| 1104 | ehci->command &= ~CMD_RUN; |
| 1105 | |
| 1106 | /* restore CMD_RUN, framelist size, and irq threshold */ |
| 1107 | ehci_writel(ehci, ehci->command, &ehci->regs->command); |
| 1108 | |
| 1109 | /* manually resume the ports we suspended during bus_suspend() */ |
| 1110 | resume_again: |
| 1111 | if (retry_cnt >= RESUME_RETRY_LIMIT) { |
| 1112 | pr_info("retry count(%d) reached max, resume in tight loop\n", |
| 1113 | retry_cnt); |
| 1114 | tight_resume = 1; |
| 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | temp = ehci_readl(ehci, &ehci->regs->port_status[0]); |
| 1119 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
| 1120 | if (test_bit(0, &ehci->bus_suspended) && (temp & PORT_SUSPEND)) { |
| 1121 | temp |= PORT_RESUME; |
| 1122 | set_bit(0, &resume_needed); |
| 1123 | } |
| 1124 | dbg_log_event(NULL, "FPR: Set", temp); |
| 1125 | ehci_writel(ehci, temp, &ehci->regs->port_status[0]); |
| 1126 | |
| 1127 | /* HSIC controller has a h/w bug due to which it can try to send SOFs |
| 1128 | * (start of frames) during port resume resulting in phy lockup. HSIC hw |
| 1129 | * controller in MSM clears FPR bit after driving the resume signal for |
| 1130 | * 20ms. Workaround is to stop SOFs before driving resume and then start |
| 1131 | * sending SOFs immediately. Need to send SOFs within 3ms of resume |
| 1132 | * completion otherwise peripheral may enter undefined state. As |
| 1133 | * usleep_range does not gurantee exact sleep time, GPTimer is used to |
| 1134 | * to time the resume sequence. If driver exceeds allowable time SOFs, |
| 1135 | * repeat the resume process. |
| 1136 | */ |
| 1137 | if (ehci->resume_sof_bug && resume_needed) { |
| 1138 | if (!tight_resume) { |
| 1139 | mehci->resume_again = 0; |
Pavankumar Kondeti | c91a92a | 2013-01-29 19:08:12 +0530 | [diff] [blame] | 1140 | ehci_writel(ehci, GPT_LD(RESUME_SIGNAL_TIME_USEC - 1), |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1141 | &mehci->timer->gptimer0_ld); |
| 1142 | ehci_writel(ehci, GPT_RESET | GPT_RUN, |
| 1143 | &mehci->timer->gptimer0_ctrl); |
| 1144 | ehci_writel(ehci, INTR_MASK | STS_GPTIMER0_INTERRUPT, |
| 1145 | &ehci->regs->intr_enable); |
| 1146 | |
Pavankumar Kondeti | c91a92a | 2013-01-29 19:08:12 +0530 | [diff] [blame] | 1147 | ehci_writel(ehci, GPT_LD( |
| 1148 | RESUME_SIGNAL_TIME_SOF_USEC - 1), |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1149 | &mehci->timer->gptimer1_ld); |
| 1150 | ehci_writel(ehci, GPT_RESET | GPT_RUN, |
| 1151 | &mehci->timer->gptimer1_ctrl); |
| 1152 | |
| 1153 | spin_unlock_irq(&ehci->lock); |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1154 | if (pdata && pdata->swfi_latency) |
| 1155 | pm_qos_update_request(&mehci->pm_qos_req_dma, |
| 1156 | pdata->swfi_latency + 1); |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1157 | wait_for_completion(&mehci->gpt0_completion); |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1158 | if (pdata && pdata->swfi_latency) |
| 1159 | pm_qos_update_request(&mehci->pm_qos_req_dma, |
| 1160 | PM_QOS_DEFAULT_VALUE); |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1161 | spin_lock_irq(&ehci->lock); |
| 1162 | } else { |
| 1163 | dbg_log_event(NULL, "FPR: Tightloop", 0); |
| 1164 | /* do the resume in a tight loop */ |
| 1165 | handshake(ehci, &ehci->regs->port_status[0], |
| 1166 | PORT_RESUME, 0, 22 * 1000); |
| 1167 | ehci_writel(ehci, ehci_readl(ehci, |
| 1168 | &ehci->regs->command) | CMD_RUN, |
| 1169 | &ehci->regs->command); |
| 1170 | } |
| 1171 | |
| 1172 | if (mehci->resume_again) { |
| 1173 | int temp; |
| 1174 | |
| 1175 | dbg_log_event(NULL, "FPR: Re-Resume", retry_cnt); |
| 1176 | pr_info("FPR: retry count: %d\n", retry_cnt); |
| 1177 | spin_unlock_irq(&ehci->lock); |
| 1178 | temp = ehci_readl(ehci, &ehci->regs->port_status[0]); |
| 1179 | temp &= ~PORT_RWC_BITS; |
| 1180 | temp |= PORT_SUSPEND; |
| 1181 | ehci_writel(ehci, temp, &ehci->regs->port_status[0]); |
| 1182 | /* Keep the bus idle for 5ms so that peripheral |
| 1183 | * can detect and initiate suspend |
| 1184 | */ |
| 1185 | usleep_range(5000, 5000); |
| 1186 | dbg_log_event(NULL, |
| 1187 | "FPR: RResume", |
| 1188 | ehci_readl(ehci, &ehci->regs->port_status[0])); |
| 1189 | spin_lock_irq(&ehci->lock); |
| 1190 | mehci->resume_again = 0; |
| 1191 | retry_cnt++; |
| 1192 | goto resume_again; |
| 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | dbg_log_event(NULL, "FPR: RT-Done", 0); |
| 1197 | mehci->resume_status = 1; |
| 1198 | spin_unlock_irq(&ehci->lock); |
| 1199 | |
| 1200 | complete(&mehci->rt_completion); |
| 1201 | |
| 1202 | return 0; |
| 1203 | } |
| 1204 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1205 | static int ehci_hsic_bus_resume(struct usb_hcd *hcd) |
| 1206 | { |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1207 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1208 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 1209 | u32 temp; |
| 1210 | struct task_struct *resume_thread = NULL; |
| 1211 | |
| 1212 | mehci->resume_status = 0; |
| 1213 | resume_thread = kthread_run(msm_hsic_resume_thread, |
| 1214 | mehci, "hsic_resume_thread"); |
| 1215 | if (IS_ERR(resume_thread)) { |
| 1216 | pr_err("Error creating resume thread:%lu\n", |
| 1217 | PTR_ERR(resume_thread)); |
| 1218 | return PTR_ERR(resume_thread); |
| 1219 | } |
| 1220 | |
| 1221 | wait_for_completion(&mehci->rt_completion); |
| 1222 | |
| 1223 | if (mehci->resume_status < 0) |
| 1224 | return mehci->resume_status; |
| 1225 | |
| 1226 | dbg_log_event(NULL, "FPR: Wokeup", 0); |
| 1227 | spin_lock_irq(&ehci->lock); |
| 1228 | (void) ehci_readl(ehci, &ehci->regs->command); |
| 1229 | |
| 1230 | temp = 0; |
| 1231 | if (ehci->async->qh_next.qh) |
| 1232 | temp |= CMD_ASE; |
| 1233 | if (ehci->periodic_sched) |
| 1234 | temp |= CMD_PSE; |
| 1235 | if (temp) { |
| 1236 | ehci->command |= temp; |
| 1237 | ehci_writel(ehci, ehci->command, &ehci->regs->command); |
| 1238 | } |
| 1239 | |
| 1240 | ehci->next_statechange = jiffies + msecs_to_jiffies(5); |
| 1241 | hcd->state = HC_STATE_RUNNING; |
| 1242 | ehci->rh_state = EHCI_RH_RUNNING; |
| 1243 | |
| 1244 | /* Now we can safely re-enable irqs */ |
| 1245 | ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable); |
| 1246 | |
| 1247 | spin_unlock_irq(&ehci->lock); |
| 1248 | |
| 1249 | return 0; |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1250 | } |
| 1251 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1252 | static struct hc_driver msm_hsic_driver = { |
| 1253 | .description = hcd_name, |
| 1254 | .product_desc = "Qualcomm EHCI Host Controller using HSIC", |
| 1255 | .hcd_priv_size = sizeof(struct msm_hsic_hcd), |
| 1256 | |
| 1257 | /* |
| 1258 | * generic hardware linkage |
| 1259 | */ |
| 1260 | .irq = msm_hsic_irq, |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 1261 | .flags = HCD_USB2 | HCD_MEMORY | HCD_OLD_ENUM, |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1262 | |
| 1263 | .reset = ehci_hsic_reset, |
| 1264 | .start = ehci_run, |
| 1265 | |
| 1266 | .stop = ehci_stop, |
| 1267 | .shutdown = ehci_shutdown, |
| 1268 | |
| 1269 | /* |
| 1270 | * managing i/o requests and associated device resources |
| 1271 | */ |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 1272 | .urb_enqueue = ehci_urb_enqueue, |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1273 | .urb_dequeue = ehci_urb_dequeue, |
| 1274 | .endpoint_disable = ehci_endpoint_disable, |
| 1275 | .endpoint_reset = ehci_endpoint_reset, |
| 1276 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
| 1277 | |
| 1278 | /* |
| 1279 | * scheduling support |
| 1280 | */ |
| 1281 | .get_frame_number = ehci_get_frame, |
| 1282 | |
| 1283 | /* |
| 1284 | * root hub support |
| 1285 | */ |
| 1286 | .hub_status_data = ehci_hub_status_data, |
| 1287 | .hub_control = ehci_hub_control, |
| 1288 | .relinquish_port = ehci_relinquish_port, |
| 1289 | .port_handed_over = ehci_port_handed_over, |
| 1290 | |
| 1291 | /* |
| 1292 | * PM support |
| 1293 | */ |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1294 | .bus_suspend = ehci_hsic_bus_suspend, |
| 1295 | .bus_resume = ehci_hsic_bus_resume, |
| 1296 | |
Hemant Kumar | df2d84d | 2012-08-15 09:06:35 -0700 | [diff] [blame] | 1297 | .log_urb = dbg_log_event, |
Hemant Kumar | 105d07f | 2012-07-02 15:33:07 -0700 | [diff] [blame] | 1298 | .dump_regs = dump_hsic_regs, |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 1299 | |
Pavankumar Kondeti | 9ecc39c | 2013-01-29 14:41:58 +0530 | [diff] [blame] | 1300 | .reset_sof_bug_handler = ehci_hsic_reset_sof_bug_handler, |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1301 | }; |
| 1302 | |
| 1303 | static int msm_hsic_init_clocks(struct msm_hsic_hcd *mehci, u32 init) |
| 1304 | { |
| 1305 | int ret = 0; |
| 1306 | |
| 1307 | if (!init) |
| 1308 | goto put_clocks; |
| 1309 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 1310 | /*core_clk is required for LINK protocol engine |
| 1311 | *clock rate appropriately set by target specific clock driver */ |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1312 | mehci->core_clk = clk_get(mehci->dev, "core_clk"); |
| 1313 | if (IS_ERR(mehci->core_clk)) { |
| 1314 | dev_err(mehci->dev, "failed to get core_clk\n"); |
| 1315 | ret = PTR_ERR(mehci->core_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1316 | return ret; |
| 1317 | } |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1318 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 1319 | /* alt_core_clk is for LINK to be used during PHY RESET |
| 1320 | * clock rate appropriately set by target specific clock driver */ |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1321 | mehci->alt_core_clk = clk_get(mehci->dev, "alt_core_clk"); |
| 1322 | if (IS_ERR(mehci->alt_core_clk)) { |
| 1323 | dev_err(mehci->dev, "failed to core_clk\n"); |
| 1324 | ret = PTR_ERR(mehci->alt_core_clk); |
| 1325 | goto put_core_clk; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1326 | } |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1327 | |
Lena Salman | 8c8ba38 | 2012-02-14 15:59:31 +0200 | [diff] [blame] | 1328 | /* phy_clk is required for HSIC PHY operation |
| 1329 | * clock rate appropriately set by target specific clock driver */ |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1330 | mehci->phy_clk = clk_get(mehci->dev, "phy_clk"); |
| 1331 | if (IS_ERR(mehci->phy_clk)) { |
| 1332 | dev_err(mehci->dev, "failed to get phy_clk\n"); |
| 1333 | ret = PTR_ERR(mehci->phy_clk); |
| 1334 | goto put_alt_core_clk; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1335 | } |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1336 | |
| 1337 | /* 10MHz cal_clk is required for calibration of I/O pads */ |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1338 | mehci->cal_clk = clk_get(mehci->dev, "cal_clk"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1339 | if (IS_ERR(mehci->cal_clk)) { |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1340 | dev_err(mehci->dev, "failed to get cal_clk\n"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1341 | ret = PTR_ERR(mehci->cal_clk); |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1342 | goto put_phy_clk; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1343 | } |
| 1344 | clk_set_rate(mehci->cal_clk, 10000000); |
| 1345 | |
| 1346 | /* ahb_clk is required for data transfers */ |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1347 | mehci->ahb_clk = clk_get(mehci->dev, "iface_clk"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1348 | if (IS_ERR(mehci->ahb_clk)) { |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1349 | dev_err(mehci->dev, "failed to get iface_clk\n"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1350 | ret = PTR_ERR(mehci->ahb_clk); |
| 1351 | goto put_cal_clk; |
| 1352 | } |
| 1353 | |
Manu Gautam | 28b1bac | 2012-01-30 16:43:06 +0530 | [diff] [blame] | 1354 | clk_prepare_enable(mehci->core_clk); |
| 1355 | clk_prepare_enable(mehci->phy_clk); |
| 1356 | clk_prepare_enable(mehci->cal_clk); |
| 1357 | clk_prepare_enable(mehci->ahb_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1358 | |
| 1359 | return 0; |
| 1360 | |
| 1361 | put_clocks: |
Jack Pham | fd193eb | 2012-02-22 15:38:08 -0800 | [diff] [blame] | 1362 | if (!atomic_read(&mehci->in_lpm)) { |
| 1363 | clk_disable_unprepare(mehci->core_clk); |
| 1364 | clk_disable_unprepare(mehci->phy_clk); |
| 1365 | clk_disable_unprepare(mehci->cal_clk); |
| 1366 | clk_disable_unprepare(mehci->ahb_clk); |
| 1367 | } |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1368 | clk_put(mehci->ahb_clk); |
| 1369 | put_cal_clk: |
| 1370 | clk_put(mehci->cal_clk); |
Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1371 | put_phy_clk: |
| 1372 | clk_put(mehci->phy_clk); |
| 1373 | put_alt_core_clk: |
| 1374 | clk_put(mehci->alt_core_clk); |
| 1375 | put_core_clk: |
| 1376 | clk_put(mehci->core_clk); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1377 | |
| 1378 | return ret; |
| 1379 | } |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1380 | static irqreturn_t hsic_peripheral_status_change(int irq, void *dev_id) |
| 1381 | { |
| 1382 | struct msm_hsic_hcd *mehci = dev_id; |
| 1383 | |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1384 | pr_debug("%s: mehci:%p dev_id:%p\n", __func__, mehci, dev_id); |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1385 | |
| 1386 | if (mehci) |
| 1387 | msm_hsic_config_gpios(mehci, 0); |
| 1388 | |
| 1389 | return IRQ_HANDLED; |
| 1390 | } |
| 1391 | |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1392 | static irqreturn_t msm_hsic_wakeup_irq(int irq, void *data) |
| 1393 | { |
| 1394 | struct msm_hsic_hcd *mehci = data; |
Ajay Dudani | d666daf | 2012-09-27 12:04:12 +0530 | [diff] [blame] | 1395 | int ret; |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1396 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1397 | mehci->wakeup_int_cnt++; |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1398 | dbg_log_event(NULL, "Remote Wakeup IRQ", mehci->wakeup_int_cnt); |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1399 | dev_dbg(mehci->dev, "%s: hsic remote wakeup interrupt cnt: %u\n", |
| 1400 | __func__, mehci->wakeup_int_cnt); |
| 1401 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 1402 | wake_lock(&mehci->wlock); |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1403 | |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 1404 | spin_lock(&mehci->wakeup_lock); |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 1405 | if (mehci->wakeup_irq_enabled) { |
| 1406 | mehci->wakeup_irq_enabled = 0; |
| 1407 | disable_irq_wake(irq); |
| 1408 | disable_irq_nosync(irq); |
| 1409 | } |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 1410 | spin_unlock(&mehci->wakeup_lock); |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 1411 | |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 1412 | if (!atomic_read(&mehci->pm_usage_cnt)) { |
Ajay Dudani | d666daf | 2012-09-27 12:04:12 +0530 | [diff] [blame] | 1413 | ret = pm_runtime_get(mehci->dev); |
| 1414 | /* |
| 1415 | * HSIC runtime resume can race with us. |
| 1416 | * if we are active (ret == 1) or resuming |
| 1417 | * (ret == -EINPROGRESS), decrement the |
| 1418 | * PM usage counter before returning. |
| 1419 | */ |
| 1420 | if ((ret == 1) || (ret == -EINPROGRESS)) |
| 1421 | pm_runtime_put_noidle(mehci->dev); |
| 1422 | else |
| 1423 | atomic_set(&mehci->pm_usage_cnt, 1); |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 1424 | } |
| 1425 | |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1426 | return IRQ_HANDLED; |
| 1427 | } |
| 1428 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1429 | static int ehci_hsic_msm_bus_show(struct seq_file *s, void *unused) |
| 1430 | { |
| 1431 | if (debug_bus_voting_enabled) |
| 1432 | seq_printf(s, "enabled\n"); |
| 1433 | else |
| 1434 | seq_printf(s, "disabled\n"); |
| 1435 | |
| 1436 | return 0; |
| 1437 | } |
| 1438 | |
| 1439 | static int ehci_hsic_msm_bus_open(struct inode *inode, struct file *file) |
| 1440 | { |
| 1441 | return single_open(file, ehci_hsic_msm_bus_show, inode->i_private); |
| 1442 | } |
| 1443 | |
| 1444 | static ssize_t ehci_hsic_msm_bus_write(struct file *file, |
| 1445 | const char __user *ubuf, size_t count, loff_t *ppos) |
| 1446 | { |
| 1447 | char buf[8]; |
| 1448 | int ret; |
| 1449 | struct seq_file *s = file->private_data; |
| 1450 | struct msm_hsic_hcd *mehci = s->private; |
| 1451 | |
| 1452 | memset(buf, 0x00, sizeof(buf)); |
| 1453 | |
| 1454 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) |
| 1455 | return -EFAULT; |
| 1456 | |
| 1457 | if (!strncmp(buf, "enable", 6)) { |
| 1458 | /* Do not vote here. Let hsic driver decide when to vote */ |
| 1459 | debug_bus_voting_enabled = true; |
| 1460 | } else { |
| 1461 | debug_bus_voting_enabled = false; |
| 1462 | if (mehci->bus_perf_client) { |
| 1463 | ret = msm_bus_scale_client_update_request( |
| 1464 | mehci->bus_perf_client, 0); |
| 1465 | if (ret) |
| 1466 | dev_err(mehci->dev, "%s: Failed to devote " |
| 1467 | "for bus bw %d\n", __func__, ret); |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | return count; |
| 1472 | } |
| 1473 | |
| 1474 | const struct file_operations ehci_hsic_msm_bus_fops = { |
| 1475 | .open = ehci_hsic_msm_bus_open, |
| 1476 | .read = seq_read, |
| 1477 | .write = ehci_hsic_msm_bus_write, |
| 1478 | .llseek = seq_lseek, |
| 1479 | .release = single_release, |
| 1480 | }; |
| 1481 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1482 | static int ehci_hsic_msm_wakeup_cnt_show(struct seq_file *s, void *unused) |
| 1483 | { |
| 1484 | struct msm_hsic_hcd *mehci = s->private; |
| 1485 | |
| 1486 | seq_printf(s, "%u\n", mehci->wakeup_int_cnt); |
| 1487 | |
| 1488 | return 0; |
| 1489 | } |
| 1490 | |
| 1491 | static int ehci_hsic_msm_wakeup_cnt_open(struct inode *inode, struct file *f) |
| 1492 | { |
| 1493 | return single_open(f, ehci_hsic_msm_wakeup_cnt_show, inode->i_private); |
| 1494 | } |
| 1495 | |
| 1496 | const struct file_operations ehci_hsic_msm_wakeup_cnt_fops = { |
| 1497 | .open = ehci_hsic_msm_wakeup_cnt_open, |
| 1498 | .read = seq_read, |
| 1499 | .llseek = seq_lseek, |
| 1500 | .release = single_release, |
| 1501 | }; |
| 1502 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1503 | static int ehci_hsic_msm_data_events_show(struct seq_file *s, void *unused) |
| 1504 | { |
| 1505 | unsigned long flags; |
| 1506 | unsigned i; |
| 1507 | |
| 1508 | read_lock_irqsave(&dbg_hsic_data.lck, flags); |
| 1509 | |
| 1510 | i = dbg_hsic_data.idx; |
| 1511 | for (dbg_inc(&i); i != dbg_hsic_data.idx; dbg_inc(&i)) { |
| 1512 | if (!strnlen(dbg_hsic_data.buf[i], DBG_MSG_LEN)) |
| 1513 | continue; |
| 1514 | seq_printf(s, "%s\n", dbg_hsic_data.buf[i]); |
| 1515 | } |
| 1516 | |
| 1517 | read_unlock_irqrestore(&dbg_hsic_data.lck, flags); |
| 1518 | |
| 1519 | return 0; |
| 1520 | } |
| 1521 | |
| 1522 | static int ehci_hsic_msm_data_events_open(struct inode *inode, struct file *f) |
| 1523 | { |
| 1524 | return single_open(f, ehci_hsic_msm_data_events_show, inode->i_private); |
| 1525 | } |
| 1526 | |
| 1527 | const struct file_operations ehci_hsic_msm_dbg_data_fops = { |
| 1528 | .open = ehci_hsic_msm_data_events_open, |
| 1529 | .read = seq_read, |
| 1530 | .llseek = seq_lseek, |
| 1531 | .release = single_release, |
| 1532 | }; |
| 1533 | |
| 1534 | static int ehci_hsic_msm_ctrl_events_show(struct seq_file *s, void *unused) |
| 1535 | { |
| 1536 | unsigned long flags; |
| 1537 | unsigned i; |
| 1538 | |
| 1539 | read_lock_irqsave(&dbg_hsic_ctrl.lck, flags); |
| 1540 | |
| 1541 | i = dbg_hsic_ctrl.idx; |
| 1542 | for (dbg_inc(&i); i != dbg_hsic_ctrl.idx; dbg_inc(&i)) { |
| 1543 | if (!strnlen(dbg_hsic_ctrl.buf[i], DBG_MSG_LEN)) |
| 1544 | continue; |
| 1545 | seq_printf(s, "%s\n", dbg_hsic_ctrl.buf[i]); |
| 1546 | } |
| 1547 | |
| 1548 | read_unlock_irqrestore(&dbg_hsic_ctrl.lck, flags); |
| 1549 | |
| 1550 | return 0; |
| 1551 | } |
| 1552 | |
| 1553 | static int ehci_hsic_msm_ctrl_events_open(struct inode *inode, struct file *f) |
| 1554 | { |
| 1555 | return single_open(f, ehci_hsic_msm_ctrl_events_show, inode->i_private); |
| 1556 | } |
| 1557 | |
| 1558 | const struct file_operations ehci_hsic_msm_dbg_ctrl_fops = { |
| 1559 | .open = ehci_hsic_msm_ctrl_events_open, |
| 1560 | .read = seq_read, |
| 1561 | .llseek = seq_lseek, |
| 1562 | .release = single_release, |
| 1563 | }; |
| 1564 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1565 | static struct dentry *ehci_hsic_msm_dbg_root; |
| 1566 | static int ehci_hsic_msm_debugfs_init(struct msm_hsic_hcd *mehci) |
| 1567 | { |
| 1568 | struct dentry *ehci_hsic_msm_dentry; |
| 1569 | |
| 1570 | ehci_hsic_msm_dbg_root = debugfs_create_dir("ehci_hsic_msm_dbg", NULL); |
| 1571 | |
| 1572 | if (!ehci_hsic_msm_dbg_root || IS_ERR(ehci_hsic_msm_dbg_root)) |
| 1573 | return -ENODEV; |
| 1574 | |
| 1575 | ehci_hsic_msm_dentry = debugfs_create_file("bus_voting", |
| 1576 | S_IRUGO | S_IWUSR, |
| 1577 | ehci_hsic_msm_dbg_root, mehci, |
| 1578 | &ehci_hsic_msm_bus_fops); |
| 1579 | |
| 1580 | if (!ehci_hsic_msm_dentry) { |
| 1581 | debugfs_remove_recursive(ehci_hsic_msm_dbg_root); |
| 1582 | return -ENODEV; |
| 1583 | } |
| 1584 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1585 | ehci_hsic_msm_dentry = debugfs_create_file("wakeup_cnt", |
| 1586 | S_IRUGO, |
| 1587 | ehci_hsic_msm_dbg_root, mehci, |
| 1588 | &ehci_hsic_msm_wakeup_cnt_fops); |
| 1589 | |
| 1590 | if (!ehci_hsic_msm_dentry) { |
| 1591 | debugfs_remove_recursive(ehci_hsic_msm_dbg_root); |
| 1592 | return -ENODEV; |
| 1593 | } |
| 1594 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1595 | ehci_hsic_msm_dentry = debugfs_create_file("show_ctrl_events", |
| 1596 | S_IRUGO, |
| 1597 | ehci_hsic_msm_dbg_root, mehci, |
| 1598 | &ehci_hsic_msm_dbg_ctrl_fops); |
| 1599 | |
| 1600 | if (!ehci_hsic_msm_dentry) { |
| 1601 | debugfs_remove_recursive(ehci_hsic_msm_dbg_root); |
| 1602 | return -ENODEV; |
| 1603 | } |
| 1604 | |
| 1605 | ehci_hsic_msm_dentry = debugfs_create_file("show_data_events", |
| 1606 | S_IRUGO, |
| 1607 | ehci_hsic_msm_dbg_root, mehci, |
| 1608 | &ehci_hsic_msm_dbg_data_fops); |
| 1609 | |
| 1610 | if (!ehci_hsic_msm_dentry) { |
| 1611 | debugfs_remove_recursive(ehci_hsic_msm_dbg_root); |
| 1612 | return -ENODEV; |
| 1613 | } |
| 1614 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1615 | return 0; |
| 1616 | } |
| 1617 | |
| 1618 | static void ehci_hsic_msm_debugfs_cleanup(void) |
| 1619 | { |
| 1620 | debugfs_remove_recursive(ehci_hsic_msm_dbg_root); |
| 1621 | } |
| 1622 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1623 | static int __devinit ehci_hsic_msm_probe(struct platform_device *pdev) |
| 1624 | { |
| 1625 | struct usb_hcd *hcd; |
| 1626 | struct resource *res; |
| 1627 | struct msm_hsic_hcd *mehci; |
Vijayavardhan Vennapusa | 2b592824f | 2011-11-02 19:51:32 +0530 | [diff] [blame] | 1628 | struct msm_hsic_host_platform_data *pdata; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1629 | int ret; |
| 1630 | |
| 1631 | dev_dbg(&pdev->dev, "ehci_msm-hsic probe\n"); |
| 1632 | |
Vijayavardhan Vennapusa | afbbb8f | 2012-04-13 16:28:45 +0530 | [diff] [blame] | 1633 | /* After parent device's probe is executed, it will be put in suspend |
| 1634 | * mode. When child device's probe is called, driver core is not |
| 1635 | * resuming parent device due to which parent will be in suspend even |
| 1636 | * though child is active. Hence resume the parent device explicitly. |
| 1637 | */ |
| 1638 | if (pdev->dev.parent) |
| 1639 | pm_runtime_get_sync(pdev->dev.parent); |
| 1640 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1641 | hcd = usb_create_hcd(&msm_hsic_driver, &pdev->dev, |
| 1642 | dev_name(&pdev->dev)); |
| 1643 | if (!hcd) { |
| 1644 | dev_err(&pdev->dev, "Unable to create HCD\n"); |
| 1645 | return -ENOMEM; |
| 1646 | } |
| 1647 | |
Pavankumar Kondeti | 1c85169 | 2012-09-18 17:52:51 +0530 | [diff] [blame] | 1648 | hcd_to_bus(hcd)->skip_resume = true; |
| 1649 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1650 | hcd->irq = platform_get_irq(pdev, 0); |
| 1651 | if (hcd->irq < 0) { |
| 1652 | dev_err(&pdev->dev, "Unable to get IRQ resource\n"); |
| 1653 | ret = hcd->irq; |
| 1654 | goto put_hcd; |
| 1655 | } |
| 1656 | |
| 1657 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1658 | if (!res) { |
| 1659 | dev_err(&pdev->dev, "Unable to get memory resource\n"); |
| 1660 | ret = -ENODEV; |
| 1661 | goto put_hcd; |
| 1662 | } |
| 1663 | |
| 1664 | hcd->rsrc_start = res->start; |
| 1665 | hcd->rsrc_len = resource_size(res); |
| 1666 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); |
| 1667 | if (!hcd->regs) { |
| 1668 | dev_err(&pdev->dev, "ioremap failed\n"); |
| 1669 | ret = -ENOMEM; |
| 1670 | goto put_hcd; |
| 1671 | } |
| 1672 | |
| 1673 | mehci = hcd_to_hsic(hcd); |
| 1674 | mehci->dev = &pdev->dev; |
Ajay Dudani | c4e40db | 2012-08-20 14:44:40 -0700 | [diff] [blame] | 1675 | pdata = mehci->dev->platform_data; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1676 | |
Hemant Kumar | 4cd49e1 | 2012-09-06 19:57:14 -0700 | [diff] [blame] | 1677 | spin_lock_init(&mehci->wakeup_lock); |
| 1678 | |
Hemant Kumar | 38ce5d8 | 2012-05-29 13:00:58 -0700 | [diff] [blame] | 1679 | mehci->ehci.susp_sof_bug = 1; |
Vamsi Krishna | 8e6edcb | 2012-06-20 18:08:50 -0700 | [diff] [blame] | 1680 | mehci->ehci.reset_sof_bug = 1; |
Hemant Kumar | 38ce5d8 | 2012-05-29 13:00:58 -0700 | [diff] [blame] | 1681 | |
Hemant Kumar | e404049 | 2012-06-21 17:35:42 -0700 | [diff] [blame] | 1682 | mehci->ehci.resume_sof_bug = 1; |
| 1683 | |
Ajay Dudani | c4e40db | 2012-08-20 14:44:40 -0700 | [diff] [blame] | 1684 | if (pdata) |
| 1685 | mehci->ehci.log2_irq_thresh = pdata->log2_irq_thresh; |
Hemant Kumar | 933e040 | 2012-05-22 11:11:40 -0700 | [diff] [blame] | 1686 | |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1687 | res = platform_get_resource_byname(pdev, |
| 1688 | IORESOURCE_IRQ, |
| 1689 | "peripheral_status_irq"); |
| 1690 | if (res) |
| 1691 | mehci->peripheral_status_irq = res->start; |
| 1692 | |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1693 | res = platform_get_resource_byname(pdev, IORESOURCE_IO, "wakeup"); |
| 1694 | if (res) { |
| 1695 | mehci->wakeup_gpio = res->start; |
| 1696 | mehci->wakeup_irq = MSM_GPIO_TO_INT(res->start); |
| 1697 | dev_dbg(mehci->dev, "wakeup_irq: %d\n", mehci->wakeup_irq); |
| 1698 | } |
| 1699 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1700 | ret = msm_hsic_init_clocks(mehci, 1); |
| 1701 | if (ret) { |
| 1702 | dev_err(&pdev->dev, "unable to initialize clocks\n"); |
| 1703 | ret = -ENODEV; |
| 1704 | goto unmap; |
| 1705 | } |
| 1706 | |
| 1707 | ret = msm_hsic_init_vddcx(mehci, 1); |
| 1708 | if (ret) { |
| 1709 | dev_err(&pdev->dev, "unable to initialize VDDCX\n"); |
| 1710 | ret = -ENODEV; |
| 1711 | goto deinit_clocks; |
| 1712 | } |
| 1713 | |
Ajay Dudani | 11ab1d5 | 2012-08-17 17:12:26 -0700 | [diff] [blame] | 1714 | init_completion(&mehci->rt_completion); |
| 1715 | init_completion(&mehci->gpt0_completion); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1716 | ret = msm_hsic_reset(mehci); |
| 1717 | if (ret) { |
| 1718 | dev_err(&pdev->dev, "unable to initialize PHY\n"); |
Vijayavardhan Vennapusa | afbbb8f | 2012-04-13 16:28:45 +0530 | [diff] [blame] | 1719 | goto deinit_vddcx; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1720 | } |
| 1721 | |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 1722 | ehci_wq = create_singlethread_workqueue("ehci_wq"); |
| 1723 | if (!ehci_wq) { |
| 1724 | dev_err(&pdev->dev, "unable to create workqueue\n"); |
| 1725 | ret = -ENOMEM; |
| 1726 | goto deinit_vddcx; |
| 1727 | } |
| 1728 | |
| 1729 | INIT_WORK(&mehci->bus_vote_w, ehci_hsic_bus_vote_w); |
| 1730 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1731 | ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); |
| 1732 | if (ret) { |
| 1733 | dev_err(&pdev->dev, "unable to register HCD\n"); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 1734 | goto unconfig_gpio; |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1735 | } |
| 1736 | |
| 1737 | device_init_wakeup(&pdev->dev, 1); |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 1738 | wake_lock_init(&mehci->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev)); |
| 1739 | wake_lock(&mehci->wlock); |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1740 | |
| 1741 | if (mehci->peripheral_status_irq) { |
| 1742 | ret = request_threaded_irq(mehci->peripheral_status_irq, |
| 1743 | NULL, hsic_peripheral_status_change, |
| 1744 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
| 1745 | | IRQF_SHARED, |
| 1746 | "hsic_peripheral_status", mehci); |
| 1747 | if (ret) |
| 1748 | dev_err(&pdev->dev, "%s:request_irq:%d failed:%d", |
| 1749 | __func__, mehci->peripheral_status_irq, ret); |
| 1750 | } |
| 1751 | |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1752 | /* configure wakeup irq */ |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1753 | if (mehci->wakeup_irq) { |
Hemant Kumar | 5e38663 | 2012-08-30 14:23:38 -0700 | [diff] [blame] | 1754 | /* In case if wakeup gpio is pulled high at this point |
| 1755 | * remote wakeup interrupt fires right after request_irq. |
| 1756 | * Remote wake up interrupt only needs to be enabled when |
| 1757 | * HSIC bus goes to suspend. |
| 1758 | */ |
| 1759 | irq_set_status_flags(mehci->wakeup_irq, IRQ_NOAUTOEN); |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1760 | ret = request_irq(mehci->wakeup_irq, msm_hsic_wakeup_irq, |
Hemant Kumar | 6fd6503 | 2012-05-23 13:02:24 -0700 | [diff] [blame] | 1761 | IRQF_TRIGGER_HIGH, |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1762 | "msm_hsic_wakeup", mehci); |
Hemant Kumar | 5e38663 | 2012-08-30 14:23:38 -0700 | [diff] [blame] | 1763 | if (ret) { |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1764 | dev_err(&pdev->dev, "request_irq(%d) failed: %d\n", |
| 1765 | mehci->wakeup_irq, ret); |
| 1766 | mehci->wakeup_irq = 0; |
| 1767 | } |
| 1768 | } |
| 1769 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1770 | ret = ehci_hsic_msm_debugfs_init(mehci); |
| 1771 | if (ret) |
| 1772 | dev_dbg(&pdev->dev, "mode debugfs file is" |
| 1773 | "not available\n"); |
| 1774 | |
| 1775 | if (pdata && pdata->bus_scale_table) { |
| 1776 | mehci->bus_perf_client = |
| 1777 | msm_bus_scale_register_client(pdata->bus_scale_table); |
| 1778 | /* Configure BUS performance parameters for MAX bandwidth */ |
| 1779 | if (mehci->bus_perf_client) { |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 1780 | mehci->bus_vote = true; |
| 1781 | queue_work(ehci_wq, &mehci->bus_vote_w); |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1782 | } else { |
| 1783 | dev_err(&pdev->dev, "%s: Failed to register BUS " |
| 1784 | "scaling client!!\n", __func__); |
| 1785 | } |
| 1786 | } |
| 1787 | |
Hemant Kumar | 105d07f | 2012-07-02 15:33:07 -0700 | [diff] [blame] | 1788 | __mehci = mehci; |
| 1789 | |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1790 | if (pdata && pdata->swfi_latency) |
| 1791 | pm_qos_add_request(&mehci->pm_qos_req_dma, |
| 1792 | PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); |
| 1793 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1794 | /* |
| 1795 | * This pdev->dev is assigned parent of root-hub by USB core, |
| 1796 | * hence, runtime framework automatically calls this driver's |
| 1797 | * runtime APIs based on root-hub's state. |
| 1798 | */ |
| 1799 | pm_runtime_set_active(&pdev->dev); |
| 1800 | pm_runtime_enable(&pdev->dev); |
Vijayavardhan Vennapusa | afbbb8f | 2012-04-13 16:28:45 +0530 | [diff] [blame] | 1801 | /* Decrement the parent device's counter after probe. |
| 1802 | * As child is active, parent will not be put into |
| 1803 | * suspend mode. |
| 1804 | */ |
| 1805 | if (pdev->dev.parent) |
| 1806 | pm_runtime_put_sync(pdev->dev.parent); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1807 | |
| 1808 | return 0; |
| 1809 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 1810 | unconfig_gpio: |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 1811 | destroy_workqueue(ehci_wq); |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 1812 | msm_hsic_config_gpios(mehci, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1813 | deinit_vddcx: |
| 1814 | msm_hsic_init_vddcx(mehci, 0); |
| 1815 | deinit_clocks: |
| 1816 | msm_hsic_init_clocks(mehci, 0); |
| 1817 | unmap: |
| 1818 | iounmap(hcd->regs); |
| 1819 | put_hcd: |
| 1820 | usb_put_hcd(hcd); |
| 1821 | |
| 1822 | return ret; |
| 1823 | } |
| 1824 | |
| 1825 | static int __devexit ehci_hsic_msm_remove(struct platform_device *pdev) |
| 1826 | { |
| 1827 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 1828 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1829 | struct msm_hsic_host_platform_data *pdata = mehci->dev->platform_data; |
| 1830 | |
Pavankumar Kondeti | fff3f2e | 2013-02-12 21:43:56 +0530 | [diff] [blame] | 1831 | /* Remove the HCD prior to releasing our resources. */ |
| 1832 | usb_remove_hcd(hcd); |
| 1833 | |
Pavankumar Kondeti | fe2d4d3 | 2012-09-07 15:33:09 +0530 | [diff] [blame] | 1834 | if (pdata && pdata->swfi_latency) |
| 1835 | pm_qos_remove_request(&mehci->pm_qos_req_dma); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1836 | |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1837 | if (mehci->peripheral_status_irq) |
| 1838 | free_irq(mehci->peripheral_status_irq, mehci); |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 1839 | |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1840 | if (mehci->wakeup_irq) { |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 1841 | if (mehci->wakeup_irq_enabled) |
| 1842 | disable_irq_wake(mehci->wakeup_irq); |
Vamsi Krishna | 6921cbe | 2012-02-21 18:34:43 -0800 | [diff] [blame] | 1843 | free_irq(mehci->wakeup_irq, mehci); |
| 1844 | } |
Vamsi Krishna | 34f0158 | 2011-12-14 19:54:42 -0800 | [diff] [blame] | 1845 | |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 1846 | /* |
| 1847 | * If the update request is called after unregister, the request will |
| 1848 | * fail. Results are undefined if unregister is called in the middle of |
| 1849 | * update request. |
| 1850 | */ |
| 1851 | mehci->bus_vote = false; |
| 1852 | cancel_work_sync(&mehci->bus_vote_w); |
| 1853 | |
Hemant Kumar | e627597 | 2012-02-29 20:06:21 -0800 | [diff] [blame] | 1854 | if (mehci->bus_perf_client) |
| 1855 | msm_bus_scale_unregister_client(mehci->bus_perf_client); |
| 1856 | |
| 1857 | ehci_hsic_msm_debugfs_cleanup(); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1858 | device_init_wakeup(&pdev->dev, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1859 | pm_runtime_set_suspended(&pdev->dev); |
| 1860 | |
Hemant Kumar | 2309eaa | 2012-08-14 16:46:42 -0700 | [diff] [blame] | 1861 | destroy_workqueue(ehci_wq); |
| 1862 | |
Vijayavardhan Vennapusa | e3316a1 | 2011-10-15 06:05:17 +0530 | [diff] [blame] | 1863 | msm_hsic_config_gpios(mehci, 0); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1864 | msm_hsic_init_vddcx(mehci, 0); |
| 1865 | |
| 1866 | msm_hsic_init_clocks(mehci, 0); |
Ajay Dudani | ab3bf19 | 2012-08-28 09:58:04 -0700 | [diff] [blame] | 1867 | wake_lock_destroy(&mehci->wlock); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1868 | iounmap(hcd->regs); |
| 1869 | usb_put_hcd(hcd); |
| 1870 | |
| 1871 | return 0; |
| 1872 | } |
| 1873 | |
| 1874 | #ifdef CONFIG_PM_SLEEP |
| 1875 | static int msm_hsic_pm_suspend(struct device *dev) |
| 1876 | { |
| 1877 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1878 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1879 | |
| 1880 | dev_dbg(dev, "ehci-msm-hsic PM suspend\n"); |
| 1881 | |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1882 | dbg_log_event(NULL, "PM Suspend", 0); |
| 1883 | |
Pavankumar Kondeti | fe31963 | 2013-04-25 13:51:24 +0530 | [diff] [blame^] | 1884 | if (!atomic_read(&mehci->in_lpm)) { |
| 1885 | dev_info(dev, "abort suspend\n"); |
| 1886 | dbg_log_event(NULL, "PM Suspend abort", 0); |
| 1887 | return -EBUSY; |
| 1888 | } |
| 1889 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1890 | if (device_may_wakeup(dev)) |
| 1891 | enable_irq_wake(hcd->irq); |
| 1892 | |
Pavankumar Kondeti | fe31963 | 2013-04-25 13:51:24 +0530 | [diff] [blame^] | 1893 | return 0; |
Jack Pham | fe441ea | 2012-03-23 17:03:15 -0700 | [diff] [blame] | 1894 | } |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1895 | |
Jack Pham | 16b06f8 | 2012-08-14 20:03:59 -0700 | [diff] [blame] | 1896 | static int msm_hsic_pm_suspend_noirq(struct device *dev) |
| 1897 | { |
| 1898 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1899 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1900 | |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 1901 | if (atomic_read(&mehci->async_int)) { |
Jack Pham | 16b06f8 | 2012-08-14 20:03:59 -0700 | [diff] [blame] | 1902 | dev_dbg(dev, "suspend_noirq: Aborting due to pending interrupt\n"); |
| 1903 | return -EBUSY; |
| 1904 | } |
| 1905 | |
| 1906 | return 0; |
| 1907 | } |
| 1908 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1909 | static int msm_hsic_pm_resume(struct device *dev) |
| 1910 | { |
| 1911 | int ret; |
| 1912 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1913 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1914 | |
Jack Pham | 16b06f8 | 2012-08-14 20:03:59 -0700 | [diff] [blame] | 1915 | dev_dbg(dev, "ehci-msm-hsic PM resume\n"); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1916 | dbg_log_event(NULL, "PM Resume", 0); |
| 1917 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1918 | if (device_may_wakeup(dev)) |
| 1919 | disable_irq_wake(hcd->irq); |
| 1920 | |
Pavankumar Kondeti | 1c85169 | 2012-09-18 17:52:51 +0530 | [diff] [blame] | 1921 | /* |
| 1922 | * Keep HSIC in Low Power Mode if system is resumed |
| 1923 | * by any other wakeup source. HSIC is resumed later |
| 1924 | * when remote wakeup is received or interface driver |
| 1925 | * start I/O. |
| 1926 | */ |
Pavankumar Kondeti | 98089c0 | 2012-11-09 10:54:00 +0530 | [diff] [blame] | 1927 | if (!atomic_read(&mehci->pm_usage_cnt) && |
Pavankumar Kondeti | bbd0582 | 2013-01-28 17:04:39 +0530 | [diff] [blame] | 1928 | !atomic_read(&mehci->async_int) && |
Pavankumar Kondeti | 98089c0 | 2012-11-09 10:54:00 +0530 | [diff] [blame] | 1929 | pm_runtime_suspended(dev)) |
Pavankumar Kondeti | 1c85169 | 2012-09-18 17:52:51 +0530 | [diff] [blame] | 1930 | return 0; |
| 1931 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1932 | ret = msm_hsic_resume(mehci); |
| 1933 | if (ret) |
| 1934 | return ret; |
| 1935 | |
| 1936 | /* Bring the device to full powered state upon system resume */ |
| 1937 | pm_runtime_disable(dev); |
| 1938 | pm_runtime_set_active(dev); |
| 1939 | pm_runtime_enable(dev); |
| 1940 | |
| 1941 | return 0; |
| 1942 | } |
| 1943 | #endif |
| 1944 | |
| 1945 | #ifdef CONFIG_PM_RUNTIME |
| 1946 | static int msm_hsic_runtime_idle(struct device *dev) |
| 1947 | { |
| 1948 | dev_dbg(dev, "EHCI runtime idle\n"); |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1949 | return 0; |
| 1950 | } |
| 1951 | |
| 1952 | static int msm_hsic_runtime_suspend(struct device *dev) |
| 1953 | { |
| 1954 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1955 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1956 | |
| 1957 | dev_dbg(dev, "EHCI runtime suspend\n"); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1958 | |
| 1959 | dbg_log_event(NULL, "Run Time PM Suspend", 0); |
| 1960 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1961 | return msm_hsic_suspend(mehci); |
| 1962 | } |
| 1963 | |
| 1964 | static int msm_hsic_runtime_resume(struct device *dev) |
| 1965 | { |
| 1966 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 1967 | struct msm_hsic_hcd *mehci = hcd_to_hsic(hcd); |
| 1968 | |
| 1969 | dev_dbg(dev, "EHCI runtime resume\n"); |
Hemant Kumar | 45d211b | 2012-05-31 17:58:43 -0700 | [diff] [blame] | 1970 | |
| 1971 | dbg_log_event(NULL, "Run Time PM Resume", 0); |
| 1972 | |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1973 | return msm_hsic_resume(mehci); |
| 1974 | } |
| 1975 | #endif |
| 1976 | |
| 1977 | #ifdef CONFIG_PM |
| 1978 | static const struct dev_pm_ops msm_hsic_dev_pm_ops = { |
| 1979 | SET_SYSTEM_SLEEP_PM_OPS(msm_hsic_pm_suspend, msm_hsic_pm_resume) |
Jack Pham | 16b06f8 | 2012-08-14 20:03:59 -0700 | [diff] [blame] | 1980 | .suspend_noirq = msm_hsic_pm_suspend_noirq, |
Vijayavardhan Vennapusa | 39025fe | 2011-10-15 05:55:10 +0530 | [diff] [blame] | 1981 | SET_RUNTIME_PM_OPS(msm_hsic_runtime_suspend, msm_hsic_runtime_resume, |
| 1982 | msm_hsic_runtime_idle) |
| 1983 | }; |
| 1984 | #endif |
| 1985 | |
| 1986 | static struct platform_driver ehci_msm_hsic_driver = { |
| 1987 | .probe = ehci_hsic_msm_probe, |
| 1988 | .remove = __devexit_p(ehci_hsic_msm_remove), |
| 1989 | .driver = { |
| 1990 | .name = "msm_hsic_host", |
| 1991 | #ifdef CONFIG_PM |
| 1992 | .pm = &msm_hsic_dev_pm_ops, |
| 1993 | #endif |
| 1994 | }, |
| 1995 | }; |