cs35l43.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/sound/cs35l43.h -- Platform data for CS35L43
  4. *
  5. * Copyright (c) 2021 Cirrus Logic Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef __CS35L43_H
  12. #define __CS35L43_H
  13. #define CS35L43_REGMAP_RETRY 5
  14. #define CS35L43_IRQ_UNHANDLED_ALERT_INTERVAL_MS 300
  15. #define CS35L43_IRQ_UNHANDLED_ALERT_THRESH 15
  16. #define CS35L43_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
  17. #define CS35L43_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE \
  18. | SNDRV_PCM_FMTBIT_S32_LE)
  19. #define CS35L43_VALID_PDATA 0x80000000
  20. #define CS35L43_NUM_DEFAULTS 41
  21. struct cs35l43_platform_data {
  22. bool gpio1_out_enable;
  23. bool gpio2_out_enable;
  24. bool classh_disable;
  25. bool dsp_ng_enable;
  26. bool vpbr_enable;
  27. int asp_sdout_hiz;
  28. int dsp_ng_pcm_thld;
  29. int dsp_ng_delay;
  30. int dout_hiz;
  31. int bst_vctrl;
  32. int bst_ipk;
  33. int hw_ng_sel;
  34. int hw_ng_delay;
  35. int hw_ng_thld;
  36. int gpio1_src_sel;
  37. int gpio2_src_sel;
  38. int vpbr_rel_rate;
  39. int vpbr_wait;
  40. int vpbr_atk_rate;
  41. int vpbr_atk_vol;
  42. int vpbr_max_att;
  43. int vpbr_thld;
  44. const char *dsp_part_name;
  45. const char *mfd_suffix;
  46. };
  47. struct cs35l43_pll_sysclk_config {
  48. int freq;
  49. int clk_cfg;
  50. };
  51. struct cs35l43_fs_mon_config {
  52. int freq;
  53. unsigned int fs1;
  54. unsigned int fs2;
  55. };
  56. extern const struct cs35l43_pll_sysclk_config cs35l43_pll_sysclk[64];
  57. extern const struct cs35l43_fs_mon_config cs35l43_fs_mon[7];
  58. extern const unsigned int cs35l43_hibernate_update_regs[CS35L43_POWER_SEQ_LENGTH];
  59. extern const u8 cs35l43_write_seq_op_sizes[CS35L43_POWER_SEQ_NUM_OPS][2];
  60. enum cs35l43_hibernate_state {
  61. CS35L43_HIBERNATE_AWAKE = 0,
  62. CS35L43_HIBERNATE_STANDBY = 1,
  63. CS35L43_HIBERNATE_UPDATE = 2,
  64. CS35L43_HIBERNATE_NOT_LOADED = 3,
  65. CS35L43_HIBERNATE_DISABLED = 4,
  66. };
  67. struct cs35l43_write_seq_elem {
  68. u8 size;
  69. u16 offset; /* offset in words from pseq_base */
  70. u8 operation;
  71. u32 *words;
  72. struct list_head list;
  73. };
  74. struct cs35l43_write_seq {
  75. const char *name;
  76. struct list_head list_head;
  77. unsigned int num_ops;
  78. unsigned int length;
  79. };
  80. struct cs35l43_dsp_reg {
  81. const char *name;
  82. unsigned int id;
  83. unsigned int check_value;
  84. };
  85. enum cs35l43_hibernate_mode {
  86. CS35L43_ULTRASONIC_MODE_DISABLED = 0,
  87. CS35L43_ULTRASONIC_MODE_INBAND = 1,
  88. CS35L43_ULTRASONIC_MODE_OUT_OF_BAND = 2,
  89. };
  90. enum cs35l43_low_pwr_mode {
  91. CS35L43_LOW_PWR_MODE_HIBERNATE = 0,
  92. CS35L43_LOW_PWR_MODE_STANDBY = 1,
  93. };
  94. struct cs35l43_private {
  95. struct wm_adsp dsp; /* needs to be first member */
  96. struct snd_soc_component *component;
  97. struct cs35l43_platform_data pdata;
  98. struct device *dev;
  99. struct regmap *regmap;
  100. struct regulator_bulk_data supplies[2];
  101. int num_supplies;
  102. int irq;
  103. int extclk_cfg;
  104. int clk_id;
  105. int lrclk_fmt;
  106. int sclk_fmt;
  107. int asp_fmt;
  108. int hibernate_state;
  109. int hibernate_delay_ms;
  110. int ultrasonic_mode;
  111. int slot_width;
  112. int amp_switch;
  113. int delta_requested;
  114. int delta_applied;
  115. int low_pwr_mode;
  116. int pcm_vol;
  117. int amp_mute;
  118. int mbox_err_pmu;
  119. int mbox_err_pmd;
  120. int irq_unhandled_events;
  121. bool first_event;
  122. bool write_seq_initialized;
  123. bool pcm_muted;
  124. unsigned int max_spi_freq;
  125. struct gpio_desc *reset_gpio;
  126. struct mutex hb_lock;
  127. struct mutex err_lock;
  128. struct workqueue_struct *err_wq;
  129. struct work_struct err_work;
  130. struct workqueue_struct *mbox_wq;
  131. struct work_struct mbox_work;
  132. struct workqueue_struct *irq_wq;
  133. struct delayed_work irq_work;
  134. struct cs35l43_write_seq power_on_seq;
  135. void (*limit_spi_clock)(struct cs35l43_private *cs35l43, bool state);
  136. };
  137. int cs35l43_reinit(struct snd_soc_component *component);
  138. int cs35l43_probe(struct cs35l43_private *cs35l43,
  139. struct cs35l43_platform_data *pdata);
  140. int cs35l43_remove(struct cs35l43_private *cs35l43);
  141. bool cs35l43_readable_reg(struct device *dev, unsigned int reg);
  142. bool cs35l43_precious_reg(struct device *dev, unsigned int reg);
  143. bool cs35l43_volatile_reg(struct device *dev, unsigned int reg);
  144. /* Power management */
  145. #define CS35L43_PM_AUTOSUSPEND_DELAY_MS 150
  146. int cs35l43_suspend_runtime(struct device *dev);
  147. int cs35l43_resume_runtime(struct device *dev);
  148. int cs35l43_sys_suspend(struct device *dev);
  149. int cs35l43_sys_suspend_noirq(struct device *dev);
  150. int cs35l43_sys_resume(struct device *dev);
  151. int cs35l43_sys_resume_noirq(struct device *dev);
  152. extern const struct dev_pm_ops cs35l43_pm_ops;
  153. extern const struct reg_default cs35l43_reg[CS35L43_NUM_DEFAULTS];
  154. #endif /* __CS35L43_H */