pdata.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /* Copyright (c) 2011-2017, 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 __MFD_WCD9XXX_PDATA_H__
  13. #define __MFD_WCD9XXX_PDATA_H__
  14. #include <linux/slimbus/slimbus.h>
  15. #include "msm-cdc-supply.h"
  16. #define MICBIAS_EXT_BYP_CAP 0x00
  17. #define MICBIAS_NO_EXT_BYP_CAP 0x01
  18. #define SITAR_LDOH_1P95_V 0x0
  19. #define SITAR_LDOH_2P35_V 0x1
  20. #define SITAR_LDOH_2P75_V 0x2
  21. #define SITAR_LDOH_2P85_V 0x3
  22. #define SITAR_CFILT1_SEL 0x0
  23. #define SITAR_CFILT2_SEL 0x1
  24. #define SITAR_CFILT3_SEL 0x2
  25. #define WCD9XXX_LDOH_1P95_V 0x0
  26. #define WCD9XXX_LDOH_2P35_V 0x1
  27. #define WCD9XXX_LDOH_2P75_V 0x2
  28. #define WCD9XXX_LDOH_2P85_V 0x3
  29. #define WCD9XXX_LDOH_3P0_V 0x3
  30. #define TABLA_LDOH_1P95_V 0x0
  31. #define TABLA_LDOH_2P35_V 0x1
  32. #define TABLA_LDOH_2P75_V 0x2
  33. #define TABLA_LDOH_2P85_V 0x3
  34. #define TABLA_CFILT1_SEL 0x0
  35. #define TABLA_CFILT2_SEL 0x1
  36. #define TABLA_CFILT3_SEL 0x2
  37. #define MAX_AMIC_CHANNEL 7
  38. #define TABLA_OCP_300_MA 0x0
  39. #define TABLA_OCP_350_MA 0x2
  40. #define TABLA_OCP_365_MA 0x3
  41. #define TABLA_OCP_150_MA 0x4
  42. #define TABLA_OCP_190_MA 0x6
  43. #define TABLA_OCP_220_MA 0x7
  44. #define TABLA_DCYCLE_255 0x0
  45. #define TABLA_DCYCLE_511 0x1
  46. #define TABLA_DCYCLE_767 0x2
  47. #define TABLA_DCYCLE_1023 0x3
  48. #define TABLA_DCYCLE_1279 0x4
  49. #define TABLA_DCYCLE_1535 0x5
  50. #define TABLA_DCYCLE_1791 0x6
  51. #define TABLA_DCYCLE_2047 0x7
  52. #define TABLA_DCYCLE_2303 0x8
  53. #define TABLA_DCYCLE_2559 0x9
  54. #define TABLA_DCYCLE_2815 0xA
  55. #define TABLA_DCYCLE_3071 0xB
  56. #define TABLA_DCYCLE_3327 0xC
  57. #define TABLA_DCYCLE_3583 0xD
  58. #define TABLA_DCYCLE_3839 0xE
  59. #define TABLA_DCYCLE_4095 0xF
  60. #define WCD9XXX_MCLK_CLK_12P288MHZ 12288000
  61. #define WCD9XXX_MCLK_CLK_9P6HZ 9600000
  62. /* Only valid for 9.6 MHz mclk */
  63. #define WCD9XXX_DMIC_SAMPLE_RATE_600KHZ 600000
  64. #define WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ 2400000
  65. #define WCD9XXX_DMIC_SAMPLE_RATE_3P2MHZ 3200000
  66. #define WCD9XXX_DMIC_SAMPLE_RATE_4P8MHZ 4800000
  67. /* Only valid for 12.288 MHz mclk */
  68. #define WCD9XXX_DMIC_SAMPLE_RATE_768KHZ 768000
  69. #define WCD9XXX_DMIC_SAMPLE_RATE_2P048MHZ 2048000
  70. #define WCD9XXX_DMIC_SAMPLE_RATE_3P072MHZ 3072000
  71. #define WCD9XXX_DMIC_SAMPLE_RATE_4P096MHZ 4096000
  72. #define WCD9XXX_DMIC_SAMPLE_RATE_6P144MHZ 6144000
  73. #define WCD9XXX_DMIC_SAMPLE_RATE_UNDEFINED 0
  74. #define WCD9XXX_DMIC_CLK_DRIVE_UNDEFINED 0
  75. struct wcd9xxx_amic {
  76. /*legacy mode, txfe_enable and txfe_buff take 7 input
  77. * each bit represent the channel / TXFE number
  78. * and numbered as below
  79. * bit 0 = channel 1 / TXFE1_ENABLE / TXFE1_BUFF
  80. * bit 1 = channel 2 / TXFE2_ENABLE / TXFE2_BUFF
  81. * ...
  82. * bit 7 = channel 7 / TXFE7_ENABLE / TXFE7_BUFF
  83. */
  84. u8 legacy_mode:MAX_AMIC_CHANNEL;
  85. u8 txfe_enable:MAX_AMIC_CHANNEL;
  86. u8 txfe_buff:MAX_AMIC_CHANNEL;
  87. u8 use_pdata:MAX_AMIC_CHANNEL;
  88. };
  89. /* Each micbias can be assigned to one of three cfilters
  90. * Vbatt_min >= .15V + ldoh_v
  91. * ldoh_v >= .15v + cfiltx_mv
  92. * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
  93. * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
  94. * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
  95. * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
  96. */
  97. struct wcd9xxx_micbias_setting {
  98. u8 ldoh_v;
  99. u32 cfilt1_mv; /* in mv */
  100. u32 cfilt2_mv; /* in mv */
  101. u32 cfilt3_mv; /* in mv */
  102. u32 micb1_mv;
  103. u32 micb2_mv;
  104. u32 micb3_mv;
  105. u32 micb4_mv;
  106. /* Different WCD9xxx series codecs may not
  107. * have 4 mic biases. If a codec has fewer
  108. * mic biases, some of these properties will
  109. * not be used.
  110. */
  111. u8 bias1_cfilt_sel;
  112. u8 bias2_cfilt_sel;
  113. u8 bias3_cfilt_sel;
  114. u8 bias4_cfilt_sel;
  115. u8 bias1_cap_mode;
  116. u8 bias2_cap_mode;
  117. u8 bias3_cap_mode;
  118. u8 bias4_cap_mode;
  119. bool bias2_is_headset_only;
  120. };
  121. struct wcd9xxx_ocp_setting {
  122. unsigned int use_pdata:1; /* 0 - use sys default as recommended */
  123. unsigned int num_attempts:4; /* up to 15 attempts */
  124. unsigned int run_time:4; /* in duty cycle */
  125. unsigned int wait_time:4; /* in duty cycle */
  126. unsigned int hph_ocp_limit:3; /* Headphone OCP current limit */
  127. };
  128. #define WCD9XXX_MAX_REGULATOR 9
  129. /*
  130. * format : TABLA_<POWER_SUPPLY_PIN_NAME>_CUR_MAX
  131. *
  132. * <POWER_SUPPLY_PIN_NAME> from Tabla objective spec
  133. */
  134. #define WCD9XXX_CDC_VDDA_CP_CUR_MAX 500000
  135. #define WCD9XXX_CDC_VDDA_RX_CUR_MAX 20000
  136. #define WCD9XXX_CDC_VDDA_TX_CUR_MAX 20000
  137. #define WCD9XXX_VDDIO_CDC_CUR_MAX 5000
  138. #define WCD9XXX_VDDD_CDC_D_CUR_MAX 5000
  139. #define WCD9XXX_VDDD_CDC_A_CUR_MAX 5000
  140. #define WCD9XXX_VDD_SPKDRV_NAME "cdc-vdd-spkdrv"
  141. #define WCD9XXX_VDD_SPKDRV2_NAME "cdc-vdd-spkdrv-2"
  142. struct wcd9xxx_regulator {
  143. const char *name;
  144. int min_uV;
  145. int max_uV;
  146. int optimum_uA;
  147. bool ondemand;
  148. struct regulator *regulator;
  149. };
  150. struct wcd9xxx_pdata {
  151. int irq;
  152. int irq_base;
  153. int num_irqs;
  154. int reset_gpio;
  155. bool has_buck_vsel_gpio;
  156. struct device_node *buck_vsel_ctl_np;
  157. struct device_node *wcd_rst_np;
  158. struct wcd9xxx_amic amic_settings;
  159. struct slim_device slimbus_slave_device;
  160. struct wcd9xxx_micbias_setting micbias;
  161. struct wcd9xxx_ocp_setting ocp;
  162. struct cdc_regulator *regulator;
  163. int num_supplies;
  164. u32 mclk_rate;
  165. u32 dmic_sample_rate;
  166. u32 mad_dmic_sample_rate;
  167. u32 ecpp_dmic_sample_rate;
  168. u32 dmic_clk_drv;
  169. u16 use_pinctrl;
  170. };
  171. #endif