All of lore.kernel.org
 help / color / mirror / Atom feed
From: patrice.chotard at st.com <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 07/14] usb: ohci: Add STi ohci support
Date: Wed, 22 Mar 2017 10:54:09 +0100	[thread overview]
Message-ID: <1490176456-24813-8-git-send-email-patrice.chotard@st.com> (raw)
In-Reply-To: <1490176456-24813-1-git-send-email-patrice.chotard@st.com>

From: Patrice Chotard <patrice.chotard@st.com>

Add support for on-chip ohci controller available
on STMicrolectronics SoCs.
Ohci support will be then available on both type A
USB 2.0 connectors.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

v2:	_ put board specific defines in a separate patch (patch 8)


 drivers/usb/host/Kconfig    |  9 +++++
 drivers/usb/host/Makefile   |  1 +
 drivers/usb/host/ohci-sti.c | 90 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/usb/host/ohci-sti.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index d66f49e..33ded5d 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -168,6 +168,15 @@ config USB_OHCI_GENERIC
 	---help---
 	  Enables support for generic OHCI controller.
 
+config USB_OHCI_STI
+	bool "Support for STMicroelectronics OHCI USB controller"
+	depends on ARCH_STI
+	depends on OF_CONTROL
+	depends on DM_USB
+	select USB_HOST
+	---help---
+	  Enables support for the on-chip OHCI controller on STMicroelectronics SoCs.
+
 endif # USB_OHCI_HCD
 
 config USB_UHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 303aa32..b78e632 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
 obj-$(CONFIG_USB_OHCI_SUNXI) += ohci-sunxi.o
 obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o
 obj-$(CONFIG_USB_OHCI_GENERIC) += ohci-generic.o
+obj-$(CONFIG_USB_OHCI_STI) += ohci-sti.o
 
 # echi
 obj-$(CONFIG_USB_EHCI) += ehci-hcd.o
diff --git a/drivers/usb/host/ohci-sti.c b/drivers/usb/host/ohci-sti.c
new file mode 100644
index 0000000..62b63cd
--- /dev/null
+++ b/drivers/usb/host/ohci-sti.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017
+ * Patrice Chotard <patrice.chotard@st.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <dm.h>
+#include <errno.h>
+#include "ohci.h"
+#include <reset-uclass.h>
+#include <usb.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if !defined(CONFIG_USB_OHCI_NEW)
+# error "Generic OHCI driver requires CONFIG_USB_OHCI_NEW"
+#endif
+
+struct sti_ohci_priv {
+	ohci_t ohci;
+	struct reset_ctl power_ctl;
+	struct reset_ctl softreset_ctl;
+};
+
+static int ohci_usb_probe(struct udevice *dev)
+{
+	struct sti_ohci_priv *priv = dev_get_priv(dev);
+	struct ohci_regs *regs;
+	struct udevice *dev_phy;
+	int ret, phy_node;
+
+	regs = (struct ohci_regs *)dev_get_addr(dev);
+	if (regs == (void *)FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	ret = reset_get_by_name(dev, "power", &priv->power_ctl);
+	if (ret) {
+		error("can't get power reset for %s (%d)", dev->name, ret);
+		return ret;
+	}
+
+	ret = reset_get_by_name(dev, "softreset", &priv->softreset_ctl);
+	if (ret) {
+		error("can't get soft reset for %s (%d)", dev->name, ret);
+		return ret;
+	}
+
+	ret = reset_deassert(&priv->power_ctl);
+	if (ret < 0) {
+		error("OHCI power reset deassert failed: %d", ret);
+		return ret;
+	}
+
+	ret = reset_deassert(&priv->softreset_ctl);
+	if (ret < 0) {
+		error("OHCI soft reset deassert failed: %d", ret);
+		return ret;
+	}
+
+	/* get phy node */
+	phy_node = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "phys");
+	if (phy_node <= 0) {
+		error("Not found usb phy device\n");
+		return -ENODEV;
+	}
+
+	/* probe associated phy node */
+	ret = uclass_get_device_by_of_offset(UCLASS_MISC, phy_node, &dev_phy);
+
+	return ohci_register(dev, regs);
+}
+
+static const struct udevice_id sti_usb_ids[] = {
+	{ .compatible = "st,st-ohci-300x" },
+	{ }
+};
+
+U_BOOT_DRIVER(ohci_sti) = {
+	.name = "ohci_sti",
+	.id = UCLASS_USB,
+	.of_match = sti_usb_ids,
+	.probe = ohci_usb_probe,
+	.remove = ohci_deregister,
+	.ops = &ohci_usb_ops,
+	.priv_auto_alloc_size = sizeof(struct sti_ohci_priv),
+	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
-- 
1.9.1

  parent reply	other threads:[~2017-03-22  9:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22  9:54 [U-Boot] [PATCH v2 00/14] STiH410-B2260: add reset, usb and fastboot support patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 01/14] reset: Add STi reset support patrice.chotard at st.com
2017-03-27  2:27   ` Simon Glass
2017-03-22  9:54 ` [U-Boot] [PATCH v2 02/14] mmc: sti_sdhci: Rework sti_mmc_core_config() patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 03/14] ARM: dts: stih410-family: Add missing reset_names for mmc1 node patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 04/14] mmc: sti_sdhci: Use reset framework patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 05/14] phy: Add STi phy usb support patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 06/14] usb: ehci: Add STi ehci support patrice.chotard at st.com
2017-04-01  4:20   ` Simon Glass
2017-04-03 11:43     ` Patrice CHOTARD
2017-03-22  9:54 ` patrice.chotard at st.com [this message]
2017-04-01  4:21   ` [U-Boot] [PATCH v2 07/14] usb: ohci: Add STi ohci support Simon Glass
2017-03-22  9:54 ` [U-Boot] [PATCH v2 08/14] board: STiH410-B2260: add OHCI related defines patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 09/14] usb: xhci: Add STi xhci support patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 10/14] board: STiH410-B2260: add XHCI related define patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 11/14] usb: dwc3: Add dwc3 support for STi patrice.chotard at st.com
2017-04-01  4:21   ` Simon Glass
2017-04-03 12:00     ` Patrice CHOTARD
2017-03-22  9:54 ` [U-Boot] [PATCH v2 12/14] board: STiH410-B2260: add fastboot support patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 13/14] STiH410-B2260: enable USB Host Networking patrice.chotard at st.com
2017-03-22  9:54 ` [U-Boot] [PATCH v2 14/14] STiH410-B2260: enable USB, fastboot, reset related flags patrice.chotard at st.com
2017-04-21  6:56 ` [U-Boot] [PATCH v2 00/14] STiH410-B2260: add reset, usb and fastboot support Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490176456-24813-8-git-send-email-patrice.chotard@st.com \
    --to=patrice.chotard@st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.