Skip to content

Commit 95153de

Browse files
AlessandroLuokartben
authored andcommitted
drivers: hwinfo: Add support for Apollo510 hwinfo
This commit adds support for Apollo510 SoC in ambiq hwinfo driver Signed-off-by: Hao Luo <[email protected]>
1 parent ba52a93 commit 95153de

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

boards/ambiq/apollo510_evb/apollo510_evb.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ supported:
1616
- spi
1717
- i2c
1818
- rtc
19+
- hwinfo
1920
- clock_control
2021
- mspi
2122
testing:

drivers/hwinfo/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ config HWINFO_RW61X
247247
config HWINFO_AMBIQ
248248
bool "AMBIQ hwinfo"
249249
default y
250-
depends on SOC_SERIES_APOLLO4X
250+
depends on SOC_SERIES_APOLLO4X || SOC_SERIES_APOLLO5X
251251
select HWINFO_HAS_DRIVER
252252
select AMBIQ_HAL
253253
select AMBIQ_HAL_USE_HWINFO

drivers/hwinfo/hwinfo_ambiq.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
1313
{
14-
1514
struct ambiq_hwinfo {
1615
/* Ambiq Chip ID0 */
1716
uint32_t chip_id_0;
@@ -27,7 +26,12 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
2726
/* Contains the HAL hardware information about the device. */
2827
am_hal_mcuctrl_device_t mcu_ctrl_device;
2928

29+
#if (CONFIG_SOC_SERIES_APOLLO5X)
30+
am_hal_info1_read(AM_HAL_INFO_INFOSPACE_CURRENT_INFO1, AM_REG_OTP_INFO1_TRIM_REV_O / 4, 1,
31+
&dev_hw_info.factory_trim_version);
32+
#else
3033
am_hal_mram_info_read(1, AM_REG_INFO1_TRIM_REV_O / 4, 1, &dev_hw_info.factory_trim_version);
34+
#endif
3135
am_hal_mcuctrl_info_get(AM_HAL_MCUCTRL_INFO_DEVICEID, &mcu_ctrl_device);
3236

3337
dev_hw_info.chip_id_0 = mcu_ctrl_device.ui32ChipID0;
@@ -61,9 +65,15 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
6165
}
6266

6367
/* POWER CYCLE */
68+
#if (CONFIG_SOC_SERIES_APOLLO5X)
69+
if (reset_status & AM_HAL_RESET_STATUS_POA) {
70+
flags |= RESET_POR;
71+
}
72+
#else
6473
if (reset_status & AM_HAL_RESET_STATUS_POR) {
6574
flags |= RESET_POR;
6675
}
76+
#endif
6777

6878
/* BROWNOUT DETECTOR */
6979
if (reset_status & AM_HAL_RESET_STATUS_BOD) {
@@ -110,6 +120,13 @@ int z_impl_hwinfo_get_reset_cause(uint32_t *cause)
110120
flags |= RESET_HARDWARE;
111121
}
112122

123+
#if (CONFIG_SOC_SERIES_APOLLO5X)
124+
/* AIRCR */
125+
if (reset_status & AM_HAL_RESET_STATUS_AIRCR) {
126+
flags |= RESET_SOFTWARE;
127+
}
128+
#endif
129+
113130
*cause = flags;
114131
return 0;
115132
}

0 commit comments

Comments
 (0)