blob: 136c6d9718ee30bc5bb9a1b26e0facf42639ec76 [file] [log] [blame]
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/slab.h>
17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h>
Manu Gautamb5067272012-07-02 09:53:41 +053019#include <linux/pm_runtime.h>
20#include <linux/interrupt.h>
Ido Shayevitzef72ddd2012-03-28 18:55:55 +020021#include <linux/ioport.h>
Manu Gautam1742db22012-06-19 13:33:24 +053022#include <linux/clk.h>
Ido Shayevitzef72ddd2012-03-28 18:55:55 +020023#include <linux/io.h>
24#include <linux/module.h>
25#include <linux/types.h>
Ido Shayevitzef72ddd2012-03-28 18:55:55 +020026#include <linux/delay.h>
27#include <linux/of.h>
Ido Shayevitz9fb83452012-04-01 17:45:58 +030028#include <linux/list.h>
Manu Gautamb5067272012-07-02 09:53:41 +053029#include <linux/debugfs.h>
30#include <linux/uaccess.h>
Ido Shayevitz9fb83452012-04-01 17:45:58 +030031#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h>
33#include <linux/usb/msm_hsusb.h>
Manu Gautam60e01352012-05-29 09:00:34 +053034#include <linux/regulator/consumer.h>
35
36#include <mach/rpm-regulator.h>
Ido Shayevitz9fb83452012-04-01 17:45:58 +030037
Manu Gautam8c642812012-06-07 10:35:10 +053038#include "dwc3_otg.h"
Ido Shayevitz9fb83452012-04-01 17:45:58 +030039#include "core.h"
40#include "gadget.h"
41
42/**
43 * USB DBM Hardware registers.
44 *
45 */
46#define DBM_EP_CFG(n) (0x00 + 4 * (n))
47#define DBM_DATA_FIFO(n) (0x10 + 4 * (n))
48#define DBM_DATA_FIFO_SIZE(n) (0x20 + 4 * (n))
49#define DBM_DATA_FIFO_EN (0x30)
50#define DBM_GEVNTADR (0x34)
51#define DBM_GEVNTSIZ (0x38)
52#define DBM_DBG_CNFG (0x3C)
53#define DBM_HW_TRB0_EP(n) (0x40 + 4 * (n))
54#define DBM_HW_TRB1_EP(n) (0x50 + 4 * (n))
55#define DBM_HW_TRB2_EP(n) (0x60 + 4 * (n))
56#define DBM_HW_TRB3_EP(n) (0x70 + 4 * (n))
57#define DBM_PIPE_CFG (0x80)
58#define DBM_SOFT_RESET (0x84)
59
60/**
61 * USB DBM Hardware registers bitmask.
62 *
63 */
64/* DBM_EP_CFG */
65#define DBM_EN_EP 0x00000000
66#define DBM_USB3_EP_NUM 0x0000003E
67#define DBM_BAM_PIPE_NUM 0x000000C0
68#define DBM_PRODUCER 0x00000100
69#define DBM_DISABLE_WB 0x00000200
70#define DBM_INT_RAM_ACC 0x00000400
71
72/* DBM_DATA_FIFO_SIZE */
73#define DBM_DATA_FIFO_SIZE_MASK 0x0000ffff
74
75/* DBM_GEVNTSIZ */
76#define DBM_GEVNTSIZ_MASK 0x0000ffff
77
78/* DBM_DBG_CNFG */
79#define DBM_ENABLE_IOC_MASK 0x0000000f
80
81/* DBM_SOFT_RESET */
82#define DBM_SFT_RST_EP0 0x00000001
83#define DBM_SFT_RST_EP1 0x00000002
84#define DBM_SFT_RST_EP2 0x00000004
85#define DBM_SFT_RST_EP3 0x00000008
86#define DBM_SFT_RST_EPS 0x0000000F
87#define DBM_SFT_RST 0x80000000
Ido Shayevitzef72ddd2012-03-28 18:55:55 +020088
89#define DBM_MAX_EPS 4
90
Ido Shayevitzfa65a582012-06-06 14:39:54 +030091/* DBM TRB configurations */
92#define DBM_TRB_BIT 0x80000000
93#define DBM_TRB_DATA_SRC 0x40000000
94#define DBM_TRB_DMA 0x20000000
95#define DBM_TRB_EP_NUM(ep) (ep<<24)
Manu Gautam8c642812012-06-07 10:35:10 +053096/**
97 * USB QSCRATCH Hardware registers
98 *
99 */
100#define QSCRATCH_REG_OFFSET (0x000F8800)
101#define CHARGING_DET_CTRL_REG (QSCRATCH_REG_OFFSET + 0x18)
102#define CHARGING_DET_OUTPUT_REG (QSCRATCH_REG_OFFSET + 0x1C)
103#define ALT_INTERRUPT_EN_REG (QSCRATCH_REG_OFFSET + 0x20)
104#define HS_PHY_IRQ_STAT_REG (QSCRATCH_REG_OFFSET + 0x24)
105
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300106
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300107struct dwc3_msm_req_complete {
108 struct list_head list_item;
109 struct usb_request *req;
110 void (*orig_complete)(struct usb_ep *ep,
111 struct usb_request *req);
112};
113
Ido Shayevitzef72ddd2012-03-28 18:55:55 +0200114struct dwc3_msm {
115 struct platform_device *dwc3;
116 struct device *dev;
117 void __iomem *base;
118 u32 resource_size;
119 int dbm_num_eps;
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300120 u8 ep_num_mapping[DBM_MAX_EPS];
121 const struct usb_ep_ops *original_ep_ops[DWC3_ENDPOINTS_NUM];
122 struct list_head req_complete_list;
Manu Gautam1742db22012-06-19 13:33:24 +0530123 struct clk *core_clk;
Manu Gautam60e01352012-05-29 09:00:34 +0530124 struct regulator *hsusb_3p3;
125 struct regulator *hsusb_1p8;
126 struct regulator *hsusb_vddcx;
127 struct regulator *ssusb_1p8;
128 struct regulator *ssusb_vddcx;
129 enum usb_vdd_type ss_vdd_type;
130 enum usb_vdd_type hs_vdd_type;
Manu Gautamb5067272012-07-02 09:53:41 +0530131 struct dwc3_ext_xceiv ext_xceiv;
132 bool resume_pending;
133 atomic_t pm_suspended;
134 atomic_t in_lpm;
135 struct delayed_work resume_work;
136 struct wake_lock wlock;
Manu Gautam8c642812012-06-07 10:35:10 +0530137 struct dwc3_charger charger;
138 struct usb_phy *otg_xceiv;
139 struct delayed_work chg_work;
140 enum usb_chg_state chg_state;
141 u8 dcd_retries;
Manu Gautam60e01352012-05-29 09:00:34 +0530142};
143
144#define USB_HSPHY_3P3_VOL_MIN 3050000 /* uV */
145#define USB_HSPHY_3P3_VOL_MAX 3300000 /* uV */
146#define USB_HSPHY_3P3_HPM_LOAD 16000 /* uA */
147
148#define USB_HSPHY_1P8_VOL_MIN 1800000 /* uV */
149#define USB_HSPHY_1P8_VOL_MAX 1800000 /* uV */
150#define USB_HSPHY_1P8_HPM_LOAD 19000 /* uA */
151
152#define USB_SSPHY_1P8_VOL_MIN 1800000 /* uV */
153#define USB_SSPHY_1P8_VOL_MAX 1800000 /* uV */
154#define USB_SSPHY_1P8_HPM_LOAD 23000 /* uA */
155
156#define USB_PHY_VDD_DIG_VOL_NONE 0 /* uV */
157#define USB_PHY_VDD_DIG_VOL_MIN 1045000 /* uV */
158#define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
159
Manu Gautam60e01352012-05-29 09:00:34 +0530160static const int vdd_val[VDD_TYPE_MAX][VDD_VAL_MAX] = {
161 { /* VDD_CX CORNER Voting */
162 [VDD_NONE] = RPM_VREG_CORNER_NONE,
163 [VDD_MIN] = RPM_VREG_CORNER_NOMINAL,
164 [VDD_MAX] = RPM_VREG_CORNER_HIGH,
165 },
166 { /* VDD_CX Voltage Voting */
167 [VDD_NONE] = USB_PHY_VDD_DIG_VOL_NONE,
168 [VDD_MIN] = USB_PHY_VDD_DIG_VOL_MIN,
169 [VDD_MAX] = USB_PHY_VDD_DIG_VOL_MAX,
170 },
Ido Shayevitzef72ddd2012-03-28 18:55:55 +0200171};
172
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300173static struct dwc3_msm *context;
Ido Shayevitzc9e92e92012-05-30 14:36:35 +0300174static u64 dwc3_msm_dma_mask = DMA_BIT_MASK(64);
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300175
176/**
177 *
178 * Read register with debug info.
179 *
180 * @base - DWC3 base virtual address.
181 * @offset - register offset.
182 *
183 * @return u32
184 */
185static inline u32 dwc3_msm_read_reg(void *base, u32 offset)
186{
187 u32 val = ioread32(base + offset);
188 return val;
189}
190
191/**
192 * Read register masked field with debug info.
193 *
194 * @base - DWC3 base virtual address.
195 * @offset - register offset.
196 * @mask - register bitmask.
197 *
198 * @return u32
199 */
200static inline u32 dwc3_msm_read_reg_field(void *base,
201 u32 offset,
202 const u32 mask)
203{
204 u32 shift = find_first_bit((void *)&mask, 32);
205 u32 val = ioread32(base + offset);
206 val &= mask; /* clear other bits */
207 val >>= shift;
208 return val;
209}
210
211/**
212 *
213 * Write register with debug info.
214 *
215 * @base - DWC3 base virtual address.
216 * @offset - register offset.
217 * @val - value to write.
218 *
219 */
220static inline void dwc3_msm_write_reg(void *base, u32 offset, u32 val)
221{
222 iowrite32(val, base + offset);
223}
224
225/**
226 * Write register masked field with debug info.
227 *
228 * @base - DWC3 base virtual address.
229 * @offset - register offset.
230 * @mask - register bitmask.
231 * @val - value to write.
232 *
233 */
234static inline void dwc3_msm_write_reg_field(void *base, u32 offset,
235 const u32 mask, u32 val)
236{
237 u32 shift = find_first_bit((void *)&mask, 32);
238 u32 tmp = ioread32(base + offset);
239
240 tmp &= ~mask; /* clear written bits */
241 val = tmp | (val << shift);
242 iowrite32(val, base + offset);
243}
244
245/**
Manu Gautam8c642812012-06-07 10:35:10 +0530246 * Write register and read back masked value to confirm it is written
247 *
248 * @base - DWC3 base virtual address.
249 * @offset - register offset.
250 * @mask - register bitmask specifying what should be updated
251 * @val - value to write.
252 *
253 */
254static inline void dwc3_msm_write_readback(void *base, u32 offset,
255 const u32 mask, u32 val)
256{
257 u32 write_val, tmp = ioread32(base + offset);
258
259 tmp &= ~mask; /* retain other bits */
260 write_val = tmp | val;
261
262 iowrite32(write_val, base + offset);
263
264 /* Read back to see if val was written */
265 tmp = ioread32(base + offset);
266 tmp &= mask; /* clear other bits */
267
268 if (tmp != val)
269 dev_err(context->dev, "%s: write: %x to QSCRATCH: %x FAILED\n",
270 __func__, val, offset);
271}
272
273/**
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300274 * Return DBM EP number which is not already configured.
275 *
276 */
277static int dwc3_msm_find_avail_dbm_ep(void)
278{
279 int i;
280
281 for (i = 0; i < context->dbm_num_eps; i++)
282 if (!context->ep_num_mapping[i])
283 return i;
284
285 return -ENODEV; /* Not found */
286}
287
288/**
289 * Return DBM EP number according to usb endpoint number.
290 *
291 */
292static int dwc3_msm_find_matching_dbm_ep(u8 usb_ep)
293{
294 int i;
295
296 for (i = 0; i < context->dbm_num_eps; i++)
297 if (context->ep_num_mapping[i] == usb_ep)
298 return i;
299
300 return -ENODEV; /* Not found */
301}
302
303/**
304 * Return number of configured DBM endpoints.
305 *
306 */
307static int dwc3_msm_configured_dbm_ep_num(void)
308{
309 int i;
310 int count = 0;
311
312 for (i = 0; i < context->dbm_num_eps; i++)
313 if (context->ep_num_mapping[i])
314 count++;
315
316 return count;
317}
318
319/**
320 * Configure the DBM with the USB3 core event buffer.
321 * This function is called by the SNPS UDC upon initialization.
322 *
323 * @addr - address of the event buffer.
324 * @size - size of the event buffer.
325 *
326 */
327static int dwc3_msm_event_buffer_config(u32 addr, u16 size)
328{
329 dev_dbg(context->dev, "%s\n", __func__);
330
331 dwc3_msm_write_reg(context->base, DBM_GEVNTADR, addr);
332 dwc3_msm_write_reg_field(context->base, DBM_GEVNTSIZ,
333 DBM_GEVNTSIZ_MASK, size);
334
335 return 0;
336}
337
338/**
339 * Reset the DBM registers upon initialization.
340 *
341 */
342static int dwc3_msm_dbm_soft_reset(void)
343{
344 dev_dbg(context->dev, "%s\n", __func__);
345
346 dwc3_msm_write_reg_field(context->base, DBM_SOFT_RESET,
347 DBM_SFT_RST, 1);
348
349 return 0;
350}
351
352/**
353 * Soft reset specific DBM ep.
354 * This function is called by the function driver upon events
355 * such as transfer aborting, USB re-enumeration and USB
356 * disconnection.
357 *
358 * @dbm_ep - DBM ep number.
359 * @enter_reset - should we enter a reset state or get out of it.
360 *
361 */
362static int dwc3_msm_dbm_ep_soft_reset(u8 dbm_ep, bool enter_reset)
363{
364 dev_dbg(context->dev, "%s\n", __func__);
365
366 if (dbm_ep >= context->dbm_num_eps) {
367 dev_err(context->dev,
368 "%s: Invalid DBM ep index\n", __func__);
369 return -ENODEV;
370 }
371
372 if (enter_reset) {
373 dwc3_msm_write_reg_field(context->base, DBM_SOFT_RESET,
374 DBM_SFT_RST_EPS, 1 << dbm_ep);
375 } else {
376 dwc3_msm_write_reg_field(context->base, DBM_SOFT_RESET,
377 DBM_SFT_RST_EPS, 0);
378 }
379
380 return 0;
381}
382
383/**
384 * Configure a USB DBM ep to work in BAM mode.
385 *
386 *
387 * @usb_ep - USB physical EP number.
388 * @producer - producer/consumer.
389 * @disable_wb - disable write back to system memory.
390 * @internal_mem - use internal USB memory for data fifo.
391 * @ioc - enable interrupt on completion.
392 *
393 * @return int - DBM ep number.
394 */
395static int dwc3_msm_dbm_ep_config(u8 usb_ep, u8 bam_pipe,
396 bool producer, bool disable_wb,
397 bool internal_mem, bool ioc)
398{
399 u8 dbm_ep;
400 u8 ioc_mask;
401
402 dev_dbg(context->dev, "%s\n", __func__);
403
404 dbm_ep = dwc3_msm_find_avail_dbm_ep();
405 if (dbm_ep < 0) {
406 dev_err(context->dev, "%s: No more DBM eps\n", __func__);
407 return -ENODEV;
408 }
409
410 context->ep_num_mapping[dbm_ep] = usb_ep;
411
412 /* First, reset the dbm endpoint */
413 dwc3_msm_dbm_ep_soft_reset(dbm_ep, false);
414
415 ioc_mask = dwc3_msm_read_reg_field(context->base, DBM_DBG_CNFG,
416 DBM_ENABLE_IOC_MASK);
417 ioc_mask &= ~(ioc << dbm_ep); /* Clear ioc bit for dbm_ep */
418 /* Set ioc bit for dbm_ep if needed */
419 dwc3_msm_write_reg_field(context->base, DBM_DBG_CNFG,
420 DBM_ENABLE_IOC_MASK, ioc_mask | (ioc << dbm_ep));
421
422 dwc3_msm_write_reg(context->base, DBM_EP_CFG(dbm_ep),
423 producer | disable_wb | internal_mem);
424 dwc3_msm_write_reg_field(context->base, DBM_EP_CFG(dbm_ep),
425 DBM_USB3_EP_NUM, usb_ep);
426 dwc3_msm_write_reg_field(context->base, DBM_EP_CFG(dbm_ep),
427 DBM_BAM_PIPE_NUM, bam_pipe);
428 dwc3_msm_write_reg_field(context->base, DBM_EP_CFG(dbm_ep),
429 DBM_EN_EP, 1);
430
431 return dbm_ep;
432}
433
434/**
435 * Configure a USB DBM ep to work in normal mode.
436 *
437 * @usb_ep - USB ep number.
438 *
439 */
440static int dwc3_msm_dbm_ep_unconfig(u8 usb_ep)
441{
442 u8 dbm_ep;
443
444 dev_dbg(context->dev, "%s\n", __func__);
445
446 dbm_ep = dwc3_msm_find_matching_dbm_ep(usb_ep);
447
448 if (dbm_ep < 0) {
449 dev_err(context->dev,
450 "%s: Invalid usb ep index\n", __func__);
451 return -ENODEV;
452 }
453
454 context->ep_num_mapping[dbm_ep] = 0;
455
456 dwc3_msm_write_reg(context->base, DBM_EP_CFG(dbm_ep), 0);
457
458 /* Reset the dbm endpoint */
459 dwc3_msm_dbm_ep_soft_reset(dbm_ep, true);
460
461 return 0;
462}
463
464/**
465 * Configure the DBM with the BAM's data fifo.
466 * This function is called by the USB BAM Driver
467 * upon initialization.
468 *
469 * @ep - pointer to usb endpoint.
470 * @addr - address of data fifo.
471 * @size - size of data fifo.
472 *
473 */
474int msm_data_fifo_config(struct usb_ep *ep, u32 addr, u32 size)
475{
476 u8 dbm_ep;
477 struct dwc3_ep *dep = to_dwc3_ep(ep);
478
479 dev_dbg(context->dev, "%s\n", __func__);
480
481 dbm_ep = dwc3_msm_find_matching_dbm_ep(dep->number);
482
483 if (dbm_ep >= context->dbm_num_eps) {
484 dev_err(context->dev,
485 "%s: Invalid DBM ep index\n", __func__);
486 return -ENODEV;
487 }
488
489 dwc3_msm_write_reg(context->base, DBM_DATA_FIFO(dbm_ep), addr);
490 dwc3_msm_write_reg_field(context->base, DBM_DATA_FIFO_SIZE(dbm_ep),
491 DBM_DATA_FIFO_SIZE_MASK, size);
492
493 return 0;
494}
495
496/**
497* Cleanups for msm endpoint on request complete.
498*
499* Also call original request complete.
500*
501* @usb_ep - pointer to usb_ep instance.
502* @request - pointer to usb_request instance.
503*
504* @return int - 0 on success, negetive on error.
505*/
506static void dwc3_msm_req_complete_func(struct usb_ep *ep,
507 struct usb_request *request)
508{
509 struct dwc3_request *req = to_dwc3_request(request);
510 struct dwc3_ep *dep = to_dwc3_ep(ep);
511 struct dwc3_msm_req_complete *req_complete = NULL;
512
513 /* Find original request complete function and remove it from list */
514 list_for_each_entry(req_complete,
515 &context->req_complete_list,
516 list_item) {
517 if (req_complete->req == request)
518 break;
519 }
520 if (!req_complete || req_complete->req != request) {
521 dev_err(dep->dwc->dev, "%s: could not find the request\n",
522 __func__);
523 return;
524 }
525 list_del(&req_complete->list_item);
526
527 /*
528 * Release another one TRB to the pool since DBM queue took 2 TRBs
529 * (normal and link), and the dwc3/gadget.c :: dwc3_gadget_giveback
530 * released only one.
531 */
532 if (req->queued)
533 dep->busy_slot++;
534
535 /* Unconfigure dbm ep */
536 dwc3_msm_dbm_ep_unconfig(dep->number);
537
538 /*
539 * If this is the last endpoint we unconfigured, than reset also
540 * the event buffers.
541 */
542 if (0 == dwc3_msm_configured_dbm_ep_num())
543 dwc3_msm_event_buffer_config(0, 0);
544
545 /*
546 * Call original complete function, notice that dwc->lock is already
547 * taken by the caller of this function (dwc3_gadget_giveback()).
548 */
549 request->complete = req_complete->orig_complete;
550 request->complete(ep, request);
551
552 kfree(req_complete);
553}
554
555/**
556* Helper function.
557* See the header of the dwc3_msm_ep_queue function.
558*
559* @dwc3_ep - pointer to dwc3_ep instance.
560* @req - pointer to dwc3_request instance.
561*
562* @return int - 0 on success, negetive on error.
563*/
564static int __dwc3_msm_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
565{
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300566 struct dwc3_trb *trb;
567 struct dwc3_trb *trb_link;
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300568 struct dwc3_gadget_ep_cmd_params params;
569 u32 cmd;
570 int ret = 0;
571
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300572 /* We push the request to the dep->req_queued list to indicate that
573 * this request is issued with start transfer. The request will be out
574 * from this list in 2 cases. The first is that the transfer will be
575 * completed (not if the transfer is endless using a circular TRBs with
576 * with link TRB). The second case is an option to do stop stransfer,
577 * this can be initiated by the function driver when calling dequeue.
578 */
579 req->queued = true;
580 list_add_tail(&req->list, &dep->req_queued);
581
582 /* First, prepare a normal TRB, point to the fake buffer */
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300583 trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK];
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300584 dep->free_slot++;
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300585 memset(trb, 0, sizeof(*trb));
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300586
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300587 req->trb = trb;
588 req->trb_dma = dwc3_trb_dma_offset(dep, trb);
589 trb->bph = DBM_TRB_BIT | DBM_TRB_DATA_SRC |
590 DBM_TRB_DMA | DBM_TRB_EP_NUM(dep->number);
591 trb->size = DWC3_TRB_SIZE_LENGTH(req->request.length);
592 trb->ctrl = DWC3_TRBCTL_NORMAL | DWC3_TRB_CTRL_HWO | DWC3_TRB_CTRL_CHN;
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300593
594 /* Second, prepare a Link TRB that points to the first TRB*/
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300595 trb_link = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK];
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300596 dep->free_slot++;
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300597
Ido Shayevitzfa65a582012-06-06 14:39:54 +0300598 trb_link->bpl = lower_32_bits(req->trb_dma);
599 trb_link->bph = DBM_TRB_BIT | DBM_TRB_DATA_SRC |
600 DBM_TRB_DMA | DBM_TRB_EP_NUM(dep->number);
601 trb_link->size = 0;
602 trb_link->ctrl = DWC3_TRBCTL_LINK_TRB | DWC3_TRB_CTRL_HWO;
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300603
604 /*
605 * Now start the transfer
606 */
607 memset(&params, 0, sizeof(params));
608 params.param0 = upper_32_bits(req->trb_dma);
609 params.param1 = lower_32_bits(req->trb_dma);
610 cmd = DWC3_DEPCMD_STARTTRANSFER;
611 ret = dwc3_send_gadget_ep_cmd(dep->dwc, dep->number, cmd, &params);
612 if (ret < 0) {
613 dev_dbg(dep->dwc->dev,
614 "%s: failed to send STARTTRANSFER command\n",
615 __func__);
616
Ido Shayevitz9fb83452012-04-01 17:45:58 +0300617 list_del(&req->list);
618 return ret;
619 }
620
621 return ret;
622}
623
624/**
625* Queue a usb request to the DBM endpoint.
626* This function should be called after the endpoint
627* was enabled by the ep_enable.
628*
629* This function prepares special structure of TRBs which
630* is familier with the DBM HW, so it will possible to use
631* this endpoint in DBM mode.
632*
633* The TRBs prepared by this function, is one normal TRB
634* which point to a fake buffer, followed by a link TRB
635* that points to the first TRB.
636*
637* The API of this function follow the regular API of
638* usb_ep_queue (see usb_ep_ops in include/linuk/usb/gadget.h).
639*
640* @usb_ep - pointer to usb_ep instance.
641* @request - pointer to usb_request instance.
642* @gfp_flags - possible flags.
643*
644* @return int - 0 on success, negetive on error.
645*/
646static int dwc3_msm_ep_queue(struct usb_ep *ep,
647 struct usb_request *request, gfp_t gfp_flags)
648{
649 struct dwc3_request *req = to_dwc3_request(request);
650 struct dwc3_ep *dep = to_dwc3_ep(ep);
651 struct dwc3 *dwc = dep->dwc;
652 struct dwc3_msm_req_complete *req_complete;
653 unsigned long flags;
654 int ret = 0;
655 u8 bam_pipe;
656 bool producer;
657 bool disable_wb;
658 bool internal_mem;
659 bool ioc;
660
661 if (!(request->udc_priv & MSM_SPS_MODE)) {
662 /* Not SPS mode, call original queue */
663 dev_vdbg(dwc->dev, "%s: not sps mode, use regular queue\n",
664 __func__);
665
666 return (context->original_ep_ops[dep->number])->queue(ep,
667 request,
668 gfp_flags);
669 }
670
671 if (!dep->endpoint.desc) {
672 dev_err(dwc->dev,
673 "%s: trying to queue request %p to disabled ep %s\n",
674 __func__, request, ep->name);
675 return -EPERM;
676 }
677
678 if (dep->number == 0 || dep->number == 1) {
679 dev_err(dwc->dev,
680 "%s: trying to queue dbm request %p to control ep %s\n",
681 __func__, request, ep->name);
682 return -EPERM;
683 }
684
685 if (dep->free_slot > 0 || dep->busy_slot > 0 ||
686 !list_empty(&dep->request_list) ||
687 !list_empty(&dep->req_queued)) {
688
689 dev_err(dwc->dev,
690 "%s: trying to queue dbm request %p tp ep %s\n",
691 __func__, request, ep->name);
692 return -EPERM;
693 }
694
695 /*
696 * Override req->complete function, but before doing that,
697 * store it's original pointer in the req_complete_list.
698 */
699 req_complete = kzalloc(sizeof(*req_complete), GFP_KERNEL);
700 if (!req_complete) {
701 dev_err(dep->dwc->dev, "%s: not enough memory\n", __func__);
702 return -ENOMEM;
703 }
704 req_complete->req = request;
705 req_complete->orig_complete = request->complete;
706 list_add_tail(&req_complete->list_item, &context->req_complete_list);
707 request->complete = dwc3_msm_req_complete_func;
708
709 /*
710 * Configure dbm event buffers if this is the first
711 * dbm endpoint we about to configure.
712 */
713 if (0 == dwc3_msm_configured_dbm_ep_num())
714 dwc3_msm_event_buffer_config(dwc->ev_buffs[0]->dma,
715 dwc->ev_buffs[0]->length);
716
717 /*
718 * Configure the DBM endpoint
719 */
720 bam_pipe = (request->udc_priv & MSM_PIPE_ID_MASK);
721 producer = ((request->udc_priv & MSM_PRODUCER) ? true : false);
722 disable_wb = ((request->udc_priv & MSM_DISABLE_WB) ? true : false);
723 internal_mem = ((request->udc_priv & MSM_INTERNAL_MEM) ? true : false);
724 ioc = ((request->udc_priv & MSM_ETD_IOC) ? true : false);
725
726 ret = dwc3_msm_dbm_ep_config(dep->number,
727 bam_pipe, producer,
728 disable_wb, internal_mem, ioc);
729 if (ret < 0) {
730 dev_err(context->dev,
731 "error %d after calling dwc3_msm_dbm_ep_config\n",
732 ret);
733 return ret;
734 }
735
736 dev_vdbg(dwc->dev, "%s: queing request %p to ep %s length %d\n",
737 __func__, request, ep->name, request->length);
738
739 /*
740 * We must obtain the lock of the dwc3 core driver,
741 * including disabling interrupts, so we will be sure
742 * that we are the only ones that configure the HW device
743 * core and ensure that we queuing the request will finish
744 * as soon as possible so we will release back the lock.
745 */
746 spin_lock_irqsave(&dwc->lock, flags);
747 ret = __dwc3_msm_ep_queue(dep, req);
748 spin_unlock_irqrestore(&dwc->lock, flags);
749 if (ret < 0) {
750 dev_err(context->dev,
751 "error %d after calling __dwc3_msm_ep_queue\n", ret);
752 return ret;
753 }
754
755 return 0;
756}
757
758/**
759 * Configure MSM endpoint.
760 * This function do specific configurations
761 * to an endpoint which need specific implementaion
762 * in the MSM architecture.
763 *
764 * This function should be called by usb function/class
765 * layer which need a support from the specific MSM HW
766 * which wrap the USB3 core. (like DBM specific endpoints)
767 *
768 * @ep - a pointer to some usb_ep instance
769 *
770 * @return int - 0 on success, negetive on error.
771 */
772int msm_ep_config(struct usb_ep *ep)
773{
774 struct dwc3_ep *dep = to_dwc3_ep(ep);
775 struct usb_ep_ops *new_ep_ops;
776
777 /* Save original ep ops for future restore*/
778 if (context->original_ep_ops[dep->number]) {
779 dev_err(context->dev,
780 "ep [%s,%d] already configured as msm endpoint\n",
781 ep->name, dep->number);
782 return -EPERM;
783 }
784 context->original_ep_ops[dep->number] = ep->ops;
785
786 /* Set new usb ops as we like */
787 new_ep_ops = kzalloc(sizeof(struct usb_ep_ops), GFP_KERNEL);
788 if (!new_ep_ops) {
789 dev_err(context->dev,
790 "%s: unable to allocate mem for new usb ep ops\n",
791 __func__);
792 return -ENOMEM;
793 }
794 (*new_ep_ops) = (*ep->ops);
795 new_ep_ops->queue = dwc3_msm_ep_queue;
796 ep->ops = new_ep_ops;
797
798 /*
799 * Do HERE more usb endpoint configurations
800 * which are specific to MSM.
801 */
802
803 return 0;
804}
805EXPORT_SYMBOL(msm_ep_config);
806
807/**
808 * Un-configure MSM endpoint.
809 * Tear down configurations done in the
810 * dwc3_msm_ep_config function.
811 *
812 * @ep - a pointer to some usb_ep instance
813 *
814 * @return int - 0 on success, negetive on error.
815 */
816int msm_ep_unconfig(struct usb_ep *ep)
817{
818 struct dwc3_ep *dep = to_dwc3_ep(ep);
819 struct usb_ep_ops *old_ep_ops;
820
821 /* Restore original ep ops */
822 if (!context->original_ep_ops[dep->number]) {
823 dev_err(context->dev,
824 "ep [%s,%d] was not configured as msm endpoint\n",
825 ep->name, dep->number);
826 return -EINVAL;
827 }
828 old_ep_ops = (struct usb_ep_ops *)ep->ops;
829 ep->ops = context->original_ep_ops[dep->number];
830 context->original_ep_ops[dep->number] = NULL;
831 kfree(old_ep_ops);
832
833 /*
834 * Do HERE more usb endpoint un-configurations
835 * which are specific to MSM.
836 */
837
838 return 0;
839}
840EXPORT_SYMBOL(msm_ep_unconfig);
841
Manu Gautam60e01352012-05-29 09:00:34 +0530842/* HSPHY */
843static int dwc3_hsusb_config_vddcx(int high)
844{
845 int min_vol, ret;
846 struct dwc3_msm *dwc = context;
847 enum usb_vdd_type vdd_type = context->hs_vdd_type;
848 int max_vol = vdd_val[vdd_type][VDD_MAX];
849
850 min_vol = vdd_val[vdd_type][high ? VDD_MIN : VDD_NONE];
851 ret = regulator_set_voltage(dwc->hsusb_vddcx, min_vol, max_vol);
852 if (ret) {
853 dev_err(dwc->dev, "unable to set voltage for HSUSB_VDDCX\n");
854 return ret;
855 }
856
857 dev_dbg(dwc->dev, "%s: min_vol:%d max_vol:%d\n", __func__,
858 min_vol, max_vol);
859
860 return ret;
861}
862
863static int dwc3_hsusb_ldo_init(int init)
864{
865 int rc = 0;
866 struct dwc3_msm *dwc = context;
867
868 if (!init) {
869 regulator_set_voltage(dwc->hsusb_1p8, 0, USB_HSPHY_1P8_VOL_MAX);
870 regulator_set_voltage(dwc->hsusb_3p3, 0, USB_HSPHY_3P3_VOL_MAX);
871 return 0;
872 }
873
874 dwc->hsusb_3p3 = devm_regulator_get(dwc->dev, "HSUSB_3p3");
875 if (IS_ERR(dwc->hsusb_3p3)) {
876 dev_err(dwc->dev, "unable to get hsusb 3p3\n");
877 return PTR_ERR(dwc->hsusb_3p3);
878 }
879
880 rc = regulator_set_voltage(dwc->hsusb_3p3,
881 USB_HSPHY_3P3_VOL_MIN, USB_HSPHY_3P3_VOL_MAX);
882 if (rc) {
883 dev_err(dwc->dev, "unable to set voltage for hsusb 3p3\n");
884 return rc;
885 }
886 dwc->hsusb_1p8 = devm_regulator_get(dwc->dev, "HSUSB_1p8");
887 if (IS_ERR(dwc->hsusb_1p8)) {
888 dev_err(dwc->dev, "unable to get hsusb 1p8\n");
889 rc = PTR_ERR(dwc->hsusb_1p8);
890 goto devote_3p3;
891 }
892 rc = regulator_set_voltage(dwc->hsusb_1p8,
893 USB_HSPHY_1P8_VOL_MIN, USB_HSPHY_1P8_VOL_MAX);
894 if (rc) {
895 dev_err(dwc->dev, "unable to set voltage for hsusb 1p8\n");
896 goto devote_3p3;
897 }
898
899 return 0;
900
901devote_3p3:
902 regulator_set_voltage(dwc->hsusb_3p3, 0, USB_HSPHY_3P3_VOL_MAX);
903
904 return rc;
905}
906
907static int dwc3_hsusb_ldo_enable(int on)
908{
909 int rc = 0;
910 struct dwc3_msm *dwc = context;
911
912 dev_dbg(dwc->dev, "reg (%s)\n", on ? "HPM" : "LPM");
913
914 if (!on)
915 goto disable_regulators;
916
917
918 rc = regulator_set_optimum_mode(dwc->hsusb_1p8, USB_HSPHY_1P8_HPM_LOAD);
919 if (rc < 0) {
920 dev_err(dwc->dev, "Unable to set HPM of regulator HSUSB_1p8\n");
921 return rc;
922 }
923
924 rc = regulator_enable(dwc->hsusb_1p8);
925 if (rc) {
926 dev_err(dwc->dev, "Unable to enable HSUSB_1p8\n");
927 goto put_1p8_lpm;
928 }
929
930 rc = regulator_set_optimum_mode(dwc->hsusb_3p3, USB_HSPHY_3P3_HPM_LOAD);
931 if (rc < 0) {
932 dev_err(dwc->dev, "Unable to set HPM of regulator HSUSB_3p3\n");
933 goto disable_1p8;
934 }
935
936 rc = regulator_enable(dwc->hsusb_3p3);
937 if (rc) {
938 dev_err(dwc->dev, "Unable to enable HSUSB_3p3\n");
939 goto put_3p3_lpm;
940 }
941
942 return 0;
943
944disable_regulators:
945 rc = regulator_disable(dwc->hsusb_3p3);
946 if (rc)
947 dev_err(dwc->dev, "Unable to disable HSUSB_3p3\n");
948
949put_3p3_lpm:
950 rc = regulator_set_optimum_mode(dwc->hsusb_3p3, 0);
951 if (rc < 0)
952 dev_err(dwc->dev, "Unable to set LPM of regulator HSUSB_3p3\n");
953
954disable_1p8:
955 rc = regulator_disable(dwc->hsusb_1p8);
956 if (rc)
957 dev_err(dwc->dev, "Unable to disable HSUSB_1p8\n");
958
959put_1p8_lpm:
960 rc = regulator_set_optimum_mode(dwc->hsusb_1p8, 0);
961 if (rc < 0)
962 dev_err(dwc->dev, "Unable to set LPM of regulator HSUSB_1p8\n");
963
964 return rc < 0 ? rc : 0;
965}
966
967/* SSPHY */
968static int dwc3_ssusb_config_vddcx(int high)
969{
970 int min_vol, ret;
971 struct dwc3_msm *dwc = context;
972 enum usb_vdd_type vdd_type = context->ss_vdd_type;
973 int max_vol = vdd_val[vdd_type][VDD_MAX];
974
975 min_vol = vdd_val[vdd_type][high ? VDD_MIN : VDD_NONE];
976 ret = regulator_set_voltage(dwc->ssusb_vddcx, min_vol, max_vol);
977 if (ret) {
978 dev_err(dwc->dev, "unable to set voltage for SSUSB_VDDCX\n");
979 return ret;
980 }
981
982 dev_dbg(dwc->dev, "%s: min_vol:%d max_vol:%d\n", __func__,
983 min_vol, max_vol);
984 return ret;
985}
986
987/* 3.3v supply not needed for SS PHY */
988static int dwc3_ssusb_ldo_init(int init)
989{
990 int rc = 0;
991 struct dwc3_msm *dwc = context;
992
993 if (!init) {
994 regulator_set_voltage(dwc->ssusb_1p8, 0, USB_SSPHY_1P8_VOL_MAX);
995 return 0;
996 }
997
998 dwc->ssusb_1p8 = devm_regulator_get(dwc->dev, "SSUSB_1p8");
999 if (IS_ERR(dwc->ssusb_1p8)) {
1000 dev_err(dwc->dev, "unable to get ssusb 1p8\n");
1001 return PTR_ERR(dwc->ssusb_1p8);
1002 }
1003 rc = regulator_set_voltage(dwc->ssusb_1p8,
1004 USB_SSPHY_1P8_VOL_MIN, USB_SSPHY_1P8_VOL_MAX);
1005 if (rc)
1006 dev_err(dwc->dev, "unable to set voltage for ssusb 1p8\n");
1007
1008 return rc;
1009}
1010
1011static int dwc3_ssusb_ldo_enable(int on)
1012{
1013 int rc = 0;
1014 struct dwc3_msm *dwc = context;
1015
1016 dev_dbg(context->dev, "reg (%s)\n", on ? "HPM" : "LPM");
1017
1018 if (!on)
1019 goto disable_regulators;
1020
1021
1022 rc = regulator_set_optimum_mode(dwc->ssusb_1p8, USB_SSPHY_1P8_HPM_LOAD);
1023 if (rc < 0) {
1024 dev_err(dwc->dev, "Unable to set HPM of SSUSB_1p8\n");
1025 return rc;
1026 }
1027
1028 rc = regulator_enable(dwc->ssusb_1p8);
1029 if (rc) {
1030 dev_err(dwc->dev, "Unable to enable SSUSB_1p8\n");
1031 goto put_1p8_lpm;
1032 }
1033
1034 return 0;
1035
1036disable_regulators:
1037 rc = regulator_disable(dwc->ssusb_1p8);
1038 if (rc)
1039 dev_err(dwc->dev, "Unable to disable SSUSB_1p8\n");
1040
1041put_1p8_lpm:
1042 rc = regulator_set_optimum_mode(dwc->ssusb_1p8, 0);
1043 if (rc < 0)
1044 dev_err(dwc->dev, "Unable to set LPM of SSUSB_1p8\n");
1045
1046 return rc < 0 ? rc : 0;
1047}
1048
Manu Gautam8c642812012-06-07 10:35:10 +05301049static void dwc3_chg_enable_secondary_det(struct dwc3_msm *mdwc)
1050{
1051 u32 chg_ctrl;
1052
1053 /* Turn off VDP_SRC */
1054 dwc3_msm_write_reg(mdwc->base, CHARGING_DET_CTRL_REG, 0x0);
1055 msleep(20);
1056
1057 /* Before proceeding make sure VDP_SRC is OFF */
1058 chg_ctrl = dwc3_msm_read_reg(mdwc->base, CHARGING_DET_CTRL_REG);
1059 if (chg_ctrl & 0x3F)
1060 dev_err(mdwc->dev, "%s Unable to reset chg_det block: %x\n",
1061 __func__, chg_ctrl);
1062 /*
1063 * Configure DM as current source, DP as current sink
1064 * and enable battery charging comparators.
1065 */
1066 dwc3_msm_write_readback(mdwc->base, CHARGING_DET_CTRL_REG, 0x3F, 0x34);
1067}
1068
1069static bool dwc3_chg_det_check_output(struct dwc3_msm *mdwc)
1070{
1071 u32 chg_det;
1072 bool ret = false;
1073
1074 chg_det = dwc3_msm_read_reg(mdwc->base, CHARGING_DET_OUTPUT_REG);
1075 ret = chg_det & 1;
1076
1077 return ret;
1078}
1079
1080static void dwc3_chg_enable_primary_det(struct dwc3_msm *mdwc)
1081{
1082 /*
1083 * Configure DP as current source, DM as current sink
1084 * and enable battery charging comparators.
1085 */
1086 dwc3_msm_write_readback(mdwc->base, CHARGING_DET_CTRL_REG, 0x3F, 0x30);
1087}
1088
1089static inline bool dwc3_chg_check_dcd(struct dwc3_msm *mdwc)
1090{
1091 u32 chg_state;
1092 bool ret = false;
1093
1094 chg_state = dwc3_msm_read_reg(mdwc->base, CHARGING_DET_OUTPUT_REG);
1095 ret = chg_state & 2;
1096
1097 return ret;
1098}
1099
1100static inline void dwc3_chg_disable_dcd(struct dwc3_msm *mdwc)
1101{
1102 dwc3_msm_write_readback(mdwc->base, CHARGING_DET_CTRL_REG, 0x3F, 0x0);
1103}
1104
1105static inline void dwc3_chg_enable_dcd(struct dwc3_msm *mdwc)
1106{
1107 /* Data contact detection enable, DCDENB */
1108 dwc3_msm_write_readback(mdwc->base, CHARGING_DET_CTRL_REG, 0x3F, 0x2);
1109}
1110
1111static void dwc3_chg_block_reset(struct dwc3_msm *mdwc)
1112{
1113 u32 chg_ctrl;
1114
1115 /* Clear charger detecting control bits */
1116 dwc3_msm_write_reg(mdwc->base, CHARGING_DET_CTRL_REG, 0x0);
1117
1118 /* Clear alt interrupt latch and enable bits */
1119 dwc3_msm_write_reg(mdwc->base, HS_PHY_IRQ_STAT_REG, 0xFFF);
1120 dwc3_msm_write_reg(mdwc->base, ALT_INTERRUPT_EN_REG, 0x0);
1121
1122 udelay(100);
1123
1124 /* Before proceeding make sure charger block is RESET */
1125 chg_ctrl = dwc3_msm_read_reg(mdwc->base, CHARGING_DET_CTRL_REG);
1126 if (chg_ctrl & 0x3F)
1127 dev_err(mdwc->dev, "%s Unable to reset chg_det block: %x\n",
1128 __func__, chg_ctrl);
1129}
1130
1131static const char *chg_to_string(enum dwc3_chg_type chg_type)
1132{
1133 switch (chg_type) {
1134 case USB_SDP_CHARGER: return "USB_SDP_CHARGER";
1135 case USB_DCP_CHARGER: return "USB_DCP_CHARGER";
1136 case USB_CDP_CHARGER: return "USB_CDP_CHARGER";
1137 default: return "INVALID_CHARGER";
1138 }
1139}
1140
1141#define DWC3_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */
1142#define DWC3_CHG_DCD_MAX_RETRIES 6 /* Tdcd_tmout = 6 * 100 msec */
1143#define DWC3_CHG_PRIMARY_DET_TIME (50 * HZ/1000) /* TVDPSRC_ON */
1144#define DWC3_CHG_SECONDARY_DET_TIME (50 * HZ/1000) /* TVDMSRC_ON */
1145
1146static void dwc3_chg_detect_work(struct work_struct *w)
1147{
1148 struct dwc3_msm *mdwc = container_of(w, struct dwc3_msm, chg_work.work);
1149 bool is_dcd = false, tmout, vout;
1150 unsigned long delay;
1151
1152 dev_dbg(mdwc->dev, "chg detection work\n");
1153 switch (mdwc->chg_state) {
1154 case USB_CHG_STATE_UNDEFINED:
1155 dwc3_chg_block_reset(mdwc);
1156 dwc3_chg_enable_dcd(mdwc);
1157 mdwc->chg_state = USB_CHG_STATE_WAIT_FOR_DCD;
1158 mdwc->dcd_retries = 0;
1159 delay = DWC3_CHG_DCD_POLL_TIME;
1160 break;
1161 case USB_CHG_STATE_WAIT_FOR_DCD:
1162 is_dcd = dwc3_chg_check_dcd(mdwc);
1163 tmout = ++mdwc->dcd_retries == DWC3_CHG_DCD_MAX_RETRIES;
1164 if (is_dcd || tmout) {
1165 dwc3_chg_disable_dcd(mdwc);
1166 dwc3_chg_enable_primary_det(mdwc);
1167 delay = DWC3_CHG_PRIMARY_DET_TIME;
1168 mdwc->chg_state = USB_CHG_STATE_DCD_DONE;
1169 } else {
1170 delay = DWC3_CHG_DCD_POLL_TIME;
1171 }
1172 break;
1173 case USB_CHG_STATE_DCD_DONE:
1174 vout = dwc3_chg_det_check_output(mdwc);
1175 if (vout) {
1176 dwc3_chg_enable_secondary_det(mdwc);
1177 delay = DWC3_CHG_SECONDARY_DET_TIME;
1178 mdwc->chg_state = USB_CHG_STATE_PRIMARY_DONE;
1179 } else {
1180 mdwc->charger.chg_type = USB_SDP_CHARGER;
1181 mdwc->chg_state = USB_CHG_STATE_DETECTED;
1182 delay = 0;
1183 }
1184 break;
1185 case USB_CHG_STATE_PRIMARY_DONE:
1186 vout = dwc3_chg_det_check_output(mdwc);
1187 if (vout)
1188 mdwc->charger.chg_type = USB_DCP_CHARGER;
1189 else
1190 mdwc->charger.chg_type = USB_CDP_CHARGER;
1191 mdwc->chg_state = USB_CHG_STATE_SECONDARY_DONE;
1192 /* fall through */
1193 case USB_CHG_STATE_SECONDARY_DONE:
1194 mdwc->chg_state = USB_CHG_STATE_DETECTED;
1195 /* fall through */
1196 case USB_CHG_STATE_DETECTED:
1197 dwc3_chg_block_reset(mdwc);
1198 dev_dbg(mdwc->dev, "chg_type = %s\n",
1199 chg_to_string(mdwc->charger.chg_type));
1200 mdwc->charger.notify_detection_complete(mdwc->otg_xceiv->otg,
1201 &mdwc->charger);
1202 return;
1203 default:
1204 return;
1205 }
1206
1207 queue_delayed_work(system_nrt_wq, &mdwc->chg_work, delay);
1208}
1209
1210static void dwc3_start_chg_det(struct dwc3_charger *charger, bool start)
1211{
1212 struct dwc3_msm *mdwc = context;
1213
1214 if (start == false) {
1215 cancel_delayed_work_sync(&mdwc->chg_work);
1216 mdwc->chg_state = USB_CHG_STATE_UNDEFINED;
1217 charger->chg_type = DWC3_INVALID_CHARGER;
1218 return;
1219 }
1220
1221 mdwc->chg_state = USB_CHG_STATE_UNDEFINED;
1222 charger->chg_type = DWC3_INVALID_CHARGER;
1223 queue_delayed_work(system_nrt_wq, &mdwc->chg_work, 0);
1224}
1225
Manu Gautamb5067272012-07-02 09:53:41 +05301226static int dwc3_msm_suspend(struct dwc3_msm *mdwc)
1227{
1228 dev_dbg(mdwc->dev, "%s: entering lpm\n", __func__);
1229
1230 if (atomic_read(&mdwc->in_lpm)) {
1231 dev_dbg(mdwc->dev, "%s: Already suspended\n", __func__);
1232 return 0;
1233 }
1234
1235 clk_disable_unprepare(mdwc->core_clk);
1236 dwc3_hsusb_ldo_enable(0);
1237 dwc3_ssusb_ldo_enable(0);
1238 wake_unlock(&mdwc->wlock);
1239
1240 atomic_set(&mdwc->in_lpm, 1);
1241 dev_info(mdwc->dev, "DWC3 in low power mode\n");
1242
1243 return 0;
1244}
1245
1246static int dwc3_msm_resume(struct dwc3_msm *mdwc)
1247{
1248 dev_dbg(mdwc->dev, "%s: exiting lpm\n", __func__);
1249
1250 if (!atomic_read(&mdwc->in_lpm)) {
1251 dev_dbg(mdwc->dev, "%s: Already resumed\n", __func__);
1252 return 0;
1253 }
1254
1255 wake_lock(&mdwc->wlock);
1256 clk_prepare_enable(mdwc->core_clk);
1257 dwc3_hsusb_ldo_enable(1);
1258 dwc3_ssusb_ldo_enable(1);
1259
1260 atomic_set(&mdwc->in_lpm, 0);
1261 dev_info(mdwc->dev, "DWC3 exited from low power mode\n");
1262
1263 return 0;
1264}
1265
1266static void dwc3_resume_work(struct work_struct *w)
1267{
1268 struct dwc3_msm *mdwc = container_of(w, struct dwc3_msm,
1269 resume_work.work);
1270
1271 dev_dbg(mdwc->dev, "%s: dwc3 resume work\n", __func__);
1272 /* handle any event that was queued while work was already running */
1273 if (!atomic_read(&mdwc->in_lpm)) {
1274 dev_dbg(mdwc->dev, "%s: notifying xceiv event\n", __func__);
1275 if (mdwc->otg_xceiv)
1276 mdwc->ext_xceiv.notify_ext_events(mdwc->otg_xceiv->otg,
1277 DWC3_EVENT_XCEIV_STATE);
1278 return;
1279 }
1280
1281 /* bail out if system resume in process, else initiate RESUME */
1282 if (atomic_read(&mdwc->pm_suspended)) {
1283 mdwc->resume_pending = true;
1284 } else {
1285 pm_runtime_get_sync(mdwc->dev);
1286 if (mdwc->otg_xceiv)
1287 mdwc->ext_xceiv.notify_ext_events(mdwc->otg_xceiv->otg,
1288 DWC3_EVENT_PHY_RESUME);
1289 pm_runtime_put_sync(mdwc->dev);
1290 }
1291}
1292
1293static bool debug_id, debug_bsv, debug_connect;
1294
1295static int dwc3_connect_show(struct seq_file *s, void *unused)
1296{
1297 if (debug_connect)
1298 seq_printf(s, "true\n");
1299 else
1300 seq_printf(s, "false\n");
1301
1302 return 0;
1303}
1304
1305static int dwc3_connect_open(struct inode *inode, struct file *file)
1306{
1307 return single_open(file, dwc3_connect_show, inode->i_private);
1308}
1309
1310static ssize_t dwc3_connect_write(struct file *file, const char __user *ubuf,
1311 size_t count, loff_t *ppos)
1312{
1313 struct seq_file *s = file->private_data;
1314 struct dwc3_msm *mdwc = s->private;
1315 char buf[8];
1316
1317 memset(buf, 0x00, sizeof(buf));
1318
1319 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
1320 return -EFAULT;
1321
1322 if (!strncmp(buf, "enable", 6) || !strncmp(buf, "true", 4)) {
1323 debug_connect = true;
1324 } else {
1325 debug_connect = debug_bsv = false;
1326 debug_id = true;
1327 }
1328
1329 mdwc->ext_xceiv.bsv = debug_bsv;
1330 mdwc->ext_xceiv.id = debug_id ? DWC3_ID_FLOAT : DWC3_ID_GROUND;
1331
1332 if (atomic_read(&mdwc->in_lpm)) {
1333 dev_dbg(mdwc->dev, "%s: calling resume_work\n", __func__);
1334 dwc3_resume_work(&mdwc->resume_work.work);
1335 } else {
1336 dev_dbg(mdwc->dev, "%s: notifying xceiv event\n", __func__);
1337 if (mdwc->otg_xceiv)
1338 mdwc->ext_xceiv.notify_ext_events(mdwc->otg_xceiv->otg,
1339 DWC3_EVENT_XCEIV_STATE);
1340 }
1341
1342 return count;
1343}
1344
1345const struct file_operations dwc3_connect_fops = {
1346 .open = dwc3_connect_open,
1347 .read = seq_read,
1348 .write = dwc3_connect_write,
1349 .llseek = seq_lseek,
1350 .release = single_release,
1351};
1352
1353static struct dentry *dwc3_debugfs_root;
1354
1355static void dwc3_debugfs_init(struct dwc3_msm *mdwc)
1356{
1357 dwc3_debugfs_root = debugfs_create_dir("msm_dwc3", NULL);
1358
1359 if (!dwc3_debugfs_root || IS_ERR(dwc3_debugfs_root))
1360 return;
1361
1362 if (!debugfs_create_bool("id", S_IRUGO | S_IWUSR, dwc3_debugfs_root,
1363 (u32 *)&debug_id))
1364 goto error;
1365
1366 if (!debugfs_create_bool("bsv", S_IRUGO | S_IWUSR, dwc3_debugfs_root,
1367 (u32 *)&debug_bsv))
1368 goto error;
1369
1370 if (!debugfs_create_file("connect", S_IRUGO | S_IWUSR,
1371 dwc3_debugfs_root, mdwc, &dwc3_connect_fops))
1372 goto error;
1373
1374 return;
1375
1376error:
1377 debugfs_remove_recursive(dwc3_debugfs_root);
1378}
Manu Gautam8c642812012-06-07 10:35:10 +05301379
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001380static int __devinit dwc3_msm_probe(struct platform_device *pdev)
1381{
1382 struct device_node *node = pdev->dev.of_node;
1383 struct platform_device *dwc3;
1384 struct dwc3_msm *msm;
1385 struct resource *res;
1386 int ret = 0;
1387
1388 msm = devm_kzalloc(&pdev->dev, sizeof(*msm), GFP_KERNEL);
1389 if (!msm) {
1390 dev_err(&pdev->dev, "not enough memory\n");
1391 return -ENOMEM;
1392 }
1393
1394 platform_set_drvdata(pdev, msm);
Ido Shayevitz9fb83452012-04-01 17:45:58 +03001395 context = msm;
Manu Gautam60e01352012-05-29 09:00:34 +05301396 msm->dev = &pdev->dev;
Ido Shayevitz9fb83452012-04-01 17:45:58 +03001397
1398 INIT_LIST_HEAD(&msm->req_complete_list);
Manu Gautam8c642812012-06-07 10:35:10 +05301399 INIT_DELAYED_WORK(&msm->chg_work, dwc3_chg_detect_work);
Manu Gautamb5067272012-07-02 09:53:41 +05301400 INIT_DELAYED_WORK(&msm->resume_work, dwc3_resume_work);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001401
Manu Gautam1742db22012-06-19 13:33:24 +05301402 /*
1403 * DWC3 Core requires its CORE CLK (aka master / bus clk) to
1404 * run at 125Mhz in SSUSB mode and >60MHZ for HSUSB mode.
1405 */
1406 msm->core_clk = devm_clk_get(&pdev->dev, "core_clk");
1407 if (IS_ERR(msm->core_clk)) {
1408 dev_err(&pdev->dev, "failed to get core_clk\n");
1409 return PTR_ERR(msm->core_clk);
1410 }
1411 clk_set_rate(msm->core_clk, 125000000);
1412 clk_prepare_enable(msm->core_clk);
1413
Manu Gautam60e01352012-05-29 09:00:34 +05301414 /* SS PHY */
1415 msm->ss_vdd_type = VDDCX_CORNER;
1416 msm->ssusb_vddcx = devm_regulator_get(&pdev->dev, "ssusb_vdd_dig");
1417 if (IS_ERR(msm->ssusb_vddcx)) {
1418 msm->ssusb_vddcx = devm_regulator_get(&pdev->dev,
1419 "SSUSB_VDDCX");
1420 if (IS_ERR(msm->ssusb_vddcx)) {
1421 dev_err(&pdev->dev, "unable to get ssusb vddcx\n");
Manu Gautam1742db22012-06-19 13:33:24 +05301422 ret = PTR_ERR(msm->ssusb_vddcx);
1423 goto disable_core_clk;
Manu Gautam60e01352012-05-29 09:00:34 +05301424 }
1425 msm->ss_vdd_type = VDDCX;
1426 dev_dbg(&pdev->dev, "ss_vdd_type: VDDCX\n");
1427 }
1428
1429 ret = dwc3_ssusb_config_vddcx(1);
1430 if (ret) {
1431 dev_err(&pdev->dev, "ssusb vddcx configuration failed\n");
Manu Gautam1742db22012-06-19 13:33:24 +05301432 goto disable_core_clk;
Manu Gautam60e01352012-05-29 09:00:34 +05301433 }
1434
1435 ret = regulator_enable(context->ssusb_vddcx);
1436 if (ret) {
1437 dev_err(&pdev->dev, "unable to enable the ssusb vddcx\n");
1438 goto unconfig_ss_vddcx;
1439 }
1440
1441 ret = dwc3_ssusb_ldo_init(1);
1442 if (ret) {
1443 dev_err(&pdev->dev, "ssusb vreg configuration failed\n");
1444 goto disable_ss_vddcx;
1445 }
1446
1447 ret = dwc3_ssusb_ldo_enable(1);
1448 if (ret) {
1449 dev_err(&pdev->dev, "ssusb vreg enable failed\n");
1450 goto free_ss_ldo_init;
1451 }
1452
1453 /* HS PHY */
1454 msm->hs_vdd_type = VDDCX_CORNER;
1455 msm->hsusb_vddcx = devm_regulator_get(&pdev->dev, "hsusb_vdd_dig");
1456 if (IS_ERR(msm->hsusb_vddcx)) {
1457 msm->hsusb_vddcx = devm_regulator_get(&pdev->dev,
1458 "HSUSB_VDDCX");
1459 if (IS_ERR(msm->hsusb_vddcx)) {
1460 dev_err(&pdev->dev, "unable to get hsusb vddcx\n");
1461 ret = PTR_ERR(msm->ssusb_vddcx);
1462 goto disable_ss_ldo;
1463 }
1464 msm->hs_vdd_type = VDDCX;
1465 dev_dbg(&pdev->dev, "hs_vdd_type: VDDCX\n");
1466 }
1467
1468 ret = dwc3_hsusb_config_vddcx(1);
1469 if (ret) {
1470 dev_err(&pdev->dev, "hsusb vddcx configuration failed\n");
1471 goto disable_ss_ldo;
1472 }
1473
1474 ret = regulator_enable(context->hsusb_vddcx);
1475 if (ret) {
1476 dev_err(&pdev->dev, "unable to enable the hsusb vddcx\n");
1477 goto unconfig_hs_vddcx;
1478 }
1479
1480 ret = dwc3_hsusb_ldo_init(1);
1481 if (ret) {
1482 dev_err(&pdev->dev, "hsusb vreg configuration failed\n");
1483 goto disable_hs_vddcx;
1484 }
1485
1486 ret = dwc3_hsusb_ldo_enable(1);
1487 if (ret) {
1488 dev_err(&pdev->dev, "hsusb vreg enable failed\n");
1489 goto free_hs_ldo_init;
1490 }
1491
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001492 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1493 if (!res) {
1494 dev_err(&pdev->dev, "missing memory base resource\n");
Manu Gautam60e01352012-05-29 09:00:34 +05301495 ret = -ENODEV;
1496 goto disable_hs_ldo;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001497 }
1498
1499 msm->base = devm_ioremap_nocache(&pdev->dev, res->start,
1500 resource_size(res));
1501 if (!msm->base) {
1502 dev_err(&pdev->dev, "ioremap failed\n");
Manu Gautam60e01352012-05-29 09:00:34 +05301503 ret = -ENODEV;
1504 goto disable_hs_ldo;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001505 }
1506
Ido Shayevitzca2691e2012-04-17 15:54:53 +03001507 dwc3 = platform_device_alloc("dwc3", -1);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001508 if (!dwc3) {
1509 dev_err(&pdev->dev, "couldn't allocate dwc3 device\n");
Manu Gautam60e01352012-05-29 09:00:34 +05301510 ret = -ENODEV;
1511 goto disable_hs_ldo;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001512 }
1513
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001514 dwc3->dev.parent = &pdev->dev;
Ido Shayevitzc9e92e92012-05-30 14:36:35 +03001515 dwc3->dev.coherent_dma_mask = DMA_BIT_MASK(32);
1516 dwc3->dev.dma_mask = &dwc3_msm_dma_mask;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001517 dwc3->dev.dma_parms = pdev->dev.dma_parms;
1518 msm->resource_size = resource_size(res);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001519 msm->dwc3 = dwc3;
1520
Manu Gautamb5067272012-07-02 09:53:41 +05301521 pm_runtime_set_active(msm->dev);
1522 pm_runtime_enable(msm->dev);
1523
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001524 if (of_property_read_u32(node, "qcom,dwc-usb3-msm-dbm-eps",
1525 &msm->dbm_num_eps)) {
1526 dev_err(&pdev->dev,
1527 "unable to read platform data num of dbm eps\n");
1528 msm->dbm_num_eps = DBM_MAX_EPS;
1529 }
1530
1531 if (msm->dbm_num_eps > DBM_MAX_EPS) {
1532 dev_err(&pdev->dev,
1533 "Driver doesn't support number of DBM EPs. "
1534 "max: %d, dbm_num_eps: %d\n",
1535 DBM_MAX_EPS, msm->dbm_num_eps);
1536 ret = -ENODEV;
Manu Gautam60e01352012-05-29 09:00:34 +05301537 goto put_pdev;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001538 }
1539
1540 ret = platform_device_add_resources(dwc3, pdev->resource,
1541 pdev->num_resources);
1542 if (ret) {
1543 dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n");
Manu Gautam60e01352012-05-29 09:00:34 +05301544 goto put_pdev;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001545 }
1546
1547 ret = platform_device_add(dwc3);
1548 if (ret) {
1549 dev_err(&pdev->dev, "failed to register dwc3 device\n");
Manu Gautam60e01352012-05-29 09:00:34 +05301550 goto put_pdev;
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001551 }
1552
Ido Shayevitz9fb83452012-04-01 17:45:58 +03001553 /* Reset the DBM */
1554 dwc3_msm_dbm_soft_reset();
1555
Manu Gautam8c642812012-06-07 10:35:10 +05301556 msm->otg_xceiv = usb_get_transceiver();
1557 if (msm->otg_xceiv) {
1558 msm->charger.start_detection = dwc3_start_chg_det;
1559 ret = dwc3_set_charger(msm->otg_xceiv->otg, &msm->charger);
1560 if (ret || !msm->charger.notify_detection_complete) {
1561 dev_err(&pdev->dev, "failed to register charger: %d\n",
1562 ret);
1563 goto put_xcvr;
1564 }
Manu Gautamb5067272012-07-02 09:53:41 +05301565
1566 ret = dwc3_set_ext_xceiv(msm->otg_xceiv->otg, &msm->ext_xceiv);
1567 if (ret || !msm->ext_xceiv.notify_ext_events) {
1568 dev_err(&pdev->dev, "failed to register xceiver: %d\n",
1569 ret);
1570 goto put_xcvr;
1571 }
Manu Gautam8c642812012-06-07 10:35:10 +05301572 } else {
1573 dev_err(&pdev->dev, "%s: No OTG transceiver found\n", __func__);
1574 }
1575
Manu Gautamb5067272012-07-02 09:53:41 +05301576 wake_lock_init(&msm->wlock, WAKE_LOCK_SUSPEND, "msm_dwc3");
1577 wake_lock(&msm->wlock);
1578 dwc3_debugfs_init(msm);
1579
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001580 return 0;
1581
Manu Gautam8c642812012-06-07 10:35:10 +05301582put_xcvr:
1583 usb_put_transceiver(msm->otg_xceiv);
1584 platform_device_del(dwc3);
Manu Gautam60e01352012-05-29 09:00:34 +05301585put_pdev:
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001586 platform_device_put(dwc3);
Manu Gautam60e01352012-05-29 09:00:34 +05301587disable_hs_ldo:
1588 dwc3_hsusb_ldo_enable(0);
1589free_hs_ldo_init:
1590 dwc3_hsusb_ldo_init(0);
1591disable_hs_vddcx:
1592 regulator_disable(context->hsusb_vddcx);
1593unconfig_hs_vddcx:
1594 dwc3_hsusb_config_vddcx(0);
1595disable_ss_ldo:
1596 dwc3_ssusb_ldo_enable(0);
1597free_ss_ldo_init:
1598 dwc3_ssusb_ldo_init(0);
1599disable_ss_vddcx:
1600 regulator_disable(context->ssusb_vddcx);
1601unconfig_ss_vddcx:
1602 dwc3_ssusb_config_vddcx(0);
Manu Gautam1742db22012-06-19 13:33:24 +05301603disable_core_clk:
1604 clk_disable_unprepare(msm->core_clk);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001605
1606 return ret;
1607}
1608
1609static int __devexit dwc3_msm_remove(struct platform_device *pdev)
1610{
1611 struct dwc3_msm *msm = platform_get_drvdata(pdev);
1612
Manu Gautamb5067272012-07-02 09:53:41 +05301613 if (dwc3_debugfs_root)
1614 debugfs_remove_recursive(dwc3_debugfs_root);
Manu Gautam8c642812012-06-07 10:35:10 +05301615 if (msm->otg_xceiv) {
1616 dwc3_start_chg_det(&msm->charger, false);
1617 usb_put_transceiver(msm->otg_xceiv);
1618 }
Manu Gautamb5067272012-07-02 09:53:41 +05301619 pm_runtime_disable(msm->dev);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001620 platform_device_unregister(msm->dwc3);
Manu Gautamb5067272012-07-02 09:53:41 +05301621 wake_lock_destroy(&msm->wlock);
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001622
Manu Gautam60e01352012-05-29 09:00:34 +05301623 dwc3_hsusb_ldo_enable(0);
1624 dwc3_hsusb_ldo_init(0);
1625 regulator_disable(msm->hsusb_vddcx);
1626 dwc3_hsusb_config_vddcx(0);
1627 dwc3_ssusb_ldo_enable(0);
1628 dwc3_ssusb_ldo_init(0);
1629 regulator_disable(msm->ssusb_vddcx);
1630 dwc3_ssusb_config_vddcx(0);
Manu Gautam1742db22012-06-19 13:33:24 +05301631 clk_disable_unprepare(msm->core_clk);
Manu Gautam60e01352012-05-29 09:00:34 +05301632
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001633 return 0;
1634}
1635
Manu Gautamb5067272012-07-02 09:53:41 +05301636static int dwc3_msm_pm_suspend(struct device *dev)
1637{
1638 int ret = 0;
1639 struct dwc3_msm *mdwc = dev_get_drvdata(dev);
1640
1641 dev_dbg(dev, "dwc3-msm PM suspend\n");
1642
1643 ret = dwc3_msm_suspend(mdwc);
1644 if (!ret)
1645 atomic_set(&mdwc->pm_suspended, 1);
1646
1647 return ret;
1648}
1649
1650static int dwc3_msm_pm_resume(struct device *dev)
1651{
1652 int ret = 0;
1653 struct dwc3_msm *mdwc = dev_get_drvdata(dev);
1654
1655 dev_dbg(dev, "dwc3-msm PM resume\n");
1656
1657 atomic_set(&mdwc->pm_suspended, 0);
1658 if (mdwc->resume_pending) {
1659 mdwc->resume_pending = false;
1660
1661 ret = dwc3_msm_resume(mdwc);
1662 /* Update runtime PM status */
1663 pm_runtime_disable(dev);
1664 pm_runtime_set_active(dev);
1665 pm_runtime_enable(dev);
1666
1667 /* Let OTG know about resume event and update pm_count */
1668 if (mdwc->otg_xceiv)
1669 mdwc->ext_xceiv.notify_ext_events(mdwc->otg_xceiv->otg,
1670 DWC3_EVENT_PHY_RESUME);
1671 }
1672
1673 return ret;
1674}
1675
1676static int dwc3_msm_runtime_idle(struct device *dev)
1677{
1678 dev_dbg(dev, "DWC3-msm runtime idle\n");
1679
1680 return 0;
1681}
1682
1683static int dwc3_msm_runtime_suspend(struct device *dev)
1684{
1685 struct dwc3_msm *mdwc = dev_get_drvdata(dev);
1686
1687 dev_dbg(dev, "DWC3-msm runtime suspend\n");
1688
1689 return dwc3_msm_suspend(mdwc);
1690}
1691
1692static int dwc3_msm_runtime_resume(struct device *dev)
1693{
1694 struct dwc3_msm *mdwc = dev_get_drvdata(dev);
1695
1696 dev_dbg(dev, "DWC3-msm runtime resume\n");
1697
1698 return dwc3_msm_resume(mdwc);
1699}
1700
1701static const struct dev_pm_ops dwc3_msm_dev_pm_ops = {
1702 SET_SYSTEM_SLEEP_PM_OPS(dwc3_msm_pm_suspend, dwc3_msm_pm_resume)
1703 SET_RUNTIME_PM_OPS(dwc3_msm_runtime_suspend, dwc3_msm_runtime_resume,
1704 dwc3_msm_runtime_idle)
1705};
1706
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001707static const struct of_device_id of_dwc3_matach[] = {
1708 {
1709 .compatible = "qcom,dwc-usb3-msm",
1710 },
1711 { },
1712};
1713MODULE_DEVICE_TABLE(of, of_dwc3_matach);
1714
1715static struct platform_driver dwc3_msm_driver = {
1716 .probe = dwc3_msm_probe,
1717 .remove = __devexit_p(dwc3_msm_remove),
1718 .driver = {
1719 .name = "msm-dwc3",
Manu Gautamb5067272012-07-02 09:53:41 +05301720 .pm = &dwc3_msm_dev_pm_ops,
Ido Shayevitzef72ddd2012-03-28 18:55:55 +02001721 .of_match_table = of_dwc3_matach,
1722 },
1723};
1724
1725MODULE_LICENSE("GPLV2");
1726MODULE_DESCRIPTION("DesignWare USB3 MSM Glue Layer");
1727
1728static int __devinit dwc3_msm_init(void)
1729{
1730 return platform_driver_register(&dwc3_msm_driver);
1731}
1732module_init(dwc3_msm_init);
1733
1734static void __exit dwc3_msm_exit(void)
1735{
1736 platform_driver_unregister(&dwc3_msm_driver);
1737}
1738module_exit(dwc3_msm_exit);