diff mbox

[U-Boot,v5,4/6] mvebu: usb: xhci: Add VBUS regulator supply to the host driver

Message ID 1486639930-22570-1-git-send-email-kostap@marvell.com
State Superseded
Delegated to: Stefan Roese
Headers show

Commit Message

Kostya Porotchkin Feb. 9, 2017, 11:32 a.m. UTC
From: Konstantin Porotchkin <kostap@marvell.com>

The USB device should linked to VBUS regulator through "vbus-supply"
DTS property.
This patch adds handling for "vbus-supply" property inside the USB
device entry for turning on the VBUS regulator upon the host adapter probe.

Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Nadav Haklai <nadavh@marvell.com>
Cc: Neta Zur Hershkovits <neta@marvell.com>
Cc: Igal Liberman <igall@marvell.com>
Cc: Haim Boot <hayim@marvell.com>
---
Changes for v5:
- Extended clocks description in documentation
- Removed print for regulator not found case

 doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
 drivers/usb/host/Kconfig                          |  1 +
 drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt

Comments

Marek Vasut Feb. 9, 2017, 1:37 p.m. UTC | #1
On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
> From: Konstantin Porotchkin <kostap@marvell.com>
> 
> The USB device should linked to VBUS regulator through "vbus-supply"
> DTS property.
> This patch adds handling for "vbus-supply" property inside the USB
> device entry for turning on the VBUS regulator upon the host adapter probe.
> 
> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Nadav Haklai <nadavh@marvell.com>
> Cc: Neta Zur Hershkovits <neta@marvell.com>
> Cc: Igal Liberman <igall@marvell.com>
> Cc: Haim Boot <hayim@marvell.com>
> ---
> Changes for v5:
> - Extended clocks description in documentation
> - Removed print for regulator not found case
> 
>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
>  drivers/usb/host/Kconfig                          |  1 +
>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>  3 files changed, 42 insertions(+), 1 deletion(-)
>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> 
> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> new file mode 100644
> index 0000000..6cc370c
> --- /dev/null
> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> @@ -0,0 +1,29 @@
> +Marvell SOC USB controllers
> +
> +This controller is integrated in Armada 3700/8K.
> +It uses the same properties as a generic XHCI host controller
> +
> +Required properties :
> + - compatible: should be one or more of:
> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
> + - reg: should contain address and length of the standard XHCI
> +   register set for the device.
> + - interrupts: one XHCI interrupt should be described here.
> +
> +Optional properties:
> + - clocks: reference to a platform clocks that should be enabled/configured
> +   upon interface initialization. May not exist on all platforms.

This is probably block clock then ?

Otherwise,
Acked-by: Marek Vasut <marex@denx.de>

