blob: 8f222adeadbef6519f2fb662943f3c3bc50bff4a [file] [log] [blame]
Joonwoo Park1d05bb92013-03-07 16:55:06 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Kiran Kandic3b24402012-06-11 00:05:59 -07002 *
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 Park1d05bb92013-03-07 16:55:06 -080017#include <sound/apr_audio-v2.h>
Kiran Kandic3b24402012-06-11 00:05:59 -070018#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
Joonwoo Parka8890262012-10-15 12:04:27 -070019#include "wcd9xxx-mbhc.h"
20#include "wcd9xxx-resmgr.h"
Kiran Kandia1bed422013-05-28 18:29:12 -070021#include "wcd9xxx-common.h"
Kiran Kandic3b24402012-06-11 00:05:59 -070022
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 Sudhira41630a2012-10-27 00:57:31 -070028#define TAIKO_MCLK_ID 0
Kiran Kandic3b24402012-06-11 00:05:59 -070029
Joonwoo Park1d05bb92013-03-07 16:55:06 -080030#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 Kandic3b24402012-06-11 00:05:59 -070034extern const u8 taiko_reg_readable[TAIKO_CACHE_SIZE];
Kiran Kandi7b7d2ff2012-09-14 14:52:14 -070035extern const u8 taiko_reset_reg_defaults[TAIKO_CACHE_SIZE];
Joonwoo Parka8890262012-10-15 12:04:27 -070036struct taiko_codec_dai_data {
37 u32 rate;
38 u32 *ch_num;
39 u32 ch_act;
40 u32 ch_tot;
Kiran Kandic3b24402012-06-11 00:05:59 -070041};
42
43enum 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 Kandic3b24402012-06-11 00:05:59 -070050enum 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 Wang906ac472012-07-09 12:54:44 -070056/* Number of input and output Slimbus port */
57enum {
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
74enum {
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 Park1d05bb92013-03-07 16:55:06 -080094struct mad_audio_header {
95 u32 reserved[3];
96 u32 num_reg_cfg;
97};
98
99struct 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
106struct 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
115struct 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
126struct 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
136struct 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 Kandic3b24402012-06-11 00:05:59 -0700145extern int taiko_mclk_enable(struct snd_soc_codec *codec, int mclk_enable,
146 bool dapm);
Joonwoo Parka8890262012-10-15 12:04:27 -0700147extern int taiko_hs_detect(struct snd_soc_codec *codec,
148 struct wcd9xxx_mbhc_config *mbhc_cfg);
Joonwoo Park1d05bb92013-03-07 16:55:06 -0800149extern void *taiko_get_afe_config(struct snd_soc_codec *codec,
150 enum afe_config_type config_type);
Kiran Kandic3b24402012-06-11 00:05:59 -0700151
Kiran Kandia1bed422013-05-28 18:29:12 -0700152extern 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 Kandic3b24402012-06-11 00:05:59 -0700157#endif