xref: /linux/sound/soc/codecs/lpass-macro-common.h (revision 6ace1c7ea2972bb3d8bfd5ca3d1a1b2bbc41687e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2022, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef __LPASS_MACRO_COMMON_H__
7 #define __LPASS_MACRO_COMMON_H__
8 
9 /* NPL clock is expected */
10 #define LPASS_MACRO_FLAG_HAS_NPL_CLOCK		BIT(0)
11 /* The soundwire block should be internally reset at probe */
12 #define LPASS_MACRO_FLAG_RESET_SWR		BIT(1)
13 
14 enum lpass_version {
15 	LPASS_VER_9_0_0,
16 	LPASS_VER_9_2_0,
17 	LPASS_VER_10_0_0,
18 	LPASS_VER_11_0_0,
19 };
20 
21 enum lpass_codec_version {
22 	LPASS_CODEC_VERSION_UNKNOWN,
23 	LPASS_CODEC_VERSION_1_0,
24 	LPASS_CODEC_VERSION_1_1,
25 	LPASS_CODEC_VERSION_1_2,
26 	LPASS_CODEC_VERSION_2_0,
27 	LPASS_CODEC_VERSION_2_1,
28 	LPASS_CODEC_VERSION_2_5,
29 	LPASS_CODEC_VERSION_2_6,
30 	LPASS_CODEC_VERSION_2_7,
31 	LPASS_CODEC_VERSION_2_8,
32 };
33 
34 struct lpass_macro {
35 	struct device *macro_pd;
36 	struct device *dcodec_pd;
37 };
38 
39 struct lpass_macro *lpass_macro_pds_init(struct device *dev);
40 void lpass_macro_pds_exit(struct lpass_macro *pds);
41 void lpass_macro_set_codec_version(enum lpass_codec_version version);
42 enum lpass_codec_version lpass_macro_get_codec_version(void);
43 
lpass_macro_pds_exit_action(void * pds)44 static inline void lpass_macro_pds_exit_action(void *pds)
45 {
46 	lpass_macro_pds_exit(pds);
47 }
48 
lpass_macro_get_codec_version_string(int version)49 static inline const char *lpass_macro_get_codec_version_string(int version)
50 {
51 	switch (version) {
52 	case LPASS_CODEC_VERSION_1_0:
53 		return "v1.0";
54 	case LPASS_CODEC_VERSION_1_1:
55 		return "v1.1";
56 	case LPASS_CODEC_VERSION_1_2:
57 		return "v1.2";
58 	case LPASS_CODEC_VERSION_2_0:
59 		return "v2.0";
60 	case LPASS_CODEC_VERSION_2_1:
61 		return "v2.1";
62 	case LPASS_CODEC_VERSION_2_5:
63 		return "v2.5";
64 	case LPASS_CODEC_VERSION_2_6:
65 		return "v2.6";
66 	case LPASS_CODEC_VERSION_2_7:
67 		return "v2.7";
68 	case LPASS_CODEC_VERSION_2_8:
69 		return "v2.8";
70 	default:
71 		break;
72 	}
73 	return "NA";
74 }
75 
76 #endif /* __LPASS_MACRO_COMMON_H__ */
77