All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
@ 2011-01-19 15:32 Fabio Estevam
  2011-01-19 15:36 ` Eric Bénard
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2011-01-19 15:32 UTC (permalink / raw)
  To: linux-arm-kernel

Instead of checking the CPU type in build-time, do it in run-time.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/usb/gadget/fsl_mxc_udc.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
index 77b1eb5..167abe0 100644
--- a/drivers/usb/gadget/fsl_mxc_udc.c
+++ b/drivers/usb/gadget/fsl_mxc_udc.c
@@ -88,17 +88,18 @@ eenahb:
 void fsl_udc_clk_finalize(struct platform_device *pdev)
 {
 	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
-#if defined(CONFIG_ARCH_MX35)
-	unsigned int v;
-
-	/* workaround ENGcm09152 for i.MX35 */
-	if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
-		v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
-				USBPHYCTRL_OTGBASE_OFFSET));
-		writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
-				USBPHYCTRL_OTGBASE_OFFSET));
-	}
-#endif
+	if (cpu_is_mx35()) {
+		unsigned int v;
+
+		/* workaround ENGcm09152 for i.MX35 */
+		if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
+			v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
+					USBPHYCTRL_OTGBASE_OFFSET));
+			writel(v | USBPHYCTRL_EVDO,
+				MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
+					USBPHYCTRL_OTGBASE_OFFSET));
+		}
+	}
 
 	/* ULPI transceivers don't need usbpll */
 	if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
  2011-01-19 15:32 [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time Fabio Estevam
@ 2011-01-19 15:36 ` Eric Bénard
  2011-01-19 16:08   ` Fabio Estevam
  2011-01-19 17:09   ` Fabio Estevam
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Bénard @ 2011-01-19 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Fabio,

On 19/01/2011 16:32, Fabio Estevam wrote:
> Instead of checking the CPU type in build-time, do it in run-time.
>
> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
> ---
>   drivers/usb/gadget/fsl_mxc_udc.c |   23 ++++++++++++-----------
>   1 files changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
> index 77b1eb5..167abe0 100644
> --- a/drivers/usb/gadget/fsl_mxc_udc.c
> +++ b/drivers/usb/gadget/fsl_mxc_udc.c
> @@ -88,17 +88,18 @@ eenahb:
>   void fsl_udc_clk_finalize(struct platform_device *pdev)
>   {
>   	struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
> -#if defined(CONFIG_ARCH_MX35)
> -	unsigned int v;
> -
> -	/* workaround ENGcm09152 for i.MX35 */
> -	if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
> -		v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> -				USBPHYCTRL_OTGBASE_OFFSET));
> -		writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> -				USBPHYCTRL_OTGBASE_OFFSET));
> -	}
> -#endif
> +	if (cpu_is_mx35()) {
> +		unsigned int v;
> +
> +		/* workaround ENGcm09152 for i.MX35 */
> +		if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
> +			v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> +					USBPHYCTRL_OTGBASE_OFFSET));
> +			writel(v | USBPHYCTRL_EVDO,
> +				MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> +					USBPHYCTRL_OTGBASE_OFFSET));
> +		}
> +	}
>
are you sure this compiles when MX35 is not selected ?

Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
  2011-01-19 15:36 ` Eric Bénard
@ 2011-01-19 16:08   ` Fabio Estevam
  2011-01-19 17:09   ` Fabio Estevam
  1 sibling, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2011-01-19 16:08 UTC (permalink / raw)
  To: linux-arm-kernel

On 1/19/2011 1:36 PM, Eric B?nard wrote:
...

> are you sure this compiles when MX35 is not selected ?

You?re right. Doesn?t build when I tried a mx5 kernel.

We can?t use this approach then.

Thanks,

Fabio Estevam
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
  2011-01-19 15:36 ` Eric Bénard
  2011-01-19 16:08   ` Fabio Estevam
@ 2011-01-19 17:09   ` Fabio Estevam
  2011-01-19 18:54     ` Uwe Kleine-König
  1 sibling, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2011-01-19 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

On 1/19/2011 1:36 PM, Eric B?nard wrote:
> Hi Fabio,
> 
> On 19/01/2011 16:32, Fabio Estevam wrote:
>> Instead of checking the CPU type in build-time, do it in run-time.
>>
>> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
>> ---
>>   drivers/usb/gadget/fsl_mxc_udc.c |   23 ++++++++++++-----------
>>   1 files changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
>> index 77b1eb5..167abe0 100644
>> --- a/drivers/usb/gadget/fsl_mxc_udc.c
>> +++ b/drivers/usb/gadget/fsl_mxc_udc.c
>> @@ -88,17 +88,18 @@ eenahb:
>>   void fsl_udc_clk_finalize(struct platform_device *pdev)
>>   {
>>       struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
>> -#if defined(CONFIG_ARCH_MX35)
>> -    unsigned int v;
>> -
>> -    /* workaround ENGcm09152 for i.MX35 */
>> -    if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
>> -        v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> -                USBPHYCTRL_OTGBASE_OFFSET));
>> -        writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> -                USBPHYCTRL_OTGBASE_OFFSET));
>> -    }
>> -#endif
>> +    if (cpu_is_mx35()) {
>> +        unsigned int v;
>> +
>> +        /* workaround ENGcm09152 for i.MX35 */
>> +        if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
>> +            v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> +                    USBPHYCTRL_OTGBASE_OFFSET));
>> +            writel(v | USBPHYCTRL_EVDO,
>> +                MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> +                    USBPHYCTRL_OTGBASE_OFFSET));
>> +        }
>> +    }
>>
> are you sure this compiles when MX35 is not selected ?

Including #include <mach/mx35.h> fixes the build for a non- mx35 kernel.

Would this be acceptable? If so, I can send v2.

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
  2011-01-19 17:09   ` Fabio Estevam
