Skip to content

Commit 033c7ed

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

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

drivers/memc/memc_sam_smc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <zephyr/device.h>
1010
#include <zephyr/drivers/pinctrl.h>
11+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
1112
#include <soc.h>
1213

1314
#include <zephyr/logging/log.h>
@@ -23,11 +24,9 @@ struct memc_smc_bank_config {
2324

2425
struct memc_smc_config {
2526
Smc *regs;
26-
uint32_t periph_id;
27-
2827
size_t banks_len;
2928
const struct memc_smc_bank_config *banks;
30-
29+
const struct atmel_sam_pmc_config clock_cfg;
3130
const struct pinctrl_dev_config *pcfg;
3231
};
3332

@@ -37,7 +36,9 @@ static int memc_smc_init(const struct device *dev)
3736
const struct memc_smc_config *cfg = dev->config;
3837
SmcCs_number *bank;
3938

40-
soc_pmc_peripheral_enable(cfg->periph_id);
39+
/* Enable SMC clock in PMC */
40+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
41+
(clock_control_subsys_t *)&cfg->clock_cfg);
4142

4243
ret = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT);
4344
if (ret < 0) {
@@ -93,7 +94,7 @@ static int memc_smc_init(const struct device *dev)
9394
PINCTRL_DT_INST_DEFINE(inst); \
9495
static const struct memc_smc_config smc_config_##inst = { \
9596
.regs = (Smc *)DT_INST_REG_ADDR(inst), \
96-
.periph_id = DT_INST_PROP(inst, peripheral_id), \
97+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(inst), \
9798
.banks_len = ARRAY_SIZE(smc_bank_config_##inst), \
9899
.banks = smc_bank_config_##inst, \
99100
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \

dts/arm/atmel/sam4e.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
#address-cells = <1>;
261261
#size-cells = <0>;
262262
reg = <0x40060000 0x200>;
263-
peripheral-id = <8>;
263+
clocks = <&pmc PMC_TYPE_PERIPHERAL 8>;
264264
status = "disabled";
265265
};
266266
};

dts/arm/atmel/sam4s.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
#address-cells = <1>;
226226
#size-cells = <0>;
227227
reg = <0x400e0000 0x200>;
228-
peripheral-id = <10>;
228+
clocks = <&pmc PMC_TYPE_PERIPHERAL 10>;
229229
status = "disabled";
230230
};
231231
};

dts/bindings/memory-controllers/atmel,sam-smc.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ properties:
6767
reg:
6868
required: true
6969

70+
clocks:
71+
required: true
72+
7073
"#address-cells":
7174
required: true
7275
const: 1
@@ -75,11 +78,6 @@ properties:
7578
required: true
7679
const: 0
7780

78-
peripheral-id:
79-
type: int
80-
description: peripheral ID
81-
required: true
82-
8381
child-binding:
8482
description: |
8583
Child device nodes are representing devices connected to the EBI/SMC bus.

0 commit comments

Comments
 (0)