swr-wcd-ctrl.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #define SWR_MAX_ROW 0 /* Rows = 48 */
  10. #define SWR_MAX_COL 7 /* Cols = 16 */
  11. #define SWR_MIN_COL 0 /* Cols = 2 */
  12. #define SWR_WCD_NAME "swr-wcd"
  13. #define SWR_MSTR_PORT_LEN 8 /* Number of master ports */
  14. #define SWR_MAX_SLAVE_DEVICES 11
  15. #define SWRM_VERSION_1_0 0x01010000
  16. #define SWRM_VERSION_1_2 0x01030000
  17. #define SWRM_VERSION_1_3 0x01040000
  18. enum {
  19. SWR_MSTR_PAUSE,
  20. SWR_MSTR_RESUME,
  21. SWR_MSTR_UP,
  22. SWR_MSTR_DOWN,
  23. SWR_MSTR_SSR,
  24. };
  25. enum {
  26. SWR_IRQ_FREE,
  27. SWR_IRQ_REGISTER,
  28. };
  29. enum {
  30. SWR_DAC_PORT,
  31. SWR_COMP_PORT,
  32. SWR_BOOST_PORT,
  33. SWR_VISENSE_PORT,
  34. };
  35. struct usecase {
  36. u8 num_port;
  37. u8 num_ch;
  38. u32 chrate;
  39. };
  40. struct port_params {
  41. u8 si;
  42. u8 off1;
  43. u8 off2;
  44. };
  45. struct swrm_mports {
  46. struct list_head list;
  47. u8 id;
  48. };
  49. struct swr_ctrl_platform_data {
  50. void *handle; /* holds priv data */
  51. int (*read)(void *handle, int reg);
  52. int (*write)(void *handle, int reg, int val);
  53. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  54. int (*clk)(void *handle, bool enable);
  55. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  56. void *data), void *swr_handle, int type);
  57. };
  58. struct swr_mstr_ctrl {
  59. struct swr_master master;
  60. struct device *dev;
  61. struct resource *supplies;
  62. struct clk *mclk;
  63. int clk_ref_count;
  64. struct completion reset;
  65. struct completion broadcast;
  66. struct mutex mlock;
  67. struct mutex reslock;
  68. u8 rcmd_id;
  69. u8 wcmd_id;
  70. void *handle; /* SWR Master handle from client for read and writes */
  71. int (*read)(void *handle, int reg);
  72. int (*write)(void *handle, int reg, int val);
  73. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  74. int (*clk)(void *handle, bool enable);
  75. int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
  76. void *data), void *swr_handle, int type);
  77. int irq;
  78. int version;
  79. u32 num_dev;
  80. int num_enum_slaves;
  81. int slave_status;
  82. struct swr_mstr_port *mstr_port;
  83. struct list_head mport_list;
  84. int state;
  85. struct platform_device *pdev;
  86. int num_rx_chs;
  87. u8 num_cfg_devs;
  88. struct mutex force_down_lock;
  89. int force_down_state;
  90. struct notifier_block event_notifier;
  91. struct work_struct dc_presence_work;
  92. };
  93. #endif /* _SWR_WCD_CTRL_H */