RE: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-03 Thread Badola Nikhil
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Thursday, September 03, 2015 9:25 PM
> To: Badola Nikhil-B46172 
> Cc: linux-kernel@vger.kernel.org; linux-...@vger.kernel.org; linux-
> o...@vger.kernel.org; ba...@ti.com; gre...@linuxfoundation.org
> Subject: Re: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length
> adjustment quirk
> 
> On Thu, Sep 03, 2015 at 11:34:04AM +0530, Nikhil Badola wrote:
> > Add adjust_frame_length_quirk for writing to fladj register which
> > adjusts (micro)frame length to value provided by
> > "snps,quirk-frame-length-adjustment" property thus avoiding USB 2.0
> > devices to time-out over a longer run
> >
> > Signed-off-by: Nikhil Badola 
> > ---
> > Changes for v3:
> > - removed unnecessary if(fladj) condition
> > - removed stray newline
> >
> >  drivers/usb/dwc3/core.c  | 34
> ++
> >  drivers/usb/dwc3/core.h  |  5 +
> >  drivers/usb/dwc3/platform_data.h |  2 ++
> >  3 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
> > 064123e..75a17bf 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
> > return 0;
> >  }
> >
> > +/*
> > + * dwc3_frame_length_adjustment - Adjusts frame length if required
> > + * @dwc3: Pointer to our controller context structure
> > + * @fladj: Value of GFLADJ_30MHZ to adjust frame length  */ static
> > +void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj) {
> > +   if (dwc->revision < DWC3_REVISION_250A)
> > +   return;
> > +
> > +   if (fladj == 0)
> > +   return;
> > +
> > +   u32 reg;
> > +   u32 dft;
> 
> are you seriously telling me that GCC didn't warn you about mixing
> declaration and code ?

That's really careless of me.  Somehow this warning skipped my attention.
Apologies for this silly thing. I will resend the patch.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-03 Thread Felipe Balbi
On Thu, Sep 03, 2015 at 11:34:04AM +0530, Nikhil Badola wrote:
> Add adjust_frame_length_quirk for writing to fladj register
> which adjusts (micro)frame length to value provided by
> "snps,quirk-frame-length-adjustment" property thus avoiding
> USB 2.0 devices to time-out over a longer run
> 
> Signed-off-by: Nikhil Badola 
> ---
> Changes for v3:
>   - removed unnecessary if(fladj) condition
>   - removed stray newline
> 
>  drivers/usb/dwc3/core.c  | 34 ++
>  drivers/usb/dwc3/core.h  |  5 +
>  drivers/usb/dwc3/platform_data.h |  2 ++
>  3 files changed, 41 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 064123e..75a17bf 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
>   return 0;
>  }
>  
> +/*
> + * dwc3_frame_length_adjustment - Adjusts frame length if required
> + * @dwc3: Pointer to our controller context structure
> + * @fladj: Value of GFLADJ_30MHZ to adjust frame length
> + */
> +static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
> +{
> + if (dwc->revision < DWC3_REVISION_250A)
> + return;
> +
> + if (fladj == 0)
> + return;
> +
> + u32 reg;
> + u32 dft;

are you seriously telling me that GCC didn't warn you about mixing
declaration and code ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-03 Thread Felipe Balbi
On Thu, Sep 03, 2015 at 11:34:04AM +0530, Nikhil Badola wrote:
> Add adjust_frame_length_quirk for writing to fladj register
> which adjusts (micro)frame length to value provided by
> "snps,quirk-frame-length-adjustment" property thus avoiding
> USB 2.0 devices to time-out over a longer run
> 
> Signed-off-by: Nikhil Badola 
> ---
> Changes for v3:
>   - removed unnecessary if(fladj) condition
>   - removed stray newline
> 
>  drivers/usb/dwc3/core.c  | 34 ++
>  drivers/usb/dwc3/core.h  |  5 +
>  drivers/usb/dwc3/platform_data.h |  2 ++
>  3 files changed, 41 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 064123e..75a17bf 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
>   return 0;
>  }
>  
> +/*
> + * dwc3_frame_length_adjustment - Adjusts frame length if required
> + * @dwc3: Pointer to our controller context structure
> + * @fladj: Value of GFLADJ_30MHZ to adjust frame length
> + */
> +static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
> +{
> + if (dwc->revision < DWC3_REVISION_250A)
> + return;
> +
> + if (fladj == 0)
> + return;
> +
> + u32 reg;
> + u32 dft;

are you seriously telling me that GCC didn't warn you about mixing
declaration and code ?

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-03 Thread Badola Nikhil
> -Original Message-
> From: Felipe Balbi [mailto:ba...@ti.com]
> Sent: Thursday, September 03, 2015 9:25 PM
> To: Badola Nikhil-B46172 <nikhil.bad...@freescale.com>
> Cc: linux-kernel@vger.kernel.org; linux-...@vger.kernel.org; linux-
> o...@vger.kernel.org; ba...@ti.com; gre...@linuxfoundation.org
> Subject: Re: [PATCH 2/3][v3] drivers: usb: dwc3: Add frame length
> adjustment quirk
> 
> On Thu, Sep 03, 2015 at 11:34:04AM +0530, Nikhil Badola wrote:
> > Add adjust_frame_length_quirk for writing to fladj register which
> > adjusts (micro)frame length to value provided by
> > "snps,quirk-frame-length-adjustment" property thus avoiding USB 2.0
> > devices to time-out over a longer run
> >
> > Signed-off-by: Nikhil Badola <nikhil.bad...@freescale.com>
> > ---
> > Changes for v3:
> > - removed unnecessary if(fladj) condition
> > - removed stray newline
> >
> >  drivers/usb/dwc3/core.c  | 34
> ++
> >  drivers/usb/dwc3/core.h  |  5 +
> >  drivers/usb/dwc3/platform_data.h |  2 ++
> >  3 files changed, 41 insertions(+)
> >
> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
> > 064123e..75a17bf 100644
> > --- a/drivers/usb/dwc3/core.c
> > +++ b/drivers/usb/dwc3/core.c
> > @@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
> > return 0;
> >  }
> >
> > +/*
> > + * dwc3_frame_length_adjustment - Adjusts frame length if required
> > + * @dwc3: Pointer to our controller context structure
> > + * @fladj: Value of GFLADJ_30MHZ to adjust frame length  */ static
> > +void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj) {
> > +   if (dwc->revision < DWC3_REVISION_250A)
> > +   return;
> > +
> > +   if (fladj == 0)
> > +   return;
> > +
> > +   u32 reg;
> > +   u32 dft;
> 
> are you seriously telling me that GCC didn't warn you about mixing
> declaration and code ?

That's really careless of me.  Somehow this warning skipped my attention.
Apologies for this silly thing. I will resend the patch.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-02 Thread Nikhil Badola
Add adjust_frame_length_quirk for writing to fladj register
which adjusts (micro)frame length to value provided by
"snps,quirk-frame-length-adjustment" property thus avoiding
USB 2.0 devices to time-out over a longer run

Signed-off-by: Nikhil Badola 
---
Changes for v3:
- removed unnecessary if(fladj) condition
- removed stray newline

 drivers/usb/dwc3/core.c  | 34 ++
 drivers/usb/dwc3/core.h  |  5 +
 drivers/usb/dwc3/platform_data.h |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 064123e..75a17bf 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
return 0;
 }
 
