Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drivers/adc/adc_sam0.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ static int adc_sam0_channel_setup(const struct device *dev,
case ADC_REF_EXTERNAL0:
refctrl = ADC_REFCTRL_REFSEL_AREFA;
break;
#ifdef ADC_REFCTRL_REFSEL_AREFB
case ADC_REF_EXTERNAL1:
refctrl = ADC_REFCTRL_REFSEL_AREFB;
break;
#endif
default:
LOG_ERR("Selected reference is not valid");
return -EINVAL;
Expand Down Expand Up @@ -449,7 +451,7 @@ static int adc_sam0_init(const struct device *dev)
#ifdef MCLK
GCLK->PCHCTRL[cfg->gclk_id].reg = cfg->gclk_mask | GCLK_PCHCTRL_CHEN;

MCLK->APBDMASK.reg |= cfg->mclk_mask;
MCLK_ADC |= cfg->mclk_mask;
#else
PM->APBCMASK.bit.ADC_ = 1;

Expand Down
13 changes: 13 additions & 0 deletions soc/arm/atmel_sam0/common/adc_fixup_sam0.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
#else
# define ADC_SAM0_BIASREFBUF(n) 0
#endif

/*
* The following MCLK clock configuration fix-up symbols map to the applicable
* APB-specific symbols, in order to accommodate different SoC series with the
* ADC core connected to different APBs.
*/
#if defined(MCLK_APBDMASK_ADC) || defined(MCLK_APBDMASK_ADC0)
# define MCLK_ADC (MCLK->APBDMASK.reg)
#elif defined(MCLK_APBCMASK_ADC0)
# define MCLK_ADC (MCLK->APBCMASK.reg)
#else
# error ADC not supported...
Comment on lines +109 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this be supported in devicetree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At SAM MCU clock connection to ADC module is located in some processor in ABPD registry and some at APBC.
I don't find any usage at devicetree to set / get valid registry.
SAM Drives uses constraints from ASF headers.

#endif
#endif /* MCLK */

/*
Expand Down