internal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_21DB = 0,
  28. G_19P5DB,
  29. G_18DB,
  30. G_16P5DB,
  31. G_15DB,
  32. G_13P5DB,
  33. G_12DB,
  34. G_10P5DB,
  35. G_9DB,
  36. G_7P5DB,
  37. G_6DB,
  38. G_4P5DB,
  39. G_3DB,
  40. G_1P5DB,
  41. G_0DB,
  42. };
  43. enum {
  44. DISABLE = 0,
  45. ENABLE,
  46. };
  47. enum {
  48. SWR_DAC_PORT,
  49. SWR_COMP_PORT,
  50. SWR_BOOST_PORT,
  51. SWR_PBR_PORT,
  52. SWR_VISENSE_PORT,
  53. SWR_CPS_PORT
  54. };
  55. struct wsa_ctrl_platform_data {
  56. void *handle;
  57. int (*update_wsa_event)(void *handle, u16 event, u32 data);
  58. int (*register_notifier)(void *handle, struct notifier_block *nblock,
  59. bool enable);
  60. };
  61. struct swr_port {
  62. u8 port_id;
  63. u8 ch_mask;
  64. u32 ch_rate;
  65. u8 num_ch;
  66. u8 port_type;
  67. };
  68. extern struct regmap_config wsa884x_regmap_config;
  69. /*
  70. * Private data Structure for wsa884x. All parameters related to
  71. * WSA884X codec needs to be defined here.
  72. */
  73. struct wsa884x_priv {
  74. struct regmap *regmap;
  75. struct device *dev;
  76. struct swr_device *swr_slave;
  77. struct snd_soc_component *component;
  78. bool comp_enable;
  79. bool visense_enable;
  80. bool cps_enable;
  81. bool pbr_enable;
  82. bool ext_vdd_spk;
  83. bool dapm_bias_off;
  84. struct swr_port port[WSA884X_MAX_SWR_PORTS];
  85. int global_pa_cnt;
  86. int dev_mode;
  87. int comp_offset;
  88. struct mutex res_lock;
  89. struct snd_info_entry *entry;
  90. struct snd_info_entry *version_entry;
  91. struct snd_info_entry *variant_entry;
  92. struct device_node *wsa_rst_np;
  93. int pa_mute;
  94. int curr_temp;
  95. int variant;
  96. int version;
  97. u8 pa_gain;
  98. struct irq_domain *virq;
  99. struct wcd_irq_info irq_info;
  100. #ifdef CONFIG_DEBUG_FS
  101. struct dentry *debugfs_dent;
  102. struct dentry *debugfs_peek;
  103. struct dentry *debugfs_poke;
  104. struct dentry *debugfs_reg_dump;
  105. unsigned int read_data;
  106. #endif
  107. struct device_node *parent_np;
  108. struct platform_device *parent_dev;
  109. struct notifier_block parent_nblock;
  110. void *handle;
  111. int (*register_notifier)(void *handle,
  112. struct notifier_block *nblock, bool enable);
  113. struct cdc_regulator *regulator;
  114. int num_supplies;
  115. struct regulator_bulk_data *supplies;
  116. unsigned long status_mask;
  117. char *wsa884x_name_prefix;
  118. struct snd_soc_dai_driver *dai_driver;
  119. struct snd_soc_component_driver *driver;
  120. };
  121. #endif /* WSA884X_INTERNAL_H */