+/*
+ * dwc3_frame_length_adjustment - Adjusts frame length if required
+ * @dwc3: Pointer to our controller context structure
+ * @fladj: Value of GFLADJ_30MHZ to adjust frame length
+ */
+static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
+{
+   if (dwc->revision < DWC3_REVISION_250A)
+   return;
+
+   if (fladj == 0)
+   return;
+
+   u32 reg;
+   u32 dft;
+
+   reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
+   dft = reg & DWC3_GFLADJ_30MHZ_MASK;
+   if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
+   "request value same as default, ignoring\n")) {
+   reg &= ~DWC3_GFLADJ_30MHZ_MASK;
+   reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
+   dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
+   }
+}
+
 /**
  * dwc3_free_one_event_buffer - Frees one event buffer
  * @dwc: Pointer to our controller context structure
@@ -779,6 +805,7 @@ static int dwc3_probe(struct platform_device *pdev)
u8  lpm_nyet_threshold;
u8  tx_de_emphasis;
u8  hird_threshold;
+   u32 fladj = 0;
 
int ret;
 
@@ -886,6 +913,9 @@ static int dwc3_probe(struct platform_device *pdev)
_de_emphasis);
of_property_read_string(node, "snps,hsphy_interface",
>hsphy_interface);
+   of_property_read_u32(node,
+"snps,quirk-frame-length-adjustment",
+);
} else if (pdata) {
dwc->maximum_speed = pdata->maximum_speed;
dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -915,6 +945,7 @@ static int dwc3_probe(struct platform_device *pdev)
tx_de_emphasis = pdata->tx_de_emphasis;
 
dwc->hsphy_interface = pdata->hsphy_interface;
+   fladj = pdata->fladj_value;
}
 
/* default to superspeed if no maximum_speed passed */
@@ -971,6 +1002,9 @@ static int dwc3_probe(struct platform_device *pdev)
goto err1;
}
 
+   /* Adjust Frame Length */
+   dwc3_frame_length_adjustment(dwc, fladj);
+
usb_phy_set_suspend(dwc->usb2_phy, 0);
usb_phy_set_suspend(dwc->usb3_phy, 0);
ret = phy_power_on(dwc->usb2_generic_phy);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 0447788..9188745 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -124,6 +124,7 @@
 #define DWC3_GEVNTCOUNT(n) (0xc40c + (n * 0x10))
 
 #define DWC3_GHWPARAMS80xc600
+#define DWC3_GFLADJ0xc630
 
 /* Device Registers */
 #define DWC3_DCFG  0xc700
@@ -234,6 +235,10 @@
 /* Global HWPARAMS6 Register */
 #define DWC3_GHWPARAMS6_EN_FPGA(1 << 7)
 
+/* Global Frame Length Adjustment Register */
+#define DWC3_GFLADJ_30MHZ_SDBND_SEL(1 << 7)
+#define DWC3_GFLADJ_30MHZ_MASK 0x3f
+
 /* Device Configuration Register */
 #define DWC3_DCFG_DEVADDR(addr)((addr) << 3)
 #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index d3614ec..400b197 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -46,5 +46,7 @@ struct dwc3_platform_data {
unsigned tx_de_emphasis_quirk:1;
unsigned tx_de_emphasis:2;
 
+   u32 fladj_value;
+
const char *hsphy_interface;
 };
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3][v3] drivers: usb: dwc3: Add frame length adjustment quirk

2015-09-02 Thread Nikhil Badola
Add adjust_frame_length_quirk for writing to fladj register
which adjusts (micro)frame length to value provided by
"snps,quirk-frame-length-adjustment" property thus avoiding
USB 2.0 devices to time-out over a longer run

Signed-off-by: Nikhil Badola 
---
Changes for v3:
- removed unnecessary if(fladj) condition
- removed stray newline

 drivers/usb/dwc3/core.c  | 34 ++
 drivers/usb/dwc3/core.h  |  5 +
 drivers/usb/dwc3/platform_data.h |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 064123e..75a17bf 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
return 0;
 }
 
+/*
+ * dwc3_frame_length_adjustment - Adjusts frame length if required
+ * @dwc3: Pointer to our controller context structure
+ * @fladj: Value of GFLADJ_30MHZ to adjust frame length
+ */
+static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
+{
+   if (dwc->revision < DWC3_REVISION_250A)
+   return;
+
+   if (fladj == 0)
+   return;
+
+   u32 reg;
+   u32 dft;
+
+   reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
+   dft = reg & DWC3_GFLADJ_30MHZ_MASK;
+   if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
+   "request value same as default, ignoring\n")) {
+   reg &= ~DWC3_GFLADJ_30MHZ_MASK;
+   reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
+   dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
+   }
+}
+
 /**
  * dwc3_free_one_event_buffer - Frees one event buffer
  * @dwc: Pointer to our controller context structure
@@ -779,6 +805,7 @@ static int dwc3_probe(struct platform_device *pdev)
u8  lpm_nyet_threshold;
u8  tx_de_emphasis;
u8  hird_threshold;
+   u32 fladj = 0;
 
int ret;
 
@@ -886,6 +913,9 @@ static int dwc3_probe(struct platform_device *pdev)
_de_emphasis);
of_property_read_string(node, "snps,hsphy_interface",
>hsphy_interface);
+   of_property_read_u32(node,
+"snps,quirk-frame-length-adjustment",
+);
} else if (pdata) {
dwc->maximum_speed = pdata->maximum_speed;
dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -915,6 +945,7 @@ static int dwc3_probe(struct platform_device *pdev)
tx_de_emphasis = pdata->tx_de_emphasis;
 
dwc->hsphy_interface = pdata->hsphy_interface;
+   fladj = pdata->fladj_value;
}
 
/* default to superspeed if no maximum_speed passed */
@@ -971,6 +1002,9 @@ static int dwc3_probe(struct platform_device *pdev)
goto err1;
}
 
+   /* Adjust Frame Length */
+   dwc3_frame_length_adjustment(dwc, fladj);
+
usb_phy_set_suspend(dwc->usb2_phy, 0);
usb_phy_set_suspend(dwc->usb3_phy, 0);
ret = phy_power_on(dwc->usb2_generic_phy);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 0447788..9188745 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -124,6 +124,7 @@
 #define DWC3_GEVNTCOUNT(n) (0xc40c + (n * 0x10))
 
 #define DWC3_GHWPARAMS80xc600
+#define DWC3_GFLADJ0xc630
 
 /* Device Registers */
 #define DWC3_DCFG  0xc700
@@ -234,6 +235,10 @@
 /* Global HWPARAMS6 Register */
 #define DWC3_GHWPARAMS6_EN_FPGA(1 << 7)
 
+/* Global Frame Length Adjustment Register */
+#define DWC3_GFLADJ_30MHZ_SDBND_SEL(1 << 7)
+#define DWC3_GFLADJ_30MHZ_MASK 0x3f
+
 /* Device Configuration Register */
 #define DWC3_DCFG_DEVADDR(addr)((addr) << 3)
 #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index d3614ec..400b197 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -46,5 +46,7 @@ struct dwc3_platform_data {
unsigned tx_de_emphasis_quirk:1;
unsigned tx_de_emphasis:2;
 
+   u32 fladj_value;
+
const char *hsphy_interface;
 };
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/