Skip to content

Commit

Permalink
drivers: can: initial support for Renesas RA CANFD
Browse files Browse the repository at this point in the history
Add support for CAN driver running on Renesas RA CANFD

Signed-off-by: The Nguyen <[email protected]>
  • Loading branch information
thenguyenyf authored and henrikbrixandersen committed Oct 25, 2024
1 parent e876c5d commit 95cc5f5
Show file tree
Hide file tree
Showing 14 changed files with 1,356 additions and 20 deletions.
9 changes: 9 additions & 0 deletions boards/renesas/ek_ra8d1/ek_ra8d1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@
psels = <RA_PSEL(RA_PSEL_GPT1, 10, 6)>;
};
};

canfd0_default: canfd0_default {
group1 {
/* CRX0 CTX0 */
psels = <RA_PSEL(RA_PSEL_CANFD, 4, 2)>,
<RA_PSEL(RA_PSEL_CANFD, 4, 1)>;
drive-strength = "high";
};
};
};
17 changes: 17 additions & 0 deletions boards/renesas/ek_ra8d1/ek_ra8d1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
zephyr,shell-uart = &uart9;
zephyr,entropy = &trng;
zephyr,flash-controller = &flash1;
zephyr,canbus = &canfd0;
};

leds {
Expand Down Expand Up @@ -74,6 +75,12 @@
status = "okay";
};

&canfdclk {
clocks = <&pll>;
div = <5>;
status = "okay";
};

&ioport1 {
status = "okay";
};
Expand Down Expand Up @@ -132,3 +139,13 @@
pinctrl-names = "default";
status = "okay";
};

&canfd_global {
status = "okay";
canfd0 {
pinctrl-0 = <&canfd0_default>;
pinctrl-names = "default";
rx-max-filters = <16>;
status = "okay";
};
};
9 changes: 9 additions & 0 deletions boards/renesas/ek_ra8m1/ek_ra8m1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@
psels = <RA_PSEL(RA_PSEL_GPT1, 6, 2)>;
};
};

canfd0_default: canfd0_default {
group1 {
/* CRX0 CTX0 */
psels = <RA_PSEL(RA_PSEL_CANFD, 3, 11)>,
<RA_PSEL(RA_PSEL_CANFD, 3, 12)>;
drive-strength = "high";
};
};
};
29 changes: 29 additions & 0 deletions boards/renesas/ek_ra8m1/ek_ra8m1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
zephyr,console = &uart9;
zephyr,shell-uart = &uart9;
zephyr,entropy = &trng;
zephyr,canbus = &canfd0;
};

leds {
Expand Down Expand Up @@ -65,6 +66,13 @@
aliases {
led0 = &led1;
};

transceiver0: can-phy0 {
compatible = "nxp,tja1040t", "can-transceiver-gpio";
standby-gpios = <&ioport2 7 GPIO_ACTIVE_HIGH>;
max-bitrate = <5000000>;
#phy-cells = <0>;
};
};

&xtal {
Expand Down Expand Up @@ -97,6 +105,12 @@
status = "okay";
};

&canfdclk {
clocks = <&pll>;
div = <5>;
status = "okay";
};

&ioport0 {
status = "okay";
};
Expand All @@ -105,6 +119,10 @@
status = "okay";
};

&ioport2 {
status = "okay";
};

&ioport3 {
status = "okay";
};
Expand Down Expand Up @@ -189,3 +207,14 @@ mikrobus_serial: &uart3 {};
};
};
};

&canfd_global {
status = "okay";
canfd0 {
pinctrl-0 = <&canfd0_default>;
pinctrl-names = "default";
phys = <&transceiver0>;
rx-max-filters = <16>;
status = "okay";
};
};
9 changes: 9 additions & 0 deletions boards/renesas/mck_ra8t1/mck_ra8t1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@
psels = <RA_PSEL(RA_PSEL_GPT1, 1, 14)>;
};
};

canfd1_default: canfd1_default {
group1 {
/* CRX1 CTX1 */
psels = <RA_PSEL(RA_PSEL_CANFD, 4, 14)>,
<RA_PSEL(RA_PSEL_CANFD, 4, 15)>;
drive-strength = "high";
};
};
};
17 changes: 17 additions & 0 deletions boards/renesas/mck_ra8t1/mck_ra8t1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
zephyr,shell-uart = &uart3;
zephyr,entropy = &trng;
zephyr,flash-controller = &flash1;
zephyr,canbus = &canfd1;
};

leds {
Expand Down Expand Up @@ -78,6 +79,12 @@
status = "okay";
};

