Netdev List
 help / color / mirror / Atom feed
* RE: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: U Bhaskar-B22300 @ 2011-08-09 12:41 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Marc Kleine-Budde
In-Reply-To: <4E41108F.1090104-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>



> -----Original Message-----
> From: Wolfgang Grandegger [mailto:wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org]
> Sent: Tuesday, August 09, 2011 4:19 PM
> To: U Bhaskar-B22300
> Cc: Marc Kleine-Budde; socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org;
> netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> 
> On 08/09/2011 11:27 AM, U Bhaskar-B22300 wrote:
> >
> >
> >> -----Original Message-----
> >> From: Wolfgang Grandegger [mailto:wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org]
> >> Sent: Tuesday, August 09, 2011 2:03 PM
> >> To: U Bhaskar-B22300
> >> Cc: Marc Kleine-Budde; socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org;
> >> netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> >> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> >>
> >> Hi Bhaskar,
> >>
> >> On 08/09/2011 09:57 AM, U Bhaskar-B22300 wrote:
> >>>
> >>>
> >>>> -----Original Message-----
> >>>> From: Marc Kleine-Budde [mailto:mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org]
> >>>> Sent: Tuesday, August 09, 2011 12:23 AM
> >>>> To: Wolfgang Grandegger
> >>>> Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org; netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; U
> >>>> Bhaskar- B22300
> >>>> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> >>>>
> >>>> On 08/08/2011 05:33 PM, Wolfgang Grandegger wrote:
> >>>>>> ACK - The device tree bindings as in mainline's Documentation is
> >>>>>> a
> >>>> mess.
> >>>>>> If the powerpc guys are happy with a clock interfaces based
> >>>>>> approach somewhere in arch/ppc, I'm more than happy to remove:
> >>>>>> - fsl,flexcan-clock-source (not implemented, even in the fsl
> >>>>>> driver)
> >>> [Bhaskar]I have pushed the FlexCAN series of patches, It contains
> >>> the usage of all the fields posted in the FlexCAN bindings at
> >>> http://git.kernel.org/?p=linux/kernel/git/stable/linux-3.0.y.git;a=b
> >>> lo
> >>> b;f=Documentation/devicetree/bindings/net/can/fsl-flexcan.txt;h=1a72
> >>> 9f
> >>> 089866259ef82d0db5893ff7a8c54d5ccf;hb=94ed5b4788a7cdbe68bc7cb8516972
> >>> cb
> >>> ebdc8274
> >>
> >> As Marc already pointed out, Robin already has a much more advanced
> >> patch stack in preparation. Especially your patches do not care about
> >> the already existing Flexcan core on the Freescale's ARM socks.
> > [Bhaskar] No, the patches are taking care of the existing ARM
> functionality.
> > 	I have not tested on the ARM based board, but the patches are made
> in a
> >       Manner that it should not break the ARM based functionality.
> >>
> >>>>>>
> >>>>>> - fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
> >>>>>> - clock-frequency           /   a single clock-frequency attribute
> >>>>>
> >>>>> In the "net-next-2.6" tree there is also:
> >>>>>
> >>>>>  $ grep flexcan arch/powerpc/boots/dts/*.dts
> >>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> >> "platform";
> >>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> >> "platform";
> >>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>>>
> >>>>> Especially the fsl,flexcan-clock-divider = <2>; might make people
> >>>>> think, that they could set something else.
> >>>>
> >>> [Bhaskar] As it is mentioned in the Flexcan bindings, the need of
> >> fsl,flexcan-clock-divider = <2>;
> >>> 	    But I kept it as "2" because FlexCan clock source is the
> >> platform clock and it is CCB/2
> >>> 	    If the "2" is misleading, the bindings can be changed or some
> >> text can be written to make the meaning of "2"
> >>>           Understandable , Please suggest ..
> >>
> >> The clock source and frequency is fixed. Why do we need an extra
> >> properties for that. We have panned to remove these bogus bindings
> >> from the Linux kernel, which sneaked in *without* any review on the
> >> relevant mailing lists (at least I have not realized any posting). We
> >> do not think they are really needed. They just confuse the user. We
> >> also prefer to use the compatibility string "fsl,flexcan" instead
> >> "fsl,flexcan-v1.0". It's unusual to add a version number, which is
> >> for the Flexcan on the PowerPC cores only, I assume, but there will
> >> be device tree for ARM soon. A proper compatibility string would be
> >> "fsl,p1010-flexcan" if we really need to distinguish.
> >>
> > [Bhaskar] About clock source.. There can be two sources of clock for
> the CAN.
> > 	Oscillator or the platform clock, but at present only platform
> clock is supported
> > 	in P1010.If we remove the fsl,flexcan-clock-source property, we
> will lost the flexibility
> > 	of changing the clock source ..
> >
> >           About clock-frequency... it is also not fixed. It depends on
> the platform clock which in turns
> >           Depends on the CCB clock. So it will be better to keep clock-
> frequency property which is getting fixed via u-boot.
> 
> The frequency is fixed to CCB-frequency / 2. Will that ever change? What
> can we expect from future Flexcan hardware? Will it support further clock
> sources?
[Bhaskar] Yes the frequency will always be CCB-frequency/2.Even if the CCB gets changed that will be taken care by the u-boot fixup code for
	clock-frequency. clock-frequency is not filled by somebody in the dts file. It will be done by u-boot.
	For clock source,I can't say right now, that's why I have kept a property for this in the can node. So that in future, we need to fill it 
	appropriately
> 
> Wolfgang.

^ permalink raw reply

* Re: [RFC 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Robin Holt @ 2011-08-09 12:40 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w, PPC list,
	Wolfgang Grandegger
In-Reply-To: <4E41291B.3020001-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

On Tue, Aug 09, 2011 at 02:33:31PM +0200, Marc Kleine-Budde wrote:
> On 08/09/2011 07:55 AM, Robin Holt wrote:
> > I added a clock source for the p1010rdb so the flexcan driver
> > could find its clock frequency.
> > 
> > Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
> > To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
> > To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>,
> > To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> > Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
> > Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
> > Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
> 
> After fixing Wolfgangs remarks add by Acked-by, for what it's worth in
> the ppc-world :)

Does that go for the other two patches in the series you have not
commented on in many revs as well?

Robin

^ permalink raw reply

* Re: [PATCH 12/12] headers, ppp: Add missing #include to <linux/if_ppp.h>
From: Ben Hutchings @ 2011-08-09 12:40 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, paulus, linux-ppp
In-Reply-To: <20110809.002738.679747111943821641.davem@davemloft.net>

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]

On Tue, 2011-08-09 at 00:27 -0700, David Miller wrote:
> From: Ben Hutchings <ben@decadent.org.uk>
> Date: Mon, 08 Aug 2011 14:25:19 +0100
> 
> > <linux/if_ppp.h> uses various types defined in <linux/ppp_defs.h>.
> > 
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> 
> Unfortunately there is a "net/if_ppp.h" provided by glibc that
> includes "net/ppp_defs.h", and all of this is presumably in order
> to discourage direct use of the kernel headers.
> 
> Even though net/ppp_defs.h ends up including linux/ppp_defs.h
> anyways.
> 
> Whilst I think your efforts are to be commended, we can't start doing
> or else we'll start breaking the build in various unexpected ways.
> 
> The SIOCDEVPRIVATE (defined by GLIBC in bits/ioctls.h) case is just
> one such example.

I did try to check for these cases, but obviously missed some.  I'll
re-post the series without these ones.

In the longer term I would really like to solve this mess somehow.
glibc is obviously duplicating a lot of definitions in different headers
(but tends to lag behind a little) and other C libraries may also have
to duplicate that work for compatibility.  Some kernel headers already
*do* include headers such as <linux/if.h> that can conflict with C
library headers, sometimes requiring userland to work around the
conflict somehow.

Ben.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply

* Re: [RFC 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Marc Kleine-Budde @ 2011-08-09 12:33 UTC (permalink / raw)
  To: Robin Holt
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300, PPC list,
	Wolfgang Grandegger
In-Reply-To: <1312869313-22434-5-git-send-email-holt-sJ/iWh9BUns@public.gmane.org>


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

On 08/09/2011 07:55 AM, Robin Holt wrote:
> I added a clock source for the p1010rdb so the flexcan driver
> could find its clock frequency.
> 
> Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
> To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
> To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>,
> To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
> Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>

After fixing Wolfgangs remarks add by Acked-by, for what it's worth in
the ppc-world :)

Some nitpicking from me :) - Darn you send another patch. This comments
still apply.

> 
> ---
> 
> Could I also get a ruling on the Kconfig language.  I could do it either
> with the 85xx_HAVE_CAN_FLEXCAN in or out of the Kconfig file.  It felt
> like the right thing to do was without, but the arm Kconfig files do
> it this way and a patch from freescale had something similar so I went
> this route.
> 
>  arch/powerpc/platforms/85xx/Kconfig    |    6 +++
>  arch/powerpc/platforms/85xx/Makefile   |    1 +
>  arch/powerpc/platforms/85xx/clock.c    |   59 ++++++++++++++++++++++++++++++++
>  arch/powerpc/platforms/85xx/p1010rdb.c |    8 ++++
>  4 files changed, 74 insertions(+), 0 deletions(-)
>  create mode 100644 arch/powerpc/platforms/85xx/clock.c
> 
> diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
> index 498534c..ed4cf92 100644
> --- a/arch/powerpc/platforms/85xx/Kconfig
> +++ b/arch/powerpc/platforms/85xx/Kconfig
> @@ -26,6 +26,10 @@ config MPC8560_ADS
>  	help
>  	  This option enables support for the MPC 8560 ADS board
>  
> +config 85xx_HAVE_CAN_FLEXCAN
> +	bool
> +	select HAVE_CAN_FLEXCAN if NET && CAN
> +
>  config MPC85xx_CDS
>  	bool "Freescale MPC85xx CDS"
>  	select DEFAULT_UIMAGE
> @@ -70,6 +74,8 @@ config MPC85xx_RDB
>  config P1010_RDB
>  	bool "Freescale P1010RDB"
>  	select DEFAULT_UIMAGE
> +	select 85xx_HAVE_CAN_FLEXCAN
> +	select PPC_CLOCK if CAN_FLEXCAN
>  	help
>  	  This option enables support for the MPC85xx RDB (P1010 RDB) board
>  
> diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
> index a971b32..64ad7a4 100644
> --- a/arch/powerpc/platforms/85xx/Makefile
> +++ b/arch/powerpc/platforms/85xx/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_MPC85xx_DS)  += mpc85xx_ds.o
>  obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
>  obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
>  obj-$(CONFIG_P1010_RDB)   += p1010rdb.o
> +obj-$(CONFIG_PPC_CLOCK)   += clock.o
>  obj-$(CONFIG_P1022_DS)    += p1022_ds.o
>  obj-$(CONFIG_P1023_RDS)   += p1023_rds.o
>  obj-$(CONFIG_P2040_RDB)   += p2040_rdb.o corenet_ds.o
> diff --git a/arch/powerpc/platforms/85xx/clock.c b/arch/powerpc/platforms/85xx/clock.c
> new file mode 100644
> index 0000000..a25cbf3
> --- /dev/null
> +++ b/arch/powerpc/platforms/85xx/clock.c
> @@ -0,0 +1,59 @@

Please add your copyright notice and add a license, e.g. "This file is
released under GPLv2"

> +
> +#include <linux/device.h>
> +#include <linux/err.h>
> +
> +#include <asm/clk_interface.h>
> +
> +#include <sysdev/fsl_soc.h>
> +
> +/*
> + * p1010rdb needs to provide a clock source for the flexcan driver.
> + */
> +struct clk {
> +	unsigned long rate;
> +} p1010_rdb_system_clock;
> +
> +static struct clk *p1010_rdb_clk_get(struct device *dev, const char *id)
> +{
> +	const char *dev_init_name;
> +
> +	if (!dev)
> +		return ERR_PTR(-ENOENT);
> +
> +	/*
> +	 * The can devices are named ffe1c000.can0 and ffe1d000.can1 on
> +	 * the p1010rdb.  Check for the "can" portion of that name before
> +	 * returning a clock source.
> +	 */
> +	dev_init_name = dev_name(dev);
> +	if (strlen(dev_init_name) != 13)
> +		return ERR_PTR(-ENOENT);
> +	dev_init_name += 9;
> +	if (strncmp(dev_init_name, "can", 3))
> +		return ERR_PTR(-ENOENT);
> +
> +	return &p1010_rdb_system_clock;
> +}
> +
> +static void p1010_rdb_clk_put(struct clk *clk)
> +{
> +	return;
> +}
> +
> +static unsigned long p1010_rdb_clk_get_rate(struct clk *clk)
> +{
> +	return clk->rate;
> +}
> +
> +static struct clk_interface p1010_rdb_clk_functions = {
> +	.clk_get		= p1010_rdb_clk_get,
> +	.clk_get_rate		= p1010_rdb_clk_get_rate,
> +	.clk_put		= p1010_rdb_clk_put,

no indention here please, just one space before the "=". YMMV

> +};
> +
> +void __init p1010_rdb_clk_init(void)
> +{
> +	p1010_rdb_system_clock.rate = fsl_get_sys_freq();
> +	clk_functions = p1010_rdb_clk_functions;
> +}
> +
> diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
> index d7387fa..29e04d6 100644
> --- a/arch/powerpc/platforms/85xx/p1010rdb.c
> +++ b/arch/powerpc/platforms/85xx/p1010rdb.c
> @@ -81,6 +81,13 @@ static void __init p1010_rdb_setup_arch(void)
>  	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
>  }
>  
> +static void __init p1010_rdb_init(void)
> +{
> +#ifdef PPC_CLOCK
> +	p1010_rdb_clk_init();
> +#endif
> +}
> +
>  static struct of_device_id __initdata p1010rdb_ids[] = {
>  	{ .type = "soc", },
>  	{ .compatible = "soc", },
> @@ -111,6 +118,7 @@ define_machine(p1010_rdb) {
>  	.name			= "P1010 RDB",
>  	.probe			= p1010_rdb_probe,
>  	.setup_arch		= p1010_rdb_setup_arch,
> +	.init			= p1010_rdb_init,
>  	.init_IRQ		= p1010_rdb_pic_init,
>  #ifdef CONFIG_PCI
>  	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,

cheers, Marc

-- 
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: 262 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

* [PATCH 2/4] [flexcan] Abstract off read/write for big/little endian.
From: Robin Holt @ 2011-08-09 12:28 UTC (permalink / raw)
  To: Robin Holt, Marc Kleine-Budde, Wolfgang Grandegger,
	U Bhaskar-B22300
  Cc: Robin Holt, Marc Kleine-Budde, socketcan-core, netdev, PPC list
In-Reply-To: <1312892907-20419-1-git-send-email-holt@sgi.com>

Make flexcan driver handle register reads in the appropriate endianess.
This was a basic search and replace and then define some inlines.

Signed-off-by: Robin Holt <holt@sgi.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
To: Wolfgang Grandegger <wg@grandegger.com>
To: U Bhaskar-B22300 <B22300@freescale.com>
Cc: socketcan-core@lists.berlios.de
Cc: netdev@vger.kernel.org
Cc: PPC list <linuxppc-dev@lists.ozlabs.org>
---
 drivers/net/can/flexcan.c |  140 ++++++++++++++++++++++++++------------------
 1 files changed, 83 insertions(+), 57 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 586b2cd..68cbe52 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -190,6 +190,31 @@ static struct can_bittiming_const flexcan_bittiming_const = {
 };
 
 /*
+ * Abstract off the read/write for arm versus ppc.
+ */
+#if defined(__BIG_ENDIAN)
+static inline u32 flexcan_read(void __iomem *addr)
+{
+	return in_be32(addr);
+}
+
+static inline void flexcan_write(u32 val, void __iomem *addr)
+{
+	out_be32(addr, val);
+}
+#else
+static inline u32 flexcan_read(void __iomem *addr)
+{
+	return readl(addr);
+}
+
+static inline void flexcan_write(u32 val, void __iomem *addr)
+{
+	writel(val, addr);
+}
+#endif
+
+/*
  * Swtich transceiver on or off
  */
 static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on)
@@ -210,9 +235,9 @@ static inline void flexcan_chip_enable(struct flexcan_priv *priv)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg &= ~FLEXCAN_MCR_MDIS;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 
 	udelay(10);
 }
