swr-mstr-ctrl.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SWR_WCD_CTRL_H
  6. #define _SWR_WCD_CTRL_H
  7. #include <linux/module.h>
  8. #include <soc/swr-wcd.h>
  9. #include <linux/pm_qos.h>
  10. #include <soc/qcom/pm.h>
  11. #include <soc/swr-common.h>
  12. #define SWR_ROW_48 0
  13. #define SWR_ROW_50 1
  14. #define SWR_ROW_64 2
  15. #define SWR_MAX_COL 7 /* Cols = 16 */
  16. #define SWR_MIN_COL 0 /* Cols = 2 */
  17. #define SWR_WCD_NAME "swr-wcd"
  18. #define SWR_MSTR_PORT_LEN 8 /* Number of master ports */
  19. #define SWRM_VERSION_1_0 0x01010000
  20. #define SWRM_VERSION_1_2 0x01030000
  21. #define SWRM_VERSION_1_3 0x01040000
  22. #define SWRM_VERSION_1_5 0x01050000
  23. #define SWR_MAX_CH_PER_PORT 8
  24. #define SWR_MAX_SLAVE_DEVICES 11
  25. enum {
  26. SWR_MSTR_PAUSE,
  27. SWR_MSTR_RESUME,
  28. SWR_MSTR_UP,
  29. SWR_MSTR_DOWN,
  30. SWR_MSTR_SSR,
  31. };
  32. enum swrm_pm_state {
  33. SWRM_PM_SLEEPABLE,
  34. SWRM_PM_AWAKE,
  35. SWRM_PM_ASLEEP,
  36. };
  37. enum {
  38. SWR_IRQ_FREE,
  39. SWR_IRQ_REGISTER,
  40. };
  41. enum {
  42. SWR_DAC_PORT,
  43. SWR_COMP_PORT,
  44. SWR_BOOST_PORT,
  45. SWR_VISENSE_PORT,
  46. };
  47. struct usecase {
  48. u8 num_port;
  49. u8 num_ch;
  50. u32 chrate;
  51. };
  52. struct swrm_mports {
  53. struct list_head port_req_list;
  54. bool port_en;
  55. u8 ch_en;
  56. u8 req_ch;
  57. u8 ch_rate;
  58. u8 offset1;
  59. u8 offset2;
  60. u8 sinterval;
  61. u8 hstart;
  62. u8 hstop;
  63. u8 blk_grp_count;
  64. u8 blk_pack_mode;
  65. u8 word_length;
  66. u8 lane_ctrl;
  67. };
  68. struct swrm_port_type {
  69. u8 port_type;
  70. u8 ch_mask;
  71. };
  72. struct swr_ctrl_platform_data {
  73. void *handle; /* holds priv data */
  74. int (*read)(void *handle, int reg);
  75. int (*write)(void *handle, int reg, int val);
  76. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  77. int (*clk)(void *handle, bool enable);
  78. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  79. void *data), void *swr_handle, int type);
  80. };
  81. struct swr_mstr_ctrl {
  82. struct swr_master master;
  83. struct device *dev;
  84. struct resource *supplies;
  85. struct clk *mclk;
  86. int clk_ref_count;
  87. struct completion clk_off_complete;
  88. struct completion reset;
  89. struct completion broadcast;
  90. struct mutex clklock;
  91. struct mutex iolock;
  92. struct mutex devlock;
  93. struct mutex mlock;
  94. struct mutex reslock;
  95. struct mutex pm_lock;
  96. u32 swrm_base_reg;
  97. char __iomem *swrm_dig_base;
  98. u8 rcmd_id;
  99. u8 wcmd_id;
  100. u32 master_id;
  101. void *handle; /* SWR Master handle from client for read and writes */
  102. int (*read)(void *handle, int reg);
  103. int (*write)(void *handle, int reg, int val);
  104. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  105. int (*clk)(void *handle, bool enable);
  106. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  107. void *data), void *swr_handle, int type);
  108. int irq;
  109. int wake_irq;
  110. int version;
  111. int mclk_freq;
  112. u32 num_dev;
  113. int slave_status;
  114. struct swrm_mports mport_cfg[SWR_MAX_MSTR_PORT_NUM];
  115. struct list_head port_req_list;
  116. unsigned long port_req_pending;
  117. int state;
  118. struct platform_device *pdev;
  119. int num_rx_chs;
  120. u8 num_cfg_devs;
  121. struct mutex force_down_lock;
  122. int force_down_state;
  123. struct notifier_block event_notifier;
  124. struct work_struct dc_presence_work;
  125. u8 num_ports;
  126. struct swrm_port_type
  127. port_mapping[SWR_MSTR_PORT_LEN][SWR_MAX_CH_PER_PORT];
  128. int swr_irq;
  129. u32 clk_stop_mode0_supp;
  130. struct work_struct wakeup_work;
  131. u32 ipc_wakeup;
  132. bool dev_up;
  133. bool ipc_wakeup_triggered;
  134. struct pm_qos_request pm_qos_req;
  135. enum swrm_pm_state pm_state;
  136. wait_queue_head_t pm_wq;
  137. int wlock_holders;
  138. u32 intr_mask;
  139. struct port_params **port_param;
  140. u8 num_usecase;
  141. };
  142. #endif /* _SWR_WCD_CTRL_H */