swr-mstr-ctrl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_MAX_ROW 0 /* Rows = 48 */
  17. #define SWR_MAX_COL 7 /* Cols = 16 */
  18. #define SWR_MIN_COL 0 /* Cols = 2 */
  19. #define SWR_WCD_NAME "swr-wcd"
  20. #define SWR_MSTR_PORT_LEN 8 /* Number of master ports */
  21. #define SWRM_VERSION_1_0 0x01010000
  22. #define SWRM_VERSION_1_2 0x01030000
  23. #define SWRM_VERSION_1_3 0x01040000
  24. #define SWRM_VERSION_1_5 0x01050000
  25. #define SWR_MAX_CH_PER_PORT 8
  26. #define SWR_MAX_SLAVE_DEVICES 11
  27. enum {
  28. SWR_MSTR_PAUSE,
  29. SWR_MSTR_RESUME,
  30. SWR_MSTR_UP,
  31. SWR_MSTR_DOWN,
  32. SWR_MSTR_SSR,
  33. };
  34. enum {
  35. SWR_IRQ_FREE,
  36. SWR_IRQ_REGISTER,
  37. };
  38. enum {
  39. SWR_DAC_PORT,
  40. SWR_COMP_PORT,
  41. SWR_BOOST_PORT,
  42. SWR_VISENSE_PORT,
  43. };
  44. struct usecase {
  45. u8 num_port;
  46. u8 num_ch;
  47. u32 chrate;
  48. };
  49. struct port_params {
  50. u8 si;
  51. u8 off1;
  52. u8 off2;
  53. };
  54. struct swrm_mports {
  55. struct list_head port_req_list;
  56. bool port_en;
  57. u8 ch_en;
  58. u8 req_ch;
  59. u8 ch_rate;
  60. u8 offset1;
  61. u8 offset2;
  62. u8 sinterval;
  63. u8 hstart;
  64. u8 hstop;
  65. u8 blk_grp_count;
  66. u8 blk_pack_mode;
  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 reset;
  88. struct completion broadcast;
  89. struct mutex mlock;
  90. struct mutex reslock;
  91. u32 swrm_base_reg;
  92. char __iomem *swrm_dig_base;
  93. u8 rcmd_id;
  94. u8 wcmd_id;
  95. void *handle; /* SWR Master handle from client for read and writes */
  96. int (*read)(void *handle, int reg);
  97. int (*write)(void *handle, int reg, int val);
  98. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  99. int (*clk)(void *handle, bool enable);
  100. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  101. void *data), void *swr_handle, int type);
  102. int irq;
  103. int version;
  104. u32 num_dev;
  105. int slave_status;
  106. struct swrm_mports mport_cfg[SWR_MAX_MSTR_PORT_NUM];
  107. struct list_head port_req_list;
  108. int state;
  109. struct platform_device *pdev;
  110. int num_rx_chs;
  111. u8 num_cfg_devs;
  112. struct mutex force_down_lock;
  113. int force_down_state;
  114. u8 num_ports;
  115. struct swrm_port_type
  116. port_mapping[SWR_MSTR_PORT_LEN][SWR_MAX_CH_PER_PORT];
  117. int swr_irq;
  118. };
  119. #endif /* _SWR_WCD_CTRL_H */