internal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef _LPASS_CDC_INTERNAL_H
  6. #define _LPASS_CDC_INTERNAL_H
  7. #include "lpass-cdc-registers.h"
  8. #define LPASS_CDC_CHILD_DEVICES_MAX 6
  9. /* from lpass_cdc to WCD events */
  10. enum {
  11. LPASS_CDC_WCD_EVT_TX_CH_HOLD_CLEAR = 1,
  12. LPASS_CDC_WCD_EVT_PA_OFF_PRE_SSR,
  13. LPASS_CDC_WCD_EVT_SSR_DOWN,
  14. LPASS_CDC_WCD_EVT_SSR_UP,
  15. LPASS_CDC_WCD_EVT_PA_ON_POST_FSCLK,
  16. LPASS_CDC_WCD_EVT_PA_ON_POST_FSCLK_ADIE_LB,
  17. LPASS_CDC_WCD_EVT_CLK_NOTIFY,
  18. };
  19. enum {
  20. REG_NO_ACCESS,
  21. RD_REG,
  22. WR_REG,
  23. RD_WR_REG
  24. };
  25. /* from WCD to lpass_cdc events */
  26. enum {
  27. WCD_LPASS_CDC_EVT_RX_MUTE = 1, /* for RX mute/unmute */
  28. WCD_LPASS_CDC_EVT_IMPED_TRUE, /* for imped true */
  29. WCD_LPASS_CDC_EVT_IMPED_FALSE, /* for imped false */
  30. WCD_LPASS_CDC_EVT_RX_COMPANDER_SOFT_RST,
  31. WCD_LPASS_CDC_EVT_BCS_CLK_OFF,
  32. WCD_LPASS_CDC_EVT_RX_PA_GAIN_UPDATE,
  33. WCD_LPASS_CDC_EVT_HPHL_HD2_ENABLE, /* to enable hd2 config for hphl */
  34. WCD_LPASS_CDC_EVT_HPHR_HD2_ENABLE, /* to enable hd2 config for hphr */
  35. };
  36. struct wcd_ctrl_platform_data {
  37. void *handle;
  38. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  39. int (*register_notifier)(void *handle,
  40. struct notifier_block *nblock,
  41. bool enable);
  42. };
  43. struct lpass_cdc_priv {
  44. struct device *dev;
  45. struct snd_soc_component *component;
  46. struct regmap *regmap;
  47. struct mutex macro_lock;
  48. struct mutex io_lock;
  49. struct mutex clk_lock;
  50. struct mutex vote_lock;
  51. bool va_without_decimation;
  52. bool macros_supported[MAX_MACRO];
  53. bool dev_up;
  54. bool pre_dev_up;
  55. bool initial_boot;
  56. struct macro_ops macro_params[MAX_MACRO];
  57. struct snd_soc_dai_driver *lpass_cdc_dais;
  58. u16 num_dais;
  59. u16 num_macros_registered;
  60. u16 num_macros;
  61. u16 current_mclk_mux_macro[MAX_MACRO];
  62. struct work_struct lpass_cdc_add_child_devices_work;
  63. u32 version;
  64. struct clk *lpass_core_hw_vote;
  65. struct clk *lpass_audio_hw_vote;
  66. int core_hw_vote_count;
  67. int core_audio_vote_count;
  68. int core_clk_vote_count;
  69. /* Entry for version info */
  70. struct snd_info_entry *entry;
  71. struct snd_info_entry *version_entry;
  72. int (*read_dev)(struct lpass_cdc_priv *priv,
  73. u16 macro_id, u16 reg, u8 *val);
  74. int (*write_dev)(struct lpass_cdc_priv *priv,
  75. u16 macro_id, u16 reg, u8 val);
  76. struct platform_device *pdev_child_devices
  77. [LPASS_CDC_CHILD_DEVICES_MAX];
  78. u16 child_count;
  79. struct wcd_ctrl_platform_data plat_data;
  80. struct device *wcd_dev;
  81. struct blocking_notifier_head notifier;
  82. struct device *clk_dev;
  83. rsc_clk_cb_t rsc_clk_cb;
  84. s32 dmic_0_1_clk_cnt;
  85. s32 dmic_2_3_clk_cnt;
  86. s32 dmic_4_5_clk_cnt;
  87. s32 dmic_6_7_clk_cnt;
  88. u8 dmic_0_1_clk_div;
  89. u8 dmic_2_3_clk_div;
  90. u8 dmic_4_5_clk_div;
  91. u8 dmic_6_7_clk_div;
  92. };
  93. struct regmap *lpass_cdc_regmap_init(struct device *dev,
  94. const struct regmap_config *config);
  95. int lpass_cdc_get_macro_id(bool va_no_dec_flag, u16 reg);
  96. extern const struct regmap_config lpass_cdc_regmap_config;
  97. extern u8 *lpass_cdc_reg_access[MAX_MACRO];
  98. extern const u16 macro_id_base_offset[MAX_MACRO];
  99. #endif