> + - vbus-supply : If present, specifies the fixed regulator to be turned on
> +   for providing power to the USB VBUS rail.
> +
> +Example:
> +	cpm_usb3_0: usb3@500000 {
> +		compatible = "marvell,armada-8k-xhci",
> +			     "generic-xhci";
> +		reg = <0x500000 0x4000>;
> +		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
> +		clocks = <&cpm_syscon0 1 22>;
> +		vbus-supply = <&reg_usb3h0_vbus>;
> +		status = "disabled";
> +	};
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index 5129a57..0bf8274 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
>  	bool "MVEBU USB 3.0 support"
>  	default y
>  	depends on ARCH_MVEBU
> +	select DM_REGULATOR
>  	help
>  	  Choose this option to add support for USB 3.0 driver on mvebu
>  	  SoCs, which includes Armada8K, Armada3700 and other Armada
> diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
> index 46eb937..d880af1 100644
> --- a/drivers/usb/host/xhci-mvebu.c
> +++ b/drivers/usb/host/xhci-mvebu.c
> @@ -10,6 +10,7 @@
>  #include <dm.h>
>  #include <fdtdec.h>
>  #include <usb.h>
> +#include <power/regulator.h>
>  #include <asm/gpio.h>
>  
>  #include "xhci.h"
> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
>  	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
>  	struct mvebu_xhci *ctx = dev_get_priv(dev);
>  	struct xhci_hcor *hcor;
> -	int len;
> +	int len, ret;
> +	struct udevice *regulator;
>  
>  	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
>  	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
>  	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
>  
> +	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
> +	if (!ret) {
> +		ret = regulator_set_enable(regulator, true);
> +		if (ret) {
> +			printf("Failed to turn ON the VBUS regulator\n");
> +			return ret;
> +		}
> +	}
> +
>  	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
>  	board_xhci_enable();
>  
>
Kostya Porotchkin Feb. 9, 2017, 3:30 p.m. UTC | #2
On 02/09/2017 03:37 PM, Marek Vasut wrote:
> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>> From: Konstantin Porotchkin <kostap@marvell.com>
>>
>> The USB device should linked to VBUS regulator through "vbus-supply"
>> DTS property.
>> This patch adds handling for "vbus-supply" property inside the USB
>> device entry for turning on the VBUS regulator upon the host adapter probe.
>>
>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>> Cc: Stefan Roese <sr@denx.de>
>> Cc: Marek Vasut <marex@denx.de>
>> Cc: Nadav Haklai <nadavh@marvell.com>
>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>> Cc: Igal Liberman <igall@marvell.com>
>> Cc: Haim Boot <hayim@marvell.com>
>> ---
>> Changes for v5:
>> - Extended clocks description in documentation
>> - Removed print for regulator not found case
>>
>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29 +++++++++++++++++++++++
>>  drivers/usb/host/Kconfig                          |  1 +
>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>>  3 files changed, 42 insertions(+), 1 deletion(-)
>>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>
>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> new file mode 100644
>> index 0000000..6cc370c
>> --- /dev/null
>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> @@ -0,0 +1,29 @@
>> +Marvell SOC USB controllers
>> +
>> +This controller is integrated in Armada 3700/8K.
>> +It uses the same properties as a generic XHCI host controller
>> +
>> +Required properties :
>> + - compatible: should be one or more of:
>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>> + - reg: should contain address and length of the standard XHCI
>> +   register set for the device.
>> + - interrupts: one XHCI interrupt should be described here.
>> +
>> +Optional properties:
>> + - clocks: reference to a platform clocks that should be enabled/configured
>> +   upon interface initialization. May not exist on all platforms.
>
> This is probably block clock then ?
>
> Otherwise,
> Acked-by: Marek Vasut <marex@denx.de>
Otherwise the the internal SoC clock does not require gating/muxing or 
any other configuration for making this USB host adapter running.
Not sure if I understood your question well.
>
>> + - vbus-supply : If present, specifies the fixed regulator to be turned on
>> +   for providing power to the USB VBUS rail.
>> +
>> +Example:
>> +	cpm_usb3_0: usb3@500000 {
>> +		compatible = "marvell,armada-8k-xhci",
>> +			     "generic-xhci";
>> +		reg = <0x500000 0x4000>;
>> +		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
>> +		clocks = <&cpm_syscon0 1 22>;
>> +		vbus-supply = <&reg_usb3h0_vbus>;
>> +		status = "disabled";
>> +	};
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index 5129a57..0bf8274 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
>>  	bool "MVEBU USB 3.0 support"
>>  	default y
>>  	depends on ARCH_MVEBU
>> +	select DM_REGULATOR
>>  	help
>>  	  Choose this option to add support for USB 3.0 driver on mvebu
>>  	  SoCs, which includes Armada8K, Armada3700 and other Armada
>> diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
>> index 46eb937..d880af1 100644
>> --- a/drivers/usb/host/xhci-mvebu.c
>> +++ b/drivers/usb/host/xhci-mvebu.c
>> @@ -10,6 +10,7 @@
>>  #include <dm.h>
>>  #include <fdtdec.h>
>>  #include <usb.h>
>> +#include <power/regulator.h>
>>  #include <asm/gpio.h>
>>
>>  #include "xhci.h"
>> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
>>  	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
>>  	struct mvebu_xhci *ctx = dev_get_priv(dev);
>>  	struct xhci_hcor *hcor;
>> -	int len;
>> +	int len, ret;
>> +	struct udevice *regulator;
>>
>>  	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
>>  	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
>>  	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
>>
>> +	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
>> +	if (!ret) {
>> +		ret = regulator_set_enable(regulator, true);
>> +		if (ret) {
>> +			printf("Failed to turn ON the VBUS regulator\n");
>> +			return ret;
>> +		}
>> +	}
>> +
>>  	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
>>  	board_xhci_enable();
>>
>>
>
>
Marek Vasut Feb. 9, 2017, 3:36 p.m. UTC | #3
On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
> 
> 
> On 02/09/2017 03:37 PM, Marek Vasut wrote:
>> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>>> From: Konstantin Porotchkin <kostap@marvell.com>
>>>
>>> The USB device should linked to VBUS regulator through "vbus-supply"
>>> DTS property.
>>> This patch adds handling for "vbus-supply" property inside the USB
>>> device entry for turning on the VBUS regulator upon the host adapter
>>> probe.
>>>
>>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>>> Cc: Stefan Roese <sr@denx.de>
>>> Cc: Marek Vasut <marex@denx.de>
>>> Cc: Nadav Haklai <nadavh@marvell.com>
>>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>>> Cc: Igal Liberman <igall@marvell.com>
>>> Cc: Haim Boot <hayim@marvell.com>
>>> ---
>>> Changes for v5:
>>> - Extended clocks description in documentation
>>> - Removed print for regulator not found case
>>>
>>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
>>> +++++++++++++++++++++++
>>>  drivers/usb/host/Kconfig                          |  1 +
>>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>>>  3 files changed, 42 insertions(+), 1 deletion(-)
>>>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>
>>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>> new file mode 100644
>>> index 0000000..6cc370c
>>> --- /dev/null
>>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>> @@ -0,0 +1,29 @@
>>> +Marvell SOC USB controllers
>>> +
>>> +This controller is integrated in Armada 3700/8K.
>>> +It uses the same properties as a generic XHCI host controller
>>> +
>>> +Required properties :
>>> + - compatible: should be one or more of:
>>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
>>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>>> + - reg: should contain address and length of the standard XHCI
>>> +   register set for the device.
>>> + - interrupts: one XHCI interrupt should be described here.
>>> +
>>> +Optional properties:
>>> + - clocks: reference to a platform clocks that should be
>>> enabled/configured
>>> +   upon interface initialization. May not exist on all platforms.
>>
>> This is probably block clock then ?
>>
>> Otherwise,
>> Acked-by: Marek Vasut <marex@denx.de>
> Otherwise the the internal SoC clock does not require gating/muxing or
> any other configuration for making this USB host adapter running.
> Not sure if I understood your question well.

Well,  do these clock drive the USB block or do they drive the register
interface or what ?

