netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next-2.6] can: sja1000 platform data fixes
@ 2010-05-17 14:25 Wolfgang Grandegger
       [not found] ` <4BF151D2.5030906-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Grandegger @ 2010-05-17 14:25 UTC (permalink / raw)
  To: Netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: SocketCAN Core Mailing List, Marc Kleine-Budde

The member "clock" of struct "sja1000_platform_data" is documented as
"CAN bus oscillator frequency in Hz" but it's actually used as the CAN
clock frequency, which is half of it. To avoid further confusion, this
patch fixes it by renaming the member to "osc_freq". That way, also
non mainline users will notice the change. The platform code for the
relevant boards is updated accordingly. Furthermore, pre-defined
values are now used for the members "ocr" and "cdr".

Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
CC: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

diff --git a/arch/arm/mach-mx2/pcm970-baseboard.c b/arch/arm/mach-mx2/pcm970-baseboard.c
index 4aafd5b..f490a40 100644
--- a/arch/arm/mach-mx2/pcm970-baseboard.c
+++ b/arch/arm/mach-mx2/pcm970-baseboard.c
@@ -201,9 +201,9 @@ static struct resource pcm970_sja1000_resources[] = {
 };
 
 struct sja1000_platform_data pcm970_sja1000_platform_data = {
-	.clock		= 16000000 / 2,
-	.ocr		= 0x40 | 0x18,
-	.cdr		= 0x40,
+	.osc_freq	= 16000000,
+	.ocr		= OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
+	.cdr		= CDR_CBP,
 };
 
 static struct platform_device pcm970_sja1000 = {
diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c
index 2df1ec5..78ecd75 100644
--- a/arch/arm/mach-mx3/mach-pcm037.c
+++ b/arch/arm/mach-mx3/mach-pcm037.c
@@ -530,9 +530,9 @@ static struct resource pcm970_sja1000_resources[] = {
 };
 
 struct sja1000_platform_data pcm970_sja1000_platform_data = {
-	.clock		= 16000000 / 2,
-	.ocr		= 0x40 | 0x18,
-	.cdr		= 0x40,
+	.osc_freq	= 16000000,
+	.ocr		= OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
+	.cdr		= CDR_CBP,
 };
 
 static struct platform_device pcm970_sja1000 = {
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index b65cabb..d9fadc4 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -111,7 +111,8 @@ static int sp_probe(struct platform_device *pdev)
 	dev->irq = res_irq->start;
 	priv->irq_flags = res_irq->flags & (IRQF_TRIGGER_MASK | IRQF_SHARED);
 	priv->reg_base = addr;
-	priv->can.clock.freq = pdata->clock;
+	/* The CAN clock frequency is half the oscillator clock frequency */
+	priv->can.clock.freq = pdata->osc_freq / 2;
 	priv->ocr = pdata->ocr;
 	priv->cdr = pdata->cdr;
 
diff --git a/include/linux/can/platform/sja1000.h b/include/linux/can/platform/sja1000.h
index 01ee2ae..96f8fcc 100644
--- a/include/linux/can/platform/sja1000.h
+++ b/include/linux/can/platform/sja1000.h
@@ -26,7 +26,7 @@
 #define OCR_TX_SHIFT      2
 
 struct sja1000_platform_data {
-	u32 clock;	/* CAN bus oscillator frequency in Hz */
+	u32 osc_freq;	/* CAN bus oscillator frequency in Hz */
 
 	u8 ocr;		/* output control register */
 	u8 cdr;		/* clock divider register */

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

* Re: [PATCH net-next-2.6] can: sja1000 platform data fixes
       [not found] ` <4BF151D2.5030906-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
