]> rtime.felk.cvut.cz Git - can-utils.git/commitdiff
can-calc-bit-timing: add support for rcar_can
authorRamesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
Mon, 29 Feb 2016 10:18:45 +0000 (10:18 +0000)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 29 Feb 2016 10:27:05 +0000 (11:27 +0100)
Signed-off-by: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
can-calc-bit-timing.c

index 9031a78f36180735195ad521a24f0f30c5a435f7..77f133311c2709224af1c6774d895490c0820841 100644 (file)
@@ -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[] = {