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

usb: dwc3: make usb2 phy utmi interface configurable

Support to configure the UTMI+ PHY with an 8- or 16-bit
interface via DT. The UTMI+ PHY interface is a hardware
capability, and it's platform dependent. Normally, the
PHYIF can be configured during coreconsultant.

But for some specific USB cores(e.g. rk3399 SoC DWC3),
the default PHYIF configuration value is false, so we
need to reconfigure it by software.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

William Wu and committed by
Felipe Balbi
32f2ed86 16199f33

+36
+6
Documentation/devicetree/bindings/usb/generic.txt
··· 11 11 "peripheral" and "otg". In case this attribute isn't 12 12 passed via DT, USB DRD controllers should default to 13 13 OTG. 14 + - phy_type: tells USB controllers that we want to configure the core to support 15 + a UTMI+ PHY with an 8- or 16-bit interface if UTMI+ is 16 + selected. Valid arguments are "utmi" and "utmi_wide". 17 + In case this isn't passed via DT, USB controllers should 18 + default to HW capability. 14 19 - otg-rev: tells usb driver the release number of the OTG and EH supplement 15 20 with which the device and its descriptors are compliant, 16 21 in binary-coded decimal (i.e. 2.0 is 0200H). This ··· 39 34 usb-phy = <&usb2_phy>, <&usb3,phy>; 40 35 maximum-speed = "super-speed"; 41 36 dr_mode = "otg"; 37 + phy_type = "utmi_wide"; 42 38 otg-rev = <0x0200>; 43 39 adp-disable; 44 40 };
+18
drivers/usb/dwc3/core.c
··· 485 485 break; 486 486 } 487 487 488 + switch (dwc->hsphy_mode) { 489 + case USBPHY_INTERFACE_MODE_UTMI: 490 + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | 491 + DWC3_GUSB2PHYCFG_USBTRDTIM_MASK); 492 + reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_8_BIT) | 493 + DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_8_BIT); 494 + break; 495 + case USBPHY_INTERFACE_MODE_UTMIW: 496 + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK | 497 + DWC3_GUSB2PHYCFG_USBTRDTIM_MASK); 498 + reg |= DWC3_GUSB2PHYCFG_PHYIF(UTMI_PHYIF_16_BIT) | 499 + DWC3_GUSB2PHYCFG_USBTRDTIM(USBTRDTIM_UTMI_16_BIT); 500 + break; 501 + default: 502 + break; 503 + } 504 + 488 505 /* 489 506 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to 490 507 * '0' during coreConsultant configuration. So default value will ··· 908 891 909 892 dwc->maximum_speed = usb_get_maximum_speed(dev); 910 893 dwc->dr_mode = usb_get_dr_mode(dev); 894 + dwc->hsphy_mode = of_usb_get_phy_mode(dev->of_node); 911 895 912 896 dwc->has_lpm_erratum = device_property_read_bool(dev, 913 897 "snps,has-lpm-erratum");
+12
drivers/usb/dwc3/core.h
··· 203 203 #define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6) 204 204 #define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4) 205 205 #define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8) 206 + #define DWC3_GUSB2PHYCFG_PHYIF(n) (n << 3) 207 + #define DWC3_GUSB2PHYCFG_PHYIF_MASK DWC3_GUSB2PHYCFG_PHYIF(1) 208 + #define DWC3_GUSB2PHYCFG_USBTRDTIM(n) (n << 10) 209 + #define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK DWC3_GUSB2PHYCFG_USBTRDTIM(0xf) 210 + #define USBTRDTIM_UTMI_8_BIT 9 211 + #define USBTRDTIM_UTMI_16_BIT 5 212 + #define UTMI_PHYIF_16_BIT 1 213 + #define UTMI_PHYIF_8_BIT 0 206 214 207 215 /* Global USB2 PHY Vendor Control Register */ 208 216 #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25) ··· 756 748 * @maximum_speed: maximum speed requested (mainly for testing purposes) 757 749 * @revision: revision register contents 758 750 * @dr_mode: requested mode of operation 751 + * @hsphy_mode: UTMI phy mode, one of following: 752 + * - USBPHY_INTERFACE_MODE_UTMI 753 + * - USBPHY_INTERFACE_MODE_UTMIW 759 754 * @usb2_phy: pointer to USB2 PHY 760 755 * @usb3_phy: pointer to USB3 PHY 761 756 * @usb2_generic_phy: pointer to USB2 PHY ··· 864 853 size_t regs_size; 865 854 866 855 enum usb_dr_mode dr_mode; 856 + enum usb_phy_interface hsphy_mode; 867 857 868 858 u32 fladj; 869 859 u32 irq_gadget;