All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] USB: add generic onboard USB driver
@ 2015-12-18  9:33 ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

Hi all,

This is later patch set for generic onboard HUB dirver [1], since
I find it can apply for all generic onboard USB devices, so I
changed a little for it, it should be work for the use case found
at imx6qdl udoo board, but several people have comments for its
design, I mark RFC for disucssion, and see how to implement it
properly.

The purpose for this patch set is to let the USB handle platform
parameters properly, since some usb devices need to pre-setup
before it can be recognized by controller [2], some usb devices
has more interfaces for others use, like i2c, gpios, etc.[3]

Thanks.

[1] http://www.spinics.net/lists/linux-usb/msg134082.html
[2] http://www.spinics.net/lists/linux-usb/msg131502.html
[3] http://marc.info/?l=linux-usb&m=142772952730243&w=2

Peter Chen (5):
  usb: hub: add device tree support for populating onboard usb device
  doc: dt-binding: generic onboard USB device
  usb: misc: generic_onboard_hub: add generic onboard USB device driver
  usb: chipidea: host: let the hcd know's parent device node
  ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property

 .../bindings/usb/generic-onboard-device.txt        |  31 +++++
 MAINTAINERS                                        |   7 +
 arch/arm/boot/dts/imx6qdl-udoo.dtsi                |  35 ++---
 drivers/usb/chipidea/host.c                        |  18 ++-
 drivers/usb/core/hub.c                             |  37 ++++++
 drivers/usb/misc/Kconfig                           |  10 ++
 drivers/usb/misc/Makefile                          |   1 +
 drivers/usb/misc/generic_onboard_device.c          | 144 +++++++++++++++++++++
 8 files changed, 258 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
 create mode 100644 drivers/usb/misc/generic_onboard_device.c

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 0/5] USB: add generic onboard USB driver
@ 2015-12-18  9:33 ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

This is later patch set for generic onboard HUB dirver [1], since
I find it can apply for all generic onboard USB devices, so I
changed a little for it, it should be work for the use case found
at imx6qdl udoo board, but several people have comments for its
design, I mark RFC for disucssion, and see how to implement it
properly.

The purpose for this patch set is to let the USB handle platform
parameters properly, since some usb devices need to pre-setup
before it can be recognized by controller [2], some usb devices
has more interfaces for others use, like i2c, gpios, etc.[3]

Thanks.

[1] http://www.spinics.net/lists/linux-usb/msg134082.html
[2] http://www.spinics.net/lists/linux-usb/msg131502.html
[3] http://marc.info/?l=linux-usb&m=142772952730243&w=2

Peter Chen (5):
  usb: hub: add device tree support for populating onboard usb device
  doc: dt-binding: generic onboard USB device
  usb: misc: generic_onboard_hub: add generic onboard USB device driver
  usb: chipidea: host: let the hcd know's parent device node
  ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property

 .../bindings/usb/generic-onboard-device.txt        |  31 +++++
 MAINTAINERS                                        |   7 +
 arch/arm/boot/dts/imx6qdl-udoo.dtsi                |  35 ++---
 drivers/usb/chipidea/host.c                        |  18 ++-
 drivers/usb/core/hub.c                             |  37 ++++++
 drivers/usb/misc/Kconfig                           |  10 ++
 drivers/usb/misc/Makefile                          |   1 +
 drivers/usb/misc/generic_onboard_device.c          | 144 +++++++++++++++++++++
 8 files changed, 258 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
 create mode 100644 drivers/usb/misc/generic_onboard_device.c