@ 2011-01-19 18:54     ` Uwe Kleine-König
  2011-01-19 20:07       ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2011-01-19 18:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 19, 2011 at 03:09:15PM -0200, Fabio Estevam wrote:
> On 1/19/2011 1:36 PM, Eric B?nard wrote:
> > Hi Fabio,
> > 
> > On 19/01/2011 16:32, Fabio Estevam wrote:
> >> Instead of checking the CPU type in build-time, do it in run-time.
> >>
> >> Signed-off-by: Fabio Estevam<fabio.estevam@freescale.com>
> >> ---
> >>   drivers/usb/gadget/fsl_mxc_udc.c |   23 ++++++++++++-----------
> >>   1 files changed, 12 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c
> >> index 77b1eb5..167abe0 100644
> >> --- a/drivers/usb/gadget/fsl_mxc_udc.c
> >> +++ b/drivers/usb/gadget/fsl_mxc_udc.c
> >> @@ -88,17 +88,18 @@ eenahb:
> >>   void fsl_udc_clk_finalize(struct platform_device *pdev)
> >>   {
> >>       struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
> >> -#if defined(CONFIG_ARCH_MX35)
> >> -    unsigned int v;
> >> -
> >> -    /* workaround ENGcm09152 for i.MX35 */
> >> -    if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
> >> -        v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> >> -                USBPHYCTRL_OTGBASE_OFFSET));
> >> -        writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> >> -                USBPHYCTRL_OTGBASE_OFFSET));
> >> -    }
> >> -#endif
> >> +    if (cpu_is_mx35()) {
> >> +        unsigned int v;
> >> +
> >> +        /* workaround ENGcm09152 for i.MX35 */
> >> +        if (pdata->workaround&  FLS_USB2_WORKAROUND_ENGCM09152) {
can you please fix up the position of the '&'?

> >> +            v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> >> +                    USBPHYCTRL_OTGBASE_OFFSET));
> >> +            writel(v | USBPHYCTRL_EVDO,
> >> +                MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
> >> +                    USBPHYCTRL_OTGBASE_OFFSET));
I wonder if the address isn't mapped via ioremap in the driver and the
cookie saved somewhere?  (And no, I don't ask you to change that in this
patch.)  (If so, it this already problematic aliasing?)

> >> +        }
> >> +    }
> >>
> > are you sure this compiles when MX35 is not selected ?
> 
> Including #include <mach/mx35.h> fixes the build for a non- mx35 kernel.
> 
> Would this be acceptable? If so, I can send v2.
If you keep the #if defined(CONFIG_ARCH_MX35) and only add the if
(cpu_is_mx35()) it should work without a new #include.
Doing that seems a tad cleaner to me.

Best regards
Uwe 

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time
  2011-01-19 18:54     ` Uwe Kleine-König
@ 2011-01-19 20:07       ` Fabio Estevam
  0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2011-01-19 20:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Uwe,

On Wed, Jan 19, 2011 at 4:54 PM, Uwe Kleine-K?nig
<u.kleine-koenig@pengutronix.de> wrote:
...
> can you please fix up the position of the '&'?

The original patch had the '&' in the correct position. Looks like it
got shifted on some of the replies.

>
>> >> + ? ? ? ? ? ?v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> >> + ? ? ? ? ? ? ? ? ? ?USBPHYCTRL_OTGBASE_OFFSET));
>> >> + ? ? ? ? ? ?writel(v | USBPHYCTRL_EVDO,
>> >> + ? ? ? ? ? ? ? ?MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
>> >> + ? ? ? ? ? ? ? ? ? ?USBPHYCTRL_OTGBASE_OFFSET));
> I wonder if the address isn't mapped via ioremap in the driver and the
> cookie saved somewhere? ?(And no, I don't ask you to change that in this
> patch.) ?(If so, it this already problematic aliasing?)

This address is only used once here and it is related to the MX35 USB erratum.

>
>> >> + ? ? ? ?}
>> >> + ? ?}
>> >>
>> > are you sure this compiles when MX35 is not selected ?
>>
>> Including #include <mach/mx35.h> fixes the build for a non- mx35 kernel.
>>
>> Would this be acceptable? If so, I can send v2.
> If you keep the #if defined(CONFIG_ARCH_MX35) and only add the if
> (cpu_is_mx35()) it should work without a new #include.
> Doing that seems a tad cleaner to me.

Ok, will do as suggested in v2.

Thanks,

Fabio Estevam

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-19 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 15:32 [PATCH] usb: gadget/fsl_mxc_udc: Detect the CPU type in run-time Fabio Estevam
2011-01-19 15:36 ` Eric Bénard
2011-01-19 16:08   ` Fabio Estevam
2011-01-19 17:09   ` Fabio Estevam
2011-01-19 18:54     ` Uwe Kleine-König
2011-01-19 20:07       ` Fabio Estevam

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.