Skip to contentSkip to conversation

usb: ohci: Clear control register at driver startup

PATCH In review Alexander Shiyan 2 participants 5 messages May 25, 2016 – May 26, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 usb: ohci: Clear control register at driver startup

---
 drivers/usb/host/ohci-at91.c | 7 -------
 drivers/usb/host/ohci-hcd.c  | 7 ++++---
 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/usb/host/ohci-at91.c +0 -7
index 0f5c8f1..0a6e5ca 100644
@@ -44,8 +44,6 @@ static void at91_stop_clock(void)
 
 static int at91_ohci_probe(struct device_d *dev)
 {
-	struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
-
 	iclk = clk_get(NULL, "ohci_clk");
 	fclk = clk_get(NULL, "uhpck");
 
@@ -54,11 +52,6 @@ static int at91_ohci_probe(struct device_d *dev)
 	 */
 	at91_start_clock();
 
-	/*
-	 * The USB host controller must remain in reset.
-	 */
-	writel(0, &regs->control);
-
 	add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, dev->resource[0].start,
 			   resource_size(&dev->resource[0]), IORESOURCE_MEM, NULL);
 
drivers/usb/host/ohci-hcd.c +4 -3
index 612c3a1..a4795bb 100644
@@ -1817,14 +1817,15 @@ static int ohci_probe(struct device_d *dev)
 		return -ENOMEM;
 	memset(ohci->ohci_dev, 0, sizeof(*ohci->ohci_dev));
 
-	usb_register_host(host);
-
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
 	ohci->regs = IOMEM(iores->start);
 