>>> + - vbus-supply : If present, specifies the fixed regulator to be
>>> turned on
>>> +   for providing power to the USB VBUS rail.
>>> +
>>> +Example:
>>> +    cpm_usb3_0: usb3@500000 {
>>> +        compatible = "marvell,armada-8k-xhci",
>>> +                 "generic-xhci";
>>> +        reg = <0x500000 0x4000>;
>>> +        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
>>> +        clocks = <&cpm_syscon0 1 22>;
>>> +        vbus-supply = <&reg_usb3h0_vbus>;
>>> +        status = "disabled";
>>> +    };
>>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>>> index 5129a57..0bf8274 100644
>>> --- a/drivers/usb/host/Kconfig
>>> +++ b/drivers/usb/host/Kconfig
>>> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
>>>      bool "MVEBU USB 3.0 support"
>>>      default y
>>>      depends on ARCH_MVEBU
>>> +    select DM_REGULATOR
>>>      help
>>>        Choose this option to add support for USB 3.0 driver on mvebu
>>>        SoCs, which includes Armada8K, Armada3700 and other Armada
>>> diff --git a/drivers/usb/host/xhci-mvebu.c
>>> b/drivers/usb/host/xhci-mvebu.c
>>> index 46eb937..d880af1 100644
>>> --- a/drivers/usb/host/xhci-mvebu.c
>>> +++ b/drivers/usb/host/xhci-mvebu.c
>>> @@ -10,6 +10,7 @@
>>>  #include <dm.h>
>>>  #include <fdtdec.h>
>>>  #include <usb.h>
>>> +#include <power/regulator.h>
>>>  #include <asm/gpio.h>
>>>
>>>  #include "xhci.h"
>>> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
>>>      struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
>>>      struct mvebu_xhci *ctx = dev_get_priv(dev);
>>>      struct xhci_hcor *hcor;
>>> -    int len;
>>> +    int len, ret;
>>> +    struct udevice *regulator;
>>>
>>>      ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
>>>      len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
>>>      hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
>>>
>>> +    ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
>>> +    if (!ret) {
>>> +        ret = regulator_set_enable(regulator, true);
>>> +        if (ret) {
>>> +            printf("Failed to turn ON the VBUS regulator\n");
>>> +            return ret;
>>> +        }
>>> +    }
>>> +
>>>      /* Enable USB xHCI (VBUS, reset etc) in board specific code */
>>>      board_xhci_enable();
>>>
>>>
>>
>>
Kostya Porotchkin Feb. 9, 2017, 3:54 p.m. UTC | #4
On 02/09/2017 05:36 PM, Marek Vasut wrote:
> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
> >
> >
> > On 02/09/2017 03:37 PM, Marek Vasut wrote:
> >> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
> >>> From: Konstantin Porotchkin <kostap@marvell.com>
> >>>
> >>> The USB device should linked to VBUS regulator through "vbus-supply"
> >>> DTS property.
> >>> This patch adds handling for "vbus-supply" property inside the USB
> >>> device entry for turning on the VBUS regulator upon the host adapter
> >>> probe.
> >>>
> >>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
> >>> Cc: Stefan Roese <sr@denx.de>
> >>> Cc: Marek Vasut <marex@denx.de>
> >>> Cc: Nadav Haklai <nadavh@marvell.com>
> >>> Cc: Neta Zur Hershkovits <neta@marvell.com>
> >>> Cc: Igal Liberman <igall@marvell.com>
> >>> Cc: Haim Boot <hayim@marvell.com>
> >>> ---
> >>> Changes for v5:
> >>> - Extended clocks description in documentation
> >>> - Removed print for regulator not found case
> >>>
> >>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
> >>> +++++++++++++++++++++++
> >>>  drivers/usb/host/Kconfig                          |  1 +
> >>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
> >>>  3 files changed, 42 insertions(+), 1 deletion(-)
> >>>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>>
> >>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>> new file mode 100644
> >>> index 0000000..6cc370c
> >>> --- /dev/null
> >>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>> @@ -0,0 +1,29 @@
> >>> +Marvell SOC USB controllers
> >>> +
> >>> +This controller is integrated in Armada 3700/8K.
> >>> +It uses the same properties as a generic XHCI host controller
> >>> +
> >>> +Required properties :
> >>> + - compatible: should be one or more of:
> >>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
> >>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
> >>> + - reg: should contain address and length of the standard XHCI
> >>> +   register set for the device.
> >>> + - interrupts: one XHCI interrupt should be described here.
> >>> +
> >>> +Optional properties:
> >>> + - clocks: reference to a platform clocks that should be
> >>> enabled/configured
> >>> +   upon interface initialization. May not exist on all platforms.
> >>
> >> This is probably block clock then ?
> >>
> >> Otherwise,
> >> Acked-by: Marek Vasut <marex@denx.de>
> > Otherwise the the internal SoC clock does not require gating/muxing or
> > any other configuration for making this USB host adapter running.
> > Not sure if I understood your question well.
>
> Well,  do these clock drive the USB block or do they drive the register
> interface or what ?
This entry is generic and applicable to all XHCI controllers, so it is hard to answer your question.  It supposes to be a clock that drives the data transfer. It can be directly connected to the internal clock generator and divider or pass though an additional gate/mux. In the last case it can be inhibited or redirected.
>
> >>> + - vbus-supply : If present, specifies the fixed regulator to be
> >>> turned on
> >>> +   for providing power to the USB VBUS rail.
> >>> +
> >>> +Example:
> >>> +    cpm_usb3_0: usb3@500000 {
> >>> +        compatible = "marvell,armada-8k-xhci",
> >>> +                 "generic-xhci";
> >>> +        reg = <0x500000 0x4000>;
> >>> +        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
> >>> +        clocks = <&cpm_syscon0 1 22>;
> >>> +        vbus-supply = <&reg_usb3h0_vbus>;
> >>> +        status = "disabled";
> >>> +    };
> >>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> >>> index 5129a57..0bf8274 100644
> >>> --- a/drivers/usb/host/Kconfig
> >>> +++ b/drivers/usb/host/Kconfig
> >>> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
> >>>      bool "MVEBU USB 3.0 support"
> >>>      default y
> >>>      depends on ARCH_MVEBU
> >>> +    select DM_REGULATOR
> >>>      help
> >>>        Choose this option to add support for USB 3.0 driver on mvebu
> >>>        SoCs, which includes Armada8K, Armada3700 and other Armada
> >>> diff --git a/drivers/usb/host/xhci-mvebu.c
> >>> b/drivers/usb/host/xhci-mvebu.c
> >>> index 46eb937..d880af1 100644
> >>> --- a/drivers/usb/host/xhci-mvebu.c
> >>> +++ b/drivers/usb/host/xhci-mvebu.c
> >>> @@ -10,6 +10,7 @@
> >>>  #include <dm.h>
> >>>  #include <fdtdec.h>
> >>>  #include <usb.h>
> >>> +#include <power/regulator.h>
> >>>  #include <asm/gpio.h>
> >>>
> >>>  #include "xhci.h"
> >>> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
> >>>      struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
> >>>      struct mvebu_xhci *ctx = dev_get_priv(dev);
> >>>      struct xhci_hcor *hcor;
> >>> -    int len;
> >>> +    int len, ret;
> >>> +    struct udevice *regulator;
> >>>
> >>>      ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
> >>>      len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
> >>>      hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
> >>>
> >>> +    ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
> >>> +    if (!ret) {
> >>> +        ret = regulator_set_enable(regulator, true);
> >>> +        if (ret) {
> >>> +            printf("Failed to turn ON the VBUS regulator\n");
> >>> +            return ret;
> >>> +        }
> >>> +    }
> >>> +
> >>>      /* Enable USB xHCI (VBUS, reset etc) in board specific code */
> >>>      board_xhci_enable();
> >>>
> >>>
> >>
> >>
>
>
Marek Vasut Feb. 9, 2017, 4:15 p.m. UTC | #5
On 02/09/2017 04:54 PM, Konstantin Porotchkin wrote:
> 
> On 02/09/2017 05:36 PM, Marek Vasut wrote:
>> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
>> >
>> >
>> > On 02/09/2017 03:37 PM, Marek Vasut wrote:
>> >> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>> >>> From: Konstantin Porotchkin <kostap@marvell.com>
>> >>>
>> >>> The USB device should linked to VBUS regulator through "vbus-supply"
>> >>> DTS property.
>> >>> This patch adds handling for "vbus-supply" property inside the USB
>> >>> device entry for turning on the VBUS regulator upon the host adapter
>> >>> probe.
>> >>>
>> >>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>> >>> Cc: Stefan Roese <sr@denx.de>
>> >>> Cc: Marek Vasut <marex@denx.de>
>> >>> Cc: Nadav Haklai <nadavh@marvell.com>
>> >>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>> >>> Cc: Igal Liberman <igall@marvell.com>
>> >>> Cc: Haim Boot <hayim@marvell.com>
>> >>> ---
>> >>> Changes for v5:
>> >>> - Extended clocks description in documentation
>> >>> - Removed print for regulator not found case
>> >>>
>> >>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
>> >>> +++++++++++++++++++++++
>> >>>  drivers/usb/host/Kconfig                          |  1 +
>> >>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>> >>>  3 files changed, 42 insertions(+), 1 deletion(-)
>> >>>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>>
>> >>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>> new file mode 100644
>> >>> index 0000000..6cc370c
>> >>> --- /dev/null
>> >>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>> @@ -0,0 +1,29 @@
>> >>> +Marvell SOC USB controllers
>> >>> +
>> >>> +This controller is integrated in Armada 3700/8K.
>> >>> +It uses the same properties as a generic XHCI host controller
>> >>> +
>> >>> +Required properties :
>> >>> + - compatible: should be one or more of:
>> >>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
>> >>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>> >>> + - reg: should contain address and length of the standard XHCI
>> >>> +   register set for the device.
>> >>> + - interrupts: one XHCI interrupt should be described here.
>> >>> +
>> >>> +Optional properties:
>> >>> + - clocks: reference to a platform clocks that should be
>> >>> enabled/configured
>> >>> +   upon interface initialization. May not exist on all platforms.
>> >>
>> >> This is probably block clock then ?
>> >>
>> >> Otherwise,
>> >> Acked-by: Marek Vasut <marex@denx.de>
>> > Otherwise the the internal SoC clock does not require gating/muxing or
>> > any other configuration for making this USB host adapter running.
>> > Not sure if I understood your question well.
>>
>> Well,  do these clock drive the USB block or do they drive the register
>> interface or what ?
> This entry is generic and applicable to all XHCI controllers, so it is
> hard to answer your question.  It supposes to be a clock that drives the
> data transfer. It can be directly connected to the internal clock
> generator and divider or pass though an additional gate/mux. In the last
> case it can be inhibited or redirected.

