diff mbox

[1/2] OMAP4: otg: phy: fix charger detection

Message ID 1341477720-6771-1-git-send-email-ruslan.bilovol@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ruslan Bilovol July 5, 2012, 8:42 a.m. UTC
Charger detection feature is not correctly used
and thus makes some regressions if OTG was used in
the host mode. Charger detection takes 500 ms so
if some device is attached to the host after 500 ms
it will be suddenly resetted.

This feature is enabled by default after reset/cold boot
so always affects PHY usage. So finally this was wrongly
interpreted as "phy requires 200ms to start".
After fixing this we can safely remove uggly mdelay after
powering on the PHY.

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
---
 arch/arm/mach-omap2/omap_phy_internal.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Comments

Kishon Vijay Abraham I Aug. 3, 2012, 9:01 a.m. UTC | #1
Hi,

On Thu, Jul 5, 2012 at 2:12 PM, Ruslan Bilovol <ruslan.bilovol@ti.com> wrote:
> Charger detection feature is not correctly used
> and thus makes some regressions if OTG was used in
> the host mode. Charger detection takes 500 ms so
> if some device is attached to the host after 500 ms
> it will be suddenly resetted.
>
> This feature is enabled by default after reset/cold boot
> so always affects PHY usage. So finally this was wrongly
> interpreted as "phy requires 200ms to start".
> After fixing this we can safely remove uggly mdelay after
> powering on the PHY.
>
> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
> ---
>  arch/arm/mach-omap2/omap_phy_internal.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-omap2/omap_phy_internal.c
> index d52651a..a13a37c 100644
> --- a/arch/arm/mach-omap2/omap_phy_internal.c
> +++ b/arch/arm/mach-omap2/omap_phy_internal.c
> @@ -42,12 +42,16 @@
>  #define        SESSEND                         BIT(3)
>  #define        IDDIG                           BIT(4)
>
> +#define CONTROL_USB2PHYCORE            0x620
> +#define USB2PHY_DISCHGDET              BIT(30)
> +
>  static struct clk *phyclk, *clk48m, *clk32k;
>  static void __iomem *ctrl_base;
>  static int usbotghs_control;
>
>  int omap4430_phy_init(struct device *dev)
>  {
> +       u32 usb2phycore;
>         ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
>         if (!ctrl_base) {
>                 pr_err("control module ioremap failed\n");
> @@ -56,6 +60,11 @@ int omap4430_phy_init(struct device *dev)
>         /* Power down the phy */
>         __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
>
> +       /* Disable charger detection by default */
> +       usb2phycore = omap4_ctrl_pad_readl(CONTROL_USB2PHYCORE);
> +       usb2phycore |= USB2PHY_DISCHGDET;
> +       omap4_ctrl_pad_writel(usb2phycore, CONTROL_USB2PHYCORE);

Maybe I failed to understand correctly but the $subject says it
*fixes* charger detection but the patch *disables* charger detection.

-Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ruslan Bilovol Aug. 3, 2012, 1:35 p.m. UTC | #2
Hi,

On Fri, Aug 3, 2012 at 12:01 PM, ABRAHAM, KISHON VIJAY <kishon@ti.com> wrote:
> Hi,
>
> On Thu, Jul 5, 2012 at 2:12 PM, Ruslan Bilovol <ruslan.bilovol@ti.com> wrote:
>> Charger detection feature is not correctly used
>> and thus makes some regressions if OTG was used in
>> the host mode. Charger detection takes 500 ms so
>> if some device is attached to the host after 500 ms
>> it will be suddenly resetted.
>>
>> This feature is enabled by default after reset/cold boot
>> so always affects PHY usage. So finally this was wrongly
>> interpreted as "phy requires 200ms to start".
>> After fixing this we can safely remove uggly mdelay after
>> powering on the PHY.
>>
>> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
>> ---
>>  arch/arm/mach-omap2/omap_phy_internal.c |    9 +++++++++
>>  1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-omap2/omap_phy_internal.c
>> index d52651a..a13a37c 100644
>> --- a/arch/arm/mach-omap2/omap_phy_internal.c
>> +++ b/arch/arm/mach-omap2/omap_phy_internal.c
>> @@ -42,12 +42,16 @@
>>  #define        SESSEND                         BIT(3)
>>  #define        IDDIG                           BIT(4)
>>
>> +#define CONTROL_USB2PHYCORE            0x620
>> +#define USB2PHY_DISCHGDET              BIT(30)
>> +
>>  static struct clk *phyclk, *clk48m, *clk32k;
>>  static void __iomem *ctrl_base;
>>  static int usbotghs_control;
>>
>>  int omap4430_phy_init(struct device *dev)
>>  {
>> +       u32 usb2phycore;
>>         ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
>>         if (!ctrl_base) {
>>                 pr_err("control module ioremap failed\n");
>> @@ -56,6 +60,11 @@ int omap4430_phy_init(struct device *dev)
>>         /* Power down the phy */
>>         __raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
>>
>> +       /* Disable charger detection by default */
>> +       usb2phycore = omap4_ctrl_pad_readl(CONTROL_USB2PHYCORE);
>> +       usb2phycore |= USB2PHY_DISCHGDET;
>> +       omap4_ctrl_pad_writel(usb2phycore, CONTROL_USB2PHYCORE);
>
> Maybe I failed to understand correctly but the $subject says it
> *fixes* charger detection but the patch *disables* charger detection.
>

Yes, you are correct (the patch originally was done for case with
charger detection realized)

Will submit new patchsets with fixed subject and description

--
Best regards,
Ruslan Bilovol
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/omap_phy_internal.c b/arch/arm/mach-omap2/omap_phy_internal.c
index d52651a..a13a37c 100644
--- a/arch/arm/mach-omap2/omap_phy_internal.c
+++ b/arch/arm/mach-omap2/omap_phy_internal.c
@@ -42,12 +42,16 @@ 
 #define	SESSEND				BIT(3)
 #define	IDDIG				BIT(4)
 
+#define CONTROL_USB2PHYCORE		0x620
+#define USB2PHY_DISCHGDET		BIT(30)
+
 static struct clk *phyclk, *clk48m, *clk32k;
 static void __iomem *ctrl_base;
 static int usbotghs_control;
 
 int omap4430_phy_init(struct device *dev)
 {
+	u32 usb2phycore;
 	ctrl_base = ioremap(OMAP443X_SCM_BASE, SZ_1K);
 	if (!ctrl_base) {
 		pr_err("control module ioremap failed\n");
@@ -56,6 +60,11 @@  int omap4430_phy_init(struct device *dev)
 	/* Power down the phy */
 	__raw_writel(PHY_PD, ctrl_base + CONTROL_DEV_CONF);
 
+	/* Disable charger detection by default */
+	usb2phycore = omap4_ctrl_pad_readl(CONTROL_USB2PHYCORE);
+	usb2phycore |= USB2PHY_DISCHGDET;
+	omap4_ctrl_pad_writel(usb2phycore, CONTROL_USB2PHYCORE);
+
 	if (!dev) {
 		iounmap(ctrl_base);
 		return 0;