Skip to content

Commit 41ab680

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

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

drivers/can/can_sam.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <zephyr/drivers/can.h>
99
#include <zephyr/drivers/pinctrl.h>
10+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
1011
#include <soc.h>
1112
#include <zephyr/kernel.h>
1213
#include <zephyr/logging/log.h>
@@ -20,8 +21,8 @@ LOG_MODULE_REGISTER(can_sam, CONFIG_CAN_LOG_LEVEL);
2021

2122
struct can_sam_config {
2223
void (*config_irq)(void);
24+
const struct atmel_sam_pmc_config clock_cfg;
2325
const struct pinctrl_dev_config *pcfg;
24-
uint8_t pmc_id;
2526
int divider;
2627
};
2728

@@ -44,7 +45,9 @@ static void can_sam_clock_enable(const struct can_sam_config *sam_cfg)
4445
REG_PMC_PCK5 = PMC_PCK_CSS_UPLL_CLK | PMC_PCK_PRES(sam_cfg->divider - 1);
4546
PMC->PMC_SCER |= PMC_SCER_PCK5;
4647

47-
soc_pmc_peripheral_enable(sam_cfg->pmc_id);
48+
/* Enable CAN clock in PMC */
49+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
50+
(clock_control_subsys_t *)&sam_cfg->clock_cfg);
4851
}
4952

5053
static int can_sam_init(const struct device *dev)
@@ -136,7 +139,7 @@ static void config_can_##inst##_irq(void)
136139

137140
#define CAN_SAM_CFG_INST(inst) \
138141
static const struct can_sam_config can_sam_cfg_##inst = { \
139-
.pmc_id = DT_INST_PROP(inst, peripheral_id), \
142+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(inst), \
140143
.divider = DT_INST_PROP(inst, divider), \
141144
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
142145
.config_irq = config_can_##inst##_irq, \

dts/arm/atmel/same70.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424
reg-names = "m_can";
425425
interrupts = <35 0>, <36 0>;
426426
interrupt-names = "LINE_0", "LINE_1";
427-
peripheral-id = <35>;
427+
clocks = <&pmc PMC_TYPE_PERIPHERAL 35>;
428428
divider = <6>;
429429
sjw = <1>;
430430
sample-point = <875>;
@@ -439,7 +439,7 @@
439439
reg-names = "m_can";
440440
interrupts = <37 0>, <38 0>;
441441
interrupt-names = "LINE_0", "LINE_1";
442-
peripheral-id = <37>;
442+
clocks = <&pmc PMC_TYPE_PERIPHERAL 37>;
443443
divider = <6>;
444444
sjw = <1>;
445445
sample-point = <875>;

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

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

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

2119
divider:
2220
type: int

0 commit comments

Comments
 (0)