marimba.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /* Copyright (c) 2009-2011, 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. */
  13. /*
  14. * Qualcomm Marimba Core Driver header file
  15. */
  16. #ifndef _MARIMBA_H
  17. #define _MARIMBA_H_
  18. #include <linux/types.h>
  19. #include <linux/i2c.h>
  20. #include <linux/input/msm_ts.h>
  21. #include <mach/vreg.h>
  22. #define MARIMBA_NUM_CHILD 4
  23. #define MARIMBA_SLAVE_ID_MARIMBA 0x00
  24. #define MARIMBA_SLAVE_ID_FM 0x01
  25. #define MARIMBA_SLAVE_ID_CDC 0x02
  26. #define MARIMBA_SLAVE_ID_QMEMBIST 0x03
  27. #define MARIMBA_ID_TSADC 0x04
  28. #define BAHAMA_SLAVE_ID_FM_ID 0x02
  29. #define SLAVE_ID_BAHAMA 0x05
  30. #define SLAVE_ID_BAHAMA_FM 0x07
  31. #define SLAVE_ID_BAHAMA_QMEMBIST 0x08
  32. #if defined(CONFIG_ARCH_MSM7X30)
  33. #define MARIMBA_SSBI_ADAP 0x7
  34. #elif defined(CONFIG_ARCH_MSM8X60)
  35. #define MARIMBA_SSBI_ADAP 0X8
  36. #endif
  37. enum chip_id {
  38. MARIMBA_ID = 0,
  39. TIMPANI_ID,
  40. BAHAMA_ID,
  41. CHIP_ID_MAX
  42. };
  43. enum bahama_version {
  44. BAHAMA_VER_1_0,
  45. BAHAMA_VER_2_0,
  46. BAHAMA_VER_UNSUPPORTED = 0xFF
  47. };
  48. enum {
  49. BT_PCM_ON,
  50. BT_PCM_OFF,
  51. FM_I2S_ON,
  52. FM_I2S_OFF,
  53. };
  54. struct marimba {
  55. struct i2c_client *client;
  56. struct i2c_msg xfer_msg[2];
  57. struct mutex xfer_lock;
  58. int mod_id;
  59. };
  60. struct marimba_top_level_platform_data {
  61. int slave_id; /* Member added for eg. */
  62. };
  63. struct marimba_fm_platform_data {
  64. int irq;
  65. int (*fm_setup)(struct marimba_fm_platform_data *pdata);
  66. void (*fm_shutdown)(struct marimba_fm_platform_data *pdata);
  67. struct vreg *vreg_s2;
  68. struct vreg *vreg_xo_out;
  69. /*
  70. This is to indicate whether Fm SoC is I2S master/slave
  71. false - FM SoC is I2S slave
  72. true - FM SoC is I2S master
  73. */
  74. bool is_fm_soc_i2s_master;
  75. int (*config_i2s_gpio)(int mode);
  76. };
  77. struct marimba_codec_platform_data {
  78. int (*marimba_codec_power)(int vreg_on);
  79. void (*snddev_profile_init) (void);
  80. };
  81. struct marimba_tsadc_setup_params {
  82. bool pen_irq_en;
  83. bool tsadc_en;
  84. };
  85. enum sample_period {
  86. TSADC_CLK_3 = 0,
  87. TSADC_CLK_24,
  88. TSADC_CLK_36,
  89. TSADC_CLK_48,
  90. TSADC_CLK_1,
  91. TSADC_CLK_2,
  92. TSADC_CLK_6,
  93. TSADC_CLK_12,
  94. TSADC_CLOCK_MAX
  95. };
  96. struct marimba_tsadc_config_params2 {
  97. unsigned long input_clk_khz;
  98. enum sample_period sample_prd;
  99. };
  100. struct marimba_tsadc_config_params3 {
  101. unsigned long prechg_time_nsecs;
  102. unsigned long stable_time_nsecs;
  103. unsigned long tsadc_test_mode;
  104. };
  105. struct marimba_tsadc_platform_data {
  106. int (*marimba_tsadc_power)(int vreg_on);
  107. int (*init)(void);
  108. int (*exit)(void);
  109. int (*level_vote)(int vote_on);
  110. bool tsadc_prechg_en;
  111. bool can_wakeup;
  112. struct marimba_tsadc_setup_params setup;
  113. struct marimba_tsadc_config_params2 params2;
  114. struct marimba_tsadc_config_params3 params3;
  115. struct msm_ts_platform_data *tssc_data;
  116. };
  117. /*
  118. * Marimba Platform Data
  119. * */
  120. struct marimba_platform_data {
  121. struct marimba_top_level_platform_data *marimba_tp_level;
  122. struct marimba_fm_platform_data *fm;
  123. struct marimba_codec_platform_data *codec;
  124. struct marimba_tsadc_platform_data *tsadc;
  125. u8 slave_id[(MARIMBA_NUM_CHILD + 1) * CHIP_ID_MAX];
  126. u32 (*marimba_setup) (void);
  127. void (*marimba_shutdown) (void);
  128. u32 (*bahama_setup) (void);
  129. u32 (*bahama_shutdown) (int);
  130. u32 (*marimba_gpio_config) (int);
  131. u32 (*bahama_core_config) (int type);
  132. u32 tsadc_ssbi_adap;
  133. };
  134. /*
  135. * Read and Write to register
  136. * */
  137. int marimba_read(struct marimba *, u8 reg, u8 *value, unsigned num_bytes);
  138. int marimba_write(struct marimba *, u8 reg, u8 *value, unsigned num_bytes);
  139. /*
  140. * Read and Write single 8 bit register with bit mask
  141. * */
  142. int marimba_read_bit_mask(struct marimba *, u8 reg, u8 *value,
  143. unsigned num_bytes, u8 mask);
  144. int marimba_write_bit_mask(struct marimba *, u8 reg, u8 *value,
  145. unsigned num_bytes, u8 mask);
  146. /*
  147. * Read and Write to TSADC registers across the SSBI
  148. * * */
  149. int marimba_ssbi_read(struct marimba *, u16 reg, u8 *value, int len);
  150. int marimba_ssbi_write(struct marimba *, u16 reg , u8 *value, int len);
  151. /* Read and write to Timpani */
  152. int timpani_read(struct marimba*, u8 reg, u8 *value, unsigned num_bytes);
  153. int timpani_write(struct marimba*, u8 reg, u8 *value,
  154. unsigned num_bytes);
  155. /* Get the detected codec type */
  156. int adie_get_detected_codec_type(void);
  157. int adie_get_detected_connectivity_type(void);
  158. int marimba_gpio_config(int gpio_value);
  159. bool marimba_get_fm_status(struct marimba *);
  160. bool marimba_get_bt_status(struct marimba *);
  161. void marimba_set_fm_status(struct marimba *, bool);
  162. void marimba_set_bt_status(struct marimba *, bool);
  163. int marimba_read_bahama_ver(struct marimba *);
  164. #endif