So it's a PHY clock then ? Or XHCI block clock ?

marvell.xhci-usb.txt probably doesn't contain generic stuff, but marvell
XHCI implementation specific stuff, right ?

>> >>> + - vbus-supply : If present, specifies the fixed regulator to be
>> >>> turned on
>> >>> +   for providing power to the USB VBUS rail.
>> >>> +
>> >>> +Example:
>> >>> +    cpm_usb3_0: usb3@500000 {
>> >>> +        compatible = "marvell,armada-8k-xhci",
>> >>> +                 "generic-xhci";
>> >>> +        reg = <0x500000 0x4000>;
>> >>> +        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
>> >>> +        clocks = <&cpm_syscon0 1 22>;
>> >>> +        vbus-supply = <&reg_usb3h0_vbus>;
>> >>> +        status = "disabled";
>> >>> +    };
>> >>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> >>> index 5129a57..0bf8274 100644
>> >>> --- a/drivers/usb/host/Kconfig
>> >>> +++ b/drivers/usb/host/Kconfig
>> >>> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
>> >>>      bool "MVEBU USB 3.0 support"
>> >>>      default y
>> >>>      depends on ARCH_MVEBU
>> >>> +    select DM_REGULATOR
>> >>>      help
>> >>>        Choose this option to add support for USB 3.0 driver on mvebu
>> >>>        SoCs, which includes Armada8K, Armada3700 and other Armada
>> >>> diff --git a/drivers/usb/host/xhci-mvebu.c
>> >>> b/drivers/usb/host/xhci-mvebu.c
>> >>> index 46eb937..d880af1 100644
>> >>> --- a/drivers/usb/host/xhci-mvebu.c
>> >>> +++ b/drivers/usb/host/xhci-mvebu.c
>> >>> @@ -10,6 +10,7 @@
>> >>>  #include <dm.h>
>> >>>  #include <fdtdec.h>
>> >>>  #include <usb.h>
>> >>> +#include <power/regulator.h>
>> >>>  #include <asm/gpio.h>
>> >>>
>> >>>  #include "xhci.h"
>> >>> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
>> >>>      struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
>> >>>      struct mvebu_xhci *ctx = dev_get_priv(dev);
>> >>>      struct xhci_hcor *hcor;
>> >>> -    int len;
>> >>> +    int len, ret;
>> >>> +    struct udevice *regulator;
>> >>>
>> >>>      ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
>> >>>      len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
>> >>>      hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
>> >>>
>> >>> +    ret = device_get_supply_regulator(dev, "vbus-supply",
>> &regulator);
>> >>> +    if (!ret) {
>> >>> +        ret = regulator_set_enable(regulator, true);
>> >>> +        if (ret) {
>> >>> +            printf("Failed to turn ON the VBUS regulator\n");
>> >>> +            return ret;
>> >>> +        }
>> >>> +    }
>> >>> +
>> >>>      /* Enable USB xHCI (VBUS, reset etc) in board specific code */
>> >>>      board_xhci_enable();
>> >>>
>> >>>
>> >>
>> >>
>>
>>
>
Kostya Porotchkin Feb. 9, 2017, 4:43 p.m. UTC | #6
On 02/09/2017 06:15 PM, Marek Vasut wrote:
> On 02/09/2017 04:54 PM, Konstantin Porotchkin wrote:
> >
> > On 02/09/2017 05:36 PM, Marek Vasut wrote:
> >> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
> >>>
> >>>
> >>> On 02/09/2017 03:37 PM, Marek Vasut wrote:
> >>>> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
> >>>>> From: Konstantin Porotchkin <kostap@marvell.com>
> >>>>>
> >>>>> The USB device should linked to VBUS regulator through "vbus-supply"
> >>>>> DTS property.
> >>>>> This patch adds handling for "vbus-supply" property inside the USB
> >>>>> device entry for turning on the VBUS regulator upon the host adapter
> >>>>> probe.
> >>>>>
> >>>>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
> >>>>> Cc: Stefan Roese <sr@denx.de>
> >>>>> Cc: Marek Vasut <marex@denx.de>
> >>>>> Cc: Nadav Haklai <nadavh@marvell.com>
> >>>>> Cc: Neta Zur Hershkovits <neta@marvell.com>
> >>>>> Cc: Igal Liberman <igall@marvell.com>
> >>>>> Cc: Haim Boot <hayim@marvell.com>
> >>>>> ---
> >>>>> Changes for v5:
> >>>>> - Extended clocks description in documentation
> >>>>> - Removed print for regulator not found case
> >>>>>
> >>>>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
> >>>>> +++++++++++++++++++++++
> >>>>>  drivers/usb/host/Kconfig                          |  1 +
> >>>>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
> >>>>>  3 files changed, 42 insertions(+), 1 deletion(-)
> >>>>>  create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>>>>
> >>>>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>>>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>>>> new file mode 100644
> >>>>> index 0000000..6cc370c
> >>>>> --- /dev/null
> >>>>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
> >>>>> @@ -0,0 +1,29 @@
> >>>>> +Marvell SOC USB controllers
> >>>>> +
> >>>>> +This controller is integrated in Armada 3700/8K.
> >>>>> +It uses the same properties as a generic XHCI host controller
> >>>>> +
> >>>>> +Required properties :
> >>>>> + - compatible: should be one or more of:
> >>>>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
> >>>>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
> >>>>> + - reg: should contain address and length of the standard XHCI
> >>>>> +   register set for the device.
> >>>>> + - interrupts: one XHCI interrupt should be described here.
> >>>>> +
> >>>>> +Optional properties:
> >>>>> + - clocks: reference to a platform clocks that should be
> >>>>> enabled/configured
> >>>>> +   upon interface initialization. May not exist on all platforms.
> >>>>
> >>>> This is probably block clock then ?
> >>>>
> >>>> Otherwise,
> >>>> Acked-by: Marek Vasut <marex@denx.de>
> >>> Otherwise the the internal SoC clock does not require gating/muxing or
> >>> any other configuration for making this USB host adapter running.
> >>> Not sure if I understood your question well.
> >>
> >> Well,  do these clock drive the USB block or do they drive the register
> >> interface or what ?
> > This entry is generic and applicable to all XHCI controllers, so it is
> > hard to answer your question.  It supposes to be a clock that drives the
> > data transfer. It can be directly connected to the internal clock
> > generator and divider or pass though an additional gate/mux. In the last
> > case it can be inhibited or redirected.
>
> So it's a PHY clock then ? Or XHCI block clock ?
>
> marvell.xhci-usb.txt probably doesn't contain generic stuff, but marvell
> XHCI implementation specific stuff, right ?
No, in this particular case this entry is generic. That is why I proposed to remove it in the past.
For the purpose of mvebu XHCI driver this entry is not required.
In general and in Marvell case particularly, every unit is driven by some kind of internal clock.
>
> >>>>> + - vbus-supply : If present, specifies the fixed regulator to be
> >>>>> turned on
> >>>>> +   for providing power to the USB VBUS rail.
> >>>>> +
> >>>>> +Example:
> >>>>> +    cpm_usb3_0: usb3@500000 {
> >>>>> +        compatible = "marvell,armada-8k-xhci",
> >>>>> +                 "generic-xhci";
> >>>>> +        reg = <0x500000 0x4000>;
> >>>>> +        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
> >>>>> +        clocks = <&cpm_syscon0 1 22>;
> >>>>> +        vbus-supply = <&reg_usb3h0_vbus>;
> >>>>> +        status = "disabled";
> >>>>> +    };
> >>>>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> >>>>> index 5129a57..0bf8274 100644
> >>>>> --- a/drivers/usb/host/Kconfig
> >>>>> +++ b/drivers/usb/host/Kconfig
> >>>>> @@ -25,6 +25,7 @@ config USB_XHCI_MVEBU
> >>>>>      bool "MVEBU USB 3.0 support"
> >>>>>      default y
> >>>>>      depends on ARCH_MVEBU
> >>>>> +    select DM_REGULATOR
> >>>>>      help
> >>>>>        Choose this option to add support for USB 3.0 driver on mvebu
> >>>>>        SoCs, which includes Armada8K, Armada3700 and other Armada
> >>>>> diff --git a/drivers/usb/host/xhci-mvebu.c
> >>>>> b/drivers/usb/host/xhci-mvebu.c
> >>>>> index 46eb937..d880af1 100644
> >>>>> --- a/drivers/usb/host/xhci-mvebu.c
> >>>>> +++ b/drivers/usb/host/xhci-mvebu.c
> >>>>> @@ -10,6 +10,7 @@
> >>>>>  #include <dm.h>
> >>>>>  #include <fdtdec.h>
> >>>>>  #include <usb.h>
> >>>>> +#include <power/regulator.h>
> >>>>>  #include <asm/gpio.h>
> >>>>>
> >>>>>  #include "xhci.h"
> >>>>> @@ -44,12 +45,22 @@ static int xhci_usb_probe(struct udevice *dev)
> >>>>>      struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
> >>>>>      struct mvebu_xhci *ctx = dev_get_priv(dev);
> >>>>>      struct xhci_hcor *hcor;
> >>>>> -    int len;
> >>>>> +    int len, ret;
> >>>>> +    struct udevice *regulator;
> >>>>>
> >>>>>      ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
> >>>>>      len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
> >>>>>      hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
> >>>>>
> >>>>> +    ret = device_get_supply_regulator(dev, "vbus-supply",
> >> &regulator);
> >>>>> +    if (!ret) {
> >>>>> +        ret = regulator_set_enable(regulator, true);
> >>>>> +        if (ret) {
> >>>>> +            printf("Failed to turn ON the VBUS regulator\n");
> >>>>> +            return ret;
> >>>>> +        }
> >>>>> +    }
> >>>>> +
> >>>>>      /* Enable USB xHCI (VBUS, reset etc) in board specific code */
> >>>>>      board_xhci_enable();
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>
> >>
> >
>
>
Marek Vasut Feb. 9, 2017, 5:24 p.m. UTC | #7
On 02/09/2017 05:43 PM, Konstantin Porotchkin wrote:
> 
> On 02/09/2017 06:15 PM, Marek Vasut wrote:
>> On 02/09/2017 04:54 PM, Konstantin Porotchkin wrote:
>> >
>> > On 02/09/2017 05:36 PM, Marek Vasut wrote:
>> >> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
>> >>>
>> >>>
>> >>> On 02/09/2017 03:37 PM, Marek Vasut wrote:
>> >>>> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>> >>>>> From: Konstantin Porotchkin <kostap@marvell.com>
>> >>>>>
>> >>>>> The USB device should linked to VBUS regulator through
>> "vbus-supply"
>> >>>>> DTS property.
>> >>>>> This patch adds handling for "vbus-supply" property inside the USB
>> >>>>> device entry for turning on the VBUS regulator upon the host
>> adapter
>> >>>>> probe.
>> >>>>>
>> >>>>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>> >>>>> Cc: Stefan Roese <sr@denx.de>
>> >>>>> Cc: Marek Vasut <marex@denx.de>
>> >>>>> Cc: Nadav Haklai <nadavh@marvell.com>
>> >>>>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>> >>>>> Cc: Igal Liberman <igall@marvell.com>
>> >>>>> Cc: Haim Boot <hayim@marvell.com>
>> >>>>> ---
>> >>>>> Changes for v5:
>> >>>>> - Extended clocks description in documentation
>> >>>>> - Removed print for regulator not found case
>> >>>>>
>> >>>>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
>> >>>>> +++++++++++++++++++++++
>> >>>>>  drivers/usb/host/Kconfig                          |  1 +
>> >>>>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>> >>>>>  3 files changed, 42 insertions(+), 1 deletion(-)
>> >>>>>  create mode 100644
>> doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>>>>
>> >>>>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>>>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>>>> new file mode 100644
>> >>>>> index 0000000..6cc370c
>> >>>>> --- /dev/null
>> >>>>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>> >>>>> @@ -0,0 +1,29 @@
>> >>>>> +Marvell SOC USB controllers
>> >>>>> +
>> >>>>> +This controller is integrated in Armada 3700/8K.
>> >>>>> +It uses the same properties as a generic XHCI host controller
>> >>>>> +
>> >>>>> +Required properties :
>> >>>>> + - compatible: should be one or more of:
>> >>>>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx
>> SoCs
>> >>>>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>> >>>>> + - reg: should contain address and length of the standard XHCI
>> >>>>> +   register set for the device.
>> >>>>> + - interrupts: one XHCI interrupt should be described here.
>> >>>>> +
>> >>>>> +Optional properties:
>> >>>>> + - clocks: reference to a platform clocks that should be
>> >>>>> enabled/configured
>> >>>>> +   upon interface initialization. May not exist on all platforms.
>> >>>>
>> >>>> This is probably block clock then ?
>> >>>>
>> >>>> Otherwise,
>> >>>> Acked-by: Marek Vasut <marex@denx.de>
>> >>> Otherwise the the internal SoC clock does not require
>> gating/muxing or
>> >>> any other configuration for making this USB host adapter running.
>> >>> Not sure if I understood your question well.
>> >>
>> >> Well,  do these clock drive the USB block or do they drive the
>> register
>> >> interface or what ?
>> > This entry is generic and applicable to all XHCI controllers, so it is
>> > hard to answer your question.  It supposes to be a clock that drives
>> the
>> > data transfer. It can be directly connected to the internal clock
>> > generator and divider or pass though an additional gate/mux. In the
>> last
>> > case it can be inhibited or redirected.
>>
>> So it's a PHY clock then ? Or XHCI block clock ?
>>
>> marvell.xhci-usb.txt probably doesn't contain generic stuff, but marvell
>> XHCI implementation specific stuff, right ?
> No, in this particular case this entry is generic. That is why I
> proposed to remove it in the past.
> For the purpose of mvebu XHCI driver this entry is not required.
> In general and in Marvell case particularly, every unit is driven by
> some kind of internal clock.

