Skip to content

Commit 75e7d0e

Browse files
ccli8kartben
authored andcommitted
drivers: can: support nuvoton m55m1x series
This supports Nuvoton m55m1x series can-fd controller. Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
1 parent d1e8590 commit 75e7d0e

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

boards/nuvoton/numaker_m55m1/numaker_m55m1-pinctrl.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
};
2626
};
2727

28+
/* CAN TX/RX --> PJ10/PJ11 (J8) */
29+
canfd0_default: canfd0_default {
30+
group0 {
31+
pinmux = <PJ10MFP_CANFD0_TXD>,
32+
<PJ11MFP_CANFD0_RXD>;
33+
};
34+
};
35+
2836
/* EMAC multi-function pins for MDIO, TX, REFCLK, RX pins */
2937
emac_default: emac_default {
3038
group0 {

boards/nuvoton/numaker_m55m1/numaker_m55m1.dts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
zephyr,itcm = &itcm;
2828
zephyr,flash = &flash0;
2929
zephyr,code-partition = &slot0_partition;
30+
zephyr,canbus = &canfd0;
3031
};
3132

3233
leds {
@@ -87,6 +88,12 @@
8788
status = "okay";
8889
};
8990

91+
&canfd0 {
92+
pinctrl-0 = <&canfd0_default>;
93+
pinctrl-names = "default";
94+
status = "okay";
95+
};
96+
9097
&emac {
9198
pinctrl-0 = <&emac_default>;
9299
pinctrl-names = "default";

boards/nuvoton/numaker_m55m1/numaker_m55m1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ ram: 1536
1212
flash: 2048
1313
supported:
1414
- gpio
15+
- can
1516
vendor: nuvoton

drivers/can/Kconfig.numaker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ config CAN_NUMAKER
99
select CAN_MCAN
1010
select PINCTRL
1111
depends on DT_HAS_NUVOTON_NUMAKER_CANFD_ENABLED
12-
depends on SOC_SERIES_M46X || SOC_SERIES_M2L31X
12+
depends on SOC_SERIES_M46X || SOC_SERIES_M2L31X || SOC_SERIES_M55M1X
1313
help
1414
Enables Nuvoton NuMaker CAN FD driver, using Bosch M_CAN

drivers/can/can_numaker.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ static int can_numaker_get_core_clock(const struct device *dev, uint32_t *rate)
7575
case (CLK_CLKSEL0_CANFD0SEL_HIRC >> CLK_CLKSEL0_CANFD0SEL_Pos):
7676
*rate = __HIRC / clkdiv_divider;
7777
break;
78+
#elif defined(CONFIG_SOC_SERIES_M55M1X)
79+
case (CLK_CANFDSEL_CANFD0SEL_HXT >> CLK_CANFDSEL_CANFD0SEL_Pos):
80+
*rate = __HXT / clkdiv_divider;
81+
break;
82+
case (CLK_CANFDSEL_CANFD0SEL_APLL0_DIV2 >> CLK_CANFDSEL_CANFD0SEL_Pos):
83+
*rate = (CLK_GetAPLL0ClockFreq() / 2) / clkdiv_divider;
84+
break;
85+
case (CLK_CANFDSEL_CANFD0SEL_HCLK0 >> CLK_CANFDSEL_CANFD0SEL_Pos):
86+
*rate = CLK_GetHCLK0Freq() / clkdiv_divider;
87+
break;
88+
case (CLK_CANFDSEL_CANFD0SEL_HIRC >> CLK_CANFDSEL_CANFD0SEL_Pos):
89+
*rate = __HIRC / clkdiv_divider;
90+
break;
91+
case (CLK_CANFDSEL_CANFD0SEL_HIRC48M_DIV4 >> CLK_CANFDSEL_CANFD0SEL_Pos):
92+
*rate = (__HIRC48M / 4) / clkdiv_divider;
93+
break;
7894
#endif
7995
default:
8096
LOG_ERR("Invalid clock source rate index");

dts/arm/nuvoton/m55m1x.dtsi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,34 @@
338338
status = "disabled";
339339
};
340340

341+
canfd0: canfd@40222000 {
342+
compatible = "nuvoton,numaker-canfd";
343+
reg = <0x40222000 0x200>, <0x40222200 0x1800>;
344+
reg-names = "m_can", "message_ram";
345+
interrupts = <117 0>, <118 0>;
346+
interrupt-names = "int0", "int1";
347+
resets = <&rst NUMAKER_SYS_CANFD0RST>;
348+
clocks = <&pcc NUMAKER_CANFD0_MODULE
349+
NUMAKER_CLK_CANFDSEL_CANFD0SEL_HCLK0
350+
NUMAKER_CLK_CANFDDIV_CANFD0DIV(1)>;
351+
bosch,mram-cfg = <0x0 12 10 3 3 3 3 3>;
352+
status = "disabled";
353+
};
354+
355+
canfd1: canfd@40224000 {
356+
compatible = "nuvoton,numaker-canfd";
357+
reg = <0x40224000 0x200>, <0x40224200 0x1800>;
358+
reg-names = "m_can", "message_ram";
359+
interrupts = <119 0>, <120 0>;
360+
interrupt-names = "int0", "int1";
361+
resets = <&rst NUMAKER_SYS_CANFD1RST>;
362+
clocks = <&pcc NUMAKER_CANFD1_MODULE
363+
NUMAKER_CLK_CANFDSEL_CANFD1SEL_HCLK0
364+
NUMAKER_CLK_CANFDDIV_CANFD1DIV(1)>;
365+
bosch,mram-cfg = <0x0 12 10 3 3 3 3 3>;
366+
status = "disabled";
367+
};
368+
341369
emac: ethernet@40208000 {
342370
compatible = "nuvoton,numaker-ethernet";
343371
reg = <0x40208000 0x2000>;

0 commit comments

Comments
 (0)