aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/core.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-14 19:43:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-14 19:43:09 -0400
commit37a842d36f63a047d94be2603d40d4407c949f1b (patch)
tree6aed94775f66f7198130b725bb5c7eae98faacdb /drivers/usb/chipidea/core.c
parenta3fbedf98fe9909cb2e406e2018ec437d64806f6 (diff)
parent96625eadca1bb8832fb502f0899a543695f1ba35 (diff)
Merge tag 'usb-ci-v4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-next
Peter writes: USB: chipidea updates for v4.3-rc1 The main changes are adding several system interfaces for tuning performance, and each vendors can adjust them according to their design configurations. Others are tiny improvements, like more well siTD supports, USB_DEVICE_A_HNP_SUPPORT supports, etc.
Diffstat (limited to 'drivers/usb/chipidea/core.c')
-rw-r--r--drivers/usb/chipidea/core.c113
1 files changed, 101 insertions, 12 deletions
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ab6212e888e1..3feebf7f31f0 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -64,6 +64,7 @@
64#include <linux/of.h> 64#include <linux/of.h>
65#include <linux/phy.h> 65#include <linux/phy.h>
66#include <linux/regulator/consumer.h> 66#include <linux/regulator/consumer.h>
67#include <linux/usb/ehci_def.h>
67 68
68#include "ci.h" 69#include "ci.h"
69#include "udc.h" 70#include "udc.h"
@@ -84,6 +85,8 @@ static const u8 ci_regs_nolpm[] = {
84 [OP_USBINTR] = 0x08U, 85 [OP_USBINTR] = 0x08U,
85 [OP_DEVICEADDR] = 0x14U, 86 [OP_DEVICEADDR] = 0x14U,
86 [OP_ENDPTLISTADDR] = 0x18U, 87 [OP_ENDPTLISTADDR] = 0x18U,
88 [OP_TTCTRL] = 0x1CU,
89 [OP_BURSTSIZE] = 0x20U,
87 [OP_PORTSC] = 0x44U, 90 [OP_PORTSC] = 0x44U,
88 [OP_DEVLC] = 0x84U, 91 [OP_DEVLC] = 0x84U,
89 [OP_OTGSC] = 0x64U, 92 [OP_OTGSC] = 0x64U,
@@ -106,6 +109,8 @@ static const u8 ci_regs_lpm[] = {
106 [OP_USBINTR] = 0x08U, 109 [OP_USBINTR] = 0x08U,
107 [OP_DEVICEADDR] = 0x14U, 110 [OP_DEVICEADDR] = 0x14U,
108 [OP_ENDPTLISTADDR] = 0x18U, 111 [OP_ENDPTLISTADDR] = 0x18U,
112 [OP_TTCTRL] = 0x1CU,
113 [OP_BURSTSIZE] = 0x20U,
109 [OP_PORTSC] = 0x44U, 114 [OP_PORTSC] = 0x44U,
110 [OP_DEVLC] = 0x84U, 115 [OP_DEVLC] = 0x84U,
111 [OP_OTGSC] = 0xC4U, 116 [OP_OTGSC] = 0xC4U,
@@ -118,7 +123,7 @@ static const u8 ci_regs_lpm[] = {
118 [OP_ENDPTCTRL] = 0xECU, 123 [OP_ENDPTCTRL] = 0xECU,
119}; 124};
120 125
121static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm) 126static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
122{ 127{
123 int i; 128 int i;
124 129
@@ -134,7 +139,6 @@ static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
134 ? ci_regs_lpm[OP_ENDPTCTRL] 139 ? ci_regs_lpm[OP_ENDPTCTRL]
135 : ci_regs_nolpm[OP_ENDPTCTRL]); 140 : ci_regs_nolpm[OP_ENDPTCTRL]);
136 141
137 return 0;
138} 142}
139 143
140static enum ci_revision ci_get_revision(struct ci_hdrc *ci) 144static enum ci_revision ci_get_revision(struct ci_hdrc *ci)
@@ -403,6 +407,55 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
403 return ret; 407 return ret;
404} 408}
405 409
410
411/**
412 * ci_platform_configure: do controller configure
413 * @ci: the controller
414 *
415 */
416void ci_platform_configure(struct ci_hdrc *ci)
417{
418 bool is_device_mode, is_host_mode;
419
420 is_device_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_DC;
421 is_host_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_HC;
422
423 if (is_device_mode &&
424 (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING))
425 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
426
427 if (is_host_mode &&
428 (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING))
429 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
430
431 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
432 if (ci->hw_bank.lpm)
433 hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
434 else
435 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
436 }
437
438 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA)
439 hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA);
440
441 hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16);
442
443 if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST)
444 hw_write_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK,
445 ci->platdata->ahb_burst_config);
446
447 /* override burst size, take effect only when ahb_burst_config is 0 */
448 if (!hw_read_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK)) {
449 if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST)
450 hw_write(ci, OP_BURSTSIZE, TX_BURST_MASK,
451 ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK));
452
453 if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST)
454 hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK,
455 ci->platdata->rx_burst_size);
456 }
457}
458
406/** 459/**
407 * hw_controller_reset: do controller reset 460 * hw_controller_reset: do controller reset
408 * @ci: the controller 461 * @ci: the controller
@@ -447,16 +500,6 @@ int hw_device_reset(struct ci_hdrc *ci)
447 ci->platdata->notify_event(ci, 500 ci->platdata->notify_event(ci,
448 CI_HDRC_CONTROLLER_RESET_EVENT); 501 CI_HDRC_CONTROLLER_RESET_EVENT);
449 502
450 if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING)
451 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
452
453 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) {
454 if (ci->hw_bank.lpm)
455 hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC);
456 else
457 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC);
458 }
459
460 /* USBMODE should be configured step by step */ 503 /* USBMODE should be configured step by step */
461 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); 504 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
462 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC); 505 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC);
@@ -469,6 +512,8 @@ int hw_device_reset(struct ci_hdrc *ci)
469 return -ENODEV; 512 return -ENODEV;
470 } 513 }
471 514
515 ci_platform_configure(ci);
516
472 return 0; 517 return 0;
473} 518}
474 519
@@ -606,6 +651,50 @@ static int ci_get_platdata(struct device *dev,
606 if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) 651 if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
607 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; 652 platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
608 653
654 platdata->itc_setting = 1;
655 if (of_find_property(dev->of_node, "itc-setting", NULL)) {
656 ret = of_property_read_u32(dev->of_node, "itc-setting",
657 &platdata->itc_setting);
658 if (ret) {
659 dev_err(dev,
660 "failed to get itc-setting\n");
661 return ret;
662 }
663 }
664
665 if (of_find_property(dev->of_node, "ahb-burst-config", NULL)) {
666 ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
667 &platdata->ahb_burst_config);
668 if (ret) {
669 dev_err(dev,
670 "failed to get ahb-burst-config\n");
671 return ret;
672 }
673 platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
674 }
675
676 if (of_find_property(dev->of_node, "tx-burst-size-dword", NULL)) {
677 ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
678 &platdata->tx_burst_size);
679 if (ret) {
680 dev_err(dev,
681 "failed to get tx-burst-size-dword\n");
682 return ret;
683 }
684 platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST;
685 }
686
687 if (of_find_property(dev->of_node, "rx-burst-size-dword", NULL)) {
688 ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
689 &platdata->rx_burst_size);
690 if (ret) {
691 dev_err(dev,
692 "failed to get rx-burst-size-dword\n");
693 return ret;
694 }
695 platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST;
696 }
697
609 return 0; 698 return 0;
610} 699}
611 700