mvebu: usb: xhci: Add VBUS regulator supply to the host driver
Subsystems (2)
PATCH v6 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver
From: Konstantin Porotchkin <[email protected]>
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.
---
Changes for v6:
- Corerct the "clocks" definition in document file
doc/device-tree-bindings/usb/marvell.xhci-usb.txt | 28 +++++++++++++++++++++++ drivers/usb/host/Kconfig | 1 + drivers/usb/host/xhci-mvebu.c | 13 ++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txt
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +28 -0
@@ -0,0 +1,28 @@ +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: phandle to system controller clock driving this unit + - 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 at 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 = <®_usb3h0_vbus>; + status = "disabled"; + };
drivers/usb/host/Kconfig +1 -0
@@ -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
drivers/usb/host/xhci-mvebu.c +12 -1
@@ -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" , ®ulator); +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 ();
Signature · 1 line
2.7.4
PATCH v6 4/6 mvebu: usb: xhci: Add VBUS regulator supply to the host driver
Quoted 35 lines · kostap at marvell.com
From: Konstantin Porotchkin <[email protected]>
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 <[email protected]>Cc Stefan Roese <[email protected]>Cc Marek Vasut <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>---
Changes for v6:
- Corerct the "clocks" definition in document filedoc/device-tree-bindings/usb/marvell.xhci-usb.txt | 28 +++++++++++++++++++++++ drivers/usb/host/Kconfig | 1 + drivers/usb/host/xhci-mvebu.c | 13 ++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/usb/marvell.xhci-usb.txtdoc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +5
-0@@ -0,0 +1,28 @@ +Marvell SOC USB controllers + +This controller is integrated in Armada 3700/8K. +It uses the same properties as a generic XHCI host controller +
doc/device-tree-bindings/usb/marvell.xhci-usb.txt line 15
Quoted 10 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +10
-0+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: phandle to system controller clock driving this unit
Sigh, I didn't ask you to copy my random blurb here verbatim, but whatever:
Quoted 62 lines
doc/device-tree-bindings/usb/marvell.xhci-usb.txt new file +13
-0+ - 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 at 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 = <®_usb3h0_vbus>; + status = "disabled"; + };drivers/usb/host/Kconfig +1
-0@@ -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 Armadadrivers/usb/host/xhci-mvebu.c +12
-1@@ -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" , ®ulator); +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 ();
Signature · 2 lines
Best regards, Marek Vasut