-	return 0;
+	/* Put the USB host controller into reset */
+	writel(0, &ohci->regs->control);
+
+	return usb_register_host(host);
 }
 
 static struct driver_d ohci_driver = {
Signature · 7 lines
2.4.9


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/3 usb: Add OHCI platform driver

---
 drivers/usb/host/Kconfig         |  3 +++
 drivers/usb/host/Makefile        |  1 +
 drivers/usb/host/ohci-platform.c | 57 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 drivers/usb/host/ohci-platform.c
drivers/usb/host/Kconfig +3 -0
index 54eaf46..6ff4afc 100644
@@ -22,6 +22,9 @@ config USB_OHCI_AT91
 	depends on ARCH_AT91
 	bool "AT91 OHCI driver"
 
+config USB_OHCI_PLATFORM
+	bool "Platform OHCI driver"
+
 endif
 
 config USB_XHCI
drivers/usb/host/Makefile +1 -0
index 0478d34..1b5319d 100644
@@ -3,5 +3,6 @@ obj-$(CONFIG_USB_EHCI_OMAP)	+= ehci-omap.o
 obj-$(CONFIG_USB_EHCI_ATMEL)	+= ehci-atmel.o
 obj-$(CONFIG_USB_OHCI)		+= ohci-hcd.o
 obj-$(CONFIG_USB_OHCI_AT91)	+= ohci-at91.o
+obj-$(CONFIG_USB_OHCI_PLATFORM)	+= ohci-platform.o
 obj-$(CONFIG_USB_XHCI)		+= xhci-hcd.o xhci-hub.o
 obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
drivers/usb/host/ohci-platform.c new file +57 -0

57 lines not on this page · raw message

Signature · 7 lines
2.4.9


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [PATCH 2/3] usb: Add OHCI platform driver

Quoted 76 lines · Alexander Shiyan
---
 drivers/usb/host/Kconfig         |  3 +++
 drivers/usb/host/Makefile        |  1 +
 drivers/usb/host/ohci-platform.c | 57 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 drivers/usb/host/ohci-platform.c
drivers/usb/host/Kconfig +3 -0
index 54eaf46..6ff4afc 100644
@@ -22,6 +22,9 @@ config USB_OHCI_AT91
 	depends on ARCH_AT91
 	bool "AT91 OHCI driver"
 
+config USB_OHCI_PLATFORM
+	bool "Platform OHCI driver"
+
 endif
 
 config USB_XHCI
drivers/usb/host/Makefile +1 -0
index 0478d34..1b5319d 100644
@@ -3,5 +3,6 @@ obj-$(CONFIG_USB_EHCI_OMAP)	+= ehci-omap.o
 obj-$(CONFIG_USB_EHCI_ATMEL)	+= ehci-atmel.o
 obj-$(CONFIG_USB_OHCI)		+= ohci-hcd.o
 obj-$(CONFIG_USB_OHCI_AT91)	+= ohci-at91.o
+obj-$(CONFIG_USB_OHCI_PLATFORM)	+= ohci-platform.o
 obj-$(CONFIG_USB_XHCI)		+= xhci-hcd.o xhci-hub.o
 obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
drivers/usb/host/ohci-platform.c new file +37 -0
new file mode 100644
index 0000000..4c97330
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 Alexander Shiyan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <errno.h>
+#include <init.h>
+#include <io.h>
+#include <linux/clk.h>
+
+struct ohci_platform_data {
+	int (*probe)(struct device_d *, struct resource *);
+};
+
+static struct platform_device_id ohci_platform_ids[] = {
+	{ }
+};
+
+static int ohci_platform_probe(struct device_d *dev)
+{
+	struct ohci_platform_data *data;
+	struct resource *res;
+	int ret;
+
+	ret = dev_get_drvdata(dev, (const void **)&data);
+	if (ret)
+		return ret;
+
+	res = dev_get_resource(dev, IORESOURCE_MEM, 0);
+	if (IS_ERR(res))
+		return PTR_ERR(res);

drivers/usb/host/ohci-platform.c line 47

Quoted 10 lines
drivers/usb/host/ohci-platform.c new file +10 -0
+
+	dev->priv = data;
+
+	if (data->probe) {
+		ret = data->probe(dev, res);
+		if (ret)
+			return ret;
+	}
+
+	add_generic_device_res("ohci", DEVICE_ID_SINGLE, res, 1, NULL);

We should get rid of this additional device along the way and instead create a dedicated ohci_register() function which is directly called by the different SoC specific drivers. See the ehci driver for a template what I mean.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 usb: Replace AT91 OHCI driver with platform OHCI driver

In reply to Alexander Shiyan
---
 arch/arm/boards/pm9g45/init.c        |  2 +-
 arch/arm/configs/animeo_ip_defconfig |  2 +-
 arch/arm/configs/dss11_defconfig     |  2 +-
 arch/arm/configs/pm9g45_defconfig    |  2 +-
 drivers/usb/host/Kconfig             |  9 +---
 drivers/usb/host/Makefile            |  1 -
 drivers/usb/host/ohci-at91.c         | 81 ------------------------------------
 drivers/usb/host/ohci-platform.c     | 27 ++++++++++++
 8 files changed, 32 insertions(+), 94 deletions(-)
 delete mode 100644 drivers/usb/host/ohci-at91.c
arch/arm/boards/pm9g45/init.c +1 -1
index 524fe53..58d84dc 100644
@@ -100,7 +100,7 @@ static void pm9g45_add_device_mci(void) {}
 /*
  * USB OHCI Host port
  */
-#ifdef CONFIG_USB_OHCI_AT91
+#ifdef CONFIG_USB_OHCI_PLATFORM
 static struct at91_usbh_data  __initdata usbh_data = {
 	.ports		= 2,
 	.vbus_pin	= { AT91_PIN_PD0,  -EINVAL },
arch/arm/configs/animeo_ip_defconfig +1 -1
index 825c5e4..4f5e959 100644
@@ -68,7 +68,7 @@ CONFIG_NAND_ATMEL=y
 CONFIG_UBI=y
 CONFIG_USB_HOST=y
 CONFIG_USB_OHCI=y
-CONFIG_USB_OHCI_AT91=y
+CONFIG_USB_OHCI_PLATFORM=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
 CONFIG_MCI_ATMEL=y
arch/arm/configs/dss11_defconfig +1 -1
index f15fb6b..ddf7acf 100644
@@ -33,7 +33,7 @@ CONFIG_UBI=y
 CONFIG_DISK_WRITE=y
 CONFIG_USB_HOST=y
 CONFIG_USB_OHCI=y
-CONFIG_USB_OHCI_AT91=y
+CONFIG_USB_OHCI_PLATFORM=y
 CONFIG_USB_STORAGE=y
 CONFIG_MCI=y
 CONFIG_MCI_STARTUP=y
arch/arm/configs/pm9g45_defconfig +1 -1
index d3a5624..7661644 100644
@@ -52,7 +52,7 @@ CONFIG_UBI=y
 CONFIG_DISK_ATA=y
 CONFIG_USB_HOST=y
 CONFIG_USB_OHCI=y
-CONFIG_USB_OHCI_AT91=y
+CONFIG_USB_OHCI_PLATFORM=y
 CONFIG_USB_STORAGE=y
 CONFIG_MCI=y
 CONFIG_MCI_ATMEL=y
drivers/usb/host/Kconfig +1 -8
index 6ff4afc..117cb2e 100644
@@ -16,16 +16,9 @@ config USB_OHCI
 	bool "OHCI driver"
 	depends on !MMU
 
-if USB_OHCI
-
-config USB_OHCI_AT91
-	depends on ARCH_AT91
-	bool "AT91 OHCI driver"
-
 config USB_OHCI_PLATFORM
 	bool "Platform OHCI driver"
-
-endif
+	depends on USB_OHCI
 
 config USB_XHCI
 	bool "xHCI driver"
drivers/usb/host/Makefile +0 -1
index 1b5319d..cf30655 100644
@@ -2,7 +2,6 @@ obj-$(CONFIG_USB_EHCI)		+= ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_OMAP)	+= ehci-omap.o
 obj-$(CONFIG_USB_EHCI_ATMEL)	+= ehci-atmel.o
 obj-$(CONFIG_USB_OHCI)		+= ohci-hcd.o
-obj-$(CONFIG_USB_OHCI_AT91)	+= ohci-at91.o
 obj-$(CONFIG_USB_OHCI_PLATFORM)	+= ohci-platform.o
 obj-$(CONFIG_USB_XHCI)		+= xhci-hcd.o xhci-hub.o
 obj-$(CONFIG_USB_XHCI_PCI)	+= xhci-pci.o
drivers/usb/host/ohci-at91.c deleted +0 -81

81 lines not on this page · raw message

drivers/usb/host/ohci-platform.c +27 -0
index 4c97330..5765373 100644
@@ -18,7 +18,34 @@ struct ohci_platform_data {
 	int (*probe)(struct device_d *, struct resource *);
 };
 
+static int at91_ohci_probe(struct device_d *dev, struct resource *res)
+{
+	struct clk *iclk, *fclk;
+
+	iclk = clk_get(NULL, "ohci_clk");
+	if (IS_ERR(iclk))
+		return PTR_ERR(iclk);
+
+	fclk = clk_get(NULL, "uhpck");
+	if (IS_ERR(fclk))
+		return PTR_ERR(fclk);
+
+	/* Start the USB clocks */
+	clk_enable(iclk);
+	clk_enable(fclk);
+
+	return 0;
+}
+
+static struct ohci_platform_data at91_ohci_data = {
+	.probe	= at91_ohci_probe,
+};
+
 static struct platform_device_id ohci_platform_ids[] = {
+	{
+		.name		= "at91_ohci",
+		.driver_data	= (unsigned long)&at91_ohci_data,
+	},
 	{ }
 };
 
Signature · 7 lines
2.4.9


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
In reply to Alexander Shiyan
Quoted 2 lines · Alexander Shiyan

---

A comment why this is done would be nice.

Sascha

Quoted 61 lines
 drivers/usb/host/ohci-at91.c | 7 -------
 drivers/usb/host/ohci-hcd.c  | 7 ++++---
 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/usb/host/ohci-at91.c +0 -7
index 0f5c8f1..0a6e5ca 100644
@@ -44,8 +44,6 @@ static void at91_stop_clock(void)
 
 static int at91_ohci_probe(struct device_d *dev)
 {
-	struct ohci_regs __iomem *regs = (struct ohci_regs __iomem *)dev->resource[0].start;
-
 	iclk = clk_get(NULL, "ohci_clk");
 	fclk = clk_get(NULL, "uhpck");
 
@@ -54,11 +52,6 @@ static int at91_ohci_probe(struct device_d *dev)
 	 */
 	at91_start_clock();
 
-	/*
-	 * The USB host controller must remain in reset.
-	 */
-	writel(0, &regs->control);
-
 	add_generic_device("ohci", DEVICE_ID_DYNAMIC, NULL, dev->resource[0].start,
 			   resource_size(&dev->resource[0]), IORESOURCE_MEM, NULL);
 
drivers/usb/host/ohci-hcd.c +4 -3
index 612c3a1..a4795bb 100644
@@ -1817,14 +1817,15 @@ static int ohci_probe(struct device_d *dev)
 		return -ENOMEM;
 	memset(ohci->ohci_dev, 0, sizeof(*ohci->ohci_dev));
 
-	usb_register_host(host);
-
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
 	ohci->regs = IOMEM(iores->start);
 
-	return 0;
+	/* Put the USB host controller into reset */
+	writel(0, &ohci->regs->control);
+
+	return usb_register_host(host);
 }
 
 static struct driver_d ohci_driver = {
Signature · 7 lines
2.4.9


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox