internal.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef WSA883X_INTERNAL_H
  6. #define WSA883X_INTERNAL_H
  7. #include <asoc/wcd-irq.h>
  8. #include "wsa883x.h"
  9. #include "wsa883x-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 WSA883X_DRV_NAME "wsa883x-codec"
  22. #define WSA883X_NUM_RETRY 5
  23. #define WSA883X_VERSION_ENTRY_SIZE 32
  24. #define WSA883X_VARIANT_ENTRY_SIZE 32
  25. #define WSA883X_VERSION_1_0 0
  26. #define WSA883X_VERSION_1_1 1
  27. enum {
  28. G_18DB = 0,
  29. G_16P5DB,
  30. G_15DB,
  31. G_13P5DB,
  32. G_12DB,
  33. G_10P5DB,
  34. G_9DB,
  35. G_7P5DB,
  36. G_6DB,
  37. G_4P5DB,
  38. G_3DB,
  39. G_1P5DB,
  40. G_0DB,
  41. };
  42. enum {
  43. DISABLE = 0,
  44. ENABLE,
  45. };
  46. enum {
  47. SWR_DAC_PORT,
  48. SWR_COMP_PORT,
  49. SWR_BOOST_PORT,
  50. SWR_VISENSE_PORT,
  51. };
  52. enum {
  53. BOLERO_WSA_EVT_TX_CH_HOLD_CLEAR = 1,
  54. BOLERO_WSA_EVT_PA_OFF_PRE_SSR,
  55. BOLERO_WSA_EVT_SSR_DOWN,
  56. BOLERO_WSA_EVT_SSR_UP,
  57. BOLERO_WSA_EVT_PA_ON_POST_FSCLK,
  58. BOLERO_WSA_EVT_PA_ON_POST_FSCLK_ADIE_LB,
  59. };
  60. struct wsa_ctrl_platform_data {
  61. void *handle;
  62. int (*update_wsa_event)(void *handle, u16 event, u32 data);
  63. int (*register_notifier)(void *handle, struct notifier_block *nblock,
  64. bool enable);
  65. };
  66. struct swr_port {
  67. u8 port_id;
  68. u8 ch_mask;
  69. u32 ch_rate;
  70. u8 num_ch;
  71. u8 port_type;
  72. };
  73. extern struct regmap_config wsa883x_regmap_config;
  74. /*
  75. * Private data Structure for wsa883x. All parameters related to
  76. * WSA883X codec needs to be defined here.
  77. */
  78. struct wsa883x_priv {
  79. struct regmap *regmap;
  80. struct device *dev;
  81. struct swr_device *swr_slave;
  82. struct snd_soc_component *component;
  83. bool comp_enable;
  84. bool visense_enable;
  85. bool ext_vdd_spk;
  86. bool dapm_bias_off;
  87. struct swr_port port[WSA883X_MAX_SWR_PORTS];
  88. int global_pa_cnt;
  89. int dev_mode;
  90. struct mutex res_lock;
  91. struct snd_info_entry *entry;
  92. struct snd_info_entry *version_entry;
  93. struct snd_info_entry *variant_entry;
  94. struct device_node *wsa_rst_np;
  95. int pa_mute;
  96. int curr_temp;
  97. int variant;
  98. int version;
  99. u8 pa_gain;
  100. struct irq_domain *virq;
  101. struct wcd_irq_info irq_info;
  102. #ifdef CONFIG_DEBUG_FS
  103. struct dentry *debugfs_dent;
  104. struct dentry *debugfs_peek;
  105. struct dentry *debugfs_poke;
  106. struct dentry *debugfs_reg_dump;
  107. unsigned int read_data;
  108. #endif
  109. struct device_node *parent_np;
  110. struct platform_device *parent_dev;
  111. struct notifier_block parent_nblock;
  112. void *handle;
  113. int (*register_notifier)(void *handle,
  114. struct notifier_block *nblock, bool enable);
  115. struct cdc_regulator *regulator;
  116. int num_supplies;
  117. struct regulator_bulk_data *supplies;
  118. unsigned long status_mask;
  119. char *wsa883x_name_prefix;
  120. struct snd_soc_dai_driver *dai_driver;
  121. struct snd_soc_component_driver *driver;
  122. };
  123. #endif /* WSA883X_INTERNAL_H */