From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Pankaj Bansal <pankaj.bansal-3arQi8VN3Tc@public.gmane.org>,
wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org,
linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: V.Sethi-3arQi8VN3Tc@public.gmane.org,
poonam.aggrwal-3arQi8VN3Tc@public.gmane.org,
Bhupesh Sharma
<bhupesh.sharma-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
Sakar Arora <Sakar.Arora-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Subject: Re: [PATCH v4 1/6] can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers.
Date: Fri, 24 Nov 2017 16:02:39 +0100 [thread overview]
Message-ID: <44f37aef-7f45-a7c7-7320-01a62e23fbde@pengutronix.de> (raw)
In-Reply-To: <1511529733-27942-2-git-send-email-pankaj.bansal-3arQi8VN3Tc@public.gmane.org>
[-- Attachment #1.1: Type: text/plain, Size: 3511 bytes --]
On 11/24/2017 02:22 PM, Pankaj Bansal wrote:
> The FlexCAN driver assumed that FlexCAN controller is big endian for
> powerpc architecture and little endian for other architectures.
>
> But this may not be the case. FlexCAN controller can be little or big
> endian on any architecture. For e.g. NXP LS1021A ARM based SOC has big
> endian FlexCAN controller.
>
> Therefore, the driver has been modified to add a provision for both
> types of controllers using an additional device tree property. On a
> "fsl,p1010-flexcan" device BE is default, on all other devices LE is.
>
> Big Endian controllers should have "big-endian" set in the device tree.
> check "Documentation/devicetree/bindings/net/can/fsl-flexcan.txt" for
> usage.
>
> This is the standard practice followed in linux. for more info check:
> Documentation/devicetree/bindings/common-properties.txt
>
> Signed-off-by: Pankaj Bansal <pankaj.bansal-3arQi8VN3Tc@public.gmane.org>
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Signed-off-by: Sakar Arora <Sakar.Arora-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Reviewed-by: Zhengxiong Jin <Jason.Jin-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Reviewed-by: Poonam Aggrwal <poonam.aggrwal-3arQi8VN3Tc@public.gmane.org>
> ---
> Changes in v4:
> - Merged device tree changes and driver changes in one series
> Changes in v3:
> - Added fsl,imx25-flexcan, fsl,imx35-flexcan and fsl,imx53-flexcan
> support to the driver.
> - Modified patch deciption to state default endianness followed and
> to include fsl-flexcan.txt referance.
> Changes in v2:
> - Modified patch deciption to include common-properties.txt reference.
> - Reorder the LE/BE read/write APIs for better readability of code
> - Added an exception to force BE API selection, for powerpc based platform
> P1010. This ensures that new linux kernel works with old P1010
> device-tree, while future powerpc platforms that use big endian
> FlexCAN controller need to specify big-endian in device tree in
> FlexCAN node.
> - Tested on P1010 after backporting to freescale sdk 1.4 linux, without
> any change in device-tree.
> - Tested on NXP LS1021A arm based platform.
>
> drivers/net/can/flexcan.c | 233 ++++++++++++++++++++----------------
> 1 file changed, 131 insertions(+), 102 deletions(-)
>
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index a13a489..4c873fb 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
[...]
I think this will select LE for non DT devices, right?
> + if (of_property_read_bool(pdev->dev.of_node, "big-endian")) {
> + priv->read = flexcan_read_be;
> + priv->write = flexcan_write_be;
> + } else {
> + if (of_device_is_compatible(pdev->dev.of_node,
> + "fsl,p1010-flexcan")) {
> + priv->read = flexcan_read_be;
> + priv->write = flexcan_write_be;
> + } else {
> + priv->read = flexcan_read_le;
> + priv->write = flexcan_write_le;
> + }
> + }
> +
> priv->can.clock.freq = clock_freq;
> priv->can.bittiming_const = &flexcan_bittiming_const;
> priv->can.do_set_mode = flexcan_set_mode;
>
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: 488 bytes --]
next prev parent reply other threads:[~2017-11-24 15:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-24 13:22 [PATCH v4 0/6] Remodel FlexCAN register r/w APIs for big endian Pankaj Bansal
[not found] ` <1511529733-27942-1-git-send-email-pankaj.bansal-3arQi8VN3Tc@public.gmane.org>
2017-11-24 13:22 ` [PATCH v4 1/6] can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers Pankaj Bansal
[not found] ` <1511529733-27942-2-git-send-email-pankaj.bansal-3arQi8VN3Tc@public.gmane.org>
2017-11-24 15:02 ` Marc Kleine-Budde [this message]
[not found] ` <44f37aef-7f45-a7c7-7320-01a62e23fbde-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2017-11-26 2:20 ` Pankaj Bansal
2017-11-27 14:06 ` Marc Kleine-Budde
2017-11-24 13:22 ` [PATCH v4 2/6] can: flexcan: adding platform specific details for LS1021A Pankaj Bansal
2017-11-24 13:22 ` [PATCH v4 3/6] Documentation : can : flexcan : Add big-endian property to device tree Pankaj Bansal
[not found] ` <1511529733-27942-4-git-send-email-pankaj.bansal-3arQi8VN3Tc@public.gmane.org>
2017-11-26 22:18 ` Rob Herring
2017-11-24 13:22 ` [PATCH v4 6/6] arm/dts: Add nodes for flexcan devices present on LS1021A-Rev2 SoC Pankaj Bansal
2017-11-27 14:07 ` [PATCH v4 0/6] Remodel FlexCAN register r/w APIs for big endian Marc Kleine-Budde
2017-11-24 13:22 ` [PATCH v4 4/6] powerpc: dts: P1010: Add endianness property to flexcan node Pankaj Bansal
2017-11-24 13:22 ` [PATCH v4 5/6] arm: dts: Remove p1010-flexcan compatible from imx series dts Pankaj Bansal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44f37aef-7f45-a7c7-7320-01a62e23fbde@pengutronix.de \
--to=mkl-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=Sakar.Arora-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
--cc=V.Sethi-3arQi8VN3Tc@public.gmane.org \
--cc=bhupesh.sharma-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pankaj.bansal-3arQi8VN3Tc@public.gmane.org \
--cc=poonam.aggrwal-3arQi8VN3Tc@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).