Skip to contentSkip to conversation

Update ehci-platform driver to support devicetree

RFC PATCH Superseded Tony Prisk 3 participants 8 messages Oct 20, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tony Prisk

author
#0 lore raw

cover Update ehci-platform driver to support devicetree

This patchset updates the ehci-platform.c driver to allow device tree probing. I have dropped support for the three function pointers (power_on, power_off and power_suspend). If someone has knowledge of the power sequence functions that are being implemented, these functions could be replaced (Sorry, I don't know anything about implementing it).

port_power_(on_off) properties are not supported in DT as Alan Stern indicated they are going to be removed.

I have included a binding document, but must admit most of the descriptions for the properties are guessed. Quite likely some of these descriptions are incorrect and/or need to be clarified.

Tony Prisk (2):
USB: Update EHCI-platform driver to devicetree.
USB: doc: Binding document for ehci-platform driver

 .../devicetree/bindings/usb/ehci-platform.txt      |   22 +++
 drivers/usb/host/ehci-hcd.c                        |    5 -
 drivers/usb/host/ehci-platform.c                   |   46 ++++++
 drivers/usb/host/ehci-vt8500.c                     |  171 --------------------
 4 files changed, 68 insertions(+), 176 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-platform.txt
 delete mode 100644 drivers/usb/host/ehci-vt8500.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 USB: Update EHCI-platform driver to devicetree.

This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c

Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers.

---
 drivers/usb/host/ehci-hcd.c      |    5 --
 drivers/usb/host/ehci-platform.c |   46 ++++++++++
 drivers/usb/host/ehci-vt8500.c   |  171 --------------------------------------
 3 files changed, 46 insertions(+), 176 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-vt8500.c
drivers/usb/host/ehci-hcd.c +0 -5
index 6bf6c42..42c8e84 100644
@@ -1274,11 +1274,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		cns3xxx_ehci_driver
 #endif
 
-#ifdef CONFIG_ARCH_VT8500
-#include "ehci-vt8500.c"
-#define	PLATFORM_DRIVER		vt8500_ehci_driver
-#endif
-
 #ifdef CONFIG_PLAT_SPEAR
 #include "ehci-spear.c"
 #define PLATFORM_DRIVER		spear_ehci_hcd_driver
drivers/usb/host/ehci-platform.c +46 -0

77 lines not on this page · raw message

drivers/usb/host/ehci-vt8500.c deleted +0 -171

171 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/2 USB: Update EHCI-platform driver to devicetree.

Hi Tony,

Quoted 5 lines · On Saturday 20 October 2012 16:17:32 Tony Prisk wrote:

This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c

Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers.

Ok, so I have recently sent a bit patchset to remove most OHCI/EHCI drivers that could be converted to the generic variants, series starts here:
1349701906-16481-1-git-send-email-florian at openwrt.org

in this patchset I added a new property to the EHCI platform data:
need_io_watchdog, which needs to be handled too from DT ideally.

Adding device tree bindings is on my TODO after having a generic way to pass clocks to the ehci/ohci platform drivers, so you are right on time :)

[snip]

