internal.h 3.0 KB

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