Skip to content

Commit 1d3f5ac

Browse files
ajf58kartben
authored andcommitted
drivers: hwinfo: rp2350: Add initial support for RP2350
Extend the existing driver to add some initial support for the new SoC, whilst maintaining compatibility with the RP2040. Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
1 parent cc4a985 commit 1d3f5ac

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/hwinfo/hwinfo_rpi_pico.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
/*
22
* Copyright (c) 2022 Yonatan Schachter
3+
* Copyright (c) 2024 Andrew Featherstone
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
67

78
#include <string.h>
89
#include <zephyr/drivers/hwinfo.h>
910
#include <hardware/flash.h>
11+
#if defined(CONFIG_SOC_SERIES_RP2040)
1012
#include <hardware/structs/vreg_and_chip_reset.h>
13+
#else
14+
#include <hardware/structs/powman.h>
15+
#endif
1116

1217
#define FLASH_RUID_DATA_BYTES 8
1318

19+
#if defined(CONFIG_SOC_SERIES_RP2040)
1420
#define HAD_RUN_BIT BIT(VREG_AND_CHIP_RESET_CHIP_RESET_HAD_RUN_LSB)
1521
#define HAD_PSM_RESTART_BIT BIT(VREG_AND_CHIP_RESET_CHIP_RESET_HAD_PSM_RESTART_LSB)
1622
#define HAD_POR_BIT BIT(VREG_AND_CHIP_RESET_CHIP_RESET_HAD_POR_LSB)
23+
#else
24+
#define HAD_RUN_BIT BIT(POWMAN_CHIP_RESET_HAD_RUN_LOW_LSB)
25+
#define HAD_PSM_RESTART_BIT BIT(POWMAN_CHIP_RESET_HAD_DP_RESET_REQ_LSB)
26+
#define HAD_POR_BIT BIT(POWMAN_CHIP_RESET_HAD_POR_LSB)
27+
#endif
1728

1829
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
1930
{
@@ -41,7 +52,11 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
4152
int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
4253
{
4354
uint32_t flags = 0;
55+
#if defined(CONFIG_SOC_SERIES_RP2040)
4456
uint32_t reset_register = vreg_and_chip_reset_hw->chip_reset;
57+
#else
58+
uint32_t reset_register = powman_hw->chip_reset;
59+
#endif
4560

4661
if (reset_register & HAD_POR_BIT) {
4762
flags |= RESET_POR;
@@ -54,6 +69,18 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
5469
if (reset_register & HAD_PSM_RESTART_BIT) {
5570
flags |= RESET_DEBUG;
5671
}
72+
#if defined(CONFIG_SOC_SERIES_RP2350)
73+
if (reset_register & POWMAN_CHIP_RESET_HAD_BOR_BITS) {
74+
flags |= RESET_BROWNOUT;
75+
}
76+
77+
if (reset_register & (POWMAN_CHIP_RESET_HAD_WATCHDOG_RESET_RSM_BITS |
78+
POWMAN_CHIP_RESET_HAD_WATCHDOG_RESET_SWCORE_BITS |
79+
POWMAN_CHIP_RESET_HAD_WATCHDOG_RESET_POWMAN_BITS |
80+
POWMAN_CHIP_RESET_HAD_WATCHDOG_RESET_POWMAN_ASYNC_BITS)) {
81+
flags |= RESET_WATCHDOG;
82+
}
83+
#endif
5784

5885
*cause = flags;
5986
return 0;
@@ -69,6 +96,9 @@ int z_impl_hwinfo_clear_reset_cause(void)
6996
int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported)
7097
{
7198
*supported = RESET_PIN | RESET_DEBUG | RESET_POR;
99+
#if defined(CONFIG_SOC_SERIES_RP2350)
100+
*supported |= RESET_BROWNOUT | RESET_WATCHDOG;
101+
#endif
72102

73103
return 0;
74104
}

0 commit comments

Comments
 (0)