&canfdclk {
clocks = <&pll>;
div = <5>;
status = "okay";
};

&ioport6 {
status = "okay";
};
Expand Down Expand Up @@ -126,3 +133,13 @@
pinctrl-names = "default";
status = "okay";
};

&canfd_global {
status = "okay";
canfd1 {
pinctrl-0 = <&canfd1_default>;
pinctrl-names = "default";
rx-max-filters = <16>;
status = "okay";
};
};
41 changes: 21 additions & 20 deletions drivers/can/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/can.h)
zephyr_library()
zephyr_sources_ifdef(CONFIG_CAN_MCUX_MCAN can_mcux_mcan.c)

zephyr_library_sources_ifdef(CONFIG_CAN can_common.c)
zephyr_library_sources_ifdef(CONFIG_CAN_FAKE can_fake.c)
zephyr_library_sources_ifdef(CONFIG_CAN_LOOPBACK can_loopback.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCAN can_mcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCP2515 can_mcp2515.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCP251XFD can_mcp251xfd.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCUX_FLEXCAN can_mcux_flexcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SAM can_sam.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SAM0 can_sam0.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32_BXCAN can_stm32_bxcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32_FDCAN can_stm32_fdcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32H7_FDCAN can_stm32h7_fdcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_TCAN4X5X can_tcan4x5x.c)
zephyr_library_sources_ifdef(CONFIG_CAN_RCAR can_rcar.c)
zephyr_library_sources_ifdef(CONFIG_CAN_NUMAKER can_numaker.c)
zephyr_library_sources_ifdef(CONFIG_CAN_XMC4XXX can_xmc4xxx.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SJA1000 can_sja1000.c)
zephyr_library_sources_ifdef(CONFIG_CAN_ESP32_TWAI can_esp32_twai.c)
zephyr_library_sources_ifdef(CONFIG_CAN_KVASER_PCI can_kvaser_pci.c)
zephyr_library_sources_ifdef(CONFIG_CAN_NRF can_nrf.c)
zephyr_library_sources_ifdef(CONFIG_CAN can_common.c)
zephyr_library_sources_ifdef(CONFIG_CAN_FAKE can_fake.c)
zephyr_library_sources_ifdef(CONFIG_CAN_LOOPBACK can_loopback.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCAN can_mcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCP2515 can_mcp2515.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCP251XFD can_mcp251xfd.c)
zephyr_library_sources_ifdef(CONFIG_CAN_MCUX_FLEXCAN can_mcux_flexcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SAM can_sam.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SAM0 can_sam0.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32_BXCAN can_stm32_bxcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32_FDCAN can_stm32_fdcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_STM32H7_FDCAN can_stm32h7_fdcan.c)
zephyr_library_sources_ifdef(CONFIG_CAN_TCAN4X5X can_tcan4x5x.c)
zephyr_library_sources_ifdef(CONFIG_CAN_RCAR can_rcar.c)
zephyr_library_sources_ifdef(CONFIG_CAN_NUMAKER can_numaker.c)
zephyr_library_sources_ifdef(CONFIG_CAN_XMC4XXX can_xmc4xxx.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SJA1000 can_sja1000.c)
zephyr_library_sources_ifdef(CONFIG_CAN_ESP32_TWAI can_esp32_twai.c)
zephyr_library_sources_ifdef(CONFIG_CAN_KVASER_PCI can_kvaser_pci.c)
zephyr_library_sources_ifdef(CONFIG_CAN_NRF can_nrf.c)
zephyr_library_sources_ifdef(CONFIG_CAN_RENESAS_RA_CANFD can_renesas_ra.c)

zephyr_library_sources_ifdef(CONFIG_USERSPACE can_handlers.c)
zephyr_library_sources_ifdef(CONFIG_CAN_SHELL can_shell.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/can/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ source "drivers/can/Kconfig.tcan4x5x"
source "drivers/can/Kconfig.mcp251xfd"
source "drivers/can/Kconfig.xmc4xxx"
source "drivers/can/Kconfig.nrf"
source "drivers/can/Kconfig.renesas_ra"

source "drivers/can/transceiver/Kconfig"

Expand Down
11 changes: 11 additions & 0 deletions drivers/can/Kconfig.renesas_ra
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2024 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0

config CAN_RENESAS_RA_CANFD
bool "Renesas RA CANFD"
default y
depends on DT_HAS_RENESAS_RA_CANFD_ENABLED
select USE_RA_FSP_CANFD
select PINCTRL
help
Enable Renesas RA CANFD driver
Loading

0 comments on commit 95cc5f5

Please sign in to comment.