Skip to content

Commit 3bc47d7

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

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

drivers/dac/dac_sam.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <zephyr/device.h>
2020
#include <zephyr/drivers/dac.h>
2121
#include <zephyr/drivers/pinctrl.h>
22+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
2223

2324
#include <zephyr/logging/log.h>
2425
#include <zephyr/irq.h>
@@ -33,10 +34,10 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_SOC_SERIES_SAME70) ||
3334
/* Device constant configuration parameters */
3435
struct dac_sam_dev_cfg {
3536
Dacc *regs;
37+
const struct atmel_sam_pmc_config clock_cfg;
3638
const struct pinctrl_dev_config *pcfg;
3739
void (*irq_config)(void);
3840
uint8_t irq_id;
39-
uint8_t periph_id;
4041
uint8_t prescaler;
4142
};
4243

@@ -133,7 +134,8 @@ static int dac_sam_init(const struct device *dev)
133134
}
134135

135136
/* Enable DAC clock in PMC */
136-
soc_pmc_peripheral_enable(dev_cfg->periph_id);
137+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
138+
(clock_control_subsys_t *)&dev_cfg->clock_cfg);
137139

138140
retval = pinctrl_apply_state(dev_cfg->pcfg, PINCTRL_STATE_DEFAULT);
139141
if (retval < 0) {
@@ -171,7 +173,7 @@ static const struct dac_sam_dev_cfg dacc_sam_config = {
171173
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
172174
.irq_id = DT_INST_IRQN(0),
173175
.irq_config = dacc_irq_config,
174-
.periph_id = DT_INST_PROP(0, peripheral_id),
176+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0),
175177
.prescaler = DT_INST_PROP(0, prescaler),
176178
};
177179

dts/arm/atmel/same70.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
compatible = "atmel,sam-dac";
222222
reg = <0x40040000 0x100>;
223223
interrupts = <30 0>;
224-
peripheral-id = <30>;
224+
clocks = <&pmc PMC_TYPE_PERIPHERAL 30>;
225225
status = "disabled";
226226
#io-channel-cells = <1>;
227227
};

dts/bindings/dac/atmel,sam-dac.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ properties:
1313
reg:
1414
required: true
1515

16-
peripheral-id:
17-
type: int
16+
clocks:
1817
required: true
19-
description: |
20-
peripheral ID
2118

2219
prescaler:
2320
type: int

0 commit comments

Comments
 (0)