From: paul@pwsan.com (Paul Walmsley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/11] ARM: OMAP2+: usb_host_fs: add custom reset for usb_host_fs (fsusb)
Date: Thu, 07 Jun 2012 00:13:09 -0600 [thread overview]
Message-ID: <20120607061308.25532.19767.stgit@dusk> (raw)
In-Reply-To: <20120607060901.25532.68354.stgit@dusk>
From: Tero Kristo <t-kristo@ti.com>
Add a custom reset function for the usb_host_fs/fsusb IP block, and
connect it to the OMAP4 FSUSB block.
This is the first of two fixes required to get rid of the boot
warning:
omap_hwmod: usb_host_fs: _wait_target_disable failed
and to allow the module to idle.
It may be necessary to use this reset method for OMAP2xxx SoCs as
well; this is left for a future patch.
Signed-off-by: Tero Kristo <t-kristo@ti.com>
[paul at pwsan.com: rewrote the custom reset function, documented it and
updated the commit message, and moved the code to mach-omap2/fs-usb.c]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Beno?t Cousson <b-cousson@ti.com>
Cc: Felipe Balbi <balbi@ti.com>
---
arch/arm/mach-omap2/Makefile | 4 --
arch/arm/mach-omap2/cm.h | 8 +++-
arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 1
arch/arm/mach-omap2/usb-fs.c | 62 ++++++++++++++++++++++++++++
arch/arm/plat-omap/include/plat/usb.h | 3 +
5 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bc2ac4f..fc2ff91 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -245,9 +245,7 @@ omap-hsmmc-$(CONFIG_MMC_OMAP_HS) := hsmmc.o
obj-y += $(omap-hsmmc-m) $(omap-hsmmc-y)
-usbfs-$(CONFIG_ARCH_OMAP_OTG) := usb-fs.o
-obj-y += $(usbfs-m) $(usbfs-y)
-obj-y += usb-musb.o
+obj-y += usb-fs.o usb-musb.o
obj-y += omap_phy_internal.o
obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o
diff --git a/arch/arm/mach-omap2/cm.h b/arch/arm/mach-omap2/cm.h
index a7bc096..99978c7 100644
--- a/arch/arm/mach-omap2/cm.h
+++ b/arch/arm/mach-omap2/cm.h
@@ -1,7 +1,7 @@
/*
* OMAP2+ Clock Management prototypes
*
- * Copyright (C) 2007-2009 Texas Instruments, Inc.
+ * Copyright (C) 2007-2012 Texas Instruments, Inc.
* Copyright (C) 2007-2009 Nokia Corporation
*
* Written by Paul Walmsley
@@ -14,6 +14,12 @@
#define __ARCH_ASM_MACH_OMAP2_CM_H
/*
+ * MAX_MODULE_SOFTRESET_TIME: maximum time in microseconds to wait for
+ * an IP block to finish an OCP SOFTRESET.
+ */
+#define MAX_MODULE_SOFTRESET_WAIT 10000
+
+/*
* MAX_MODULE_READY_TIME: max duration in microseconds to wait for the
* PRCM to request that a module exit the inactive state in the case of
* OMAP2 & 3.
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index a93ce48..02daacc 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -3314,6 +3314,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_usb_host_fs_sysc = {
static struct omap_hwmod_class omap44xx_usb_host_fs_hwmod_class = {
.name = "usb_host_fs",
.sysc = &omap44xx_usb_host_fs_sysc,
+ .reset = omap_usb_host_fs_reset,
};
/* usb_host_fs */
diff --git a/arch/arm/mach-omap2/usb-fs.c b/arch/arm/mach-omap2/usb-fs.c
index 1481078..4faf0f7 100644
--- a/arch/arm/mach-omap2/usb-fs.c
+++ b/arch/arm/mach-omap2/usb-fs.c
@@ -1,7 +1,7 @@
/*
* Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
*
- * Copyright (C) 2004 Texas Instruments, Inc.
+ * Copyright (C) 2004, 2012 Texas Instruments, Inc.
*
* 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
@@ -32,6 +32,8 @@
#include <plat/usb.h>
#include <plat/board.h>
+#include "cm.h"
+#include "common.h"
#include "control.h"
#include "mux.h"
@@ -41,6 +43,64 @@
#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
+/* HCCOMMANDSTATUS: the register offset of the HCCOMMANDSTATUS register */
+#define HCCOMMANDSTATUS 0x0008
+
+/* HCCOMMANDSTATUS_HCR: the bitmask of the host controller reset flag */
+#define HCCOMMANDSTATUS_HCR_MASK (1 << 0)
+
+/**
+ * omap_usb_host_fs_reset - custom reset function for the FSUSB IP block
+ * @oh: struct omap_hwmod * of the usb_host_fs IP block
+ *
+ * Reset the FSUSB IP block. This IP block requires a custom
+ * two-stage reset; otherwise the IP block won't idle-ack to the PRCM.
+ * First the OCP SOFTRESET method must be used. Next, the IP block's
+ * internal reset bit must be toggled. This will place the OHCI
+ * controller state into UsbSuspend, which allows the IP block to
+ * idle-ack to the PRCM. Note that the FSUSB still takes almost 4
+ * milliseconds to idle-ack after this function returns. Returns 0
+ * upon success, -EINVAL if the IP block softreset data wasn't
+ * supplied, or -EBUSY if the IP block reset times out.
+ */
+int omap_usb_host_fs_reset(struct omap_hwmod *oh)
+{
+ int c;
+
+ if (omap_hwmod_softreset(oh))
+ return -EINVAL;
+
+ omap_test_timeout(!(omap_hwmod_read(oh, oh->class->sysc->sysc_offs)
+ & SYSC_TYPE2_SOFTRESET_MASK),
+ MAX_MODULE_SOFTRESET_WAIT, c);
+
+ if (c == MAX_MODULE_SOFTRESET_WAIT) {
+ pr_warn("%s: %s: softreset failed (waited %d usec)\n",
+ __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
+ return -EBUSY;
+ } else {
+ pr_debug("%s: %s: softreset in %d usec\n", __func__,
+ oh->name, c);
+ }
+
+ omap_hwmod_write(HCCOMMANDSTATUS_HCR_MASK, oh, HCCOMMANDSTATUS);
+
+ omap_test_timeout(!(omap_hwmod_read(oh, HCCOMMANDSTATUS)
+ & HCCOMMANDSTATUS_HCR_MASK),
+ MAX_MODULE_SOFTRESET_WAIT, c);
+
+ if (c == MAX_MODULE_SOFTRESET_WAIT) {
+ pr_warn("%s: %s: host controller reset failed (waited %d usec)\n",
+ __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
+ return -EBUSY;
+ } else {
+ pr_debug("%s: %s: host controller reset in %d usec\n", __func__,
+ oh->name, c);
+ }
+
+ return 0;
+}
+
#if defined(CONFIG_ARCH_OMAP2)
#ifdef CONFIG_USB_GADGET_OMAP
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 762eeb0..ac7db50 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -6,6 +6,7 @@
#include <linux/io.h>
#include <linux/usb/musb.h>
#include <plat/board.h>
+#include <plat/omap_hwmod.h>
#define OMAP3_HS_USB_PORTS 3
@@ -181,6 +182,8 @@ static inline void omap2_usbfs_init(struct omap_usb_config *pdata)
}
#endif
+extern int omap_usb_host_fs_reset(struct omap_hwmod *oh);
+
/*-------------------------------------------------------------------------*/
/*
next prev parent reply other threads:[~2012-06-07 6:13 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 6:13 [PATCH 00/11] ARM: OMAP: core/hwmod: first set of fixes for 3.5-rc Paul Walmsley
2012-06-07 6:13 ` [PATCH 01/11] ARM: OMAP2+: hwmod: add setup_preprogram hook Paul Walmsley
2012-06-07 6:13 ` [PATCH 02/11] ARM: OMAP4+: AESS: enable internal auto-gating during initial setup Paul Walmsley
2012-06-07 7:19 ` Tony Lindgren
2012-06-07 7:31 ` Paul Walmsley
2012-06-07 7:48 ` Tony Lindgren
2012-06-07 10:45 ` Paul Walmsley
2012-06-07 11:08 ` Tony Lindgren
2012-06-07 6:13 ` [PATCH 03/11] ARM: OMAP4: hwmod data: add SL2IF hardreset line Paul Walmsley
2012-06-07 6:13 ` Paul Walmsley [this message]
2012-06-07 7:31 ` [PATCH 04/11] ARM: OMAP2+: usb_host_fs: add custom reset for usb_host_fs (fsusb) Tony Lindgren
2012-06-07 7:33 ` Felipe Balbi
2012-06-07 8:00 ` Tony Lindgren
2012-06-07 7:40 ` Paul Walmsley
2012-06-07 7:51 ` Tony Lindgren
2012-06-07 7:55 ` Felipe Balbi
2012-06-07 8:02 ` Cousson, Benoit
2012-06-07 8:10 ` Tony Lindgren
2012-06-07 8:14 ` Felipe Balbi
2012-06-07 10:52 ` Paul Walmsley
2012-06-07 12:30 ` Cousson, Benoit
2012-06-08 1:11 ` Paul Walmsley
2012-06-08 13:13 ` Cousson, Benoit
2012-06-08 13:28 ` Paul Walmsley
2012-06-08 19:32 ` Hiremath, Vaibhav
2012-06-08 23:10 ` AM335x CPSW reset (was "RE: [PATCH 04/11] ARM: OMAP2+: usb_host_fs: add custom reset for usb_host_fs (fsusb)") Paul Walmsley
2012-06-09 8:39 ` Hiremath, Vaibhav
2012-06-09 16:05 ` Paul Walmsley
2012-06-11 6:15 ` [PATCH 04/11] ARM: OMAP2+: usb_host_fs: add custom reset for usb_host_fs (fsusb) Tony Lindgren
2012-06-11 8:04 ` Paul Walmsley
2012-06-11 9:24 ` Cousson, Benoit
2012-06-11 16:20 ` Paul Walmsley
2012-06-07 10:20 ` Paul Walmsley
2012-06-07 10:52 ` Tony Lindgren
2012-06-07 22:05 ` Paul Walmsley
2012-06-08 6:38 ` Tony Lindgren
2012-06-09 1:31 ` Paul Walmsley
2012-06-11 6:21 ` Tony Lindgren
2012-06-07 6:13 ` [PATCH 05/11] ARM: OMAP2+: hwmod code/data: fix 32K sync timer Paul Walmsley
2012-06-07 6:59 ` Hiremath, Vaibhav
2012-06-07 7:08 ` Paul Walmsley
2012-06-07 18:09 ` Hiremath, Vaibhav
2012-06-07 20:03 ` Paul Walmsley
2012-06-08 19:10 ` Hiremath, Vaibhav
2012-06-11 9:12 ` Cousson, Benoit
2012-06-08 13:22 ` Tero Kristo
2012-06-08 23:18 ` Paul Walmsley
2012-06-07 6:13 ` [PATCH 06/11] ARM: OMAP4+: hwmod: fix issue causing IPs not going back to Smart-Standby Paul Walmsley
2012-06-07 6:13 ` [PATCH 07/11] ARM: OMAP: PM: Lock clocks list while generating summary Paul Walmsley
2012-06-07 6:13 ` [PATCH 08/11] ARM: OMAP2+: CM: increase the module disable timeout Paul Walmsley
2012-06-07 6:13 ` [PATCH 10/11] ARM: OMAP2+: hwmod: add flag to prevent hwmod code from touching IP block during init Paul Walmsley
2012-06-07 6:13 ` [PATCH 09/11] ARM: OMAP4: clock data: add clockdomains for clocks used as main clocks Paul Walmsley
2012-06-07 6:39 ` Rajendra Nayak
2012-06-18 17:41 ` Paul Walmsley
2012-06-19 5:15 ` Rajendra Nayak
2012-06-07 6:13 ` [PATCH 11/11] ARM: OMAP4: hwmod data: do not enable or reset the McPDM during kernel init Paul Walmsley
2012-06-08 13:30 ` [PATCH 00/11] ARM: OMAP: core/hwmod: first set of fixes for 3.5-rc Tero Kristo
2012-06-09 1:15 ` Paul Walmsley
2012-06-13 23:55 ` Paul Walmsley
2012-06-14 7:36 ` Tero Kristo
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=20120607061308.25532.19767.stgit@dusk \
--to=paul@pwsan.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox