Merge pull request #302 from kurt-vd/more-chips-bittiming

[v2] more chips bittiming
pull/311/head
Marc Kleine-Budde 2021-06-24 14:34:07 +02:00 committed by GitHub
commit c1aae77740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 99 additions and 0 deletions

View File

@ -273,6 +273,57 @@ static void printf_btr_rcar_can(struct can_bittiming *bt, bool hdr)
}
}
static void printf_btr_bxcan(struct can_bittiming *bt, bool hdr)
{
if (hdr) {
printf("%10s", "CAN_BTR");
} else {
uint32_t btr;
btr = (((bt->brp -1) & 0x3ff) << 0) |
(((bt->prop_seg + bt->phase_seg1 -1) & 0xf) << 16) |
(((bt->phase_seg2 -1) & 0x7) << 20) |
(((bt->sjw -1) & 0x3) << 24);
printf("0x%08x", btr);
}
}
static void printf_btr_c_can(struct can_bittiming *bt, bool hdr)
{
if (hdr) {
printf("%s", " BTR BRPEXT");
} else {
uint32_t btr;
uint32_t brpext;
btr = (((bt->brp -1) & 0x3f) << 0) |
(((bt->sjw -1) & 0x3) << 6) |
(((bt->prop_seg + bt->phase_seg1 -1) & 0xf) << 8) |
(((bt->phase_seg2 -1) & 0x7) << 12);
brpext = ((bt->brp -1) >> 6) & 0xf;
printf("0x%04x 0x%04x", btr, brpext);
}
}
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 = {
@ -417,6 +468,54 @@ static struct calc_bittiming_const can_calc_consts[] = {
{ .clk = 65000000, },
},
.printf_btr = printf_btr_rcar_can,
}, {
.bittiming_const = {
.name = "bxcan",
.tseg1_min = 1,
.tseg1_max = 16,
.tseg2_min = 1,
.tseg2_max = 8,
.sjw_max = 4,
.brp_min = 1,
.brp_max = 1024,
.brp_inc = 1,
},
.ref_clk = {
{ .clk = 48000000, },
},
.printf_btr = printf_btr_bxcan,
}, {
.bittiming_const = {
.name = "c_can",
.tseg1_min = 2,
.tseg1_max = 16,
.tseg2_min = 1,
.tseg2_max = 8,
.sjw_max = 4,
.brp_min = 1,
.brp_max = 1024,
.brp_inc = 1,
},
.ref_clk = {
{ .clk = 24000000, },
},
.printf_btr = printf_btr_c_can,
}, {
.bittiming_const = {
.name = "mcan-v3.1+",
.tseg1_min = 2,
.tseg1_max = 256,
.tseg2_min = 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,
},
};