@ 2010-05-17 14:42   ` Marc Kleine-Budde
  2010-05-18  5:39     ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2010-05-17 14:42 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: SocketCAN Core Mailing List, Netdev-u79uwXL29TY76Z2rM5mHXA


[-- Attachment #1.1: Type: text/plain, Size: 3446 bytes --]

Wolfgang Grandegger wrote:
> The member "clock" of struct "sja1000_platform_data" is documented as
> "CAN bus oscillator frequency in Hz" but it's actually used as the CAN
> clock frequency, which is half of it. To avoid further confusion, this
> patch fixes it by renaming the member to "osc_freq". That way, also
> non mainline users will notice the change. The platform code for the
> relevant boards is updated accordingly. Furthermore, pre-defined
> values are now used for the members "ocr" and "cdr".
> 
> Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> CC: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Acked-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Cheers, Marc
> 
> diff --git a/arch/arm/mach-mx2/pcm970-baseboard.c b/arch/arm/mach-mx2/pcm970-baseboard.c
> index 4aafd5b..f490a40 100644
> --- a/arch/arm/mach-mx2/pcm970-baseboard.c
> +++ b/arch/arm/mach-mx2/pcm970-baseboard.c
> @@ -201,9 +201,9 @@ static struct resource pcm970_sja1000_resources[] = {
>  };
>  
>  struct sja1000_platform_data pcm970_sja1000_platform_data = {
> -	.clock		= 16000000 / 2,
> -	.ocr		= 0x40 | 0x18,
> -	.cdr		= 0x40,
> +	.osc_freq	= 16000000,
> +	.ocr		= OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
> +	.cdr		= CDR_CBP,
>  };
>  
>  static struct platform_device pcm970_sja1000 = {
> diff --git a/arch/arm/mach-mx3/mach-pcm037.c b/arch/arm/mach-mx3/mach-pcm037.c
> index 2df1ec5..78ecd75 100644
> --- a/arch/arm/mach-mx3/mach-pcm037.c
> +++ b/arch/arm/mach-mx3/mach-pcm037.c
> @@ -530,9 +530,9 @@ static struct resource pcm970_sja1000_resources[] = {
>  };
>  
>  struct sja1000_platform_data pcm970_sja1000_platform_data = {
> -	.clock		= 16000000 / 2,
> -	.ocr		= 0x40 | 0x18,
> -	.cdr		= 0x40,
> +	.osc_freq	= 16000000,
> +	.ocr		= OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
> +	.cdr		= CDR_CBP,
>  };
>  
>  static struct platform_device pcm970_sja1000 = {
> diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
> index b65cabb..d9fadc4 100644
> --- a/drivers/net/can/sja1000/sja1000_platform.c
> +++ b/drivers/net/can/sja1000/sja1000_platform.c
> @@ -111,7 +111,8 @@ static int sp_probe(struct platform_device *pdev)
>  	dev->irq = res_irq->start;
>  	priv->irq_flags = res_irq->flags & (IRQF_TRIGGER_MASK | IRQF_SHARED);
>  	priv->reg_base = addr;
> -	priv->can.clock.freq = pdata->clock;
> +	/* The CAN clock frequency is half the oscillator clock frequency */
> +	priv->can.clock.freq = pdata->osc_freq / 2;
>  	priv->ocr = pdata->ocr;
>  	priv->cdr = pdata->cdr;
>  
> diff --git a/include/linux/can/platform/sja1000.h b/include/linux/can/platform/sja1000.h
> index 01ee2ae..96f8fcc 100644
> --- a/include/linux/can/platform/sja1000.h
> +++ b/include/linux/can/platform/sja1000.h
> @@ -26,7 +26,7 @@
>  #define OCR_TX_SHIFT      2
>  
>  struct sja1000_platform_data {
> -	u32 clock;	/* CAN bus oscillator frequency in Hz */
> +	u32 osc_freq;	/* CAN bus oscillator frequency in Hz */
>  
>  	u8 ocr;		/* output control register */
>  	u8 cdr;		/* clock divider register */


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

[-- Attachment #2: Type: text/plain, Size: 188 bytes --]

_______________________________________________
Socketcan-core mailing list
Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
https://lists.berlios.de/mailman/listinfo/socketcan-core

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

* Re: [PATCH net-next-2.6] can: sja1000 platform data fixes
  2010-05-17 14:42   ` Marc Kleine-Budde
@ 2010-05-18  5:39     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-05-18  5:39 UTC (permalink / raw)
  To: mkl; +Cc: wg, Netdev, socketcan-core

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Mon, 17 May 2010 16:42:23 +0200

> Wolfgang Grandegger wrote:
>> The member "clock" of struct "sja1000_platform_data" is documented as
>> "CAN bus oscillator frequency in Hz" but it's actually used as the CAN
>> clock frequency, which is half of it. To avoid further confusion, this
>> patch fixes it by renaming the member to "osc_freq". That way, also
>> non mainline users will notice the change. The platform code for the
>> relevant boards is updated accordingly. Furthermore, pre-defined
>> values are now used for the members "ocr" and "cdr".
>> 
>> Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
>> CC: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>

Applied, thanks everyone.

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

end of thread, other threads:[~2010-05-18  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17 14:25 [PATCH net-next-2.6] can: sja1000 platform data fixes Wolfgang Grandegger
     [not found] ` <4BF151D2.5030906-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2010-05-17 14:42   ` Marc Kleine-Budde
2010-05-18  5:39     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).