msm8x10-wcd.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* Copyright (c) 2013, 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 MSM8X10_WCD_H
  13. #define MSM8X10_WCD_H
  14. #include <sound/soc.h>
  15. #include <sound/jack.h>
  16. #include "wcd9xxx-mbhc.h"
  17. #include "wcd9xxx-resmgr.h"
  18. #include <linux/mfd/wcd9xxx/pdata.h>
  19. #define MSM8X10_WCD_NUM_REGISTERS 0x600
  20. #define MSM8X10_WCD_MAX_REGISTER (MSM8X10_WCD_NUM_REGISTERS-1)
  21. #define MSM8X10_WCD_CACHE_SIZE MSM8X10_WCD_NUM_REGISTERS
  22. #define MSM8X10_WCD_NUM_IRQ_REGS 3
  23. #define MAX_REGULATOR 7
  24. #define MSM8X10_WCD_REG_VAL(reg, val) {reg, 0, val}
  25. #define MSM8X10_DINO_LPASS_AUDIO_CORE_DIG_CODEC_CLK_SEL 0xFE03B004
  26. #define MSM8X10_DINO_LPASS_DIGCODEC_CMD_RCGR 0xFE02C000
  27. #define MSM8X10_DINO_LPASS_DIGCODEC_CFG_RCGR 0xFE02C004
  28. #define MSM8X10_DINO_LPASS_DIGCODEC_M 0xFE02C008
  29. #define MSM8X10_DINO_LPASS_DIGCODEC_N 0xFE02C00C
  30. #define MSM8X10_DINO_LPASS_DIGCODEC_D 0xFE02C010
  31. #define MSM8X10_DINO_LPASS_DIGCODEC_CBCR 0xFE02C014
  32. #define MSM8X10_DINO_LPASS_DIGCODEC_AHB_CBCR 0xFE02C018
  33. #define MSM8X10_CODEC_NAME "msm8x10_wcd_codec"
  34. #define MSM8X10_WCD_IS_DINO_REG(reg) \
  35. (((reg >= 0x400) && (reg <= 0x5FF)) ? 1 : 0)
  36. #define MSM8X10_WCD_IS_HELICON_REG(reg) \
  37. (((reg >= 0x000) && (reg <= 0x1FF)) ? 1 : 0)
  38. extern const u8 msm8x10_wcd_reg_readable[MSM8X10_WCD_CACHE_SIZE];
  39. extern const u8 msm8x10_wcd_reset_reg_defaults[MSM8X10_WCD_CACHE_SIZE];
  40. struct msm8x10_wcd_codec_dai_data {
  41. u32 rate;
  42. u32 *ch_num;
  43. u32 ch_act;
  44. u32 ch_tot;
  45. };
  46. enum msm8x10_wcd_pid_current {
  47. MSM8X10_WCD_PID_MIC_2P5_UA,
  48. MSM8X10_WCD_PID_MIC_5_UA,
  49. MSM8X10_WCD_PID_MIC_10_UA,
  50. MSM8X10_WCD_PID_MIC_20_UA,
  51. };
  52. struct msm8x10_wcd_reg_mask_val {
  53. u16 reg;
  54. u8 mask;
  55. u8 val;
  56. };
  57. enum msm8x10_wcd_mbhc_analog_pwr_cfg {
  58. MSM8X10_WCD_ANALOG_PWR_COLLAPSED = 0,
  59. MSM8X10_WCD_ANALOG_PWR_ON,
  60. MSM8X10_WCD_NUM_ANALOG_PWR_CONFIGS,
  61. };
  62. /* Number of input and output Slimbus port */
  63. enum {
  64. MSM8X10_WCD_RX1 = 0,
  65. MSM8X10_WCD_RX2,
  66. MSM8X10_WCD_RX3,
  67. MSM8X10_WCD_RX_MAX,
  68. };
  69. enum {
  70. MSM8X10_WCD_TX1 = 0,
  71. MSM8X10_WCD_TX2,
  72. MSM8X10_WCD_TX3,
  73. MSM8X10_WCD_TX4,
  74. MSM8X10_WCD_TX_MAX,
  75. };
  76. enum {
  77. /* INTR_REG 0 */
  78. MSM8X10_WCD_IRQ_RESERVED_0 = 0,
  79. MSM8X10_WCD_IRQ_MBHC_REMOVAL,
  80. MSM8X10_WCD_IRQ_MBHC_SHORT_TERM,
  81. MSM8X10_WCD_IRQ_MBHC_PRESS,
  82. MSM8X10_WCD_IRQ_MBHC_RELEASE,
  83. MSM8X10_WCD_IRQ_MBHC_POTENTIAL,
  84. MSM8X10_WCD_IRQ_MBHC_INSERTION,
  85. MSM8X10_WCD_IRQ_MBHC_HS_DET,
  86. /* INTR_REG 1 */
  87. MSM8X10_WCD_IRQ_PA_STARTUP,
  88. MSM8X10_WCD_IRQ_BG_PRECHARGE,
  89. MSM8X10_WCD_IRQ_RESERVED_1,
  90. MSM8X10_WCD_IRQ_EAR_PA_OCPL_FAULT,
  91. MSM8X10_WCD_IRQ_EAR_PA_STARTUP,
  92. MSM8X10_WCD_IRQ_SPKR_PA_OCPL_FAULT,
  93. MSM8X10_WCD_IRQ_SPKR_CLIP_FAULT,
  94. MSM8X10_WCD_IRQ_RESERVED_2,
  95. /* INTR_REG 2 */
  96. MSM8X10_WCD_IRQ_HPH_L_PA_STARTUP,
  97. MSM8X10_WCD_IRQ_HPH_R_PA_STARTUP,
  98. MSM8X10_WCD_IRQ_HPH_PA_OCPL_FAULT,
  99. MSM8X10_WCD_IRQ_HPH_PA_OCPR_FAULT,
  100. MSM8X10_WCD_IRQ_RESERVED_3,
  101. MSM8X10_WCD_IRQ_RESERVED_4,
  102. MSM8X10_WCD_IRQ_RESERVED_5,
  103. MSM8X10_WCD_IRQ_RESERVED_6,
  104. MSM8X10_WCD_NUM_IRQS,
  105. };
  106. struct msm8x10_wcd_ocp_setting {
  107. unsigned int use_pdata:1; /* 0 - use sys default as recommended */
  108. unsigned int num_attempts:4; /* up to 15 attempts */
  109. unsigned int run_time:4; /* in duty cycle */
  110. unsigned int wait_time:4; /* in duty cycle */
  111. unsigned int hph_ocp_limit:3; /* Headphone OCP current limit */
  112. };
  113. struct msm8x10_wcd_regulator {
  114. const char *name;
  115. int min_uV;
  116. int max_uV;
  117. int optimum_uA;
  118. bool ondemand;
  119. struct regulator *regulator;
  120. };
  121. struct msm8x10_wcd_pdata {
  122. int irq;
  123. int irq_base;
  124. int num_irqs;
  125. int reset_gpio;
  126. void *msm8x10_wcd_ahb_base_vaddr;
  127. struct wcd9xxx_micbias_setting micbias;
  128. struct msm8x10_wcd_ocp_setting ocp;
  129. struct msm8x10_wcd_regulator regulator[MAX_REGULATOR];
  130. u32 mclk_rate;
  131. };
  132. enum msm8x10_wcd_micbias_num {
  133. MSM8X10_WCD_MICBIAS1 = 0,
  134. };
  135. enum msm8x10_wcd_pm_state {
  136. MSM8X10_WCD_PM_SLEEPABLE,
  137. MSM8X10_WCD_PM_AWAKE,
  138. MSM8X10_WCD_PM_ASLEEP,
  139. };
  140. struct msm8x10_wcd {
  141. struct device *dev;
  142. struct mutex io_lock;
  143. struct mutex xfer_lock;
  144. u8 version;
  145. int reset_gpio;
  146. int (*read_dev)(struct msm8x10_wcd *msm8x10,
  147. unsigned short reg);
  148. int (*write_dev)(struct msm8x10_wcd *msm8x10,
  149. unsigned short reg, u8 val);
  150. u32 num_of_supplies;
  151. struct regulator_bulk_data *supplies;
  152. u8 idbyte[4];
  153. int num_irqs;
  154. u32 mclk_rate;
  155. char __iomem *pdino_base;
  156. struct wcd9xxx_core_resource wcd9xxx_res;
  157. };
  158. extern int msm8x10_wcd_mclk_enable(struct snd_soc_codec *codec, int mclk_enable,
  159. bool dapm);
  160. extern int msm8x10_wcd_hs_detect(struct snd_soc_codec *codec,
  161. struct wcd9xxx_mbhc_config *mbhc_cfg);
  162. #endif