xref: /linux/include/sound/sdca.h (revision 456aae6c963e4c63b571249869e6cd7366546504)
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 acpi_table_swft;
16 struct fwnode_handle;
17 struct sdw_slave;
18 struct sdca_dev;
19 
20 #define SDCA_MAX_FUNCTION_COUNT 8
21 
22 /**
23  * struct sdca_function_desc - short descriptor for an SDCA Function
24  * @node: firmware node for the Function.
25  * @func_dev: pointer to SDCA function device.
26  * @name: Human-readable string.
27  * @type: Function topology type.
28  * @adr: ACPI address (used for SDCA register access).
29  * @duplicate: Internal flag to indicate if other functions of the same type
30  * exist.
31  */
32 struct sdca_function_desc {
33 	struct fwnode_handle *node;
34 	struct sdca_dev *func_dev;
35 	const char *name;
36 	u32 type;
37 	u8 adr;
38 
39 	bool duplicate;
40 };
41 
42 /**
43  * struct sdca_device_data - structure containing all SDCA related information
44  * @interface_revision: Value read from _DSD property, mainly to check
45  * for changes between silicon versions.
46  * @num_functions: Total number of supported SDCA functions. Invalid/unsupported
47  * functions will be skipped.
48  * @function: Array of function descriptors.
49  * @swft: Pointer to the SWFT table, if available.
50  */
51 struct sdca_device_data {
52 	u32 interface_revision;
53 	int num_functions;
54 	struct sdca_function_desc function[SDCA_MAX_FUNCTION_COUNT];
55 	struct acpi_table_swft *swft;
56 };
57 
58 enum sdca_quirk {
59 	SDCA_QUIRKS_RT712_VB,
60 	SDCA_QUIRKS_SKIP_FUNC_TYPE_PATCHING,
61 };
62 
63 #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_SOC_SDCA)
64 
65 void sdca_lookup_functions(struct sdw_slave *slave);
66 void sdca_lookup_swft(struct sdw_slave *slave);
67 void sdca_lookup_interface_revision(struct sdw_slave *slave);
68 bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk);
69 int sdca_dev_register_functions(struct sdw_slave *slave);
70 void sdca_dev_unregister_functions(struct sdw_slave *slave);
71 
72 #else
73 
74 static inline void sdca_lookup_functions(struct sdw_slave *slave) {}
75 static inline void sdca_lookup_swft(struct sdw_slave *slave) {}
76 static inline void sdca_lookup_interface_revision(struct sdw_slave *slave) {}
77 static inline bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk)
78 {
79 	return false;
80 }
81 
82 static inline int sdca_dev_register_functions(struct sdw_slave *slave)
83 {
84 	return 0;
85 }
86 
87 static inline void sdca_dev_unregister_functions(struct sdw_slave *slave) {}
88 
89 #endif
90 
91 #endif
92