@@ -222,9 +247,9 @@ static inline void flexcan_chip_disable(struct flexcan_priv *priv)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_MDIS;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 }
 
 static int flexcan_get_berr_counter(const struct net_device *dev,
@@ -232,7 +257,7 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
 {
 	const struct flexcan_priv *priv = netdev_priv(dev);
 	struct flexcan_regs __iomem *regs = priv->base;
-	u32 reg = readl(&regs->ecr);
+	u32 reg = flexcan_read(&regs->ecr);
 
 	bec->txerr = (reg >> 0) & 0xff;
 	bec->rxerr = (reg >> 8) & 0xff;
@@ -266,15 +291,15 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	if (cf->can_dlc > 0) {
 		u32 data = be32_to_cpup((__be32 *)&cf->data[0]);
-		writel(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
+		flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
 	}
 	if (cf->can_dlc > 3) {
 		u32 data = be32_to_cpup((__be32 *)&cf->data[4]);
-		writel(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
+		flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
 	}
 
-	writel(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
-	writel(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
+	flexcan_write(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
+	flexcan_write(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
 
 	kfree_skb(skb);
 
@@ -462,8 +487,8 @@ static void flexcan_read_fifo(const struct net_device *dev,
 	struct flexcan_mb __iomem *mb = &regs->cantxfg[0];
 	u32 reg_ctrl, reg_id;
 
-	reg_ctrl = readl(&mb->can_ctrl);
-	reg_id = readl(&mb->can_id);
+	reg_ctrl = flexcan_read(&mb->can_ctrl);
+	reg_id = flexcan_read(&mb->can_id);
 	if (reg_ctrl & FLEXCAN_MB_CNT_IDE)
 		cf->can_id = ((reg_id >> 0) & CAN_EFF_MASK) | CAN_EFF_FLAG;
 	else
@@ -473,12 +498,12 @@ static void flexcan_read_fifo(const struct net_device *dev,
 		cf->can_id |= CAN_RTR_FLAG;
 	cf->can_dlc = get_can_dlc((reg_ctrl >> 16) & 0xf);
 
-	*(__be32 *)(cf->data + 0) = cpu_to_be32(readl(&mb->data[0]));
-	*(__be32 *)(cf->data + 4) = cpu_to_be32(readl(&mb->data[1]));
+	*(__be32 *)(cf->data + 0) = cpu_to_be32(flexcan_read(&mb->data[0]));
+	*(__be32 *)(cf->data + 4) = cpu_to_be32(flexcan_read(&mb->data[1]));
 
 	/* mark as read */
-	writel(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->iflag1);
-	readl(&regs->timer);
+	flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->iflag1);
+	flexcan_read(&regs->timer);
 }
 
 static int flexcan_read_frame(struct net_device *dev)
@@ -514,17 +539,17 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
 	 * The error bits are cleared on read,
 	 * use saved value from irq handler.
 	 */
-	reg_esr = readl(&regs->esr) | priv->reg_esr;
+	reg_esr = flexcan_read(&regs->esr) | priv->reg_esr;
 
 	/* handle state changes */
 	work_done += flexcan_poll_state(dev, reg_esr);
 
 	/* handle RX-FIFO */
-	reg_iflag1 = readl(&regs->iflag1);
+	reg_iflag1 = flexcan_read(&regs->iflag1);
 	while (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE &&
 	       work_done < quota) {
 		work_done += flexcan_read_frame(dev);
-		reg_iflag1 = readl(&regs->iflag1);
+		reg_iflag1 = flexcan_read(&regs->iflag1);
 	}
 
 	/* report bus errors */
@@ -534,8 +559,8 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
 	if (work_done < quota) {
 		napi_complete(napi);
 		/* enable IRQs */
-		writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
-		writel(priv->reg_ctrl_default, &regs->ctrl);
+		flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
+		flexcan_write(priv->reg_ctrl_default, &regs->ctrl);
 	}
 
 	return work_done;
@@ -549,9 +574,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg_iflag1, reg_esr;
 
-	reg_iflag1 = readl(&regs->iflag1);
-	reg_esr = readl(&regs->esr);
-	writel(FLEXCAN_ESR_ERR_INT, &regs->esr);	/* ACK err IRQ */
+	reg_iflag1 = flexcan_read(&regs->iflag1);
+	reg_esr = flexcan_read(&regs->esr);
+	flexcan_write(FLEXCAN_ESR_ERR_INT, &regs->esr);	/* ACK err IRQ */
 
 	/*
 	 * schedule NAPI in case of:
@@ -567,16 +592,16 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
 		 * save them for later use.
 		 */
 		priv->reg_esr = reg_esr & FLEXCAN_ESR_ERR_BUS;
-		writel(FLEXCAN_IFLAG_DEFAULT & ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE,
-		       &regs->imask1);
-		writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
+		flexcan_write(FLEXCAN_IFLAG_DEFAULT &
+			~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->imask1);
+		flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
 		       &regs->ctrl);
 		napi_schedule(&priv->napi);
 	}
 
 	/* FIFO overflow */
 	if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
-		writel(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, &regs->iflag1);
+		flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, &regs->iflag1);
 		dev->stats.rx_over_errors++;
 		dev->stats.rx_errors++;
 	}
@@ -585,7 +610,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
 	if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) {
 		/* tx_bytes is incremented in flexcan_start_xmit */
 		stats->tx_packets++;
-		writel((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
+		flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
 		netif_wake_queue(dev);
 	}
 
@@ -599,7 +624,7 @@ static void flexcan_set_bittiming(struct net_device *dev)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->ctrl);
+	reg = flexcan_read(&regs->ctrl);
 	reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
 		 FLEXCAN_CTRL_RJW(0x3) |
 		 FLEXCAN_CTRL_PSEG1(0x7) |
@@ -623,11 +648,11 @@ static void flexcan_set_bittiming(struct net_device *dev)
 		reg |= FLEXCAN_CTRL_SMP;
 
 	dev_info(dev->dev.parent, "writing ctrl=0x%08x\n", reg);
-	writel(reg, &regs->ctrl);
+	flexcan_write(reg, &regs->ctrl);
 
 	/* print chip status */
 	dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
-		readl(&regs->mcr), readl(&regs->ctrl));
+		flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
 }
 
 /*
@@ -648,10 +673,10 @@ static int flexcan_chip_start(struct net_device *dev)
 	flexcan_chip_enable(priv);
 
 	/* soft reset */
-	writel(FLEXCAN_MCR_SOFTRST, &regs->mcr);
+	flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
 	udelay(10);
 
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->mcr);
 	if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
 		dev_err(dev->dev.parent,
 			"Failed to softreset can module (mcr=0x%08x)\n",
@@ -673,12 +698,12 @@ static int flexcan_chip_start(struct net_device *dev)
 	 * choose format C
 	 *
 	 */
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->mcr);
 	reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
 		FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
 		FLEXCAN_MCR_IDAM_C;
 	dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr);
-	writel(reg_mcr, &regs->mcr);
+	flexcan_write(reg_mcr, &regs->mcr);
 
 	/*
 	 * CTRL
@@ -696,7 +721,7 @@ static int flexcan_chip_start(struct net_device *dev)
 	 * (FLEXCAN_CTRL_ERR_MSK), too. Otherwise we don't get any
 	 * warning or bus passive interrupts.
 	 */
-	reg_ctrl = readl(&regs->ctrl);
+	reg_ctrl = flexcan_read(&regs->ctrl);
 	reg_ctrl &= ~FLEXCAN_CTRL_TSYN;
 	reg_ctrl |= FLEXCAN_CTRL_BOFF_REC | FLEXCAN_CTRL_LBUF |
 		FLEXCAN_CTRL_ERR_STATE | FLEXCAN_CTRL_ERR_MSK;
@@ -704,38 +729,39 @@ static int flexcan_chip_start(struct net_device *dev)
 	/* save for later use */
 	priv->reg_ctrl_default = reg_ctrl;
 	dev_dbg(dev->dev.parent, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
-	writel(reg_ctrl, &regs->ctrl);
+	flexcan_write(reg_ctrl, &regs->ctrl);
 
 	for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
-		writel(0, &regs->cantxfg[i].can_ctrl);
-		writel(0, &regs->cantxfg[i].can_id);
-		writel(0, &regs->cantxfg[i].data[0]);
-		writel(0, &regs->cantxfg[i].data[1]);
+		flexcan_write(0, &regs->cantxfg[i].can_ctrl);
+		flexcan_write(0, &regs->cantxfg[i].can_id);
+		flexcan_write(0, &regs->cantxfg[i].data[0]);
+		flexcan_write(0, &regs->cantxfg[i].data[1]);
 
 		/* put MB into rx queue */
-		writel(FLEXCAN_MB_CNT_CODE(0x4), &regs->cantxfg[i].can_ctrl);
+		flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
+			&regs->cantxfg[i].can_ctrl);
 	}
 
 	/* acceptance mask/acceptance code (accept everything) */
-	writel(0x0, &regs->rxgmask);
-	writel(0x0, &regs->rx14mask);
-	writel(0x0, &regs->rx15mask);
+	flexcan_write(0x0, &regs->rxgmask);
+	flexcan_write(0x0, &regs->rx14mask);
+	flexcan_write(0x0, &regs->rx15mask);
 
 	flexcan_transceiver_switch(priv, 1);
 
 	/* synchronize with the can bus */
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->mcr);
 	reg_mcr &= ~FLEXCAN_MCR_HALT;
-	writel(reg_mcr, &regs->mcr);
+	flexcan_write(reg_mcr, &regs->mcr);
 
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
 
 	/* enable FIFO interrupts */
-	writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
+	flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
 
 	/* print chip status */
 	dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n",
-		__func__, readl(&regs->mcr), readl(&regs->ctrl));
+		__func__, flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
 
 	return 0;
 
@@ -757,12 +783,12 @@ static void flexcan_chip_stop(struct net_device *dev)
 	u32 reg;
 
 	/* Disable all interrupts */
-	writel(0, &regs->imask1);
+	flexcan_write(0, &regs->imask1);
 
 	/* Disable + halt module */
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 
 	flexcan_transceiver_switch(priv, 0);
 	priv->can.state = CAN_STATE_STOPPED;
@@ -854,24 +880,24 @@ static int __devinit register_flexcandev(struct net_device *dev)
 
 	/* select "bus clock", chip must be disabled */
 	flexcan_chip_disable(priv);
-	reg = readl(&regs->ctrl);
+	reg = flexcan_read(&regs->ctrl);
 	reg |= FLEXCAN_CTRL_CLK_SRC;
