* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 15:50 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808153835.GC4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 05:38 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 05:22:41PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 05:18 PM, Wolfgang Grandegger wrote:
>>> On 08/08/2011 05:09 PM, Robin Holt wrote:
>>>> On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
>>>>> On 08/08/2011 04:44 PM, Robin Holt wrote:
>>>>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>>>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>>>>>
>>>>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>>>>>> ...
>>>>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>>>>>
>>>>>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>>>>>
>>>>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>>>>>> "clock_freq" while
>>>>>>>>>
>>>>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>>>>>
>>>>>>>>> documents "clock-frequencies"... :-(.
>>>>>>>>
>>>>>>>> You answered a different question that I was asking. I was asking if
>>>>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>>>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>>>>>> as well.
>>>>>>>
>>>>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>>>>>
>>>>>>> For the P1010 we can sinmply derive the clock frequency from
>>>>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>>>>>> properties, etc. The clk implemetation might go into
>>>>>>>
>>>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>>>>>
>>>>>>> or
>>>>>>>
>>>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>>>>>
>>>>>>> And may depend on HAVE_CAN_FLEXCAN
>>>>>>>
>>>>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>>>>>> you using?
>>>>>>
>>>>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>>>>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>>>>>> platform, and then work from there for the flexcan stuff. That patch
>>>>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>>>>>> that Kconfig bit, so I have tweaked it to be selected automatically
>>>>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>>>>>> selection to determine is we are going to build the flexcan.c file.
>>>>>
>>>>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
>>>>> we should do it differently for PowerPC.
>>>>>
>>>>> For mainline inclusion, you should provide your patches against the
>>>>> David Millers "net-next-2.6" tree, which already seems to have support
>>>>> for the P1010RDB:
>>>>>
>>>>> config P1010_RDB
>>>>> bool "Freescale P1010RDB"
>>>>> select DEFAULT_UIMAGE
>>>>> help
>>>>> This option enables support for the MPC85xx RDB (P1010 RDB) board
>>>>>
>>>>> P1010RDB contains P1010Si, which provides CPU performance up to 800
>>>>> MHz and 1600 DMIPS, additional functionality and faster interfaces
>>>>> (DDR3/3L, SATA II, and PCI Express).
>>>>>
>>>>>
>>>>>> Our contact with Freescale would prefer that I not post that patch until
>>>>>> we get the OK from freescale to do so since we received it under NDA.
>>>>>
>>>>> I don't think we currently need it. I prefer dropping and cleaning up
>>>>> the device tree stuff as it is not needed for the P1010 anyway. If a
>>>>> new processor shows up with enhanced capabilities requiring
>>>>> configuration via device tree, we or somebody else can provide a patch.
>>>>> Marc, what do you think?
>>>>
>>>> I will rebase shortly and provide a newer set of patches.
>>>>
>>>> I do think powerpc does need the device tree support. That is how the flexcan_probe
>>>> is getting called. How would you suggest I do it otherwise?
>>>
>>> Why do you think that?
>>
>> To be clear. I mean we do not need the extra "fsl," properties for the
>> clock source and divider and frequency.
>
> I agree with that. The can definition in the .dts file, however,
> should be can0@... "fsl,flexcan" in an ideal world, correct? If that
No, it's normally <device-type>@<address>.
> is correct, then I will make the of_match string match fsl,flexcan and
> update the .dts file accordingly.
As I said. For the P1010 the clock get function just needs to return
"fsl_get_sys_freq()". No need to inspect the device tree. And I would
provide the clk implementation in
http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
or even:
http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
Wolfgang.
^ permalink raw reply
* Re: [RFC PATCH v2 0/9] bql: Byte Queue Limits
From: Stephen Hemminger @ 2011-08-08 15:40 UTC (permalink / raw)
To: Tom Herbert; +Cc: davem, netdev
In-Reply-To: <alpine.DEB.2.00.1108072129010.13386@pokey.mtv.corp.google.com>
On Sun, 7 Aug 2011 21:43:13 -0700 (PDT)
Tom Herbert <therbert@google.com> wrote:
> netdev_tx_completed_queue: Called at end of transmit completion
> to inform stack of number of bytes and packets processed.
> netdev_tx_sent_queue: Called to inform stack when packets are
> queued.
Couldn't these be done for the device in the existing qdisc infra
structure (or dev_start_xmit). Alternatively, rename ndo_start_xmit
to something else and make all the callers use the wrapper.
Changing all the drivers for something that the driver has no real
need to care about seems like incorrect object design.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 15:38 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FFF41.7030401-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On Mon, Aug 08, 2011 at 05:22:41PM +0200, Wolfgang Grandegger wrote:
> On 08/08/2011 05:18 PM, Wolfgang Grandegger wrote:
> > On 08/08/2011 05:09 PM, Robin Holt wrote:
> >> On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
> >>> On 08/08/2011 04:44 PM, Robin Holt wrote:
> >>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
> >>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
> >>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
> >>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
> >>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>>>>>>
> >>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
> >>>>>>>> ...
> >>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
> >>>>>>>> + "clock_freq", gd->bus_clk, 1);
> >>>>>>>>
> >>>>>>>> Should I go back to flexcan-v1.0 in my patches?
> >>>>>>>
> >>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
> >>>>>>> "clock_freq" while
> >>>>>>>
> >>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> >>>>>>>
> >>>>>>> documents "clock-frequencies"... :-(.
> >>>>>>
> >>>>>> You answered a different question that I was asking. I was asking if
> >>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> >>>>>> line 5. The clock_freq looks like a uboot change will need to be made
> >>>>>> as well.
> >>>>>
> >>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
> >>>>>
> >>>>> For the P1010 we can sinmply derive the clock frequency from
> >>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
> >>>>> properties, etc. The clk implemetation might go into
> >>>>>
> >>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
> >>>>>
> >>>>> or
> >>>>>
> >>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
> >>>>>
> >>>>> And may depend on HAVE_CAN_FLEXCAN
> >>>>>
> >>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
> >>>>> you using?
> >>>>
> >>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
> >>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
> >>>> platform, and then work from there for the flexcan stuff. That patch
> >>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
> >>>> that Kconfig bit, so I have tweaked it to be selected automatically
> >>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
> >>>> selection to determine is we are going to build the flexcan.c file.
> >>>
> >>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
> >>> we should do it differently for PowerPC.
> >>>
> >>> For mainline inclusion, you should provide your patches against the
> >>> David Millers "net-next-2.6" tree, which already seems to have support
> >>> for the P1010RDB:
> >>>
> >>> config P1010_RDB
> >>> bool "Freescale P1010RDB"
> >>> select DEFAULT_UIMAGE
> >>> help
> >>> This option enables support for the MPC85xx RDB (P1010 RDB) board
> >>>
> >>> P1010RDB contains P1010Si, which provides CPU performance up to 800
> >>> MHz and 1600 DMIPS, additional functionality and faster interfaces
> >>> (DDR3/3L, SATA II, and PCI Express).
> >>>
> >>>
> >>>> Our contact with Freescale would prefer that I not post that patch until
> >>>> we get the OK from freescale to do so since we received it under NDA.
> >>>
> >>> I don't think we currently need it. I prefer dropping and cleaning up
> >>> the device tree stuff as it is not needed for the P1010 anyway. If a
> >>> new processor shows up with enhanced capabilities requiring
> >>> configuration via device tree, we or somebody else can provide a patch.
> >>> Marc, what do you think?
> >>
> >> I will rebase shortly and provide a newer set of patches.
> >>
> >> I do think powerpc does need the device tree support. That is how the flexcan_probe
> >> is getting called. How would you suggest I do it otherwise?
> >
> > Why do you think that?
>
> To be clear. I mean we do not need the extra "fsl," properties for the
> clock source and divider and frequency.
I agree with that. The can definition in the .dts file, however,
should be can0@... "fsl,flexcan" in an ideal world, correct? If that
is correct, then I will make the of_match string match fsl,flexcan and
update the .dts file accordingly.
Thanks,
Robin
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 15:33 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300
In-Reply-To: <4E3FFD5B.7080000-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On 08/08/2011 05:14 PM, Marc Kleine-Budde wrote:
> On 08/08/2011 04:59 PM, Wolfgang Grandegger wrote:
>> On 08/08/2011 04:44 PM, Robin Holt wrote:
>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>>
>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>>> ...
>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>>
>>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>>
>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>>> "clock_freq" while
>>>>>>
>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>>
>>>>>> documents "clock-frequencies"... :-(.
>>>>>
>>>>> You answered a different question that I was asking. I was asking if
>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>>> as well.
>>>>
>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>>
>>>> For the P1010 we can sinmply derive the clock frequency from
>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>>> properties, etc. The clk implemetation might go into
>>>>
>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>>
>>>> or
>>>>
>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>>
>>>> And may depend on HAVE_CAN_FLEXCAN
>>>>
>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>>> you using?
>>>
>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>>> platform, and then work from there for the flexcan stuff. That patch
>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>>> that Kconfig bit, so I have tweaked it to be selected automatically
>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>>> selection to determine is we are going to build the flexcan.c file.
>>
>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
>> we should do it differently for PowerPC.
>>
>> For mainline inclusion, you should provide your patches against the
>> David Millers "net-next-2.6" tree, which already seems to have support
>> for the P1010RDB:
>>
>> config P1010_RDB
>> bool "Freescale P1010RDB"
>> select DEFAULT_UIMAGE
>> help
>> This option enables support for the MPC85xx RDB (P1010 RDB) board
>>
>> P1010RDB contains P1010Si, which provides CPU performance up to 800
>> MHz and 1600 DMIPS, additional functionality and faster interfaces
>> (DDR3/3L, SATA II, and PCI Express).
>>
>>
>>> Our contact with Freescale would prefer that I not post that patch until
>>> we get the OK from freescale to do so since we received it under NDA.
>>
>> I don't think we currently need it. I prefer dropping and cleaning up
>> the device tree stuff as it is not needed for the P1010 anyway. If a
>> new processor shows up with enhanced capabilities requiring
>> configuration via device tree, we or somebody else can provide a patch.
>> Marc, what do you think?
>
> 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)
>
> - 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.
Wolfgang.
> Marc
>
>
>
>
> _______________________________________________
> Socketcan-core mailing list
> Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
> https://lists.berlios.de/mailman/listinfo/socketcan-core
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 15:27 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808152549.GB4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 05:25 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 05:18:57PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 05:09 PM, Robin Holt wrote:
>>> On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
>>>> On 08/08/2011 04:44 PM, Robin Holt wrote:
>>>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>>>>
>>>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>>>>> ...
>>>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>>>>
>>>>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>>>>
>>>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>>>>> "clock_freq" while
>>>>>>>>
>>>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>>>>
>>>>>>>> documents "clock-frequencies"... :-(.
>>>>>>>
>>>>>>> You answered a different question that I was asking. I was asking if
>>>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>>>>> as well.
>>>>>>
>>>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>>>>
>>>>>> For the P1010 we can sinmply derive the clock frequency from
>>>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>>>>> properties, etc. The clk implemetation might go into
>>>>>>
>>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>>>>
>>>>>> or
>>>>>>
>>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>>>>
>>>>>> And may depend on HAVE_CAN_FLEXCAN
>>>>>>
>>>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>>>>> you using?
>>>>>
>>>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>>>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>>>>> platform, and then work from there for the flexcan stuff. That patch
>>>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>>>>> that Kconfig bit, so I have tweaked it to be selected automatically
>>>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>>>>> selection to determine is we are going to build the flexcan.c file.
>>>>
>>>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
>>>> we should do it differently for PowerPC.
>>>>
>>>> For mainline inclusion, you should provide your patches against the
>>>> David Millers "net-next-2.6" tree, which already seems to have support
>>>> for the P1010RDB:
>>>>
>>>> config P1010_RDB
>>>> bool "Freescale P1010RDB"
>>>> select DEFAULT_UIMAGE
>>>> help
>>>> This option enables support for the MPC85xx RDB (P1010 RDB) board
>>>>
>>>> P1010RDB contains P1010Si, which provides CPU performance up to 800
>>>> MHz and 1600 DMIPS, additional functionality and faster interfaces
>>>> (DDR3/3L, SATA II, and PCI Express).
>>>>
>>>>
>>>>> Our contact with Freescale would prefer that I not post that patch until
>>>>> we get the OK from freescale to do so since we received it under NDA.
>>>>
>>>> I don't think we currently need it. I prefer dropping and cleaning up
>>>> the device tree stuff as it is not needed for the P1010 anyway. If a
>>>> new processor shows up with enhanced capabilities requiring
>>>> configuration via device tree, we or somebody else can provide a patch.
>>>> Marc, what do you think?
>>>
>>> I will rebase shortly and provide a newer set of patches.
>>>
>>> I do think powerpc does need the device tree support. That is how the flexcan_probe
>>> is getting called. How would you suggest I do it otherwise?
>>
>> Why do you think that?
>
> In patch 3/5 in this series (attached below), I made a change in how
> device discovery works. Without that of_match stuff, the flexcan
> driver was never getting its flexcan_probe function called. As soon
> as I added that, it worked. Looking at the driver_register path, this
> appeared to be the "correct" way to implement the device discovery.
> Did I miss something?
I already clarified my statement. Hope you agree now.
Wolfgang.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 15:25 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FFE61.4090109-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On Mon, Aug 08, 2011 at 05:18:57PM +0200, Wolfgang Grandegger wrote:
> On 08/08/2011 05:09 PM, Robin Holt wrote:
> > On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
> >> On 08/08/2011 04:44 PM, Robin Holt wrote:
> >>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
> >>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
> >>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
> >>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
> >>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>>>>>
> >>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
> >>>>>>> ...
> >>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
> >>>>>>> + "clock_freq", gd->bus_clk, 1);
> >>>>>>>
> >>>>>>> Should I go back to flexcan-v1.0 in my patches?
> >>>>>>
> >>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
> >>>>>> "clock_freq" while
> >>>>>>
> >>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> >>>>>>
> >>>>>> documents "clock-frequencies"... :-(.
> >>>>>
> >>>>> You answered a different question that I was asking. I was asking if
> >>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> >>>>> line 5. The clock_freq looks like a uboot change will need to be made
> >>>>> as well.
> >>>>
> >>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
> >>>>
> >>>> For the P1010 we can sinmply derive the clock frequency from
> >>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
> >>>> properties, etc. The clk implemetation might go into
> >>>>
> >>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
> >>>>
> >>>> or
> >>>>
> >>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
> >>>>
> >>>> And may depend on HAVE_CAN_FLEXCAN
> >>>>
> >>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
> >>>> you using?
> >>>
> >>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
> >>> we receive under NDA which introduces the P1010RDB board into the QorIQ
> >>> platform, and then work from there for the flexcan stuff. That patch
> >>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
> >>> that Kconfig bit, so I have tweaked it to be selected automatically
> >>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
> >>> selection to determine is we are going to build the flexcan.c file.
> >>
> >> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
> >> we should do it differently for PowerPC.
> >>
> >> For mainline inclusion, you should provide your patches against the
> >> David Millers "net-next-2.6" tree, which already seems to have support
> >> for the P1010RDB:
> >>
> >> config P1010_RDB
> >> bool "Freescale P1010RDB"
> >> select DEFAULT_UIMAGE
> >> help
> >> This option enables support for the MPC85xx RDB (P1010 RDB) board
> >>
> >> P1010RDB contains P1010Si, which provides CPU performance up to 800
> >> MHz and 1600 DMIPS, additional functionality and faster interfaces
> >> (DDR3/3L, SATA II, and PCI Express).
> >>
> >>
> >>> Our contact with Freescale would prefer that I not post that patch until
> >>> we get the OK from freescale to do so since we received it under NDA.
> >>
> >> I don't think we currently need it. I prefer dropping and cleaning up
> >> the device tree stuff as it is not needed for the P1010 anyway. If a
> >> new processor shows up with enhanced capabilities requiring
> >> configuration via device tree, we or somebody else can provide a patch.
> >> Marc, what do you think?
> >
> > I will rebase shortly and provide a newer set of patches.
> >
> > I do think powerpc does need the device tree support. That is how the flexcan_probe
> > is getting called. How would you suggest I do it otherwise?
>
> Why do you think that?
In patch 3/5 in this series (attached below), I made a change in how
device discovery works. Without that of_match stuff, the flexcan
driver was never getting its flexcan_probe function called. As soon
as I added that, it worked. Looking at the driver_register path, this
appeared to be the "correct" way to implement the device discovery.
Did I miss something?
Thanks,
Robin
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
---
I kept the of_match for "fsl,flexcan-v1.0" for the time being. I will
happily drop it for final submission once I have a boot loader worked
up that matches on either string.
---
drivers/net/can/flexcan.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index ecdd4e6..d4ac81b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1028,8 +1028,22 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
return 0;
}
+static struct of_device_id flexcan_of_match[] = {
+ {
+ .compatible = "fsl,flexcan-v1.0",
+ },
+ {
+ .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
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Marc Kleine-Budde @ 2011-08-08 15:23 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300
In-Reply-To: <4E3FFE61.4090109-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 1169 bytes --]
On 08/08/2011 05:18 PM, Wolfgang Grandegger wrote:
>>>> Our contact with Freescale would prefer that I not post that patch until
>>>> we get the OK from freescale to do so since we received it under NDA.
>>>
>>> I don't think we currently need it. I prefer dropping and cleaning up
>>> the device tree stuff as it is not needed for the P1010 anyway. If a
>>> new processor shows up with enhanced capabilities requiring
>>> configuration via device tree, we or somebody else can provide a patch.
>>> Marc, what do you think?
>>
>> I will rebase shortly and provide a newer set of patches.
>>
>> I do think powerpc does need the device tree support. That is how the flexcan_probe
>> is getting called. How would you suggest I do it otherwise?
I think Wolfgang was talking about removing the clock* attributes from
the device tree, not the device tree bindings at all.
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
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 15:22 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FFE61.4090109-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On 08/08/2011 05:18 PM, Wolfgang Grandegger wrote:
> On 08/08/2011 05:09 PM, Robin Holt wrote:
>> On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
>>> On 08/08/2011 04:44 PM, Robin Holt wrote:
>>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>>>
>>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>>>> ...
>>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>>>
>>>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>>>
>>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>>>> "clock_freq" while
>>>>>>>
>>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>>>
>>>>>>> documents "clock-frequencies"... :-(.
>>>>>>
>>>>>> You answered a different question that I was asking. I was asking if
>>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>>>> as well.
>>>>>
>>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>>>
>>>>> For the P1010 we can sinmply derive the clock frequency from
>>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>>>> properties, etc. The clk implemetation might go into
>>>>>
>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>>>
>>>>> or
>>>>>
>>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>>>
>>>>> And may depend on HAVE_CAN_FLEXCAN
>>>>>
>>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>>>> you using?
>>>>
>>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>>>> platform, and then work from there for the flexcan stuff. That patch
>>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>>>> that Kconfig bit, so I have tweaked it to be selected automatically
>>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>>>> selection to determine is we are going to build the flexcan.c file.
>>>
>>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
>>> we should do it differently for PowerPC.
>>>
>>> For mainline inclusion, you should provide your patches against the
>>> David Millers "net-next-2.6" tree, which already seems to have support
>>> for the P1010RDB:
>>>
>>> config P1010_RDB
>>> bool "Freescale P1010RDB"
>>> select DEFAULT_UIMAGE
>>> help
>>> This option enables support for the MPC85xx RDB (P1010 RDB) board
>>>
>>> P1010RDB contains P1010Si, which provides CPU performance up to 800
>>> MHz and 1600 DMIPS, additional functionality and faster interfaces
>>> (DDR3/3L, SATA II, and PCI Express).
>>>
>>>
>>>> Our contact with Freescale would prefer that I not post that patch until
>>>> we get the OK from freescale to do so since we received it under NDA.
>>>
>>> I don't think we currently need it. I prefer dropping and cleaning up
>>> the device tree stuff as it is not needed for the P1010 anyway. If a
>>> new processor shows up with enhanced capabilities requiring
>>> configuration via device tree, we or somebody else can provide a patch.
>>> Marc, what do you think?
>>
>> I will rebase shortly and provide a newer set of patches.
>>
>> I do think powerpc does need the device tree support. That is how the flexcan_probe
>> is getting called. How would you suggest I do it otherwise?
>
> Why do you think that?
To be clear. I mean we do not need the extra "fsl," properties for the
clock source and divider and frequency.
Wolfgang.
^ permalink raw reply
* Re: [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
From: Marc Kleine-Budde @ 2011-08-08 15:21 UTC (permalink / raw)
To: Bhaskar Upadhaya
Cc: netdev, holt, wg, davem, linuxppc-release, b22300, socketcan-core
In-Reply-To: <1312815640-25804-1-git-send-email-bhaskar.upadhaya@freescale.com>
[-- Attachment #1: Type: text/plain, Size: 26219 bytes --]
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).
Further you still add bugs to the driver. I've send you patches to fix them.
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(®s->mcr);
> + reg = flexcan_read(®s->mcr);
> +
> reg &= ~FLEXCAN_MCR_MDIS;
> - writel(reg, ®s->mcr);
> + flexcan_write(reg, ®s->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(®s->mcr);
> + reg = flexcan_read(®s->mcr);
> +
> reg |= FLEXCAN_MCR_MDIS;
> - writel(reg, ®s->mcr);
> + flexcan_write(reg, ®s->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(®s->ecr);
>
> - bec->txerr = (reg >> 0) & 0xff;
> + u32 reg = flexcan_read(®s->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, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
> + flexcan_write(data,
> + ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
> }
> if (cf->can_dlc > 3) {
> u32 data = be32_to_cpup((__be32 *)&cf->data[4]);
> - writel(data, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
> + flexcan_write(data,
> + ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
> }
>
> - writel(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
> - writel(ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
> + flexcan_write(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
> + flexcan_write(ctrl, ®s->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 = ®s->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, ®s->iflag1);
> - readl(®s->timer);
> + flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->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(®s->esr) | priv->reg_esr;
> + reg_esr = flexcan_read(®s->esr) | priv->reg_esr;
>
> /* handle state changes */
> work_done += flexcan_poll_state(dev, reg_esr);
>
> /* handle RX-FIFO */
> - reg_iflag1 = readl(®s->iflag1);
> - while (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE &&
> - work_done < quota) {
> + reg_iflag1 = flexcan_read(®s->iflag1);
> + while ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) &&
> + (work_done < quota)) {
> work_done += flexcan_read_frame(dev);
> - reg_iflag1 = readl(®s->iflag1);
> + reg_iflag1 = flexcan_read(®s->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, ®s->imask1);
> - writel(priv->reg_ctrl_default, ®s->ctrl);
> + flexcan_write(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
> + flexcan_write(priv->reg_ctrl_default, ®s->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(®s->iflag1);
> - reg_esr = readl(®s->esr);
> - writel(FLEXCAN_ESR_ERR_INT, ®s->esr); /* ACK err IRQ */
> + flexcan_reg_dump(dev);
> + reg_iflag1 = flexcan_read(®s->iflag1);
> + reg_esr = flexcan_read(®s->esr);
> + flexcan_write(FLEXCAN_ESR_ERR_INT, ®s->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,
> - ®s->imask1);
> - writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
> - ®s->ctrl);
> + flexcan_write(FLEXCAN_IFLAG_DEFAULT &
> + ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->imask1);
> + flexcan_write(priv->reg_ctrl_default &
> + ~FLEXCAN_CTRL_ERR_ALL, ®s->ctrl);
> napi_schedule(&priv->napi);
> }
>
> /* FIFO overflow */
> if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
> - writel(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, ®s->iflag1);
> + flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW,
> + ®s->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), ®s->iflag1);
> + flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->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(®s->ctrl);
> + reg = flexcan_read(®s->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, ®s->ctrl);
> + flexcan_write(reg, ®s->ctrl);
>
> /* print chip status */
> dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
> - readl(®s->mcr), readl(®s->ctrl));
> + flexcan_read(®s->mcr), flexcan_read(®s->ctrl));
> }
>
> /**
> @@ -751,10 +742,10 @@ static int flexcan_chip_start(struct net_device *dev)
> flexcan_chip_enable(priv);
>
> /* soft reset */
> - writel(FLEXCAN_MCR_SOFTRST, ®s->mcr);
> + flexcan_write(FLEXCAN_MCR_SOFTRST, ®s->mcr);
> udelay(10);
>
> - reg_mcr = readl(®s->mcr);
> + reg_mcr = flexcan_read(®s->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(®s->mcr);
> + reg_mcr = flexcan_read(®s->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, ®s->mcr);
> + flexcan_write(reg_mcr, ®s->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(®s->ctrl);
> + reg_ctrl = flexcan_read(®s->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, ®s->ctrl);
> + flexcan_write(reg_ctrl, ®s->ctrl);
>
> for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
> - writel(0, ®s->cantxfg[i].can_ctrl);
> - writel(0, ®s->cantxfg[i].can_id);
> - writel(0, ®s->cantxfg[i].data[0]);
> - writel(0, ®s->cantxfg[i].data[1]);
> + flexcan_write(0, ®s->cantxfg[i].can_ctrl);
> + flexcan_write(0, ®s->cantxfg[i].can_id);
> + flexcan_write(0, ®s->cantxfg[i].data[0]);
> + flexcan_write(0, ®s->cantxfg[i].data[1]);
>
> /* put MB into rx queue */
> - writel(FLEXCAN_MB_CNT_CODE(0x4), ®s->cantxfg[i].can_ctrl);
> + flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
> + ®s->cantxfg[i].can_ctrl);
> }
>
> /* acceptance mask/acceptance code (accept everything) */
> - writel(0x0, ®s->rxgmask);
> - writel(0x0, ®s->rx14mask);
> - writel(0x0, ®s->rx15mask);
> + flexcan_write(0x0, ®s->rxgmask);
> + flexcan_write(0x0, ®s->rx14mask);
> + flexcan_write(0x0, ®s->rx15mask);
>
> flexcan_transceiver_switch(priv, 1);
>
> /* synchronize with the can bus */
> - reg_mcr = readl(®s->mcr);
> + reg_mcr = flexcan_read(®s->mcr);
> reg_mcr &= ~FLEXCAN_MCR_HALT;
> - writel(reg_mcr, ®s->mcr);
> + flexcan_write(reg_mcr, ®s->mcr);
>
> priv->can.state = CAN_STATE_ERROR_ACTIVE;
>
> /* enable FIFO interrupts */
> - writel(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
> + flexcan_write(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
>
> /* print chip status */
> dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n",
> - __func__, readl(®s->mcr), readl(®s->ctrl));
> + __func__, flexcan_read(®s->mcr),
> + flexcan_read(®s->ctrl));
>
> return 0;
>
> @@ -860,12 +853,12 @@ static void flexcan_chip_stop(struct net_device *dev)
> u32 reg;
>
> /* Disable all interrupts */
> - writel(0, ®s->imask1);
> + flexcan_write(0, ®s->imask1);
>
> /* Disable + halt module */
> - reg = readl(®s->mcr);
> + reg = flexcan_read(®s->mcr);
> reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
> - writel(reg, ®s->mcr);
> + flexcan_write(reg, ®s->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(®s->ctrl);
> + reg = flexcan_read(®s->ctrl);
> reg |= FLEXCAN_CTRL_CLK_SRC;
> - writel(reg, ®s->ctrl);
> + flexcan_write(reg, ®s->ctrl);
>
> flexcan_chip_enable(priv);
>
> /* set freeze, halt and activate FIFO, restrict register access */
> - reg = readl(®s->mcr);
> + reg = flexcan_read(®s->mcr);
> reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
> FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
> - writel(reg, ®s->mcr);
> + flexcan_write(reg, ®s->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(®s->mcr);
> + reg = flexcan_read(®s->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 |
[-- 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-08 15:18 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808150925.GA4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 05:09 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 04:44 PM, Robin Holt wrote:
>>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>>
>>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>>> ...
>>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>>
>>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>>
>>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>>> "clock_freq" while
>>>>>>
>>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>>
>>>>>> documents "clock-frequencies"... :-(.
>>>>>
>>>>> You answered a different question that I was asking. I was asking if
>>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>>> as well.
>>>>
>>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>>
>>>> For the P1010 we can sinmply derive the clock frequency from
>>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>>> properties, etc. The clk implemetation might go into
>>>>
>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>>
>>>> or
>>>>
>>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>>
>>>> And may depend on HAVE_CAN_FLEXCAN
>>>>
>>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>>> you using?
>>>
>>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>>> platform, and then work from there for the flexcan stuff. That patch
>>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>>> that Kconfig bit, so I have tweaked it to be selected automatically
>>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>>> selection to determine is we are going to build the flexcan.c file.
>>
>> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
>> we should do it differently for PowerPC.
>>
>> For mainline inclusion, you should provide your patches against the
>> David Millers "net-next-2.6" tree, which already seems to have support
>> for the P1010RDB:
>>
>> config P1010_RDB
>> bool "Freescale P1010RDB"
>> select DEFAULT_UIMAGE
>> help
>> This option enables support for the MPC85xx RDB (P1010 RDB) board
>>
>> P1010RDB contains P1010Si, which provides CPU performance up to 800
>> MHz and 1600 DMIPS, additional functionality and faster interfaces
>> (DDR3/3L, SATA II, and PCI Express).
>>
>>
>>> Our contact with Freescale would prefer that I not post that patch until
>>> we get the OK from freescale to do so since we received it under NDA.
>>
>> I don't think we currently need it. I prefer dropping and cleaning up
>> the device tree stuff as it is not needed for the P1010 anyway. If a
>> new processor shows up with enhanced capabilities requiring
>> configuration via device tree, we or somebody else can provide a patch.
>> Marc, what do you think?
>
> I will rebase shortly and provide a newer set of patches.
>
> I do think powerpc does need the device tree support. That is how the flexcan_probe
> is getting called. How would you suggest I do it otherwise?
Why do you think that?
Wolfgang.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 15:16 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808144808.GZ4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 04:48 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 04:21 PM, Robin Holt wrote:
...
>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>
> My question remains "What should we be naming the device tree node in
> general. Line 5 of the fsl-flexcan.txt file specifically calls the node
> "fsl,flexcan-v1.0" In the .dts file the freescale patches introduces into
> the arch/powerpc portion of the kernel, they call it that same thing.
We should provide a patch removing that doc. The version suffix does not
follow the device tree convention. A proper compatibility string would be:
"fsl,p1010-flexcan", "fsl,flexcan"
But as the Flexcan on the P1010 is not treated differently,
"fsl,flexcan" is just fine. Also, the v1.0 is only for the PowerPC SOCs
(ignoring ARM).
> Likewise, in the code already checked into uboot it is the same name.
> Whether it is needed or not for the clock frequency, it does need to
> be consistent between the .dts file and the driver for device discovery
> to work.
Yes, depending on what we decide we need to clean that up as well.
Wolfgang.
^ permalink raw reply
* Re: [PATCH 10/12] headers, can: Add missing #include to <linux/can/bcm.h>
From: Oliver Hartkopp @ 2011-08-08 15:15 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev, Urs Thuermann
In-Reply-To: <1312809655.2591.1149.camel@deadeye>
On 08.08.2011 15:20, Ben Hutchings wrote:
> <linux/can/bcm.h> uses type canid_t, defined in <linux/can.h>.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Thanks Ben!
^ permalink raw reply
* Re: [PATCH 4/4] ARM:FlexCAN Controller for platform_ type
From: Marc Kleine-Budde @ 2011-08-08 15:15 UTC (permalink / raw)
To: Bhaskar Upadhaya
Cc: netdev, holt, wg, davem, linuxppc-release, b22300, socketcan-core
In-Reply-To: <1312815660-25828-1-git-send-email-bhaskar.upadhaya@freescale.com>
[-- Attachment #1: Type: text/plain, Size: 544 bytes --]
On 08/08/2011 05:01 PM, Bhaskar Upadhaya wrote:
> Rearrange the existing ARM based FlexCAN implementation, so as to
> support powerpc based FlexCAN on P1010.
> Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
NACK - see Robin's patches
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: Marc Kleine-Budde @ 2011-08-08 15:14 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300
In-Reply-To: <4E3FF9EA.6030601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 4310 bytes --]
On 08/08/2011 04:59 PM, Wolfgang Grandegger wrote:
> On 08/08/2011 04:44 PM, Robin Holt wrote:
>> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>>
>>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>>> ...
>>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>>
>>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>>
>>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>>> "clock_freq" while
>>>>>
>>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>>
>>>>> documents "clock-frequencies"... :-(.
>>>>
>>>> You answered a different question that I was asking. I was asking if
>>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>>> line 5. The clock_freq looks like a uboot change will need to be made
>>>> as well.
>>>
>>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>>
>>> For the P1010 we can sinmply derive the clock frequency from
>>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>>> properties, etc. The clk implemetation might go into
>>>
>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>>
>>> or
>>>
>>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>>
>>> And may depend on HAVE_CAN_FLEXCAN
>>>
>>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>>> you using?
>>
>> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
>> we receive under NDA which introduces the P1010RDB board into the QorIQ
>> platform, and then work from there for the flexcan stuff. That patch
>> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
>> that Kconfig bit, so I have tweaked it to be selected automatically
>> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
>> selection to determine is we are going to build the flexcan.c file.
>
> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
> we should do it differently for PowerPC.
>
> For mainline inclusion, you should provide your patches against the
> David Millers "net-next-2.6" tree, which already seems to have support
> for the P1010RDB:
>
> config P1010_RDB
> bool "Freescale P1010RDB"
> select DEFAULT_UIMAGE
> help
> This option enables support for the MPC85xx RDB (P1010 RDB) board
>
> P1010RDB contains P1010Si, which provides CPU performance up to 800
> MHz and 1600 DMIPS, additional functionality and faster interfaces
> (DDR3/3L, SATA II, and PCI Express).
>
>
>> Our contact with Freescale would prefer that I not post that patch until
>> we get the OK from freescale to do so since we received it under NDA.
>
> I don't think we currently need it. I prefer dropping and cleaning up
> the device tree stuff as it is not needed for the P1010 anyway. If a
> new processor shows up with enhanced capabilities requiring
> configuration via device tree, we or somebody else can provide a patch.
> Marc, what do you think?
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)
- fsl,flexcan-clock-divider \__ replace with code in arch/ppc, or
- clock-frequency / a single clock-frequency attribute
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
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 15:09 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FF9EA.6030601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On Mon, Aug 08, 2011 at 04:59:54PM +0200, Wolfgang Grandegger wrote:
> On 08/08/2011 04:44 PM, Robin Holt wrote:
> > On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
> >> On 08/08/2011 04:21 PM, Robin Holt wrote:
> >>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
> >>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
> >>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>>>
> >>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
> >>>>> ...
> >>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
> >>>>> + "clock_freq", gd->bus_clk, 1);
> >>>>>
> >>>>> Should I go back to flexcan-v1.0 in my patches?
> >>>>
> >>>> Well, no. Let's wait. I don't think we need it. Also, it sets
> >>>> "clock_freq" while
> >>>>
> >>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> >>>>
> >>>> documents "clock-frequencies"... :-(.
> >>>
> >>> You answered a different question that I was asking. I was asking if
> >>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> >>> line 5. The clock_freq looks like a uboot change will need to be made
> >>> as well.
> >>
> >> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
> >>
> >> For the P1010 we can sinmply derive the clock frequency from
> >> "fsl_get_sys_freq()", which is fine for the time being. No extra
> >> properties, etc. The clk implemetation might go into
> >>
> >> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
> >>
> >> or
> >>
> >> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
> >>
> >> And may depend on HAVE_CAN_FLEXCAN
> >>
> >> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
> >> you using?
> >
> > I am starting with the v3.0 kernel, apply one patch from the freescale BSP
> > we receive under NDA which introduces the P1010RDB board into the QorIQ
> > platform, and then work from there for the flexcan stuff. That patch
> > introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
> > that Kconfig bit, so I have tweaked it to be selected automatically
> > when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
> > selection to determine is we are going to build the flexcan.c file.
>
> ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
> we should do it differently for PowerPC.
>
> For mainline inclusion, you should provide your patches against the
> David Millers "net-next-2.6" tree, which already seems to have support
> for the P1010RDB:
>
> config P1010_RDB
> bool "Freescale P1010RDB"
> select DEFAULT_UIMAGE
> help
> This option enables support for the MPC85xx RDB (P1010 RDB) board
>
> P1010RDB contains P1010Si, which provides CPU performance up to 800
> MHz and 1600 DMIPS, additional functionality and faster interfaces
> (DDR3/3L, SATA II, and PCI Express).
>
>
> > Our contact with Freescale would prefer that I not post that patch until
> > we get the OK from freescale to do so since we received it under NDA.
>
> I don't think we currently need it. I prefer dropping and cleaning up
> the device tree stuff as it is not needed for the P1010 anyway. If a
> new processor shows up with enhanced capabilities requiring
> configuration via device tree, we or somebody else can provide a patch.
> Marc, what do you think?
I will rebase shortly and provide a newer set of patches.
I do think powerpc does need the device tree support. That is how the flexcan_probe
is getting called. How would you suggest I do it otherwise?
Robin
^ permalink raw reply
* Re: [PATCH 1/4][upstream] powerpc/p1010: Rearrange header file for FlexCAN
From: Marc Kleine-Budde @ 2011-08-08 15:08 UTC (permalink / raw)
To: Bhaskar Upadhaya
Cc: netdev, holt, wg, davem, linuxppc-release, b22300, socketcan-core
In-Reply-To: <1312815586-25756-1-git-send-email-bhaskar.upadhaya@freescale.com>
[-- Attachment #1: Type: text/plain, Size: 3381 bytes --]
On 08/08/2011 04:59 PM, Bhaskar Upadhaya wrote:
> - Rearrange header file so that it can be used by both of_ type
> and platform_ type architecture.
> - Provide a common read and write interface for of_ type and platform_
> type architecture for accessing h/w registers.
> Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
NACK - please have a look at Robin's patches. They are in a much better
shape.
cheers, Marc
> ---
> Based on http://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
> Branch master
>
> include/linux/can/platform/flexcan.h | 65 ++++++++++++++++++++++++++++++++++
> 1 files changed, 65 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/can/platform/flexcan.h b/include/linux/can/platform/flexcan.h
> index 72b713a..8458a87 100644
> --- a/include/linux/can/platform/flexcan.h
> +++ b/include/linux/can/platform/flexcan.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2010 Marc Kleine-Budde <kernel@pengutronix.de>
> + * Copyright 2011 Freescale Semiconductor, Inc.
> *
> * This file is released under the GPLv2
> *
> @@ -8,6 +9,27 @@
> #ifndef __CAN_PLATFORM_FLEXCAN_H
> #define __CAN_PLATFORM_FLEXCAN_H
>
> +#include <linux/clk.h>
> +#include <linux/can/dev.h>
> +#include <linux/io.h>
> +
> +#ifdef CONFIG_OF
> +#include<linux/of_platform.h>
> +#else
> +#include <linux/platform_device.h>
> +#include <mach/clock.h>
> +#endif
> +
> +#define DRV_NAME "flexcan"
> +
> +#ifdef __BIG_ENDIAN
> +#define flexcan_read(x) in_be32(x)
> +#define flexcan_write(x, y) out_be32(y, x)
> +#else
> +#define flexcan_read(x) readl(x)
> +#define flexcan_write(x, y) writel(x, y)
> +#endif
> +
> /**
> * struct flexcan_platform_data - flex CAN controller platform data
> * @transceiver_enable: - called to power on/off the transceiver
> @@ -17,4 +39,47 @@ struct flexcan_platform_data {
> void (*transceiver_switch)(int enable);
> };
>
> +struct flexcan_interface {
> + int (*clk_enable) (struct clk *clk);
> + void (*clk_disable) (struct clk *clk);
> + void (*clk_put) (struct clk *clk);
> + unsigned long (*clk_get_rate) (struct clk *clk);
> + struct clk *(*clk_get) (struct device *dev, const char *id);
> +};
> +
> +struct flexcan_resource {
> + u32 irq;
> + u64 addr;
> + u64 size;
> + const char *drv_name;
> +};
> +
> +#ifdef CONFIG_OF
> +struct clk {
> + unsigned long rate;
> + void *data;
> +};
> +#endif
> +
> +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_interface *flexcan_ops;
> + struct flexcan_platform_data *pdata;
> +};
> +
> +int flexcan_dev_init(struct device *pdev, struct flexcan_resource
> + flexcan_res, struct flexcan_interface *flexcan_ops);
> +
> +void __devexit unregister_flexcandev(struct net_device *dev);
> +
> +void flexcan_reg_dump(struct net_device *dev);
> +
> #endif /* __CAN_PLATFORM_FLEXCAN_H */
--
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
* [PATCH 4/4] ARM:FlexCAN Controller for platform_ type
From: Bhaskar Upadhaya @ 2011-08-08 15:01 UTC (permalink / raw)
To: netdev, mkl, holt, wg, davem, linuxppc-release, b22300,
<socketcan-
Cc: Bhaskar Upadhaya
Rearrange the existing ARM based FlexCAN implementation, so as to
support powerpc based FlexCAN on P1010.
Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
---
Based on http://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
Branch master
drivers/net/can/flexcan.c | 105 ++++++++++++++-------------------------
drivers/net/can/flexcan_iface.c | 99 ++++++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 68 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1c1af24..b4d9afb 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -993,37 +993,29 @@ void __devexit unregister_flexcandev(struct net_device *dev)
unregister_candev(dev);
}
-static int __devinit flexcan_probe(struct platform_device *pdev)
+int flexcan_dev_init(struct device *pdev, struct flexcan_resource flexcan_res,
+ struct flexcan_interface *flexcan_ops)
{
struct net_device *dev;
struct flexcan_priv *priv;
- struct resource *mem;
struct clk *clk;
void __iomem *base;
- resource_size_t mem_size;
- int err, irq;
+ int err;
- clk = clk_get(&pdev->dev, NULL);
+ clk = flexcan_ops->clk_get(pdev, NULL);
if (IS_ERR(clk)) {
- dev_err(&pdev->dev, "no clock defined\n");
+ dev_err(pdev, "no clock defined\n");
err = PTR_ERR(clk);
goto failed_clock;
}
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- irq = platform_get_irq(pdev, 0);
- if (!mem || irq <= 0) {
- err = -ENODEV;
- goto failed_get;
- }
-
- mem_size = resource_size(mem);
- if (!request_mem_region(mem->start, mem_size, pdev->name)) {
+ if (!request_mem_region
+ (flexcan_res.addr, flexcan_res.size, flexcan_res.drv_name)) {
err = -EBUSY;
- goto failed_get;
+ goto failed_req;
}
- base = ioremap(mem->start, mem_size);
+ base = ioremap(flexcan_res.addr, flexcan_res.size);
if (!base) {
err = -ENOMEM;
goto failed_map;
@@ -1036,11 +1028,11 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
}
dev->netdev_ops = &flexcan_netdev_ops;
- dev->irq = irq;
+ dev->irq = flexcan_res.irq;
dev->flags |= IFF_ECHO; /* we support local echo in hardware */
priv = netdev_priv(dev);
- priv->can.clock.freq = clk_get_rate(clk);
+ priv->can.clock.freq = flexcan_ops->clk_get_rate(clk);
priv->can.bittiming_const = &flexcan_bittiming_const;
priv->can.do_set_mode = flexcan_set_mode;
priv->can.do_get_berr_counter = flexcan_get_berr_counter;
@@ -1050,20 +1042,21 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
priv->base = base;
priv->dev = dev;
priv->clk = clk;
- priv->pdata = pdev->dev.platform_data;
+ priv->pdata = pdev->platform_data;
+ priv->flexcan_ops = flexcan_ops;
netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
- dev_set_drvdata(&pdev->dev, dev);
- SET_NETDEV_DEV(dev, &pdev->dev);
+ dev_set_drvdata(pdev, dev);
+ SET_NETDEV_DEV(dev, pdev);
err = register_flexcandev(dev);
if (err) {
- dev_err(&pdev->dev, "registering netdev failed\n");
+ dev_err(pdev, "registering netdev failed\n");
goto failed_register;
}
- dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
+ dev_info(pdev, "device registered (reg_base=%p, irq=%d)\n",
priv->base, dev->irq);
return 0;
@@ -1073,55 +1066,31 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
failed_alloc:
iounmap(base);
failed_map:
- release_mem_region(mem->start, mem_size);
- failed_get:
+ release_mem_region(flexcan_res.addr, flexcan_res.size);
+ failed_req:
clk_put(clk);
failed_clock:
return err;
}
-static int __devexit flexcan_remove(struct platform_device *pdev)
+void flexcan_reg_dump(struct net_device *dev)
{
- struct net_device *dev = platform_get_drvdata(pdev);
- struct flexcan_priv *priv = netdev_priv(dev);
- struct resource *mem;
-
- unregister_flexcandev(dev);
- platform_set_drvdata(pdev, NULL);
- iounmap(priv->base);
-
- mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(mem->start, resource_size(mem));
-
- clk_put(priv->clk);
-
- free_candev(dev);
-
- return 0;
-}
-
-static struct platform_driver flexcan_driver = {
- .driver.name = DRV_NAME,
- .probe = flexcan_probe,
- .remove = __devexit_p(flexcan_remove),
-};
-
-static int __init flexcan_init(void)
-{
- pr_info("%s netdevice driver\n", DRV_NAME);
- return platform_driver_register(&flexcan_driver);
-}
+ const struct flexcan_priv *priv = netdev_priv(dev);
+ struct flexcan_regs __iomem *regs = priv->base;
-static void __exit flexcan_exit(void)
-{
- platform_driver_unregister(&flexcan_driver);
- pr_info("%s: driver removed\n", DRV_NAME);
+ dev_dbg(dev->dev.parent, "can-mcr 0x%x \r\n can-ctrl 0x%x \r\n"
+ "can-ecr 0x%x \r\n can-esr 0x%x \r\n"
+ "can-rxgmask 0x%x \r\n can-rx14mask 0x%x \r\n"
+ "can-rx15mask 0x%x \r\n can-imask1 0x%x \r\n"
+ "can-iflag1 0x%x \r\n"
+ "in func <%s> line <%d> \r\n",
+ flexcan_read(®s->mcr),
+ flexcan_read(®s->ctrl),
+ flexcan_read(®s->ecr),
+ flexcan_read(®s->esr),
+ flexcan_read(®s->rxgmask),
+ flexcan_read(®s->rx14mask),
+ flexcan_read(®s->rx15mask),
+ flexcan_read(®s->imask1),
+ flexcan_read(®s->iflag1), __func__, __LINE__);
}
-
-module_init(flexcan_init);
-module_exit(flexcan_exit);
-
-MODULE_AUTHOR("Sascha Hauer <kernel@pengutronix.de>, "
- "Marc Kleine-Budde <kernel@pengutronix.de>");
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("CAN port driver for flexcan based chip");
diff --git a/drivers/net/can/flexcan_iface.c b/drivers/net/can/flexcan_iface.c
index 0c5f6dd..faa6c07 100644
--- a/drivers/net/can/flexcan_iface.c
+++ b/drivers/net/can/flexcan_iface.c
@@ -180,7 +180,55 @@ failed_req:
return err;
}
+/**
+ * flexcan_plt_resource_init - initialize the resources for
+ * "platform" type architecture like "ARM"
+ * @flexcan_res: input buffer filled with address for accessing h/w registers
+ * of CAN
+ * @pdev: the CAN 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_plt_resource_init(struct flexcan_resource *flexcan_res,
+ struct platform_device *pdev,
+ struct flexcan_interface *flexcan_ops)
+{
+ int err, irq;
+ resource_size_t mem_size;
+ struct resource *mem;
+
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ irq = platform_get_irq(pdev, 0);
+ if (!mem || irq <= 0) {
+ dev_err(&pdev->dev, "Cannot map to irq\n");
+ err = -ENODEV;
+ goto failed_get;
+ }
+
+ mem_size = resource_size(mem);
+ flexcan_res->addr = mem->start;
+ flexcan_res->size = mem_size;
+ flexcan_res->drv_name = pdev->name;
+
+ flexcan_ops->clk_enable = clk_enable;
+ flexcan_ops->clk_disable = clk_disable;
+ flexcan_ops->clk_get_rate = clk_get_rate;
+ flexcan_ops->clk_get = clk_get;
+ flexcan_ops->clk_put = clk_put;
+ return 0;
+failed_get:
+ return err;
+}
/**
* flexcan_probe - performs the resource initialization
@@ -212,6 +260,15 @@ static int flexcan_probe(struct platform_device *pdev)
err = -EINVAL;
goto failed_req;
}
+ } else {
+ err = flexcan_plt_resource_init(&flexcan_res, pdev,
+ &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);
@@ -251,6 +308,9 @@ static int flexcan_remove(struct platform_device *pdev)
addr = of_translate_address(pdev->dev.of_node,
of_get_address(pdev->dev.of_node, 0, &size, NULL));
release_mem_region(addr, size);
+ } else {
+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ release_mem_region(addr, size);
} clk_put(priv->clk);
platform_set_drvdata(pdev, NULL);
@@ -259,3 +319,42 @@ static int flexcan_remove(struct platform_device *pdev)
return 0;
}
+
+static struct of_device_id flexcan_match[] = {
+ {
+ .compatible = "fsl,flexcan-v1.0",
+ },
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, flexcan_match);
+
+static struct platform_driver flexcan_driver = {
+ .driver = {
+ .name = "DRV_NAME",
+ .owner = THIS_MODULE,
+#ifdef CONFIG_OF
+ .of_match_table = flexcan_match,
+#endif
+ },
+ .probe = flexcan_probe,
+ .remove = flexcan_remove,
+};
+
+static int __init flexcan_init(void)
+{
+ return platform_driver_register(&flexcan_driver);
+}
+
+static void __exit flexcan_exit(void)
+{
+ platform_driver_unregister(&flexcan_driver);
+}
+
+module_init(flexcan_init);
+module_exit(flexcan_exit);
+
+MODULE_AUTHOR("Sascha Hauer <kernel@pengutronix.de>, "
+ "Marc Kleine-Budde <kernel@pengutronix.de>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("CAN port driver for flexcan based chip");
--
1.5.6.5
^ permalink raw reply related
* [PATCH 3/4] powerpc/p1010: FlexCAN Controller for of_ type
From: Bhaskar Upadhaya @ 2011-08-08 15:00 UTC (permalink / raw)
To: netdev, mkl, holt, wg, davem, linuxppc-release, b22300,
<socketcan-
Cc: Bhaskar Upadhaya
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>
---
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(®s->mcr);
+ reg = flexcan_read(®s->mcr);
+
reg &= ~FLEXCAN_MCR_MDIS;
- writel(reg, ®s->mcr);
+ flexcan_write(reg, ®s->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(®s->mcr);
+ reg = flexcan_read(®s->mcr);
+
reg |= FLEXCAN_MCR_MDIS;
- writel(reg, ®s->mcr);
+ flexcan_write(reg, ®s->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(®s->ecr);
- bec->txerr = (reg >> 0) & 0xff;
+ u32 reg = flexcan_read(®s->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, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
+ flexcan_write(data,
+ ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
}
if (cf->can_dlc > 3) {
u32 data = be32_to_cpup((__be32 *)&cf->data[4]);
- writel(data, ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
+ flexcan_write(data,
+ ®s->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
}
- writel(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
- writel(ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
+ flexcan_write(can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
+ flexcan_write(ctrl, ®s->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 = ®s->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, ®s->iflag1);
- readl(®s->timer);
+ flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->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(®s->esr) | priv->reg_esr;
+ reg_esr = flexcan_read(®s->esr) | priv->reg_esr;
/* handle state changes */
work_done += flexcan_poll_state(dev, reg_esr);
/* handle RX-FIFO */
- reg_iflag1 = readl(®s->iflag1);
- while (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE &&
- work_done < quota) {
+ reg_iflag1 = flexcan_read(®s->iflag1);
+ while ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) &&
+ (work_done < quota)) {
work_done += flexcan_read_frame(dev);
- reg_iflag1 = readl(®s->iflag1);
+ reg_iflag1 = flexcan_read(®s->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, ®s->imask1);
- writel(priv->reg_ctrl_default, ®s->ctrl);
+ flexcan_write(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
+ flexcan_write(priv->reg_ctrl_default, ®s->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(®s->iflag1);
- reg_esr = readl(®s->esr);
- writel(FLEXCAN_ESR_ERR_INT, ®s->esr); /* ACK err IRQ */
+ flexcan_reg_dump(dev);
+ reg_iflag1 = flexcan_read(®s->iflag1);
+ reg_esr = flexcan_read(®s->esr);
+ flexcan_write(FLEXCAN_ESR_ERR_INT, ®s->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,
- ®s->imask1);
- writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
- ®s->ctrl);
+ flexcan_write(FLEXCAN_IFLAG_DEFAULT &
+ ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, ®s->imask1);
+ flexcan_write(priv->reg_ctrl_default &
+ ~FLEXCAN_CTRL_ERR_ALL, ®s->ctrl);
napi_schedule(&priv->napi);
}
/* FIFO overflow */
if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
- writel(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, ®s->iflag1);
+ flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW,
+ ®s->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), ®s->iflag1);
+ flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->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(®s->ctrl);
+ reg = flexcan_read(®s->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, ®s->ctrl);
+ flexcan_write(reg, ®s->ctrl);
/* print chip status */
dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
- readl(®s->mcr), readl(®s->ctrl));
+ flexcan_read(®s->mcr), flexcan_read(®s->ctrl));
}
/**
@@ -751,10 +742,10 @@ static int flexcan_chip_start(struct net_device *dev)
flexcan_chip_enable(priv);
/* soft reset */
- writel(FLEXCAN_MCR_SOFTRST, ®s->mcr);
+ flexcan_write(FLEXCAN_MCR_SOFTRST, ®s->mcr);
udelay(10);
- reg_mcr = readl(®s->mcr);
+ reg_mcr = flexcan_read(®s->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(®s->mcr);
+ reg_mcr = flexcan_read(®s->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, ®s->mcr);
+ flexcan_write(reg_mcr, ®s->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(®s->ctrl);
+ reg_ctrl = flexcan_read(®s->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, ®s->ctrl);
+ flexcan_write(reg_ctrl, ®s->ctrl);
for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
- writel(0, ®s->cantxfg[i].can_ctrl);
- writel(0, ®s->cantxfg[i].can_id);
- writel(0, ®s->cantxfg[i].data[0]);
- writel(0, ®s->cantxfg[i].data[1]);
+ flexcan_write(0, ®s->cantxfg[i].can_ctrl);
+ flexcan_write(0, ®s->cantxfg[i].can_id);
+ flexcan_write(0, ®s->cantxfg[i].data[0]);
+ flexcan_write(0, ®s->cantxfg[i].data[1]);
/* put MB into rx queue */
- writel(FLEXCAN_MB_CNT_CODE(0x4), ®s->cantxfg[i].can_ctrl);
+ flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
+ ®s->cantxfg[i].can_ctrl);
}
/* acceptance mask/acceptance code (accept everything) */
- writel(0x0, ®s->rxgmask);
- writel(0x0, ®s->rx14mask);
- writel(0x0, ®s->rx15mask);
+ flexcan_write(0x0, ®s->rxgmask);
+ flexcan_write(0x0, ®s->rx14mask);
+ flexcan_write(0x0, ®s->rx15mask);
flexcan_transceiver_switch(priv, 1);
/* synchronize with the can bus */
- reg_mcr = readl(®s->mcr);
+ reg_mcr = flexcan_read(®s->mcr);
reg_mcr &= ~FLEXCAN_MCR_HALT;
- writel(reg_mcr, ®s->mcr);
+ flexcan_write(reg_mcr, ®s->mcr);
priv->can.state = CAN_STATE_ERROR_ACTIVE;
/* enable FIFO interrupts */
- writel(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
+ flexcan_write(FLEXCAN_IFLAG_DEFAULT, ®s->imask1);
/* print chip status */
dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n",
- __func__, readl(®s->mcr), readl(®s->ctrl));
+ __func__, flexcan_read(®s->mcr),
+ flexcan_read(®s->ctrl));
return 0;
@@ -860,12 +853,12 @@ static void flexcan_chip_stop(struct net_device *dev)
u32 reg;
/* Disable all interrupts */
- writel(0, ®s->imask1);
+ flexcan_write(0, ®s->imask1);
/* Disable + halt module */
- reg = readl(®s->mcr);
+ reg = flexcan_read(®s->mcr);
reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
- writel(reg, ®s->mcr);
+ flexcan_write(reg, ®s->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(®s->ctrl);
+ reg = flexcan_read(®s->ctrl);
reg |= FLEXCAN_CTRL_CLK_SRC;
- writel(reg, ®s->ctrl);
+ flexcan_write(reg, ®s->ctrl);
flexcan_chip_enable(priv);
/* set freeze, halt and activate FIFO, restrict register access */
- reg = readl(®s->mcr);
+ reg = flexcan_read(®s->mcr);
reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
- writel(reg, ®s->mcr);
+ flexcan_write(reg, ®s->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(®s->mcr);
+ reg = flexcan_read(®s->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;
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;
+}
+
--
1.5.6.5
^ permalink raw reply related
* [PATCH 2/4][upstream] powerpc/p1010: Add description for FlexCAN functions
From: Bhaskar Upadhaya @ 2011-08-08 15:00 UTC (permalink / raw)
To: netdev, mkl, holt, wg, davem, linuxppc-release, b22300,
<socketcan-
Cc: Bhaskar Upadhaya
Add description to the existing function of FlexCAN
Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
---
Based on http://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
Branch master
drivers/net/can/flexcan.c | 121 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 111 insertions(+), 10 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1767811..a24aa12 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -4,6 +4,7 @@
* Copyright (c) 2005-2006 Varma Electronics Oy
* Copyright (c) 2009 Sascha Hauer, Pengutronix
* Copyright (c) 2010 Marc Kleine-Budde, Pengutronix
+ * Copyright 2011 Freescale Semiconductor, Inc.
*
* Based on code originally by Andrey Volkov <avolkov@varma-el.com>
*
@@ -191,8 +192,11 @@ static struct can_bittiming_const flexcan_bittiming_const = {
.brp_inc = 1,
};
-/*
- * Swtich transceiver on or off
+/**
+ * flexcan_transceiver_switch - Switches the transceiver
+ * on/off
+ * @priv: pointer to private data
+ * @on: 1 == turns transceiver on, 0 == turn it off
*/
static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on)
{
@@ -200,6 +204,12 @@ static void flexcan_transceiver_switch(const struct flexcan_priv *priv, int on)
priv->pdata->transceiver_switch(on);
}
+/**
+ * flexcan_has_and_handle_berr - returns 0/1 after checking the
+ * Error and Status register.
+ * @priv: pointer to private data
+ * @reg_esr: error and status register.
+ */
static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
u32 reg_esr)
{
@@ -207,6 +217,13 @@ static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
(reg_esr & FLEXCAN_ESR_ERR_BUS);
}
+/**
+ * flexcan_chip_enable - enables the flexCAN
+ * @priv: pointer to private data
+ *
+ * Enables FlexCAN by writing to the MDIS bit
+ * of MCR
+ */
static inline void flexcan_chip_enable(struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->base;
@@ -219,6 +236,13 @@ static inline void flexcan_chip_enable(struct flexcan_priv *priv)
udelay(10);
}
+/**
+ * flexcan_chip_disable - disables the flexCAN
+ * @priv: pointer to private data
+ *
+ * disables FlexCAN by writing to the MDIS bit
+ * of MCR
+ */
static inline void flexcan_chip_disable(struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->base;
@@ -229,6 +253,14 @@ static inline void flexcan_chip_disable(struct flexcan_priv *priv)
writel(reg, ®s->mcr);
}
+/**
+ * flexcan_get_berr_counter - gets the Rx/Tx Error counter
+ * @dev: dev pointer of FlexCAN
+ * @bec: buffer to be filled with Tx/Rx Error Counter
+ *
+ * fills the tx/rx error counter values from the ECR
+ * register of FlexCAN
+ */
static int flexcan_get_berr_counter(const struct net_device *dev,
struct can_berr_counter *bec)
{
@@ -242,6 +274,17 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
return 0;
}
+/**
+ * flexcan_start_xmit -
+ * @skb: socket buffer to hold CAN frames
+ * @dev: dev pointer of FlexCAN
+ *
+ * validates the incomming socket buffer and also
+ * prepares the message buffer for transmission process
+ *
+ * Return value
+ * - NETDEV_TX_OK
+ */
static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
const struct flexcan_priv *priv = netdev_priv(dev);
@@ -286,6 +329,16 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
+/**
+ * do_bus_err - fills the FlexCAN Message buffer
+ * depending on the Error and Status register
+ * @dev: dev pointer of FlexCAN
+ * @cf: can frame
+ * @reg_esr: error and status register
+ *
+ * checks the various error bits of Error and status
+ * register, and fills the message buffer of CAN frame accordingly
+ */
static void do_bus_err(struct net_device *dev,
struct can_frame *cf, u32 reg_esr)
{
@@ -352,6 +405,16 @@ static int flexcan_poll_bus_err(struct net_device *dev, u32 reg_esr)
return 1;
}
+/**
+ * do_state - updates the CAN frame depending on
+ * CAN bus states
+ * @dev: dev pointer of FlexCAN
+ * @cf: can frame
+ * @new_state: CAN frame is filled in accordance with the new_state
+ *
+ * checks the new_state against various CAN bus states
+ * and fills the id and data fields of CAN frame accordingly
+ */
static void do_state(struct net_device *dev,
struct can_frame *cf, enum can_state new_state)
{
@@ -418,6 +481,15 @@ static void do_state(struct net_device *dev,
}
}
+/**
+ * flexcan_poll_state - polls FlexCAN state depending on the Fault
+ * confinement state of ESR
+ * @dev: dev pointer of FlexCAN
+ * @reg_esr: Error and Status register
+ *
+ * polls for FlexCAN state ie busoff, error active,
+ * error passive or error warning depending on the fault confinement state
+ */
static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
{
struct flexcan_priv *priv = netdev_priv(dev);
@@ -504,6 +576,14 @@ static int flexcan_read_frame(struct net_device *dev)
return 1;
}
+/**
+ * flexcan_poll - NAPI interface poll function
+ * @napi: napi pointer
+ * @quota: Number of packets to be processed
+ *
+ * checks whether the FIFO bits are set for Interrupt Flag1
+ * register and then process the received frames
+ */
static int flexcan_poll(struct napi_struct *napi, int quota)
{
struct net_device *dev = napi->dev;
@@ -543,6 +623,16 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
return work_done;
}
+/**
+ * flexcan_irq - ISR handler
+ * @irq: irq number
+ * @dev_id: device id
+ *
+ * handler gets called in the below context
+ * 1. When the frames are available in FIFO
+ * 2. FIFO Ovrflow
+ * 3. Transmission complete interrupt
+ */
static irqreturn_t flexcan_irq(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
@@ -594,6 +684,13 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
return IRQ_HANDLED;
}
+/**
+ * flexcan_set_bittiming - Sets bit-timing paramaters
+ * @dev: dev pointer of FlexCAN
+ *
+ * sets the bit-timing parameters of FlexCAN
+ * responsible for CAN clock generation.
+ */
static void flexcan_set_bittiming(struct net_device *dev)
{
const struct flexcan_priv *priv = netdev_priv(dev);
@@ -632,11 +729,15 @@ static void flexcan_set_bittiming(struct net_device *dev)
readl(®s->mcr), readl(®s->ctrl));
}
-/*
- * flexcan_chip_start
- *
- * this functions is entered with clocks enabled
+/**
+ * flexcan_chip_start - performs the basic CAN initialization
+ * @dev: dev pointer of FlexCAN
*
+ * function is entered with clocks enabled
+ * It does the following
+ * 1. Enabling the CAN module
+ * 2. Basic registers initialization
+ * 3. Enabling FIFO
*/
static int flexcan_chip_start(struct net_device *dev)
{
@@ -746,11 +847,11 @@ static int flexcan_chip_start(struct net_device *dev)
return err;
}
-/*
- * flexcan_chip_stop
- *
- * this functions is entered with clocks enabled
+/**
+ * flexcan_chip_stop -
+ * @dev: dev pointer of FlexCAN
*
+ * disables the CAN
*/
static void flexcan_chip_stop(struct net_device *dev)
{
--
1.5.6.5
^ permalink raw reply related
* [PATCH 1/4][upstream] powerpc/p1010: Rearrange header file for FlexCAN
From: Bhaskar Upadhaya @ 2011-08-08 14:59 UTC (permalink / raw)
To: netdev, mkl, holt, wg, davem, linuxppc-release, b22300,
<socketcan-
Cc: Bhaskar Upadhaya
- Rearrange header file so that it can be used by both of_ type
and platform_ type architecture.
- Provide a common read and write interface for of_ type and platform_
type architecture for accessing h/w registers.
Signed-off-by: Bhaskar Upadhaya <bhaskar.upadhaya@freescale.com>
---
Based on http://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6.git
Branch master
include/linux/can/platform/flexcan.h | 65 ++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/include/linux/can/platform/flexcan.h b/include/linux/can/platform/flexcan.h
index 72b713a..8458a87 100644
--- a/include/linux/can/platform/flexcan.h
+++ b/include/linux/can/platform/flexcan.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Marc Kleine-Budde <kernel@pengutronix.de>
+ * Copyright 2011 Freescale Semiconductor, Inc.
*
* This file is released under the GPLv2
*
@@ -8,6 +9,27 @@
#ifndef __CAN_PLATFORM_FLEXCAN_H
#define __CAN_PLATFORM_FLEXCAN_H
+#include <linux/clk.h>
+#include <linux/can/dev.h>
+#include <linux/io.h>
+
+#ifdef CONFIG_OF
+#include<linux/of_platform.h>
+#else
+#include <linux/platform_device.h>
+#include <mach/clock.h>
+#endif
+
+#define DRV_NAME "flexcan"
+
+#ifdef __BIG_ENDIAN
+#define flexcan_read(x) in_be32(x)
+#define flexcan_write(x, y) out_be32(y, x)
+#else
+#define flexcan_read(x) readl(x)
+#define flexcan_write(x, y) writel(x, y)
+#endif
+
/**
* struct flexcan_platform_data - flex CAN controller platform data
* @transceiver_enable: - called to power on/off the transceiver
@@ -17,4 +39,47 @@ struct flexcan_platform_data {
void (*transceiver_switch)(int enable);
};
+struct flexcan_interface {
+ int (*clk_enable) (struct clk *clk);
+ void (*clk_disable) (struct clk *clk);
+ void (*clk_put) (struct clk *clk);
+ unsigned long (*clk_get_rate) (struct clk *clk);
+ struct clk *(*clk_get) (struct device *dev, const char *id);
+};
+
+struct flexcan_resource {
+ u32 irq;
+ u64 addr;
+ u64 size;
+ const char *drv_name;
+};
+
+#ifdef CONFIG_OF
+struct clk {
+ unsigned long rate;
+ void *data;
+};
+#endif
+
+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_interface *flexcan_ops;
+ struct flexcan_platform_data *pdata;
+};
+
+int flexcan_dev_init(struct device *pdev, struct flexcan_resource
+ flexcan_res, struct flexcan_interface *flexcan_ops);
+
+void __devexit unregister_flexcandev(struct net_device *dev);
+
+void flexcan_reg_dump(struct net_device *dev);
+
#endif /* __CAN_PLATFORM_FLEXCAN_H */
--
1.5.6.5
^ permalink raw reply related
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 14:59 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, U Bhaskar-B22300,
Marc Kleine-Budde, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808144424.GY4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 04:44 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 04:21 PM, Robin Holt wrote:
>>> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>>>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>>>
>>>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>>>> ...
>>>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>>>> + "clock_freq", gd->bus_clk, 1);
>>>>>
>>>>> Should I go back to flexcan-v1.0 in my patches?
>>>>
>>>> Well, no. Let's wait. I don't think we need it. Also, it sets
>>>> "clock_freq" while
>>>>
>>>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>>>
>>>> documents "clock-frequencies"... :-(.
>>>
>>> You answered a different question that I was asking. I was asking if
>>> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
>>> line 5. The clock_freq looks like a uboot change will need to be made
>>> as well.
>>
>> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>>
>> For the P1010 we can sinmply derive the clock frequency from
>> "fsl_get_sys_freq()", which is fine for the time being. No extra
>> properties, etc. The clk implemetation might go into
>>
>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>>
>> or
>>
>> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>>
>> And may depend on HAVE_CAN_FLEXCAN
>>
>> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
>> you using?
>
> I am starting with the v3.0 kernel, apply one patch from the freescale BSP
> we receive under NDA which introduces the P1010RDB board into the QorIQ
> platform, and then work from there for the flexcan stuff. That patch
> introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
> that Kconfig bit, so I have tweaked it to be selected automatically
> when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
> selection to determine is we are going to build the flexcan.c file.
ARM boards select HAVE_CAN_FLEXCAN and I do not see a good reason why
we should do it differently for PowerPC.
For mainline inclusion, you should provide your patches against the
David Millers "net-next-2.6" tree, which already seems to have support
for the P1010RDB:
config P1010_RDB
bool "Freescale P1010RDB"
select DEFAULT_UIMAGE
help
This option enables support for the MPC85xx RDB (P1010 RDB) board
P1010RDB contains P1010Si, which provides CPU performance up to 800
MHz and 1600 DMIPS, additional functionality and faster interfaces
(DDR3/3L, SATA II, and PCI Express).
> Our contact with Freescale would prefer that I not post that patch until
> we get the OK from freescale to do so since we received it under NDA.
I don't think we currently need it. I prefer dropping and cleaning up
the device tree stuff as it is not needed for the P1010 anyway. If a
new processor shows up with enhanced capabilities requiring
configuration via device tree, we or somebody else can provide a patch.
Marc, what do you think?
Wolfgang.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 14:48 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FF4B8.2010603-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
> On 08/08/2011 04:21 PM, Robin Holt wrote:
> > On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
> >> On 08/08/2011 03:56 PM, Robin Holt wrote:
> >>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>
> >>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
> >>> ...
> >>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
> >>> + "clock_freq", gd->bus_clk, 1);
> >>>
> >>> Should I go back to flexcan-v1.0 in my patches?
> >>
> >> Well, no. Let's wait. I don't think we need it. Also, it sets
> >> "clock_freq" while
> >>
> >> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> >>
> >> documents "clock-frequencies"... :-(.
> >
> > You answered a different question that I was asking. I was asking if
> > I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> > line 5. The clock_freq looks like a uboot change will need to be made
> > as well.
>
> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
My question remains "What should we be naming the device tree node in
general. Line 5 of the fsl-flexcan.txt file specifically calls the node
"fsl,flexcan-v1.0" In the .dts file the freescale patches introduces into
the arch/powerpc portion of the kernel, they call it that same thing.
Likewise, in the code already checked into uboot it is the same name.
Whether it is needed or not for the clock frequency, it does need to
be consistent between the .dts file and the driver for device discovery
to work.
Thanks,
Robin
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 14:44 UTC (permalink / raw)
To: Wolfgang Grandegger
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <4E3FF4B8.2010603-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
On Mon, Aug 08, 2011 at 04:37:44PM +0200, Wolfgang Grandegger wrote:
> On 08/08/2011 04:21 PM, Robin Holt wrote:
> > On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
> >> On 08/08/2011 03:56 PM, Robin Holt wrote:
> >>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>
> >>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
> >>> ...
> >>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
> >>> + "clock_freq", gd->bus_clk, 1);
> >>>
> >>> Should I go back to flexcan-v1.0 in my patches?
> >>
> >> Well, no. Let's wait. I don't think we need it. Also, it sets
> >> "clock_freq" while
> >>
> >> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
> >>
> >> documents "clock-frequencies"... :-(.
> >
> > You answered a different question that I was asking. I was asking if
> > I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> > line 5. The clock_freq looks like a uboot change will need to be made
> > as well.
>
> Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
>
> For the P1010 we can sinmply derive the clock frequency from
> "fsl_get_sys_freq()", which is fine for the time being. No extra
> properties, etc. The clk implemetation might go into
>
> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
>
> or
>
> http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
>
> And may depend on HAVE_CAN_FLEXCAN
>
> BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
> you using?
I am starting with the v3.0 kernel, apply one patch from the freescale BSP
we receive under NDA which introduces the P1010RDB board into the QorIQ
platform, and then work from there for the flexcan stuff. That patch
introduces the HAVE_CAN_FLEXCAN. I do not like how freescale structured
that Kconfig bit, so I have tweaked it to be selected automatically
when P1010RDB, NET, and CAN are selected. That allows the CAN_FLEXCAN
selection to determine is we are going to build the flexcan.c file.
Our contact with Freescale would prefer that I not post that patch until
we get the OK from freescale to do so since we received it under NDA.
Robin
>
> Wolfgang.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Wolfgang Grandegger @ 2011-08-08 14:37 UTC (permalink / raw)
To: Robin Holt
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, Marc Kleine-Budde,
U Bhaskar-B22300, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110808142153.GW4926-sJ/iWh9BUns@public.gmane.org>
On 08/08/2011 04:21 PM, Robin Holt wrote:
> On Mon, Aug 08, 2011 at 04:16:27PM +0200, Wolfgang Grandegger wrote:
>> On 08/08/2011 03:56 PM, Robin Holt wrote:
>>>> commit 65bb8b060a873fa4f5188f2951081f6011259614
>>>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>>>> Date: Fri Mar 4 20:27:58 2011 +0530
>>>
>>> On a side note, that commit fixes up "fsl,flexcan-v1.0"
>>> ...
>>> + do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
>>> + "clock_freq", gd->bus_clk, 1);
>>>
>>> Should I go back to flexcan-v1.0 in my patches?
>>
>> Well, no. Let's wait. I don't think we need it. Also, it sets
>> "clock_freq" while
>>
>> http://lxr.linux.no/#linux+v3.0.1/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
>>
>> documents "clock-frequencies"... :-(.
>
> You answered a different question that I was asking. I was asking if
> I should change fsl,flexcan back to fsl,flexcan-v1.0 as documented on
> line 5. The clock_freq looks like a uboot change will need to be made
> as well.
Well, I wrote above: "Well, no. Let's wait. I don't think we need it."
For the P1010 we can sinmply derive the clock frequency from
"fsl_get_sys_freq()", which is fine for the time being. No extra
properties, etc. The clk implemetation might go into
http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/platforms/85xx/clock.c
or
http://lxr.linux.no/#linux+v3.0.1/arch/powerpc/sysdev/fsl_soc.c
And may depend on HAVE_CAN_FLEXCAN
BTW, I have not found HAVE_CAN_FLEXCAN in your patch. What kernel are
you using?
Wolfgang.
^ permalink raw reply
* Re: [RFC 5/5] [powerpc] Implement a p1010rdb clock source.
From: Robin Holt @ 2011-08-08 14:29 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA, U Bhaskar-B22300,
Wolfgang Grandegger
In-Reply-To: <4E3FF068.6070905-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On Mon, Aug 08, 2011 at 04:19:20PM +0200, Marc Kleine-Budde wrote:
> On 08/08/2011 04:03 PM, Robin Holt wrote:
> > On Mon, Aug 08, 2011 at 03:44:36PM +0200, Marc Kleine-Budde wrote:
> >> On 08/08/2011 03:08 PM, Wolfgang Grandegger wrote:
> >>> On 08/08/2011 01:31 PM, Robin Holt wrote:
> >>>> On Mon, Aug 08, 2011 at 10:37:58AM +0200, Wolfgang Grandegger wrote:
> >>>>> On 08/06/2011 04:34 PM, Robin Holt wrote:
> >>>>>> flexcan driver needs the clk_get, clk_get_rate, etc functions
> >>>>>> to work. This patch provides the minimum functionality.
> >>>>>
> >>>>> This needs some more general thoughts... apart from the question where
> >>>>> the code should go.
> >>>>>
> >>>>> Like for the MSCAN on the MPC5200, the user should be *able* to select
> >>>>> an appropriate clock source and divider via DTS node properties.
> >>>>> Currently it seems, that the DTS properties must match some
> >>>>> pre-configured values, most likely set by the boot loader. Please
> >>>>> correct me if I'm wrong. For me this is generic and should go into the
> >>>>> Flexcan driver. From there, a platform specific function, e.g.
> >>>>> flexcan_set_clock() might be called.
> >>>>
> >>>> OK. Dug a bit more. The p1010 built-in clocksource seems to be the
> >>>> periphereal clock frequency which is system bus frequency divided
> >>>> by 2. The clock source can not be changed, but the clock divider can
> >>>> by freezing the interface and setting the CTRL register. This appears
> >>>> to only be done by the boot loader. I do not see why we can not leave
> >>>
> >>> And likely Freescale's bootloader does also fixup the DTS Flexcan node.
> >>> Ah, oh, there's already someting in the mainline U-BOOT:
> >>>
> >>> commit 65bb8b060a873fa4f5188f2951081f6011259614
> >>> Author: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>> Date: Fri Mar 4 20:27:58 2011 +0530
> >>>
> >>> powerpc/85xx: Fix up clock_freq property in CAN node of dts
> >>>
> >>> Fix up the device tree property associated with the Flexcan clock
> >>> frequency. This property is used to calculate the bit timing parameters
> >>> for Flexcan.
> >>>
> >>> Signed-off-by: Bhaskar Upadhaya <Bhaskar.Upadhaya-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> >>> Signed-off-by: Kumar Gala <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
> >>>
> >>>
> >>>> that functionality in the boot loader and then go back to a variation
> >>>> on my earlier flexcan_clk_* patch. Is that close to the direction you
> >>>> think we should go or have I completely misunderstood your wishes?
> >>>
> >>> The boot loader might not chose the optimum clock source and frequency,
> >>> which might even be application dependent. Therefore it would be nice to
> >>> allow the user to change it if necessary. Some CAN interfaces do even
> >>> allow to use an external clock source. The main question is where we add
> >>> that functionality. As more as I think of it, the clock interface would
> >>> not be that bad, especially if it's available.
> >>>
> >>> Furthermore, if the bootloader sets the clock source and divider, we do
> >>> not need device tree properties for it. A simply register lookup would
> >>> reveal what values are used. We may just need the input clock source.
> >>
> >> If the bootloader touches the divider _in_ the flexcan core, that would
> >> make absolutely no sense. The clock divider in the flexcan core (in the
> >> CTRL register) is the bitrate pre-scaler calculated by the bit-timing
> >> algorithm.
> >>
> >> What we need in the device tree is, from my point of view.
> >> a) the used clock source (bus clock or xtal clock)
> >> b) the frequency of that clock
> >>
> >> These problems are solved on arm via:
> >> a) bus clock is hard coded [1]
> >> b) get that clock frequency via clk_get_rate().
> >
> > Just to make sure I understand correctly, the clk_get_rate() return
> > value comes from the device tree and a mach specific handler, right?
> > And 'mach-specific' really means what, a processor family?
>
> I'm talking about the mainline driver, that has no device tree support.
> The clock stuff on arm currently goes like this:
What is the difference between device tree support and the clkdev based
clock sources using of_match to find a clock source for a particular
device. It looks to me like those are filled in based upon device tree
information, but I _TRULY_ do not know what I am talking about.
> The driver asks for the clock related to the device. The architecture
> code has previously connected the flexcan device to an arch specific
> (i.mx25, i.mx35) clock. That clock is returned. Enable/disable/get_rate
> are working on that specific clock.
I will go and study that some more. I did my cross-compile using
mxs_defconfig. Is there a better config I should be using? I typically
compile a kernel with the drivers I desire and then build my cscope
database using the files used in that build.
Thanks,
Robin
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox