From: Kishon Vijay Abraham I <kishon@ti.com>
To: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
balbi@ti.com, heikki.krogerus@linux.intel.com, gregkh@suse.de
Cc: p-basak2@ti.com, kishon@ti.com, balajitk@ti.com, x0153364@ti.com,
m-sonasath@ti.com, vishp@ti.com, hemahk@ti.com
Subject: [RFC PATCH 1/6] usb: musb: omap: Configure OTG_INTERFSEL for proper charger detection
Date: Thu, 15 Sep 2011 19:49:58 +0530 [thread overview]
Message-ID: <1316096403-6013-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1316096403-6013-1-git-send-email-kishon@ti.com>
Setting OTG_INTERFSEL to UTMI interferes with charger detection resulting
in incorrect detection of charger type. Hence OTG_INTERFSEL is configured to
ULPI initially and changed to UTMI only after receiving USB_EVENT_ID or
USB_EVENT_VBUS notification.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Balaji T K <balajitk@ti.com>
[sandesh.gowda@ti.com: The interface selection has to be done before the PHY
is activated and is not allowed to change when the PHY clock is already
running]
---
drivers/usb/musb/omap2430.c | 50 +++++++++++++++++++++++++++++++++++-------
1 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index fc9377c..724450b 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -228,6 +228,7 @@ static inline void omap2430_low_level_init(struct musb *musb)
static int musb_otg_notifications(struct notifier_block *nb,
unsigned long event, void *unused)
{
+ u32 val;
struct musb *musb = container_of(nb, struct musb, nb);
struct device *dev = musb->controller;
struct musb_hdrc_platform_data *pdata = dev->platform_data;
@@ -240,11 +241,32 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_otg_enabled(musb)) {
if (musb->gadget_driver) {
pm_runtime_get_sync(musb->controller);
+
+ val = musb_readl(musb->mregs, OTG_INTERFSEL);
+ if (data->interface_type ==
+ MUSB_INTERFACE_UTMI) {
+ val &= ~ULPI_12PIN;
+ val |= UTMI_8BIT;
+ } else {
+ val |= ULPI_12PIN;
+ }
+ musb_writel(musb->mregs, OTG_INTERFSEL, val);
+
usb_phy_init(musb->xceiv);
omap2430_musb_set_vbus(musb, 1);
}
} else {
pm_runtime_get_sync(musb->controller);
+
+ val = musb_readl(musb->mregs, OTG_INTERFSEL);
+ if (data->interface_type == MUSB_INTERFACE_UTMI) {
+ val &= ~ULPI_12PIN;
+ val |= UTMI_8BIT;
+ } else {
+ val |= ULPI_12PIN;
+ }
+ musb_writel(musb->mregs, OTG_INTERFSEL, val);
+
usb_phy_init(musb->xceiv);
omap2430_musb_set_vbus(musb, 1);
}
@@ -255,6 +277,16 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (musb->gadget_driver)
pm_runtime_get_sync(musb->controller);
+
+ val = musb_readl(musb->mregs, OTG_INTERFSEL);
+ if (data->interface_type == MUSB_INTERFACE_UTMI) {
+ val &= ~ULPI_12PIN;
+ val |= UTMI_8BIT;
+ } else {
+ val |= ULPI_12PIN;
+ }
+ musb_writel(musb->mregs, OTG_INTERFSEL, val);
+
usb_phy_init(musb->xceiv);
break;
@@ -272,6 +304,11 @@ static int musb_otg_notifications(struct notifier_block *nb,
otg_set_vbus(musb->xceiv->otg, 0);
}
usb_phy_shutdown(musb->xceiv);
+
+ val = musb_readl(musb->mregs, OTG_INTERFSEL);
+ val |= ULPI_12PIN;
+ musb_writel(musb->mregs, OTG_INTERFSEL, val);
+
break;
default:
dev_dbg(musb->controller, "ID float\n");
@@ -304,16 +341,11 @@ static int omap2430_musb_init(struct musb *musb)
goto err1;
}
+ /* Set OTG_INTERFSEL to ULPI for correct charger detection.
+ * This should be later set to UTMI.
+ */
l = musb_readl(musb->mregs, OTG_INTERFSEL);
-
- if (data->interface_type == MUSB_INTERFACE_UTMI) {
- /* OMAP4 uses Internal PHY GS70 which uses UTMI interface */
- l &= ~ULPI_12PIN; /* Disable ULPI */
- l |= UTMI_8BIT; /* Enable UTMI */
- } else {
- l |= ULPI_12PIN;
- }
-
+ l |= ULPI_12PIN;
musb_writel(musb->mregs, OTG_INTERFSEL, l);
pr_debug("HS USB OTG: revision 0x%x, sysconfig 0x%02x, "
--
1.7.0.4
next prev parent reply other threads:[~2011-09-15 14:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-15 14:19 [RFC PATCH 0/6] usb: musb: charger detection Kishon Vijay Abraham I
2011-09-15 14:19 ` Kishon Vijay Abraham I [this message]
2011-09-16 9:48 ` [RFC PATCH 1/6] usb: musb: omap: Configure OTG_INTERFSEL for proper " Sergei Shtylyov
2011-09-16 13:51 ` ABRAHAM, KISHON VIJAY
[not found] ` <CAAe_U6KaFJGM61=Pkm2q-EBQeEtSAOBuC2jgFRd7DV4xKOjJdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-16 14:13 ` Greg KH
2011-09-19 14:56 ` T Krishnamoorthy, Balaji
2011-09-19 17:12 ` Greg KH
[not found] ` <1316096403-6013-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2011-09-15 14:19 ` [RFC PATCH 2/6] usb: musb: omap4430_phy_power to enable/disable clocks and power up/down phy Kishon Vijay Abraham I
2011-09-15 14:20 ` [RFC PATCH 3/6] OMAP4: TWL6030: add USB charger detection Kishon Vijay Abraham I
2011-09-15 14:20 ` [RFC PATCH 4/6] MUSB Charger Type Detection: Fix DCP detect during boot Kishon Vijay Abraham I
2011-09-15 14:20 ` [RFC PATCH 6/6] twl6030: set charger current to be used by battery charging module Kishon Vijay Abraham I
2011-09-15 14:20 ` [RFC PATCH 5/6] OMAP4: PHY internal: Add msleep_interruptible to charger detection function Kishon Vijay Abraham I
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=1316096403-6013-2-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=balajitk@ti.com \
--cc=balbi@ti.com \
--cc=gregkh@suse.de \
--cc=heikki.krogerus@linux.intel.com \
--cc=hemahk@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m-sonasath@ti.com \
--cc=p-basak2@ti.com \
--cc=vishp@ti.com \
--cc=x0153364@ti.com \
/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.