drivers/usb/host/ehci-platform.c static const struct hc_driver ehci_platform_hc_driver = { · line 102

Quoted 9 lines
drivers/usb/host/ehci-platform.c +9 -0
+	if (np) {
+		/*
+		 * No platform data is being passed, so initalize pdata.
+		 * Limitation: we can't support power_on, power_off or
+		 * power_suspend function pointers from DT.
+		 * TODO: The missing functions could be replaced with
+		 * power sequence handlers.
+		 */
+		pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL);

Missing allocation failure handling here. And you should free this in ehci_platform_remove() accordingly.

drivers/usb/host/ehci-platform.c static const struct hc_driver ehci_platform_hc_driver = { · line 114

Quoted 12 lines
drivers/usb/host/ehci-platform.c +12 -0
+		dev->dev.platform_data = pdata;
+
+		/* Read the optional properties from DT node */
+		of_property_read_u32(np, "caps-offset", &pdata->caps_offset);
+		if (of_property_read_bool(np, "has-tt"))
+			pdata->has_tt = 1;
+		if (of_property_read_bool(np, "has-synopsys-hc-bug"))
+			pdata->has_synopsys_hc_bug = 1;
+		if (of_property_read_bool(np, "big-endian-desc"))
+			pdata->big_endian_desc = 1;
+		if (of_property_read_bool(np, "big-endian-mmio"))
+			pdata->big_endian_mmio = 1;

I would rather we remain compatible with ehci-ppc-of, by handling the big-endian property you set big_endian_mmiod and big_endian_desc to 1, and by setting them individually, you get what you expect.

Quoted 13 lines
drivers/usb/host/ehci-platform.c +9 -0
+
+		/* Right now device-tree probed devices don't get dma_mask set.
+		 * Since shared usb code relies on it, set it here for now.
+		 * Once we have dma capability bindings this can go away.
+		 */
+		if (!dev->dev.dma_mask)
+			dev->dev.dma_mask = &ehci_dma_mask;
+	}
+
 	if (!pdata) {
 		WARN_ON(1);
 		return -ENODEV;

drivers/usb/host/ehci-platform.c static const struct platform_device_id ehci_platform_table[] = { · line 257

Quoted 8 lines
drivers/usb/host/ehci-platform.c +5 -0
@@ -215,6 +250,16 @@ static const struct platform_device_id ehci_platform_table[] = {
 	{ "ehci-platform", 0 },
 	{ }
 };
+
+#ifdef CONFIG_OF
+static const struct of_device_id ehci_platform_ids[] = {
+	{ .compatible = "ehci-platform", },
+	{}

ehci-platform is very linux-specific, so this should either be:
"linux,ehci-platform", or "usb-ehci", pretty much like the ppc-of ehci driver.

Signature · 1 line
Florian
maintainer
#3 lore raw

PATCH 1/2 USB: Update EHCI-platform driver to devicetree.

Quoted 9 lines · Florian Fainelli

Hi Tony,

Quoted 5 lines · On Saturday 20 October 2012 16:17:32 Tony Prisk wrote:

This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c

Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers.

Quoted 6 lines

Ok, so I have recently sent a bit patchset to remove most OHCI/EHCI drivers that could be converted to the generic variants, series starts here:
1349701906-16481-1-git-send-email-florian at openwrt.org

in this patchset I added a new property to the EHCI platform data:
need_io_watchdog, which needs to be handled too from DT ideally.

Actually the new property is "no_io_watchdog". See

	http://marc.info/?l=linux-usb&m=134970247511140&w=2
Quoted 2 lines

Adding device tree bindings is on my TODO after having a generic way to pass clocks to the ehci/ohci platform drivers, so you are right on time :)

At some point we'll need a way to handle the power_{on,off,suspend} callbacks. I don't know how that should be done.

Alan Stern

author
#4 lore raw

PATCH 1/2 USB: Update EHCI-platform driver to devicetree.

Quoted 22 lines · Alan Stern
Quoted 9 lines · Florian Fainelli

Hi Tony,

Quoted 5 lines · On Saturday 20 October 2012 16:17:32 Tony Prisk wrote:

This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c

Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers.

Quoted 6 lines

Ok, so I have recently sent a bit patchset to remove most OHCI/EHCI drivers that could be converted to the generic variants, series starts here:
1349701906-16481-1-git-send-email-florian at openwrt.org

in this patchset I added a new property to the EHCI platform data:
need_io_watchdog, which needs to be handled too from DT ideally.

Actually the new property is "no_io_watchdog". See

	http://marc.info/?l=linux-usb&m=134970247511140&w=2
Quoted 7 lines
Quoted 2 lines

Adding device tree bindings is on my TODO after having a generic way to pass clocks to the ehci/ohci platform drivers, so you are right on time :)

At some point we'll need a way to handle the power_{on,off,suspend} callbacks. I don't know how that should be done.

Alan Stern

I actually included a comment in the patch regarding the missing functions:

drivers/usb/host/ehci-platform.c static const struct hc_driver ehci_platform_hc_driver = { · line 101

Quoted 7 lines

+ * No platform data is being passed, so initalize
pdata.

drivers/usb/host/ehci-platform.c +5 -0
+                * Limitation: we can't support power_on, power_off or
+                * power_suspend function pointers from DT.
+                * TODO: The missing functions could be replaced with
+                * power sequence handlers.
+                */

I don't know anything about the power sequence code, but have seen some patches for pwm backlight using it. I don't know if it would allow everything that's needed, but it seems to have support for voltage regulators and gpios (among other things).

Regards
Tony P

author
#5 lore raw

PATCH 1/2 USB: Update EHCI-platform driver to devicetree.

In reply to Florian Fainelli
Quoted 21 lines · Florian Fainelli

Hi Tony,

Quoted 5 lines · On Saturday 20 October 2012 16:17:32 Tony Prisk wrote:

This patch adds devicetree support to the EHCI-platform driver, and removes the now unneeded ehci-vt8500.c

Existing platform properties are maintained, with the exception the power_(on/off) and suspend function pointers.

Ok, so I have recently sent a bit patchset to remove most OHCI/EHCI drivers that could be converted to the generic variants, series starts here:
1349701906-16481-1-git-send-email-florian at openwrt.org

in this patchset I added a new property to the EHCI platform data:
need_io_watchdog, which needs to be handled too from DT ideally.

Adding device tree bindings is on my TODO after having a generic way to pass clocks to the ehci/ohci platform drivers, so you are right on time :)

[snip]

Quoted 12 lines

drivers/usb/host/ehci-platform.c static const struct hc_driver ehci_platform_hc_driver = { · line 102

Quoted 9 lines
drivers/usb/host/ehci-platform.c +9 -0
+	if (np) {
+		/*
+		 * No platform data is being passed, so initalize pdata.
+		 * Limitation: we can't support power_on, power_off or
+		 * power_suspend function pointers from DT.
+		 * TODO: The missing functions could be replaced with
+		 * power sequence handlers.
+		 */
+		pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL);

Missing allocation failure handling here. And you should free this in ehci_platform_remove() accordingly.

Oops - good catch. Will fix.

Quoted 17 lines

drivers/usb/host/ehci-platform.c static const struct hc_driver ehci_platform_hc_driver = { · line 114

Quoted 13 lines
drivers/usb/host/ehci-platform.c +12 -0
+		dev->dev.platform_data = pdata;
+
+		/* Read the optional properties from DT node */
+		of_property_read_u32(np, "caps-offset", &pdata->caps_offset);
+		if (of_property_read_bool(np, "has-tt"))
+			pdata->has_tt = 1;
+		if (of_property_read_bool(np, "has-synopsys-hc-bug"))
+			pdata->has_synopsys_hc_bug = 1;
+		if (of_property_read_bool(np, "big-endian-desc"))
+			pdata->big_endian_desc = 1;
+		if (of_property_read_bool(np, "big-endian-mmio"))
+			pdata->big_endian_mmio = 1;

I would rather we remain compatible with ehci-ppc-of, by handling the big-endian property you set big_endian_mmiod and big_endian_desc to 1, and by setting them individually, you get what you expect.

I noticed in the usb-ehci.txt binding document, it lists big-endian-regs, big-endian-desc and big-endian so perhaps we should rename all these to match.

Quoted 17 lines
Quoted 17 lines
drivers/usb/host/ehci-platform.c +9 -0
+
+		/* Right now device-tree probed devices don't get dma_mask set.
+		 * Since shared usb code relies on it, set it here for now.
+		 * Once we have dma capability bindings this can go away.
+		 */
+		if (!dev->dev.dma_mask)
+			dev->dev.dma_mask = &ehci_dma_mask;
+	}
+
 	if (!pdata) {
 		WARN_ON(1);
 		return -ENODEV;
@@ -215,6 +250,16 @@ static const struct platform_device_id ehci_platform_table[] = {
 	{ "ehci-platform", 0 },
 	{ }
 };
Quoted 8 lines

drivers/usb/host/ehci-platform.c static const struct platform_device_id ehci_platform_table[] = { · line 257

Quoted 5 lines
drivers/usb/host/ehci-platform.c +5 -0
+
+#ifdef CONFIG_OF
+static const struct of_device_id ehci_platform_ids[] = {
+	{ .compatible = "ehci-platform", },
+	{}

ehci-platform is very linux-specific, so this should either be:
"linux,ehci-platform", or "usb-ehci", pretty much like the ppc-of ehci driver.

Anyone has any preferences? This change should also be applied to platform-uhci to keep everything uniform (and ohci-platform eventually as well).

author
#6 lore raw

PATCH 2/2 USB: doc: Binding document for ehci-platform driver

In reply to Tony Prisk

Add a binding document for ehci-platform driver.

---
 .../devicetree/bindings/usb/ehci-platform.txt      |   22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ehci-platform.txt
Documentation/devicetree/bindings/usb/ehci-platform.txt new file +22 -0
new file mode 100644
index 0000000..faeffe4
@@ -0,0 +1,22 @@
+Generic Platform EHCI Controller
+-----------------------------------------------------
+
+Required properties:
+- compatible : "ehci-platform"
+- reg : Should contain 1 register ranges(address and length)
+- interrupts : EHCI controller interrupt
+
+Optional properties:
+- caps-offset : offset to the capabilities register (default = 0)
+- has-tt : controller has transaction translator(s).
+- big-endian-desc : descriptors are in big-endian format
+- big-endian-mmio : mmio is in big-endian format
+- has-synopsys-hc-bug : controller has the synopsys hc bug
+
+Example:
+	ehci at d8007c00 {
+		compatible = "ehci-platform";
+		reg = <0xd8007c00 0x200>;
+		interrupts = <43>;
+		has-tt;
+	};
Signature · 1 line
1.7.9.5
maintainer
#7 lore raw

cover Update ehci-platform driver to support devicetree

In reply to Tony Prisk
Quoted 6 lines · Tony Prisk

This patchset updates the ehci-platform.c driver to allow device tree probing. I have dropped support for the three function pointers (power_on, power_off and power_suspend). If someone has knowledge of the power sequence functions that are being implemented, these functions could be replaced (Sorry, I don't know anything about implementing it).

Quoted 6 lines

port_power_(on_off) properties are not supported in DT as Alan Stern indicated they are going to be removed.

I have included a binding document, but must admit most of the descriptions for the properties are guessed. Quite likely some of these descriptions are incorrect and/or need to be clarified.

They look okay to me. Over time we may need to add a few more entries, as more drivers are converted over to ehci-platform.

Quoted 3 lines

Tony Prisk (2):
USB: Update EHCI-platform driver to devicetree.
USB: doc: Binding document for ehci-platform driver

This is very good; thanks for doing the work.

Alan Stern