internal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. };
  30. struct wcd_ctrl_platform_data {
  31. void *handle;
  32. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  33. int (*register_notifier)(void *handle,
  34. struct notifier_block *nblock,
  35. bool enable);
  36. };
  37. struct bolero_priv {
  38. struct device *dev;
  39. struct snd_soc_component *component;
  40. struct regmap *regmap;
  41. struct mutex io_lock;
  42. struct mutex clk_lock;
  43. struct mutex vote_lock;
  44. bool va_without_decimation;
  45. bool macros_supported[MAX_MACRO];
  46. bool dev_up;
  47. bool initial_boot;
  48. struct macro_ops macro_params[MAX_MACRO];
  49. struct snd_soc_dai_driver *bolero_dais;
  50. u16 num_dais;
  51. u16 num_macros_registered;
  52. u16 num_macros;
  53. u16 current_mclk_mux_macro[MAX_MACRO];
  54. struct work_struct bolero_add_child_devices_work;
  55. u32 version;
  56. struct clk *lpass_core_hw_vote;
  57. struct clk *lpass_audio_hw_vote;
  58. int core_hw_vote_count;
  59. int core_audio_vote_count;
  60. /* Entry for version info */
  61. struct snd_info_entry *entry;
  62. struct snd_info_entry *version_entry;
  63. int (*read_dev)(struct bolero_priv *priv,
  64. u16 macro_id, u16 reg, u8 *val);
  65. int (*write_dev)(struct bolero_priv *priv,
  66. u16 macro_id, u16 reg, u8 val);
  67. struct platform_device *pdev_child_devices
  68. [BOLERO_CDC_CHILD_DEVICES_MAX];
  69. u16 child_count;
  70. struct wcd_ctrl_platform_data plat_data;
  71. struct device *wcd_dev;
  72. struct blocking_notifier_head notifier;
  73. struct device *clk_dev;
  74. rsc_clk_cb_t rsc_clk_cb;
  75. s32 dmic_0_1_clk_cnt;
  76. s32 dmic_2_3_clk_cnt;
  77. s32 dmic_4_5_clk_cnt;
  78. s32 dmic_6_7_clk_cnt;
  79. u8 dmic_0_1_clk_div;
  80. u8 dmic_2_3_clk_div;
  81. u8 dmic_4_5_clk_div;
  82. u8 dmic_6_7_clk_div;
  83. };
  84. struct regmap *bolero_regmap_init(struct device *dev,
  85. const struct regmap_config *config);
  86. int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
  87. extern const struct regmap_config bolero_regmap_config;
  88. extern u8 *bolero_reg_access[MAX_MACRO];
  89. extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
  90. extern u8 bolero_va_reg_access_v2[BOLERO_CDC_VA_MACRO_MAX];
  91. extern u8 bolero_va_reg_access_v3[BOLERO_CDC_VA_MACRO_MAX];
  92. extern u8 bolero_tx_reg_access_v2[BOLERO_CDC_TX_MACRO_MAX];
  93. extern const u16 macro_id_base_offset[MAX_MACRO];
  94. #endif