sdca.h 2.4 KB

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