internal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef WSA884X_INTERNAL_H
  6. #define WSA884X_INTERNAL_H
  7. #include <asoc/wcd-irq.h>
  8. #include "wsa884x.h"
  9. #include "wsa884x-registers.h"
  10. #ifdef CONFIG_DEBUG_FS
  11. #include <linux/debugfs.h>
  12. #include <linux/uaccess.h>
  13. #define SWR_SLV_MAX_REG_ADDR 0x2009
  14. #define SWR_SLV_START_REG_ADDR 0x40
  15. #define SWR_SLV_MAX_BUF_LEN 20
  16. #define BYTES_PER_LINE 12
  17. #define SWR_SLV_RD_BUF_LEN 8
  18. #define SWR_SLV_WR_BUF_LEN 32
  19. #define SWR_SLV_MAX_DEVICES 2
  20. #endif /* CONFIG_DEBUG_FS */
  21. #define WSA884X_DRV_NAME "wsa884x-codec"
  22. #define WSA884X_NUM_RETRY 5
  23. #define WSA884X_VERSION_ENTRY_SIZE 32
  24. #define WSA884X_VARIANT_ENTRY_SIZE 32
  25. #define WSA884X_VERSION_1_0 0
  26. enum {
  27. G_21_DB = 0,
  28. G_19P5_DB,
  29. G_18_DB,
  30. G_16P5_DB,
  31. G_15_DB,
  32. G_13P5_DB,
  33. G_12_DB,
  34. G_10P5_DB,
  35. G_9_DB,
  36. G_7P5_DB,
  37. G_6_DB,
  38. G_4P5_DB,
  39. G_3_DB,
  40. G_1P5_DB,
  41. G_0_DB,
  42. G_M1P5_DB,
  43. G_M3_DB,
  44. G_M4P5_DB,
  45. G_M6_DB,
  46. G_MAX_DB,
  47. };
  48. enum {
  49. PA_AUX_DISABLE = 0,
  50. PA_AUX_M6_DB = 3,
  51. PA_AUX_M4P5_DB = 4,
  52. PA_AUX_M3_DB = 5,
  53. PA_AUX_M1P5_DB = 6,
  54. PA_AUX_0_DB = 7,
  55. PA_AUX_7P5_DB = 8,
  56. PA_AUX_12_DB = 9,
  57. PA_AUX_18_DB = 0xA,
  58. };
  59. enum {
  60. ISENSE_6_DB = 0,
  61. ISENSE_12_DB,
  62. ISENSE_15_DB,
  63. ISENSE_18_DB
  64. };
  65. enum {
  66. VSENSE_M12_DB = 0,
  67. VSENSE_M15_DB,
  68. VSENSE_M18_DB,
  69. VSENSE_M21_DB,
  70. VSENSE_M24_DB
  71. };
  72. enum {
  73. DISABLE = 0,
  74. ENABLE,
  75. };
  76. enum {
  77. SWR_DAC_PORT = 0,
  78. SWR_COMP_PORT,
  79. SWR_BOOST_PORT,
  80. SWR_PBR_PORT,
  81. SWR_VISENSE_PORT,
  82. SWR_CPS_PORT
  83. };
  84. struct wsa_ctrl_platform_data {
  85. void *handle;
  86. int (*update_wsa_event)(void *handle, u16 event, u32 data);
  87. int (*register_notifier)(void *handle, struct notifier_block *nblock,
  88. bool enable);
  89. };
  90. struct swr_port {
  91. u8 port_id;
  92. u8 ch_mask;
  93. u32 ch_rate;
  94. u8 num_ch;
  95. u8 port_type;
  96. };
  97. extern struct regmap_config wsa884x_regmap_config;
  98. /*
  99. * Private data Structure for wsa884x. All parameters related to
  100. * WSA884X codec needs to be defined here.
  101. */
  102. struct wsa884x_priv {
  103. struct regmap *regmap;
  104. struct device *dev;
  105. struct swr_device *swr_slave;
  106. struct snd_soc_component *component;
  107. bool comp_enable;
  108. bool visense_enable;
  109. bool cps_enable;
  110. bool pbr_enable;
  111. bool ext_vdd_spk;
  112. bool dapm_bias_off;
  113. struct swr_port port[WSA884X_MAX_SWR_PORTS];
  114. int global_pa_cnt;
  115. int dev_mode;
  116. int comp_offset;
  117. struct mutex res_lock;
  118. struct snd_info_entry *entry;
  119. struct snd_info_entry *version_entry;
  120. struct snd_info_entry *variant_entry;
  121. struct device_node *wsa_rst_np;
  122. int pa_mute;
  123. int curr_temp;
  124. int variant;
  125. int version;
  126. u8 pa_gain;
  127. u8 bat_cfg;
  128. u8 rload;
  129. u8 system_gain;
  130. int min_gain;
  131. int pa_aux_gain;
  132. struct irq_domain *virq;
  133. struct wcd_irq_info irq_info;
  134. #ifdef CONFIG_DEBUG_FS
  135. struct dentry *debugfs_dent;
  136. struct dentry *debugfs_peek;
  137. struct dentry *debugfs_poke;
  138. struct dentry *debugfs_reg_dump;
  139. unsigned int read_data;
  140. #endif
  141. struct device_node *parent_np;
  142. struct platform_device *parent_dev;
  143. struct notifier_block parent_nblock;
  144. void *handle;
  145. int (*register_notifier)(void *handle,
  146. struct notifier_block *nblock, bool enable);
  147. struct cdc_regulator *regulator;
  148. int num_supplies;
  149. struct regulator_bulk_data *supplies;
  150. unsigned long status_mask;
  151. struct snd_soc_dai_driver *dai_driver;
  152. struct snd_soc_component_driver *driver;
  153. };
  154. #endif /* WSA884X_INTERNAL_H */