-- 
1.9.1

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/5] usb: hub: add device tree support for populating onboard usb device
  2015-12-18  9:33 ` Peter Chen
@ 2015-12-18  9:33     ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

Although most of USB device is hot-plug's, there are still some
USB devices are soldered on the board, and these kinds of devices
maybe the upstream device at 1st or 2nd level hub's, so in order to
detect all onboard devices, we put the detect device node code
at hub's driver, and it will populate platform device under this HUB.

Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 drivers/usb/core/hub.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5e32ce7..889f188 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
 #include <linux/mutex.h>
 #include <linux/random.h>
 #include <linux/pm_qos.h>
+#include <linux/of_platform.h>
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
@@ -1334,6 +1335,34 @@ static int hub_post_reset(struct usb_interface *intf)
 	return 0;
 }
 
+static int hub_of_children_register(struct usb_device *hdev)
+{
+	struct device *dev;
+
+	if (hdev->parent)
+		dev = &hdev->dev;
+	else
+		dev = bus_to_hcd(hdev->bus)->self.controller;
+
+	if (!dev->of_node)
+		return 0;
+
+	return of_platform_populate(dev->of_node, NULL, NULL, dev);
+}
+
+static void hub_of_children_unregister(struct usb_device *hdev)
+{
+	struct device *dev;
+
+	if (hdev->parent)
+		dev = &hdev->dev;
+	else
+		dev = bus_to_hcd(hdev->bus)->self.controller;
+
+	if (dev->of_node)
+		of_platform_depopulate(dev);
+}
+
 static int hub_configure(struct usb_hub *hub,
 	struct usb_endpoint_descriptor *endpoint)
 {
@@ -1677,6 +1706,7 @@ static void hub_disconnect(struct usb_interface *intf)
 	usb_set_intfdata(intf, NULL);
 	spin_unlock_irq(&device_state_lock);
 
+	hub_of_children_unregister(hdev);
 	for (; port1 > 0; --port1)
 		usb_hub_remove_port_device(hub, port1);
 
@@ -1701,6 +1731,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	int ret;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
@@ -1820,6 +1851,12 @@ descriptor_error:
 	if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
 		hub->quirk_check_port_auto_suspend = 1;
 
+	ret = hub_of_children_register(hdev);
+	if (ret) {
+		dev_err(&hdev->dev, "Failed to register child device\n");
+		return ret;
+	}
+
 	if (hub_configure(hub, endpoint) >= 0)
 		return 0;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 1/5] usb: hub: add device tree support for populating onboard usb device
@ 2015-12-18  9:33     ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Although most of USB device is hot-plug's, there are still some
USB devices are soldered on the board, and these kinds of devices
maybe the upstream device at 1st or 2nd level hub's, so in order to
detect all onboard devices, we put the detect device node code
at hub's driver, and it will populate platform device under this HUB.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/core/hub.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5e32ce7..889f188 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
 #include <linux/mutex.h>
 #include <linux/random.h>
 #include <linux/pm_qos.h>
+#include <linux/of_platform.h>
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
@@ -1334,6 +1335,34 @@ static int hub_post_reset(struct usb_interface *intf)
 	return 0;
 }
 
+static int hub_of_children_register(struct usb_device *hdev)
+{
+	struct device *dev;
+
+	if (hdev->parent)
+		dev = &hdev->dev;
+	else
+		dev = bus_to_hcd(hdev->bus)->self.controller;
+
+	if (!dev->of_node)
+		return 0;
+
+	return of_platform_populate(dev->of_node, NULL, NULL, dev);
+}
+
+static void hub_of_children_unregister(struct usb_device *hdev)
+{
+	struct device *dev;
+
+	if (hdev->parent)
+		dev = &hdev->dev;
+	else
+		dev = bus_to_hcd(hdev->bus)->self.controller;
+
+	if (dev->of_node)
+		of_platform_depopulate(dev);
+}
+
 static int hub_configure(struct usb_hub *hub,
 	struct usb_endpoint_descriptor *endpoint)
 {
@@ -1677,6 +1706,7 @@ static void hub_disconnect(struct usb_interface *intf)
 	usb_set_intfdata(intf, NULL);
 	spin_unlock_irq(&device_state_lock);
 
+	hub_of_children_unregister(hdev);
 	for (; port1 > 0; --port1)
 		usb_hub_remove_port_device(hub, port1);
 
@@ -1701,6 +1731,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_device *hdev;
 	struct usb_hub *hub;
+	int ret;
 
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
@@ -1820,6 +1851,12 @@ descriptor_error:
 	if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND)
 		hub->quirk_check_port_auto_suspend = 1;
 
+	ret = hub_of_children_register(hdev);
+	if (ret) {
+		dev_err(&hdev->dev, "Failed to register child device\n");
+		return ret;
+	}
+
 	if (hub_configure(hub, endpoint) >= 0)
 		return 0;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
  2015-12-18  9:33 ` Peter Chen
@ 2015-12-18  9:33     ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

Add dt-binding documentation for generic onboard USB device.

Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt

diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
new file mode 100644
index 0000000..cdb3014
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
@@ -0,0 +1,31 @@
+Generic Onboard USB Device 
+
+The node should be located at USB host controller's node or
+any USB HUB's node.
+
+Required properties:
+- compatible: should be "generic-onboard-device"
+
+Optional properties:
+- clocks: the input clock for USB device.
+- clock-frequency: the frequency for device's clock.
+- reset-gpios: Should specify the GPIO for reset.
+- reset-duration-us: the duration for assert reset signal, the time unit
+  is microsecond.
+
+Example:
+
+&usbh1 {
+	vbus-supply = <&reg_usb_h1_vbus>;
+        status = "okay";
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+	hub: usb2415@01 {
+	       compatible = "generic-onboard-device";
+	       reg = <0x01>;
+	       clocks = <&clks IMX6QDL_CLK_CKO>;
+	       reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
+	       reset-duration-us = <10>;
+	};
+};
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
@ 2015-12-18  9:33     ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Add dt-binding documentation for generic onboard USB device.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt

diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
new file mode 100644
index 0000000..cdb3014
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
@@ -0,0 +1,31 @@
+Generic Onboard USB Device 
+
+The node should be located at USB host controller's node or
+any USB HUB's node.
+
+Required properties:
+- compatible: should be "generic-onboard-device"
+
+Optional properties:
+- clocks: the input clock for USB device.
+- clock-frequency: the frequency for device's clock.
+- reset-gpios: Should specify the GPIO for reset.
+- reset-duration-us: the duration for assert reset signal, the time unit
+  is microsecond.
+
+Example:
+
+&usbh1 {
+	vbus-supply = <&reg_usb_h1_vbus>;
+        status = "okay";
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+	hub: usb2415 at 01 {
+	       compatible = "generic-onboard-device";
+	       reg = <0x01>;
+	       clocks = <&clks IMX6QDL_CLK_CKO>;
+	       reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
+	       reset-duration-us = <10>;
+	};
+};
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 3/5] usb: misc: generic_onboard_hub: add generic onboard USB device driver
  2015-12-18  9:33 ` Peter Chen
@ 2015-12-18  9:33     ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

Current USB device driver lacks of platform interfaces to configure
external signal on HUB chip, eg, the PHY input clock and gpio reset
pin for HUB, these kinds of devices are usually soldered at the board,
and they are not hot-plug USB devices.

With this patch, the user can configure the device's pins at device tree,
and these configuration will be effective before the USB bus can be used,
it can avoid unexpected signals at USB bus during this USB device hardware
reset process, so we use subsys_initcall for this driver.

Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 MAINTAINERS                               |   7 ++
 drivers/usb/misc/Kconfig                  |  10 +++
 drivers/usb/misc/Makefile                 |   1 +
 drivers/usb/misc/generic_onboard_device.c | 144 ++++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+)
 create mode 100644 drivers/usb/misc/generic_onboard_device.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9bff63c..9ea0955 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11140,6 +11140,13 @@ S:	Maintained
 F:	Documentation/usb/ohci.txt
 F:	drivers/usb/host/ohci*
 
+USB Generic Onboard Device Driver
+M:	Peter Chen <Peter.Chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
+L:	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+S:	Maintained
+F:	drivers/usb/misc/generic_onboard_device.c
+
 USB OTG FSM (Finite State Machine)
 M:	Peter Chen <Peter.Chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index f7a7fc2..089e2c4 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -268,3 +268,13 @@ config USB_CHAOSKEY
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called chaoskey.
+
+config USB_ONBOARD_DEVICE
+	tristate "Generic USB Onboard Device"
+	help
+	  depends on OF
+	  Say Y here if your board has an onboard device, and this device
+	  needs to control its PHY clock and reset pin through external
+	  signals. If you are not sure, say N.
+
+	  To compile this driver as a module, choose M here.
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 45fd4ac..60731bb 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
+obj-$(CONFIG_USB_ONBOARD_DEVICE)	+= generic_onboard_device.o
diff --git a/drivers/usb/misc/generic_onboard_device.c b/drivers/usb/misc/generic_onboard_device.c
new file mode 100644
index 0000000..0111bd9
--- /dev/null
+++ b/drivers/usb/misc/generic_onboard_device.c
@@ -0,0 +1,144 @@
+/*
+ * generic_onboard_device.c	The generic onboard USB device driver
+ *
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Author: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This driver is only for the USB HUB devices which need to control
+ * their external pins(clock, reset, etc), and these USB HUB devices
+ * are soldered at the board.
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+
+struct usb_generic_onboard_data {
+	struct clk *clk;
+};
+
+static int usb_generic_onboard_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct usb_generic_onboard_data *hub_data;
+	int ret = -EINVAL;
+	struct gpio_desc *gpiod_reset = NULL;
+	struct device_node *node = dev->of_node;
+	u32 duration_us = 50, clk_rate = 0;
+
+	/* Only support device tree now */
+	if (!node)
+		return ret;
+
+	hub_data = devm_kzalloc(dev, sizeof(*hub_data), GFP_KERNEL);
+	if (!hub_data)
+		return -ENOMEM;
+
+	hub_data->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(hub_data->clk)) {
+		dev_dbg(dev, "Can't get clock: %ld\n",
+			PTR_ERR(hub_data->clk));
+		hub_data->clk = NULL;
+	} else {
+		ret = clk_prepare_enable(hub_data->clk);
+		if (ret) {
+			dev_err(dev,
+				"Can't enable external clock: %d\n",
+				ret);
+			return ret;
+		}
+
+		of_property_read_u32(node, "clock-frequency", &clk_rate);
+		if (clk_rate) {
+			ret = clk_set_rate(hub_data->clk, clk_rate);
+			if (ret) {
+				dev_err(dev, "Error setting clock rate\n");
+				goto disable_clk;
+			}
+		}
+	}
+
+	gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
+	ret = PTR_ERR_OR_ZERO(gpiod_reset);
+	if (ret) {
+		dev_err(dev, "Failed to get reset gpio, err = %d\n", ret);
+		goto disable_clk;
+	}
+
+	of_property_read_u32(node, "reset-duration-us", &duration_us);
+
+	if (gpiod_reset) {
+		gpiod_direction_output(gpiod_reset, 1);
+
+		gpiod_set_value(gpiod_reset, 1);
+		usleep_range(duration_us, duration_us + 10);
+		gpiod_set_value(gpiod_reset, 0);
+	}
+
+	dev_set_drvdata(dev, hub_data);
+	return ret;
+
+disable_clk:
+	clk_disable_unprepare(hub_data->clk);
+	return ret;
+}
+
+static int usb_generic_onboard_remove(struct platform_device *pdev)
+{
+	struct usb_generic_onboard_data *hub_data = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(hub_data->clk);
+	return 0;
+}
+
+static const struct of_device_id usb_generic_onboard_dt_ids[] = {
+	{.compatible = "generic-onboard-device"},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, usb_generic_onboard_dt_ids);
+
+static struct platform_driver usb_generic_onboard_driver = {
+	.probe = usb_generic_onboard_probe,
+	.remove = usb_generic_onboard_remove,
+	.driver = {
+		.name = "usb_generic_onboard",
+		.of_match_table = usb_generic_onboard_dt_ids,
+	 },
+};
+
+static int __init usb_generic_onboard_init(void)
+{
+	return platform_driver_register(&usb_generic_onboard_driver);
+}
+subsys_initcall(usb_generic_onboard_init);
+
+static void __exit usb_generic_onboard_exit(void)
+{
+	platform_driver_unregister(&usb_generic_onboard_driver);
+}
+module_exit(usb_generic_onboard_exit);
+
+MODULE_AUTHOR("Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>");
+MODULE_DESCRIPTION("Generic Onboard USB HUB driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 3/5] usb: misc: generic_onboard_hub: add generic onboard USB device driver
@ 2015-12-18  9:33     ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Current USB device driver lacks of platform interfaces to configure
external signal on HUB chip, eg, the PHY input clock and gpio reset
pin for HUB, these kinds of devices are usually soldered at the board,
and they are not hot-plug USB devices.

With this patch, the user can configure the device's pins at device tree,
and these configuration will be effective before the USB bus can be used,
it can avoid unexpected signals at USB bus during this USB device hardware
reset process, so we use subsys_initcall for this driver.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 MAINTAINERS                               |   7 ++
 drivers/usb/misc/Kconfig                  |  10 +++
 drivers/usb/misc/Makefile                 |   1 +
 drivers/usb/misc/generic_onboard_device.c | 144 ++++++++++++++++++++++++++++++
 4 files changed, 162 insertions(+)
 create mode 100644 drivers/usb/misc/generic_onboard_device.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 9bff63c..9ea0955 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11140,6 +11140,13 @@ S:	Maintained
 F:	Documentation/usb/ohci.txt
 F:	drivers/usb/host/ohci*
 
+USB Generic Onboard Device Driver
+M:	Peter Chen <Peter.Chen@freescale.com>
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
+L:	linux-usb at vger.kernel.org
+S:	Maintained
+F:	drivers/usb/misc/generic_onboard_device.c
+
 USB OTG FSM (Finite State Machine)
 M:	Peter Chen <Peter.Chen@freescale.com>
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index f7a7fc2..089e2c4 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -268,3 +268,13 @@ config USB_CHAOSKEY
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called chaoskey.
+
+config USB_ONBOARD_DEVICE
+	tristate "Generic USB Onboard Device"
+	help
+	  depends on OF
+	  Say Y here if your board has an onboard device, and this device
+	  needs to control its PHY clock and reset pin through external
+	  signals. If you are not sure, say N.
+
+	  To compile this driver as a module, choose M here.
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 45fd4ac..60731bb 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_USB_CHAOSKEY)		+= chaoskey.o
 
 obj-$(CONFIG_USB_SISUSBVGA)		+= sisusbvga/
 obj-$(CONFIG_USB_LINK_LAYER_TEST)	+= lvstest.o
+obj-$(CONFIG_USB_ONBOARD_DEVICE)	+= generic_onboard_device.o
diff --git a/drivers/usb/misc/generic_onboard_device.c b/drivers/usb/misc/generic_onboard_device.c
new file mode 100644
index 0000000..0111bd9
--- /dev/null
+++ b/drivers/usb/misc/generic_onboard_device.c
@@ -0,0 +1,144 @@
+/*
+ * generic_onboard_device.c	The generic onboard USB device driver
+ *
+ * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Author: Peter Chen <peter.chen@freescale.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * This driver is only for the USB HUB devices which need to control
+ * their external pins(clock, reset, etc), and these USB HUB devices
+ * are soldered at the board.
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+
+struct usb_generic_onboard_data {
+	struct clk *clk;
+};
+
+static int usb_generic_onboard_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct usb_generic_onboard_data *hub_data;
+	int ret = -EINVAL;
+	struct gpio_desc *gpiod_reset = NULL;
+	struct device_node *node = dev->of_node;
+	u32 duration_us = 50, clk_rate = 0;
+
+	/* Only support device tree now */
+	if (!node)
+		return ret;
+
+	hub_data = devm_kzalloc(dev, sizeof(*hub_data), GFP_KERNEL);
+	if (!hub_data)
+		return -ENOMEM;
+
+	hub_data->clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(hub_data->clk)) {
+		dev_dbg(dev, "Can't get clock: %ld\n",
+			PTR_ERR(hub_data->clk));
+		hub_data->clk = NULL;
+	} else {
+		ret = clk_prepare_enable(hub_data->clk);
+		if (ret) {
+			dev_err(dev,
+				"Can't enable external clock: %d\n",
+				ret);
+			return ret;
+		}
+
+		of_property_read_u32(node, "clock-frequency", &clk_rate);
+		if (clk_rate) {
+			ret = clk_set_rate(hub_data->clk, clk_rate);
+			if (ret) {
+				dev_err(dev, "Error setting clock rate\n");
+				goto disable_clk;
+			}
+		}
+	}
+
+	gpiod_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
+	ret = PTR_ERR_OR_ZERO(gpiod_reset);
+	if (ret) {
+		dev_err(dev, "Failed to get reset gpio, err = %d\n", ret);
+		goto disable_clk;
+	}
+
+	of_property_read_u32(node, "reset-duration-us", &duration_us);
+
+	if (gpiod_reset) {
+		gpiod_direction_output(gpiod_reset, 1);
+
+		gpiod_set_value(gpiod_reset, 1);
+		usleep_range(duration_us, duration_us + 10);
+		gpiod_set_value(gpiod_reset, 0);
+	}
+
+	dev_set_drvdata(dev, hub_data);
+	return ret;
+
+disable_clk:
+	clk_disable_unprepare(hub_data->clk);
+	return ret;
+}
+
+static int usb_generic_onboard_remove(struct platform_device *pdev)
+{
+	struct usb_generic_onboard_data *hub_data = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(hub_data->clk);
+	return 0;
+}
+
+static const struct of_device_id usb_generic_onboard_dt_ids[] = {
+	{.compatible = "generic-onboard-device"},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, usb_generic_onboard_dt_ids);
+
+static struct platform_driver usb_generic_onboard_driver = {
+	.probe = usb_generic_onboard_probe,
+	.remove = usb_generic_onboard_remove,
+	.driver = {
+		.name = "usb_generic_onboard",
+		.of_match_table = usb_generic_onboard_dt_ids,
+	 },
+};
+
+static int __init usb_generic_onboard_init(void)
+{
+	return platform_driver_register(&usb_generic_onboard_driver);
+}
+subsys_initcall(usb_generic_onboard_init);
+
+static void __exit usb_generic_onboard_exit(void)
+{
+	platform_driver_unregister(&usb_generic_onboard_driver);
+}
+module_exit(usb_generic_onboard_exit);
+
+MODULE_AUTHOR("Peter Chen <peter.chen@freescale.com>");
+MODULE_DESCRIPTION("Generic Onboard USB HUB driver");
+MODULE_LICENSE("GPL v2");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 4/5] usb: chipidea: host: let the hcd know's parent device node
  2015-12-18  9:33 ` Peter Chen
@ 2015-12-18  9:33     ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

Since the hcd (chipidea core device) has no device node, so
if we want to describe the child node under the hcd, we had
to put it under its parent's node (glue layer device), and
in the code, we need to let the hcd knows glue layer's code,
then the USB core can handle this node.

Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 drivers/usb/chipidea/host.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 3d24304..63a6aa4 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -109,15 +109,25 @@ static int host_start(struct ci_hdrc *ci)
 	struct ehci_hcd *ehci;
 	struct ehci_ci_priv *priv;
 	int ret;
+	struct device *dev = ci->dev;
 
-	if (usb_disabled())
+	if (usb_disabled() || !dev)
 		return -ENODEV;
 
-	hcd = usb_create_hcd(&ci_ehci_hc_driver, ci->dev, dev_name(ci->dev));
+	/*
+	 * USB Core will try to get child node under roothub,
+	 * but chipidea core has no of_node, and the child node
+	 * for controller is located at glue layer's node which
+	 * is chipidea core's parent.
+	 */
+	if (dev->parent && dev->parent->of_node)
+		dev->of_node = dev->parent->of_node;
+
+	hcd = usb_create_hcd(&ci_ehci_hc_driver, dev, dev_name(dev));
 	if (!hcd)
 		return -ENOMEM;
 
