Skip to content

Commit 08015c8

Browse files
nandojvembolivar-nordic
authored andcommitted
drivers: hwinfo: sam: Update to use clock control
This update Atmel SAM hwinfo reset cause driver to use clock control driver. Signed-off-by: Gerson Fernando Budke <[email protected]>
1 parent eb2c6d7 commit 08015c8

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

drivers/hwinfo/hwinfo_sam_rstc.c

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

910
#include <zephyr/device.h>
1011
#include <zephyr/drivers/hwinfo.h>
11-
#include <zephyr/init.h>
12-
#include <soc.h>
12+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
1313

1414
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
1515
"No atmel,sam-rstc compatible device found");
@@ -56,12 +56,14 @@ int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported)
5656
static int hwinfo_rstc_init(const struct device *dev)
5757
{
5858
Rstc *regs = (Rstc *)DT_INST_REG_ADDR(0);
59+
const struct atmel_sam_pmc_config clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0);
5960
uint32_t mode;
6061

6162
ARG_UNUSED(dev);
6263

6364
/* Enable RSTC in PMC */
64-
soc_pmc_peripheral_enable(DT_INST_PROP(0, peripheral_id));
65+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
66+
(clock_control_subsys_t *)&clock_cfg);
6567

6668
/* Get current Mode Register value */
6769
mode = regs->RSTC_MR;

dts/arm/atmel/sam4s.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
rstc: rstc@400e1400 {
217217
compatible = "atmel,sam-rstc";
218218
reg = <0x400e1400 0x10>;
219-
peripheral-id = <1>;
219+
clocks = <&pmc PMC_TYPE_PERIPHERAL 1>;
220220
user-nrst;
221221
};
222222

dts/arm/atmel/same70.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@
452452
rstc: rstc@400e1800 {
453453
compatible = "atmel,sam-rstc";
454454
reg = <0x400e1800 0x10>;
455-
peripheral-id = <1>;
455+
clocks = <&pmc PMC_TYPE_PERIPHERAL 1>;
456456
user-nrst;
457457
};
458458
};

dts/bindings/hwinfo/atmel,sam-rstc.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ properties:
1111
reg:
1212
required: true
1313

14-
peripheral-id:
15-
type: int
16-
description: peripheral ID
14+
clocks:
1715
required: true
1816

1917
user-nrst:

0 commit comments

Comments
 (0)