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