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