-	writel(reg, &regs->ctrl);
+	flexcan_write(reg, &regs->ctrl);
 
 	flexcan_chip_enable(priv);
 
 	/* set freeze, halt and activate FIFO, restrict register access */
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
 		FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 
 	/*
 	 * Currently we only support newer versions of this core
 	 * featuring a RX FIFO. Older cores found on some Coldfire
 	 * derivates are not yet supported.
 	 */
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	if (!(reg & FLEXCAN_MCR_FEN)) {
 		dev_err(dev->dev.parent,
 			"Could not enable RX FIFO, unsupported core\n");
-- 
1.7.2.1


^ permalink raw reply related

* [PATCH 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Robin Holt @ 2011-08-09 12:28 UTC (permalink / raw)
  To: Robin Holt, Marc Kleine-Budde, Wolfgang Grandegger,
	U Bhaskar-B22300
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, , PPC list,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1312892907-20419-1-git-send-email-holt-sJ/iWh9BUns@public.gmane.org>

I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 can device only has an
oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>,
To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
---
 arch/powerpc/platforms/85xx/Kconfig    |    2 +
 arch/powerpc/platforms/85xx/Makefile   |    2 +
 arch/powerpc/platforms/85xx/clock.c    |   42 ++++++++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/p1010rdb.c |    8 ++++++
 4 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/85xx/clock.c

diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index 498534c..c4304ae 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -70,6 +70,8 @@ config MPC85xx_RDB
 config P1010_RDB
 	bool "Freescale P1010RDB"
 	select DEFAULT_UIMAGE
+	select HAVE_CAN_FLEXCAN if NET && CAN
+	select PPC_CLOCK if CAN_FLEXCAN
 	help
 	  This option enables support for the MPC85xx RDB (P1010 RDB) board
 
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index a971b32..cc7f381 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -3,6 +3,8 @@
 #
 obj-$(CONFIG_SMP) += smp.o
 
+obj-$(CONFIG_PPC_CLOCK)   += clock.o
+
 obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
diff --git a/arch/powerpc/platforms/85xx/clock.c b/arch/powerpc/platforms/85xx/clock.c
new file mode 100644
index 0000000..a6fd2c8
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/clock.c
@@ -0,0 +1,42 @@
+
+#include <linux/device.h>
+#include <linux/err.h>
+
+#include <asm/clk_interface.h>
+
+#include <sysdev/fsl_soc.h>
+
+/*
+ * p1010 needs to provide a clock source for the flexcan driver. The
+ * oscillator for the p1010 processor is only ever the system clock / 2.
+ */
+
+static struct clk *mpc85xx_clk_get(struct device *dev, const char *id)
+{
+	if (!dev)
+		return ERR_PTR(-ENOENT);
+
+	return NULL;
+}
+
+static void mpc85xx_clk_put(struct clk *clk)
+{
+	return;
+}
+
+static unsigned long mpc85xx_clk_get_rate(struct clk *clk)
+{
+	return fsl_get_sys_freq() / 2;
+}
+
+static struct clk_interface mpc85xx_clk_functions = {
+	.clk_get		= mpc85xx_clk_get,
+	.clk_get_rate		= mpc85xx_clk_get_rate,
+	.clk_put		= mpc85xx_clk_put,
+};
+
+void __init mpc85xx_clk_init(void)
+{
+	clk_functions = mpc85xx_clk_functions;
+}
+
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index d7387fa..5e52122 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -81,6 +81,13 @@ static void __init p1010_rdb_setup_arch(void)
 	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
 }
 
+extern void mpc85xx_clk_init(void);
+
+static void __init p1010_rdb_init(void)
+{
+	mpc85xx_clk_init();
+}
+
 static struct of_device_id __initdata p1010rdb_ids[] = {
 	{ .type = "soc", },
 	{ .compatible = "soc", },
@@ -111,6 +118,7 @@ define_machine(p1010_rdb) {
 	.name			= "P1010 RDB",
 	.probe			= p1010_rdb_probe,
 	.setup_arch		= p1010_rdb_setup_arch,
+	.init			= p1010_rdb_init,
 	.init_IRQ		= p1010_rdb_pic_init,
 #ifdef CONFIG_PCI
 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
-- 
1.7.2.1

^ permalink raw reply related

* [PATCH 3/4] [flexcan] Add of_match to platform_device definition.
From: Robin Holt @ 2011-08-09 12:28 UTC (permalink / raw)
  To: Robin Holt, Marc Kleine-Budde, Wolfgang Grandegger,
	U Bhaskar-B22300
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, PPC list
In-Reply-To: <1312892907-20419-1-git-send-email-holt-sJ/iWh9BUns@public.gmane.org>

On powerpc, the OpenFirmware devices are not matched without specifying
an of_match array.  Introduce that array as that is used for matching
on the Freescale P1010 processor.

Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
---
 drivers/net/can/flexcan.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 68cbe52..662f832 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1027,8 +1027,19 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static struct of_device_id flexcan_of_match[] = {
+	{
+		.compatible = "fsl,flexcan",
+	},
+	{},
+};
+
 static struct platform_driver flexcan_driver = {
-	.driver.name = DRV_NAME,
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+		.of_match_table = flexcan_of_match,
+	},
 	.probe = flexcan_probe,
 	.remove = __devexit_p(flexcan_remove),
 };
-- 
1.7.2.1

^ permalink raw reply related

* [PATCH 1/4] [flexcan] Remove #include <mach/clock.h>
From: Robin Holt @ 2011-08-09 12:28 UTC (permalink / raw)
  To: Robin Holt, Marc Kleine-Budde, Wolfgang Grandegger,
	U Bhaskar-B22300
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, PPC list
In-Reply-To: <1312892907-20419-1-git-send-email-holt-sJ/iWh9BUns@public.gmane.org>

powerpc does not have a mach-####/clock.h.  When testing, I found neither
arm nor powerpc needed the mach/clock.h at all so I removed it.

Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
---
 drivers/net/can/flexcan.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1767811..586b2cd 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -35,8 +35,6 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 
-#include <mach/clock.h>
-
 #define DRV_NAME			"flexcan"
 
 /* 8 for RX fifo and 2 error handling */
-- 
1.7.2.1

^ permalink raw reply related

* [Patch 0/4] [flexcan/powerpc] Add support for powerpc flexcan (freescale p1010) -V8
From: Robin Holt @ 2011-08-09 12:28 UTC (permalink / raw)
  To: Robin Holt, Marc Kleine-Budde, Wolfgang Grandegger,
	U Bhaskar-B22300
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, PPC list

Marc, Wolfgang or U Bhaskar,

This patch set should have all your comments included.  It is based on
the David S. Miller net-next-2.6 tree commit 19fd617.

I have compiled each patch in the series individually for both arm and
powerpc (cheated on ppc and reordered them with the last patch first so
I could select CAN_FLEXCAN.

With all the patches applied, my p1010rdb works for communicating between
its two can ports and also can communicate with an external PSOC.  I have
done no testing beyond compile testing on an arm system as I have no
access to an arm based system.

For the first three patches in the series, I believe they are all ready
for submission to David S. Miller for the netdev tree.  This is the
first submission of patch 4 which, I believe, will end up going through
the linuxppc-dev list and can go at any time after the flexcan patches
are submitted.  As long the first and last patches are both applied,
the tree will compile for either ppc or arm, but will not work without
all patches.  If the ppc patch (4/4) gets applied before 1/4, we could
have a random config tester detect a compile failure on ppc if they
select NET, CAN, and CAN_FLEXCAN.

Thanks,
Robin Holt

^ permalink raw reply

* Re: [RFC 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Robin Holt @ 2011-08-09 12:04 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
	PPC list
In-Reply-To: <4E40DDA5.1050004-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

On Tue, Aug 09, 2011 at 09:11:33AM +0200, Wolfgang Grandegger wrote:
> On 08/09/2011 08:33 AM, Robin Holt wrote:
> > Argh.  I sent an earlier (non-working) version of this patch.  Here is
> > the correct one.
> 
> Please always resend the complete series of patches with an incremented
> version number. Furthermore, this is not an RFC any more. A prefix
> similar to [PATCH nfsl_get_sys_freq() et-next-2.6 v2] would be perfect.
> 
> > I added a clock source for the p1010rdb so the flexcan driver
> > could find its clock frequency.
> > 
> > Signed-off-by: Robin Holt <holt-sJ/iWh9BUns@public.gmane.org>
> > To: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
> > To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>,
> > To: U Bhaskar-B22300 <B22300-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> > Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
> > Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
> > Cc: PPC list <linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
> > ---
> >  arch/powerpc/platforms/85xx/Kconfig    |    6 +++
> >  arch/powerpc/platforms/85xx/Makefile   |    1 +
> >  arch/powerpc/platforms/85xx/clock.c    |   59 ++++++++++++++++++++++++++++++++
> >  arch/powerpc/platforms/85xx/p1010rdb.c |   10 +++++
> >  4 files changed, 76 insertions(+), 0 deletions(-)
> >  create mode 100644 arch/powerpc/platforms/85xx/clock.c
> > 
> > diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
> > index 498534c..ed4cf92 100644
> > --- a/arch/powerpc/platforms/85xx/Kconfig
> > +++ b/arch/powerpc/platforms/85xx/Kconfig
> > @@ -26,6 +26,10 @@ config MPC8560_ADS
> >  	help
> >  	  This option enables support for the MPC 8560 ADS board
> >  
> > +config 85xx_HAVE_CAN_FLEXCAN
> > +	bool
> > +	select HAVE_CAN_FLEXCAN if NET && CAN
> > +
> 
> Why do you need that? More below...

Happily removed.

> >  config MPC85xx_CDS
> >  	bool "Freescale MPC85xx CDS"
> >  	select DEFAULT_UIMAGE
> > @@ -70,6 +74,8 @@ config MPC85xx_RDB
> >  config P1010_RDB
> >  	bool "Freescale P1010RDB"
> >  	select DEFAULT_UIMAGE
> > +	select 85xx_HAVE_CAN_FLEXCAN
> > +	select PPC_CLOCK if CAN_FLEXCAN
> 
> 	select HAVE_CAN_FLEXCAN
> 	select PPC_CLOCK
> 
> Should just be fine, or have I missed something.

If I don't have the if NET && CAN, then 'make savedefconfig' will
complain.  Otherwise, removed 85xx_HAVE_CAN_FLEXCAN.

> >  	help
> >  	  This option enables support for the MPC85xx RDB (P1010 RDB) board
> >  
> > diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
> > index a971b32..64ad7a4 100644
> > --- a/arch/powerpc/platforms/85xx/Makefile
> > +++ b/arch/powerpc/platforms/85xx/Makefile
> > @@ -11,6 +11,7 @@ obj-$(CONFIG_MPC85xx_DS)  += mpc85xx_ds.o
> >  obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
> >  obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
> >  obj-$(CONFIG_P1010_RDB)   += p1010rdb.o
> > +obj-$(CONFIG_PPC_CLOCK)   += clock.o
> 
> I would put that to the beginning or before the board settings.

Done.

> >  obj-$(CONFIG_P1022_DS)    += p1022_ds.o
> >  obj-$(CONFIG_P1023_RDS)   += p1023_rds.o
> >  obj-$(CONFIG_P2040_RDB)   += p2040_rdb.o corenet_ds.o
> > diff --git a/arch/powerpc/platforms/85xx/clock.c b/arch/powerpc/platforms/85xx/clock.c
> > new file mode 100644
> > index 0000000..a25cbf3
> > --- /dev/null
> > +++ b/arch/powerpc/platforms/85xx/clock.c
> > @@ -0,0 +1,59 @@
> > +
> > +#include <linux/device.h>
> > +#include <linux/err.h>
> > +
> > +#include <asm/clk_interface.h>
> > +
> > +#include <sysdev/fsl_soc.h>
> > +
> > +/*
> > + * p1010rdb needs to provide a clock source for the flexcan driver.
> > + */
> > +struct clk {
> > +	unsigned long rate;
> > +} p1010_rdb_system_clock;
> > +
> > +static struct clk *p1010_rdb_clk_get(struct device *dev, const char *id)
> > +{
> > +	const char *dev_init_name;
> > +
> > +	if (!dev)
> > +		return ERR_PTR(-ENOENT);
> > +
> > +	/*
> > +	 * The can devices are named ffe1c000.can0 and ffe1d000.can1 on
> > +	 * the p1010rdb.  Check for the "can" portion of that name before
> > +	 * returning a clock source.
> > +	 */
> > +	dev_init_name = dev_name(dev);
> > +	if (strlen(dev_init_name) != 13)
> > +		return ERR_PTR(-ENOENT);
> > +	dev_init_name += 9;
> > +	if (strncmp(dev_init_name, "can", 3))
> > +		return ERR_PTR(-ENOENT);
> 
> What's that good for? Also it's wrong to rely on the special name of the
> node. I think it can be removed.

Removed.

> 
> > +	return &p1010_rdb_system_clock;
> 
> Just returning fsl_get_sys_freq() here would already be fine. I'm also
> missing the factor of two here:
> 
>         return fsl_get_sys_freq() / 2; ????

If we were going that route, I would return NULL here and do that
return on the clk_get_rate() call, correct?  I just tested with that
and it worked.

> > +}
> > +
> > +static void p1010_rdb_clk_put(struct clk *clk)
> > +{
> > +	return;
> > +}
> > +
> > +static unsigned long p1010_rdb_clk_get_rate(struct clk *clk)
> > +{
> > +	return clk->rate;
> > +}
> > +
> > +static struct clk_interface p1010_rdb_clk_functions = {
> > +	.clk_get		= p1010_rdb_clk_get,
> > +	.clk_get_rate		= p1010_rdb_clk_get_rate,
> > +	.clk_put		= p1010_rdb_clk_put,
> > +};
> > +
> > +void __init p1010_rdb_clk_init(void)
> > +{
> > +	p1010_rdb_system_clock.rate = fsl_get_sys_freq();
> 
> > +	clk_functions = p1010_rdb_clk_functions;
> > +}
> 
> The name is too specific. The idea is that the interface could be used
> for other 85xx processors as well, not only the p1010. The prefix
> "mpc85xx_" instead of "p1010_rdb" seems more appropriate to me.

Done.

> 
> > diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
> > index d7387fa..d0afbf9 100644
> > --- a/arch/powerpc/platforms/85xx/p1010rdb.c
> > +++ b/arch/powerpc/platforms/85xx/p1010rdb.c
> > @@ -81,6 +81,15 @@ static void __init p1010_rdb_setup_arch(void)
> >  	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
> >  }
> >  
> > +extern void p1010_rdb_clk_init(void);
> > +
> > +static void __init p1010_rdb_init(void)
> > +{
> > +#ifdef CONFIG_PPC_CLOCK
> > +	p1010_rdb_clk_init();
> > +#endif
> > +}
> 
> The #ifdef's are not needed if CONFIG_PPC_CLOCK is selected in the Kconfig.

Done.

> 
> >  static struct of_device_id __initdata p1010rdb_ids[] = {
> >  	{ .type = "soc", },
> >  	{ .compatible = "soc", },
> > @@ -111,6 +120,7 @@ define_machine(p1010_rdb) {
> >  	.name			= "P1010 RDB",
> >  	.probe			= p1010_rdb_probe,
> >  	.setup_arch		= p1010_rdb_setup_arch,
> > +	.init			= p1010_rdb_init,
> >  	.init_IRQ		= p1010_rdb_pic_init,
> >  #ifdef CONFIG_PCI
> >  	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,

Thank you very much for your patience with me,
Robin

^ permalink raw reply

* Re: [RFC 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Marc Kleine-Budde @ 2011-08-09 12:04 UTC (permalink / raw)
  To: Robin Holt
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300, PPC list,
	Wolfgang Grandegger
In-Reply-To: <20110809114043.GN4926-sJ/iWh9BUns@public.gmane.org>


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

On 08/09/2011 01:40 PM, Robin Holt wrote:
> On Tue, Aug 09, 2011 at 09:11:33AM +0200, Wolfgang Grandegger wrote:
>>> +	return &p1010_rdb_system_clock;
>>
>> Just returning fsl_get_sys_freq() here would already be fine. I'm also
>> missing the factor of two here:
>>
>>         return fsl_get_sys_freq() / 2; ????
> 
> I am working on the other comments right now as well, but this one
> brought up a good question.  The old algorithm in the original freescale
> patches I started with actually did, essentially:
> 
> 	...clock.freq = DIV_ROUND_CLOSEST(fsl_get_sys_freq() / 2, 1000) * 1000
> 
> The end result was before:
> 	...clock.freq=0x0bebc200

That's exactly 200 MHz

> After:
> 	...clock.freq=0x0bebc1fe

this is 199 999 998 Hz

> Is that rounding relavent?

_If_ 200 MHz is correct, this would be an error of 0.000001%. But the
fsl code rounds to closest KHz. Rounding introduces errors in most of
the cases. IMHO it's better not to round here.

For example the usual at91can is clocked with 99.532800 MHz, this is a
least the value the arm clock framework reports.

Cheers, Marc

-- 
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: 262 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

* [PATCH] net_sched: prio: use qdisc_dequeue_peeked
From: Florian Westphal @ 2011-08-09 12:04 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal, Eric Dumazet

commit 07bd8df5df4369487812bf85a237322ff3569b77
(sch_sfq: fix peek() implementation) changed sfq to use generic
peek helper.

This makes HFSC complain about a non-work-conserving child qdisc, if
prio with sfq child is used within hfsc:

hfsc peeks into prio qdisc, which will then peek into sfq.
returned skb is stashed in sch->gso_skb.

Next, hfsc tries to dequeue from prio, but prio will call sfq dequeue
directly, which may return NULL instead of previously peeked-at skb.

Have prio call qdisc_dequeue_peeked, so sfq->dequeue() is
not called in this case.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 Eric, does this look correct to you?
 I am not sure if sfq needs fixing instead of this patch here.

diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 2a318f2..b5d56a2 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -112,7 +112,7 @@ static struct sk_buff *prio_dequeue(struct Qdisc *sch)
 
 	for (prio = 0; prio < q->bands; prio++) {
 		struct Qdisc *qdisc = q->queues[prio];
-		struct sk_buff *skb = qdisc->dequeue(qdisc);
+		struct sk_buff *skb = qdisc_dequeue_peeked(qdisc);
 		if (skb) {
 			qdisc_bstats_update(sch, skb);
 			sch->q.qlen--;
-- 
1.7.3.4


^ permalink raw reply related

* Re: [RFC 4/4] [powerpc] Add flexcan device support for p1010rdb.
From: Robin Holt @ 2011-08-09 11:40 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
	PPC list
In-Reply-To: <4E40DDA5.1050004-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

On Tue, Aug 09, 2011 at 09:11:33AM +0200, Wolfgang Grandegger wrote:
> > +	return &p1010_rdb_system_clock;
> 
> Just returning fsl_get_sys_freq() here would already be fine. I'm also
> missing the factor of two here:
> 
>         return fsl_get_sys_freq() / 2; ????

I am working on the other comments right now as well, but this one
brought up a good question.  The old algorithm in the original freescale
patches I started with actually did, essentially:

	...clock.freq = DIV_ROUND_CLOSEST(fsl_get_sys_freq() / 2, 1000) * 1000

The end result was before:
	...clock.freq=0x0bebc200
After:
	...clock.freq=0x0bebc1fe

Is that rounding relavent?

Thanks,
Robin

^ permalink raw reply

* Re: 802.3ad bonding brain damaged?
From: Benny Amorsen @ 2011-08-09 11:24 UTC (permalink / raw)
  To: Phillip Susi; +Cc: Chris Friesen, David Lamparter, netdev
In-Reply-To: <4E4047CF.5030705@cfl.rr.com>

Phillip Susi <psusi@cfl.rr.com> writes:

> Try, sure, but if you can't without seriously affecting performance,
> then having a knob for damn the torpedoes, full speed ahead mode seems
> reasonable.

Packet reordering often affects performance. It can easily be more
costly than losing half the bandwidth of a bundled link.

These days you are even dependent on the NIC firmware for good
performance with TCP for reordered packets -- if the NIC is bad at
handling them, you don't get any performance boost from GRO.

For UDP, applications have to handle it on their own.


/Benny

^ permalink raw reply

* Re: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
From: Marc Kleine-Budde @ 2011-08-09 10:56 UTC (permalink / raw)
  To: U Bhaskar-B22300
  Cc: netdev@vger.kernel.org, holt@sgi.com, wg@grandegger.com,
	davem@davemloft.net, linuxppc-release@linux.freescale.net,
	socketcan-core@lists.berlios.de
In-Reply-To: <9C64B7751C3BCA41B64A68E23005A7BE1BF197@039-SN1MPN1-004.039d.mgd.msft.net>

[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]

On 08/09/2011 12:29 PM, U Bhaskar-B22300 wrote:
>> NACK - your patch does more than the description states (debug code).
> [Bhaskar] Ok I will change description as below
> 	This patch introduces the following features
> 	1. provides the support for FlexCAN on P1010 SoC.
> 	2. Provides the common read/write interface for ARM and PowerPC based FlexCAN.
> 	3. Provides the clock interface for PowerPC based FlexCAN.
> 	Will it be OK ?
> 
>> Further you still add bugs to the driver. I've send you patches to fix
>> them.
> [Bhaskar] Please mention what sort of BUG you are seeing ..

I have, it's in that mail:

> @@ -957,24 +952,24 @@ static int __devinit register_flexcandev(struct net_device *dev)
> >  
> >  	/* select "bus clock", chip must be disabled */
> >  	flexcan_chip_disable(priv);
> > -	reg = readl(&regs->ctrl);
> > +	reg = flexcan_read(&regs->ctrl);
> >  	reg |= FLEXCAN_CTRL_CLK_SRC;
> > -	writel(reg, &regs->ctrl);
> > +	flexcan_write(reg, &regs->ctrl);
> >  
> >  	flexcan_chip_enable(priv);
> >  
> >  	/* set freeze, halt and activate FIFO, restrict register access */
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> >  	reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
> >  		FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
> > -	writel(reg, &regs->mcr);
> > +	flexcan_write(reg, &regs->mcr);
> >  
> >  	/*
> >  	 * Currently we only support newer versions of this core
> >  	 * featuring a RX FIFO. Older cores found on some Coldfire
> >  	 * derivates are not yet supported.
> >  	 */
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> >  	if (!(reg & FLEXCAN_MCR_FEN)) {
> >  		dev_err(dev->dev.parent,
> >  			"Could not enable RX FIFO, unsupported core\n");
> > @@ -984,6 +979,7 @@ static int __devinit register_flexcandev(struct net_device *dev)
> >  
> >  	err = register_candev(dev);
> >  
> > +	return err;
If you return here, the clock stays enabled....not good

> >   out:
> >  	/* disable core and turn off clocks */
> >  	flexcan_chip_disable(priv);
> > @@ -992,7 +988,7 @@ static int __devinit register_flexcandev(struct net_device *dev)
> >  	return err;
> >  }

For reference bugreport + fix:
https://lists.berlios.de/pipermail/socketcan-core/2011-July/005838.html

cheers, Marc
-- 
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply

* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-09 10:48 UTC (permalink / raw)
  To: U Bhaskar-B22300
  Cc: Marc Kleine-Budde, socketcan-core@lists.berlios.de,
	netdev@vger.kernel.org, Devicetree-discuss@lists.ozlabs.org
In-Reply-To: <9C64B7751C3BCA41B64A68E23005A7BE1BDF8C@039-SN1MPN1-004.039d.mgd.msft.net>

On 08/09/2011 11:27 AM, U Bhaskar-B22300 wrote:
> 
> 
>> -----Original Message-----
>> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
>> Sent: Tuesday, August 09, 2011 2:03 PM
>> To: U Bhaskar-B22300
>> Cc: Marc Kleine-Budde; socketcan-core@lists.berlios.de;
>> netdev@vger.kernel.org; Devicetree-discuss@lists.ozlabs.org
>> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
>>
>> Hi Bhaskar,
>>
>> On 08/09/2011 09:57 AM, U Bhaskar-B22300 wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
>>>> Sent: Tuesday, August 09, 2011 12:23 AM
>>>> To: Wolfgang Grandegger
>>>> Cc: socketcan-core@lists.berlios.de; netdev@vger.kernel.org; U
>>>> Bhaskar- B22300
>>>> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
>>>>
>>>> On 08/08/2011 05:33 PM, Wolfgang Grandegger wrote:
>>>>>> ACK - The device tree bindings as in mainline's Documentation is a
>>>> mess.
>>>>>> If the powerpc guys are happy with a clock interfaces based
>>>>>> approach somewhere in arch/ppc, I'm more than happy to remove:
>>>>>> - fsl,flexcan-clock-source (not implemented, even in the fsl
>>>>>> driver)
>>> [Bhaskar]I have pushed the FlexCAN series of patches, It contains the
>>> usage of all the fields posted in the FlexCAN bindings at
>>> http://git.kernel.org/?p=linux/kernel/git/stable/linux-3.0.y.git;a=blo
>>> b;f=Documentation/devicetree/bindings/net/can/fsl-flexcan.txt;h=1a729f
>>> 089866259ef82d0db5893ff7a8c54d5ccf;hb=94ed5b4788a7cdbe68bc7cb8516972cb
>>> ebdc8274
>>
>> As Marc already pointed out, Robin already has a much more advanced patch
>> stack in preparation. Especially your patches do not care about the
>> already existing Flexcan core on the Freescale's ARM socks.
> [Bhaskar] No, the patches are taking care of the existing ARM functionality.
> 	I have not tested on the ARM based board, but the patches are made in a 
>       Manner that it should not break the ARM based functionality.
>>
>>>>>>
>>>>>> - fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
>>>>>> - clock-frequency           /   a single clock-frequency attribute
>>>>>
>>>>> In the "net-next-2.6" tree there is also:
>>>>>
>>>>>  $ grep flexcan arch/powerpc/boots/dts/*.dts
>>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
>> "platform";
>>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
>> "platform";
>>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
>>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
>>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
>>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
>>>>>
>>>>> Especially the fsl,flexcan-clock-divider = <2>; might make people
>>>>> think, that they could set something else.
>>>>
>>> [Bhaskar] As it is mentioned in the Flexcan bindings, the need of
>> fsl,flexcan-clock-divider = <2>;
>>> 	    But I kept it as "2" because FlexCan clock source is the
>> platform clock and it is CCB/2
>>> 	    If the "2" is misleading, the bindings can be changed or some
>> text can be written to make the meaning of "2"
>>>           Understandable , Please suggest ..
>>
>> The clock source and frequency is fixed. Why do we need an extra
>> properties for that. We have panned to remove these bogus bindings from
>> the Linux kernel, which sneaked in *without* any review on the relevant
>> mailing lists (at least I have not realized any posting). We do not think
>> they are really needed. They just confuse the user. We also prefer to use
>> the compatibility string "fsl,flexcan" instead "fsl,flexcan-v1.0". It's
>> unusual to add a version number, which is  for the Flexcan on the PowerPC
>> cores only, I assume, but there will be device tree for ARM soon. A
>> proper compatibility string would be "fsl,p1010-flexcan" if we really
>> need to distinguish.
>>
> [Bhaskar] About clock source.. There can be two sources of clock for the CAN.
> 	Oscillator or the platform clock, but at present only platform clock is supported
> 	in P1010.If we remove the fsl,flexcan-clock-source property, we will lost the flexibility
> 	of changing the clock source ..
> 	   
>           About clock-frequency... it is also not fixed. It depends on the platform clock which in turns
>           Depends on the CCB clock. So it will be better to keep clock-frequency property which is getting fixed via u-boot.   	

The frequency is fixed to CCB-frequency / 2. Will that ever change? What
can we expect from future Flexcan hardware? Will it support further
clock sources?

Wolfgang.

^ permalink raw reply

* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-09 10:41 UTC (permalink / raw)
  To: U Bhaskar-B22300
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Marc Kleine-Budde
In-Reply-To: <9C64B7751C3BCA41B64A68E23005A7BE1BEFCE-TcFNo7jSaXM0vywKSws3iq4g8xLGJsHaLnY5E4hWTkheoWH0uzbU5w@public.gmane.org>

On 08/09/2011 11:34 AM, U Bhaskar-B22300 wrote:
> 
> 
>> -----Original Message-----
>> From: Marc Kleine-Budde [mailto:mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org]
>> Sent: Tuesday, August 09, 2011 1:43 PM
>> To: U Bhaskar-B22300
>> Cc: Wolfgang Grandegger; socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org;
>> netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
>>
>> On 08/09/2011 09:57 AM, U Bhaskar-B22300 wrote:
>>>> On 08/08/2011 05:33 PM, Wolfgang Grandegger wrote:
>>>>>> ACK - The device tree bindings as in mainline's Documentation is a
>>>> mess.
>>>>>> If the powerpc guys are happy with a clock interfaces based
>>>>>> approach somewhere in arch/ppc, I'm more than happy to remove:
>>>>>> - fsl,flexcan-clock-source (not implemented, even in the fsl
>>>>>> driver)
>>
>>> [Bhaskar]I have pushed the FlexCAN series of patches, It contains the
>>> usage of all the fields posted in the FlexCAN bindings at
>>> http://git.kernel.org/?p=linux/kernel/git/stable/linux-3.0.y.git;a=blo
>>> b;f=Documentation/devicetree/bindings/net/can/fsl-flexcan.txt;h=1a729f
>>> 089866259ef82d0db5893ff7a8c54d5ccf;hb=94ed5b4788a7cdbe68bc7cb8516972cb
>>> ebdc8274
>>
>> I've commented the patches. They are in a very bad shape. Please test
>> Robin's patches.
>>
>>>>>>
>>>>>> - fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
>>>>>> - clock-frequency           /   a single clock-frequency attribute
>>>>>
>>>>> In the "net-next-2.6" tree there is also:
>>>>>
>>>>>  $ grep flexcan arch/powerpc/boots/dts/*.dts
>>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
>> "platform";
>>>>>   p1010rdb.dts:			fsl,flexcan-clock-source =
>> "platform";
>>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
>>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
>>>>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
>>>>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
>>>>>
>>>>> Especially the fsl,flexcan-clock-divider = <2>; might make people
>>>>> think, that they could set something else.
>>>>
>>> [Bhaskar] As it is mentioned in the Flexcan bindings, the need of
>>> fsl,flexcan-clock-divider = <2>; But I kept it as "2" because FlexCan
>>> clock source is the platform clock and it is CCB/2 If the "2" is
>>> misleading, the bindings can be changed or some text can be written to
>>> make the meaning of "2" Understandable , Please suggest ..
>>
>> The clock devider is crap. Why not specify the clockrate that goes into
>> the flexcan core?
> [Bhaskar] The reason why I placed the "fsl,flexcan-clock-divider" property is just because the earlier implementations
> 		 Of CAN also follows the same approach. Please see below the approach of mscan.
>                 compatible = "fsl,mpc5121-mscan";
>                 interrupts = <13 0x8>;
>                 interrupt-parent = <&ipic>;
>                 reg = <0x1380 0x80>;
>                 fsl,mscan-clock-source = "ref";
>                 fsl,mscan-clock-divider = <3>;
>         };
> 	If you want we can remove the fsl,flexcan-clock-divider property. Please comment ..

For that platform the user can *change* these properties so select
another clock-source or clock-divider. This is not the case for the
P1010. Therefore these properties are not needed.

Wolfgang.

^ permalink raw reply

* Re: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
From: Wolfgang Grandegger @ 2011-08-09 10:37 UTC (permalink / raw)
  To: U Bhaskar-B22300
  Cc: linuxppc-release-50dRxjG7WBCY5r8RbUyfqNHuzzzSOjJt@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	Marc Kleine-Budde, davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org
In-Reply-To: <9C64B7751C3BCA41B64A68E23005A7BE1BF197-TcFNo7jSaXM0vywKSws3iq4g8xLGJsHaLnY5E4hWTkheoWH0uzbU5w@public.gmane.org>

On 08/09/2011 12:29 PM, U Bhaskar-B22300 wrote:
> 
> 
>> -----Original Message-----
>> From: Marc Kleine-Budde [mailto:mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org]
>> Sent: Monday, August 08, 2011 8:51 PM
>> To: U Bhaskar-B22300
>> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; holt-sJ/iWh9BUns@public.gmane.org; wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org;
>> davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org; linuxppc-release-50dRxjG7WBCY5r8RbUyfqNHuzzzSOjJt@public.gmane.org; U Bhaskar-
>> B22300; socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
>> Subject: Re: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
>>
>> On 08/08/2011 05:00 PM, Bhaskar Upadhaya wrote:
>>> Provide FlexCAN support for Freescale P1010 SoC.
>>> Modify the existing FlexCAN, so as to support the of_type approach on
>>> P1010(power architecture based)SoC.
>>>
>>> FlexCAN is a communication controller implementing the CAN protocol
>>> according to the CAN 2.0B protocol specification.
>>> This controller is available on Freescale P1010 platform.
>>> Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>
>> NACK - your patch does more than the description states (debug code).
> [Bhaskar] Ok I will change description as below
> 	This patch introduces the following features
> 	1. provides the support for FlexCAN on P1010 SoC.
> 	2. Provides the common read/write interface for ARM and PowerPC based FlexCAN.
> 	3. Provides the clock interface for PowerPC based FlexCAN.
> 	Will it be OK ?

Sorry, too late. Please try the patches posted by Robin recently. We are
currently reviewing those for mainline inclusion and would be happy, if
you would help.

Thanks,

Wolfgang.

^ permalink raw reply

* RE: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
From: U Bhaskar-B22300 @ 2011-08-09 10:29 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev@vger.kernel.org, holt@sgi.com, wg@grandegger.com,
	davem@davemloft.net, linuxppc-release@linux.freescale.net,
	socketcan-core@lists.berlios.de
In-Reply-To: <4E3FFEEB.8070400@pengutronix.de>



> -----Original Message-----
> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> Sent: Monday, August 08, 2011 8:51 PM
> To: U Bhaskar-B22300
> Cc: netdev@vger.kernel.org; holt@sgi.com; wg@grandegger.com;
> davem@davemloft.net; linuxppc-release@linux.freescale.net; U Bhaskar-
> B22300; socketcan-core@lists.berlios.de
> Subject: Re: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
> 
> On 08/08/2011 05:00 PM, Bhaskar Upadhaya wrote:
> > Provide FlexCAN support for Freescale P1010 SoC.
> > Modify the existing FlexCAN, so as to support the of_type approach on
> > P1010(power architecture based)SoC.
> >
> > FlexCAN is a communication controller implementing the CAN protocol
> > according to the CAN 2.0B protocol specification.
> > This controller is available on Freescale P1010 platform.
> > Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
> 
> NACK - your patch does more than the description states (debug code).
[Bhaskar] Ok I will change description as below
	This patch introduces the following features
	1. provides the support for FlexCAN on P1010 SoC.
	2. Provides the common read/write interface for ARM and PowerPC based FlexCAN.
	3. Provides the clock interface for PowerPC based FlexCAN.
	Will it be OK ?

> Further you still add bugs to the driver. I've send you patches to fix
> them.
[Bhaskar] Please mention what sort of BUG you are seeing ..
	    
> 
> Marc
> 
> > ---
> > Based on
> > git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
> >  Branch master
> >
> >  drivers/net/can/Kconfig         |    8 +-
> >  drivers/net/can/Makefile        |    4 +-
> >  drivers/net/can/flexcan.c       |  162 ++++++++++++------------
> >  drivers/net/can/flexcan_iface.c |  261
> > +++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 349 insertions(+), 86 deletions(-)  create mode
> > 100644 drivers/net/can/flexcan_iface.c
> >
> > diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index
> > f6c98fb..882da54 100644
> > --- a/drivers/net/can/Kconfig
> > +++ b/drivers/net/can/Kconfig
> > @@ -98,9 +98,12 @@ config HAVE_CAN_FLEXCAN
> >
> >  config CAN_FLEXCAN
> >  	tristate "Support for Freescale FLEXCAN based chips"
> > -	depends on CAN_DEV && HAVE_CAN_FLEXCAN
> > +	depends on CAN_DEV && (!ARM || HAVE_CAN_FLEXCAN)
> > +	select PPC_CLOCK
> >  	---help---
> > -	  Say Y here if you want to support for Freescale FlexCAN.
> > +	  Say Y here if you want support for Freescale FlexCAN.
> > +	  Flexcan Module is implementing the CAN Protocol
> > +	  version 2.0
> >
> >  config PCH_CAN
> >  	tristate "PCH CAN"
> > @@ -123,6 +126,7 @@ source "drivers/net/can/softing/Kconfig"
> >  config CAN_DEBUG_DEVICES
> >  	bool "CAN devices debugging messages"
> >  	depends on CAN
> > +	default N
> >  	---help---
> >  	  Say Y here if you want the CAN device drivers to produce a bunch
> of
> >  	  debug messages to the system log.  Select this if you are having
> > diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index
> > 24ebfe8..4965e6f 100644
> > --- a/drivers/net/can/Makefile
> > +++ b/drivers/net/can/Makefile
> > @@ -19,7 +19,9 @@ obj-$(CONFIG_CAN_TI_HECC)	+= ti_hecc.o
> >  obj-$(CONFIG_CAN_MCP251X)	+= mcp251x.o
> >  obj-$(CONFIG_CAN_BFIN)		+= bfin_can.o
> >  obj-$(CONFIG_CAN_JANZ_ICAN3)	+= janz-ican3.o
> > -obj-$(CONFIG_CAN_FLEXCAN)	+= flexcan.o
> > +obj-$(CONFIG_CAN_FLEXCAN)	+= flexcan_driver.o
> > +flexcan_driver-objs := flexcan.o \
> > +		flexcan_iface.o
> >  obj-$(CONFIG_PCH_CAN)		+= pch_can.o
> >
> >  ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG diff --git
> > a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index
> > a24aa12..1c1af24 100644
> > --- a/drivers/net/can/flexcan.c
> > +++ b/drivers/net/can/flexcan.c
> > @@ -22,10 +22,8 @@
> >
> >  #include <linux/netdevice.h>
> >  #include <linux/can.h>
> > -#include <linux/can/dev.h>
> >  #include <linux/can/error.h>
> >  #include <linux/can/platform/flexcan.h> -#include <linux/clk.h>
> > #include <linux/delay.h>  #include <linux/if_arp.h>  #include
> > <linux/if_ether.h> @@ -34,11 +32,6 @@  #include <linux/kernel.h>
> > #include <linux/list.h>  #include <linux/module.h> -#include
> > <linux/platform_device.h>
> > -
> > -#include <mach/clock.h>
> > -
> > -#define DRV_NAME			"flexcan"
> >
> >  /* 8 for RX fifo and 2 error handling */
> >  #define FLEXCAN_NAPI_WEIGHT		(8 + 2)
> > @@ -167,19 +160,6 @@ struct flexcan_regs {
> >  	struct flexcan_mb cantxfg[64];
> >  };
> >
> > -struct flexcan_priv {
> > -	struct can_priv can;
> > -	struct net_device *dev;
> > -	struct napi_struct napi;
> > -
> > -	void __iomem *base;
> > -	u32 reg_esr;
> > -	u32 reg_ctrl_default;
> > -
> > -	struct clk *clk;
> > -	struct flexcan_platform_data *pdata;
> > -};
> > -
> >  static struct can_bittiming_const flexcan_bittiming_const = {
> >  	.name = DRV_NAME,
> >  	.tseg1_min = 4,
> > @@ -229,9 +209,10 @@ static inline void flexcan_chip_enable(struct
> flexcan_priv *priv)
> >  	struct flexcan_regs __iomem *regs = priv->base;
> >  	u32 reg;
> >
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> > +
> >  	reg &= ~FLEXCAN_MCR_MDIS;
> > -	writel(reg, &regs->mcr);
> > +	flexcan_write(reg, &regs->mcr);
> >
> >  	udelay(10);
> >  }
> > @@ -248,9 +229,10 @@ static inline void flexcan_chip_disable(struct
> flexcan_priv *priv)
> >  	struct flexcan_regs __iomem *regs = priv->base;
> >  	u32 reg;
> >
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> > +
> >  	reg |= FLEXCAN_MCR_MDIS;
> > -	writel(reg, &regs->mcr);
> > +	flexcan_write(reg, &regs->mcr);
> >  }
> >
> >  /**
> > @@ -266,9 +248,9 @@ static int flexcan_get_berr_counter(const struct
> > net_device *dev,  {
> >  	const struct flexcan_priv *priv = netdev_priv(dev);
> >  	struct flexcan_regs __iomem *regs = priv->base;
> > -	u32 reg = readl(&regs->ecr);
> >
> > -	bec->txerr = (reg >> 0) & 0xff;
> > +	u32 reg = flexcan_read(&regs->ecr);
> > +	bec->txerr = reg & 0xff;
> >  	bec->rxerr = (reg >> 8) & 0xff;
> >
> >  	return 0;
> > @@ -294,6 +276,7 @@ static int flexcan_start_xmit(struct sk_buff *skb,
> struct net_device *dev)
> >  	u32 can_id;
> >  	u32 ctrl = FLEXCAN_MB_CNT_CODE(0xc) | (cf->can_dlc << 16);
> >
> > +	flexcan_reg_dump(dev);
> >  	if (can_dropped_invalid_skb(dev, skb))
> >  		return NETDEV_TX_OK;
> >
> > @@ -311,21 +294,24 @@ static int flexcan_start_xmit(struct sk_buff
> > *skb, struct net_device *dev)
> >
> >  	if (cf->can_dlc > 0) {
> >  		u32 data = be32_to_cpup((__be32 *)&cf->data[0]);
> > -		writel(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
> > +		flexcan_write(data,
> > +			&regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
> >  	}
> >  	if (cf->can_dlc > 3) {
> >  		u32 data = be32_to_cpup((__be32 *)&cf->data[4]);
> > -		writel(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
> > +		flexcan_write(data,
> > +			&regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
> >  	}
> >
> > -	writel(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
> > -	writel(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
> > +	flexcan_write(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
> > +	flexcan_write(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
> >
> >  	kfree_skb(skb);
> >
> >  	/* tx_packets is incremented in flexcan_irq */
> >  	stats->tx_bytes += cf->can_dlc;
> >
> > +	flexcan_reg_dump(dev);
> >  	return NETDEV_TX_OK;
> >  }
> >
> > @@ -440,7 +426,8 @@ static void do_state(struct net_device *dev,
> >  				CAN_ERR_CRTL_TX_WARNING :
> >  				CAN_ERR_CRTL_RX_WARNING;
> >  		}
> > -	case CAN_STATE_ERROR_WARNING:	/* fallthrough */
> > +		/* fallthrough */
> > +	case CAN_STATE_ERROR_WARNING:
> >  		/*
> >  		 * from: ERROR_ACTIVE, ERROR_WARNING
> >  		 * to  : ERROR_PASSIVE, BUS_OFF
> > @@ -536,8 +523,8 @@ static void flexcan_read_fifo(const struct
> net_device *dev,
> >  	struct flexcan_mb __iomem *mb = &regs->cantxfg[0];
> >  	u32 reg_ctrl, reg_id;
> >
> > -	reg_ctrl = readl(&mb->can_ctrl);
> > -	reg_id = readl(&mb->can_id);
> > +	reg_ctrl = flexcan_read(&mb->can_ctrl);
> > +	reg_id = flexcan_read(&mb->can_id);
> >  	if (reg_ctrl & FLEXCAN_MB_CNT_IDE)
> >  		cf->can_id = ((reg_id >> 0) & CAN_EFF_MASK) | CAN_EFF_FLAG;
> >  	else
> > @@ -547,12 +534,13 @@ static void flexcan_read_fifo(const struct
> net_device *dev,
> >  		cf->can_id |= CAN_RTR_FLAG;
> >  	cf->can_dlc = get_can_dlc((reg_ctrl >> 16) & 0xf);
> >
> > -	*(__be32 *)(cf->data + 0) = cpu_to_be32(readl(&mb->data[0]));
> > -	*(__be32 *)(cf->data + 4) = cpu_to_be32(readl(&mb->data[1]));
> > +	*(__be32 *) (&cf->data[0]) =
> > +	    cpu_to_be32(flexcan_read(&mb->data[0]));
> > +	*(__be32 *) (&cf->data[4]) =
> > +	    cpu_to_be32(flexcan_read(&mb->data[1]));
> >
> >  	/* mark as read */
> > -	writel(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->iflag1);
> > -	readl(&regs->timer);
> > +	flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->iflag1);
> >  }
> >
> >  static int flexcan_read_frame(struct net_device *dev) @@ -596,17
> > +584,17 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
> >  	 * The error bits are cleared on read,
> >  	 * use saved value from irq handler.
> >  	 */
> > -	reg_esr = readl(&regs->esr) | priv->reg_esr;
> > +	reg_esr = flexcan_read(&regs->esr) | priv->reg_esr;
> >
> >  	/* handle state changes */
> >  	work_done += flexcan_poll_state(dev, reg_esr);
> >
> >  	/* handle RX-FIFO */
> > -	reg_iflag1 = readl(&regs->iflag1);
> > -	while (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE &&
> > -	       work_done < quota) {
> > +	reg_iflag1 = flexcan_read(&regs->iflag1);
> > +	while ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) &&
> > +	       (work_done < quota)) {
> >  		work_done += flexcan_read_frame(dev);
> > -		reg_iflag1 = readl(&regs->iflag1);
> > +		reg_iflag1 = flexcan_read(&regs->iflag1);
> >  	}
> >
> >  	/* report bus errors */
> > @@ -616,8 +604,8 @@ static int flexcan_poll(struct napi_struct *napi,
> int quota)
> >  	if (work_done < quota) {
> >  		napi_complete(napi);
> >  		/* enable IRQs */
> > -		writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> > -		writel(priv->reg_ctrl_default, &regs->ctrl);
> > +		flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> > +		flexcan_write(priv->reg_ctrl_default, &regs->ctrl);
> >  	}
> >
> >  	return work_done;
> > @@ -641,9 +629,10 @@ static irqreturn_t flexcan_irq(int irq, void
> *dev_id)
> >  	struct flexcan_regs __iomem *regs = priv->base;
> >  	u32 reg_iflag1, reg_esr;
> >
> > -	reg_iflag1 = readl(&regs->iflag1);
> > -	reg_esr = readl(&regs->esr);
> > -	writel(FLEXCAN_ESR_ERR_INT, &regs->esr);	/* ACK err IRQ */
> > +	flexcan_reg_dump(dev);
> > +	reg_iflag1 = flexcan_read(&regs->iflag1);
> > +	reg_esr = flexcan_read(&regs->esr);
> > +	flexcan_write(FLEXCAN_ESR_ERR_INT, &regs->esr);/* ACK err IRQ */
> >
> >  	/*
> >  	 * schedule NAPI in case of:
> > @@ -659,16 +648,17 @@ static irqreturn_t flexcan_irq(int irq, void
> *dev_id)
> >  		 * save them for later use.
> >  		 */
> >  		priv->reg_esr = reg_esr & FLEXCAN_ESR_ERR_BUS;
> > -		writel(FLEXCAN_IFLAG_DEFAULT &
> ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE,
> > -		       &regs->imask1);
> > -		writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
> > -		       &regs->ctrl);
> > +		flexcan_write(FLEXCAN_IFLAG_DEFAULT &
> > +			~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->imask1);
> > +		flexcan_write(priv->reg_ctrl_default &
> > +			~FLEXCAN_CTRL_ERR_ALL, &regs->ctrl);
> >  		napi_schedule(&priv->napi);
> >  	}
> >
> >  	/* FIFO overflow */
> >  	if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
> > -		writel(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, &regs->iflag1);
> > +		flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW,
> > +			&regs->iflag1);
> >  		dev->stats.rx_over_errors++;
> >  		dev->stats.rx_errors++;
> >  	}
> > @@ -677,10 +667,11 @@ static irqreturn_t flexcan_irq(int irq, void
> *dev_id)
> >  	if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) {
> >  		/* tx_bytes is incremented in flexcan_start_xmit */
> >  		stats->tx_packets++;
> > -		writel((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
> > +		flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
> >  		netif_wake_queue(dev);
> >  	}
> >
> > +	flexcan_reg_dump(dev);
> >  	return IRQ_HANDLED;
> >  }
> >
> > @@ -698,7 +689,7 @@ static void flexcan_set_bittiming(struct net_device
> *dev)
> >  	struct flexcan_regs __iomem *regs = priv->base;
> >  	u32 reg;
> >
> > -	reg = readl(&regs->ctrl);
> > +	reg = flexcan_read(&regs->ctrl);
> >  	reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
> >  		 FLEXCAN_CTRL_RJW(0x3) |
> >  		 FLEXCAN_CTRL_PSEG1(0x7) |
> > @@ -722,11 +713,11 @@ static void flexcan_set_bittiming(struct
> net_device *dev)
> >  		reg |= FLEXCAN_CTRL_SMP;
> >
> >  	dev_info(dev->dev.parent, "writing ctrl=0x%08x\n", reg);
> > -	writel(reg, &regs->ctrl);
> > +	flexcan_write(reg, &regs->ctrl);
> >
> >  	/* print chip status */
> >  	dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
> > -		readl(&regs->mcr), readl(&regs->ctrl));
> > +		flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
> >  }
> >
> >  /**
> > @@ -751,10 +742,10 @@ static int flexcan_chip_start(struct net_device
> *dev)
> >  	flexcan_chip_enable(priv);
> >
> >  	/* soft reset */
> > -	writel(FLEXCAN_MCR_SOFTRST, &regs->mcr);
> > +	flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
> >  	udelay(10);
> >
> > -	reg_mcr = readl(&regs->mcr);
> > +	reg_mcr = flexcan_read(&regs->mcr);
> >  	if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
> >  		dev_err(dev->dev.parent,
> >  			"Failed to softreset can module (mcr=0x%08x)\n", @@ -
> 776,12
> > +767,12 @@ static int flexcan_chip_start(struct net_device *dev)
> >  	 * choose format C
> >  	 *
> >  	 */
> > -	reg_mcr = readl(&regs->mcr);
> > +	reg_mcr = flexcan_read(&regs->mcr);
> >  	reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
> >  		FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
> >  		FLEXCAN_MCR_IDAM_C;
> >  	dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__,
> reg_mcr);
> > -	writel(reg_mcr, &regs->mcr);
> > +	flexcan_write(reg_mcr, &regs->mcr);
> >
> >  	/*
> >  	 * CTRL
> > @@ -799,7 +790,7 @@ static int flexcan_chip_start(struct net_device
> *dev)
> >  	 * (FLEXCAN_CTRL_ERR_MSK), too. Otherwise we don't get any
> >  	 * warning or bus passive interrupts.
> >  	 */
> > -	reg_ctrl = readl(&regs->ctrl);
> > +	reg_ctrl = flexcan_read(&regs->ctrl);
> >  	reg_ctrl &= ~FLEXCAN_CTRL_TSYN;
> >  	reg_ctrl |= FLEXCAN_CTRL_BOFF_REC | FLEXCAN_CTRL_LBUF |
> >  		FLEXCAN_CTRL_ERR_STATE | FLEXCAN_CTRL_ERR_MSK; @@ -807,38
> +798,40
> > @@ static int flexcan_chip_start(struct net_device *dev)
> >  	/* save for later use */
> >  	priv->reg_ctrl_default = reg_ctrl;
> >  	dev_dbg(dev->dev.parent, "%s: writing ctrl=0x%08x", __func__,
> reg_ctrl);
> > -	writel(reg_ctrl, &regs->ctrl);
> > +	flexcan_write(reg_ctrl, &regs->ctrl);
> >
> >  	for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
> > -		writel(0, &regs->cantxfg[i].can_ctrl);
> > -		writel(0, &regs->cantxfg[i].can_id);
> > -		writel(0, &regs->cantxfg[i].data[0]);
> > -		writel(0, &regs->cantxfg[i].data[1]);
> > +		flexcan_write(0, &regs->cantxfg[i].can_ctrl);
> > +		flexcan_write(0, &regs->cantxfg[i].can_id);
> > +		flexcan_write(0, &regs->cantxfg[i].data[0]);
> > +		flexcan_write(0, &regs->cantxfg[i].data[1]);
> >
> >  		/* put MB into rx queue */
> > -		writel(FLEXCAN_MB_CNT_CODE(0x4), &regs->cantxfg[i].can_ctrl);
> > +		flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
> > +			&regs->cantxfg[i].can_ctrl);
> >  	}
> >
> >  	/* acceptance mask/acceptance code (accept everything) */
> > -	writel(0x0, &regs->rxgmask);
> > -	writel(0x0, &regs->rx14mask);
> > -	writel(0x0, &regs->rx15mask);
> > +	flexcan_write(0x0, &regs->rxgmask);
> > +	flexcan_write(0x0, &regs->rx14mask);
> > +	flexcan_write(0x0, &regs->rx15mask);
> >
> >  	flexcan_transceiver_switch(priv, 1);
> >
> >  	/* synchronize with the can bus */
> > -	reg_mcr = readl(&regs->mcr);
> > +	reg_mcr = flexcan_read(&regs->mcr);
> >  	reg_mcr &= ~FLEXCAN_MCR_HALT;
> > -	writel(reg_mcr, &regs->mcr);
> > +	flexcan_write(reg_mcr, &regs->mcr);
> >
> >  	priv->can.state = CAN_STATE_ERROR_ACTIVE;
> >
> >  	/* enable FIFO interrupts */
> > -	writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> > +	flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
> >
> >  	/* print chip status */
> >  	dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n",
> > -		__func__, readl(&regs->mcr), readl(&regs->ctrl));
> > +		__func__, flexcan_read(&regs->mcr),
> > +			flexcan_read(&regs->ctrl));
> >
> >  	return 0;
> >
> > @@ -860,12 +853,12 @@ static void flexcan_chip_stop(struct net_device
> *dev)
> >  	u32 reg;
> >
> >  	/* Disable all interrupts */
> > -	writel(0, &regs->imask1);
> > +	flexcan_write(0, &regs->imask1);
> >
> >  	/* Disable + halt module */
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> >  	reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
> > -	writel(reg, &regs->mcr);
> > +	flexcan_write(reg, &regs->mcr);
> >
> >  	flexcan_transceiver_switch(priv, 0);
> >  	priv->can.state = CAN_STATE_STOPPED; @@ -935,6 +928,8 @@ static int
> > flexcan_set_mode(struct net_device *dev, enum can_mode mode)
> >  		break;
> >
> >  	default:
> > +		dev_dbg(dev->dev.parent, "Setting flexcan mode(%d) in func %s
> in line"
> > +					"%d \r\n", mode, __func__, __LINE__);
> >  		return -EOPNOTSUPP;
> >  	}
> >
> > @@ -957,24 +952,24 @@ static int __devinit register_flexcandev(struct
> > net_device *dev)
> >
> >  	/* select "bus clock", chip must be disabled */
> >  	flexcan_chip_disable(priv);
> > -	reg = readl(&regs->ctrl);
> > +	reg = flexcan_read(&regs->ctrl);
> >  	reg |= FLEXCAN_CTRL_CLK_SRC;
> > -	writel(reg, &regs->ctrl);
> > +	flexcan_write(reg, &regs->ctrl);
> >
> >  	flexcan_chip_enable(priv);
> >
> >  	/* set freeze, halt and activate FIFO, restrict register access */
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> >  	reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
> >  		FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
> > -	writel(reg, &regs->mcr);
> > +	flexcan_write(reg, &regs->mcr);
> >
> >  	/*
> >  	 * Currently we only support newer versions of this core
> >  	 * featuring a RX FIFO. Older cores found on some Coldfire
> >  	 * derivates are not yet supported.
> >  	 */
> > -	reg = readl(&regs->mcr);
> > +	reg = flexcan_read(&regs->mcr);
> >  	if (!(reg & FLEXCAN_MCR_FEN)) {
> >  		dev_err(dev->dev.parent,
> >  			"Could not enable RX FIFO, unsupported core\n"); @@ -
> 984,6 +979,7
> > @@ static int __devinit register_flexcandev(struct net_device *dev)
> >
> >  	err = register_candev(dev);
> >
> > +	return err;
> 
> If you return here, the clock stays enabled....not good
> 
> >   out:
> >  	/* disable core and turn off clocks */
> >  	flexcan_chip_disable(priv);
> > @@ -992,7 +988,7 @@ static int __devinit register_flexcandev(struct
> net_device *dev)
> >  	return err;
> >  }
> >
> > -static void __devexit unregister_flexcandev(struct net_device *dev)
> > +void __devexit unregister_flexcandev(struct net_device *dev)
> >  {
> >  	unregister_candev(dev);
> >  }
> > diff --git a/drivers/net/can/flexcan_iface.c
> > b/drivers/net/can/flexcan_iface.c new file mode 100644 index
> > 0000000..0c5f6dd
> > --- /dev/null
> > +++ b/drivers/net/can/flexcan_iface.c
> > @@ -0,0 +1,261 @@
> > +/*
> > + * flexcan_iface.c
> > + *
> > + * Copyright 2011 Freescale Semiconductor, Inc.
> > + *
> > + * Based on code originally by Andrey Volkov <avolkov@varma-el.com>
> > + *
> > + * LICENCE:
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation version 2.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + */
> > +
> > +#include <linux/netdevice.h>
> > +#include <linux/can/platform/flexcan.h>
> > +
> > +struct flexcan_interface flexcan_ops;
> > +
> > +/**
> > + * flexcan_of_get_clk_rate - returns the rate, used for bit-timing
> > + *				calculations of FlexCAN
> > + */
> > +static unsigned long flexcan_of_get_clk_rate(struct clk *clock) {
> > +	return clock->rate;
> > +}
> > +
> > +static void flexcan_of_clk_put(struct clk *clk) {
> > +	kfree(clk);
> > +}
> > +
> > +/**
> > + * flexcan_of_clk_get - calculates the rate, used for bit-timing
> > + *			calculations of FlexCAN
> > + * @dev: the FlexCAN device to be used
> > + * @id: id used to differentiate among different clock nodes
> > + *
> > + * calculate the rate based on the clock-frequency
> > + * and clock-divider values from device tree.
> > + * It calculate the rate being "platform" as the clock source
> > + * Framework for "oscillator" as clock source is also provided.
> > + *
> > + * Return value
> > + *    - On Success
> > + *         the rate as part of clk struct, used to calculate the bit-
> timing
> > + *	   for FlexCAN
> > + *    - On Failure
> > + *	   error value
> > + */
> > +static struct clk *flexcan_of_clk_get(struct device *dev, const char
> > +*id) {
> > +	struct clk *clock;
> > +	u32 *clock_freq = NULL;
> > +	u32 *clock_divider = NULL;
> > +	const char *clk_source;
> > +	int err;
> > +	unsigned long rate;
> > +
> > +	clk_source = (char *)of_get_property(dev->of_node,
> > +			"fsl,flexcan-clock-source", NULL);
> > +	if (clk_source == NULL) {
> > +		dev_err(dev, "Cannot find fsl,flexcan-clock-source"
> > +				"property\n");
> > +		err = -EINVAL;
> > +		goto failed_clock;
> > +	}
> > +	if (!memcmp(clk_source, "platform", strlen(clk_source))) {
> > +		clock_divider = (u32 *)of_get_property(dev->of_node,
> > +				"fsl,flexcan-clock-divider", NULL);
> > +		if (*clock_divider) {
> > +			clock_freq = (u32 *) of_get_property(dev->of_node,
> > +					"clock-frequency", NULL);
> > +			if (clock_freq == NULL) {
> > +				dev_err(dev, "Cannot find clock-frequency"
> > +							"property\n");
> > +				err = -EINVAL;
> > +				goto failed_clock;
> > +			}
> > +			rate = DIV_ROUND_CLOSEST(*clock_freq / *clock_divider,
> > +						1000) * 1000;
> > +		} else {
> > +			dev_err(dev, "Cannot find valid fsl,"
> > +					"flexcan-clock-divider\n");
> > +			err = -EINVAL;
> > +			goto failed_clock;
> > +		}
> > +	} else if (!memcmp(clk_source, "oscillator", strlen(clk_source))) {
> > +		clock_divider = (u32 *)of_get_property(dev->of_node,
> > +				"fsl,flexcan-clock-divider", NULL);
> > +		clock_freq = (u32 *)of_get_property(dev->of_node,
> > +						"clock-frequency", NULL);
> > +		if (!(*clock_divider && *clock_freq)) {
> > +			dev_err(dev, "Cannot find valid"
> > +					"fsl,flexcan-clock-divider or"
> > +					"clock-frequency\n");
> > +			err = -EINVAL;
> > +			goto failed_clock;
> > +		} else { /*FIXME for keeping oscillator as clock-source*/
> > +				dev_err(dev, "oscillator as clock support is"
> > +						"not available\n");
> > +				err = -EINVAL;
> > +				goto failed_clock;
> > +		}
> > +	} else {
> > +		dev_err(dev, "Invalid flexcan-clock-source\n");
> > +		err = -EINVAL;
> > +		goto failed_clock;
> > +	}
> > +
> > +	clock = kmalloc(sizeof(struct clk), GFP_KERNEL);
> > +	if (!clock) {
> > +		dev_err(dev, "Cannot allocate memory\n");
> > +			err = -ENOMEM;
> > +		goto failed_clock;
> > +	}
> > +
> > +	clock->rate = rate;
> > +	dev_info(dev, "clock-frequency is  %lu in line %d in function
> %s\r\n",
> > +			clock->rate, __LINE__, __func__);
> > +	return clock;
> > +
> > + failed_clock:
> > +	return ERR_PTR(err);
> > +}
> > +
> > +/**
> > + * flexcan_of_resource_init - initialize the resources for
> > + *				"of" type platform like powerpc
> > + * @flexcan_res: input buffer filled with address for accessing h/w
> registers
> > + *		of FlexCAN
> > + * @pdev: the FlexCAN device to be used
> > + * @flexcan_ops: input buffer containing different utility functions
> > + *
> > + * fills the flexcan_res with the address detail
> > + * for accessing the h/w registers of FlexCAN block.
> > + * flexcan_ops is filled with different clock functions and normal
> > +read/write
> > + *
> > + * Return value
> > + *    - On Success
> > + *	       0
> > + *    - On Failure
> > + *	   error value
> > + */
> > +static int flexcan_of_resource_init(struct flexcan_resource
> *flexcan_res,
> > +					struct device *pdev,
> > +					struct flexcan_interface *flexcan_ops) {
> > +	u64 addr, size;
> > +	int err, irq;
> > +
> > +	addr = of_translate_address(pdev->of_node,
> > +			of_get_address(pdev->of_node, 0, &size, NULL));
> > +	flexcan_res->addr = addr;
> > +	flexcan_res->size = size;
> > +	flexcan_res->drv_name = pdev->driver->name;
> > +	irq = irq_of_parse_and_map(pdev->of_node, 0);
> > +	if (irq == NO_IRQ) {
> > +		dev_err(pdev, "cannot map to irq\n");
> > +		err = -EINVAL;
> > +		goto failed_req;
> > +	}
> > +
> > +	flexcan_res->irq = irq;
> > +
> > +	flexcan_ops->clk_enable = NULL;
> > +	flexcan_ops->clk_disable = NULL;
> > +	flexcan_ops->clk_get_rate = flexcan_of_get_clk_rate;
> > +	flexcan_ops->clk_get = flexcan_of_clk_get;
> > +	flexcan_ops->clk_put = flexcan_of_clk_put;
> > +	return 0;
> > +
> > +failed_req:
> > +	return err;
> > +}
> > +
> > +
> > +
> > +/**
> > + * flexcan_probe - performs the resource initialization
> > + *		   after detecting the architecture type like "of" or
> > + *		   "platform" type
> > + * @pdev: pointer to platform device
> > + *
> > + * initialises the resources based on "platform" or "of"
> > + * type architecture.It also registers the FlexCAN with netdev layer.
> > + *
> > + * Return value
> > + *    - On Success
> > + *	       0
> > + *    - On Failure
> > + *	   error value
> > + */
> > +static int flexcan_probe(struct platform_device *pdev) {
> > +	int err;
> > +	struct flexcan_resource flexcan_res;
> > +	struct device_node *np = pdev->dev.of_node;
> > +
> > +	if (np) {
> > +		err = flexcan_of_resource_init(&flexcan_res,
> > +					&pdev->dev, &flexcan_ops);
> > +		if (err) {
> > +			dev_err(&pdev->dev, "Flexcan Initialization"
> > +				 "failed with err (%d)\n", err);
> > +			err = -EINVAL;
> > +			goto failed_req;
> > +		}
> > +	}
> > +
> > +	err = flexcan_dev_init(&pdev->dev, flexcan_res, &flexcan_ops);
> > +	if (err) {
> > +		dev_err(&pdev->dev, "Flexcan Initialization failed with err"
> > +				"(%d)\n", err);
> > +		err = -EINVAL;
> > +		goto failed_req;
> > +	}
> > +
> > +	return 0;
> > + failed_req:
> > +	return err;
> > +}
> > +
> > +/**
> > + * flexcan_remove - performs the resource de-initialization
> > + *		    after detecting the architecture type like "of" or
> > + *		    "platform" type
> > + * @pdev: pointer to platform device
> > + *
> > + * de-initializez the resources based on "platform" or "of"
> > + * type architecture.It also unregister the FlexCAN with netdev layer.
> > + */
> > +static int flexcan_remove(struct platform_device *pdev) {
> > +	struct net_device *dev = platform_get_drvdata(pdev);
> > +	struct flexcan_priv *priv = netdev_priv(dev);
> > +	struct device_node *np = pdev->dev.of_node;
> > +	struct resource *mem;
> > +	u64 addr = 0, size;
> > +
> > +	unregister_flexcandev(dev);
> > +	iounmap(priv->base);
> > +
> > +	if (np) {
> > +		addr = of_translate_address(pdev->dev.of_node,
> > +		    of_get_address(pdev->dev.of_node, 0, &size, NULL));
> > +		release_mem_region(addr, size);
> > +	}	clk_put(priv->clk);
> > +
> > +	platform_set_drvdata(pdev, NULL);
> > +	free_candev(dev);
> > +
> > +	return 0;
> > +}
> > +
> 
> 
> --
> 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   |



