internal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef _BOLERO_INTERNAL_H
  5. #define _BOLERO_INTERNAL_H
  6. #include "bolero-cdc-registers.h"
  7. #define BOLERO_CDC_CHILD_DEVICES_MAX 6
  8. /* from bolero to WCD events */
  9. enum {
  10. BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1,
  11. BOLERO_WCD_EVT_PA_OFF_PRE_SSR,
  12. BOLERO_WCD_EVT_SSR_DOWN,
  13. BOLERO_WCD_EVT_SSR_UP,
  14. BOLERO_WCD_EVT_PA_ON_POST_FSCLK,
  15. };
  16. enum {
  17. REG_NO_ACCESS,
  18. RD_REG,
  19. WR_REG,
  20. RD_WR_REG
  21. };
  22. /* from WCD to bolero events */
  23. enum {
  24. WCD_BOLERO_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  25. WCD_BOLERO_EVT_IMPED_TRUE, /* for imped true */
  26. WCD_BOLERO_EVT_IMPED_FALSE, /* for imped false */
  27. WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST,
  28. WCD_BOLERO_EVT_BCS_CLK_OFF,
  29. WCD_BOLERO_EVT_RX_PA_GAIN_UPDATE,
  30. WCD_BOLERO_EVT_HPHL_HD2_ENABLE, /* to enable hd2 config for hphl */
  31. WCD_BOLERO_EVT_HPHR_HD2_ENABLE, /* to enable hd2 config for hphr */
  32. };
  33. struct wcd_ctrl_platform_data {
  34. void *handle;
  35. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  36. int (*register_notifier)(void *handle,
  37. struct notifier_block *nblock,
  38. bool enable);
  39. };
  40. struct bolero_priv {
  41. struct device *dev;
  42. struct snd_soc_component *component;
  43. struct regmap *regmap;
  44. struct mutex io_lock;
  45. struct mutex clk_lock;
  46. struct mutex vote_lock;
  47. bool va_without_decimation;
  48. bool macros_supported[MAX_MACRO];
  49. bool dev_up;
  50. bool initial_boot;
  51. struct macro_ops macro_params[MAX_MACRO];
  52. struct snd_soc_dai_driver *bolero_dais;
  53. u16 num_dais;
  54. u16 num_macros_registered;
  55. u16 num_macros;
  56. u16 current_mclk_mux_macro[MAX_MACRO];
  57. struct work_struct bolero_add_child_devices_work;
  58. u32 version;
  59. struct clk *lpass_core_hw_vote;
  60. struct clk *lpass_audio_hw_vote;
  61. int core_hw_vote_count;
  62. int core_audio_vote_count;
  63. /* Entry for version info */
  64. struct snd_info_entry *entry;
  65. struct snd_info_entry *version_entry;
  66. int (*read_dev)(struct bolero_priv *priv,
  67. u16 macro_id, u16 reg, u8 *val);
  68. int (*write_dev)(struct bolero_priv *priv,
  69. u16 macro_id, u16 reg, u8 val);
  70. struct platform_device *pdev_child_devices
  71. [BOLERO_CDC_CHILD_DEVICES_MAX];
  72. u16 child_count;
  73. struct wcd_ctrl_platform_data plat_data;
  74. struct device *wcd_dev;
  75. struct blocking_notifier_head notifier;
  76. struct device *clk_dev;
  77. rsc_clk_cb_t rsc_clk_cb;
  78. s32 dmic_0_1_clk_cnt;
  79. s32 dmic_2_3_clk_cnt;
  80. s32 dmic_4_5_clk_cnt;
  81. s32 dmic_6_7_clk_cnt;
  82. u8 dmic_0_1_clk_div;
  83. u8 dmic_2_3_clk_div;
  84. u8 dmic_4_5_clk_div;
  85. u8 dmic_6_7_clk_div;
  86. };
  87. struct regmap *bolero_regmap_init(struct device *dev,
  88. const struct regmap_config *config);
  89. int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
  90. extern const struct regmap_config bolero_regmap_config;
  91. extern u8 *bolero_reg_access[MAX_MACRO];
  92. extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
  93. extern u8 bolero_va_reg_access_v2[BOLERO_CDC_VA_MACRO_MAX];
  94. extern u8 bolero_va_reg_access_v3[BOLERO_CDC_VA_MACRO_MAX];
  95. extern u8 bolero_tx_reg_access_v2[BOLERO_CDC_TX_MACRO_MAX];
  96. extern const u16 macro_id_base_offset[MAX_MACRO];
  97. #endif