diff options
-rw-r--r-- | firmware/drivers/audio/wm8758.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c index 3cae79f026..9db71dea0e 100644 --- a/firmware/drivers/audio/wm8758.c +++ b/firmware/drivers/audio/wm8758.c | |||
@@ -121,36 +121,52 @@ static void audiohw_mute(bool mute) | |||
121 | if (mute) { | 121 | if (mute) { |
122 | wmcodec_write(DACCTRL, DACCTRL_SOFTMUTE); | 122 | wmcodec_write(DACCTRL, DACCTRL_SOFTMUTE); |
123 | } else { | 123 | } else { |
124 | wmcodec_write(DACCTRL, 0); | 124 | wmcodec_write(DACCTRL, DACCTRL_DACOSR128); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void audiohw_preinit(void) | 128 | void audiohw_preinit(void) |
129 | { | 129 | { |
130 | wmcodec_write(RESET, RESET_RESET); | 130 | /* Set low bias mode */ |
131 | 131 | wmcodec_write(BIASCTRL, BIASCTRL_BIASCUT); | |
132 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN | 132 | /* Enable HPCOM, LINECOM */ |
133 | | PWRMGMT1_VMIDSEL_10K); | 133 | wmcodec_write(OUTCTRL, OUTCTRL_HP_COM | OUTCTRL_LINE_COM |
134 | | OUTCTRL_TSOPCTRL | OUTCTRL_TSDEN | OUTCTRL_VROI); | ||
135 | /* Mute all Outputs and set PGAs minimum gain */ | ||
136 | wmcodec_write(LOUT1VOL, 0x140); | ||
137 | wmcodec_write(ROUT1VOL, 0x140); | ||
138 | wmcodec_write(LOUT2VOL, 0x140); | ||
139 | wmcodec_write(ROUT2VOL, 0x140); | ||
140 | wmcodec_write(OUT3MIX, 0x40); | ||
141 | wmcodec_write(OUT4MIX, 0x40); | ||
142 | /* Enable L/ROUT1 */ | ||
134 | wmcodec_write(PWRMGMT2, PWRMGMT2_ROUT1EN | PWRMGMT2_LOUT1EN); | 143 | wmcodec_write(PWRMGMT2, PWRMGMT2_ROUT1EN | PWRMGMT2_LOUT1EN); |
135 | wmcodec_write(PWRMGMT3, PWRMGMT3_LOUT2EN | PWRMGMT3_ROUT2EN | 144 | /* Enable VMID independent current bias */ |
136 | | PWRMGMT3_RMIXEN | PWRMGMT3_LMIXEN | 145 | wmcodec_write(OUT4TOADC, OUT4TOADC_POBCTRL); |
146 | /* Enable required DACs and mixers */ | ||
147 | wmcodec_write(PWRMGMT3, PWRMGMT3_RMIXEN | PWRMGMT3_LMIXEN | ||
137 | | PWRMGMT3_DACENR | PWRMGMT3_DACENL); | 148 | | PWRMGMT3_DACENR | PWRMGMT3_DACENL); |
138 | 149 | /* Enable VMIDSEL, BIASEN, BUFIOEN */ | |
150 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN | ||
151 | | PWRMGMT1_BUFIOEN | PWRMGMT1_VMIDSEL_10K); | ||
152 | /* Setup digital interface, input amplifiers, PLL, ADCs and DACs */ | ||
139 | wmcodec_write(AINTFCE, AINTFCE_IWL_16BIT | AINTFCE_FORMAT_I2S); | 153 | wmcodec_write(AINTFCE, AINTFCE_IWL_16BIT | AINTFCE_FORMAT_I2S); |
140 | wmcodec_write(OUTCTRL, OUTCTRL_VROI); | ||
141 | wmcodec_write(CLKCTRL, CLKCTRL_MS); /* WM8758 is clock master */ | 154 | wmcodec_write(CLKCTRL, CLKCTRL_MS); /* WM8758 is clock master */ |
142 | 155 | ||
143 | audiohw_set_frequency(HW_FREQ_44); | 156 | audiohw_set_frequency(HW_FREQ_44); |
144 | 157 | ||
145 | wmcodec_write(LOUTMIX, LOUTMIX_DACL2LMIX); | 158 | wmcodec_write(LOUTMIX, LOUTMIX_DACL2LMIX); |
146 | wmcodec_write(ROUTMIX, ROUTMIX_DACR2RMIX); | 159 | wmcodec_write(ROUTMIX, ROUTMIX_DACR2RMIX); |
160 | /* Disable VMID independent current bias */ | ||
161 | wmcodec_write(OUT4TOADC, 0); | ||
147 | } | 162 | } |
148 | 163 | ||
149 | void audiohw_postinit(void) | 164 | void audiohw_postinit(void) |
150 | { | 165 | { |
151 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN | 166 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN |
152 | | PWRMGMT1_VMIDSEL_100K); | 167 | | PWRMGMT1_BUFIOEN | PWRMGMT1_VMIDSEL_500K); |
153 | /* lower the VMID power consumption */ | 168 | /* lower the VMID power consumption */ |
169 | wmcodec_write(BIASCTRL, 0); | ||
154 | audiohw_mute(false); | 170 | audiohw_mute(false); |
155 | } | 171 | } |
156 | 172 | ||
@@ -223,9 +239,19 @@ void audiohw_close(void) | |||
223 | { | 239 | { |
224 | audiohw_mute(true); | 240 | audiohw_mute(true); |
225 | 241 | ||
242 | /* Disable Thermal shutdown */ | ||
243 | wmcodec_write(OUTCTRL, OUTCTRL_HP_COM | OUTCTRL_VROI); | ||
244 | /* Enable VMIDTOG */ | ||
245 | wmcodec_write(OUT4TOADC, OUT4TOADC_VMIDTOG); | ||
246 | /* Disable VMIDSEL and BUFIOEN */ | ||
247 | wmcodec_write(PWRMGMT1, PWRMGMT1_PLLEN | PWRMGMT1_BIASEN | ||
248 | | PWRMGMT1_VMIDSEL_OFF); | ||
249 | /* Wait for VMID to discharge */ | ||
250 | sleep(3*HZ/10); | ||
251 | /* Power off registers */ | ||
252 | wmcodec_write(PWRMGMT2, 0); | ||
226 | wmcodec_write(PWRMGMT3, 0); | 253 | wmcodec_write(PWRMGMT3, 0); |
227 | wmcodec_write(PWRMGMT1, 0); | 254 | wmcodec_write(PWRMGMT1, 0); |
228 | wmcodec_write(PWRMGMT2, PWRMGMT2_SLEEP); | ||
229 | } | 255 | } |
230 | 256 | ||
231 | /* Note: Disable output before calling this function */ | 257 | /* Note: Disable output before calling this function */ |