* [PATCH 1/3] can-calc-bittiming: add stm32 bxcan
@ 2021-06-24 3:19 Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 2/3] can-calc-bittiming: add c_can Kurt Van Dijck
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Kurt Van Dijck @ 2021-06-24 3:19 UTC (permalink / raw)
To: linux-can; +Cc: Kurt Van Dijck
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
can-calc-bit-timing.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
index d99bd22..fb61947 100644
--- a/can-calc-bit-timing.c
+++ b/can-calc-bit-timing.c
@@ -273,6 +273,22 @@ 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 struct calc_bittiming_const can_calc_consts[] = {
{
.bittiming_const = {
@@ -417,6 +433,22 @@ 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,
},
};
--
2.25.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] can-calc-bittiming: add c_can
2021-06-24 3:19 [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Kurt Van Dijck
@ 2021-06-24 3:19 ` Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 3/3] can-calc-bittiming: add mcan Kurt Van Dijck
2021-06-24 6:20 ` [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Marc Kleine-Budde
2 siblings, 0 replies; 10+ messages in thread
From: Kurt Van Dijck @ 2021-06-24 3:19 UTC (permalink / raw)
To: linux-can; +Cc: Kurt Van Dijck
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
can-calc-bit-timing.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
index fb61947..d0626f7 100644
--- a/can-calc-bit-timing.c
+++ b/can-calc-bit-timing.c
@@ -289,6 +289,24 @@ static void printf_btr_bxcan(struct can_bittiming *bt, bool hdr)
}
}
+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 struct calc_bittiming_const can_calc_consts[] = {
{
.bittiming_const = {
@@ -449,6 +467,22 @@ static struct calc_bittiming_const can_calc_consts[] = {
{ .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,
},
};
--
2.25.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] can-calc-bittiming: add mcan
2021-06-24 3:19 [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 2/3] can-calc-bittiming: add c_can Kurt Van Dijck
@ 2021-06-24 3:19 ` Kurt Van Dijck
2021-06-24 10:50 ` Marc Kleine-Budde
2021-06-24 6:20 ` [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Marc Kleine-Budde
2 siblings, 1 reply; 10+ messages in thread
From: Kurt Van Dijck @ 2021-06-24 3:19 UTC (permalink / raw)
To: linux-can; +Cc: Kurt Van Dijck
Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
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",
+ .tseg1_min = 1,
+ .tseg1_max = 256,
+ .tseg2_min = 1,
+ .tseg2_max = 128,
+ .sjw_max = 128,
+ .brp_min = 1,
+ .brp_max = 512,
+ .brp_inc = 1,
+ },
+ .ref_clk = {
+ { .clk = 40000000, },
+ },
+ .printf_btr = printf_btr_mcan,
},
};
--
2.25.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] can-calc-bittiming: add stm32 bxcan
2021-06-24 3:19 [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 2/3] can-calc-bittiming: add c_can Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 3/3] can-calc-bittiming: add mcan Kurt Van Dijck
@ 2021-06-24 6:20 ` Marc Kleine-Budde
2021-06-24 10:37 ` Kurt Van Dijck
2 siblings, 1 reply; 10+ messages in thread
From: Marc Kleine-Budde @ 2021-06-24 6:20 UTC (permalink / raw)
To: Kurt Van Dijck; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]
On 24.06.2021 05:19:52, Kurt Van Dijck wrote:
> Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> ---
> can-calc-bit-timing.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
> index d99bd22..fb61947 100644
> --- a/can-calc-bit-timing.c
> +++ b/can-calc-bit-timing.c
> @@ -273,6 +273,22 @@ static void printf_btr_rcar_can(struct can_bittiming *bt, bool hdr)
> }
> }
>
> + .bittiming_const = {
> + .name = "bxcan",
What's that? A new CAN-IP core?
I can apply these patches to the can-utils or you can create a github
pull request and I'll merge it there. What do you prefer?
regards,
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] can-calc-bittiming: add stm32 bxcan
2021-06-24 6:20 ` [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Marc Kleine-Budde
@ 2021-06-24 10:37 ` Kurt Van Dijck
2021-06-24 10:40 ` Marc Kleine-Budde
0 siblings, 1 reply; 10+ messages in thread
From: Kurt Van Dijck @ 2021-06-24 10:37 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can
On Thu, 24 Jun 2021 08:20:16 +0200, Marc Kleine-Budde wrote:
> On 24.06.2021 05:19:52, Kurt Van Dijck wrote:
> > Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> > ---
> > can-calc-bit-timing.c | 32 ++++++++++++++++++++++++++++++++
> > 1 file changed, 32 insertions(+)
> >
> > diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
> > index d99bd22..fb61947 100644
> > --- a/can-calc-bit-timing.c
> > +++ b/can-calc-bit-timing.c
> > @@ -273,6 +273,22 @@ static void printf_btr_rcar_can(struct can_bittiming *bt, bool hdr)
> > }
> > }
> >
> > + .bittiming_const = {
> > + .name = "bxcan",
>
> What's that? A new CAN-IP core?
It's the 'old' CAN core used in STM32 cortex-m mcu's.
> I can apply these patches to the can-utils or you can create a github
> pull request and I'll merge it there. What do you prefer?
my preference is to apply from email.
The dinosaur icon on my github account comes with a reason?
Kind regards
Kurt
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] can-calc-bittiming: add stm32 bxcan
2021-06-24 10:37 ` Kurt Van Dijck
@ 2021-06-24 10:40 ` Marc Kleine-Budde
0 siblings, 0 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2021-06-24 10:40 UTC (permalink / raw)
To: linux-can
[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]
On 24.06.2021 12:37:36, Kurt Van Dijck wrote:
> On Thu, 24 Jun 2021 08:20:16 +0200, Marc Kleine-Budde wrote:
> > On 24.06.2021 05:19:52, Kurt Van Dijck wrote:
> > > Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> > > ---
> > > can-calc-bit-timing.c | 32 ++++++++++++++++++++++++++++++++
> > > 1 file changed, 32 insertions(+)
> > >
> > > diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c
> > > index d99bd22..fb61947 100644
> > > --- a/can-calc-bit-timing.c
> > > +++ b/can-calc-bit-timing.c
> > > @@ -273,6 +273,22 @@ static void printf_btr_rcar_can(struct can_bittiming *bt, bool hdr)
> > > }
> > > }
> > >
> > > + .bittiming_const = {
> > > + .name = "bxcan",
> >
> > What's that? A new CAN-IP core?
>
> It's the 'old' CAN core used in STM32 cortex-m mcu's.
Ahh - and it says stm32 in the subject of this mail :D
> > I can apply these patches to the can-utils or you can create a github
> > pull request and I'll merge it there. What do you prefer?
>
> my preference is to apply from email.
Fine with me.
> The dinosaur icon on my github account comes with a reason?
You like dinos? Don't know how fluent your german is:
https://www.dinowitz.de/
regards,
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] can-calc-bittiming: add mcan
2021-06-24 3:19 ` [PATCH 3/3] can-calc-bittiming: add mcan Kurt Van Dijck
@ 2021-06-24 10:50 ` Marc Kleine-Budde
2021-06-24 10:57 ` Kurt Van Dijck
0 siblings, 1 reply; 10+ messages in thread
From: Marc Kleine-Budde @ 2021-06-24 10:50 UTC (permalink / raw)
To: Kurt Van Dijck; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 1891 bytes --]
On 24.06.2021 05:19:54, Kurt Van Dijck wrote:
> Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> ---
> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] can-calc-bittiming: add mcan
2021-06-24 10:50 ` Marc Kleine-Budde
@ 2021-06-24 10:57 ` Kurt Van Dijck
2021-06-24 11:12 ` Marc Kleine-Budde
2021-06-24 11:15 ` Marc Kleine-Budde
0 siblings, 2 replies; 10+ messages in thread
From: Kurt Van Dijck @ 2021-06-24 10:57 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can
On Thu, 24 Jun 2021 12:50:05 +0200, Marc Kleine-Budde wrote:
> On 24.06.2021 05:19:54, Kurt Van Dijck wrote:
> > Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> > ---
> > + }, {
> > + .bittiming_const = {
> > + .name = "mcan",
>
> This is for mcan > v3.1
I don't have any earlier.
Can I just solve by putting "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.
Will adapt.
I clearly didn't pay enough attention to the lower limits.
>
> > + .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
btw, I just noticed I already have can-utils in my github account, I'll
create a Merge-Request for this V2 too, if you like.
Kurt
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] can-calc-bittiming: add mcan
2021-06-24 10:57 ` Kurt Van Dijck
@ 2021-06-24 11:12 ` Marc Kleine-Budde
2021-06-24 11:15 ` Marc Kleine-Budde
1 sibling, 0 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2021-06-24 11:12 UTC (permalink / raw)
To: linux-can
[-- Attachment #1: Type: text/plain, Size: 517 bytes --]
On 24.06.2021 12:57:31, Kurt Van Dijck wrote:
> btw, I just noticed I already have can-utils in my github account, I'll
> create a Merge-Request for this V2 too, if you like.
Go ahead, I've already reviewed the other changes there.
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] can-calc-bittiming: add mcan
2021-06-24 10:57 ` Kurt Van Dijck
2021-06-24 11:12 ` Marc Kleine-Budde
@ 2021-06-24 11:15 ` Marc Kleine-Budde
1 sibling, 0 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2021-06-24 11:15 UTC (permalink / raw)
To: linux-can
[-- Attachment #1: Type: text/plain, Size: 743 bytes --]
On 24.06.2021 12:57:31, Kurt Van Dijck wrote:
> On Thu, 24 Jun 2021 12:50:05 +0200, Marc Kleine-Budde wrote:
> > On 24.06.2021 05:19:54, Kurt Van Dijck wrote:
> > > Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> > > ---
> > > + }, {
> > > + .bittiming_const = {
> > > + .name = "mcan",
> >
> > This is for mcan > v3.1
correcting myself: >= v3.1
> I don't have any earlier.
> Can I just solve by putting "mcan-v3.1+"?
ACK
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-06-24 11:15 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 3:19 [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 2/3] can-calc-bittiming: add c_can Kurt Van Dijck
2021-06-24 3:19 ` [PATCH 3/3] can-calc-bittiming: add mcan Kurt Van Dijck
2021-06-24 10:50 ` Marc Kleine-Budde
2021-06-24 10:57 ` Kurt Van Dijck
2021-06-24 11:12 ` Marc Kleine-Budde
2021-06-24 11:15 ` Marc Kleine-Budde
2021-06-24 6:20 ` [PATCH 1/3] can-calc-bittiming: add stm32 bxcan Marc Kleine-Budde
2021-06-24 10:37 ` Kurt Van Dijck
2021-06-24 10:40 ` Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.