-	dev_set_drvdata(ci->dev, ci);
+	dev_set_drvdata(dev, ci);
 	hcd->rsrc_start = ci->hw_bank.phys;
 	hcd->rsrc_len = ci->hw_bank.size;
 	hcd->regs = ci->hw_bank.abs;
@@ -143,7 +153,7 @@ static int host_start(struct ci_hdrc *ci)
 		if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) {
 			ret = regulator_enable(ci->platdata->reg_vbus);
 			if (ret) {
-				dev_err(ci->dev,
+				dev_err(dev,
 				"Failed to enable vbus regulator, ret=%d\n",
 									ret);
 				goto put_hcd;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 4/5] usb: chipidea: host: let the hcd know's parent device node
@ 2015-12-18  9:33     ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

Since the hcd (chipidea core device) has no device node, so
if we want to describe the child node under the hcd, we had
to put it under its parent's node (glue layer device), and
in the code, we need to let the hcd knows glue layer's code,
then the USB core can handle this node.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/chipidea/host.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 3d24304..63a6aa4 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -109,15 +109,25 @@ static int host_start(struct ci_hdrc *ci)
 	struct ehci_hcd *ehci;
 	struct ehci_ci_priv *priv;
 	int ret;
+	struct device *dev = ci->dev;
 
-	if (usb_disabled())
+	if (usb_disabled() || !dev)
 		return -ENODEV;
 
-	hcd = usb_create_hcd(&ci_ehci_hc_driver, ci->dev, dev_name(ci->dev));
+	/*
+	 * USB Core will try to get child node under roothub,
+	 * but chipidea core has no of_node, and the child node
+	 * for controller is located at glue layer's node which
+	 * is chipidea core's parent.
+	 */
+	if (dev->parent && dev->parent->of_node)
+		dev->of_node = dev->parent->of_node;
+
+	hcd = usb_create_hcd(&ci_ehci_hc_driver, dev, dev_name(dev));
 	if (!hcd)
 		return -ENOMEM;
 
-	dev_set_drvdata(ci->dev, ci);
+	dev_set_drvdata(dev, ci);
 	hcd->rsrc_start = ci->hw_bank.phys;
 	hcd->rsrc_len = ci->hw_bank.size;
 	hcd->regs = ci->hw_bank.abs;
@@ -143,7 +153,7 @@ static int host_start(struct ci_hdrc *ci)
 		if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) {
 			ret = regulator_enable(ci->platdata->reg_vbus);
 			if (ret) {
-				dev_err(ci->dev,
+				dev_err(dev,
 				"Failed to enable vbus regulator, ret=%d\n",
 									ret);
 				goto put_hcd;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 5/5] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property
  2015-12-18  9:33 ` Peter Chen
@ 2015-12-18  9:33     ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, pawel.moll-5wv7dgnIgG8,
	mark.rutland-5wv7dgnIgG8, festevam-Re5JQEeQqe8AvxtiuMwx3w,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A,
	Peter Chen

The current dts describes USB HUB's property at USB controller's
entry, it is improper. The USB HUB should be the child node
under USB controller.

Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 arch/arm/boot/dts/imx6qdl-udoo.dtsi | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
index 1211da8..7155afb 100644
--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
@@ -9,6 +9,8 @@
  *
  */
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	chosen {
 		stdout-path = &uart2;
@@ -17,23 +19,6 @@
 	memory {
 		reg = <0x10000000 0x40000000>;
 	};
-
-	regulators {
-		compatible = "simple-bus";
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		reg_usb_h1_vbus: regulator@0 {
-			compatible = "regulator-fixed";
-			reg = <0>;
-			regulator-name = "usb_h1_vbus";
-			regulator-min-microvolt = <5000000>;
-			regulator-max-microvolt = <5000000>;
-			enable-active-high;
-			startup-delay-us = <2>; /* USB2415 requires a POR of 1 us minimum */
-			gpio = <&gpio7 12 0>;
-		};
-	};
 };
 
 &fec {
@@ -119,11 +104,19 @@
 };
 
 &usbh1 {
-	pinctrl-names = "default";
-	pinctrl-0 = <&pinctrl_usbh>;
-	vbus-supply = <&reg_usb_h1_vbus>;
-	clocks = <&clks 201>;
 	status = "okay";
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+	hub: usb2415@01 {
+		compatible = "generic-onboard-device";
+		reg = <0x01>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_usbh>;
+		clocks = <&clks IMX6QDL_CLK_CKO>;
+		reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
+		reset-duration-us = <2>;
+	};
 };
 
 &usdhc3 {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [RFC PATCH 5/5] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property
@ 2015-12-18  9:33     ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-18  9:33 UTC (permalink / raw)
  To: linux-arm-kernel

The current dts describes USB HUB's property at USB controller's
entry, it is improper. The USB HUB should be the child node
under USB controller.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 arch/arm/boot/dts/imx6qdl-udoo.dtsi | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
index 1211da8..7155afb 100644
--- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi
@@ -9,6 +9,8 @@
  *
  */
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	chosen {
 		stdout-path = &uart2;
@@ -17,23 +19,6 @@
 	memory {
 		reg = <0x10000000 0x40000000>;
 	};
-
-	regulators {
-		compatible = "simple-bus";
-		#address-cells = <1>;
-		#size-cells = <0>;
-
-		reg_usb_h1_vbus: regulator at 0 {
-			compatible = "regulator-fixed";
-			reg = <0>;
-			regulator-name = "usb_h1_vbus";
-			regulator-min-microvolt = <5000000>;
-			regulator-max-microvolt = <5000000>;
-			enable-active-high;
-			startup-delay-us = <2>; /* USB2415 requires a POR of 1 us minimum */
-			gpio = <&gpio7 12 0>;
-		};
-	};
 };
 
 &fec {
@@ -119,11 +104,19 @@
 };
 
 &usbh1 {
-	pinctrl-names = "default";
-	pinctrl-0 = <&pinctrl_usbh>;
-	vbus-supply = <&reg_usb_h1_vbus>;
-	clocks = <&clks 201>;
 	status = "okay";
+
+	#address-cells = <1>;
+	#size-cells = <0>;
+	hub: usb2415 at 01 {
+		compatible = "generic-onboard-device";
+		reg = <0x01>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_usbh>;
+		clocks = <&clks IMX6QDL_CLK_CKO>;
+		reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
+		reset-duration-us = <2>;
+	};
 };
 
 &usdhc3 {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
  2015-12-18  9:33     ` Peter Chen
@ 2015-12-19  4:15         ` Rob Herring
  -1 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2015-12-19  4:15 UTC (permalink / raw)
  To: Peter Chen
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
	festevam-Re5JQEeQqe8AvxtiuMwx3w, p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ,
	patryk-6+2coLtxvIyvnle+31E0rA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	balbi-l0cyMroinI0, arnd-r2nGTMty4D4,
	mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A

On Fri, Dec 18, 2015 at 05:33:56PM +0800, Peter Chen wrote:
> Add dt-binding documentation for generic onboard USB device.

As has already been mentioned, please following the existing USB device 
binding convention. We can debate whether the kernel driver is tied into 
existing USB drivers or separate platform drivers, but the binding needs 
to reflect the h/w.

Rob

> 
> Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
>  .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> new file mode 100644
> index 0000000..cdb3014
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> @@ -0,0 +1,31 @@
> +Generic Onboard USB Device 
> +
> +The node should be located at USB host controller's node or
> +any USB HUB's node.
> +
> +Required properties:
> +- compatible: should be "generic-onboard-device"
> +
> +Optional properties:
> +- clocks: the input clock for USB device.
> +- clock-frequency: the frequency for device's clock.
> +- reset-gpios: Should specify the GPIO for reset.
> +- reset-duration-us: the duration for assert reset signal, the time unit
> +  is microsecond.
> +
> +Example:
> +
> +&usbh1 {
> +	vbus-supply = <&reg_usb_h1_vbus>;
> +        status = "okay";
> +
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	hub: usb2415@01 {
> +	       compatible = "generic-onboard-device";
> +	       reg = <0x01>;
> +	       clocks = <&clks IMX6QDL_CLK_CKO>;
> +	       reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
> +	       reset-duration-us = <10>;
> +	};
> +};
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
@ 2015-12-19  4:15         ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2015-12-19  4:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 18, 2015 at 05:33:56PM +0800, Peter Chen wrote:
> Add dt-binding documentation for generic onboard USB device.

As has already been mentioned, please following the existing USB device 
binding convention. We can debate whether the kernel driver is tied into 
existing USB drivers or separate platform drivers, but the binding needs 
to reflect the h/w.

Rob

> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> new file mode 100644
> index 0000000..cdb3014
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
> @@ -0,0 +1,31 @@
> +Generic Onboard USB Device 
> +
> +The node should be located at USB host controller's node or
> +any USB HUB's node.
> +
> +Required properties:
> +- compatible: should be "generic-onboard-device"
> +
> +Optional properties:
> +- clocks: the input clock for USB device.
> +- clock-frequency: the frequency for device's clock.
> +- reset-gpios: Should specify the GPIO for reset.
> +- reset-duration-us: the duration for assert reset signal, the time unit
> +  is microsecond.
> +
> +Example:
> +
> +&usbh1 {
> +	vbus-supply = <&reg_usb_h1_vbus>;
> +        status = "okay";
> +
> +	#address-cells = <1>;
> +	#size-cells = <0>;
> +	hub: usb2415 at 01 {
> +	       compatible = "generic-onboard-device";
> +	       reg = <0x01>;
> +	       clocks = <&clks IMX6QDL_CLK_CKO>;
> +	       reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
> +	       reset-duration-us = <10>;
> +	};
> +};
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
  2015-12-19  4:15         ` Rob Herring
@ 2015-12-21  8:52           ` Peter Chen
  -1 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-21  8:52 UTC (permalink / raw)
  To: Rob Herring
  Cc: Peter Chen, shawnguo-DgEjT+Ai2ygdnm+yROfE0A, Greg Kroah-Hartman,
	Alan Stern, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, devicetree-u79uwXL29TY76Z2rM5mHXA,
	pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8, Fabio Estevam,
	p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ, patryk-6+2coLtxvIyvnle+31E0rA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
	arnd-r2nGTMty4D4, mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A

On Sat, Dec 19, 2015 at 12:15 PM, Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Fri, Dec 18, 2015 at 05:33:56PM +0800, Peter Chen wrote:
>> Add dt-binding documentation for generic onboard USB device.
>
> As has already been mentioned, please following the existing USB device
> binding convention. We can debate whether the kernel driver is tied into
> existing USB drivers or separate platform drivers, but the binding needs
> to reflect the h/w.
>
> Rob
>

There is no USB device binding currently, would you mean this:
http://playground.sun.com/1275/bindings/usb/usb-1_0.ps

In fact, we hardly describe USB device at dts. No matter device address,
Device class, or compatible string, neither can work, since we know nothing
before enumeration, and there are maybe two or more usb devices at the USB bus,
only possible is {pid, vid}, but there are may be two same devices on the bus.

>>
>> Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>> ---
>>  .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
>>  1 file changed, 31 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>>
>> diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>> new file mode 100644
>> index 0000000..cdb3014
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>> @@ -0,0 +1,31 @@
>> +Generic Onboard USB Device
>> +
>> +The node should be located at USB host controller's node or
>> +any USB HUB's node.
>> +
>> +Required properties:
>> +- compatible: should be "generic-onboard-device"
>> +
>> +Optional properties:
>> +- clocks: the input clock for USB device.
>> +- clock-frequency: the frequency for device's clock.
>> +- reset-gpios: Should specify the GPIO for reset.
>> +- reset-duration-us: the duration for assert reset signal, the time unit
>> +  is microsecond.
>> +
>> +Example:
>> +
>> +&usbh1 {
>> +     vbus-supply = <&reg_usb_h1_vbus>;
>> +        status = "okay";
>> +
>> +     #address-cells = <1>;
>> +     #size-cells = <0>;
>> +     hub: usb2415@01 {
>> +            compatible = "generic-onboard-device";
>> +            reg = <0x01>;
>> +            clocks = <&clks IMX6QDL_CLK_CKO>;
>> +            reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
>> +            reset-duration-us = <10>;
>> +     };
>> +};
>> --
>> 1.9.1
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
BR,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device
@ 2015-12-21  8:52           ` Peter Chen
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Chen @ 2015-12-21  8:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Dec 19, 2015 at 12:15 PM, Rob Herring <robh@kernel.org> wrote:
> On Fri, Dec 18, 2015 at 05:33:56PM +0800, Peter Chen wrote:
>> Add dt-binding documentation for generic onboard USB device.
>
> As has already been mentioned, please following the existing USB device
> binding convention. We can debate whether the kernel driver is tied into
> existing USB drivers or separate platform drivers, but the binding needs
> to reflect the h/w.
>
> Rob
>

There is no USB device binding currently, would you mean this:
http://playground.sun.com/1275/bindings/usb/usb-1_0.ps

In fact, we hardly describe USB device at dts. No matter device address,
Device class, or compatible string, neither can work, since we know nothing
before enumeration, and there are maybe two or more usb devices at the USB bus,
only possible is {pid, vid}, but there are may be two same devices on the bus.

>>
>> Signed-off-by: Peter Chen <peter.chen@freescale.com>
>> ---
>>  .../bindings/usb/generic-onboard-device.txt        | 31 ++++++++++++++++++++++
>>  1 file changed, 31 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>>
>> diff --git a/Documentation/devicetree/bindings/usb/generic-onboard-device.txt b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>> new file mode 100644
>> index 0000000..cdb3014
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/generic-onboard-device.txt
>> @@ -0,0 +1,31 @@
>> +Generic Onboard USB Device
>> +
>> +The node should be located at USB host controller's node or
>> +any USB HUB's node.
>> +
>> +Required properties:
>> +- compatible: should be "generic-onboard-device"
>> +
>> +Optional properties:
>> +- clocks: the input clock for USB device.
>> +- clock-frequency: the frequency for device's clock.
>> +- reset-gpios: Should specify the GPIO for reset.
>> +- reset-duration-us: the duration for assert reset signal, the time unit
>> +  is microsecond.
>> +
>> +Example:
>> +
>> +&usbh1 {
>> +     vbus-supply = <&reg_usb_h1_vbus>;
>> +        status = "okay";
>> +
>> +     #address-cells = <1>;
>> +     #size-cells = <0>;
>> +     hub: usb2415 at 01 {
>> +            compatible = "generic-onboard-device";
>> +            reg = <0x01>;
>> +            clocks = <&clks IMX6QDL_CLK_CKO>;
>> +            reset-gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
>> +            reset-duration-us = <10>;
>> +     };
>> +};
>> --
>> 1.9.1
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
BR,
Peter Chen

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-21  8:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18  9:33 [RFC PATCH 0/5] USB: add generic onboard USB driver Peter Chen
2015-12-18  9:33 ` Peter Chen
     [not found] ` <1450431239-16439-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-12-18  9:33   ` [RFC PATCH 1/5] usb: hub: add device tree support for populating onboard usb device Peter Chen
2015-12-18  9:33     ` Peter Chen
2015-12-18  9:33   ` [RFC PATCH 2/5] doc: dt-binding: generic onboard USB device Peter Chen
2015-12-18  9:33     ` Peter Chen
     [not found]     ` <1450431239-16439-3-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-12-19  4:15       ` Rob Herring
2015-12-19  4:15         ` Rob Herring
2015-12-21  8:52         ` Peter Chen
2015-12-21  8:52           ` Peter Chen
2015-12-18  9:33   ` [RFC PATCH 3/5] usb: misc: generic_onboard_hub: add generic onboard USB device driver Peter Chen
2015-12-18  9:33     ` Peter Chen
2015-12-18  9:33   ` [RFC PATCH 4/5] usb: chipidea: host: let the hcd know's parent device node Peter Chen
2015-12-18  9:33     ` Peter Chen
2015-12-18  9:33   ` [RFC PATCH 5/5] ARM: dts: imx6qdl-udoo.dtsi: fix onboard USB HUB property Peter Chen
2015-12-18  9:33     ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.