^ permalink raw reply

* Re: BUG: null pointer deref in rt2800usb_get_txwi
From: Marc Kleine-Budde @ 2011-08-09 10:21 UTC (permalink / raw)
  To: Gertjan van Wingerde
  Cc: Netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA, Stanislaw Gruszka
In-Reply-To: <CAL1gcdMTmSZGRzdek1zSS58ha9c7nUXxXBo5P41r22_wgiaMEA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 11042 bytes --]

Hello Gertjan,

On 08/09/2011 11:01 AM, Gertjan van Wingerde wrote:
> Hi Marc,
> 
> On Tue, Aug 9, 2011 at 10:23 AM, Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
>> Hello,
>>
>> I'm a running a sheeva plug (ARM/kirkwood) with a rt2800 USB stick in AP mode.
>> Bus 001 Device 002: ID 1737:0071 Linksys WUSB600N v1 Dual-Band Wireless-N Network Adapter [Ralink RT2870]
>>
>> kernel is v3.0.1 +
>> 00898a47269ae5e6dda04defad00234b96692d95 rt2x00: fix usage of NULL queue
>> b52398b6e4522176dd125722c72c301015d24520 rt2x00: rt2800: fix zeroing skb structure
>>
>> Which is here for reference:
>> (http://git.pengutronix.de/?p=mkl/linux-2.6.git;a=shortlog;h=refs/heads/wireless/rt2x00/v3.0.1)
>>
>> The Kernel crashes after ~1d with this oopses:
>> (Same oops with stock v3.0.0 and v3.0.1)
>>
>> [69638.429744] Unable to handle kernel NULL pointer dereference at virtual address 000000ac
>> [69638.438515] pgd = c0004000
>> [69638.441322] [000000ac] *pgd=00000000
>> [69638.444974] Internal error: Oops: 17 [#1]
>> [69638.449001] Modules linked in: nfsd nfs lockd fscache auth_rpcgss nfs_acl sunrpc bridge ipv6 stp ext2 arc4 rt2800usb rt2800lib crc_ccitt rt2x00usb rt2x00
>> lib mac80211 cfg80211 rfkill hmac sha1_generic mv_cesa aes_generic ext4 mbcache jbd2 mmc_block ehci_hcd mvsdio usbcore mmc_core mv643xx_eth libphy inet_lro
>> [69638.476620] CPU: 0    Not tainted  (3.0.1-100-bs-kirkwood+ #3)
>> [69638.482489] PC is at rt2800usb_get_txwi+0x10/0x1c [rt2800usb]
>> [69638.488273] LR is at rt2800_txdone_entry+0x34/0xe0 [rt2800lib]
>> [69638.494131] pc : [<bf1bb194>]    lr : [<bf1affa4>]    psr: 80000013
>> [69638.494136] sp : de44df08  ip : 00000001  fp : 00000022
>> [69638.505672] r10: 0000000e  r9 : 00000001  r8 : 0000003c
>> [69638.510914] r7 : 00000000  r6 : de6aafc0  r5 : 818c22fd  r4 : de6d99c8
>> [69638.517472] r3 : 00000000  r2 : 00000000  r1 : 818c22fd  r0 : de6d99c8
>> [69638.524030] Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
>> [69638.531371] Control: 0005397f  Table: 0105c000  DAC: 00000017
>> [69638.537144] Process kworker/u:0 (pid: 2089, stack limit = 0xde44c270)
>> [69638.543614] Stack: (0xde44df08 to 0xde44e000)
>> [69638.547997] df00:                   00000000 818c22fd 00000000 de6aafc0 de6d99c8 818c22fd
>> [69638.556221] df20: df958eb4 bf1b0128 c041a384 de6aafc0 df959600 de6ab3c4 de6ab3c4 c043defc
>> [69638.564443] df40: 00000089 00000012 00000000 bf1bba00 de6ab3c4 c043defc 00000000 df8b86a0
>> [69638.572666] df60: df959600 bf1bb9e8 de6ab3c4 c043defc 00000089 00000012 00000000 c005beac
>> [69638.580881] df80: df8b86a0 df959605 00000081 df8b86a0 de44c000 c043defc c043def4 df8b86b0
>> [69638.589103] dfa0: 00000089 c043defc 00000000 c005ca38 de4c7f30 df8b86a0 c005c878 00000013
>> [69638.597325] dfc0: 00000000 00000000 00000000 c005fdcc 00000000 00000000 df8b86a0 00000000
>> [69638.605542] dfe0: de44dfe0 de44dfe0 de4c7f30 c005fd50 c0030a94 c0030a94 ebfffffe e3500000
>> [69638.613787] [<bf1bb194>] (rt2800usb_get_txwi+0x10/0x1c [rt2800usb]) from [<bf1affa4>] (rt2800_txdone_entry+0x34/0xe0 [rt2800lib])
>> [69638.625518] [<bf1affa4>] (rt2800_txdone_entry+0x34/0xe0 [rt2800lib]) from [<bf1b0128>] (rt2800_txdone+0xd8/0x124 [rt2800lib])
>> [69638.636894] [<bf1b0128>] (rt2800_txdone+0xd8/0x124 [rt2800lib]) from [<bf1bba00>] (rt2800usb_work_txdone+0x18/0x110 [rt2800usb])
>> [69638.648522] [<bf1bba00>] (rt2800usb_work_txdone+0x18/0x110 [rt2800usb]) from [<c005beac>] (process_one_work+0x240/0x404)
>> [69638.659451] [<c005beac>] (process_one_work+0x240/0x404) from [<c005ca38>] (worker_thread+0x1c0/0x2e0)
>> [69638.668722] [<c005ca38>] (worker_thread+0x1c0/0x2e0) from [<c005fdcc>] (kthread+0x7c/0x84)
>> [69638.677036] [<c005fdcc>] (kthread+0x7c/0x84) from [<c0030a94>] (kernel_thread_exit+0x0/0x8)
>> [69638.685433] Code: e5903008 e5933008 e3530010 e590300c (e59300ac)
>> [69638.691726] ---[ end trace 99d4053be7f17aef ]---
>>
>> [69638.699949] Unable to handle kernel paging request at virtual address fffffffc
>> [69638.707210] pgd = c0004000
>> [69638.709930] [fffffffc] *pgd=1fffe831, *pte=00000000, *ppte=00000000
>> [69638.716244] Internal error: Oops: 17 [#2]
>> [69638.720270] Modules linked in: nfsd nfs lockd fscache auth_rpcgss nfs_acl sunrpc bridge ipv6 stp ext2 arc4 rt2800usb rt2800lib crc_ccitt rt2x00usb rt2x00lib mac80211 cfg80211 rfkill hmac sha1_generic mv_cesa aes_generic ext4 mbcache jbd2 mmc_block ehci_hcd mvsdio usbcore mmc_core mv643xx_eth libphy inet_lro
>> [69638.747890] CPU: 0    Tainted: G      D      (3.0.1-100-bs-kirkwood+ #3)
>> [69638.754628] PC is at kthread_data+0x4/0xc
>> [69638.758650] LR is at wq_worker_sleeping+0xc/0xc0
>> [69638.763292] pc : [<c005ffbc>]    lr : [<c005cbb8>]    psr: 20000093
>> [69638.763297] sp : de44dc68  ip : c03f1958  fp : de44dcf4
>> [69638.774833] r10: de44c000  r9 : de755d2c  r8 : 00000001
>> [69638.780084] r7 : df819ac0  r6 : de755da8  r5 : c03f1910  r4 : 00000000
>> [69638.786641] r3 : 00000000  r2 : 93c085a9  r1 : 00000000  r0 : de755c20
>> [69638.793199] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
>> [69638.800454] Control: 0005397f  Table: 1fa78000  DAC: 00000015
>> [69638.806226] Process kworker/u:0 (pid: 2089, stack limit = 0xde44c270)
>> [69638.812696] Stack: (0xde44dc68 to 0xde44e000)
>> [69638.817079] dc60:                   de755c20 c02d84c8 de7583e0 c01228b4 00000000 00000000
>> [69638.825293] dc80: 00000003 c0048920 00393830 de755c50 0ecbd14a 00000000 0ecbd14a 00000000
>> [69638.833507] dca0: c03f1dcc c0061c4c 0ecbd14a 00000000 de755c20 debe0840 00000001 c041c348
>> [69638.841722] dcc0: de755c20 c0046ffc de755c20 00000001 00000000 de755c20 ffffffff de44dcfc
>> [69638.849945] dce0: df819ac0 00000001 de755d2c de755d2c de755c18 c0048920 bf1bb194 de44dcfc
>> [69638.858168] dd00: de44dcfc de755d74 de44dd1c de44dec0 de44c000 00000001 bf1bb196 de44dd72
>> [69638.866390] dd20: bf1bb194 00000000 00000017 c0033024 de44c270 0000000b 00000001 de44c000
>> [69638.874606] dd40: 65000001 33303935 20383030 33393565 38303033 35336520 31303033 35652030
>> [69638.882827] dd60: 30333039 28206330 33393565 63613030 00002029 00000017 00000022 000000ac
>> [69638.891041] dd80: 00000017 00000000 de44dec0 00000000 00000013 00000017 00000022 c02d5af8
>> [69638.899257] dda0: de755c20 c0036430 40000013 c0038fc0 c0038f74 def76020 00000f40 c0035840
>> [69638.907479] ddc0: dee26460 df900574 df900400 bf010dac ffdf5000 ffdf56e0 00000010 df900524
>> [69638.915702] dde0: 40000013 df9004e4 00000003 00000010 60000093 c0254124 df9004e4 00000006
>> [69638.923916] de00: 00000017 c03ec210 000000ac de44dec0 0000003c 00000013 0000000e c002a1cc
>> [69638.932130] de20: 00000080 00000000 df900598 00000000 de6b4418 df9004e4 c04196a0 de44c000
>> [69638.940344] de40: 00000000 00000001 00000080 00000003 0000012c c02541c0 c043ccf0 0069ca19
>> [69638.948558] de60: 00000000 00000001 0000000c de44c000 c043cce4 0000003c 00000001 00000003
>> [69638.956773] de80: 00000001 c004af7c de8960a0 de755c50 c03f1958 c03f5fb8 0000000a 00000014
>> [69638.964987] dea0: df958eb4 0000000b 00000000 ffffffff de44def4 de6aafc0 00000000 c002f7ac
>> [69638.973201] dec0: de6d99c8 818c22fd 00000000 00000000 de6d99c8 818c22fd de6aafc0 00000000
>> [69638.981415] dee0: 0000003c 00000001 0000000e 00000022 00000001 de44df08 bf1affa4 bf1bb194
>> [69638.989631] df00: 80000013 ffffffff 00000000 818c22fd 00000000 de6aafc0 de6d99c8 818c22fd
>> [69638.997854] df20: df958eb4 bf1b0128 c041a384 de6aafc0 df959600 de6ab3c4 de6ab3c4 c043defc
>> [69639.006076] df40: 00000089 00000012 00000000 bf1bba00 de6ab3c4 c043defc 00000000 df8b86a0
>> [69639.014291] df60: df959600 bf1bb9e8 de6ab3c4 c043defc 00000089 00000012 00000000 c005beac
>> [69639.022514] df80: df8b86a0 df959605 00000081 df8b86a0 de44c000 c043defc c043def4 df8b86b0
>> [69639.030737] dfa0: 00000089 c043defc 00000000 c005ca38 de4c7f30 df8b86a0 c005c878 00000013
>> [69639.038958] dfc0: 00000000 00000000 00000000 c005fdcc 00000000 00000000 df8b86a0 00000001
>> [69639.047175] dfe0: de44dfe0 de44dfe0 de4c7f30 c005fd50 c0030a94 c0030a94 ebfffffe e3500000
>> [69639.055402] [<c005ffbc>] (kthread_data+0x4/0xc) from [<c005cbb8>] (wq_worker_sleeping+0xc/0xc0)
>> [69639.064148] [<c005cbb8>] (wq_worker_sleeping+0xc/0xc0) from [<c02d84c8>] (schedule+0xe8/0x4e8)
>> [69639.072806] [<c02d84c8>] (schedule+0xe8/0x4e8) from [<c0048920>] (do_exit+0x6b8/0x6f8)
>> [69639.080764] [<c0048920>] (do_exit+0x6b8/0x6f8) from [<c0033024>] (die+0x2e4/0x324)
>> [69639.088378] [<c0033024>] (die+0x2e4/0x324) from [<c02d5af8>] (__do_kernel_fault.part.5+0x54/0x74)
>> [69639.097301] [<c02d5af8>] (__do_kernel_fault.part.5+0x54/0x74) from [<c0036430>] (do_page_fault+0x260/0x27c)
>> [69639.107091] [<c0036430>] (do_page_fault+0x260/0x27c) from [<c002a1cc>] (do_DataAbort+0x34/0x98)
>> [69639.115839] [<c002a1cc>] (do_DataAbort+0x34/0x98) from [<c002f7ac>] (__dabt_svc+0x4c/0x60)
>> [69639.124139] Exception stack(0xde44dec0 to 0xde44df08)
>> [69639.129219] dec0: de6d99c8 818c22fd 00000000 00000000 de6d99c8 818c22fd de6aafc0 00000000
>> [69639.137433] dee0: 0000003c 00000001 0000000e 00000022 00000001 de44df08 bf1affa4 bf1bb194
>> [69639.145643] df00: 80000013 ffffffff
>> [69639.149165] [<c002f7ac>] (__dabt_svc+0x4c/0x60) from [<bf1bb194>] (rt2800usb_get_txwi+0x10/0x1c [rt2800usb])
>> [69639.159060] [<bf1bb194>] (rt2800usb_get_txwi+0x10/0x1c [rt2800usb]) from [<bf1affa4>] (rt2800_txdone_entry+0x34/0xe0 [rt2800lib])
>> [69639.170786] [<bf1affa4>] (rt2800_txdone_entry+0x34/0xe0 [rt2800lib]) from [<bf1b0128>] (rt2800_txdone+0xd8/0x124 [rt2800lib])
>> [69639.182164] [<bf1b0128>] (rt2800_txdone+0xd8/0x124 [rt2800lib]) from [<bf1bba00>] (rt2800usb_work_txdone+0x18/0x110 [rt2800usb])
>> [69639.193789] [<bf1bba00>] (rt2800usb_work_txdone+0x18/0x110 [rt2800usb]) from [<c005beac>] (process_one_work+0x240/0x404)
>> [69639.204711] [<c005beac>] (process_one_work+0x240/0x404) from [<c005ca38>] (worker_thread+0x1c0/0x2e0)
>> [69639.213980] [<c005ca38>] (worker_thread+0x1c0/0x2e0) from [<c005fdcc>] (kthread+0x7c/0x84)
>> [69639.222293] [<c005fdcc>] (kthread+0x7c/0x84) from [<c0030a94>] (kernel_thread_exit+0x0/0x8)
>> [69639.230685] Code: c03f42e8 c02dea14 c02dbd08 e590315c (e5130004)
>> [69639.237041] ---[ end trace 99d4053be7f17af0 ]---
> 
> There is a patch from Stanislaw floating around that ought to fix this crash.
> You can find the crash at:
patch? :)
> http://marc.info/?l=linux-wireless&m=131279612304597&w=2
> 
> However, there is still some discussion on the patch and some more
> tweaking of the patch may be required.

Thanks for the patch.
It's currently compiling - I'll complain it crashes again :)

Marc
-- 
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply

* RE: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: U Bhaskar-B22300 @ 2011-08-09  9:34 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Wolfgang Grandegger, socketcan-core@lists.berlios.de,
	netdev@vger.kernel.org
In-Reply-To: <4E40EC14.1010005@pengutronix.de>



> -----Original Message-----
> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> Sent: Tuesday, August 09, 2011 1:43 PM
> To: U Bhaskar-B22300
> Cc: Wolfgang Grandegger; socketcan-core@lists.berlios.de;
> netdev@vger.kernel.org
> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> 
> On 08/09/2011 09:57 AM, U Bhaskar-B22300 wrote:
> >> On 08/08/2011 05:33 PM, Wolfgang Grandegger wrote:
> >>>> ACK - The device tree bindings as in mainline's Documentation is a
> >> mess.
> >>>> If the powerpc guys are happy with a clock interfaces based
> >>>> approach somewhere in arch/ppc, I'm more than happy to remove:
> >>>> - fsl,flexcan-clock-source (not implemented, even in the fsl
> >>>> driver)
> 
> > [Bhaskar]I have pushed the FlexCAN series of patches, It contains the
> > usage of all the fields posted in the FlexCAN bindings at
> > http://git.kernel.org/?p=linux/kernel/git/stable/linux-3.0.y.git;a=blo
> > b;f=Documentation/devicetree/bindings/net/can/fsl-flexcan.txt;h=1a729f
> > 089866259ef82d0db5893ff7a8c54d5ccf;hb=94ed5b4788a7cdbe68bc7cb8516972cb
> > ebdc8274
> 
> I've commented the patches. They are in a very bad shape. Please test
> Robin's patches.
> 
> >>>>
> >>>> - fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
> >>>> - clock-frequency           /   a single clock-frequency attribute
> >>>
> >>> In the "net-next-2.6" tree there is also:
> >>>
> >>>  $ grep flexcan arch/powerpc/boots/dts/*.dts
> >>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> "platform";
> >>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> "platform";
> >>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>
> >>> Especially the fsl,flexcan-clock-divider = <2>; might make people
> >>> think, that they could set something else.
> >>
> > [Bhaskar] As it is mentioned in the Flexcan bindings, the need of
> > fsl,flexcan-clock-divider = <2>; But I kept it as "2" because FlexCan
> > clock source is the platform clock and it is CCB/2 If the "2" is
> > misleading, the bindings can be changed or some text can be written to
> > make the meaning of "2" Understandable , Please suggest ..
> 
> The clock devider is crap. Why not specify the clockrate that goes into
> the flexcan core?
[Bhaskar] The reason why I placed the "fsl,flexcan-clock-divider" property is just because the earlier implementations
		 Of CAN also follows the same approach. Please see below the approach of mscan.
                compatible = "fsl,mpc5121-mscan";
                interrupts = <13 0x8>;
                interrupt-parent = <&ipic>;
                reg = <0x1380 0x80>;
                fsl,mscan-clock-source = "ref";
                fsl,mscan-clock-divider = <3>;
        };
	If you want we can remove the fsl,flexcan-clock-divider property. Please comment ..
	
> 
> cheers, Marc
> 
> --
> 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   |



^ permalink raw reply

* RE: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: U Bhaskar-B22300 @ 2011-08-09  9:27 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: Marc Kleine-Budde, socketcan-core@lists.berlios.de,
	netdev@vger.kernel.org, Devicetree-discuss@lists.ozlabs.org
In-Reply-To: <4E40F09F.60305@grandegger.com>



> -----Original Message-----
> From: Wolfgang Grandegger [mailto:wg@grandegger.com]
> Sent: Tuesday, August 09, 2011 2:03 PM
> To: U Bhaskar-B22300
> Cc: Marc Kleine-Budde; socketcan-core@lists.berlios.de;
> netdev@vger.kernel.org; Devicetree-discuss@lists.ozlabs.org
> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> 
> Hi Bhaskar,
> 
> On 08/09/2011 09:57 AM, U Bhaskar-B22300 wrote:
> >
> >
> >> -----Original Message-----
> >> From: Marc Kleine-Budde [mailto:mkl@pengutronix.de]
> >> Sent: Tuesday, August 09, 2011 12:23 AM
> >> To: Wolfgang Grandegger
> >> Cc: socketcan-core@lists.berlios.de; netdev@vger.kernel.org; U
> >> Bhaskar- B22300
> >> Subject: Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
> >>
> >> On 08/08/2011 05:33 PM, Wolfgang Grandegger wrote:
> >>>> ACK - The device tree bindings as in mainline's Documentation is a
> >> mess.
> >>>> If the powerpc guys are happy with a clock interfaces based
> >>>> approach somewhere in arch/ppc, I'm more than happy to remove:
> >>>> - fsl,flexcan-clock-source (not implemented, even in the fsl
> >>>> driver)
> > [Bhaskar]I have pushed the FlexCAN series of patches, It contains the
> > usage of all the fields posted in the FlexCAN bindings at
> > http://git.kernel.org/?p=linux/kernel/git/stable/linux-3.0.y.git;a=blo
> > b;f=Documentation/devicetree/bindings/net/can/fsl-flexcan.txt;h=1a729f
> > 089866259ef82d0db5893ff7a8c54d5ccf;hb=94ed5b4788a7cdbe68bc7cb8516972cb
> > ebdc8274
> 
> As Marc already pointed out, Robin already has a much more advanced patch
> stack in preparation. Especially your patches do not care about the
> already existing Flexcan core on the Freescale's ARM socks.
[Bhaskar] No, the patches are taking care of the existing ARM functionality.
	I have not tested on the ARM based board, but the patches are made in a 
      Manner that it should not break the ARM based functionality.
> 
> >>>>
> >>>> - fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
> >>>> - clock-frequency           /   a single clock-frequency attribute
> >>>
> >>> In the "net-next-2.6" tree there is also:
> >>>
> >>>  $ grep flexcan arch/powerpc/boots/dts/*.dts
> >>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> "platform";
> >>>   p1010rdb.dts:			fsl,flexcan-clock-source =
> "platform";
> >>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>   p1010si.dtsi:			compatible = "fsl,flexcan-v1.0";
> >>>   p1010si.dtsi:			fsl,flexcan-clock-divider = <2>;
> >>>
> >>> Especially the fsl,flexcan-clock-divider = <2>; might make people
> >>> think, that they could set something else.
> >>
> > [Bhaskar] As it is mentioned in the Flexcan bindings, the need of
> fsl,flexcan-clock-divider = <2>;
> > 	    But I kept it as "2" because FlexCan clock source is the
> platform clock and it is CCB/2
> > 	    If the "2" is misleading, the bindings can be changed or some
> text can be written to make the meaning of "2"
> >           Understandable , Please suggest ..
> 
> The clock source and frequency is fixed. Why do we need an extra
> properties for that. We have panned to remove these bogus bindings from
> the Linux kernel, which sneaked in *without* any review on the relevant
> mailing lists (at least I have not realized any posting). We do not think
> they are really needed. They just confuse the user. We also prefer to use
> the compatibility string "fsl,flexcan" instead "fsl,flexcan-v1.0". It's
> unusual to add a version number, which is  for the Flexcan on the PowerPC
> cores only, I assume, but there will be device tree for ARM soon. A
> proper compatibility string would be "fsl,p1010-flexcan" if we really
> need to distinguish.
> 
[Bhaskar] About clock source.. There can be two sources of clock for the CAN.
	Oscillator or the platform clock, but at present only platform clock is supported
	in P1010.If we remove the fsl,flexcan-clock-source property, we will lost the flexibility
	of changing the clock source ..
	   
          About clock-frequency... it is also not fixed. It depends on the platform clock which in turns
          Depends on the CCB clock. So it will be better to keep clock-frequency property which is getting fixed via u-boot.   	

	    Agreed on the discussion of changing "fsl,flexcan-v1.0" to "fsl,flexcan"
	
> Please join the discussion on the mailing list helping to get this driver
> mainline.
> 
> Thanks,
> 
> Wolfgang.



^ permalink raw reply

* [PATCHv3 9/9] macb: allow GEM to have configurable receive buffer size
From: Jamie Iles @ 2011-08-09  9:16 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: plagnioj, Jamie Iles
In-Reply-To: <1312881411-2376-1-git-send-email-jamie@jamieiles.com>

GEM has configurable receive buffer sizes so requires this to be
programmed up.  Any size < 2048 and a multiple of 64 bytes is permitted.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/net/macb.c |   17 +++++++++++++++++
 drivers/net/macb.h |    5 +++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index a8a9b4b..69c9808 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -857,6 +857,21 @@ static u32 macb_dbw(struct macb *bp)
 	}
 }
 
+/*
+ * Configure the receive DMA engine to use the correct receive buffer size.
+ * This is a configurable parameter for GEM.
+ */
+static void macb_configure_dma(struct macb *bp)
+{
+	u32 dmacfg;
+
+	if (macb_is_gem(bp)) {
+		dmacfg = gem_readl(bp, DMACFG) & ~GEM_BF(RXBS, -1L);
+		dmacfg |= GEM_BF(RXBS, RX_BUFFER_SIZE / 64);
+		gem_writel(bp, DMACFG, dmacfg);
+	}
+}
+
 static void macb_init_hw(struct macb *bp)
 {
 	u32 config;
@@ -875,6 +890,8 @@ static void macb_init_hw(struct macb *bp)
 	config |= macb_dbw(bp);
 	macb_writel(bp, NCFGR, config);
 
+	macb_configure_dma(bp);
+
 	/* Initialize TX and RX buffers */
 	macb_writel(bp, RBQP, bp->rx_ring_dma);
 	macb_writel(bp, TBQP, bp->tx_ring_dma);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 71424aa..1931078 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -64,6 +64,7 @@
 /* GEM register offsets. */
 #define GEM_NCFGR				0x0004
 #define GEM_USRIO				0x000c
+#define GEM_DMACFG				0x0010
 #define GEM_HRB					0x0080
 #define GEM_HRT					0x0084
 #define GEM_SA1B				0x0088
@@ -154,6 +155,10 @@
 #define GEM_DBW64				1
 #define GEM_DBW128				2
 
+/* Bitfields in DMACFG. */
+#define GEM_RXBS_OFFSET				16
+#define GEM_RXBS_SIZE				8
+
 /* Bitfields in NSR */
 #define MACB_NSR_LINK_OFFSET			0
 #define MACB_NSR_LINK_SIZE			1
-- 
1.7.4.1


^ permalink raw reply related

* [PATCHv3 8/9] macb: support DMA bus widths > 32 bits
From: Jamie Iles @ 2011-08-09  9:16 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: plagnioj, Jamie Iles
In-Reply-To: <1312881411-2376-1-git-send-email-jamie@jamieiles.com>

Some GEM implementations may support DMA bus widths up to 128 bits.  We
can get the maximum supported DMA bus width from the design
configuration register so use that to program the device up.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/net/macb.c |   23 +++++++++++++++++++++++
 drivers/net/macb.h |   19 +++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 0e35804..a8a9b4b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -836,6 +836,27 @@ static u32 macb_mdc_clk_div(struct macb *bp)
 	return config;
 }
 
+/*
+ * Get the DMA bus width field of the network configuration register that we
+ * should program.  We find the width from decoding the design configuration
+ * register to find the maximum supported data bus width.
+ */
+static u32 macb_dbw(struct macb *bp)
+{
+	if (!macb_is_gem(bp))
+		return 0;
+
+	switch (GEM_BFEXT(DBWDEF, gem_readl(bp, DCFG1))) {
+	case 4:
+		return GEM_BF(DBW, GEM_DBW128);
+	case 2:
+		return GEM_BF(DBW, GEM_DBW64);
+	case 1:
+	default:
+		return GEM_BF(DBW, GEM_DBW32);
+	}
+}
+
 static void macb_init_hw(struct macb *bp)
 {
 	u32 config;
@@ -851,6 +872,7 @@ static void macb_init_hw(struct macb *bp)
 		config |= MACB_BIT(CAF);	/* Copy All Frames */
 	if (!(bp->dev->flags & IFF_BROADCAST))
 		config |= MACB_BIT(NBC);	/* No BroadCast */
+	config |= macb_dbw(bp);
 	macb_writel(bp, NCFGR, config);
 
 	/* Initialize TX and RX buffers */
@@ -1277,6 +1299,7 @@ static int __init macb_probe(struct platform_device *pdev)
 
 	/* Set MII management clock divider */
 	config = macb_mdc_clk_div(bp);
+	config |= macb_dbw(bp);
 	macb_writel(bp, NCFGR, config);
 
 	macb_get_hwaddr(bp);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 1367b92..71424aa 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -69,6 +69,13 @@
 #define GEM_SA1B				0x0088
 #define GEM_SA1T				0x008C
 #define GEM_OTX					0x0100
+#define GEM_DCFG1				0x0280
+#define GEM_DCFG2				0x0284
+#define GEM_DCFG3				0x0288
+#define GEM_DCFG4				0x028c
+#define GEM_DCFG5				0x0290
+#define GEM_DCFG6				0x0294
+#define GEM_DCFG7				0x0298
 
 /* Bitfields in NCR */
 #define MACB_LB_OFFSET				0
@@ -139,6 +146,14 @@
 /* GEM specific NCFGR bitfields. */
 #define GEM_CLK_OFFSET				18
 #define GEM_CLK_SIZE				3
+#define GEM_DBW_OFFSET				21
+#define GEM_DBW_SIZE				2
+
+/* Constants for data bus width. */
+#define GEM_DBW32				0
+#define GEM_DBW64				1
+#define GEM_DBW128				2
+
 /* Bitfields in NSR */
 #define MACB_NSR_LINK_OFFSET			0
 #define MACB_NSR_LINK_SIZE			1
@@ -247,6 +262,10 @@
 #define MACB_REV_OFFSET				0
 #define MACB_REV_SIZE				16
 
+/* Bitfields in DCFG1. */
+#define GEM_DBWDEF_OFFSET			25
+#define GEM_DBWDEF_SIZE				3
+
 /* Constants for CLK */
 #define MACB_CLK_DIV8				0
 #define MACB_CLK_DIV16				1
-- 
1.7.4.1


^ permalink raw reply related

* [PATCHv3 7/9] macb: support statistics for GEM devices
From: Jamie Iles @ 2011-08-09  9:16 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: plagnioj, Jamie Iles
In-Reply-To: <1312881411-2376-1-git-send-email-jamie@jamieiles.com>

GEM devices have a different number of statistics registers and they
are at a different offset to MACB devices.  Make the statistics
collection method dependent on device type.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/net/macb.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/net/macb.h |   54 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index fce88f9..0e35804 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -283,8 +283,8 @@ err_out:
 static void macb_update_stats(struct macb *bp)
 {
 	u32 __iomem *reg = bp->regs + MACB_PFR;
-	u32 *p = &bp->hw_stats.rx_pause_frames;
-	u32 *end = &bp->hw_stats.tx_pause_frames + 1;
+	u32 *p = &bp->hw_stats.macb.rx_pause_frames;
+	u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
 
 	WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
 
@@ -1043,11 +1043,62 @@ static int macb_close(struct net_device *dev)
 	return 0;
 }
 
+static void gem_update_stats(struct macb *bp)
+{
+	u32 __iomem *reg = bp->regs + GEM_OTX;
+	u32 *p = &bp->hw_stats.gem.tx_octets_31_0;
+	u32 *end = &bp->hw_stats.gem.rx_udp_checksum_errors + 1;
+
+	for (; p < end; p++, reg++)
+		*p += __raw_readl(reg);
+}
+
+static struct net_device_stats *gem_get_stats(struct macb *bp)
+{
+	struct gem_stats *hwstat = &bp->hw_stats.gem;
+	struct net_device_stats *nstat = &bp->stats;
+
+	gem_update_stats(bp);
+
+	nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +
+			    hwstat->rx_alignment_errors +
+			    hwstat->rx_resource_errors +
+			    hwstat->rx_overruns +
+			    hwstat->rx_oversize_frames +
+			    hwstat->rx_jabbers +
+			    hwstat->rx_undersized_frames +
+			    hwstat->rx_length_field_frame_errors);
+	nstat->tx_errors = (hwstat->tx_late_collisions +
+			    hwstat->tx_excessive_collisions +
+			    hwstat->tx_underrun +
+			    hwstat->tx_carrier_sense_errors);
+	nstat->multicast = hwstat->rx_multicast_frames;
+	nstat->collisions = (hwstat->tx_single_collision_frames +
+			     hwstat->tx_multiple_collision_frames +
+			     hwstat->tx_excessive_collisions);
+	nstat->rx_length_errors = (hwstat->rx_oversize_frames +
+				   hwstat->rx_jabbers +
+				   hwstat->rx_undersized_frames +
+				   hwstat->rx_length_field_frame_errors);
+	nstat->rx_over_errors = hwstat->rx_resource_errors;
+	nstat->rx_crc_errors = hwstat->rx_frame_check_sequence_errors;
+	nstat->rx_frame_errors = hwstat->rx_alignment_errors;
+	nstat->rx_fifo_errors = hwstat->rx_overruns;
+	nstat->tx_aborted_errors = hwstat->tx_excessive_collisions;
+	nstat->tx_carrier_errors = hwstat->tx_carrier_sense_errors;
+	nstat->tx_fifo_errors = hwstat->tx_underrun;
+
+	return nstat;
+}
+
 static struct net_device_stats *macb_get_stats(struct net_device *dev)
 {
 	struct macb *bp = netdev_priv(dev);
 	struct net_device_stats *nstat = &bp->stats;
-	struct macb_stats *hwstat = &bp->hw_stats;
+	struct macb_stats *hwstat = &bp->hw_stats.macb;
+
+	if (macb_is_gem(bp))
+		return gem_get_stats(bp);
 
 	/* read stats from hardware */
 	macb_update_stats(bp);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 354ed8f..1367b92 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -68,6 +68,7 @@
 #define GEM_HRT					0x0084
 #define GEM_SA1B				0x0088
 #define GEM_SA1T				0x008C
+#define GEM_OTX					0x0100
 
 /* Bitfields in NCR */
 #define MACB_LB_OFFSET				0
@@ -425,6 +426,54 @@ struct macb_stats {
 	u32	tx_pause_frames;
 };
 
+struct gem_stats {
+	u32	tx_octets_31_0;
+	u32	tx_octets_47_32;
+	u32	tx_frames;
+	u32	tx_broadcast_frames;
+	u32	tx_multicast_frames;
+	u32	tx_pause_frames;
+	u32	tx_64_byte_frames;
+	u32	tx_65_127_byte_frames;
+	u32	tx_128_255_byte_frames;
+	u32	tx_256_511_byte_frames;
+	u32	tx_512_1023_byte_frames;
+	u32	tx_1024_1518_byte_frames;
+	u32	tx_greater_than_1518_byte_frames;
+	u32	tx_underrun;
+	u32	tx_single_collision_frames;
+	u32	tx_multiple_collision_frames;
+	u32	tx_excessive_collisions;
+	u32	tx_late_collisions;
+	u32	tx_deferred_frames;
+	u32	tx_carrier_sense_errors;
+	u32	rx_octets_31_0;
+	u32	rx_octets_47_32;
+	u32	rx_frames;
+	u32	rx_broadcast_frames;
+	u32	rx_multicast_frames;
+	u32	rx_pause_frames;
+	u32	rx_64_byte_frames;
+	u32	rx_65_127_byte_frames;
+	u32	rx_128_255_byte_frames;
+	u32	rx_256_511_byte_frames;
+	u32	rx_512_1023_byte_frames;
+	u32	rx_1024_1518_byte_frames;
+	u32	rx_greater_than_1518_byte_frames;
+	u32	rx_undersized_frames;
+	u32	rx_oversize_frames;
+	u32	rx_jabbers;
+	u32	rx_frame_check_sequence_errors;
+	u32	rx_length_field_frame_errors;
+	u32	rx_symbol_errors;
+	u32	rx_alignment_errors;
+	u32	rx_resource_errors;
+	u32	rx_overruns;
+	u32	rx_ip_header_checksum_errors;
+	u32	rx_tcp_checksum_errors;
+	u32	rx_udp_checksum_errors;
+};
+
 struct macb {
 	void __iomem		*regs;
 
@@ -443,7 +492,10 @@ struct macb {
 	struct net_device	*dev;
 	struct napi_struct	napi;
 	struct net_device_stats	stats;
-	struct macb_stats	hw_stats;
+	union {
+		struct macb_stats	macb;
+		struct gem_stats	gem;
+	}			hw_stats;
 
 	dma_addr_t		rx_ring_dma;
 	dma_addr_t		tx_ring_dma;
-- 
1.7.4.1


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox