From c68980320412a9e9a93d35bff9f73abe6385347c Mon Sep 17 00:00:00 2001 From: Ramesh Shanmugasundaram Date: Mon, 29 Feb 2016 10:18:45 +0000 Subject: [PATCH] can-calc-bit-timing: add support for rcar_can Signed-off-by: Ramesh Shanmugasundaram Signed-off-by: Marc Kleine-Budde --- can-calc-bit-timing.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c index 9031a78..77f1333 100644 --- a/can-calc-bit-timing.c +++ b/can-calc-bit-timing.c @@ -219,6 +219,27 @@ static void printf_btr_ti_hecc(struct can_bittiming *bt, int hdr) } } +#define RCAR_CAN_BCR_TSEG1(x) (((x) & 0x0f) << 20) +#define RCAR_CAN_BCR_BPR(x) (((x) & 0x3ff) << 8) +#define RCAR_CAN_BCR_SJW(x) (((x) & 0x3) << 4) +#define RCAR_CAN_BCR_TSEG2(x) ((x) & 0x07) + +static void printf_btr_rcar_can(struct can_bittiming *bt, int hdr) +{ + if (hdr) { + printf("%10s", "CiBCR"); + } else { + uint32_t bcr; + + bcr = RCAR_CAN_BCR_TSEG1(bt->phase_seg1 + bt->prop_seg - 1) | + RCAR_CAN_BCR_BPR(bt->brp - 1) | + RCAR_CAN_BCR_SJW(bt->sjw - 1) | + RCAR_CAN_BCR_TSEG2(bt->phase_seg2 - 1); + + printf("0x%08x", bcr << 8); + } +} + static struct can_bittiming_const can_calc_consts[] = { { .name = "sja1000", @@ -472,7 +493,21 @@ static struct can_bittiming_const can_calc_consts[] = { .ref_clk = 13000000, .printf_btr = printf_btr_ti_hecc, - } + }, + { + .name = "rcar_can", + .tseg1_min = 4, + .tseg1_max = 16, + .tseg2_min = 2, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, + + .ref_clk = 65000000, + .printf_btr = printf_btr_rcar_can, + }, }; static long common_bitrates[] = { -- 2.39.2