internal.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. enum {
  56. WSA883X_DEV_DOWN,
  57. WSA883X_DEV_UP,
  58. WSA883X_DEV_READY,
  59. };
  60. extern struct regmap_config wsa883x_regmap_config;
  61. /*
  62. * Private data Structure for wsa883x. All parameters related to
  63. * WSA883X codec needs to be defined here.
  64. */
  65. struct wsa883x_priv {
  66. struct regmap *regmap;
  67. struct device *dev;
  68. struct swr_device *swr_slave;
  69. struct snd_soc_component *component;
  70. bool comp_enable;
  71. bool boost_enable;
  72. bool visense_enable;
  73. u8 pa_gain;
  74. struct swr_port port[WSA883X_MAX_SWR_PORTS];
  75. int pd_gpio;
  76. struct wsa883x_tz_priv tz_pdata;
  77. int bg_cnt;
  78. int clk_cnt;
  79. int version;
  80. struct mutex bg_lock;
  81. struct mutex res_lock;
  82. struct mutex temp_lock;
  83. struct snd_info_entry *entry;
  84. struct snd_info_entry *version_entry;
  85. int state;
  86. struct delayed_work ocp_ctl_work;
  87. struct device_node *wsa_rst_np;
  88. int pa_mute;
  89. #ifdef CONFIG_DEBUG_FS
  90. struct dentry *debugfs_dent;
  91. struct dentry *debugfs_peek;
  92. struct dentry *debugfs_poke;
  93. struct dentry *debugfs_reg_dump;
  94. unsigned int read_data;
  95. #endif
  96. };
  97. static int32_t wsa883x_resource_acquire(struct snd_soc_component *component,
  98. bool enable);
  99. #endif /* WSA883X_INTERNAL_H */