usb: ulpi bus
Subsystems (6)
Heikki Krogerus
maintainerv3 cover usb: ulpi bus
Hi,
I took the liberty of adding David's ACK to everything except 9/12, including to the 1/12 (removing the module handling has no functional affect).
Changes since v2:
- remove module handling from the bus driver as suggested by Paul Bolle.
- reordered the gpio requests in BYT quirk as suggested by David Cohen.
Major changes since v1:
- calling dwc3_phy_setup earlier and registering the ULPI interface there.
- new property to dwc3 for selecting the interface in case of UTMI+ and ULPI as suggested by Felipe
- dwc3 soft reset before registration of the ULPI interface to sync the clocks as suggested by David
- Including support for the BYT boards that have the GPIOs controlling the reset and cs signals.
Heikki Krogerus (12):
usb: add bus type for USB ULPI
usb: dwc3: USB2 PHY register access bits
usb: dwc3: ULPI or UTMI+ select
usb: dwc3: store driver data earlier
usb: dwc3: cache hwparams earlier
usb: dwc3: soft reset to it's own function
usb: dwc3: setup phys earlier
usb: dwc3: add hsphy_interface property
usb: dwc3: pci: add quirk for Baytrails
usb: dwc3: add ULPI interface support
phy: helpers for USB ULPI PHY registering
phy: add driver for TI TUSB1210 ULPI PHY
Documentation/devicetree/bindings/usb/dwc3.txt | 2 + MAINTAINERS | 7 + drivers/phy/Kconfig | 7 + drivers/phy/Makefile | 1 + drivers/phy/phy-tusb1210.c | 153 +++++++++++++++ drivers/phy/ulpi_phy.h | 31 ++++ drivers/usb/common/Makefile | 1 + drivers/usb/common/ulpi.c | 246 +++++++++++++++++++++++++ drivers/usb/core/Kconfig | 8 + drivers/usb/dwc3/Kconfig | 7 + drivers/usb/dwc3/Makefile | 4 + drivers/usb/dwc3/core.c | 99 +++++++--- drivers/usb/dwc3/core.h | 26 +++ drivers/usb/dwc3/dwc3-pci.c | 36 ++++ drivers/usb/dwc3/platform_data.h | 2 + drivers/usb/dwc3/ulpi.c | 91 +++++++++ include/linux/mod_devicetable.h | 6 + include/linux/ulpi/driver.h | 62 +++++++ include/linux/ulpi/interface.h | 23 +++ include/linux/ulpi/regs.h | 130 +++++++++++++ include/linux/usb/ulpi.h | 134 +------------- scripts/mod/devicetable-offsets.c | 4 + scripts/mod/file2alias.c | 13 ++ 23 files changed, 936 insertions(+), 157 deletions(-) create mode 100644 drivers/phy/phy-tusb1210.c create mode 100644 drivers/phy/ulpi_phy.h create mode 100644 drivers/usb/common/ulpi.c create mode 100644 drivers/usb/dwc3/ulpi.c create mode 100644 include/linux/ulpi/driver.h create mode 100644 include/linux/ulpi/interface.h create mode 100644 include/linux/ulpi/regs.h
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 1/11 usb: add bus type for USB ULPI
UTMI+ Low Pin Interface (ULPI) is a commonly used PHY interface for USB 2.0. The ULPI specification describes a standard set of registers which the vendors can extend for their specific needs. ULPI PHYs provide often functions such as charger detection and ADP sensing and probing.
There are two major issues that the bus type is meant to tackle:
Firstly, ULPI registers are accessed from the controller. The bus provides convenient method for the controller drivers to share that access with the actual PHY drivers.
Secondly, there are already platforms that assume ULPI PHYs are runtime detected, such as many Intel Baytrail based platforms. They do not provide any kind of hardware description for the ULPI PHYs like separate ACPI device object that could be used to enumerate a device from.
--- MAINTAINERS | 7 ++ drivers/usb/common/Makefile | 1 + drivers/usb/common/ulpi.c | 246 ++++++++++++++++++++++++++++++++++++++ drivers/usb/core/Kconfig | 7 ++ include/linux/mod_devicetable.h | 6 + include/linux/ulpi/driver.h | 62 ++++++++++ include/linux/ulpi/interface.h | 23 ++++ include/linux/ulpi/regs.h | 130 ++++++++++++++++++++ include/linux/usb/ulpi.h | 134 +-------------------- scripts/mod/devicetable-offsets.c | 4 + scripts/mod/file2alias.c | 13 ++ 11 files changed, 501 insertions(+), 132 deletions(-) create mode 100644 drivers/usb/common/ulpi.c create mode 100644 include/linux/ulpi/driver.h create mode 100644 include/linux/ulpi/interface.h create mode 100644 include/linux/ulpi/regs.h
MAINTAINERS +7 -0
@@ -10470,6 +10470,13 @@ S: Maintained F: Documentation/video4linux/zr364xx.txt F: drivers/media/usb/zr364xx/ +ULPI BUS +M: Heikki Krogerus <[email protected]> +L: [email protected] +S: Maintained +F: drivers/usb/common/ulpi.c +F: include/linux/ulpi/ + USER-MODE LINUX (UML) M: Jeff Dike <[email protected]> M: Richard Weinberger <[email protected]>
drivers/usb/common/Makefile +1 -0
@@ -7,3 +7,4 @@ usb-common-y += common.o usb-common-$(CONFIG_USB_LED_TRIG) += led.o obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o +obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
drivers/usb/common/ulpi.c new file +246 -0
246 lines not on this page · raw message
drivers/usb/core/Kconfig +7 -0
@@ -84,3 +84,10 @@ config USB_OTG_FSM Implements OTG Finite State Machine as specified in On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification. +config USB_ULPI_BUS + bool "USB ULPI PHY interface support" + depends on USB_SUPPORT + help + Say yes if you have ULPI PHY attached to your USB controller. + + If unsure, say N.
include/linux/mod_devicetable.h +6 -0
@@ -629,4 +629,10 @@ struct mcb_device_id { kernel_ulong_t driver_data; }; +struct ulpi_device_id { +__u16 vendor; +__u16 product; +kernel_ulong_t driver_data; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */
include/linux/ulpi/driver.h new file +62 -0
62 lines not on this page · raw message
include/linux/ulpi/interface.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef __LINUX_ULPI_INTERFACE_H +#define __LINUX_ULPI_INTERFACE_H + +#include <linux/types.h> + +struct ulpi ; + +/** +* struct ulpi_ops - ULPI register access +* @dev: the interface provider +* @read: read opearation for ULPI register access +* @write: write opearation for ULPI register access +*/ +struct ulpi_ops { +struct device *dev; +int (*read)(struct ulpi_ops *ops,u8 addr); +int (*write)(struct ulpi_ops *ops,u8 addr,u8 val); +}; + +struct ulpi *ulpi_register_interface (struct device *,struct ulpi_ops *); +void ulpi_unregister_interface (struct ulpi *); + +#endif /* __LINUX_ULPI_INTERFACE_H */
include/linux/ulpi/regs.h new file +130 -0
130 lines not on this page · raw message
include/linux/usb/ulpi.h +2 -132
146 lines not on this page · raw message
scripts/mod/devicetable-offsets.c +4 -0
@@ -189,5 +189,9 @@ int main(void)DEVID_FIELD (rio_device_id, asm_did);DEVID_FIELD (rio_device_id, asm_vid); +DEVID (ulpi_device_id); +DEVID_FIELD (ulpi_device_id, vendor); +DEVID_FIELD (ulpi_device_id, product); +return 0 ; }
scripts/mod/file2alias.c +13 -0
@@ -1192,6 +1192,19 @@ static int do_rio_entry(const char *filename, }ADD_TO_DEVTABLE ("rapidio" , rio_device_id, do_rio_entry); +/* Looks like: ulpi:vNpN */ +static int do_ulpi_entry (const char *filename,void *symval, +char *alias) +{ +DEF_FIELD (symval, ulpi_device_id, vendor); +DEF_FIELD (symval, ulpi_device_id, product); + +sprintf (alias,"ulpi:v%04xp%04x" , vendor, product); + +return 1 ; +} +ADD_TO_DEVTABLE ("ulpi" , ulpi_device_id, do_ulpi_entry); +/* Does namelen bytes of name exactly match the symbol? */ static bool sym_is (const char *name,unsigned namelen,const char *symbol) {
Signature · 1 line
2.1.4
Re: [PATCHv3 01/11] usb: add bus type for USB ULPI
Hi,
Quoted 1 line · Heikki Krogerus
+struct
bus_typeulpi_bus= {
non-static and undeclared anywhere, adds a sparse error. I'm dropping the series for now :-)
"drivers/usb/common/ulpi.c:77:17: warning: symbol 'ulpi_bus' was not declared. Should it be static?
"
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 01/11] usb: add bus type for USB ULPI
Quoted 9 lines
Quoted 1 line
+struct
bus_typeulpi_bus= {non-static and undeclared anywhere, adds a sparse error. I'm dropping the series for now :-)
"
drivers/usb/common/ulpi.c:77:17: warning: symbol 'ulpi_bus' was not declared. Should it be static?
"
Need to fix that. I'll wait for your comment's to 10/12 before preparing new version.
Thanks,
Signature · 1 line
heikki
Heikki Krogerus
maintainerPATCH v3 2/11 usb: dwc3: USB2 PHY register access bits
In reply to Heikki KrogerusDefinitions for Global USB2 PHY Vendor Control Register bits. We will need them to access ULPI PHY registers later.
--- drivers/usb/dwc3/core.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/dwc3/core.h +8 -0
@@ -174,6 +174,14 @@#define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6) +/* Global USB2 PHY Vendor Control Register */ +#define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25) +#define DWC3_GUSB2PHYACC_BUSY (1 << 23) +#define DWC3_GUSB2PHYACC_WRITE (1 << 22) +#define DWC3_GUSB2PHYACC_ADDR (n) (n << 16) +#define DWC3_GUSB2PHYACC_EXTEND_ADDR (n) (n << 8) +#define DWC3_GUSB2PHYACC_DATA (n) (n & 0xff) +/* Global USB3 PIPE Control Register */ #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31)#define DWC3_GUSB3PIPECTL_U2SSINP3OK (1 << 29)
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 3/11 usb: dwc3: ULPI or UTMI+ select
In reply to Heikki KrogerusMake selection between ULPI and UTMI+ interfaces possible by providing definition for the bit in Global USB2 PHY Configuration Register that controls it.
--- drivers/usb/dwc3/core.h | 1 + 1 file changed, 1 insertion(+)
drivers/usb/dwc3/core.h +1 -0
@@ -173,6 +173,7 @@/* Global USB2 PHY Configuration Register */ #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)#define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6) +#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4)/* Global USB2 PHY Vendor Control Register */ #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 4/11 usb: dwc3: store driver data earlier
In reply to Heikki KrogerusWe need to store it before phys are handled, so we can later use it in ULPI interface support code.
--- drivers/usb/dwc3/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.c +2 -1
@@ -875,12 +875,13 @@ static int dwc3_probe(struct platform_device *pdev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend <<4 ); +platform_set_drvdata (pdev, dwc); + ret =dwc3_core_get_phy (dwc);if (ret) goto err0;spin_lock_init (&dwc->lock); -platform_set_drvdata (pdev, dwc);if (!dev->dma_mask) { dev->dma_mask = dev->parent->dma_mask;
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 5/11 usb: dwc3: cache hwparams earlier
In reply to Heikki KrogerusSo they are available when ULPI interface support is added.
--- drivers/usb/dwc3/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/dwc3/core.c +1 -2
@@ -876,6 +876,7 @@ static int dwc3_probe(struct platform_device *pdev) | (dwc->is_utmi_l1_suspend << 4);platform_set_drvdata (pdev, dwc); +dwc3_cache_hwparams (dwc); ret =dwc3_core_get_phy (dwc);if (ret)
@@ -893,8 +894,6 @@ static int dwc3_probe(struct platform_device *pdev)pm_runtime_get_sync (dev);pm_runtime_forbid (dev); -dwc3_cache_hwparams (dwc); - ret =dwc3_alloc_event_buffers (dwc,DWC3_EVENT_BUFFERS_SIZE );if (ret) {dev_err (dwc->dev,"failed to allocate event buffers\n" );
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 6/11 usb: dwc3: soft reset to it's own function
In reply to Heikki KrogerusSo it can be called from other places later.
--- drivers/usb/dwc3/core.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-)
drivers/usb/dwc3/core.c +30 -16
@@ -117,6 +117,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) }/** +* dwc3_soft_reset - Issue soft reset +* @dwc: Pointer to our controller context structure +*/ +static int dwc3_soft_reset (struct dwc3 *dwc) +{ +unsigned long timeout; +u32 reg; + + timeout = jiffies +msecs_to_jiffies (500 ); +dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); +do { + reg =dwc3_readl (dwc->regs,DWC3_DCTL ); +if (!(reg &DWC3_DCTL_CSFTRST )) +break ; + +if (time_after (jiffies, timeout)) { +dev_err (dwc->dev,"Reset Timed Out\n" ); +return -ETIMEDOUT ; + } + +cpu_relax (); + }while (true); + +return 0 ; +} + +/** * dwc3_free_one_event_buffer - Frees one event buffer * @dwc: Pointer to our controller context structure * @evt: Pointer to event buffer to be freed
@@ -438,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)*/ static int dwc3_core_init (struct dwc3 *dwc) { -unsigned long timeout;u32 hwparams4 = dwc->hwparams.hwparams4;u32 reg;int ret;
@@ -466,21 +492,9 @@ static int dwc3_core_init(struct dwc3 *dwc) }/* issue device SoftReset too */ - timeout = jiffies +msecs_to_jiffies (500 ); -dwc3_writel (dwc->regs,DWC3_DCTL ,DWC3_DCTL_CSFTRST ); -do { - reg =dwc3_readl (dwc->regs,DWC3_DCTL ); -if (!(reg &DWC3_DCTL_CSFTRST )) -break ; - -if (time_after (jiffies, timeout)) { -dev_err (dwc->dev,"Reset Timed Out\n" ); - ret = -ETIMEDOUT ; - goto err0; - } - -cpu_relax (); - }while (true); + ret =dwc3_soft_reset (dwc); +if (ret) + goto err0; ret =dwc3_core_soft_reset (dwc);if (ret)
Signature · 1 line
2.1.4
Re: [PATCHv3 06/11] usb: dwc3: soft reset to it's own function
Quoted 13 lines · Heikki Krogerus
So it can be called from other places later.
Signed-off-by Heikki Krogerus <[email protected]>Acked-by David Cohen <[email protected]>--- drivers/usb/dwc3/core.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-)drivers/usb/dwc3/core.c +0
-0
drivers/usb/dwc3/core.c static int dwc3_core_soft_reset(struct dwc3 *dwc) · line 123
Quoted 7 lines
drivers/usb/dwc3/core.c +4
-0@@ -117,6 +117,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) }/** +* dwc3_soft_reset - Issue soft reset +* @dwc: Pointer to our controller context structure +*/ +static int dwc3_soft_reset (struct dwc3 *dwc)
I don't see this being called anywhere else in your series and I would really like to know when we would need to reset the core again ?
I don't oppose to having this split to own function because I rather like how it looks, but I don't want to reset the IP needlessly either.
cheers
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 06/11] usb: dwc3: soft reset to it's own function
Quoted 10 lines
Quoted 4 lines
+ *
dwc3_soft_reset- Issue soft reset
+ * @dwc: Pointer to our controller context structure
+ */
+static intdwc3_soft_reset(struct dwc3 *dwc)I don't see this being called anywhere else in your series and I would really like to know when we would need to reset the core again ?
I don't oppose to having this split to own function because I rather like how it looks, but I don't want to reset the IP needlessly either.
This series seems to be missing the last patch for dwc3, where I actually add the ULPI support to dwc3 :-p. How have I managed to prepare this series with one patch from the middle missing?!?! The cover letter seems to be correct.
I'll resend the patches 8-12/12.
Thanks,
Signature · 1 line
heikki
Heikki Krogerus
maintainerPATCH v3 7/11 usb: dwc3: setup phys earlier
In reply to Heikki KrogerusThis allows dwc3_phy_setup() to be more useful later. There is nothing preventing the PHY configuration registers from being programmed early. They do not loose their context in soft reset.
There are however other PHY related operations that should be executed before the driver request handles to the PHYs, such as registering DWC3's ULPI interface, which can now be done in dwc3_phy_setup().
Also, if there ever was need for the two 100ms delays in dwc3_phy_setup() there isn't anymore. The PHYs are now reset after the PHY interfaces are setup.
--- drivers/usb/dwc3/core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/usb/dwc3/core.c +2 -6
@@ -436,8 +436,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GUSB3PIPECTL (0 ), reg); -mdelay (100 ); - reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 ));/*
@@ -453,8 +451,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); - -mdelay (100 ); }/**
@@ -569,8 +565,6 @@ static int dwc3_core_init(struct dwc3 *dwc)dwc3_writel (dwc->regs,DWC3_GCTL , reg); -dwc3_phy_setup (dwc); - ret =dwc3_alloc_scratch_buffers (dwc);if (ret) goto err1;
@@ -892,6 +886,8 @@ static int dwc3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc); +dwc3_phy_setup (dwc); + ret =dwc3_core_get_phy (dwc);if (ret) goto err0;
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 8/11 usb: dwc3: add hsphy_interface property
In reply to Heikki KrogerusPlatforms that have configured DWC_USB3_HSPHY_INTERFACE with value 3, i.e. UTMI+ and ULPI, need to inform the driver of the actual HSPHY interface type with the property. "utmi" if the interface is UTMI+ or "ulpi" if the interface is ULPI.
--- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 29 ++++++++++++++++++++++++-- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/platform_data.h | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/dwc3.txt +2 -0
@@ -38,6 +38,8 @@ Optional properties: - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold + - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for + UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3. This is usually a subnode to DWC3 glue to which it is connected.
drivers/usb/dwc3/core.c +27 -2
@@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)* dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure */ -static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret; reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));
@@ -438,6 +439,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); +/* Select the HS PHY interface */ +switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) { +case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI : +if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { + reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else { +dev_err (dwc->dev,"HSPHY Interface not defined\n" ); +return -EINVAL ; + } +/* FALLTHROUGH */ +default : +break ; + } +/* * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to * '0' during coreConsultant configuration. So default value will
@@ -451,6 +468,8 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + +return 0 ; }/**
@@ -844,6 +863,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,tx_de_emphasis_quirk");of_property_read_u8 (node,"snps,tx_de_emphasis" , &tx_de_emphasis); +of_property_read_string (node,"snps,hsphy_interface" , + &dwc->hsphy_interface); }else if (pdata) { dwc->maximum_speed = pdata->maximum_speed; dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -871,6 +892,8 @@ static int dwc3_probe(struct platform_device *pdev) dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis) tx_de_emphasis = pdata->tx_de_emphasis; + + dwc->hsphy_interface = pdata->hsphy_interface; }/* default to superspeed if no maximum_speed passed */
@@ -886,7 +909,9 @@ static int dwc3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc); -dwc3_phy_setup (dwc); + ret =dwc3_phy_setup (dwc); +if (ret) + goto err0; ret =dwc3_core_get_phy (dwc);if (ret)
drivers/usb/dwc3/core.h +3 -0
@@ -682,6 +682,7 @@ struct dwc3_scratchpad_array {* @test_mode_nr: test feature selector * @lpm_nyet_threshold: LPM NYET response threshold * @hird_threshold: HIRD threshold +* @hsphy_interface: "utmi" or "ulpi" * @delayed_status: true when gadget driver asks for delayed status * @ep0_bounced: true when we used bounce buffer * @ep0_expect_in: true when we expect a DATA IN transfer
@@ -809,6 +810,8 @@ struct dwc3 {u8 lpm_nyet_threshold;u8 hird_threshold; +const char *hsphy_interface; + unsigned delayed_status:1; unsigned ep0_bounced:1; unsigned ep0_expect_in:1;
drivers/usb/dwc3/platform_data.h +2 -0
@@ -45,4 +45,6 @@ struct dwc3_platform_data { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + +const char *hsphy_interface; };
Signature · 1 line
2.1.4
Re: [PATCHv3 08/11] usb: dwc3: add hsphy_interface property
Quoted 47 lines · Heikki Krogerus
Platforms that have configured
DWC_USB3_HSPHY_INTERFACEwith value 3, i.e. UTMI+ and ULPI, need to inform the driver of the actual HSPHY interface type with the property. "utmi" if the interface is UTMI+ or "ulpi" if the interface is ULPI.Signed-off-by Heikki Krogerus <[email protected]>Acked-by David Cohen <[email protected]>--- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 29 ++++++++++++++++++++++++-- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/platform_data.h | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +2
-0@@ -38,6 +38,8 @@ Optional properties: - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold + - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for + UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3. This is usually a subnode to DWC3 glue to which it is connected.drivers/usb/dwc3/core.c +2
-1@@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)* dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure */ -static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret; reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));@@ -438,6 +439,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 ));
drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 451
Quoted 10 lines
drivers/usb/dwc3/core.c +10
-0+/* Select the HS PHY interface */ +switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) { +case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI : +if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { + reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else { +dev_err (dwc->dev,"HSPHY Interface not defined\n" ); +return -EINVAL ;
instead of erroring out, just leave default value and convert this to a dev_warn() or something similar. That way, older DTS will continue to work.
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 08/11] usb: dwc3: add hsphy_interface property
Quoted 6 lines
Quoted 6 lines
drivers/usb/dwc3/core.c +6
-0+/* Select the HS PHY interface */ +switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) { +case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI : +if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) {
Quoted 8 lines
drivers/usb/dwc3/core.c static void dwc3_phy_setup(struct dwc3 *dwc) · line 451
Quoted 4 lines
drivers/usb/dwc3/core.c +4
-0+ reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else { +dev_err (dwc->dev,"HSPHY Interface not defined\n" ); +return -EINVAL ;instead of erroring out, just leave default value and convert this to a
dev_warn()or something similar. That way, older DTS will continue to work.
OK, I'll change it.
Thanks,
Signature · 1 line
heikki
Heikki Krogerus
maintainerPATCH v3 9/11 usb: dwc3: pci: add quirk for Baytrails
In reply to Heikki KrogerusOn some BYT platforms the USB2 PHY needs to be put into operational mode by the controller driver with GPIOs controlling the PHYs reset and cs signals.
--- drivers/usb/dwc3/dwc3-pci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +36 -0
@@ -21,6 +21,8 @@#include <linux/slab.h> #include <linux/pci.h> #include <linux/platform_device.h> +#include <linux/gpio/consumer.h> +#include <linux/acpi.h> #include "platform_data.h"
@@ -31,6 +33,15 @@#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30#define PCI_DEVICE_ID_INTEL_SPTH 0xa130 +static const struct acpi_gpio_params reset_gpios = {0 ,0 , false }; +static const struct acpi_gpio_params cs_gpios = {1 ,0 , false }; + +static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = { + {"reset-gpios" , &reset_gpios,1 }, + {"cs-gpios" , &cs_gpios,1 }, + { }, +}; +static int dwc3_pci_quirks (struct pci_dev *pdev) { if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -65,6 +76,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) sizeof(pdata)); } +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_BYT ) { +struct gpio_desc *gpio; + +acpi_dev_add_driver_gpios (ACPI_COMPANION (&pdev->dev), + acpi_dwc3_byt_gpios); + +/* These GPIOs will turn on the USB2 PHY */ + gpio =gpiod_get (&pdev->dev,"cs" ); +if (!IS_ERR (gpio)) { +gpiod_direction_output (gpio,0 ); +gpiod_set_value_cansleep (gpio,1 ); +gpiod_put (gpio); + } + + gpio =gpiod_get (&pdev->dev,"reset" ); +if (!IS_ERR (gpio)) { +gpiod_direction_output (gpio,0 ); +gpiod_set_value_cansleep (gpio,1 ); +gpiod_put (gpio); +msleep (10 ); + } + } +return 0 ; }
@@ -128,6 +163,7 @@ err:static void dwc3_pci_remove (struct pci_dev *pci) { +acpi_dev_remove_driver_gpios (ACPI_COMPANION (&pci->dev));platform_device_unregister (pci_get_drvdata (pci)); }
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 10/11 phy: helpers for USB ULPI PHY registering
In reply to Heikki KrogerusULPI PHYs need to be bound to their controllers with a lookup. This adds helpers that the ULPI drivers can use to do both, the registration of the PHY and the lookup, at the same time.
--- drivers/phy/ulpi_phy.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 drivers/phy/ulpi_phy.h
drivers/phy/ulpi_phy.h new file +31 -0
@@ -0,0 +1,31 @@ +#include <linux/phy/phy.h> + +/** +* Helper that registers PHY for a ULPI device and adds a lookup for binding it +* and it's controller, which is always the parent. +*/ +static inline struct phy +*ulpi_phy_create (struct ulpi *ulpi,struct phy_ops *ops) +{ +struct phy *phy; +int ret; + + phy =phy_create (&ulpi->dev,NULL , ops); +if (IS_ERR (phy)) +return phy; + + ret =phy_create_lookup (phy,"usb2-phy" ,dev_name (ulpi->dev.parent)); +if (ret) { +phy_destroy (phy); +return ERR_PTR (ret); + } + +return phy; +} + +/* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */ +static inline void ulpi_phy_destroy (struct ulpi *ulpi,struct phy *phy) +{ +phy_remove_lookup (phy,"usb2-phy" ,dev_name (ulpi->dev.parent)); +phy_destroy (phy); +}
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 11/11 phy: add driver for TI TUSB1210 ULPI PHY
In reply to Heikki KrogerusTUSB1210 ULPI PHY has vendor specific register for eye diagram tuning. On some platforms the system firmware has set optimized value to it. In order to not loose the optimized value, the driver stores it during probe and restores it every time the PHY is powered back on.
--- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-tusb1210.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 drivers/phy/phy-tusb1210.c
drivers/phy/Kconfig +7 -0
@@ -309,4 +309,11 @@ config PHY_QCOM_UFS help Support for UFS PHY on QCOM chipsets. +config PHY_TUSB1210 + tristate "TI TUSB1210 ULPI PHY module" + depends on USB_ULPI_BUS + select GENERIC_PHY + help + Support for TI TUSB1210 USB ULPI PHY. + endmenu
drivers/phy/Makefile +1 -0
@@ -40,3 +40,4 @@ obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o +obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
drivers/phy/phy-tusb1210.c new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.1.4
Hi,
Quoted 18 lines · Heikki Krogerus
Hi,
I took the liberty of adding David's ACK to everything except 9/12, including to the 1/12 (removing the module handling has no functional affect).
Changes since v2:
- remove module handling from the bus driver as suggested by Paul Bolle.
- reordered the gpio requests in BYT quirk as suggested by David Cohen.Major changes since v1:
- callingdwc3_phy_setupearlier and registering the ULPI interface there.
- new property to dwc3 for selecting the interface in case of UTMI+ and ULPI as suggested by Felipe
- dwc3 soft reset before registration of the ULPI interface to sync the clocks as suggested by David
- Including support for the BYT boards that have the GPIOs controlling the reset and cs signals.
Quoted 8 lines
Heikki Krogerus (12):
usb: add bus type for USB ULPI
usb: dwc3: USB2 PHY register access bits
usb: dwc3: ULPI or UTMI+ select
usb: dwc3: store driver data earlier
usb: dwc3: cache hwparams earlier
usb: dwc3: soft reset to it's own function
usb: dwc3: setup phys earlier
up to patch 7/12, I've applied to my testing/next. I'll wait for a revised 8/12 before applying the rest.
Signature · 1 line
balbi
Heikki Krogerus
maintainerQuoted 30 lines · Felipe Balbi
Hi,
Quoted 18 lines · Heikki Krogerus
Hi,
I took the liberty of adding David's ACK to everything except 9/12, including to the 1/12 (removing the module handling has no functional affect).
Changes since v2:
- remove module handling from the bus driver as suggested by Paul Bolle.
- reordered the gpio requests in BYT quirk as suggested by David Cohen.Major changes since v1:
- callingdwc3_phy_setupearlier and registering the ULPI interface there.
- new property to dwc3 for selecting the interface in case of UTMI+ and ULPI as suggested by Felipe
- dwc3 soft reset before registration of the ULPI interface to sync the clocks as suggested by David
- Including support for the BYT boards that have the GPIOs controlling the reset and cs signals.Quoted 8 lines
Heikki Krogerus (12):
usb: add bus type for USB ULPI
usb: dwc3: USB2 PHY register access bits
usb: dwc3: ULPI or UTMI+ select
usb: dwc3: store driver data earlier
usb: dwc3: cache hwparams earlier
usb: dwc3: soft reset to it's own function
usb: dwc3: setup phys earlier
Quoted 2 lines
up to patch 7/12, I've applied to my testing/next. I'll wait for a revised 8/12 before applying the rest.
OK. I'll re-send the patches 8-12/12 here with the revised version of 8/12 and the missing 10/12 (usb: dwc3: add ULPI interface support).
Thanks,
Signature · 1 line
heikki
Heikki Krogerus
maintainerPATCH v3 8/12 usb: dwc3: add hsphy_interface property
Platforms that have configured DWC_USB3_HSPHY_INTERFACE with value 3, i.e. UTMI+ and ULPI, need to inform the driver of the actual HSPHY interface type with the property. "utmi" if the interface is UTMI+ or "ulpi" if the interface is ULPI.
--- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 29 ++++++++++++++++++++++++-- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/platform_data.h | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/dwc3.txt +2 -0
@@ -38,6 +38,8 @@ Optional properties: - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold + - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for + UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3. This is usually a subnode to DWC3 glue to which it is connected.
drivers/usb/dwc3/core.c +27 -2
@@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)* dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure */ -static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret; reg =dwc3_readl (dwc->regs,DWC3_GUSB3PIPECTL (0 ));
@@ -438,6 +439,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg =dwc3_readl (dwc->regs,DWC3_GUSB2PHYCFG (0 )); +/* Select the HS PHY interface */ +switch (DWC3_GHWPARAMS3_HSPHY_IFC (dwc->hwparams.hwparams3)) { +case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI : +if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { + reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { + reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; + }else { +dev_warn (dwc->dev,"HSPHY Interface not defined\n" ); +break ; + } +/* FALLTHROUGH */ +default : +break ; + } +/* * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to * '0' during coreConsultant configuration. So default value will
@@ -451,6 +468,8 @@ static void dwc3_phy_setup(struct dwc3 *dwc) reg &= ~DWC3_GUSB2PHYCFG_SUSPHY ;dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); + +return 0 ; }/**
@@ -844,6 +863,8 @@ static int dwc3_probe(struct platform_device *pdev) "snps,tx_de_emphasis_quirk");of_property_read_u8 (node,"snps,tx_de_emphasis" , &tx_de_emphasis); +of_property_read_string (node,"snps,hsphy_interface" , + &dwc->hsphy_interface); }else if (pdata) { dwc->maximum_speed = pdata->maximum_speed; dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -871,6 +892,8 @@ static int dwc3_probe(struct platform_device *pdev) dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;if (pdata->tx_de_emphasis) tx_de_emphasis = pdata->tx_de_emphasis; + + dwc->hsphy_interface = pdata->hsphy_interface; }/* default to superspeed if no maximum_speed passed */
@@ -886,7 +909,9 @@ static int dwc3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dwc);dwc3_cache_hwparams (dwc); -dwc3_phy_setup (dwc); + ret =dwc3_phy_setup (dwc); +if (ret) + goto err0; ret =dwc3_core_get_phy (dwc);if (ret)
drivers/usb/dwc3/core.h +3 -0
@@ -682,6 +682,7 @@ struct dwc3_scratchpad_array {* @test_mode_nr: test feature selector * @lpm_nyet_threshold: LPM NYET response threshold * @hird_threshold: HIRD threshold +* @hsphy_interface: "utmi" or "ulpi" * @delayed_status: true when gadget driver asks for delayed status * @ep0_bounced: true when we used bounce buffer * @ep0_expect_in: true when we expect a DATA IN transfer
@@ -809,6 +810,8 @@ struct dwc3 {u8 lpm_nyet_threshold;u8 hird_threshold; +const char *hsphy_interface; + unsigned delayed_status:1; unsigned ep0_bounced:1; unsigned ep0_expect_in:1;
drivers/usb/dwc3/platform_data.h +2 -0
@@ -45,4 +45,6 @@ struct dwc3_platform_data { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + +const char *hsphy_interface; };
Signature · 1 line
2.1.4
Re: [PATCHv3 08/12] usb: dwc3: add hsphy_interface property
Quoted 32 lines · Heikki Krogerus
Platforms that have configured
DWC_USB3_HSPHY_INTERFACEwith value 3, i.e. UTMI+ and ULPI, need to inform the driver of the actual HSPHY interface type with the property. "utmi" if the interface is UTMI+ or "ulpi" if the interface is ULPI.Signed-off-by Heikki Krogerus <[email protected]>Acked-by David Cohen <[email protected]>--- Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++ drivers/usb/dwc3/core.c | 29 ++++++++++++++++++++++++-- drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/platform_data.h | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/usb/dwc3.txt +2
-0@@ -38,6 +38,8 @@ Optional properties: - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal utmi_l1_suspend_n, false when asserts utmi_sleep_n - snps,hird-threshold: HIRD threshold + - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for + UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3. This is usually a subnode to DWC3 glue to which it is connected.drivers/usb/dwc3/core.c +0
-0
drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3 *dwc) · line 401
Quoted 8 lines
drivers/usb/dwc3/core.c +2
-1@@ -395,9 +395,10 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)* dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure */ -static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret;
unused variable
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 08/12] usb: dwc3: add hsphy_interface property
Quoted 7 lines
drivers/usb/dwc3/core.c static void dwc3_cache_hwparams(struct dwc3 *dwc) · line 401
Quoted 5 lines
drivers/usb/dwc3/core.c +2
-1-static void dwc3_phy_setup (struct dwc3 *dwc) +static int dwc3_phy_setup (struct dwc3 *dwc) {u32 reg; +int ret;unused variable
true,
Signature · 1 line
heikki
Heikki Krogerus
maintainerPATCH v3 9/12 usb: dwc3: pci: add quirk for Baytrails
In reply to Heikki KrogerusOn some BYT platforms the USB2 PHY needs to be put into operational mode by the controller driver with GPIOs controlling the PHYs reset and cs signals.
--- drivers/usb/dwc3/dwc3-pci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/usb/dwc3/dwc3-pci.c +36 -0
@@ -21,6 +21,8 @@#include <linux/slab.h> #include <linux/pci.h> #include <linux/platform_device.h> +#include <linux/gpio/consumer.h> +#include <linux/acpi.h> #include "platform_data.h"
@@ -31,6 +33,15 @@#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30#define PCI_DEVICE_ID_INTEL_SPTH 0xa130 +static const struct acpi_gpio_params reset_gpios = {0 ,0 , false }; +static const struct acpi_gpio_params cs_gpios = {1 ,0 , false }; + +static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = { + {"reset-gpios" , &reset_gpios,1 }, + {"cs-gpios" , &cs_gpios,1 }, + { }, +}; +static int dwc3_pci_quirks (struct pci_dev *pdev) { if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -65,6 +76,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev) sizeof(pdata)); } +if (pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_BYT ) { +struct gpio_desc *gpio; + +acpi_dev_add_driver_gpios (ACPI_COMPANION (&pdev->dev), + acpi_dwc3_byt_gpios); + +/* These GPIOs will turn on the USB2 PHY */ + gpio =gpiod_get (&pdev->dev,"cs" ); +if (!IS_ERR (gpio)) { +gpiod_direction_output (gpio,0 ); +gpiod_set_value_cansleep (gpio,1 ); +gpiod_put (gpio); + } + + gpio =gpiod_get (&pdev->dev,"reset" ); +if (!IS_ERR (gpio)) { +gpiod_direction_output (gpio,0 ); +gpiod_set_value_cansleep (gpio,1 ); +gpiod_put (gpio); +msleep (10 ); + } + } +return 0 ; }
@@ -128,6 +163,7 @@ err:static void dwc3_pci_remove (struct pci_dev *pci) { +acpi_dev_remove_driver_gpios (ACPI_COMPANION (&pci->dev));platform_device_unregister (pci_get_drvdata (pci)); }
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 10/12 usb: dwc3: add ULPI interface support
In reply to Heikki KrogerusRegisters DWC3's ULPI interface with the ULPI bus when it's available.
--- drivers/usb/dwc3/Kconfig | 7 ++++ drivers/usb/dwc3/Makefile | 4 +++ drivers/usb/dwc3/core.c | 19 +++++++++- drivers/usb/dwc3/core.h | 14 ++++++++ drivers/usb/dwc3/ulpi.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/dwc3/ulpi.c
drivers/usb/dwc3/Kconfig +7 -0
@@ -11,6 +11,13 @@ config USB_DWC3 if USB_DWC3 +config USB_DWC3_ULPI + bool "Register ULPI PHY Interface" + depends on USB_ULPI_BUS + help + Select this if you have ULPI type PHY attached to your DWC3 + controller. + choice bool "DWC3 Mode Selection" default USB_DWC3_DUAL_ROLE if (USB && USB_GADGET)
drivers/usb/dwc3/Makefile +4 -0
@@ -15,6 +15,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) $(CONFIG_USB_DWC3_DUAL_ROLE)),) dwc3-y += gadget.o ep0.o endif +ifneq ($(CONFIG_USB_DWC3_ULPI),) + dwc3-y += ulpi.o +endif + ifneq ($(CONFIG_DEBUG_FS),) dwc3-y += debugfs.o endif
drivers/usb/dwc3/core.c +18 -1
@@ -444,13 +444,28 @@ static int dwc3_phy_setup(struct dwc3 *dwc)case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI :if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; +break ; }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); }else {dev_warn (dwc->dev,"HSPHY Interface not defined\n" ); -break ; + +/* Relying on default value. */ +if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI )) +break ; }/* FALLTHROUGH */ +case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : +/* Soft reset here to sync the clocks */ + ret =dwc3_soft_reset (dwc); +if (ret) +return ret; + + ret =dwc3_ulpi_init (dwc); +if (ret) +return ret; +/* FALLTHROUGH */ default :break ; }
@@ -999,6 +1014,7 @@ err2: err1:dwc3_free_event_buffers (dwc); +dwc3_ulpi_exit (dwc); err0:/*
@@ -1034,6 +1050,7 @@ static int dwc3_remove(struct platform_device *pdev)phy_power_off (dwc->usb3_generic_phy);dwc3_core_exit (dwc); +dwc3_ulpi_exit (dwc);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);
drivers/usb/dwc3/core.h +14 -0
@@ -30,6 +30,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> +#include <linux/ulpi/interface.h> #include <linux/phy/phy.h>
@@ -661,6 +662,7 @@ struct dwc3_scratchpad_array {* @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY * @usb3_generic_phy: pointer to USB3 PHY +* @ulpi: pointer to ulpi interface * @dcfg: saved contents of DCFG register * @gctl: saved contents of GCTL register * @isoch_delay: wValue from Set Isochronous Delay request;
@@ -749,6 +751,8 @@ struct dwc3 {struct phy *usb2_generic_phy;struct phy *usb3_generic_phy; +struct ulpi *ulpi; +void __iomem *regs;size_t regs_size;
@@ -1047,4 +1051,14 @@ static inline int dwc3_gadget_resume(struct dwc3 *dwc) }#endif /* !IS_ENABLED(CONFIG_USB_DWC3_HOST) */ +#if IS_ENABLED (CONFIG_USB_DWC3_ULPI ) +int dwc3_ulpi_init (struct dwc3 *dwc); +void dwc3_ulpi_exit (struct dwc3 *dwc); +#else +static inline int dwc3_ulpi_init (struct dwc3 *dwc) +{return 0 ; } +static inline void dwc3_ulpi_exit (struct dwc3 *dwc) +{ } +#endif +#endif /* __DRIVERS_USB_DWC3_CORE_H */
drivers/usb/dwc3/ulpi.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCHv3 10/12] usb: dwc3: add ULPI interface support
Quoted 61 lines · Heikki Krogerus
Registers DWC3's ULPI interface with the ULPI bus when it's available.
Signed-off-by Heikki Krogerus <[email protected]>Acked-by David Cohen <[email protected]>--- drivers/usb/dwc3/Kconfig | 7 ++++ drivers/usb/dwc3/Makefile | 4 +++ drivers/usb/dwc3/core.c | 19 +++++++++- drivers/usb/dwc3/core.h | 14 ++++++++ drivers/usb/dwc3/ulpi.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/dwc3/ulpi.cdrivers/usb/dwc3/Kconfig +7
-0@@ -11,6 +11,13 @@ config USB_DWC3 if USB_DWC3 +config USB_DWC3_ULPI + bool "Register ULPI PHY Interface" + depends on USB_ULPI_BUS + help + Select this if you have ULPI type PHY attached to your DWC3 + controller. + choice bool "DWC3 Mode Selection" default USB_DWC3_DUAL_ROLE if (USB && USB_GADGET)drivers/usb/dwc3/Makefile +4
-0@@ -15,6 +15,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) $(CONFIG_USB_DWC3_DUAL_ROLE)),) dwc3-y += gadget.o ep0.o endif +ifneq ($(CONFIG_USB_DWC3_ULPI),) + dwc3-y += ulpi.o +endif + ifneq ($(CONFIG_DEBUG_FS),) dwc3-y += debugfs.o endifdrivers/usb/dwc3/core.c +2
-0@@ -444,13 +444,28 @@ static int dwc3_phy_setup(struct dwc3 *dwc)case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI :if (!strncmp (dwc->hsphy_interface,"utmi" ,4 )) { reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI ; +break ; }else if (!strncmp (dwc->hsphy_interface,"ulpi" ,4 )) { reg |=DWC3_GUSB2PHYCFG_ULPI_UTMI ; +dwc3_writel (dwc->regs,DWC3_GUSB2PHYCFG (0 ), reg); }else {dev_warn (dwc->dev,"HSPHY Interface not defined\n" );
drivers/usb/dwc3/core.c static int dwc3_phy_setup(struct dwc3 *dwc) · line 461
Quoted 10 lines
drivers/usb/dwc3/core.c +7
-1-break ; + +/* Relying on default value. */ +if (!(reg &DWC3_GUSB2PHYCFG_ULPI_UTMI )) +break ; }/* FALLTHROUGH */ +case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : +/* Soft reset here to sync the clocks */ + ret =dwc3_soft_reset (dwc);
you just lost all DWC3_GUSB3PIPECTL(0) and DWC3_GUSB2PHYCFG(0) configurations which happened right before this switch. Essentially breaking anybody who needs any of those extra bits enabled even though they're not enabled by default.
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 10/12] usb: dwc3: add ULPI interface support
Hi Felipe,
Quoted 8 lines
drivers/usb/dwc3/core.c static int dwc3_phy_setup(struct dwc3 *dwc) · line 461
Quoted 3 lines
drivers/usb/dwc3/core.c +3
-0+case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : +/* Soft reset here to sync the clocks */ + ret =dwc3_soft_reset (dwc);you just lost all
DWC3_GUSB3PIPECTL(0)andDWC3_GUSB2PHYCFG(0)configurations which happened right before this switch. Essentially breaking anybody who needs any of those extra bits enabled even though they're not enabled by default.
Is this a problem we have with DWC3 cores older then 1.94? I don't know anything about those. If it is, then I would imagine we just need to soft reset here conditionally, only cores >= 1.94a, right?
With 1.94a and newer, DWC3_GUSB3PIPECTL(0) and DWC3_GUSB2PHYCFG(0) keep their ctx over any kind of soft reset. And any configurations done to them here will take affect the latest when dwc3_core_soft_reset() is called.
Thanks,
Signature · 1 line
heikki
Re: [PATCHv3 10/12] usb: dwc3: add ULPI interface support
Hi,
Quoted 11 lines · Heikki Krogerus
Hi Felipe,
Quoted 8 lines
drivers/usb/dwc3/core.c static int dwc3_phy_setup(struct dwc3 *dwc) · line 461
Quoted 3 lines
drivers/usb/dwc3/core.c +3
-0+case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI : +/* Soft reset here to sync the clocks */ + ret =dwc3_soft_reset (dwc);you just lost all
DWC3_GUSB3PIPECTL(0)andDWC3_GUSB2PHYCFG(0)configurations which happened right before this switch. Essentially breaking anybody who needs any of those extra bits enabled even though they're not enabled by default.
Quoted 1 line
Is this a problem we have with DWC3 cores older then 1.94? I don't
no, it's a problem with anybody setting any of the quirks in this function, I'll reproduce some of the code here so we can look at it together.
| static int dwc3_phy_setup(struct dwc3 *dwc)
| {
| u32 reg;
| int ret;
|
| reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
|
| /*
| * Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
| * to '0' during coreConsultant configuration. So default value
| * will be '0' when the core is reset. Application needs to set it
| * to '1' after the core initialization is completed.
| */
| if (dwc->revision > DWC3_REVISION_194A)
| reg |= DWC3_GUSB3PIPECTL_SUSPHY;
|
| if (dwc->u2ss_inp3_quirk)
| reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
|
| if (dwc->req_p1p2p3_quirk)
| reg |= DWC3_GUSB3PIPECTL_REQP1P2P3;
|
| if (dwc->del_p1p2p3_quirk)
| reg |= DWC3_GUSB3PIPECTL_DEP1P2P3_EN;
|
| if (dwc->del_phy_power_chg_quirk)
| reg |= DWC3_GUSB3PIPECTL_DEPOCHANGE;
|
| if (dwc->lfps_filter_quirk)
| reg |= DWC3_GUSB3PIPECTL_LFPSFILT;
|
| if (dwc->rx_detect_poll_quirk)
| reg |= DWC3_GUSB3PIPECTL_RX_DETOPOLL;
|
| if (dwc->tx_de_emphasis_quirk)
| reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
|
| if (dwc->dis_u3_susphy_quirk)
| reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
|
| dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);right here we have potentially wrote quite a few quirks for the USB3 PHY...
| reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
|
| /* Select the HS PHY interface */
| switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
| case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
| if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
| reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
| break;
| } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
| reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
| dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
| } else {
| dev_warn(dwc->dev, "HSPHY Interface not defined\n");
|
| /* Relying on default value. */
| if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
| break;
| }
| /* FALLTHROUGH */
| case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
| /* Soft reset here to sync the clocks */
| ret = dwc3_soft_reset(dwc);and right here we loose those bits :-)
| if (ret) | return ret; | | ret = dwc3_ulpi_init(dwc); | if (ret) | return ret; | /* FALLTHROUGH */ | default: | break; | } | | /* | * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to | * '0' during coreConsultant configuration. So default value will | * be '0' when the core is reset. Application needs to set it to | * '1' after the core initialization is completed. | */ | if (dwc->revision > DWC3_REVISION_194A) | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | | if (dwc->dis_u2_susphy_quirk) | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | | return 0; | }
Quoted 2 lines
know anything about those. If it is, then I would imagine we just need to soft reset here conditionally, only cores >= 1.94a, right?
That's wrong, how do you support older core with ULPI vs UTMI selection needs ?
Quoted 4 lines
With 1.94a and newer,
DWC3_GUSB3PIPECTL(0)andDWC3_GUSB2PHYCFG(0)keep their ctx over any kind of soft reset. And any configurations done to them here will take affect the latest whendwc3_core_soft_reset()is called.
/me goes read Databook again.
You're right. You're using the soft reset bit from DCTL, that only resets the device side, not any global register. There are two details which you don't appear to take care of, however.
According to Table 7-82 on Databook 2.93a (page 725), bit 30 CSFTRST, it's said that "Once this bit is cleared, the software must wait at least 3 PHY clocks before accessing the PHY domain". Futher down is states that "Once a new clock is selected, the PHY domain must be reset for proper operation".
So there you go, 2 details which should be taken care of :-)
cheers
Signature · 1 line
balbi
Heikki Krogerus
maintainerRe: [PATCHv3 10/12] usb: dwc3: add ULPI interface support
Hi Felipe,
Quoted 7 lines
Quoted 4 lines
With 1.94a and newer,
DWC3_GUSB3PIPECTL(0)andDWC3_GUSB2PHYCFG(0)keep their ctx over any kind of soft reset. And any configurations done to them here will take affect the latest whendwc3_core_soft_reset()is called./me goes read Databook again.
Quoted 7 lines
You're right. You're using the soft reset bit from DCTL, that only resets the device side, not any global register. There are two details which you don't appear to take care of, however.
According to Table 7-82 on Databook 2.93a (page 725), bit 30 CSFTRST, it's said that "Once this bit is cleared, the software must wait at least 3 PHY clocks before accessing the PHY domain".
Ok, I'll add a delay for that.
Quoted 3 lines
Futher down is
states that "Once a new clock is selected, the PHY domain must be reset for proper operation".
All PHYs will be reset once we call dwc3_core_soft_reset() and we do not need them to be operational before that, except in case of ULPI in order to register the interface. To make sure the ULPI interface and PHY are operational we call dwc3_soft_reset() which does everything needed for us. When we use DCTL.SoftRst the core will reset also the ULPI PHY (PHYSoftRst in DWC3_GUSB2PHYCFG(0) has no effect with ULPI).
So dwc3_phy_setup() configures the PHY interfaces but it does not initialize them or the PHYs. dwc3_core_soft_reset() continues to take care of that in any case, so there is no reason to duplicate it. I think we need to point this out in the description comment of dwc3_phy_setup().
Thanks,
Signature · 1 line
heikki
Re: [PATCHv3 10/12] usb: dwc3: add ULPI interface support
Quoted 31 lines · Heikki Krogerus
Hi Felipe,
Quoted 7 lines
Quoted 4 lines
With 1.94a and newer,
DWC3_GUSB3PIPECTL(0)andDWC3_GUSB2PHYCFG(0)keep their ctx over any kind of soft reset. And any configurations done to them here will take affect the latest whendwc3_core_soft_reset()is called./me goes read Databook again.
Quoted 7 lines
You're right. You're using the soft reset bit from DCTL, that only resets the device side, not any global register. There are two details which you don't appear to take care of, however.
According to Table 7-82 on Databook 2.93a (page 725), bit 30 CSFTRST, it's said that "Once this bit is cleared, the software must wait at least 3 PHY clocks before accessing the PHY domain".
Ok, I'll add a delay for that.
Quoted 3 lines
Futher down is
states that "Once a new clock is selected, the PHY domain must be reset for proper operation".All PHYs will be reset once we call
dwc3_core_soft_reset()and we do not need them to be operational before that, except in case of ULPI in order to register the interface. To make sure the ULPI interface and PHY are operational we calldwc3_soft_reset()which does everything needed for us. When we use DCTL.SoftRst the core will reset also the ULPI PHY (PHYSoftRst inDWC3_GUSB2PHYCFG(0)has no effect with ULPI).
Quoted 5 lines
So
dwc3_phy_setup()configures the PHY interfaces but it does not initialize them or the PHYs.dwc3_core_soft_reset()continues to take care of that in any case, so there is no reason to duplicate it. I think we need to point this out in the description comment ofdwc3_phy_setup().
sounds good to me :-)
Signature · 1 line
balbi
Heikki Krogerus
maintainerPATCH v3 11/12 phy: helpers for USB ULPI PHY registering
In reply to Heikki KrogerusULPI PHYs need to be bound to their controllers with a lookup. This adds helpers that the ULPI drivers can use to do both, the registration of the PHY and the lookup, at the same time.
--- drivers/phy/ulpi_phy.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 drivers/phy/ulpi_phy.h
drivers/phy/ulpi_phy.h new file +31 -0
@@ -0,0 +1,31 @@ +#include <linux/phy/phy.h> + +/** +* Helper that registers PHY for a ULPI device and adds a lookup for binding it +* and it's controller, which is always the parent. +*/ +static inline struct phy +*ulpi_phy_create (struct ulpi *ulpi,struct phy_ops *ops) +{ +struct phy *phy; +int ret; + + phy =phy_create (&ulpi->dev,NULL , ops); +if (IS_ERR (phy)) +return phy; + + ret =phy_create_lookup (phy,"usb2-phy" ,dev_name (ulpi->dev.parent)); +if (ret) { +phy_destroy (phy); +return ERR_PTR (ret); + } + +return phy; +} + +/* Remove a PHY that was created with ulpi_phy_create() and it's lookup. */ +static inline void ulpi_phy_destroy (struct ulpi *ulpi,struct phy *phy) +{ +phy_remove_lookup (phy,"usb2-phy" ,dev_name (ulpi->dev.parent)); +phy_destroy (phy); +}
Signature · 1 line
2.1.4
Heikki Krogerus
maintainerPATCH v3 12/12 phy: add driver for TI TUSB1210 ULPI PHY
In reply to Heikki KrogerusTUSB1210 ULPI PHY has vendor specific register for eye diagram tuning. On some platforms the system firmware has set optimized value to it. In order to not loose the optimized value, the driver stores it during probe and restores it every time the PHY is powered back on.
--- drivers/phy/Kconfig | 7 +++ drivers/phy/Makefile | 1 + drivers/phy/phy-tusb1210.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 drivers/phy/phy-tusb1210.c
drivers/phy/Kconfig +7 -0
@@ -309,4 +309,11 @@ config PHY_QCOM_UFS help Support for UFS PHY on QCOM chipsets. +config PHY_TUSB1210 + tristate "TI TUSB1210 ULPI PHY module" + depends on USB_ULPI_BUS + select GENERIC_PHY + help + Support for TI TUSB1210 USB ULPI PHY. + endmenu
drivers/phy/Makefile +1 -0
@@ -40,3 +40,4 @@ obj-$(CONFIG_PHY_STIH41X_USB) += phy-stih41x-usb.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-20nm.o obj-$(CONFIG_PHY_QCOM_UFS) += phy-qcom-ufs-qmp-14nm.o +obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
drivers/phy/phy-tusb1210.c new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.1.4