diff mbox series

[1/2] USB: EHCI: ehci-mv: switch the HSIC HCI to HSIC mode

Message ID 20200309130014.548168-1-lkundrak@v3.sk (mailing list archive)
State Mainlined
Commit 6351f1708b14a7181b33c54f47bc38da8f9dc316
Headers show
Series [1/2] USB: EHCI: ehci-mv: switch the HSIC HCI to HSIC mode | expand

Commit Message

Lubomir Rintel March 9, 2020, 1 p.m. UTC
Turns out the undocumented and reserved bits of port status/control
register of the root port need to be set to use the HCI in HSIC mode.

Typically the firmware does this, but that is not always good enough,
because the bits get lost if the HSIC clock is disabled (e.g. when
ehci-mv is build as a module).

This supplements commit 7b104f890ade ("USB: EHCI: ehci-mv: add HSIC
support").

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/usb/host/ehci-mv.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Alan Stern March 10, 2020, 2:03 p.m. UTC | #1
On Mon, 9 Mar 2020, Lubomir Rintel wrote:

> Turns out the undocumented and reserved bits of port status/control
> register of the root port need to be set to use the HCI in HSIC mode.
> 
> Typically the firmware does this, but that is not always good enough,
> because the bits get lost if the HSIC clock is disabled (e.g. when
> ehci-mv is build as a module).
> 
> This supplements commit 7b104f890ade ("USB: EHCI: ehci-mv: add HSIC
> support").
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Acked-by: Alan Stern <stern@rowland.harvard.edu>

> ---
>  drivers/usb/host/ehci-mv.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
> index bd4f6ef534d96..ddb668963955f 100644
> --- a/drivers/usb/host/ehci-mv.c
> +++ b/drivers/usb/host/ehci-mv.c
> @@ -110,6 +110,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	int retval = -ENODEV;
>  	u32 offset;
> +	u32 status;
>  
>  	if (usb_disabled())
>  		return -ENODEV;
> @@ -213,6 +214,14 @@ static int mv_ehci_probe(struct platform_device *pdev)
>  		device_wakeup_enable(hcd->self.controller);
>  	}
>  
> +	if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_HSIC) {
> +		status = ehci_readl(ehci, &ehci->regs->port_status[0]);
> +		/* These "reserved" bits actually enable HSIC mode. */
> +		status |= BIT(25);
> +		status &= ~GENMASK(31, 30);
> +		ehci_writel(ehci, status, &ehci->regs->port_status[0]);
> +	}
> +
>  	dev_info(&pdev->dev,
>  		 "successful find EHCI device with regs 0x%p irq %d"
>  		 " working in %s mode\n", hcd->regs, hcd->irq,
>
diff mbox series

Patch

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index bd4f6ef534d96..ddb668963955f 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -110,6 +110,7 @@  static int mv_ehci_probe(struct platform_device *pdev)
 	struct resource *r;
 	int retval = -ENODEV;
 	u32 offset;
+	u32 status;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -213,6 +214,14 @@  static int mv_ehci_probe(struct platform_device *pdev)
 		device_wakeup_enable(hcd->self.controller);
 	}
 
+	if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_HSIC) {
+		status = ehci_readl(ehci, &ehci->regs->port_status[0]);
+		/* These "reserved" bits actually enable HSIC mode. */
+		status |= BIT(25);
+		status &= ~GENMASK(31, 30);
+		ehci_writel(ehci, status, &ehci->regs->port_status[0]);
+	}
+
 	dev_info(&pdev->dev,
 		 "successful find EHCI device with regs 0x%p irq %d"
 		 " working in %s mode\n", hcd->regs, hcd->irq,