Linux CAN drivers development
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Bhupesh Sharma <bhupesh.sharma@freescale.com>, linux-can@vger.kernel.org
Cc: wg@grandegger.com, netdev@vger.kernel.org
Subject: Re: [PATCH V2 1/1] net: can: Remodel FlexCAN register read/write APIs for BE instances
Date: Fri, 04 Jul 2014 15:41:08 +0200	[thread overview]
Message-ID: <53B6AEF4.6080301@pengutronix.de> (raw)
In-Reply-To: <1404478881-21853-1-git-send-email-bhupesh.sharma@freescale.com>

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

On 07/04/2014 03:01 PM, Bhupesh Sharma wrote:
> The FlexCAN IP on certain SoCs like (Freescale's LS1021A) is
> modelled in a big-endian fashion, i.e. the registers and the
> message buffers are organized in a BE way.
> 
> More details about the LS1021A SoC can be seen here:
> http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=LS1021A&nodeId=018rH325E4017B#
> 
> This patch ensures that the register read/write APIs are remodelled
> to address such cases, while ensuring that existing platforms (where
> the FlexCAN IP was modelled in LE way) do not break.
> 
> Tested on LS1021A-QDS board.
> 
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@freescale.com>
> ---
> Changes since v1:
> - Addressed Marc's review comments.
> - Also tried on ARM big-endian kernel
> 
> Rebased against v3.16-rc2

Please use net-next or linux-can-next, but I think this makes no
difference here.

>  drivers/net/can/flexcan.c |  192 +++++++++++++++++++++++++++------------------
>  1 file changed, 114 insertions(+), 78 deletions(-)

I'm missing the DT documentation update.

[...]

		of_property_read_u32(pdev->dev.of_node,
> @@ -1149,6 +1166,25 @@ static int flexcan_probe(struct platform_device *pdev)
>  	dev->flags |= IFF_ECHO;
>  
>  	priv = netdev_priv(dev);
> +
> +	if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
> +		core_is_little = false;
> +
> +	if (of_property_read_bool(dev->dev.of_node, "big-endian"))
> +		module_is_little = false;
> +
> +	if ((core_is_little && module_is_little) ||
> +	    (!core_is_little && !module_is_little)) {

I think this is broken on PPC, where both core and module are BE. Please
assume native endianess an default, if neither big-endian nor
little-endian is present.

> +		priv->read = flexcan_read_le;
> +		priv->write = flexcan_write_le;
> +	}
> +
> +	if ((!core_is_little && module_is_little) ||
> +	    (core_is_little && !module_is_little)) {
> +		priv->read = flexcan_read_be;
> +		priv->write = flexcan_write_be;
> +	}
> +
>  	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: 242 bytes --]

  reply	other threads:[~2014-07-04 13:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 13:01 [PATCH V2 1/1] net: can: Remodel FlexCAN register read/write APIs for BE instances Bhupesh Sharma
2014-07-04 13:41 ` Marc Kleine-Budde [this message]
2014-07-04 13:47   ` bhupesh.sharma
2014-07-04 13:53     ` Marc Kleine-Budde

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=53B6AEF4.6080301@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=bhupesh.sharma@freescale.com \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=wg@grandegger.com \
    /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