Skip to content

Commit 91e219c

Browse files
nandojvembolivar-nordic
authored andcommitted
drivers: entropy: sam/sam0: Update to use clock control
This update Atmel SAM trng driver to use clock control driver. Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent c4f1d98 commit 91e219c

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

drivers/entropy/entropy_sam.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2018 Aurelien Jarno
3+
* Copyright (c) 2023 Gerson Fernando Budke
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -8,6 +9,7 @@
89

910
#include <zephyr/device.h>
1011
#include <zephyr/drivers/entropy.h>
12+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
1113
#include <errno.h>
1214
#include <zephyr/init.h>
1315
#include <zephyr/kernel.h>
@@ -165,8 +167,10 @@ static int entropy_sam_init(const struct device *dev)
165167
/* Enable the TRNG */
166168
trng->CTRLA.bit.ENABLE = 1;
167169
#else
168-
/* Enable the user interface clock */
169-
soc_pmc_peripheral_enable(DT_INST_PROP(0, peripheral_id));
170+
/* Enable TRNG in PMC */
171+
const struct atmel_sam_pmc_config clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0);
172+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
173+
(clock_control_subsys_t *)&clock_cfg);
170174

171175
/* Enable the TRNG */
172176
trng->TRNG_CR = TRNG_CR_KEY_PASSWD | TRNG_CR_ENABLE;

dts/arm/atmel/sam4l.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
compatible = "atmel,sam-trng";
230230
reg = <0x40068000 0x4000>;
231231
interrupts = <73 0>;
232-
peripheral-id = <17>;
232+
clocks = <&pmc PMC_TYPE_PERIPHERAL 17>;
233233
status = "okay";
234234
};
235235

dts/arm/atmel/samd5x.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@
279279
trng: random@42002800 {
280280
compatible = "atmel,sam-trng";
281281
reg = <0x42002800 0x1e>;
282-
peripheral-id = <0>;
283282
interrupts = <131 0>;
284283
};
285284

dts/arm/atmel/same70.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@
386386
compatible = "atmel,sam-trng";
387387
reg = <0x40070000 0x4000>;
388388
interrupts = <57 0>;
389-
peripheral-id = <57>;
389+
clocks = <&pmc PMC_TYPE_PERIPHERAL 57>;
390390
status = "okay";
391391
};
392392

dts/arm/atmel/saml2x.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
trng: random@42003800 {
196196
compatible = "atmel,sam-trng";
197197
reg = <0x42003800 0x24>;
198-
peripheral-id = <0>;
199198
interrupts = <27 0>;
200199
};
201200
};

dts/bindings/rng/atmel,sam-trng.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@ properties:
1313

1414
interrupts:
1515
required: true
16-
17-
peripheral-id:
18-
type: int
19-
description: peripheral ID
20-
required: true

0 commit comments

Comments
 (0)