drivers: timer: Add sam0 tc32 support to pinctrl

This add support to pinctrl at Atmel sam0 timer tc32 driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2022-03-13 13:19:59 -03:00 committed by Marti Bolivar
parent 171440b029
commit 8427f5e9b1
2 changed files with 13 additions and 1 deletions

View file

@ -7,6 +7,7 @@
#define DT_DRV_COMPAT atmel_sam0_tc32
#include <drivers/counter.h>
#include <drivers/pinctrl.h>
#include <device.h>
#include <soc.h>
@ -28,6 +29,7 @@ struct counter_sam0_tc32_data {
struct counter_sam0_tc32_config {
struct counter_config_info info;
TcCount32 *regs;
const struct pinctrl_dev_config *pcfg;
#ifdef MCLK
volatile uint32_t *mclk;
uint32_t mclk_mask;
@ -331,6 +333,7 @@ static int counter_sam0_tc32_initialize(const struct device *dev)
{
const struct counter_sam0_tc32_config *const cfg = dev->config;
TcCount32 *tc = cfg->regs;
int retval;
#ifdef MCLK
/* Enable the GCLK */
@ -367,6 +370,11 @@ static int counter_sam0_tc32_initialize(const struct device *dev)
/* Disable all interrupts */
tc->INTENCLR.reg = TC_INTENCLR_MASK;
retval = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
if (retval < 0) {
return retval;
}
/* Set the initial top as the maximum */
tc->CC[0].reg = UINT32_MAX;
@ -410,6 +418,7 @@ static const struct counter_driver_api counter_sam0_tc32_driver_api = {
(DT_INST_PROP(n, prescaler)), (1))
#define COUNTER_SAM0_TC32_DEVICE(n) \
PINCTRL_DT_INST_DEFINE(n); \
static void counter_sam0_tc32_config_##n(const struct device *dev); \
static const struct counter_sam0_tc32_config \
\
@ -426,6 +435,7 @@ static const struct counter_driver_api counter_sam0_tc32_driver_api = {
.prescaler = UTIL_CAT(TC_CTRLA_PRESCALER_DIV, \
SAM0_TC32_PRESCALER(n)), \
.irq_config_func = &counter_sam0_tc32_config_##n, \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
}; \
\
static struct counter_sam0_tc32_data counter_sam0_tc32_dev_data_##n;\

View file

@ -5,7 +5,9 @@ description: Atmel SAM0 basic timer counter (TC) operating in 32-bit wide mode
compatible: "atmel,sam0-tc32"
include: base.yaml
include:
- name: base.yaml
- name: pinctrl-device.yaml
properties:
reg: