@@ -73,36 +73,16 @@ static inline bool sbi_is_domain_state_available(void)
7373 return data -> available ;
7474}
7575
76- static int sbi_suspend_finisher (unsigned long suspend_type ,
77- unsigned long resume_addr ,
78- unsigned long opaque )
79- {
80- struct sbiret ret ;
81-
82- ret = sbi_ecall (SBI_EXT_HSM , SBI_EXT_HSM_HART_SUSPEND ,
83- suspend_type , resume_addr , opaque , 0 , 0 , 0 );
84-
85- return (ret .error ) ? sbi_err_map_linux_errno (ret .error ) : 0 ;
86- }
87-
88- static int sbi_suspend (u32 state )
89- {
90- if (state & SBI_HSM_SUSP_NON_RET_BIT )
91- return cpu_suspend (state , sbi_suspend_finisher );
92- else
93- return sbi_suspend_finisher (state , 0 , 0 );
94- }
95-
9676static __cpuidle int sbi_cpuidle_enter_state (struct cpuidle_device * dev ,
9777 struct cpuidle_driver * drv , int idx )
9878{
9979 u32 * states = __this_cpu_read (sbi_cpuidle_data .states );
10080 u32 state = states [idx ];
10181
10282 if (state & SBI_HSM_SUSP_NON_RET_BIT )
103- return CPU_PM_CPU_IDLE_ENTER_PARAM (sbi_suspend , idx , state );
83+ return CPU_PM_CPU_IDLE_ENTER_PARAM (riscv_sbi_hart_suspend , idx , state );
10484 else
105- return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM (sbi_suspend ,
85+ return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM (riscv_sbi_hart_suspend ,
10686 idx , state );
10787}
10888
@@ -133,7 +113,7 @@ static __cpuidle int __sbi_enter_domain_idle_state(struct cpuidle_device *dev,
133113 else
134114 state = states [idx ];
135115
136- ret = sbi_suspend (state ) ? -1 : idx ;
116+ ret = riscv_sbi_hart_suspend (state ) ? -1 : idx ;
137117
138118 ct_cpuidle_exit ();
139119
@@ -206,17 +186,6 @@ static const struct of_device_id sbi_cpuidle_state_match[] = {
206186 { },
207187};
208188
209- static bool sbi_suspend_state_is_valid (u32 state )
210- {
211- if (state > SBI_HSM_SUSPEND_RET_DEFAULT &&
212- state < SBI_HSM_SUSPEND_RET_PLATFORM )
213- return false;
214- if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT &&
215- state < SBI_HSM_SUSPEND_NON_RET_PLATFORM )
216- return false;
217- return true;
218- }
219-
220189static int sbi_dt_parse_state_node (struct device_node * np , u32 * state )
221190{
222191 int err = of_property_read_u32 (np , "riscv,sbi-suspend-param" , state );
@@ -226,7 +195,7 @@ static int sbi_dt_parse_state_node(struct device_node *np, u32 *state)
226195 return err ;
227196 }
228197
229- if (!sbi_suspend_state_is_valid (* state )) {
198+ if (!riscv_sbi_suspend_state_is_valid (* state )) {
230199 pr_warn ("Invalid SBI suspend state %#x\n" , * state );
231200 return - EINVAL ;
232201 }
@@ -607,16 +576,8 @@ static int __init sbi_cpuidle_init(void)
607576 int ret ;
608577 struct platform_device * pdev ;
609578
610- /*
611- * The SBI HSM suspend function is only available when:
612- * 1) SBI version is 0.3 or higher
613- * 2) SBI HSM extension is available
614- */
615- if ((sbi_spec_version < sbi_mk_version (0 , 3 )) ||
616- !sbi_probe_extension (SBI_EXT_HSM )) {
617- pr_info ("HSM suspend not available\n" );
579+ if (!riscv_sbi_hsm_is_supported ())
618580 return 0 ;
619- }
620581
621582 ret = platform_driver_register (& sbi_cpuidle_driver );
622583 if (ret )
0 commit comments