This commit is contained in:
刘可亮
2025-07-22 11:15:46 +08:00
parent d164b333ed
commit 11c97ef399
2870 changed files with 951307 additions and 26675 deletions

View File

@@ -18,6 +18,10 @@
#include <stdlib.h>
#include <aic_io.h>
#ifdef PM_ENABLE_DEBUG
#include <aic_osal.h>
#endif
#ifdef RT_USING_PM
/* tickless threshold time */
@@ -399,6 +403,37 @@ RT_WEAK rt_uint8_t pm_get_sleep_threshold_mode(rt_uint8_t cur_mode, rt_tick_t ti
return cur_mode;
}
#ifdef PM_ENABLE_DEBUG
void pm_dump_wakeup_source(void)
{
uint32_t i;
uint32_t pending;
uint32_t enable;
#ifdef ARCH_RISCV32
for (i = 0; i < MAX_IRQn; i++)
{
pending = csi_vic_get_pending_irq(i);
enable = csi_vic_get_enabled_irq(i);
if (pending && enable)
{
rt_kprintf("The wakeup source interrupt ID: %d\n", i);
}
}
#elif defined(ARCH_RISCV64)
for (i = 0; i < MAX_IRQn; i++)
{
pending = csi_plic_get_pending_irq(PLIC_BASE, i);
enable = csi_plic_get_enabled_irq(PLIC_BASE, i);
if (pending && enable)
{
rt_kprintf("The wakeup source interrupt ID: %d\n", i);
}
}
#endif
}
#endif
/**
* This function changes the power sleep mode base on the result of selection
*/
@@ -453,6 +488,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
#else
_pm_device_suspend(pm->sleep_mode);
#endif
/* Tickless*/
if (pm->timer_mask & (0x01 << pm->sleep_mode))
{
@@ -489,6 +525,10 @@ static void _pm_change_sleep_mode(struct rt_pm *pm)
}
}
#ifdef PM_ENABLE_DEBUG
pm_dump_wakeup_source();
#endif
/* resume all device */
_pm_device_resume(pm->sleep_mode);
@@ -922,6 +962,16 @@ void rt_pm_default_set(rt_uint8_t sleep_mode)
_pm_default_deepsleep = sleep_mode;
}
rt_uint8_t rt_pm_read_mode_cnt(rt_uint8_t sleep_mode)
{
if (sleep_mode >= PM_SLEEP_MODE_MAX)
{
return 0;
}
return _pm.modes[sleep_mode];
}
/**
* RT-Thread device interface for PM device
*/