Skip to content

Commit 6634d6b

Browse files
nandojvembolivar-nordic
authored andcommitted
drivers: afec: sam: Update to use clock control
This update Atmel SAM afec driver to use clock control driver. Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent dc45d7a commit 6634d6b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

drivers/adc/adc_sam_afec.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <soc.h>
2323
#include <zephyr/drivers/adc.h>
2424
#include <zephyr/drivers/pinctrl.h>
25+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
2526

2627
#define ADC_CONTEXT_USES_KERNEL_TIMER
2728
#include "adc_context.h"
@@ -60,7 +61,7 @@ struct adc_sam_data {
6061
struct adc_sam_cfg {
6162
Afec *regs;
6263
cfg_func_t cfg_func;
63-
uint32_t periph_id;
64+
const struct atmel_sam_pmc_config clock_cfg;
6465
const struct pinctrl_dev_config *pcfg;
6566
};
6667

@@ -287,7 +288,9 @@ static int adc_sam_init(const struct device *dev)
287288
| AFEC_ACR_PGA1EN
288289
| AFEC_ACR_IBCTL(1);
289290

290-
soc_pmc_peripheral_enable(cfg->periph_id);
291+
/* Enable AFEC clock in PMC */
292+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
293+
(clock_control_subsys_t *)&cfg->clock_cfg);
291294

292295
/* Connect pins to the peripheral */
293296
retval = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
@@ -359,7 +362,7 @@ static void adc_sam_isr(const struct device *dev)
359362
static const struct adc_sam_cfg adc##n##_sam_cfg = { \
360363
.regs = (Afec *)DT_INST_REG_ADDR(n), \
361364
.cfg_func = adc##n##_sam_cfg_func, \
362-
.periph_id = DT_INST_PROP(n, peripheral_id), \
365+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(n), \
363366
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
364367
}; \
365368
\

dts/arm/atmel/same70.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
compatible = "atmel,sam-afec";
204204
reg = <0x4003c000 0x100>;
205205
interrupts = <29 0>;
206-
peripheral-id = <29>;
206+
clocks = <&pmc PMC_TYPE_PERIPHERAL 29>;
207207
status = "disabled";
208208
#io-channel-cells = <1>;
209209
};
@@ -212,7 +212,7 @@
212212
compatible = "atmel,sam-afec";
213213
reg = <0x40064000 0x100>;
214214
interrupts = <40 0>;
215-
peripheral-id = <40>;
215+
clocks = <&pmc PMC_TYPE_PERIPHERAL 40>;
216216
status = "disabled";
217217
#io-channel-cells = <1>;
218218
};

dts/bindings/adc/atmel,sam-afec.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ properties:
1313
interrupts:
1414
required: true
1515

16-
peripheral-id:
17-
type: int
18-
description: peripheral ID
16+
clocks:
1917
required: true
2018

2119
"#io-channel-cells":

0 commit comments

Comments
 (0)