And those internal clock can never ever be gated ? That's some odd
design, I would not expect that on an advanced ARM chip ... I guess
marvell is not power conscious ? :) The example contradicts what you
just said though, it points into some clock module ...
Konstantin Porotchkin Feb. 9, 2017, 7:06 p.m. UTC | #8
On 02/09/2017 07:24 PM, Marek Vasut wrote:
> On 02/09/2017 05:43 PM, Konstantin Porotchkin wrote:
>>
>> On 02/09/2017 06:15 PM, Marek Vasut wrote:
>>> On 02/09/2017 04:54 PM, Konstantin Porotchkin wrote:
>>>>
>>>> On 02/09/2017 05:36 PM, Marek Vasut wrote:
>>>>> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
>>>>>>
>>>>>>
>>>>>> On 02/09/2017 03:37 PM, Marek Vasut wrote:
>>>>>>> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>>>>>>>> From: Konstantin Porotchkin <kostap@marvell.com>
>>>>>>>>
>>>>>>>> The USB device should linked to VBUS regulator through
>>> "vbus-supply"
>>>>>>>> DTS property.
>>>>>>>> This patch adds handling for "vbus-supply" property inside the USB
>>>>>>>> device entry for turning on the VBUS regulator upon the host
>>> adapter
>>>>>>>> probe.
>>>>>>>>
>>>>>>>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>>>>>>>> Cc: Stefan Roese <sr@denx.de>
>>>>>>>> Cc: Marek Vasut <marex@denx.de>
>>>>>>>> Cc: Nadav Haklai <nadavh@marvell.com>
>>>>>>>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>>>>>>>> Cc: Igal Liberman <igall@marvell.com>
>>>>>>>> Cc: Haim Boot <hayim@marvell.com>
>>>>>>>> ---
>>>>>>>> Changes for v5:
>>>>>>>> - Extended clocks description in documentation
>>>>>>>> - Removed print for regulator not found case
>>>>>>>>
>>>>>>>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
>>>>>>>> +++++++++++++++++++++++
>>>>>>>>  drivers/usb/host/Kconfig                          |  1 +
>>>>>>>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>>>>>>>>  3 files changed, 42 insertions(+), 1 deletion(-)
>>>>>>>>  create mode 100644
>>> doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>>
>>>>>>>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>> new file mode 100644
>>>>>>>> index 0000000..6cc370c
>>>>>>>> --- /dev/null
>>>>>>>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>> @@ -0,0 +1,29 @@
>>>>>>>> +Marvell SOC USB controllers
>>>>>>>> +
>>>>>>>> +This controller is integrated in Armada 3700/8K.
>>>>>>>> +It uses the same properties as a generic XHCI host controller
>>>>>>>> +
>>>>>>>> +Required properties :
>>>>>>>> + - compatible: should be one or more of:
>>>>>>>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx
>>> SoCs
>>>>>>>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>>>>>>>> + - reg: should contain address and length of the standard XHCI
>>>>>>>> +   register set for the device.
>>>>>>>> + - interrupts: one XHCI interrupt should be described here.
>>>>>>>> +
>>>>>>>> +Optional properties:
>>>>>>>> + - clocks: reference to a platform clocks that should be
>>>>>>>> enabled/configured
>>>>>>>> +   upon interface initialization. May not exist on all platforms.
>>>>>>>
>>>>>>> This is probably block clock then ?
>>>>>>>
>>>>>>> Otherwise,
>>>>>>> Acked-by: Marek Vasut <marex@denx.de>
>>>>>> Otherwise the the internal SoC clock does not require
>>> gating/muxing or
>>>>>> any other configuration for making this USB host adapter running.
>>>>>> Not sure if I understood your question well.
>>>>>
>>>>> Well,  do these clock drive the USB block or do they drive the
>>> register
>>>>> interface or what ?
>>>> This entry is generic and applicable to all XHCI controllers, so it is
>>>> hard to answer your question.  It supposes to be a clock that drives
>>> the
>>>> data transfer. It can be directly connected to the internal clock
>>>> generator and divider or pass though an additional gate/mux. In the
>>> last
>>>> case it can be inhibited or redirected.
>>>
>>> So it's a PHY clock then ? Or XHCI block clock ?
>>>
>>> marvell.xhci-usb.txt probably doesn't contain generic stuff, but marvell
>>> XHCI implementation specific stuff, right ?
>> No, in this particular case this entry is generic. That is why I
>> proposed to remove it in the past.
>> For the purpose of mvebu XHCI driver this entry is not required.
>> In general and in Marvell case particularly, every unit is driven by
>> some kind of internal clock.
>
> And those internal clock can never ever be gated ? That's some odd
> design, I would not expect that on an advanced ARM chip ... I guess
> marvell is not power conscious ? :) The example contradicts what you
> just said though, it points into some clock module ...
Yes, it can be gated. It is a gated clock coming from system controller.
This XHCI driver supports two different SoC families, so the real clock 
names may vary.
Please help me to understand what is missing in this description?
Should I add "this clock is a gated unit clock driven by system 
controller" to th description?
Should I drop this description file and submit it in a separate patch?
>
>
Marek Vasut Feb. 9, 2017, 7:13 p.m. UTC | #9
On 02/09/2017 08:06 PM, Konstantin Porotchkin wrote:
> 
> 
> On 02/09/2017 07:24 PM, Marek Vasut wrote:
>> On 02/09/2017 05:43 PM, Konstantin Porotchkin wrote:
>>>
>>> On 02/09/2017 06:15 PM, Marek Vasut wrote:
>>>> On 02/09/2017 04:54 PM, Konstantin Porotchkin wrote:
>>>>>
>>>>> On 02/09/2017 05:36 PM, Marek Vasut wrote:
>>>>>> On 02/09/2017 04:30 PM, Konstantin Porotchkin wrote:
>>>>>>>
>>>>>>>
>>>>>>> On 02/09/2017 03:37 PM, Marek Vasut wrote:
>>>>>>>> On 02/09/2017 12:32 PM, kostap@marvell.com wrote:
>>>>>>>>> From: Konstantin Porotchkin <kostap@marvell.com>
>>>>>>>>>
>>>>>>>>> The USB device should linked to VBUS regulator through
>>>> "vbus-supply"
>>>>>>>>> DTS property.
>>>>>>>>> This patch adds handling for "vbus-supply" property inside the USB
>>>>>>>>> device entry for turning on the VBUS regulator upon the host
>>>> adapter
>>>>>>>>> probe.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
>>>>>>>>> Cc: Stefan Roese <sr@denx.de>
>>>>>>>>> Cc: Marek Vasut <marex@denx.de>
>>>>>>>>> Cc: Nadav Haklai <nadavh@marvell.com>
>>>>>>>>> Cc: Neta Zur Hershkovits <neta@marvell.com>
>>>>>>>>> Cc: Igal Liberman <igall@marvell.com>
>>>>>>>>> Cc: Haim Boot <hayim@marvell.com>
>>>>>>>>> ---
>>>>>>>>> Changes for v5:
>>>>>>>>> - Extended clocks description in documentation
>>>>>>>>> - Removed print for regulator not found case
>>>>>>>>>
>>>>>>>>>  doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 29
>>>>>>>>> +++++++++++++++++++++++
>>>>>>>>>  drivers/usb/host/Kconfig                          |  1 +
>>>>>>>>>  drivers/usb/host/xhci-mvebu.c                     | 13 +++++++++-
>>>>>>>>>  3 files changed, 42 insertions(+), 1 deletion(-)
>>>>>>>>>  create mode 100644
>>>> doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>>>
>>>>>>>>> diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>>> b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>>> new file mode 100644
>>>>>>>>> index 0000000..6cc370c
>>>>>>>>> --- /dev/null
>>>>>>>>> +++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
>>>>>>>>> @@ -0,0 +1,29 @@
>>>>>>>>> +Marvell SOC USB controllers
>>>>>>>>> +
>>>>>>>>> +This controller is integrated in Armada 3700/8K.
>>>>>>>>> +It uses the same properties as a generic XHCI host controller
>>>>>>>>> +
>>>>>>>>> +Required properties :
>>>>>>>>> + - compatible: should be one or more of:
>>>>>>>>> +   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx
>>>> SoCs
>>>>>>>>> +   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
>>>>>>>>> + - reg: should contain address and length of the standard XHCI
>>>>>>>>> +   register set for the device.
>>>>>>>>> + - interrupts: one XHCI interrupt should be described here.
>>>>>>>>> +
>>>>>>>>> +Optional properties:
>>>>>>>>> + - clocks: reference to a platform clocks that should be
>>>>>>>>> enabled/configured
>>>>>>>>> +   upon interface initialization. May not exist on all platforms.
>>>>>>>>
>>>>>>>> This is probably block clock then ?
>>>>>>>>
>>>>>>>> Otherwise,
>>>>>>>> Acked-by: Marek Vasut <marex@denx.de>
>>>>>>> Otherwise the the internal SoC clock does not require
>>>> gating/muxing or
>>>>>>> any other configuration for making this USB host adapter running.
>>>>>>> Not sure if I understood your question well.
>>>>>>
>>>>>> Well,  do these clock drive the USB block or do they drive the
>>>> register
>>>>>> interface or what ?
>>>>> This entry is generic and applicable to all XHCI controllers, so it is
>>>>> hard to answer your question.  It supposes to be a clock that drives
>>>> the
>>>>> data transfer. It can be directly connected to the internal clock
>>>>> generator and divider or pass though an additional gate/mux. In the
>>>> last
>>>>> case it can be inhibited or redirected.
>>>>
>>>> So it's a PHY clock then ? Or XHCI block clock ?
>>>>
>>>> marvell.xhci-usb.txt probably doesn't contain generic stuff, but
>>>> marvell
>>>> XHCI implementation specific stuff, right ?
>>> No, in this particular case this entry is generic. That is why I
>>> proposed to remove it in the past.
>>> For the purpose of mvebu XHCI driver this entry is not required.
>>> In general and in Marvell case particularly, every unit is driven by
>>> some kind of internal clock.
>>
>> And those internal clock can never ever be gated ? That's some odd
>> design, I would not expect that on an advanced ARM chip ... I guess
>> marvell is not power conscious ? :) The example contradicts what you
>> just said though, it points into some clock module ...
> Yes, it can be gated. It is a gated clock coming from system controller.
> This XHCI driver supports two different SoC families, so the real clock
> names may vary.
> Please help me to understand what is missing in this description?
> Should I add "this clock is a gated unit clock driven by system
> controller" to th description?
> Should I drop this description file and submit it in a separate patch?

Something like "phandle to system controller clock for this block" would
do then, or something ...
diff mbox

Patch

diff --git a/doc/device-tree-bindings/usb/marvell.xhci-usb.txt b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
new file mode 100644
index 0000000..6cc370c
--- /dev/null
+++ b/doc/device-tree-bindings/usb/marvell.xhci-usb.txt
@@ -0,0 +1,29 @@ 
+Marvell SOC USB controllers
+
+This controller is integrated in Armada 3700/8K.
+It uses the same properties as a generic XHCI host controller
+
+Required properties :
+ - compatible: should be one or more of:
+   - "marvell,armada3700-xhci", "generic-xhci" for Armada 37xx SoCs
+   - "marvell,armada-8k-xhci", "generic-xhci" for Armada A8K SoCs
+ - reg: should contain address and length of the standard XHCI
+   register set for the device.
+ - interrupts: one XHCI interrupt should be described here.
+
+Optional properties:
+ - clocks: reference to a platform clocks that should be enabled/configured
+   upon interface initialization. May not exist on all platforms.
+ - vbus-supply : If present, specifies the fixed regulator to be turned on
+   for providing power to the USB VBUS rail.
+
+Example:
+	cpm_usb3_0: usb3@500000 {
+		compatible = "marvell,armada-8k-xhci",
+			     "generic-xhci";
+		reg = <0x500000 0x4000>;
+		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cpm_syscon0 1 22>;
+		vbus-supply = <&reg_usb3h0_vbus>;
+		status = "disabled";
+	};
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 5129a57..0bf8274 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -25,6 +25,7 @@  config USB_XHCI_MVEBU
 	bool "MVEBU USB 3.0 support"
 	default y
 	depends on ARCH_MVEBU
+	select DM_REGULATOR
 	help
 	  Choose this option to add support for USB 3.0 driver on mvebu
 	  SoCs, which includes Armada8K, Armada3700 and other Armada
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
index 46eb937..d880af1 100644
--- a/drivers/usb/host/xhci-mvebu.c
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -10,6 +10,7 @@ 
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,12 +45,22 @@  static int xhci_usb_probe(struct udevice *dev)
 	struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
 	struct mvebu_xhci *ctx = dev_get_priv(dev);
 	struct xhci_hcor *hcor;
-	int len;
+	int len, ret;
+	struct udevice *regulator;
 
 	ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
 	len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
 	hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
+	ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+	if (!ret) {
+		ret = regulator_set_enable(regulator, true);
+		if (ret) {
+			printf("Failed to turn ON the VBUS regulator\n");
+			return ret;
+		}
+	}
+
 	/* Enable USB xHCI (VBUS, reset etc) in board specific code */
 	board_xhci_enable();