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>
This commit is contained in:
Ioan Dragomir 2024-12-17 14:52:29 +02:00 committed by Daniel DeGrasse
parent 4eb7168a81
commit 92a11405f7
2 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Analog Devices, Inc.
* Copyright (c) 2024-2025 Analog Devices, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -15,6 +15,7 @@
#include <zephyr/logging/log.h>
#include <can.h>
#include <wrap_max32_can.h>
LOG_MODULE_REGISTER(can_max32, CONFIG_CAN_LOG_LEVEL);
@ -639,10 +640,10 @@ static int can_max32_init(const struct device *dev)
dev_list[dev_cfg->can_id] = dev;
ret = MXC_CAN_Init(dev_cfg->can_id, MXC_CAN_OBJ_CFG_TXRX, unit_event_callback,
object_event_callback);
ret = Wrap_MXC_CAN_Init(dev_cfg->can_id, MXC_CAN_OBJ_CFG_TXRX, unit_event_callback,
object_event_callback);
if (ret < 0) {
LOG_ERR("MXC_CAN_Init() failed:%d", ret);
LOG_ERR("Wrap_MXC_CAN_Init() failed:%d", ret);
return ret;
}
@ -700,8 +701,8 @@ static const struct can_driver_api can_max32_api = {
.timing_min = {
.sjw = 1,
.prop_seg = 0,
.phase_seg1 = 3,
.phase_seg2 = 2,
.phase_seg1 = 1,
.phase_seg2 = 1,
.prescaler = 1,
},
.timing_max = {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Analog Devices, Inc.
* Copyright (c) 2024-2025 Analog Devices, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -127,5 +127,13 @@
interrupts = <3 0>;
status = "disabled";
};
can0: can@40064000 {
compatible = "adi,max32-can";
reg = <0x40064000 0x1000>;
clocks = <&gcr ADI_MAX32_CLOCK_BUS1 11>;
interrupts = <107 0>;
status = "disabled";
};
};
};