Mark Brown | 9e6e96a | 2010-01-29 17:47:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * wm8994.h -- WM8994 Soc Audio driver |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _WM8994_H |
| 10 | #define _WM8994_H |
| 11 | |
| 12 | #include <sound/soc.h> |
Mark Brown | fbbf592 | 2011-03-11 18:09:04 +0000 | [diff] [blame] | 13 | #include <linux/firmware.h> |
Mark Brown | c7ebf93 | 2011-07-12 19:47:59 +0900 | [diff] [blame] | 14 | #include <linux/completion.h> |
Mark Brown | e9b54de4 | 2012-05-09 19:20:59 +0100 | [diff] [blame] | 15 | #include <linux/workqueue.h> |
Lars-Peter Clausen | fabfad2 | 2014-11-09 17:01:02 +0100 | [diff] [blame] | 16 | #include <linux/mutex.h> |
Mark Brown | 9e6e96a | 2010-01-29 17:47:12 +0000 | [diff] [blame] | 17 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 18 | #include "wm_hubs.h" |
| 19 | |
Mark Brown | 9e6e96a | 2010-01-29 17:47:12 +0000 | [diff] [blame] | 20 | /* Sources for AIF1/2 SYSCLK - use with set_dai_sysclk() */ |
| 21 | #define WM8994_SYSCLK_MCLK1 1 |
| 22 | #define WM8994_SYSCLK_MCLK2 2 |
| 23 | #define WM8994_SYSCLK_FLL1 3 |
| 24 | #define WM8994_SYSCLK_FLL2 4 |
| 25 | |
Mark Brown | 66b47fd | 2010-07-08 11:25:43 +0900 | [diff] [blame] | 26 | /* OPCLK is also configured with set_dai_sysclk, specify division*10 as rate. */ |
| 27 | #define WM8994_SYSCLK_OPCLK 5 |
| 28 | |
Mark Brown | 9e6e96a | 2010-01-29 17:47:12 +0000 | [diff] [blame] | 29 | #define WM8994_FLL1 1 |
| 30 | #define WM8994_FLL2 2 |
| 31 | |
Mark Brown | fbfe698 | 2012-07-23 20:14:43 +0100 | [diff] [blame] | 32 | #define WM8994_FLL_SRC_MCLK1 1 |
| 33 | #define WM8994_FLL_SRC_MCLK2 2 |
| 34 | #define WM8994_FLL_SRC_LRCLK 3 |
| 35 | #define WM8994_FLL_SRC_BCLK 4 |
| 36 | #define WM8994_FLL_SRC_INTERNAL 5 |
Mark Brown | 136ff2a | 2010-04-20 12:56:18 +0900 | [diff] [blame] | 37 | |
Mark Brown | 22f8d05 | 2012-03-19 17:32:06 +0000 | [diff] [blame] | 38 | enum wm8994_vmid_mode { |
| 39 | WM8994_VMID_NORMAL, |
| 40 | WM8994_VMID_FORCE, |
| 41 | }; |
| 42 | |
Mark Brown | 63dd545 | 2012-11-22 20:44:32 +0900 | [diff] [blame] | 43 | typedef void (*wm1811_micdet_cb)(void *data); |
Mark Brown | 98869f6 | 2012-12-03 16:14:37 +0900 | [diff] [blame] | 44 | typedef void (*wm1811_mic_id_cb)(void *data, u16 status); |
Mark Brown | 821edd2 | 2010-11-26 15:21:09 +0000 | [diff] [blame] | 45 | |
Mark Brown | 8876698 | 2010-03-29 20:57:12 +0100 | [diff] [blame] | 46 | int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, |
Mark Brown | 87092e3 | 2012-02-06 18:50:39 +0000 | [diff] [blame] | 47 | int micbias); |
Mark Brown | 821edd2 | 2010-11-26 15:21:09 +0000 | [diff] [blame] | 48 | int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, |
Mark Brown | 98869f6 | 2012-12-03 16:14:37 +0900 | [diff] [blame] | 49 | wm1811_micdet_cb cb, void *det_cb_data, |
| 50 | wm1811_mic_id_cb id_cb, void *id_cb_data); |
Mark Brown | 8876698 | 2010-03-29 20:57:12 +0100 | [diff] [blame] | 51 | |
Mark Brown | 22f8d05 | 2012-03-19 17:32:06 +0000 | [diff] [blame] | 52 | int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode); |
| 53 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 54 | int wm8958_aif_ev(struct snd_soc_dapm_widget *w, |
| 55 | struct snd_kcontrol *kcontrol, int event); |
| 56 | |
| 57 | void wm8958_dsp2_init(struct snd_soc_codec *codec); |
| 58 | |
| 59 | struct wm8994_micdet { |
| 60 | struct snd_soc_jack *jack; |
Mark Brown | 87092e3 | 2012-02-06 18:50:39 +0000 | [diff] [blame] | 61 | bool detecting; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /* codec private data */ |
| 65 | struct wm8994_fll_config { |
| 66 | int src; |
| 67 | int in; |
| 68 | int out; |
| 69 | }; |
| 70 | |
| 71 | #define WM8994_NUM_DRC 3 |
| 72 | #define WM8994_NUM_EQ 3 |
| 73 | |
Mark Brown | 2a8a856 | 2011-07-24 12:20:41 +0100 | [diff] [blame] | 74 | struct wm8994; |
| 75 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 76 | struct wm8994_priv { |
| 77 | struct wm_hubs_data hubs; |
Mark Brown | 2a8a856 | 2011-07-24 12:20:41 +0100 | [diff] [blame] | 78 | struct wm8994 *wm8994; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 79 | int sysclk[2]; |
| 80 | int sysclk_rate[2]; |
| 81 | int mclk[2]; |
| 82 | int aifclk[2]; |
Mark Brown | d372576 | 2013-01-29 23:17:12 +0800 | [diff] [blame] | 83 | int aifdiv[2]; |
Mark Brown | 79748cd | 2012-10-01 15:28:30 +0100 | [diff] [blame] | 84 | int channels[2]; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 85 | struct wm8994_fll_config fll[2], fll_suspend[2]; |
Mark Brown | c7ebf93 | 2011-07-12 19:47:59 +0900 | [diff] [blame] | 86 | struct completion fll_locked[2]; |
| 87 | bool fll_locked_irq; |
Mark Brown | 20dc24a | 2012-04-05 12:55:20 +0100 | [diff] [blame] | 88 | bool fll_byp; |
Mark Brown | 99af79d | 2012-07-25 23:03:36 +0100 | [diff] [blame] | 89 | bool clk_has_run; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 90 | |
Mark Brown | 4b7ed83 | 2011-08-10 17:47:33 +0900 | [diff] [blame] | 91 | int vmid_refcount; |
Mark Brown | af6b6fe | 2011-11-30 20:32:05 +0000 | [diff] [blame] | 92 | int active_refcount; |
Mark Brown | 22f8d05 | 2012-03-19 17:32:06 +0000 | [diff] [blame] | 93 | enum wm8994_vmid_mode vmid_mode; |
Mark Brown | 4b7ed83 | 2011-08-10 17:47:33 +0900 | [diff] [blame] | 94 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 95 | int dac_rates[2]; |
| 96 | int lrclk_shared[2]; |
| 97 | |
| 98 | int mbc_ena[3]; |
Mark Brown | 09e10d7 | 2011-03-16 22:57:47 +0000 | [diff] [blame] | 99 | int hpf1_ena[3]; |
| 100 | int hpf2_ena[3]; |
| 101 | int vss_ena[3]; |
Mark Brown | 3121587 | 2011-03-17 20:23:43 +0000 | [diff] [blame] | 102 | int enh_eq_ena[3]; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 103 | |
| 104 | /* Platform dependant DRC configuration */ |
| 105 | const char **drc_texts; |
| 106 | int drc_cfg[WM8994_NUM_DRC]; |
| 107 | struct soc_enum drc_enum; |
| 108 | |
| 109 | /* Platform dependant ReTune mobile configuration */ |
| 110 | int num_retune_mobile_texts; |
| 111 | const char **retune_mobile_texts; |
| 112 | int retune_mobile_cfg[WM8994_NUM_EQ]; |
| 113 | struct soc_enum retune_mobile_enum; |
| 114 | |
| 115 | /* Platform dependant MBC configuration */ |
| 116 | int mbc_cfg; |
| 117 | const char **mbc_texts; |
| 118 | struct soc_enum mbc_enum; |
| 119 | |
Mark Brown | 09e10d7 | 2011-03-16 22:57:47 +0000 | [diff] [blame] | 120 | /* Platform dependant VSS configuration */ |
| 121 | int vss_cfg; |
| 122 | const char **vss_texts; |
| 123 | struct soc_enum vss_enum; |
| 124 | |
| 125 | /* Platform dependant VSS HPF configuration */ |
| 126 | int vss_hpf_cfg; |
| 127 | const char **vss_hpf_texts; |
| 128 | struct soc_enum vss_hpf_enum; |
| 129 | |
Mark Brown | 3121587 | 2011-03-17 20:23:43 +0000 | [diff] [blame] | 130 | /* Platform dependant enhanced EQ configuration */ |
| 131 | int enh_eq_cfg; |
| 132 | const char **enh_eq_texts; |
| 133 | struct soc_enum enh_eq_enum; |
| 134 | |
Mark Brown | af6b6fe | 2011-11-30 20:32:05 +0000 | [diff] [blame] | 135 | struct mutex accdet_lock; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 136 | struct wm8994_micdet micdet[2]; |
Mark Brown | e9b54de4 | 2012-05-09 19:20:59 +0100 | [diff] [blame] | 137 | struct delayed_work mic_work; |
Mark Brown | 70bd3b2 | 2013-05-29 20:28:16 +0100 | [diff] [blame] | 138 | struct delayed_work open_circuit_work; |
Mark Brown | 2da1c4b | 2013-05-30 13:42:29 +0100 | [diff] [blame] | 139 | struct delayed_work mic_complete_work; |
| 140 | u16 mic_status; |
Mark Brown | 157a75e | 2011-11-30 13:43:51 +0000 | [diff] [blame] | 141 | bool mic_detecting; |
Mark Brown | b00adf7 | 2011-08-13 11:57:18 +0900 | [diff] [blame] | 142 | bool jack_mic; |
Mark Brown | 4585790d | 2011-11-30 10:55:14 +0000 | [diff] [blame] | 143 | int btn_mask; |
Mark Brown | af6b6fe | 2011-11-30 20:32:05 +0000 | [diff] [blame] | 144 | bool jackdet; |
Mark Brown | 4752a88 | 2012-03-04 02:16:01 +0000 | [diff] [blame] | 145 | int jackdet_mode; |
Mark Brown | 99af79d | 2012-07-25 23:03:36 +0100 | [diff] [blame] | 146 | struct delayed_work jackdet_bootstrap; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 147 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 148 | int micdet_irq; |
Mark Brown | 63dd545 | 2012-11-22 20:44:32 +0900 | [diff] [blame] | 149 | wm1811_micdet_cb micd_cb; |
| 150 | void *micd_cb_data; |
Mark Brown | 98869f6 | 2012-12-03 16:14:37 +0900 | [diff] [blame] | 151 | wm1811_mic_id_cb mic_id_cb; |
| 152 | void *mic_id_cb_data; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 153 | |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 154 | unsigned int aif1clk_enable:1; |
| 155 | unsigned int aif2clk_enable:1; |
| 156 | |
| 157 | unsigned int aif1clk_disable:1; |
| 158 | unsigned int aif2clk_disable:1; |
Mark Brown | fbbf592 | 2011-03-11 18:09:04 +0000 | [diff] [blame] | 159 | |
Lars-Peter Clausen | fabfad2 | 2014-11-09 17:01:02 +0100 | [diff] [blame] | 160 | struct mutex fw_lock; |
Mark Brown | f20d77c | 2011-03-16 20:55:37 +0000 | [diff] [blame] | 161 | int dsp_active; |
Mark Brown | fbbf592 | 2011-03-11 18:09:04 +0000 | [diff] [blame] | 162 | const struct firmware *cur_fw; |
| 163 | const struct firmware *mbc; |
Mark Brown | 09e10d7 | 2011-03-16 22:57:47 +0000 | [diff] [blame] | 164 | const struct firmware *mbc_vss; |
Mark Brown | 3121587 | 2011-03-17 20:23:43 +0000 | [diff] [blame] | 165 | const struct firmware *enh_eq; |
Mark Brown | f701a2e | 2011-03-09 19:31:01 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
Mark Brown | 9e6e96a | 2010-01-29 17:47:12 +0000 | [diff] [blame] | 168 | #endif |