internal.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef WSA883X_INTERNAL_H
  6. #define WSA883X_INTERNAL_H
  7. #include "wsa883x.h"
  8. #include "wsa883x-registers.h"
  9. #ifdef CONFIG_DEBUG_FS
  10. #include <linux/debugfs.h>
  11. #include <linux/uaccess.h>
  12. #define SWR_SLV_MAX_REG_ADDR 0x2009
  13. #define SWR_SLV_START_REG_ADDR 0x40
  14. #define SWR_SLV_MAX_BUF_LEN 20
  15. #define BYTES_PER_LINE 12
  16. #define SWR_SLV_RD_BUF_LEN 8
  17. #define SWR_SLV_WR_BUF_LEN 32
  18. #define SWR_SLV_MAX_DEVICES 2
  19. #endif /* CONFIG_DEBUG_FS */
  20. #define WSA883X_DRV_NAME "wsa883x-codec"
  21. #define WSA883X_NUM_RETRY 5
  22. #define WSA883X_VERSION_ENTRY_SIZE 27
  23. enum {
  24. G_18DB = 0,
  25. G_16P5DB,
  26. G_15DB,
  27. G_13P5DB,
  28. G_12DB,
  29. G_10P5DB,
  30. G_9DB,
  31. G_7P5DB,
  32. G_6DB,
  33. G_4P5DB,
  34. G_3DB,
  35. G_1P5DB,
  36. G_0DB,
  37. };
  38. enum {
  39. DISABLE = 0,
  40. ENABLE,
  41. };
  42. enum {
  43. SWR_DAC_PORT,
  44. SWR_COMP_PORT,
  45. SWR_BOOST_PORT,
  46. SWR_VISENSE_PORT,
  47. };
  48. struct swr_port {
  49. u8 port_id;
  50. u8 ch_mask;
  51. u32 ch_rate;
  52. u8 num_ch;
  53. u8 port_type;
  54. };
  55. extern struct regmap_config wsa883x_regmap_config;
  56. /*
  57. * Private data Structure for wsa883x. All parameters related to
  58. * WSA883X codec needs to be defined here.
  59. */
  60. struct wsa883x_priv {
  61. struct regmap *regmap;
  62. struct device *dev;
  63. struct swr_device *swr_slave;
  64. struct snd_soc_component *component;
  65. bool comp_enable;
  66. bool visense_enable;
  67. bool ext_vdd_spk;
  68. struct swr_port port[WSA883X_MAX_SWR_PORTS];
  69. int global_pa_cnt;
  70. int dev_mode;
  71. struct mutex res_lock;
  72. struct snd_info_entry *entry;
  73. struct snd_info_entry *version_entry;
  74. struct device_node *wsa_rst_np;
  75. int pa_mute;
  76. int curr_temp;
  77. int variant;
  78. struct irq_domain *virq;
  79. struct wcd_irq_info irq_info;
  80. #ifdef CONFIG_DEBUG_FS
  81. struct dentry *debugfs_dent;
  82. struct dentry *debugfs_peek;
  83. struct dentry *debugfs_poke;
  84. struct dentry *debugfs_reg_dump;
  85. unsigned int read_data;
  86. #endif
  87. };
  88. static int32_t wsa883x_resource_acquire(struct snd_soc_component *component,
  89. bool enable);
  90. #endif /* WSA883X_INTERNAL_H */