Re: [PATCH 3/3] can-calc-bittiming: add mcan

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

 



On 24.06.2021 05:19:54, Kurt Van Dijck wrote:
> Signed-off-by: Kurt Van Dijck <dev.kurt@xxxxxxxxxxxxxxxxxxxxxx>
> ---
>  can-calc-bit-timing.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
> index d0626f7..fd37886 100644
> --- a/can-calc-bit-timing.c
> +++ b/can-calc-bit-timing.c
> @@ -307,6 +307,23 @@ static void printf_btr_c_can(struct can_bittiming *bt, bool hdr)
>  	}
>  }
>  
> +static void printf_btr_mcan(struct can_bittiming *bt, bool hdr)
> +{
> +	if (hdr) {
> +		printf("%10s", "NBTP");
> +	} else {
> +		uint32_t nbtp;
> +
> +
> +		nbtp = (((bt->brp -1) & 0x1ff) << 16) |
> +			(((bt->sjw -1) & 0x7f) << 25) |
> +			(((bt->prop_seg + bt->phase_seg1 -1) & 0xff) << 8) |
> +			(((bt->phase_seg2 -1) & 0x7f) << 0);
> +
> +		printf("0x%08x", nbtp);
> +	}
> +}
> +
>  static struct calc_bittiming_const can_calc_consts[] = {
>  	{
>  		.bittiming_const = {
> @@ -483,6 +500,22 @@ static struct calc_bittiming_const can_calc_consts[] = {
>  			{ .clk = 24000000, },
>  		},
>  		.printf_btr = printf_btr_c_can,
> +	}, {
> +		.bittiming_const = {
> +			.name = "mcan",

This is for mcan > v3.1

> +			.tseg1_min = 1,
> +			.tseg1_max = 256,
> +			.tseg2_min = 1,

I just re-chcked the datasheet, and tseg{1,2} min are actually 2.

> +			.tseg2_max = 128,
> +			.sjw_max = 128,
> +			.brp_min = 1,
> +			.brp_max = 512,
> +			.brp_inc = 1,
> +		},
> +		.ref_clk = {
> +			{ .clk = 40000000, },
> +		},
> +		.printf_btr = printf_btr_mcan,
>  	},
>  };

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux