Joonwoo Park | 1d05bb9 | 2013-03-07 16:55:06 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 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 WCD9320_H |
| 13 | #define WCD9320_H |
| 14 | |
| 15 | #include <sound/soc.h> |
| 16 | #include <sound/jack.h> |
Joonwoo Park | 1d05bb9 | 2013-03-07 16:55:06 -0800 | [diff] [blame] | 17 | #include <sound/apr_audio-v2.h> |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 18 | #include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h> |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 19 | #include "wcd9xxx-mbhc.h" |
| 20 | #include "wcd9xxx-resmgr.h" |
Kiran Kandi | a1bed42 | 2013-05-28 18:29:12 -0700 | [diff] [blame] | 21 | #include "wcd9xxx-common.h" |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 22 | |
| 23 | #define TAIKO_NUM_REGISTERS 0x400 |
| 24 | #define TAIKO_MAX_REGISTER (TAIKO_NUM_REGISTERS-1) |
| 25 | #define TAIKO_CACHE_SIZE TAIKO_NUM_REGISTERS |
| 26 | |
| 27 | #define TAIKO_REG_VAL(reg, val) {reg, 0, val} |
Venkat Sudhir | a41630a | 2012-10-27 00:57:31 -0700 | [diff] [blame] | 28 | #define TAIKO_MCLK_ID 0 |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 29 | |
Joonwoo Park | 1d05bb9 | 2013-03-07 16:55:06 -0800 | [diff] [blame] | 30 | #define TAIKO_REGISTER_START_OFFSET 0x800 |
| 31 | #define TAIKO_SB_PGD_PORT_RX_BASE 0x40 |
| 32 | #define TAIKO_SB_PGD_PORT_TX_BASE 0x50 |
| 33 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 34 | extern const u8 taiko_reg_readable[TAIKO_CACHE_SIZE]; |
Kiran Kandi | 7b7d2ff | 2012-09-14 14:52:14 -0700 | [diff] [blame] | 35 | extern const u8 taiko_reset_reg_defaults[TAIKO_CACHE_SIZE]; |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 36 | struct taiko_codec_dai_data { |
| 37 | u32 rate; |
| 38 | u32 *ch_num; |
| 39 | u32 ch_act; |
| 40 | u32 ch_tot; |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | enum taiko_pid_current { |
| 44 | TAIKO_PID_MIC_2P5_UA, |
| 45 | TAIKO_PID_MIC_5_UA, |
| 46 | TAIKO_PID_MIC_10_UA, |
| 47 | TAIKO_PID_MIC_20_UA, |
| 48 | }; |
| 49 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 50 | enum taiko_mbhc_analog_pwr_cfg { |
| 51 | TAIKO_ANALOG_PWR_COLLAPSED = 0, |
| 52 | TAIKO_ANALOG_PWR_ON, |
| 53 | TAIKO_NUM_ANALOG_PWR_CONFIGS, |
| 54 | }; |
| 55 | |
Kuirong Wang | 906ac47 | 2012-07-09 12:54:44 -0700 | [diff] [blame] | 56 | /* Number of input and output Slimbus port */ |
| 57 | enum { |
| 58 | TAIKO_RX1 = 0, |
| 59 | TAIKO_RX2, |
| 60 | TAIKO_RX3, |
| 61 | TAIKO_RX4, |
| 62 | TAIKO_RX5, |
| 63 | TAIKO_RX6, |
| 64 | TAIKO_RX7, |
| 65 | TAIKO_RX8, |
| 66 | TAIKO_RX9, |
| 67 | TAIKO_RX10, |
| 68 | TAIKO_RX11, |
| 69 | TAIKO_RX12, |
| 70 | TAIKO_RX13, |
| 71 | TAIKO_RX_MAX, |
| 72 | }; |
| 73 | |
| 74 | enum { |
| 75 | TAIKO_TX1 = 0, |
| 76 | TAIKO_TX2, |
| 77 | TAIKO_TX3, |
| 78 | TAIKO_TX4, |
| 79 | TAIKO_TX5, |
| 80 | TAIKO_TX6, |
| 81 | TAIKO_TX7, |
| 82 | TAIKO_TX8, |
| 83 | TAIKO_TX9, |
| 84 | TAIKO_TX10, |
| 85 | TAIKO_TX11, |
| 86 | TAIKO_TX12, |
| 87 | TAIKO_TX13, |
| 88 | TAIKO_TX14, |
| 89 | TAIKO_TX15, |
| 90 | TAIKO_TX16, |
| 91 | TAIKO_TX_MAX, |
| 92 | }; |
| 93 | |
Joonwoo Park | 1d05bb9 | 2013-03-07 16:55:06 -0800 | [diff] [blame] | 94 | struct mad_audio_header { |
| 95 | u32 reserved[3]; |
| 96 | u32 num_reg_cfg; |
| 97 | }; |
| 98 | |
| 99 | struct mad_microphone_info { |
| 100 | uint8_t input_microphone; |
| 101 | uint8_t cycle_time; |
| 102 | uint8_t settle_time; |
| 103 | uint8_t padding; |
| 104 | } __packed; |
| 105 | |
| 106 | struct mad_micbias_info { |
| 107 | uint8_t micbias; |
| 108 | uint8_t k_factor; |
| 109 | uint8_t external_bypass_capacitor; |
| 110 | uint8_t internal_biasing; |
| 111 | uint8_t cfilter; |
| 112 | uint8_t padding[3]; |
| 113 | } __packed; |
| 114 | |
| 115 | struct mad_rms_audio_beacon_info { |
| 116 | uint8_t rms_omit_samples; |
| 117 | uint8_t rms_comp_time; |
| 118 | uint8_t detection_mechanism; |
| 119 | uint8_t rms_diff_threshold; |
| 120 | uint8_t rms_threshold_lsb; |
| 121 | uint8_t rms_threshold_msb; |
| 122 | uint8_t padding[2]; |
| 123 | uint8_t iir_coefficients[36]; |
| 124 | } __packed; |
| 125 | |
| 126 | struct mad_rms_ultrasound_info { |
| 127 | uint8_t rms_comp_time; |
| 128 | uint8_t detection_mechanism; |
| 129 | uint8_t rms_diff_threshold; |
| 130 | uint8_t rms_threshold_lsb; |
| 131 | uint8_t rms_threshold_msb; |
| 132 | uint8_t padding[3]; |
| 133 | uint8_t iir_coefficients[36]; |
| 134 | } __packed; |
| 135 | |
| 136 | struct mad_audio_cal { |
| 137 | uint32_t version; |
| 138 | struct mad_microphone_info microphone_info; |
| 139 | struct mad_micbias_info micbias_info; |
| 140 | struct mad_rms_audio_beacon_info audio_info; |
| 141 | struct mad_rms_audio_beacon_info beacon_info; |
| 142 | struct mad_rms_ultrasound_info ultrasound_info; |
| 143 | } __packed; |
| 144 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 145 | extern int taiko_mclk_enable(struct snd_soc_codec *codec, int mclk_enable, |
| 146 | bool dapm); |
Joonwoo Park | a889026 | 2012-10-15 12:04:27 -0700 | [diff] [blame] | 147 | extern int taiko_hs_detect(struct snd_soc_codec *codec, |
| 148 | struct wcd9xxx_mbhc_config *mbhc_cfg); |
Joonwoo Park | 1d05bb9 | 2013-03-07 16:55:06 -0800 | [diff] [blame] | 149 | extern void *taiko_get_afe_config(struct snd_soc_codec *codec, |
| 150 | enum afe_config_type config_type); |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 151 | |
Kiran Kandi | a1bed42 | 2013-05-28 18:29:12 -0700 | [diff] [blame] | 152 | extern void taiko_event_register( |
| 153 | int (*machine_event_cb)(struct snd_soc_codec *codec, |
| 154 | enum wcd9xxx_codec_event), |
| 155 | struct snd_soc_codec *codec); |
| 156 | |
Kiran Kandi | c3b2440 | 2012-06-11 00:05:59 -0700 | [diff] [blame] | 157 | #endif |