forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/usb/chipidea/udc.c
....@@ -15,6 +15,7 @@
1515 #include <linux/kernel.h>
1616 #include <linux/slab.h>
1717 #include <linux/pm_runtime.h>
18
+#include <linux/pinctrl/consumer.h>
1819 #include <linux/usb/ch9.h>
1920 #include <linux/usb/gadget.h>
2021 #include <linux/usb/otg-fsm.h>
....@@ -71,6 +72,7 @@
7172
7273 /**
7374 * hw_device_state: enables/disables interrupts (execute without interruption)
75
+ * @ci: the controller
7476 * @dma: 0 => disable, !0 => enable and set dma engine
7577 *
7678 * This function returns an error code
....@@ -90,6 +92,7 @@
9092
9193 /**
9294 * hw_ep_flush: flush endpoint fifo (execute without interruption)
95
+ * @ci: the controller
9396 * @num: endpoint number
9497 * @dir: endpoint direction
9598 *
....@@ -111,6 +114,7 @@
111114
112115 /**
113116 * hw_ep_disable: disables endpoint (execute without interruption)
117
+ * @ci: the controller
114118 * @num: endpoint number
115119 * @dir: endpoint direction
116120 *
....@@ -125,6 +129,7 @@
125129
126130 /**
127131 * hw_ep_enable: enables endpoint (execute without interruption)
132
+ * @ci: the controller
128133 * @num: endpoint number
129134 * @dir: endpoint direction
130135 * @type: endpoint type
....@@ -160,6 +165,7 @@
160165
161166 /**
162167 * hw_ep_get_halt: return endpoint halt status
168
+ * @ci: the controller
163169 * @num: endpoint number
164170 * @dir: endpoint direction
165171 *
....@@ -174,6 +180,7 @@
174180
175181 /**
176182 * hw_ep_prime: primes endpoint (execute without interruption)
183
+ * @ci: the controller
177184 * @num: endpoint number
178185 * @dir: endpoint direction
179186 * @is_ctrl: true if control endpoint
....@@ -204,6 +211,7 @@
204211 /**
205212 * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute
206213 * without interruption)
214
+ * @ci: the controller
207215 * @num: endpoint number
208216 * @dir: endpoint direction
209217 * @value: true => stall, false => unstall
....@@ -230,6 +238,7 @@
230238
231239 /**
232240 * hw_is_port_high_speed: test if port is high speed
241
+ * @ci: the controller
233242 *
234243 * This function returns true if high speed port
235244 */
....@@ -242,6 +251,7 @@
242251 /**
243252 * hw_test_and_clear_complete: test & clear complete status (execute without
244253 * interruption)
254
+ * @ci: the controller
245255 * @n: endpoint number
246256 *
247257 * This function returns complete status
....@@ -255,6 +265,7 @@
255265 /**
256266 * hw_test_and_clear_intr_active: test & clear active interrupts (execute
257267 * without interruption)
268
+ * @ci: the controller
258269 *
259270 * This function returns active interrutps
260271 */
....@@ -269,6 +280,7 @@
269280 /**
270281 * hw_test_and_clear_setup_guard: test & clear setup guard (execute without
271282 * interruption)
283
+ * @ci: the controller
272284 *
273285 * This function returns guard value
274286 */
....@@ -280,6 +292,7 @@
280292 /**
281293 * hw_test_and_set_setup_guard: test & set setup guard (execute without
282294 * interruption)
295
+ * @ci: the controller
283296 *
284297 * This function returns guard value
285298 */
....@@ -290,6 +303,7 @@
290303
291304 /**
292305 * hw_usb_set_address: configures USB address (execute without interruption)
306
+ * @ci: the controller
293307 * @value: new USB address
294308 *
295309 * This function explicitly sets the address, without the "USBADRA" (advance)
....@@ -304,6 +318,7 @@
304318 /**
305319 * hw_usb_reset: restart device after a bus reset (execute without
306320 * interruption)
321
+ * @ci: the controller
307322 *
308323 * This function returns an error code
309324 */
....@@ -337,7 +352,7 @@
337352 *****************************************************************************/
338353
339354 static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
340
- unsigned length)
355
+ unsigned int length, struct scatterlist *s)
341356 {
342357 int i;
343358 u32 temp;
....@@ -365,7 +380,13 @@
365380 node->ptr->token |= cpu_to_le32(mul << __ffs(TD_MULTO));
366381 }
367382
368
- temp = (u32) (hwreq->req.dma + hwreq->req.actual);
383
+ if (s) {
384
+ temp = (u32) (sg_dma_address(s) + hwreq->req.actual);
385
+ node->td_remaining_size = CI_MAX_BUF_SIZE - length;
386
+ } else {
387
+ temp = (u32) (hwreq->req.dma + hwreq->req.actual);
388
+ }
389
+
369390 if (length) {
370391 node->ptr->page[0] = cpu_to_le32(temp);
371392 for (i = 1; i < TD_PAGE_COUNT; i++) {
....@@ -399,6 +420,123 @@
399420 return ((ep->dir == TX) ? USB_ENDPOINT_DIR_MASK : 0) | ep->num;
400421 }
401422
423
+static int prepare_td_for_non_sg(struct ci_hw_ep *hwep,
424
+ struct ci_hw_req *hwreq)
425
+{
426
+ unsigned int rest = hwreq->req.length;
427
+ int pages = TD_PAGE_COUNT;
428
+ int ret = 0;
429
+
430
+ if (rest == 0) {
431
+ ret = add_td_to_list(hwep, hwreq, 0, NULL);
432
+ if (ret < 0)
433
+ return ret;
434
+ }
435
+
436
+ /*
437
+ * The first buffer could be not page aligned.
438
+ * In that case we have to span into one extra td.
439
+ */
440
+ if (hwreq->req.dma % PAGE_SIZE)
441
+ pages--;
442
+
443
+ while (rest > 0) {
444
+ unsigned int count = min(hwreq->req.length - hwreq->req.actual,
445
+ (unsigned int)(pages * CI_HDRC_PAGE_SIZE));
446
+
447
+ ret = add_td_to_list(hwep, hwreq, count, NULL);
448
+ if (ret < 0)
449
+ return ret;
450
+
451
+ rest -= count;
452
+ }
453
+
454
+ if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX
455
+ && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
456
+ ret = add_td_to_list(hwep, hwreq, 0, NULL);
457
+ if (ret < 0)
458
+ return ret;
459
+ }
460
+
461
+ return ret;
462
+}
463
+
464
+static int prepare_td_per_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
465
+ struct scatterlist *s)
466
+{
467
+ unsigned int rest = sg_dma_len(s);
468
+ int ret = 0;
469
+
470
+ hwreq->req.actual = 0;
471
+ while (rest > 0) {
472
+ unsigned int count = min_t(unsigned int, rest,
473
+ CI_MAX_BUF_SIZE);
474
+
475
+ ret = add_td_to_list(hwep, hwreq, count, s);
476
+ if (ret < 0)
477
+ return ret;
478
+
479
+ rest -= count;
480
+ }
481
+
482
+ return ret;
483
+}
484
+
485
+static void ci_add_buffer_entry(struct td_node *node, struct scatterlist *s)
486
+{
487
+ int empty_td_slot_index = (CI_MAX_BUF_SIZE - node->td_remaining_size)
488
+ / CI_HDRC_PAGE_SIZE;
489
+ int i;
490
+ u32 token;
491
+
492
+ token = le32_to_cpu(node->ptr->token) + (sg_dma_len(s) << __ffs(TD_TOTAL_BYTES));
493
+ node->ptr->token = cpu_to_le32(token);
494
+
495
+ for (i = empty_td_slot_index; i < TD_PAGE_COUNT; i++) {
496
+ u32 page = (u32) sg_dma_address(s) +
497
+ (i - empty_td_slot_index) * CI_HDRC_PAGE_SIZE;
498
+
499
+ page &= ~TD_RESERVED_MASK;
500
+ node->ptr->page[i] = cpu_to_le32(page);
501
+ }
502
+}
503
+
504
+static int prepare_td_for_sg(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
505
+{
506
+ struct usb_request *req = &hwreq->req;
507
+ struct scatterlist *s = req->sg;
508
+ int ret = 0, i = 0;
509
+ struct td_node *node = NULL;
510
+
511
+ if (!s || req->zero || req->length == 0) {
512
+ dev_err(hwep->ci->dev, "not supported operation for sg\n");
513
+ return -EINVAL;
514
+ }
515
+
516
+ while (i++ < req->num_mapped_sgs) {
517
+ if (sg_dma_address(s) % PAGE_SIZE) {
518
+ dev_err(hwep->ci->dev, "not page aligned sg buffer\n");
519
+ return -EINVAL;
520
+ }
521
+
522
+ if (node && (node->td_remaining_size >= sg_dma_len(s))) {
523
+ ci_add_buffer_entry(node, s);
524
+ node->td_remaining_size -= sg_dma_len(s);
525
+ } else {
526
+ ret = prepare_td_per_sg(hwep, hwreq, s);
527
+ if (ret)
528
+ return ret;
529
+
530
+ node = list_entry(hwreq->tds.prev,
531
+ struct td_node, td);
532
+ }
533
+
534
+ s = sg_next(s);
535
+ }
536
+
537
+ return ret;
538
+}
539
+
402540 /**
403541 * _hardware_enqueue: configures a request at hardware level
404542 * @hwep: endpoint
....@@ -410,8 +548,6 @@
410548 {
411549 struct ci_hdrc *ci = hwep->ci;
412550 int ret = 0;
413
- unsigned rest = hwreq->req.length;
414
- int pages = TD_PAGE_COUNT;
415551 struct td_node *firstnode, *lastnode;
416552
417553 /* don't queue twice */
....@@ -425,35 +561,13 @@
425561 if (ret)
426562 return ret;
427563
428
- /*
429
- * The first buffer could be not page aligned.
430
- * In that case we have to span into one extra td.
431
- */
432
- if (hwreq->req.dma % PAGE_SIZE)
433
- pages--;
564
+ if (hwreq->req.num_mapped_sgs)
565
+ ret = prepare_td_for_sg(hwep, hwreq);
566
+ else
567
+ ret = prepare_td_for_non_sg(hwep, hwreq);
434568
435
- if (rest == 0) {
436
- ret = add_td_to_list(hwep, hwreq, 0);
437
- if (ret < 0)
438
- goto done;
439
- }
440
-
441
- while (rest > 0) {
442
- unsigned count = min(hwreq->req.length - hwreq->req.actual,
443
- (unsigned)(pages * CI_HDRC_PAGE_SIZE));
444
- ret = add_td_to_list(hwep, hwreq, count);
445
- if (ret < 0)
446
- goto done;
447
-
448
- rest -= count;
449
- }
450
-
451
- if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX
452
- && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
453
- ret = add_td_to_list(hwep, hwreq, 0);
454
- if (ret < 0)
455
- goto done;
456
- }
569
+ if (ret)
570
+ return ret;
457571
458572 firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
459573
....@@ -511,7 +625,7 @@
511625 return ret;
512626 }
513627
514
-/*
628
+/**
515629 * free_pending_td: remove a pending request for the endpoint
516630 * @hwep: endpoint
517631 */
....@@ -537,8 +651,8 @@
537651
538652 /**
539653 * _hardware_dequeue: handles a request at hardware level
540
- * @gadget: gadget
541
- * @hwep: endpoint
654
+ * @hwep: endpoint
655
+ * @hwreq: request
542656 *
543657 * This function returns an error code
544658 */
....@@ -920,6 +1034,9 @@
9201034 struct ci_hdrc *ci = req->context;
9211035 unsigned long flags;
9221036
1037
+ if (req->status < 0)
1038
+ return;
1039
+
9231040 if (ci->setaddr) {
9241041 hw_usb_set_address(ci, ci->address);
9251042 ci->setaddr = false;
....@@ -1116,11 +1233,11 @@
11161233 case USB_DEVICE_TEST_MODE:
11171234 tmode = le16_to_cpu(req.wIndex) >> 8;
11181235 switch (tmode) {
1119
- case TEST_J:
1120
- case TEST_K:
1121
- case TEST_SE0_NAK:
1122
- case TEST_PACKET:
1123
- case TEST_FORCE_EN:
1236
+ case USB_TEST_J:
1237
+ case USB_TEST_K:
1238
+ case USB_TEST_SE0_NAK:
1239
+ case USB_TEST_PACKET:
1240
+ case USB_TEST_FORCE_ENABLE:
11241241 ci->test_mode = tmode;
11251242 err = isr_setup_status_phase(
11261243 ci);
....@@ -1217,7 +1334,7 @@
12171334 /******************************************************************************
12181335 * ENDPT block
12191336 *****************************************************************************/
1220
-/**
1337
+/*
12211338 * ep_enable: configure endpoint, making it usable
12221339 *
12231340 * Check usb_ep_enable() at "usb_gadget.h" for details
....@@ -1285,7 +1402,7 @@
12851402 return retval;
12861403 }
12871404
1288
-/**
1405
+/*
12891406 * ep_disable: endpoint is no longer usable
12901407 *
12911408 * Check usb_ep_disable() at "usb_gadget.h" for details
....@@ -1325,7 +1442,7 @@
13251442 return retval;
13261443 }
13271444
1328
-/**
1445
+/*
13291446 * ep_alloc_request: allocate a request object to use with this endpoint
13301447 *
13311448 * Check usb_ep_alloc_request() at "usb_gadget.h" for details
....@@ -1346,7 +1463,7 @@
13461463 return (hwreq == NULL) ? NULL : &hwreq->req;
13471464 }
13481465
1349
-/**
1466
+/*
13501467 * ep_free_request: frees a request object
13511468 *
13521469 * Check usb_ep_free_request() at "usb_gadget.h" for details
....@@ -1379,7 +1496,7 @@
13791496 spin_unlock_irqrestore(hwep->lock, flags);
13801497 }
13811498
1382
-/**
1499
+/*
13831500 * ep_queue: queues (submits) an I/O request to an endpoint
13841501 *
13851502 * Check usb_ep_queue()* at usb_gadget.h" for details
....@@ -1404,7 +1521,7 @@
14041521 return retval;
14051522 }
14061523
1407
-/**
1524
+/*
14081525 * ep_dequeue: dequeues (cancels, unlinks) an I/O request from an endpoint
14091526 *
14101527 * Check usb_ep_dequeue() at "usb_gadget.h" for details
....@@ -1448,7 +1565,7 @@
14481565 return 0;
14491566 }
14501567
1451
-/**
1568
+/*
14521569 * ep_set_halt: sets the endpoint halt feature
14531570 *
14541571 * Check usb_ep_set_halt() at "usb_gadget.h" for details
....@@ -1458,7 +1575,7 @@
14581575 return _ep_set_halt(ep, value, true);
14591576 }
14601577
1461
-/**
1578
+/*
14621579 * ep_set_wedge: sets the halt feature and ignores clear requests
14631580 *
14641581 * Check usb_ep_set_wedge() at "usb_gadget.h" for details
....@@ -1478,7 +1595,7 @@
14781595 return usb_ep_set_halt(ep);
14791596 }
14801597
1481
-/**
1598
+/*
14821599 * ep_fifo_flush: flushes contents of a fifo
14831600 *
14841601 * Check usb_ep_fifo_flush() at "usb_gadget.h" for details
....@@ -1504,7 +1621,7 @@
15041621 spin_unlock_irqrestore(hwep->lock, flags);
15051622 }
15061623
1507
-/**
1624
+/*
15081625 * Endpoint-specific part of the API to the USB controller hardware
15091626 * Check "usb_gadget.h" for details
15101627 */
....@@ -1523,44 +1640,61 @@
15231640 /******************************************************************************
15241641 * GADGET block
15251642 *****************************************************************************/
1643
+/*
1644
+ * ci_hdrc_gadget_connect: caller makes sure gadget driver is binded
1645
+ */
1646
+static void ci_hdrc_gadget_connect(struct usb_gadget *_gadget, int is_active)
1647
+{
1648
+ struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
1649
+
1650
+ if (is_active) {
1651
+ pm_runtime_get_sync(ci->dev);
1652
+ hw_device_reset(ci);
1653
+ spin_lock_irq(&ci->lock);
1654
+ if (ci->driver) {
1655
+ hw_device_state(ci, ci->ep0out->qh.dma);
1656
+ usb_gadget_set_state(_gadget, USB_STATE_POWERED);
1657
+ spin_unlock_irq(&ci->lock);
1658
+ usb_udc_vbus_handler(_gadget, true);
1659
+ } else {
1660
+ spin_unlock_irq(&ci->lock);
1661
+ }
1662
+ } else {
1663
+ usb_udc_vbus_handler(_gadget, false);
1664
+ if (ci->driver)
1665
+ ci->driver->disconnect(&ci->gadget);
1666
+ hw_device_state(ci, 0);
1667
+ if (ci->platdata->notify_event)
1668
+ ci->platdata->notify_event(ci,
1669
+ CI_HDRC_CONTROLLER_STOPPED_EVENT);
1670
+ _gadget_stop_activity(&ci->gadget);
1671
+ pm_runtime_put_sync(ci->dev);
1672
+ usb_gadget_set_state(_gadget, USB_STATE_NOTATTACHED);
1673
+ }
1674
+}
1675
+
15261676 static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
15271677 {
15281678 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
15291679 unsigned long flags;
1530
- int gadget_ready = 0;
1680
+ int ret = 0;
15311681
15321682 spin_lock_irqsave(&ci->lock, flags);
15331683 ci->vbus_active = is_active;
1534
- if (ci->driver)
1535
- gadget_ready = 1;
15361684 spin_unlock_irqrestore(&ci->lock, flags);
15371685
15381686 if (ci->usb_phy)
15391687 usb_phy_set_charger_state(ci->usb_phy, is_active ?
15401688 USB_CHARGER_PRESENT : USB_CHARGER_ABSENT);
15411689
1542
- if (gadget_ready) {
1543
- if (is_active) {
1544
- pm_runtime_get_sync(&_gadget->dev);
1545
- hw_device_reset(ci);
1546
- hw_device_state(ci, ci->ep0out->qh.dma);
1547
- usb_gadget_set_state(_gadget, USB_STATE_POWERED);
1548
- usb_udc_vbus_handler(_gadget, true);
1549
- } else {
1550
- usb_udc_vbus_handler(_gadget, false);
1551
- if (ci->driver)
1552
- ci->driver->disconnect(&ci->gadget);
1553
- hw_device_state(ci, 0);
1554
- if (ci->platdata->notify_event)
1555
- ci->platdata->notify_event(ci,
1556
- CI_HDRC_CONTROLLER_STOPPED_EVENT);
1557
- _gadget_stop_activity(&ci->gadget);
1558
- pm_runtime_put_sync(&_gadget->dev);
1559
- usb_gadget_set_state(_gadget, USB_STATE_NOTATTACHED);
1560
- }
1561
- }
1690
+ if (ci->platdata->notify_event)
1691
+ ret = ci->platdata->notify_event(ci,
1692
+ CI_HDRC_CONTROLLER_VBUS_EVENT);
15621693
1563
- return 0;
1694
+ if (ci->driver)
1695
+ ci_hdrc_gadget_connect(_gadget, is_active);
1696
+
1697
+ return ret;
15641698 }
15651699
15661700 static int ci_udc_wakeup(struct usb_gadget *_gadget)
....@@ -1611,7 +1745,7 @@
16111745 }
16121746
16131747 /* Change Data+ pullup status
1614
- * this func is used by usb_gadget_connect/disconnet
1748
+ * this func is used by usb_gadget_connect/disconnect
16151749 */
16161750 static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
16171751 {
....@@ -1624,12 +1758,12 @@
16241758 if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST)
16251759 return 0;
16261760
1627
- pm_runtime_get_sync(&ci->gadget.dev);
1761
+ pm_runtime_get_sync(ci->dev);
16281762 if (is_on)
16291763 hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
16301764 else
16311765 hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
1632
- pm_runtime_put_sync(&ci->gadget.dev);
1766
+ pm_runtime_put_sync(ci->dev);
16331767
16341768 return 0;
16351769 }
....@@ -1656,7 +1790,7 @@
16561790 return NULL;
16571791 }
16581792
1659
-/**
1793
+/*
16601794 * Device operations part of the API to the USB controller hardware,
16611795 * which don't involve endpoints (or i/o)
16621796 * Check "usb_gadget.h" for details
....@@ -1761,11 +1895,10 @@
17611895 struct usb_gadget_driver *driver)
17621896 {
17631897 struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget);
1764
- int retval = -ENOMEM;
1898
+ int retval;
17651899
17661900 if (driver->disconnect == NULL)
17671901 return -EINVAL;
1768
-
17691902
17701903 ci->ep0out->ep.desc = &ctrl_endpt_out_desc;
17711904 retval = usb_ep_enable(&ci->ep0out->ep);
....@@ -1785,18 +1918,10 @@
17851918 return retval;
17861919 }
17871920
1788
- pm_runtime_get_sync(&ci->gadget.dev);
1789
- if (ci->vbus_active) {
1790
- hw_device_reset(ci);
1791
- } else {
1921
+ if (ci->vbus_active)
1922
+ ci_hdrc_gadget_connect(gadget, 1);
1923
+ else
17921924 usb_udc_vbus_handler(&ci->gadget, false);
1793
- pm_runtime_put_sync(&ci->gadget.dev);
1794
- return retval;
1795
- }
1796
-
1797
- retval = hw_device_state(ci, ci->ep0out->qh.dma);
1798
- if (retval)
1799
- pm_runtime_put_sync(&ci->gadget.dev);
18001925
18011926 return retval;
18021927 }
....@@ -1817,7 +1942,7 @@
18171942 mutex_unlock(&ci->fsm.lock);
18181943 }
18191944
1820
-/**
1945
+/*
18211946 * ci_udc_stop: unregister a gadget driver
18221947 */
18231948 static int ci_udc_stop(struct usb_gadget *gadget)
....@@ -1826,6 +1951,7 @@
18261951 unsigned long flags;
18271952
18281953 spin_lock_irqsave(&ci->lock, flags);
1954
+ ci->driver = NULL;
18291955
18301956 if (ci->vbus_active) {
18311957 hw_device_state(ci, 0);
....@@ -1835,10 +1961,9 @@
18351961 CI_HDRC_CONTROLLER_STOPPED_EVENT);
18361962 _gadget_stop_activity(&ci->gadget);
18371963 spin_lock_irqsave(&ci->lock, flags);
1838
- pm_runtime_put(&ci->gadget.dev);
1964
+ pm_runtime_put(ci->dev);
18391965 }
18401966
1841
- ci->driver = NULL;
18421967 spin_unlock_irqrestore(&ci->lock, flags);
18431968
18441969 ci_udc_stop_for_otg_fsm(ci);
....@@ -1848,7 +1973,7 @@
18481973 /******************************************************************************
18491974 * BUS block
18501975 *****************************************************************************/
1851
-/**
1976
+/*
18521977 * udc_irq: ci interrupt handler
18531978 *
18541979 * This function returns IRQ_HANDLED if the IRQ has been handled
....@@ -1932,6 +2057,8 @@
19322057 ci->gadget.max_speed = USB_SPEED_HIGH;
19332058 ci->gadget.name = ci->platdata->name;
19342059 ci->gadget.otg_caps = otg_caps;
2060
+ ci->gadget.sg_supported = 1;
2061
+ ci->gadget.irq = ci->irq;
19352062
19362063 if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA)
19372064 ci->gadget.quirk_avoids_skb_reserve = 1;
....@@ -1967,9 +2094,6 @@
19672094 if (retval)
19682095 goto destroy_eps;
19692096
1970
- pm_runtime_no_callbacks(&ci->gadget.dev);
1971
- pm_runtime_enable(&ci->gadget.dev);
1972
-
19732097 return retval;
19742098
19752099 destroy_eps:
....@@ -1981,7 +2105,7 @@
19812105 return retval;
19822106 }
19832107
1984
-/**
2108
+/*
19852109 * ci_hdrc_gadget_destroy: parent remove must call this to remove UDC
19862110 *
19872111 * No interrupts active, the IRQ has been released
....@@ -2001,6 +2125,10 @@
20012125
20022126 static int udc_id_switch_for_device(struct ci_hdrc *ci)
20032127 {
2128
+ if (ci->platdata->pins_device)
2129
+ pinctrl_select_state(ci->platdata->pctl,
2130
+ ci->platdata->pins_device);
2131
+
20042132 if (ci->is_otg)
20052133 /* Clear and enable BSV irq */
20062134 hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
....@@ -2019,11 +2147,15 @@
20192147 hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);
20202148
20212149 ci->vbus_active = 0;
2150
+
2151
+ if (ci->platdata->pins_device && ci->platdata->pins_default)
2152
+ pinctrl_select_state(ci->platdata->pctl,
2153
+ ci->platdata->pins_default);
20222154 }
20232155
20242156 /**
20252157 * ci_hdrc_gadget_init - initialize device related bits
2026
- * ci: the controller
2158
+ * @ci: the controller
20272159 *
20282160 * This function initializes the gadget, if the device is "device capable".
20292161 */