Skip to content

Commit bf46696

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

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

drivers/dma/dma_sam_xdmac.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string.h>
1818
#include <soc.h>
1919
#include <zephyr/drivers/dma.h>
20+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
2021
#include "dma_sam_xdmac.h"
2122

2223
#define LOG_LEVEL CONFIG_DMA_LOG_LEVEL
@@ -38,7 +39,7 @@ struct sam_xdmac_channel_cfg {
3839
struct sam_xdmac_dev_cfg {
3940
Xdmac *regs;
4041
void (*irq_config)(void);
41-
uint8_t periph_id;
42+
const struct atmel_sam_pmc_config clock_cfg;
4243
uint8_t irq_id;
4344
};
4445

@@ -357,8 +358,9 @@ static int sam_xdmac_initialize(const struct device *dev)
357358
/* Configure interrupts */
358359
dev_cfg->irq_config();
359360

360-
/* Enable module's clock */
361-
soc_pmc_peripheral_enable(dev_cfg->periph_id);
361+
/* Enable XDMAC clock in PMC */
362+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
363+
(clock_control_subsys_t *)&dev_cfg->clock_cfg);
362364

363365
/* Disable all channels */
364366
xdmac->XDMAC_GD = UINT32_MAX;
@@ -391,7 +393,7 @@ static void dma0_sam_irq_config(void)
391393
static const struct sam_xdmac_dev_cfg dma0_sam_config = {
392394
.regs = (Xdmac *)DT_INST_REG_ADDR(0),
393395
.irq_config = dma0_sam_irq_config,
394-
.periph_id = DT_INST_PROP(0, peripheral_id),
396+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0),
395397
.irq_id = DT_INST_IRQN(0),
396398
};
397399

dts/arm/atmel/same70.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,14 @@
394394
compatible = "atmel,sam-xdmac";
395395
reg = <0x40078000 0x400>;
396396
interrupts = <58 0>;
397-
peripheral-id = <58>;
397+
clocks = <&pmc PMC_TYPE_PERIPHERAL 58>;
398398
#dma-cells = <2>;
399399
status = "disabled";
400400
};
401401

402402
ssc: ssc@40004000 {
403403
compatible = "atmel,sam-ssc";
404-
reg = <0x40004000 0x400>;
404+
reg = <0x40004000 0x4000>;
405405
interrupts = <22 0>;
406406
peripheral-id = <22>;
407407
status = "disabled";

dts/bindings/dma/atmel,sam-xdmac.yaml

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

17-
peripheral-id:
18-
type: int
19-
description: peripheral ID
17+
clocks:
2018
required: true
2119

2220
"#dma-cells":
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
&xdmac {
2+
status = "okay";
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
&xdmac {
2+
status = "okay";
3+
};

0 commit comments

Comments
 (0)