swr-mstr-ctrl.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _SWR_WCD_CTRL_H
  13. #define _SWR_WCD_CTRL_H
  14. #include <linux/module.h>
  15. #include <soc/swr-wcd.h>
  16. #define SWR_ROW_48 0
  17. #define SWR_ROW_50 1
  18. #define SWR_ROW_64 2
  19. #define SWR_MAX_COL 7 /* Cols = 16 */
  20. #define SWR_MIN_COL 0 /* Cols = 2 */
  21. #define SWR_WCD_NAME "swr-wcd"
  22. #define SWR_MSTR_PORT_LEN 8 /* Number of master ports */
  23. #define SWRM_VERSION_1_0 0x01010000
  24. #define SWRM_VERSION_1_2 0x01030000
  25. #define SWRM_VERSION_1_3 0x01040000
  26. #define SWRM_VERSION_1_5 0x01050000
  27. #define SWR_MAX_CH_PER_PORT 8
  28. #define SWR_MAX_SLAVE_DEVICES 11
  29. enum {
  30. SWR_MSTR_PAUSE,
  31. SWR_MSTR_RESUME,
  32. SWR_MSTR_UP,
  33. SWR_MSTR_DOWN,
  34. SWR_MSTR_SSR,
  35. };
  36. enum {
  37. SWR_IRQ_FREE,
  38. SWR_IRQ_REGISTER,
  39. };
  40. enum {
  41. SWR_DAC_PORT,
  42. SWR_COMP_PORT,
  43. SWR_BOOST_PORT,
  44. SWR_VISENSE_PORT,
  45. };
  46. struct usecase {
  47. u8 num_port;
  48. u8 num_ch;
  49. u32 chrate;
  50. };
  51. struct port_params {
  52. u8 si;
  53. u8 off1;
  54. u8 off2;
  55. u8 hstart;/* head start */
  56. u8 hstop; /* head stop */
  57. u8 wd_len;/* word length */
  58. u8 bp_mode; /* block pack mode */
  59. u8 bgp_ctrl;/* block group control */
  60. u8 lane_ctrl;/* lane to be used */
  61. };
  62. struct swrm_mports {
  63. struct list_head port_req_list;
  64. bool port_en;
  65. u8 ch_en;
  66. u8 req_ch;
  67. u8 ch_rate;
  68. u8 offset1;
  69. u8 offset2;
  70. u8 sinterval;
  71. u8 hstart;
  72. u8 hstop;
  73. u8 blk_grp_count;
  74. u8 blk_pack_mode;
  75. u8 word_length;
  76. u8 lane_ctrl;
  77. };
  78. struct swrm_port_type {
  79. u8 port_type;
  80. u8 ch_mask;
  81. };
  82. struct swr_ctrl_platform_data {
  83. void *handle; /* holds priv data */
  84. int (*read)(void *handle, int reg);
  85. int (*write)(void *handle, int reg, int val);
  86. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  87. int (*clk)(void *handle, bool enable);
  88. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  89. void *data), void *swr_handle, int type);
  90. };
  91. struct swr_mstr_ctrl {
  92. struct swr_master master;
  93. struct device *dev;
  94. struct resource *supplies;
  95. struct clk *mclk;
  96. int clk_ref_count;
  97. struct completion reset;
  98. struct completion broadcast;
  99. struct mutex iolock;
  100. struct mutex mlock;
  101. struct mutex reslock;
  102. u32 swrm_base_reg;
  103. char __iomem *swrm_dig_base;
  104. u8 rcmd_id;
  105. u8 wcmd_id;
  106. u32 master_id;
  107. void *handle; /* SWR Master handle from client for read and writes */
  108. int (*read)(void *handle, int reg);
  109. int (*write)(void *handle, int reg, int val);
  110. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  111. int (*clk)(void *handle, bool enable);
  112. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  113. void *data), void *swr_handle, int type);
  114. int irq;
  115. int version;
  116. u32 num_dev;
  117. int slave_status;
  118. struct swrm_mports mport_cfg[SWR_MAX_MSTR_PORT_NUM];
  119. struct list_head port_req_list;
  120. int state;
  121. struct platform_device *pdev;
  122. int num_rx_chs;
  123. u8 num_cfg_devs;
  124. struct mutex force_down_lock;
  125. int force_down_state;
  126. struct notifier_block event_notifier;
  127. struct work_struct dc_presence_work;
  128. u8 num_ports;
  129. struct swrm_port_type
  130. port_mapping[SWR_MSTR_PORT_LEN][SWR_MAX_CH_PER_PORT];
  131. int swr_irq;
  132. u32 clk_stop_mode0_supp;
  133. };
  134. #endif /* _SWR_WCD_CTRL_H */