1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2024 Linaro Ltd.
4  */
5 
6 #ifndef __POWER_SEQUENCING_CONSUMER_H__
7 #define __POWER_SEQUENCING_CONSUMER_H__
8 
9 #include <linux/err.h>
10 
11 struct device;
12 struct pwrseq_desc;
13 
14 #if IS_ENABLED(CONFIG_POWER_SEQUENCING)
15 
16 struct pwrseq_desc * __must_check
17 pwrseq_get(struct device *dev, const char *target);
18 void pwrseq_put(struct pwrseq_desc *desc);
19 
20 struct pwrseq_desc * __must_check
21 devm_pwrseq_get(struct device *dev, const char *target);
22 
23 int pwrseq_power_on(struct pwrseq_desc *desc);
24 int pwrseq_power_off(struct pwrseq_desc *desc);
25 
26 #else /* CONFIG_POWER_SEQUENCING */
27 
28 static inline struct pwrseq_desc * __must_check
pwrseq_get(struct device * dev,const char * target)29 pwrseq_get(struct device *dev, const char *target)
30 {
31 	return ERR_PTR(-ENOSYS);
32 }
33 
pwrseq_put(struct pwrseq_desc * desc)34 static inline void pwrseq_put(struct pwrseq_desc *desc)
35 {
36 }
37 
38 static inline struct pwrseq_desc * __must_check
devm_pwrseq_get(struct device * dev,const char * target)39 devm_pwrseq_get(struct device *dev, const char *target)
40 {
41 	return ERR_PTR(-ENOSYS);
42 }
43 
pwrseq_power_on(struct pwrseq_desc * desc)44 static inline int pwrseq_power_on(struct pwrseq_desc *desc)
45 {
46 	return -ENOSYS;
47 }
48 
pwrseq_power_off(struct pwrseq_desc * desc)49 static inline int pwrseq_power_off(struct pwrseq_desc *desc)
50 {
51 	return -ENOSYS;
52 }
53 
54 #endif /* CONFIG_POWER_SEQUENCING */
55 
56 #endif /* __POWER_SEQUENCING_CONSUMER_H__ */
57