drivers: can: Update sam canfd driver to use pinctrl

This update Atmel sam canfd driver to use pinctrl driver and API. It
updates all boards with new pinctrl groups format. In addition this
add missing entries to run automated tests for can/canfd drivers.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2022-03-12 23:03:54 -03:00 committed by Marti Bolivar
commit d7c37d1f12
8 changed files with 39 additions and 14 deletions

View file

@ -8,6 +8,7 @@
#include <drivers/can.h>
#include <drivers/can/transceiver.h>
#include <drivers/pinctrl.h>
#include <soc.h>
#include <kernel.h>
#include <logging/log.h>
@ -19,7 +20,7 @@ LOG_MODULE_REGISTER(can_sam, CONFIG_CAN_LOG_LEVEL);
struct can_sam_config {
struct can_mcan_config mcan_cfg;
void (*config_irq)(void);
struct soc_gpio_pin pin_list[2];
const struct pinctrl_dev_config *pcfg;
uint8_t pmc_id;
};
@ -62,7 +63,12 @@ static int can_sam_init(const struct device *dev)
int ret;
can_sam_clock_enable(cfg);
soc_gpio_list_configure(cfg->pin_list, ARRAY_SIZE(cfg->pin_list));
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
if (ret < 0) {
return ret;
}
ret = can_mcan_init(dev, mcan_cfg, msg_ram, mcan_data);
if (ret) {
return ret;
@ -255,7 +261,7 @@ static void config_can_##inst##_irq(void)
#define CAN_SAM_CFG_INST(inst) \
static const struct can_sam_config can_sam_cfg_##inst = { \
.pmc_id = DT_INST_PROP(inst, peripheral_id), \
.pin_list = { ATMEL_SAM_DT_INST_PIN(inst, 0), ATMEL_SAM_DT_INST_PIN(inst, 1) }, \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
.config_irq = config_can_##inst##_irq, \
.mcan_cfg = CAN_SAM_MCAN_CFG(inst) \
};
@ -268,6 +274,7 @@ DEVICE_DT_INST_DEFINE(inst, &can_sam_init, NULL, &can_sam_dev_data_##inst,
&can_api_funcs);
#define CAN_SAM_INST(inst) \
PINCTRL_DT_INST_DEFINE(inst); \
CAN_SAM_IRQ_CFG_FUNCTION(inst) \
CAN_SAM_CFG_INST(inst) \
CAN_SAM_DATA_INST(inst) \