projects/linux·blob master · refs

91 lines · 2.5 KiB

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
15struct acpi_table_swft;
16struct fwnode_handle;
17struct sdw_slave;
18struct 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 */
32struct 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 */
51struct 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
58enum 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
65void sdca_lookup_functions(struct sdw_slave *slave);
66void sdca_lookup_swft(struct sdw_slave *slave);
67void sdca_lookup_interface_revision(struct sdw_slave *slave);
68bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk);
69int sdca_dev_register_functions(struct sdw_slave *slave);
70void sdca_dev_unregister_functions(struct sdw_slave *slave);
71
72#else
73
74static inline void sdca_lookup_functions(struct sdw_slave *slave) {}
75static inline void sdca_lookup_swft(struct sdw_slave *slave) {}
76static inline void sdca_lookup_interface_revision(struct sdw_slave *slave) {}
77static inline bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk)
78{
79 return false;
80}
81
82static inline int sdca_dev_register_functions(struct sdw_slave *slave)
83{
84 return 0;
85}
86
87static inline void sdca_dev_unregister_functions(struct sdw_slave *slave) {}
88
89#endif
90
91#endif