Commit Graph

710 Commits

Author SHA1 Message Date
Vitaliy Livnov
e6894ad576 drivers: can: sam0: fix clock configuration for SAM0 series
Fixed a bug where unconfigured clocks were connected to the can
interface in the device tree for SAM0, causing the interface to work
incorrectly. Fixed by adding the correct index when calling GENCTRL.
Also, the default divider has been reduced to 6 to allow setting
the bitrate to 500 kbps.

Tested on a canopennode sample on a board with an ATSAMC21E18A
microcontroller.

Signed-off-by: Vitaliy Livnov <vitaliy.livnov@devkit.agency>
2025-07-10 15:53:46 -05:00
Pieter De Gendt
5a051b4db3 drivers: can: Place device APIs in linker sections
Use DEVICE_API macro to place driver API instances into a linker section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-27 10:09:32 -05:00
David Jewsbury
9087e82c9f drivers: can: update clock control to use nrf2_auxpll
Auxpll driver has been refactored to use nrf2 API instead.

Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
2025-06-26 14:13:54 +02:00
Jiafei Pan
ea24ec19e1 drivers: can: mcux: flexcan: add mmio mapping support
Use MMIO for device memory mapping, so that the driver can be used
both on MCU and MPU.

Add removed static MMU mapping in some platform accordingly.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-06-25 09:52:56 +02:00
Benjamin Cabé
4b80bb5b84 drivers: can: renesas: properly clear error flag
Fix misleading comments and ensure "Bus Error" flag is properly cleared
(Bus-Off Entry flag was used twice previously).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-24 20:05:09 -10:00
Ioan Dragomir
92a11405f7 drivers: can: Add CAN support for max32662
Adapt MAX32690 driver to use Wrap_MXC_CAN_Init to handle differences
in the MSDK API (see analogdevicesinc/msdk#1306) between the
MAX32690 and MAX32662.

can_driver_api.timing_min required phase_seg1 >= 3 and phase_seg2 >= 2
when configuring CAN bit timing. Both microcontrollers covered by this
driver (MAX32662, MAX32690) support values down to 1 for both of these
timing parameters.

Refer to the docs for registers CAN_BUSTIM1, CANn_BUSTIM1.

Add a can0 node to the MAX32662 dtsi.

Signed-off-by: Ioan Dragomir <ioan.dragomir@analog.com>
2025-06-16 14:13:59 -04:00
Anıl Kara
7f3b002210 drivers: can: Add max32xxx CAN driver
This commit adds CAN driver for max32xxx.

Signed-off-by: Anıl Kara <anil.kara@analog.com>
2025-06-16 14:13:59 -04:00
Henrik Brix Andersen
362e17a0c0 drivers: can: mcp2515: reformat files using clang-format
Reformat the MCP2515 driver files using clang-format and remove excessive
newlines between variable declarations.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-06-02 13:29:17 +02:00
Henrik Brix Andersen
e4fa41e2ad drivers: can: mcp2515: merge nested if-statements into one
Merge two nested if-statements into one.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-06-02 13:29:17 +02:00
Henrik Brix Andersen
c4247c6430 drivers: can: mcp2515: terminate if...else if construct with an else
Terminate the if...else if construct with an else block in order to adhere
to coding guidelines.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-06-02 13:29:17 +02:00
Henrik Brix Andersen
214b9c5278 drivers: can: mcp2515: declare the variable "data_idx" inside the loops
Declare the variable "data_idx" inside the loops to limit it's scope.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-06-02 13:29:17 +02:00
The Nguyen
bd87dbc368 driver: can: renesas: remove first can bus starting at init
Remove can bus starting at initial function

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-05-29 06:31:47 +02:00
The Nguyen
990b000e31 drivers: can: renesas: avoid breaking driver instance access
Keep data instance inside of data structure.
Avoid accessing global data or using pointers to out of
data instance.

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-05-29 06:31:47 +02:00
Henrik Brix Andersen
18aa6c8901 drivers: can: mcan: merge nested if-statements into one
Merge two nested if-statements into one.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-28 12:22:11 +02:00
Henrik Brix Andersen
45511fe634 drivers: can: mcan: declare the loop condition variables inside the loops
Declare the loop condition variable inside the loops to limit their scope.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-28 12:22:11 +02:00
Henrik Brix Andersen
40ec42e26f drivers: can: rcar: merge nested if-statements into one
Merge two nested if-statements into one.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-28 11:18:23 +02:00
Henrik Brix Andersen
09f54c98a7 drivers: can: rcar: declare the loop condition variables inside the loops
Declare the loop condition variable inside the loops to limit their scope.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-28 11:18:23 +02:00
Henrik Brix Andersen
24a46a597c drivers: can: rcar: always initialize return value variable
Always initialize the return value variable to avoid returning garbage.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-28 11:18:23 +02:00
Henrik Brix Andersen
81ee157876 drivers: can: common: mark unused function argument as such
Use ARG_UNUSED() to mark unused function argument.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-09 18:00:27 +02:00
Henrik Brix Andersen
b04d6f876c drivers: can: common: declare prescaler variable inside loop
Declare the prescaler variable inside the loop where it is used.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-09 18:00:27 +02:00
Henrik Brix Andersen
d5f07eb8c9 drivers: can: common: terminate if ... else if ... constructs with else
Terminate "if ... else if ..." constructs with an empty "else" clause to
indicate that consideration has been given regarding the behaviour when all
other conditions evaluate to false.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-09 18:00:27 +02:00
Henrik Brix Andersen
404d92d516 drivers: can: common: define each identifier in a dedicated statement
Define each identifier in a dedicated statement.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-05-09 18:00:27 +02:00
Hieu Nguyen
a82a5187dd drivers: can: Initial support for RZ/G3S
Add CAN driver support for Renesas RZ/G3S

Signed-off-by: Hieu Nguyen <hieu.nguyen.ym@bp.renesas.com>
Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2025-05-09 17:59:38 +02:00
Chun-Chieh Li
75e7d0eeae drivers: can: support nuvoton m55m1x series
This supports Nuvoton m55m1x series can-fd controller.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-05-09 14:01:32 +02:00
Chun-Chieh Li
d1e8590b6b drivers: can: numaker: fix m2l31x core clock
This fixes canfd core clock for m2l31x soc.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-05-09 14:01:32 +02:00
Wenxi Xu
7dc2c15fd3 drivers: can: stm32_bxcan: fix filter config
Setting the filter registers in master CAN requires initializing master
CAN first. CONFIG_CAN_MAX_EXT_ID_FILTER banks are reserved for IDE
frames. Previously we set FS1R(CAN filter scale register) at init time,
but it is possible that the master CAN is not initialized at that time.
That is when the filter banks are not set correctly, causing that we get
wrong filter_id from slave CAN. This patch fixes the issue by setting
FS1R at the time of initializing master CAN.

Tested on:
STM32F407IGH6 with 2 std_id and 2 ext_id on each of CAN1 and CAN2.

Signed-off-by: Wenxi Xu <xuwenxi0517@gmail.com>
2025-04-04 09:34:30 +02:00
Marek Maškarinec
bc4d040e0d drivers: can_mcp251xfd: Add XSTBY option
Adds ability to enable the XSTBY functionality on GPIO0 pin, if enabled
in devicetree.

Signed-off-by: Marek Maškarinec <marek.maskarinec@hardwario.com>
2025-04-02 10:30:59 +02:00
Alberto Escolar Piedras
14a4f50642 drivers/can/can_native_linux_adapt: Correct a refernece to native_posix
Replace it with the driver name

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 02:27:36 +01:00
Khoa Nguyen
c768144002 drivers: Correct value of event macro for all Renesas SoC
Since the RA2L1 uses the macro "ICU_EVENT" instead of
"ELC_EVENT" (which is currently used) to input into
the IELSR register, the ek_ra2l1 board cannot assign
any interrupts for any driver.

This commit aim to correct the Event macro to input correct
value for IELSR register on all the Renesas SoC by using
"BSP_PRV_IELS_ENUM" macro.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-02-28 18:29:17 +01:00
The Nguyen
b0debcc302 drivers: can: add DLL bitrate limit check for can_renesas_ra
Add condition to check uppper/lower limit of DLL clock rate

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-02-15 07:23:10 +01:00
The Nguyen
d75125bfaa drivers: can: correct the CAN core clock setting for can_renesas_ra
Correct bit setting for CAN DLL clock as CANFDCLK

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-02-15 07:23:10 +01:00
Khaoula Bidani
9bcc89deb6 drivers : can: replace LL_RCC_GetFDCANClockFreq
replace LL_RCC_GetFDCANClockFreq, remove
stm32_ll_rcc.h include and
use_stm32_ll_rcc from kconfig.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-02-14 13:36:12 +01:00
Gerard Marull-Paretas
e9eee4eb23 drivers: can: nrf: disable pin retention if GPD is enabled
When GPD is enabled, the pinctrl driver enables pin retention if the
peripheral is in the FAST_ACTIVE1 domain. This seems to break CAN, so
make sure retention is not active.

Investigations on why this is needed are ongoing, however, this makes
CAN functional again with some minor changes.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2025-02-11 15:58:10 +01:00
Fabio Baltieri
a6a39c74e7 can_shell: add shell device filtering
Add shell device filtering using the existing can_device_check API for
CAN shell commands.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:47 +01:00
Tomislav Milkovic
fb98387f4d drivers: can: can_tcan4x5x: fix compiler build warning/error
Fix compiler warning when optional property reset-gpios
is not supplied in the ti,tcan4x5x-compatible device tree
node

Signed-off-by: Tomislav Milkovic <tomislav.milkovic95@gmail.com>
2025-01-22 08:08:24 +01:00
Henrik Brix Andersen
8cdc8ec8fd drivers: can: sort the list of source files
Sort the list of CAN driver subsystem files and split them into common and
driver-specific sections.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-01-16 22:44:47 +01:00
Henrik Brix Andersen
b401bf7583 drivers: can: build the NXP MCUX MCAN driver as part of the library
Build the NXP MCUX MCAN driver as part of the CAN driver library.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-01-16 22:44:47 +01:00
Gerson Fernando Budke
ea7922195b clocks: atmel: sam0: Fix gclk and mclk clock bindings
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.

Now the clocks properties is complemented by the atmel,assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.

All peripherals drivers were reworked with the newer solution.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2025-01-14 20:49:03 +01:00
Gerard Marull-Paretas
d78952b7ba drivers: can: nrf: make sure HSFLL frequency >= AUXPLL
When CAN is used, HSFLL frequency must >= AUXPLL frequency. Make sure to
send a request to the HSFLL clock instance.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2025-01-09 09:51:52 +01:00
Yishai Jaffe
1b4cef325b shell: use shell_device_get_binding
Use shell_device_get_binding() instead of device_get_binding() so that
we get the device based on its name and in addition by its label.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2024-12-18 15:32:10 +01:00
Alexander Kozhinov
753d788997 drivers: can: can_mcan.c: transparent error code propagation
The implementation of can_mcan_start() function
hides retun code of underlying function.
It makes root-cause search more difficult.
This change strives fro transparent error code
propagation to higher software layers.

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
2024-12-04 16:11:40 +01:00
Henrik Brix Andersen
a619fe74a9 drivers: can: remove the deprecated can_calc_prescaler() API function
Remove the deprecated can_calc_prescaler() CAN API function.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-12-04 02:02:40 +01:00
McAtee Maxwell
3024392d35 SOC: Remove config PINCTRL from xmc4xxx soc
- Move selection of CONFIG_PINCTRL from soc to individual
	  drivers
	- in accordance with issue #78619

Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2024-12-02 22:05:16 +00:00
Pieter De Gendt
3e3b3d176d drivers: can: Check CAN device API in shell commands
Update CAN shell commands to filter and verify the device's API type.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 14:24:39 +01:00
Pieter De Gendt
80440b1664 drivers: can: Place API into iterable section
Add wrapper DEVICE_API macro to all can_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 14:24:39 +01:00
Pieter De Gendt
19c9d0894a drivers: can: transceiver: Place API into iterable section
Add wrapper DEVICE_API macro to all can_transceiver_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 14:24:28 +01:00
Pisit Sawangvonganan
df24d0114c drivers: can: sja1000: reduce number of frame->id pointer dereferences
Refined `can_sja1000_read_frame` and `can_sja1000_write_frame` by
reducing `frame->id` pointer dereferences.
Using a local `id` variable aims to improve efficiency, given
the frequent execution of this code in CAN applications.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-16 15:25:55 -05:00
Henrik Brix Andersen
0bb5270f7b drivers: can: sam: fix sys_write32() arguments order
Fix the order of the arguments to sys_write32().

Fixes: #80750

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2024-11-04 13:43:03 -06:00
The Nguyen
95cc5f53b8 drivers: can: initial support for Renesas RA CANFD
Add support for CAN driver running on Renesas RA CANFD

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2024-10-25 08:55:17 +02:00
Henrik Brix Andersen
185432c96d drivers: can: select CONFIG_PINCTRL where needed
Select CONFIG_PINCTRL for all CAN controllers drivers using pinctrl.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-10-21 18:54:27 -05:00