Re: [PATCH v4 1/6] can: flexcan: Remodel FlexCAN register r/w APIs for big endian FlexCAN controllers.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxx>
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@xxxxxxxxxxxxx>
> Signed-off-by: Sakar Arora <Sakar.Arora@xxxxxxxxxxxxx>
> Reviewed-by: Zhengxiong Jin <Jason.Jin@xxxxxxxxxxxxx>
> Reviewed-by: Poonam Aggrwal <poonam.aggrwal@xxxxxxx>
> ---
> 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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux