internal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef WSA883X_INTERNAL_H
  7. #define WSA883X_INTERNAL_H
  8. #include <asoc/wcd-irq.h>
  9. #include "wsa883x.h"
  10. #include "wsa883x-registers.h"
  11. #ifdef CONFIG_DEBUG_FS
  12. #include <linux/debugfs.h>
  13. #include <linux/uaccess.h>
  14. #define SWR_SLV_MAX_REG_ADDR 0x2009
  15. #define SWR_SLV_START_REG_ADDR 0x40
  16. #define SWR_SLV_MAX_BUF_LEN 20
  17. #define BYTES_PER_LINE 12
  18. #define SWR_SLV_RD_BUF_LEN 8
  19. #define SWR_SLV_WR_BUF_LEN 32
  20. #define SWR_SLV_MAX_DEVICES 2
  21. #endif /* CONFIG_DEBUG_FS */
  22. #define WSA883X_DRV_NAME "wsa883x-codec"
  23. #define WSA883X_NUM_RETRY 5
  24. #define WSA883X_VERSION_ENTRY_SIZE 32
  25. #define WSA883X_VARIANT_ENTRY_SIZE 32
  26. #define WSA883X_VERSION_1_0 0
  27. #define WSA883X_VERSION_1_1 1
  28. enum {
  29. G_18DB = 0,
  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_VISENSE_PORT,
  52. };
  53. struct wsa_ctrl_platform_data {
  54. void *handle;
  55. int (*update_wsa_event)(void *handle, u16 event, u32 data);
  56. int (*register_notifier)(void *handle, struct notifier_block *nblock,
  57. bool enable);
  58. };
  59. struct swr_port {
  60. u8 port_id;
  61. u8 ch_mask;
  62. u32 ch_rate;
  63. u8 num_ch;
  64. u8 port_type;
  65. };
  66. extern struct regmap_config wsa883x_regmap_config;
  67. /*
  68. * Private data Structure for wsa883x. All parameters related to
  69. * WSA883X codec needs to be defined here.
  70. */
  71. struct wsa883x_priv {
  72. struct regmap *regmap;
  73. struct device *dev;
  74. struct swr_device *swr_slave;
  75. struct snd_soc_component *component;
  76. bool comp_enable;
  77. bool visense_enable;
  78. bool ext_vdd_spk;
  79. bool dapm_bias_off;
  80. struct swr_port port[WSA883X_MAX_SWR_PORTS];
  81. int global_pa_cnt;
  82. int dev_mode;
  83. int comp_offset;
  84. struct mutex res_lock;
  85. struct snd_info_entry *entry;
  86. struct snd_info_entry *version_entry;
  87. struct snd_info_entry *variant_entry;
  88. struct device_node *wsa_rst_np;
  89. int pa_mute;
  90. int curr_temp;
  91. int variant;
  92. int version;
  93. u8 pa_gain;
  94. struct irq_domain *virq;
  95. struct wcd_irq_info irq_info;
  96. #ifdef CONFIG_DEBUG_FS
  97. struct dentry *debugfs_dent;
  98. struct dentry *debugfs_peek;
  99. struct dentry *debugfs_poke;
  100. struct dentry *debugfs_reg_dump;
  101. unsigned int read_data;
  102. #endif
  103. struct device_node *parent_np;
  104. struct platform_device *parent_dev;
  105. struct notifier_block parent_nblock;
  106. void *handle;
  107. int (*register_notifier)(void *handle,
  108. struct notifier_block *nblock, bool enable);
  109. struct cdc_regulator *regulator;
  110. int num_supplies;
  111. struct regulator_bulk_data *supplies;
  112. unsigned long status_mask;
  113. struct snd_soc_dai_driver *dai_driver;
  114. struct snd_soc_component_driver *driver;
  115. unsigned long port_status_mask;
  116. };
  117. #endif /* WSA883X_INTERNAL_H */