drivers: can: mcan: add transceiver support
Add support for CAN transceivers to the Bosch M_CAN CAN drivers. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
000661db21
commit
d8e88b61eb
6 changed files with 118 additions and 10 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <drivers/can.h>
|
||||
#include <drivers/can/transceiver.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <kernel.h>
|
||||
#include <soc.h>
|
||||
|
@ -153,6 +154,15 @@ static int can_stm32fd_set_timing(const struct device *dev,
|
|||
return can_mcan_set_timing(mcan_cfg, timing, timing_data);
|
||||
}
|
||||
|
||||
int can_stm32fd_get_max_bitrate(const struct device *dev, uint32_t *max_bitrate)
|
||||
{
|
||||
const struct can_stm32fd_config *cfg = dev->config;
|
||||
|
||||
*max_bitrate = cfg->mcan.max_bitrate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void can_stm32fd_line_0_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
|
@ -188,6 +198,7 @@ static const struct can_driver_api can_api_funcs = {
|
|||
.recover = can_mcan_recover,
|
||||
#endif
|
||||
.get_core_clock = can_stm32fd_get_core_clock,
|
||||
.get_max_bitrate = can_stm32fd_get_max_bitrate,
|
||||
.get_max_filters = can_stm32fd_get_max_filters,
|
||||
.set_state_change_callback = can_stm32fd_set_state_change_callback,
|
||||
.timing_min = {
|
||||
|
@ -263,7 +274,10 @@ static const struct can_stm32fd_config can_stm32fd_cfg_##inst = { \
|
|||
DT_INST_PROP_OR(inst, phase_seg1_data, 0), \
|
||||
.ts2_data = DT_INST_PROP_OR(inst, phase_seg2_data, 0), \
|
||||
.tx_delay_comp_offset = \
|
||||
DT_INST_PROP(inst, tx_delay_comp_offset) \
|
||||
DT_INST_PROP(inst, tx_delay_comp_offset), \
|
||||
.phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, phys)), \
|
||||
.max_bitrate = \
|
||||
DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, 5000000), \
|
||||
}, \
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
||||
};
|
||||
|
@ -287,6 +301,9 @@ static const struct can_stm32fd_config can_stm32fd_cfg_##inst = { \
|
|||
.prop_ts1 = DT_INST_PROP_OR(inst, prop_seg, 0) + \
|
||||
DT_INST_PROP_OR(inst, phase_seg1, 0), \
|
||||
.ts2 = DT_INST_PROP_OR(inst, phase_seg2, 0), \
|
||||
.phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(inst, phys)), \
|
||||
.max_bitrate = \
|
||||
DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(inst, 1000000), \
|
||||
}, \
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue