diff options
author | Samuel Holland <samuel@sholland.org> | 2023-01-23 09:32:07 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-01-24 15:00:21 +0300 |
commit | c45992cc2b121e05c74b438462b8066de3e7d999 (patch) | |
tree | 3e89e9b3349613a2f4ca917959155c2147291d5e /platform/generic/allwinner/sun20i-d1.c | |
parent | 33bf9174602c900201481241e9ade31cf37fccd8 (diff) | |
download | opensbi-c45992cc2b121e05c74b438462b8066de3e7d999.tar.xz |
platform: generic: allwinner: Advertise nonretentive suspend
Add D1's nonretentive suspend state to the devicetree so S-mode software
knows about it and can use it.
Latency and power measurements were taken on an Allwinner Nezha board:
- Entry latency was measured from the beginning of sbi_ecall_handler()
to before the call to wfi() in sun20i_d1_hart_suspend().
- Exit latency was measured from the beginning of sbi_init() to before
the call to sbi_hart_switch_mode() in init_warmboot().
- There was a 17.5 mW benefit from non-retentive suspend compared to
WFI, with a 170 mW cost during the 107 us entry/exit period. This
provides a break-even point around 1040 us. Residency includes entry
latency, so round this up to 1100 us.
- The hardware power sequence latency (after the WFI) is assumed to be
negligible, so set the wakeup latency to the exit latency.
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Diffstat (limited to 'platform/generic/allwinner/sun20i-d1.c')
-rw-r--r-- | platform/generic/allwinner/sun20i-d1.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/platform/generic/allwinner/sun20i-d1.c b/platform/generic/allwinner/sun20i-d1.c index e2b76a3..295c159 100644 --- a/platform/generic/allwinner/sun20i-d1.c +++ b/platform/generic/allwinner/sun20i-d1.c @@ -12,6 +12,7 @@ #include <sbi/sbi_error.h> #include <sbi/sbi_hsm.h> #include <sbi/sbi_pmu.h> +#include <sbi_utils/fdt/fdt_fixup.h> #include <sbi_utils/fdt/fdt_helper.h> #include <sbi_utils/irqchip/fdt_irqchip_plic.h> @@ -202,6 +203,24 @@ static int sun20i_d1_final_init(bool cold_boot, const struct fdt_match *match) return 0; } +static const struct sbi_cpu_idle_state sun20i_d1_cpu_idle_states[] = { + { + .name = "cpu-nonretentive", + .suspend_param = SBI_HSM_SUSPEND_NON_RET_DEFAULT, + .local_timer_stop = true, + .entry_latency_us = 40, + .exit_latency_us = 67, + .min_residency_us = 1100, + .wakeup_latency_us = 67, + }, + { } +}; + +static int sun20i_d1_fdt_fixup(void *fdt, const struct fdt_match *match) +{ + return fdt_add_cpu_idle_states(fdt, sun20i_d1_cpu_idle_states); +} + static void thead_c9xx_pmu_ctr_enable_irq(uint32_t ctr_idx) { unsigned long mip_val; @@ -265,5 +284,6 @@ static const struct fdt_match sun20i_d1_match[] = { const struct platform_override sun20i_d1 = { .match_table = sun20i_d1_match, .final_init = sun20i_d1_final_init, + .fdt_fixup = sun20i_d1_fdt_fixup, .extensions_init = sun20i_d1_extensions_init, }; |