internal.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018-2019, 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. };
  29. struct wcd_ctrl_platform_data {
  30. void *handle;
  31. int (*update_wcd_event)(void *handle, u16 event, u32 data);
  32. int (*register_notifier)(void *handle,
  33. struct notifier_block *nblock,
  34. bool enable);
  35. };
  36. struct bolero_priv {
  37. struct device *dev;
  38. struct snd_soc_component *component;
  39. struct regmap *regmap;
  40. struct mutex io_lock;
  41. struct mutex clk_lock;
  42. struct mutex vote_lock;
  43. bool va_without_decimation;
  44. bool macros_supported[MAX_MACRO];
  45. bool dev_up;
  46. bool initial_boot;
  47. struct macro_ops macro_params[MAX_MACRO];
  48. struct snd_soc_dai_driver *bolero_dais;
  49. u16 num_dais;
  50. u16 num_macros_registered;
  51. u16 num_macros;
  52. u16 current_mclk_mux_macro[MAX_MACRO];
  53. struct work_struct bolero_add_child_devices_work;
  54. u32 version;
  55. struct clk *lpass_core_hw_vote;
  56. struct clk *lpass_audio_hw_vote;
  57. int core_hw_vote_count;
  58. int core_audio_vote_count;
  59. /* Entry for version info */
  60. struct snd_info_entry *entry;
  61. struct snd_info_entry *version_entry;
  62. int (*read_dev)(struct bolero_priv *priv,
  63. u16 macro_id, u16 reg, u8 *val);
  64. int (*write_dev)(struct bolero_priv *priv,
  65. u16 macro_id, u16 reg, u8 val);
  66. struct platform_device *pdev_child_devices
  67. [BOLERO_CDC_CHILD_DEVICES_MAX];
  68. u16 child_count;
  69. struct wcd_ctrl_platform_data plat_data;
  70. struct device *wcd_dev;
  71. struct blocking_notifier_head notifier;
  72. struct device *clk_dev;
  73. rsc_clk_cb_t rsc_clk_cb;
  74. };
  75. struct regmap *bolero_regmap_init(struct device *dev,
  76. const struct regmap_config *config);
  77. int bolero_get_macro_id(bool va_no_dec_flag, u16 reg);
  78. extern const struct regmap_config bolero_regmap_config;
  79. extern u8 *bolero_reg_access[MAX_MACRO];
  80. extern u8 bolero_va_top_reg_access[BOLERO_CDC_VA_MACRO_TOP_MAX];
  81. extern const u16 macro_id_base_offset[MAX_MACRO];
  82. #endif