internal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 io_lock;
  48. struct mutex clk_lock;
  49. struct mutex vote_lock;
  50. bool va_without_decimation;
  51. bool macros_supported[MAX_MACRO];
  52. bool dev_up;
  53. bool pre_dev_up;
  54. bool initial_boot;
  55. struct macro_ops macro_params[MAX_MACRO];
  56. struct snd_soc_dai_driver *lpass_cdc_dais;
  57. u16 num_dais;
  58. u16 num_macros_registered;
  59. u16 num_macros;
  60. u16 current_mclk_mux_macro[MAX_MACRO];
  61. struct work_struct lpass_cdc_add_child_devices_work;
  62. u32 version;
  63. struct clk *lpass_core_hw_vote;
  64. struct clk *lpass_audio_hw_vote;
  65. int core_hw_vote_count;
  66. int core_audio_vote_count;
  67. /* Entry for version info */
  68. struct snd_info_entry *entry;
  69. struct snd_info_entry *version_entry;
  70. int (*read_dev)(struct lpass_cdc_priv *priv,
  71. u16 macro_id, u16 reg, u8 *val);
  72. int (*write_dev)(struct lpass_cdc_priv *priv,
  73. u16 macro_id, u16 reg, u8 val);
  74. struct platform_device *pdev_child_devices
  75. [LPASS_CDC_CHILD_DEVICES_MAX];
  76. u16 child_count;
  77. struct wcd_ctrl_platform_data plat_data;
  78. struct device *wcd_dev;
  79. struct blocking_notifier_head notifier;
  80. struct device *clk_dev;
  81. rsc_clk_cb_t rsc_clk_cb;
  82. s32 dmic_0_1_clk_cnt;
  83. s32 dmic_2_3_clk_cnt;
  84. s32 dmic_4_5_clk_cnt;
  85. s32 dmic_6_7_clk_cnt;
  86. u8 dmic_0_1_clk_div;
  87. u8 dmic_2_3_clk_div;
  88. u8 dmic_4_5_clk_div;
  89. u8 dmic_6_7_clk_div;
  90. };
  91. struct regmap *lpass_cdc_regmap_init(struct device *dev,
  92. const struct regmap_config *config);
  93. int lpass_cdc_get_macro_id(bool va_no_dec_flag, u16 reg);
  94. extern const struct regmap_config lpass_cdc_regmap_config;
  95. extern u8 *lpass_cdc_reg_access[MAX_MACRO];
  96. extern const u16 macro_id_base_offset[MAX_MACRO];
  97. #endif