Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

+202 -32
+20
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
··· 30 30 argument that indicate usb controller index 31 31 - disable-over-current: (FSL only) disable over current detect 32 32 - external-vbus-divider: (FSL only) enables off-chip resistor divider for Vbus 33 + - itc-setting: interrupt threshold control register control, the setting 34 + should be aligned with ITC bits at register USBCMD. 35 + - ahb-burst-config: it is vendor dependent, the required value should be 36 + aligned with AHBBRST at SBUSCFG, the range is from 0x0 to 0x7. This 37 + property is used to change AHB burst configuration, check the chipidea 38 + spec for meaning of each value. If this property is not existed, it 39 + will use the reset value. 40 + - tx-burst-size-dword: it is vendor dependent, the tx burst size in dword 41 + (4 bytes), This register represents the maximum length of a the burst 42 + in 32-bit words while moving data from system memory to the USB 43 + bus, changing this value takes effect only the SBUSCFG.AHBBRST is 0. 44 + - rx-burst-size-dword: it is vendor dependent, the rx burst size in dword 45 + (4 bytes), This register represents the maximum length of a the burst 46 + in 32-bit words while moving data from the USB bus to system memory, 47 + changing this value takes effect only the SBUSCFG.AHBBRST is 0. 33 48 34 49 Example: 35 50 ··· 56 41 phys = <&usb_phy0>; 57 42 phy-names = "usb-phy"; 58 43 vbus-supply = <&reg_usb0_vbus>; 44 + gadget-itc-setting = <0x4>; /* 4 micro-frames */ 45 + /* Incremental burst of unspecified length */ 46 + ahb-burst-config = <0x0>; 47 + tx-burst-size-dword = <0x10>; /* 64 bytes */ 48 + rx-burst-size-dword = <0x10>; 59 49 };
+12
drivers/usb/chipidea/bits.h
··· 25 25 #define VERSION (0xF << 25) 26 26 #define CIVERSION (0x7 << 29) 27 27 28 + /* SBUSCFG */ 29 + #define AHBBRST_MASK 0x7 30 + 28 31 /* HCCPARAMS */ 29 32 #define HCCPARAMS_LEN BIT(17) 30 33 ··· 55 52 /* DEVICEADDR */ 56 53 #define DEVICEADDR_USBADRA BIT(24) 57 54 #define DEVICEADDR_USBADR (0x7FUL << 25) 55 + 56 + /* TTCTRL */ 57 + #define TTCTRL_TTHA_MASK (0x7fUL << 24) 58 + /* Set non-zero value for internal TT Hub address representation */ 59 + #define TTCTRL_TTHA (0x7fUL << 24) 60 + 61 + /* BURSTSIZE */ 62 + #define RX_BURST_MASK 0xff 63 + #define TX_BURST_MASK 0xff00 58 64 59 65 /* PORTSC */ 60 66 #define PORTSC_CCS BIT(0)
+4
drivers/usb/chipidea/ci.h
··· 50 50 OP_USBINTR, 51 51 OP_DEVICEADDR, 52 52 OP_ENDPTLISTADDR, 53 + OP_TTCTRL, 54 + OP_BURSTSIZE, 53 55 OP_PORTSC, 54 56 OP_DEVLC, 55 57 OP_OTGSC, ··· 430 428 431 429 int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, 432 430 u32 value, unsigned int timeout_ms); 431 + 432 + void ci_platform_configure(struct ci_hdrc *ci); 433 433 434 434 #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
+11 -6
drivers/usb/chipidea/ci_hdrc_imx.c
··· 29 29 }; 30 30 31 31 static const struct ci_hdrc_imx_platform_flag imx27_usb_data = { 32 + CI_HDRC_DISABLE_STREAMING, 32 33 }; 33 34 34 35 static const struct ci_hdrc_imx_platform_flag imx28_usb_data = { 35 36 .flags = CI_HDRC_IMX28_WRITE_FIX | 36 - CI_HDRC_TURN_VBUS_EARLY_ON, 37 + CI_HDRC_TURN_VBUS_EARLY_ON | 38 + CI_HDRC_DISABLE_STREAMING, 37 39 }; 38 40 39 41 static const struct ci_hdrc_imx_platform_flag imx6q_usb_data = { 40 42 .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | 41 - CI_HDRC_TURN_VBUS_EARLY_ON, 43 + CI_HDRC_TURN_VBUS_EARLY_ON | 44 + CI_HDRC_DISABLE_STREAMING, 42 45 }; 43 46 44 47 static const struct ci_hdrc_imx_platform_flag imx6sl_usb_data = { 45 48 .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | 46 - CI_HDRC_TURN_VBUS_EARLY_ON, 49 + CI_HDRC_TURN_VBUS_EARLY_ON | 50 + CI_HDRC_DISABLE_HOST_STREAMING, 47 51 }; 48 52 49 53 static const struct ci_hdrc_imx_platform_flag imx6sx_usb_data = { 50 54 .flags = CI_HDRC_SUPPORTS_RUNTIME_PM | 51 - CI_HDRC_TURN_VBUS_EARLY_ON, 55 + CI_HDRC_TURN_VBUS_EARLY_ON | 56 + CI_HDRC_DISABLE_HOST_STREAMING, 52 57 }; 53 58 54 59 static const struct of_device_id ci_hdrc_imx_dt_ids[] = { ··· 109 104 misc_pdev = of_find_device_by_node(args.np); 110 105 of_node_put(args.np); 111 106 112 - if (!misc_pdev) 107 + if (!misc_pdev || !platform_get_drvdata(misc_pdev)) 113 108 return ERR_PTR(-EPROBE_DEFER); 114 109 115 110 data->dev = &misc_pdev->dev; ··· 131 126 struct ci_hdrc_platform_data pdata = { 132 127 .name = dev_name(&pdev->dev), 133 128 .capoffset = DEF_CAPOFFSET, 134 - .flags = CI_HDRC_DISABLE_STREAMING, 129 + .flags = CI_HDRC_SET_NON_ZERO_TTHA, 135 130 }; 136 131 int ret; 137 132 const struct of_device_id *of_id =
+101 -12
drivers/usb/chipidea/core.c
··· 64 64 #include <linux/of.h> 65 65 #include <linux/phy.h> 66 66 #include <linux/regulator/consumer.h> 67 + #include <linux/usb/ehci_def.h> 67 68 68 69 #include "ci.h" 69 70 #include "udc.h" ··· 85 84 [OP_USBINTR] = 0x08U, 86 85 [OP_DEVICEADDR] = 0x14U, 87 86 [OP_ENDPTLISTADDR] = 0x18U, 87 + [OP_TTCTRL] = 0x1CU, 88 + [OP_BURSTSIZE] = 0x20U, 88 89 [OP_PORTSC] = 0x44U, 89 90 [OP_DEVLC] = 0x84U, 90 91 [OP_OTGSC] = 0x64U, ··· 109 106 [OP_USBINTR] = 0x08U, 110 107 [OP_DEVICEADDR] = 0x14U, 111 108 [OP_ENDPTLISTADDR] = 0x18U, 109 + [OP_TTCTRL] = 0x1CU, 110 + [OP_BURSTSIZE] = 0x20U, 112 111 [OP_PORTSC] = 0x44U, 113 112 [OP_DEVLC] = 0x84U, 114 113 [OP_OTGSC] = 0xC4U, ··· 123 118 [OP_ENDPTCTRL] = 0xECU, 124 119 }; 125 120 126 - static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm) 121 + static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm) 127 122 { 128 123 int i; 129 124 ··· 139 134 ? ci_regs_lpm[OP_ENDPTCTRL] 140 135 : ci_regs_nolpm[OP_ENDPTCTRL]); 141 136 142 - return 0; 143 137 } 144 138 145 139 static enum ci_revision ci_get_revision(struct ci_hdrc *ci) ··· 407 403 return ret; 408 404 } 409 405 406 + 407 + /** 408 + * ci_platform_configure: do controller configure 409 + * @ci: the controller 410 + * 411 + */ 412 + void ci_platform_configure(struct ci_hdrc *ci) 413 + { 414 + bool is_device_mode, is_host_mode; 415 + 416 + is_device_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_DC; 417 + is_host_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_HC; 418 + 419 + if (is_device_mode && 420 + (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING)) 421 + hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); 422 + 423 + if (is_host_mode && 424 + (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING)) 425 + hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); 426 + 427 + if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { 428 + if (ci->hw_bank.lpm) 429 + hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC); 430 + else 431 + hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); 432 + } 433 + 434 + if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA) 435 + hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA); 436 + 437 + hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16); 438 + 439 + if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST) 440 + hw_write_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK, 441 + ci->platdata->ahb_burst_config); 442 + 443 + /* override burst size, take effect only when ahb_burst_config is 0 */ 444 + if (!hw_read_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK)) { 445 + if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST) 446 + hw_write(ci, OP_BURSTSIZE, TX_BURST_MASK, 447 + ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK)); 448 + 449 + if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST) 450 + hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK, 451 + ci->platdata->rx_burst_size); 452 + } 453 + } 454 + 410 455 /** 411 456 * hw_controller_reset: do controller reset 412 457 * @ci: the controller ··· 500 447 ci->platdata->notify_event(ci, 501 448 CI_HDRC_CONTROLLER_RESET_EVENT); 502 449 503 - if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING) 504 - hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); 505 - 506 - if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { 507 - if (ci->hw_bank.lpm) 508 - hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC); 509 - else 510 - hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); 511 - } 512 - 513 450 /* USBMODE should be configured step by step */ 514 451 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); 515 452 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC); ··· 511 468 pr_err("lpm = %i", ci->hw_bank.lpm); 512 469 return -ENODEV; 513 470 } 471 + 472 + ci_platform_configure(ci); 514 473 515 474 return 0; 516 475 } ··· 650 605 651 606 if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) 652 607 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; 608 + 609 + platdata->itc_setting = 1; 610 + if (of_find_property(dev->of_node, "itc-setting", NULL)) { 611 + ret = of_property_read_u32(dev->of_node, "itc-setting", 612 + &platdata->itc_setting); 613 + if (ret) { 614 + dev_err(dev, 615 + "failed to get itc-setting\n"); 616 + return ret; 617 + } 618 + } 619 + 620 + if (of_find_property(dev->of_node, "ahb-burst-config", NULL)) { 621 + ret = of_property_read_u32(dev->of_node, "ahb-burst-config", 622 + &platdata->ahb_burst_config); 623 + if (ret) { 624 + dev_err(dev, 625 + "failed to get ahb-burst-config\n"); 626 + return ret; 627 + } 628 + platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST; 629 + } 630 + 631 + if (of_find_property(dev->of_node, "tx-burst-size-dword", NULL)) { 632 + ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword", 633 + &platdata->tx_burst_size); 634 + if (ret) { 635 + dev_err(dev, 636 + "failed to get tx-burst-size-dword\n"); 637 + return ret; 638 + } 639 + platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST; 640 + } 641 + 642 + if (of_find_property(dev->of_node, "rx-burst-size-dword", NULL)) { 643 + ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword", 644 + &platdata->rx_burst_size); 645 + if (ret) { 646 + dev_err(dev, 647 + "failed to get rx-burst-size-dword\n"); 648 + return ret; 649 + } 650 + platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST; 651 + } 653 652 654 653 return 0; 655 654 }
+6
drivers/usb/chipidea/debug.c
··· 67 67 unsigned long flags; 68 68 unsigned mode; 69 69 70 + pm_runtime_get_sync(ci->dev); 70 71 spin_lock_irqsave(&ci->lock, flags); 71 72 mode = hw_port_test_get(ci); 72 73 spin_unlock_irqrestore(&ci->lock, flags); 74 + pm_runtime_put_sync(ci->dev); 73 75 74 76 seq_printf(s, "mode = %u\n", mode); 75 77 ··· 101 99 if (sscanf(buf, "%u", &mode) != 1) 102 100 return -EINVAL; 103 101 102 + pm_runtime_get_sync(ci->dev); 104 103 spin_lock_irqsave(&ci->lock, flags); 105 104 ret = hw_port_test_set(ci, mode); 106 105 spin_unlock_irqrestore(&ci->lock, flags); 106 + pm_runtime_put_sync(ci->dev); 107 107 108 108 return ret ? ret : count; 109 109 } ··· 321 317 if (role == CI_ROLE_END || role == ci->role) 322 318 return -EINVAL; 323 319 320 + pm_runtime_get_sync(ci->dev); 324 321 ci_role_stop(ci); 325 322 ret = ci_role_start(ci, role); 323 + pm_runtime_put_sync(ci->dev); 326 324 327 325 return ret ? ret : count; 328 326 }
+17 -9
drivers/usb/chipidea/host.c
··· 37 37 38 38 struct ehci_ci_priv { 39 39 struct regulator *reg_vbus; 40 - struct ci_hdrc *ci; 41 40 }; 42 41 43 42 static int ehci_ci_portpower(struct usb_hcd *hcd, int portnum, bool enable) 44 43 { 45 44 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 46 45 struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv; 47 - struct ci_hdrc *ci = priv->ci; 48 46 struct device *dev = hcd->self.controller; 47 + struct ci_hdrc *ci = dev_get_drvdata(dev); 49 48 int ret = 0; 50 49 int port = HCS_N_PORTS(ehci->hcs_params); 51 50 ··· 77 78 return 0; 78 79 }; 79 80 81 + static int ehci_ci_reset(struct usb_hcd *hcd) 82 + { 83 + struct device *dev = hcd->self.controller; 84 + struct ci_hdrc *ci = dev_get_drvdata(dev); 85 + int ret; 86 + 87 + ret = ehci_setup(hcd); 88 + if (ret) 89 + return ret; 90 + 91 + ci_platform_configure(ci); 92 + 93 + return ret; 94 + } 95 + 80 96 static const struct ehci_driver_overrides ehci_ci_overrides = { 81 97 .extra_priv_size = sizeof(struct ehci_ci_priv), 82 98 .port_power = ehci_ci_portpower, 99 + .reset = ehci_ci_reset, 83 100 }; 84 101 85 102 static irqreturn_t host_irq(struct ci_hdrc *ci) ··· 138 123 139 124 priv = (struct ehci_ci_priv *)ehci->priv; 140 125 priv->reg_vbus = NULL; 141 - priv->ci = ci; 142 126 143 127 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) { 144 128 if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) { ··· 166 152 hcd->self.otg_port = 1; 167 153 } 168 154 } 169 - 170 - if (ci->platdata->flags & CI_HDRC_DISABLE_STREAMING) 171 - hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); 172 - 173 - if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) 174 - hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); 175 155 176 156 return ret; 177 157
-1
drivers/usb/chipidea/otg_fsm.c
··· 525 525 ci_role_start(ci, CI_ROLE_HOST); 526 526 } else { 527 527 ci_role_stop(ci); 528 - hw_device_reset(ci); 529 528 ci_role_start(ci, CI_ROLE_GADGET); 530 529 } 531 530 return 0;
+8 -1
drivers/usb/chipidea/udc.c
··· 445 445 rest -= count; 446 446 } 447 447 448 - if (hwreq->req.zero && hwreq->req.length 448 + if (hwreq->req.zero && hwreq->req.length && hwep->dir == TX 449 449 && (hwreq->req.length % hwep->ep.maxpacket == 0)) 450 450 add_td_to_list(hwep, hwreq, 0); 451 451 ··· 1089 1089 case USB_DEVICE_A_ALT_HNP_SUPPORT: 1090 1090 if (ci_otg_is_fsm_mode(ci)) 1091 1091 err = otg_a_alt_hnp_support(ci); 1092 + break; 1093 + case USB_DEVICE_A_HNP_SUPPORT: 1094 + if (ci_otg_is_fsm_mode(ci)) { 1095 + ci->gadget.a_hnp_support = 1; 1096 + err = isr_setup_status_phase( 1097 + ci); 1098 + } 1092 1099 break; 1093 1100 default: 1094 1101 goto delegate;
+10 -2
drivers/usb/chipidea/usbmisc_imx.c
··· 54 54 #define MX53_USB_PHYCTRL1_PLLDIV_MASK 0x3 55 55 #define MX53_USB_PLL_DIV_24_MHZ 0x01 56 56 57 + #define MX6_BM_NON_BURST_SETTING BIT(1) 57 58 #define MX6_BM_OVER_CUR_DIS BIT(7) 58 59 #define MX6_BM_WAKEUP_ENABLE BIT(10) 59 60 #define MX6_BM_ID_WAKEUP BIT(16) ··· 256 255 if (data->index > 3) 257 256 return -EINVAL; 258 257 258 + spin_lock_irqsave(&usbmisc->lock, flags); 259 + 259 260 if (data->disable_oc) { 260 - spin_lock_irqsave(&usbmisc->lock, flags); 261 261 reg = readl(usbmisc->base + data->index * 4); 262 262 writel(reg | MX6_BM_OVER_CUR_DIS, 263 263 usbmisc->base + data->index * 4); 264 - spin_unlock_irqrestore(&usbmisc->lock, flags); 265 264 } 265 + 266 + /* SoC non-burst setting */ 267 + reg = readl(usbmisc->base + data->index * 4); 268 + writel(reg | MX6_BM_NON_BURST_SETTING, 269 + usbmisc->base + data->index * 4); 270 + 271 + spin_unlock_irqrestore(&usbmisc->lock, flags); 266 272 267 273 usbmisc_imx6q_set_wakeup(data, false); 268 274
+13 -1
include/linux/usb/chipidea.h
··· 19 19 enum usb_phy_interface phy_mode; 20 20 unsigned long flags; 21 21 #define CI_HDRC_REGS_SHARED BIT(0) 22 + #define CI_HDRC_DISABLE_DEVICE_STREAMING BIT(1) 22 23 #define CI_HDRC_SUPPORTS_RUNTIME_PM BIT(2) 23 - #define CI_HDRC_DISABLE_STREAMING BIT(3) 24 + #define CI_HDRC_DISABLE_HOST_STREAMING BIT(3) 25 + #define CI_HDRC_DISABLE_STREAMING (CI_HDRC_DISABLE_DEVICE_STREAMING | \ 26 + CI_HDRC_DISABLE_HOST_STREAMING) 24 27 /* 25 28 * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1, 26 29 * but otg is not supported (no register otgsc). ··· 32 29 #define CI_HDRC_IMX28_WRITE_FIX BIT(5) 33 30 #define CI_HDRC_FORCE_FULLSPEED BIT(6) 34 31 #define CI_HDRC_TURN_VBUS_EARLY_ON BIT(7) 32 + #define CI_HDRC_SET_NON_ZERO_TTHA BIT(8) 33 + #define CI_HDRC_OVERRIDE_AHB_BURST BIT(9) 34 + #define CI_HDRC_OVERRIDE_TX_BURST BIT(10) 35 + #define CI_HDRC_OVERRIDE_RX_BURST BIT(11) 35 36 enum usb_dr_mode dr_mode; 36 37 #define CI_HDRC_CONTROLLER_RESET_EVENT 0 37 38 #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 ··· 43 36 struct regulator *reg_vbus; 44 37 struct usb_otg_caps ci_otg_caps; 45 38 bool tpl_support; 39 + /* interrupt threshold setting */ 40 + u32 itc_setting; 41 + u32 ahb_burst_config; 42 + u32 tx_burst_size; 43 + u32 rx_burst_size; 46 44 }; 47 45 48 46 /* Default offset of capability registers */