1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
3  * The MIPI SDCA specification is available for public downloads at
4  * https://www.mipi.org/mipi-sdca-v1-0-download
5  *
6  * Copyright(c) 2024 Intel Corporation
7  */
8 
9 #ifndef __SDCA_H__
10 #define __SDCA_H__
11 
12 #include <linux/types.h>
13 #include <linux/kconfig.h>
14 
15 struct sdw_slave;
16 
17 #define SDCA_MAX_FUNCTION_COUNT 8
18 
19 /**
20  * sdca_device_desc - short descriptor for an SDCA Function
21  * @adr: ACPI address (used for SDCA register access)
22  * @type: Function topology type
23  * @name: human-readable string
24  */
25 struct sdca_function_desc {
26 	const char *name;
27 	u32 type;
28 	u8 adr;
29 };
30 
31 /**
32  * sdca_device_data - structure containing all SDCA related information
33  * @sdca_interface_revision: value read from _DSD property, mainly to check
34  * for changes between silicon versions
35  * @num_functions: total number of supported SDCA functions. Invalid/unsupported
36  * functions will be skipped.
37  * @sdca_func: array of function descriptors
38  */
39 struct sdca_device_data {
40 	u32 interface_revision;
41 	int num_functions;
42 	struct sdca_function_desc sdca_func[SDCA_MAX_FUNCTION_COUNT];
43 };
44 
45 enum sdca_quirk {
46 	SDCA_QUIRKS_RT712_VB,
47 };
48 
49 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SDCA)
50 
51 void sdca_lookup_functions(struct sdw_slave *slave);
52 void sdca_lookup_interface_revision(struct sdw_slave *slave);
53 bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk);
54 
55 #else
56 
sdca_lookup_functions(struct sdw_slave * slave)57 static inline void sdca_lookup_functions(struct sdw_slave *slave) {}
sdca_lookup_interface_revision(struct sdw_slave * slave)58 static inline void sdca_lookup_interface_revision(struct sdw_slave *slave) {}
sdca_device_quirk_match(struct sdw_slave * slave,enum sdca_quirk quirk)59 static inline bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk)
60 {
61 	return false;
62 }
63 #endif
64 
65 #endif
66