18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * max98090.c -- MAX98090 ALSA SoC Audio driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2011-2012 Maxim Integrated Products
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/delay.h>
98c2ecf20Sopenharmony_ci#include <linux/i2c.h>
108c2ecf20Sopenharmony_ci#include <linux/module.h>
118c2ecf20Sopenharmony_ci#include <linux/of.h>
128c2ecf20Sopenharmony_ci#include <linux/pm.h>
138c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h>
148c2ecf20Sopenharmony_ci#include <linux/regmap.h>
158c2ecf20Sopenharmony_ci#include <linux/slab.h>
168c2ecf20Sopenharmony_ci#include <linux/acpi.h>
178c2ecf20Sopenharmony_ci#include <linux/clk.h>
188c2ecf20Sopenharmony_ci#include <sound/jack.h>
198c2ecf20Sopenharmony_ci#include <sound/pcm.h>
208c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
218c2ecf20Sopenharmony_ci#include <sound/soc.h>
228c2ecf20Sopenharmony_ci#include <sound/tlv.h>
238c2ecf20Sopenharmony_ci#include <sound/max98090.h>
248c2ecf20Sopenharmony_ci#include "max98090.h"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Allows for sparsely populated register maps */
278c2ecf20Sopenharmony_cistatic const struct reg_default max98090_reg[] = {
288c2ecf20Sopenharmony_ci	{ 0x00, 0x00 }, /* 00 Software Reset */
298c2ecf20Sopenharmony_ci	{ 0x03, 0x04 }, /* 03 Interrupt Masks */
308c2ecf20Sopenharmony_ci	{ 0x04, 0x00 }, /* 04 System Clock Quick */
318c2ecf20Sopenharmony_ci	{ 0x05, 0x00 }, /* 05 Sample Rate Quick */
328c2ecf20Sopenharmony_ci	{ 0x06, 0x00 }, /* 06 DAI Interface Quick */
338c2ecf20Sopenharmony_ci	{ 0x07, 0x00 }, /* 07 DAC Path Quick */
348c2ecf20Sopenharmony_ci	{ 0x08, 0x00 }, /* 08 Mic/Direct to ADC Quick */
358c2ecf20Sopenharmony_ci	{ 0x09, 0x00 }, /* 09 Line to ADC Quick */
368c2ecf20Sopenharmony_ci	{ 0x0A, 0x00 }, /* 0A Analog Mic Loop Quick */
378c2ecf20Sopenharmony_ci	{ 0x0B, 0x00 }, /* 0B Analog Line Loop Quick */
388c2ecf20Sopenharmony_ci	{ 0x0C, 0x00 }, /* 0C Reserved */
398c2ecf20Sopenharmony_ci	{ 0x0D, 0x00 }, /* 0D Input Config */
408c2ecf20Sopenharmony_ci	{ 0x0E, 0x1B }, /* 0E Line Input Level */
418c2ecf20Sopenharmony_ci	{ 0x0F, 0x00 }, /* 0F Line Config */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	{ 0x10, 0x14 }, /* 10 Mic1 Input Level */
448c2ecf20Sopenharmony_ci	{ 0x11, 0x14 }, /* 11 Mic2 Input Level */
458c2ecf20Sopenharmony_ci	{ 0x12, 0x00 }, /* 12 Mic Bias Voltage */
468c2ecf20Sopenharmony_ci	{ 0x13, 0x00 }, /* 13 Digital Mic Config */
478c2ecf20Sopenharmony_ci	{ 0x14, 0x00 }, /* 14 Digital Mic Mode */
488c2ecf20Sopenharmony_ci	{ 0x15, 0x00 }, /* 15 Left ADC Mixer */
498c2ecf20Sopenharmony_ci	{ 0x16, 0x00 }, /* 16 Right ADC Mixer */
508c2ecf20Sopenharmony_ci	{ 0x17, 0x03 }, /* 17 Left ADC Level */
518c2ecf20Sopenharmony_ci	{ 0x18, 0x03 }, /* 18 Right ADC Level */
528c2ecf20Sopenharmony_ci	{ 0x19, 0x00 }, /* 19 ADC Biquad Level */
538c2ecf20Sopenharmony_ci	{ 0x1A, 0x00 }, /* 1A ADC Sidetone */
548c2ecf20Sopenharmony_ci	{ 0x1B, 0x00 }, /* 1B System Clock */
558c2ecf20Sopenharmony_ci	{ 0x1C, 0x00 }, /* 1C Clock Mode */
568c2ecf20Sopenharmony_ci	{ 0x1D, 0x00 }, /* 1D Any Clock 1 */
578c2ecf20Sopenharmony_ci	{ 0x1E, 0x00 }, /* 1E Any Clock 2 */
588c2ecf20Sopenharmony_ci	{ 0x1F, 0x00 }, /* 1F Any Clock 3 */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	{ 0x20, 0x00 }, /* 20 Any Clock 4 */
618c2ecf20Sopenharmony_ci	{ 0x21, 0x00 }, /* 21 Master Mode */
628c2ecf20Sopenharmony_ci	{ 0x22, 0x00 }, /* 22 Interface Format */
638c2ecf20Sopenharmony_ci	{ 0x23, 0x00 }, /* 23 TDM Format 1*/
648c2ecf20Sopenharmony_ci	{ 0x24, 0x00 }, /* 24 TDM Format 2*/
658c2ecf20Sopenharmony_ci	{ 0x25, 0x00 }, /* 25 I/O Configuration */
668c2ecf20Sopenharmony_ci	{ 0x26, 0x80 }, /* 26 Filter Config */
678c2ecf20Sopenharmony_ci	{ 0x27, 0x00 }, /* 27 DAI Playback Level */
688c2ecf20Sopenharmony_ci	{ 0x28, 0x00 }, /* 28 EQ Playback Level */
698c2ecf20Sopenharmony_ci	{ 0x29, 0x00 }, /* 29 Left HP Mixer */
708c2ecf20Sopenharmony_ci	{ 0x2A, 0x00 }, /* 2A Right HP Mixer */
718c2ecf20Sopenharmony_ci	{ 0x2B, 0x00 }, /* 2B HP Control */
728c2ecf20Sopenharmony_ci	{ 0x2C, 0x1A }, /* 2C Left HP Volume */
738c2ecf20Sopenharmony_ci	{ 0x2D, 0x1A }, /* 2D Right HP Volume */
748c2ecf20Sopenharmony_ci	{ 0x2E, 0x00 }, /* 2E Left Spk Mixer */
758c2ecf20Sopenharmony_ci	{ 0x2F, 0x00 }, /* 2F Right Spk Mixer */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	{ 0x30, 0x00 }, /* 30 Spk Control */
788c2ecf20Sopenharmony_ci	{ 0x31, 0x2C }, /* 31 Left Spk Volume */
798c2ecf20Sopenharmony_ci	{ 0x32, 0x2C }, /* 32 Right Spk Volume */
808c2ecf20Sopenharmony_ci	{ 0x33, 0x00 }, /* 33 ALC Timing */
818c2ecf20Sopenharmony_ci	{ 0x34, 0x00 }, /* 34 ALC Compressor */
828c2ecf20Sopenharmony_ci	{ 0x35, 0x00 }, /* 35 ALC Expander */
838c2ecf20Sopenharmony_ci	{ 0x36, 0x00 }, /* 36 ALC Gain */
848c2ecf20Sopenharmony_ci	{ 0x37, 0x00 }, /* 37 Rcv/Line OutL Mixer */
858c2ecf20Sopenharmony_ci	{ 0x38, 0x00 }, /* 38 Rcv/Line OutL Control */
868c2ecf20Sopenharmony_ci	{ 0x39, 0x15 }, /* 39 Rcv/Line OutL Volume */
878c2ecf20Sopenharmony_ci	{ 0x3A, 0x00 }, /* 3A Line OutR Mixer */
888c2ecf20Sopenharmony_ci	{ 0x3B, 0x00 }, /* 3B Line OutR Control */
898c2ecf20Sopenharmony_ci	{ 0x3C, 0x15 }, /* 3C Line OutR Volume */
908c2ecf20Sopenharmony_ci	{ 0x3D, 0x00 }, /* 3D Jack Detect */
918c2ecf20Sopenharmony_ci	{ 0x3E, 0x00 }, /* 3E Input Enable */
928c2ecf20Sopenharmony_ci	{ 0x3F, 0x00 }, /* 3F Output Enable */
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	{ 0x40, 0x00 }, /* 40 Level Control */
958c2ecf20Sopenharmony_ci	{ 0x41, 0x00 }, /* 41 DSP Filter Enable */
968c2ecf20Sopenharmony_ci	{ 0x42, 0x00 }, /* 42 Bias Control */
978c2ecf20Sopenharmony_ci	{ 0x43, 0x00 }, /* 43 DAC Control */
988c2ecf20Sopenharmony_ci	{ 0x44, 0x06 }, /* 44 ADC Control */
998c2ecf20Sopenharmony_ci	{ 0x45, 0x00 }, /* 45 Device Shutdown */
1008c2ecf20Sopenharmony_ci	{ 0x46, 0x00 }, /* 46 Equalizer Band 1 Coefficient B0 */
1018c2ecf20Sopenharmony_ci	{ 0x47, 0x00 }, /* 47 Equalizer Band 1 Coefficient B0 */
1028c2ecf20Sopenharmony_ci	{ 0x48, 0x00 }, /* 48 Equalizer Band 1 Coefficient B0 */
1038c2ecf20Sopenharmony_ci	{ 0x49, 0x00 }, /* 49 Equalizer Band 1 Coefficient B1 */
1048c2ecf20Sopenharmony_ci	{ 0x4A, 0x00 }, /* 4A Equalizer Band 1 Coefficient B1 */
1058c2ecf20Sopenharmony_ci	{ 0x4B, 0x00 }, /* 4B Equalizer Band 1 Coefficient B1 */
1068c2ecf20Sopenharmony_ci	{ 0x4C, 0x00 }, /* 4C Equalizer Band 1 Coefficient B2 */
1078c2ecf20Sopenharmony_ci	{ 0x4D, 0x00 }, /* 4D Equalizer Band 1 Coefficient B2 */
1088c2ecf20Sopenharmony_ci	{ 0x4E, 0x00 }, /* 4E Equalizer Band 1 Coefficient B2 */
1098c2ecf20Sopenharmony_ci	{ 0x4F, 0x00 }, /* 4F Equalizer Band 1 Coefficient A1 */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	{ 0x50, 0x00 }, /* 50 Equalizer Band 1 Coefficient A1 */
1128c2ecf20Sopenharmony_ci	{ 0x51, 0x00 }, /* 51 Equalizer Band 1 Coefficient A1 */
1138c2ecf20Sopenharmony_ci	{ 0x52, 0x00 }, /* 52 Equalizer Band 1 Coefficient A2 */
1148c2ecf20Sopenharmony_ci	{ 0x53, 0x00 }, /* 53 Equalizer Band 1 Coefficient A2 */
1158c2ecf20Sopenharmony_ci	{ 0x54, 0x00 }, /* 54 Equalizer Band 1 Coefficient A2 */
1168c2ecf20Sopenharmony_ci	{ 0x55, 0x00 }, /* 55 Equalizer Band 2 Coefficient B0 */
1178c2ecf20Sopenharmony_ci	{ 0x56, 0x00 }, /* 56 Equalizer Band 2 Coefficient B0 */
1188c2ecf20Sopenharmony_ci	{ 0x57, 0x00 }, /* 57 Equalizer Band 2 Coefficient B0 */
1198c2ecf20Sopenharmony_ci	{ 0x58, 0x00 }, /* 58 Equalizer Band 2 Coefficient B1 */
1208c2ecf20Sopenharmony_ci	{ 0x59, 0x00 }, /* 59 Equalizer Band 2 Coefficient B1 */
1218c2ecf20Sopenharmony_ci	{ 0x5A, 0x00 }, /* 5A Equalizer Band 2 Coefficient B1 */
1228c2ecf20Sopenharmony_ci	{ 0x5B, 0x00 }, /* 5B Equalizer Band 2 Coefficient B2 */
1238c2ecf20Sopenharmony_ci	{ 0x5C, 0x00 }, /* 5C Equalizer Band 2 Coefficient B2 */
1248c2ecf20Sopenharmony_ci	{ 0x5D, 0x00 }, /* 5D Equalizer Band 2 Coefficient B2 */
1258c2ecf20Sopenharmony_ci	{ 0x5E, 0x00 }, /* 5E Equalizer Band 2 Coefficient A1 */
1268c2ecf20Sopenharmony_ci	{ 0x5F, 0x00 }, /* 5F Equalizer Band 2 Coefficient A1 */
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	{ 0x60, 0x00 }, /* 60 Equalizer Band 2 Coefficient A1 */
1298c2ecf20Sopenharmony_ci	{ 0x61, 0x00 }, /* 61 Equalizer Band 2 Coefficient A2 */
1308c2ecf20Sopenharmony_ci	{ 0x62, 0x00 }, /* 62 Equalizer Band 2 Coefficient A2 */
1318c2ecf20Sopenharmony_ci	{ 0x63, 0x00 }, /* 63 Equalizer Band 2 Coefficient A2 */
1328c2ecf20Sopenharmony_ci	{ 0x64, 0x00 }, /* 64 Equalizer Band 3 Coefficient B0 */
1338c2ecf20Sopenharmony_ci	{ 0x65, 0x00 }, /* 65 Equalizer Band 3 Coefficient B0 */
1348c2ecf20Sopenharmony_ci	{ 0x66, 0x00 }, /* 66 Equalizer Band 3 Coefficient B0 */
1358c2ecf20Sopenharmony_ci	{ 0x67, 0x00 }, /* 67 Equalizer Band 3 Coefficient B1 */
1368c2ecf20Sopenharmony_ci	{ 0x68, 0x00 }, /* 68 Equalizer Band 3 Coefficient B1 */
1378c2ecf20Sopenharmony_ci	{ 0x69, 0x00 }, /* 69 Equalizer Band 3 Coefficient B1 */
1388c2ecf20Sopenharmony_ci	{ 0x6A, 0x00 }, /* 6A Equalizer Band 3 Coefficient B2 */
1398c2ecf20Sopenharmony_ci	{ 0x6B, 0x00 }, /* 6B Equalizer Band 3 Coefficient B2 */
1408c2ecf20Sopenharmony_ci	{ 0x6C, 0x00 }, /* 6C Equalizer Band 3 Coefficient B2 */
1418c2ecf20Sopenharmony_ci	{ 0x6D, 0x00 }, /* 6D Equalizer Band 3 Coefficient A1 */
1428c2ecf20Sopenharmony_ci	{ 0x6E, 0x00 }, /* 6E Equalizer Band 3 Coefficient A1 */
1438c2ecf20Sopenharmony_ci	{ 0x6F, 0x00 }, /* 6F Equalizer Band 3 Coefficient A1 */
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	{ 0x70, 0x00 }, /* 70 Equalizer Band 3 Coefficient A2 */
1468c2ecf20Sopenharmony_ci	{ 0x71, 0x00 }, /* 71 Equalizer Band 3 Coefficient A2 */
1478c2ecf20Sopenharmony_ci	{ 0x72, 0x00 }, /* 72 Equalizer Band 3 Coefficient A2 */
1488c2ecf20Sopenharmony_ci	{ 0x73, 0x00 }, /* 73 Equalizer Band 4 Coefficient B0 */
1498c2ecf20Sopenharmony_ci	{ 0x74, 0x00 }, /* 74 Equalizer Band 4 Coefficient B0 */
1508c2ecf20Sopenharmony_ci	{ 0x75, 0x00 }, /* 75 Equalizer Band 4 Coefficient B0 */
1518c2ecf20Sopenharmony_ci	{ 0x76, 0x00 }, /* 76 Equalizer Band 4 Coefficient B1 */
1528c2ecf20Sopenharmony_ci	{ 0x77, 0x00 }, /* 77 Equalizer Band 4 Coefficient B1 */
1538c2ecf20Sopenharmony_ci	{ 0x78, 0x00 }, /* 78 Equalizer Band 4 Coefficient B1 */
1548c2ecf20Sopenharmony_ci	{ 0x79, 0x00 }, /* 79 Equalizer Band 4 Coefficient B2 */
1558c2ecf20Sopenharmony_ci	{ 0x7A, 0x00 }, /* 7A Equalizer Band 4 Coefficient B2 */
1568c2ecf20Sopenharmony_ci	{ 0x7B, 0x00 }, /* 7B Equalizer Band 4 Coefficient B2 */
1578c2ecf20Sopenharmony_ci	{ 0x7C, 0x00 }, /* 7C Equalizer Band 4 Coefficient A1 */
1588c2ecf20Sopenharmony_ci	{ 0x7D, 0x00 }, /* 7D Equalizer Band 4 Coefficient A1 */
1598c2ecf20Sopenharmony_ci	{ 0x7E, 0x00 }, /* 7E Equalizer Band 4 Coefficient A1 */
1608c2ecf20Sopenharmony_ci	{ 0x7F, 0x00 }, /* 7F Equalizer Band 4 Coefficient A2 */
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	{ 0x80, 0x00 }, /* 80 Equalizer Band 4 Coefficient A2 */
1638c2ecf20Sopenharmony_ci	{ 0x81, 0x00 }, /* 81 Equalizer Band 4 Coefficient A2 */
1648c2ecf20Sopenharmony_ci	{ 0x82, 0x00 }, /* 82 Equalizer Band 5 Coefficient B0 */
1658c2ecf20Sopenharmony_ci	{ 0x83, 0x00 }, /* 83 Equalizer Band 5 Coefficient B0 */
1668c2ecf20Sopenharmony_ci	{ 0x84, 0x00 }, /* 84 Equalizer Band 5 Coefficient B0 */
1678c2ecf20Sopenharmony_ci	{ 0x85, 0x00 }, /* 85 Equalizer Band 5 Coefficient B1 */
1688c2ecf20Sopenharmony_ci	{ 0x86, 0x00 }, /* 86 Equalizer Band 5 Coefficient B1 */
1698c2ecf20Sopenharmony_ci	{ 0x87, 0x00 }, /* 87 Equalizer Band 5 Coefficient B1 */
1708c2ecf20Sopenharmony_ci	{ 0x88, 0x00 }, /* 88 Equalizer Band 5 Coefficient B2 */
1718c2ecf20Sopenharmony_ci	{ 0x89, 0x00 }, /* 89 Equalizer Band 5 Coefficient B2 */
1728c2ecf20Sopenharmony_ci	{ 0x8A, 0x00 }, /* 8A Equalizer Band 5 Coefficient B2 */
1738c2ecf20Sopenharmony_ci	{ 0x8B, 0x00 }, /* 8B Equalizer Band 5 Coefficient A1 */
1748c2ecf20Sopenharmony_ci	{ 0x8C, 0x00 }, /* 8C Equalizer Band 5 Coefficient A1 */
1758c2ecf20Sopenharmony_ci	{ 0x8D, 0x00 }, /* 8D Equalizer Band 5 Coefficient A1 */
1768c2ecf20Sopenharmony_ci	{ 0x8E, 0x00 }, /* 8E Equalizer Band 5 Coefficient A2 */
1778c2ecf20Sopenharmony_ci	{ 0x8F, 0x00 }, /* 8F Equalizer Band 5 Coefficient A2 */
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	{ 0x90, 0x00 }, /* 90 Equalizer Band 5 Coefficient A2 */
1808c2ecf20Sopenharmony_ci	{ 0x91, 0x00 }, /* 91 Equalizer Band 6 Coefficient B0 */
1818c2ecf20Sopenharmony_ci	{ 0x92, 0x00 }, /* 92 Equalizer Band 6 Coefficient B0 */
1828c2ecf20Sopenharmony_ci	{ 0x93, 0x00 }, /* 93 Equalizer Band 6 Coefficient B0 */
1838c2ecf20Sopenharmony_ci	{ 0x94, 0x00 }, /* 94 Equalizer Band 6 Coefficient B1 */
1848c2ecf20Sopenharmony_ci	{ 0x95, 0x00 }, /* 95 Equalizer Band 6 Coefficient B1 */
1858c2ecf20Sopenharmony_ci	{ 0x96, 0x00 }, /* 96 Equalizer Band 6 Coefficient B1 */
1868c2ecf20Sopenharmony_ci	{ 0x97, 0x00 }, /* 97 Equalizer Band 6 Coefficient B2 */
1878c2ecf20Sopenharmony_ci	{ 0x98, 0x00 }, /* 98 Equalizer Band 6 Coefficient B2 */
1888c2ecf20Sopenharmony_ci	{ 0x99, 0x00 }, /* 99 Equalizer Band 6 Coefficient B2 */
1898c2ecf20Sopenharmony_ci	{ 0x9A, 0x00 }, /* 9A Equalizer Band 6 Coefficient A1 */
1908c2ecf20Sopenharmony_ci	{ 0x9B, 0x00 }, /* 9B Equalizer Band 6 Coefficient A1 */
1918c2ecf20Sopenharmony_ci	{ 0x9C, 0x00 }, /* 9C Equalizer Band 6 Coefficient A1 */
1928c2ecf20Sopenharmony_ci	{ 0x9D, 0x00 }, /* 9D Equalizer Band 6 Coefficient A2 */
1938c2ecf20Sopenharmony_ci	{ 0x9E, 0x00 }, /* 9E Equalizer Band 6 Coefficient A2 */
1948c2ecf20Sopenharmony_ci	{ 0x9F, 0x00 }, /* 9F Equalizer Band 6 Coefficient A2 */
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	{ 0xA0, 0x00 }, /* A0 Equalizer Band 7 Coefficient B0 */
1978c2ecf20Sopenharmony_ci	{ 0xA1, 0x00 }, /* A1 Equalizer Band 7 Coefficient B0 */
1988c2ecf20Sopenharmony_ci	{ 0xA2, 0x00 }, /* A2 Equalizer Band 7 Coefficient B0 */
1998c2ecf20Sopenharmony_ci	{ 0xA3, 0x00 }, /* A3 Equalizer Band 7 Coefficient B1 */
2008c2ecf20Sopenharmony_ci	{ 0xA4, 0x00 }, /* A4 Equalizer Band 7 Coefficient B1 */
2018c2ecf20Sopenharmony_ci	{ 0xA5, 0x00 }, /* A5 Equalizer Band 7 Coefficient B1 */
2028c2ecf20Sopenharmony_ci	{ 0xA6, 0x00 }, /* A6 Equalizer Band 7 Coefficient B2 */
2038c2ecf20Sopenharmony_ci	{ 0xA7, 0x00 }, /* A7 Equalizer Band 7 Coefficient B2 */
2048c2ecf20Sopenharmony_ci	{ 0xA8, 0x00 }, /* A8 Equalizer Band 7 Coefficient B2 */
2058c2ecf20Sopenharmony_ci	{ 0xA9, 0x00 }, /* A9 Equalizer Band 7 Coefficient A1 */
2068c2ecf20Sopenharmony_ci	{ 0xAA, 0x00 }, /* AA Equalizer Band 7 Coefficient A1 */
2078c2ecf20Sopenharmony_ci	{ 0xAB, 0x00 }, /* AB Equalizer Band 7 Coefficient A1 */
2088c2ecf20Sopenharmony_ci	{ 0xAC, 0x00 }, /* AC Equalizer Band 7 Coefficient A2 */
2098c2ecf20Sopenharmony_ci	{ 0xAD, 0x00 }, /* AD Equalizer Band 7 Coefficient A2 */
2108c2ecf20Sopenharmony_ci	{ 0xAE, 0x00 }, /* AE Equalizer Band 7 Coefficient A2 */
2118c2ecf20Sopenharmony_ci	{ 0xAF, 0x00 }, /* AF ADC Biquad Coefficient B0 */
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci	{ 0xB0, 0x00 }, /* B0 ADC Biquad Coefficient B0 */
2148c2ecf20Sopenharmony_ci	{ 0xB1, 0x00 }, /* B1 ADC Biquad Coefficient B0 */
2158c2ecf20Sopenharmony_ci	{ 0xB2, 0x00 }, /* B2 ADC Biquad Coefficient B1 */
2168c2ecf20Sopenharmony_ci	{ 0xB3, 0x00 }, /* B3 ADC Biquad Coefficient B1 */
2178c2ecf20Sopenharmony_ci	{ 0xB4, 0x00 }, /* B4 ADC Biquad Coefficient B1 */
2188c2ecf20Sopenharmony_ci	{ 0xB5, 0x00 }, /* B5 ADC Biquad Coefficient B2 */
2198c2ecf20Sopenharmony_ci	{ 0xB6, 0x00 }, /* B6 ADC Biquad Coefficient B2 */
2208c2ecf20Sopenharmony_ci	{ 0xB7, 0x00 }, /* B7 ADC Biquad Coefficient B2 */
2218c2ecf20Sopenharmony_ci	{ 0xB8, 0x00 }, /* B8 ADC Biquad Coefficient A1 */
2228c2ecf20Sopenharmony_ci	{ 0xB9, 0x00 }, /* B9 ADC Biquad Coefficient A1 */
2238c2ecf20Sopenharmony_ci	{ 0xBA, 0x00 }, /* BA ADC Biquad Coefficient A1 */
2248c2ecf20Sopenharmony_ci	{ 0xBB, 0x00 }, /* BB ADC Biquad Coefficient A2 */
2258c2ecf20Sopenharmony_ci	{ 0xBC, 0x00 }, /* BC ADC Biquad Coefficient A2 */
2268c2ecf20Sopenharmony_ci	{ 0xBD, 0x00 }, /* BD ADC Biquad Coefficient A2 */
2278c2ecf20Sopenharmony_ci	{ 0xBE, 0x00 }, /* BE Digital Mic 3 Volume */
2288c2ecf20Sopenharmony_ci	{ 0xBF, 0x00 }, /* BF Digital Mic 4 Volume */
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	{ 0xC0, 0x00 }, /* C0 Digital Mic 34 Biquad Pre Atten */
2318c2ecf20Sopenharmony_ci	{ 0xC1, 0x00 }, /* C1 Record TDM Slot */
2328c2ecf20Sopenharmony_ci	{ 0xC2, 0x00 }, /* C2 Sample Rate */
2338c2ecf20Sopenharmony_ci	{ 0xC3, 0x00 }, /* C3 Digital Mic 34 Biquad Coefficient C3 */
2348c2ecf20Sopenharmony_ci	{ 0xC4, 0x00 }, /* C4 Digital Mic 34 Biquad Coefficient C4 */
2358c2ecf20Sopenharmony_ci	{ 0xC5, 0x00 }, /* C5 Digital Mic 34 Biquad Coefficient C5 */
2368c2ecf20Sopenharmony_ci	{ 0xC6, 0x00 }, /* C6 Digital Mic 34 Biquad Coefficient C6 */
2378c2ecf20Sopenharmony_ci	{ 0xC7, 0x00 }, /* C7 Digital Mic 34 Biquad Coefficient C7 */
2388c2ecf20Sopenharmony_ci	{ 0xC8, 0x00 }, /* C8 Digital Mic 34 Biquad Coefficient C8 */
2398c2ecf20Sopenharmony_ci	{ 0xC9, 0x00 }, /* C9 Digital Mic 34 Biquad Coefficient C9 */
2408c2ecf20Sopenharmony_ci	{ 0xCA, 0x00 }, /* CA Digital Mic 34 Biquad Coefficient CA */
2418c2ecf20Sopenharmony_ci	{ 0xCB, 0x00 }, /* CB Digital Mic 34 Biquad Coefficient CB */
2428c2ecf20Sopenharmony_ci	{ 0xCC, 0x00 }, /* CC Digital Mic 34 Biquad Coefficient CC */
2438c2ecf20Sopenharmony_ci	{ 0xCD, 0x00 }, /* CD Digital Mic 34 Biquad Coefficient CD */
2448c2ecf20Sopenharmony_ci	{ 0xCE, 0x00 }, /* CE Digital Mic 34 Biquad Coefficient CE */
2458c2ecf20Sopenharmony_ci	{ 0xCF, 0x00 }, /* CF Digital Mic 34 Biquad Coefficient CF */
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	{ 0xD0, 0x00 }, /* D0 Digital Mic 34 Biquad Coefficient D0 */
2488c2ecf20Sopenharmony_ci	{ 0xD1, 0x00 }, /* D1 Digital Mic 34 Biquad Coefficient D1 */
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic bool max98090_volatile_register(struct device *dev, unsigned int reg)
2528c2ecf20Sopenharmony_ci{
2538c2ecf20Sopenharmony_ci	switch (reg) {
2548c2ecf20Sopenharmony_ci	case M98090_REG_SOFTWARE_RESET:
2558c2ecf20Sopenharmony_ci	case M98090_REG_DEVICE_STATUS:
2568c2ecf20Sopenharmony_ci	case M98090_REG_JACK_STATUS:
2578c2ecf20Sopenharmony_ci	case M98090_REG_REVISION_ID:
2588c2ecf20Sopenharmony_ci		return true;
2598c2ecf20Sopenharmony_ci	default:
2608c2ecf20Sopenharmony_ci		return false;
2618c2ecf20Sopenharmony_ci	}
2628c2ecf20Sopenharmony_ci}
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_cistatic bool max98090_readable_register(struct device *dev, unsigned int reg)
2658c2ecf20Sopenharmony_ci{
2668c2ecf20Sopenharmony_ci	switch (reg) {
2678c2ecf20Sopenharmony_ci	case M98090_REG_DEVICE_STATUS ... M98090_REG_INTERRUPT_S:
2688c2ecf20Sopenharmony_ci	case M98090_REG_LINE_INPUT_CONFIG ... 0xD1:
2698c2ecf20Sopenharmony_ci	case M98090_REG_REVISION_ID:
2708c2ecf20Sopenharmony_ci		return true;
2718c2ecf20Sopenharmony_ci	default:
2728c2ecf20Sopenharmony_ci		return false;
2738c2ecf20Sopenharmony_ci	}
2748c2ecf20Sopenharmony_ci}
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_cistatic int max98090_reset(struct max98090_priv *max98090)
2778c2ecf20Sopenharmony_ci{
2788c2ecf20Sopenharmony_ci	int ret;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	/* Reset the codec by writing to this write-only reset register */
2818c2ecf20Sopenharmony_ci	ret = regmap_write(max98090->regmap, M98090_REG_SOFTWARE_RESET,
2828c2ecf20Sopenharmony_ci		M98090_SWRESET_MASK);
2838c2ecf20Sopenharmony_ci	if (ret < 0) {
2848c2ecf20Sopenharmony_ci		dev_err(max98090->component->dev,
2858c2ecf20Sopenharmony_ci			"Failed to reset codec: %d\n", ret);
2868c2ecf20Sopenharmony_ci		return ret;
2878c2ecf20Sopenharmony_ci	}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	msleep(20);
2908c2ecf20Sopenharmony_ci	return ret;
2918c2ecf20Sopenharmony_ci}
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_micboost_tlv,
2948c2ecf20Sopenharmony_ci	0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
2958c2ecf20Sopenharmony_ci	2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0)
2968c2ecf20Sopenharmony_ci);
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_mic_tlv, 0, 100, 0);
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_line_single_ended_tlv,
3018c2ecf20Sopenharmony_ci	-600, 600, 0);
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_line_tlv,
3048c2ecf20Sopenharmony_ci	0, 3, TLV_DB_SCALE_ITEM(-600, 300, 0),
3058c2ecf20Sopenharmony_ci	4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0)
3068c2ecf20Sopenharmony_ci);
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_avg_tlv, 0, 600, 0);
3098c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_av_tlv, -1200, 100, 0);
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_dvg_tlv, 0, 600, 0);
3128c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_dv_tlv, -1500, 100, 0);
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_alcmakeup_tlv, 0, 100, 0);
3158c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_alccomp_tlv, -3100, 100, 0);
3168c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_drcexp_tlv, -6600, 100, 0);
3178c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(max98090_sdg_tlv, 50, 200, 0);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_mixout_tlv,
3208c2ecf20Sopenharmony_ci	0, 1, TLV_DB_SCALE_ITEM(-1200, 250, 0),
3218c2ecf20Sopenharmony_ci	2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0)
3228c2ecf20Sopenharmony_ci);
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_hp_tlv,
3258c2ecf20Sopenharmony_ci	0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
3268c2ecf20Sopenharmony_ci	7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
3278c2ecf20Sopenharmony_ci	15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
3288c2ecf20Sopenharmony_ci	22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
3298c2ecf20Sopenharmony_ci	28, 31, TLV_DB_SCALE_ITEM(150, 50, 0)
3308c2ecf20Sopenharmony_ci);
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_spk_tlv,
3338c2ecf20Sopenharmony_ci	0, 4, TLV_DB_SCALE_ITEM(-4800, 400, 0),
3348c2ecf20Sopenharmony_ci	5, 10, TLV_DB_SCALE_ITEM(-2900, 300, 0),
3358c2ecf20Sopenharmony_ci	11, 14, TLV_DB_SCALE_ITEM(-1200, 200, 0),
3368c2ecf20Sopenharmony_ci	15, 29, TLV_DB_SCALE_ITEM(-500, 100, 0),
3378c2ecf20Sopenharmony_ci	30, 39, TLV_DB_SCALE_ITEM(950, 50, 0)
3388c2ecf20Sopenharmony_ci);
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(max98090_rcv_lout_tlv,
3418c2ecf20Sopenharmony_ci	0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
3428c2ecf20Sopenharmony_ci	7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
3438c2ecf20Sopenharmony_ci	15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
3448c2ecf20Sopenharmony_ci	22, 27, TLV_DB_SCALE_ITEM(100, 100, 0),
3458c2ecf20Sopenharmony_ci	28, 31, TLV_DB_SCALE_ITEM(650, 50, 0)
3468c2ecf20Sopenharmony_ci);
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistatic int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol,
3498c2ecf20Sopenharmony_ci				struct snd_ctl_elem_value *ucontrol)
3508c2ecf20Sopenharmony_ci{
3518c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
3528c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
3538c2ecf20Sopenharmony_ci	struct soc_mixer_control *mc =
3548c2ecf20Sopenharmony_ci		(struct soc_mixer_control *)kcontrol->private_value;
3558c2ecf20Sopenharmony_ci	unsigned int mask = (1 << fls(mc->max)) - 1;
3568c2ecf20Sopenharmony_ci	unsigned int val = snd_soc_component_read(component, mc->reg);
3578c2ecf20Sopenharmony_ci	unsigned int *select;
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci	switch (mc->reg) {
3608c2ecf20Sopenharmony_ci	case M98090_REG_MIC1_INPUT_LEVEL:
3618c2ecf20Sopenharmony_ci		select = &(max98090->pa1en);
3628c2ecf20Sopenharmony_ci		break;
3638c2ecf20Sopenharmony_ci	case M98090_REG_MIC2_INPUT_LEVEL:
3648c2ecf20Sopenharmony_ci		select = &(max98090->pa2en);
3658c2ecf20Sopenharmony_ci		break;
3668c2ecf20Sopenharmony_ci	case M98090_REG_ADC_SIDETONE:
3678c2ecf20Sopenharmony_ci		select = &(max98090->sidetone);
3688c2ecf20Sopenharmony_ci		break;
3698c2ecf20Sopenharmony_ci	default:
3708c2ecf20Sopenharmony_ci		return -EINVAL;
3718c2ecf20Sopenharmony_ci	}
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	val = (val >> mc->shift) & mask;
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci	if (val >= 1) {
3768c2ecf20Sopenharmony_ci		/* If on, return the volume */
3778c2ecf20Sopenharmony_ci		val = val - 1;
3788c2ecf20Sopenharmony_ci		*select = val;
3798c2ecf20Sopenharmony_ci	} else {
3808c2ecf20Sopenharmony_ci		/* If off, return last stored value */
3818c2ecf20Sopenharmony_ci		val = *select;
3828c2ecf20Sopenharmony_ci	}
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = val;
3858c2ecf20Sopenharmony_ci	return 0;
3868c2ecf20Sopenharmony_ci}
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistatic int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
3898c2ecf20Sopenharmony_ci				struct snd_ctl_elem_value *ucontrol)
3908c2ecf20Sopenharmony_ci{
3918c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
3928c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
3938c2ecf20Sopenharmony_ci	struct soc_mixer_control *mc =
3948c2ecf20Sopenharmony_ci		(struct soc_mixer_control *)kcontrol->private_value;
3958c2ecf20Sopenharmony_ci	unsigned int mask = (1 << fls(mc->max)) - 1;
3968c2ecf20Sopenharmony_ci	int sel_unchecked = ucontrol->value.integer.value[0];
3978c2ecf20Sopenharmony_ci	unsigned int sel;
3988c2ecf20Sopenharmony_ci	unsigned int val = snd_soc_component_read(component, mc->reg);
3998c2ecf20Sopenharmony_ci	unsigned int *select;
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci	switch (mc->reg) {
4028c2ecf20Sopenharmony_ci	case M98090_REG_MIC1_INPUT_LEVEL:
4038c2ecf20Sopenharmony_ci		select = &(max98090->pa1en);
4048c2ecf20Sopenharmony_ci		break;
4058c2ecf20Sopenharmony_ci	case M98090_REG_MIC2_INPUT_LEVEL:
4068c2ecf20Sopenharmony_ci		select = &(max98090->pa2en);
4078c2ecf20Sopenharmony_ci		break;
4088c2ecf20Sopenharmony_ci	case M98090_REG_ADC_SIDETONE:
4098c2ecf20Sopenharmony_ci		select = &(max98090->sidetone);
4108c2ecf20Sopenharmony_ci		break;
4118c2ecf20Sopenharmony_ci	default:
4128c2ecf20Sopenharmony_ci		return -EINVAL;
4138c2ecf20Sopenharmony_ci	}
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	val = (val >> mc->shift) & mask;
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci	if (sel_unchecked < 0 || sel_unchecked > mc->max)
4188c2ecf20Sopenharmony_ci		return -EINVAL;
4198c2ecf20Sopenharmony_ci	sel = sel_unchecked;
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci	*select = sel;
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci	/* Setting a volume is only valid if it is already On */
4248c2ecf20Sopenharmony_ci	if (val >= 1) {
4258c2ecf20Sopenharmony_ci		sel = sel + 1;
4268c2ecf20Sopenharmony_ci	} else {
4278c2ecf20Sopenharmony_ci		/* Write what was already there */
4288c2ecf20Sopenharmony_ci		sel = val;
4298c2ecf20Sopenharmony_ci	}
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, mc->reg,
4328c2ecf20Sopenharmony_ci		mask << mc->shift,
4338c2ecf20Sopenharmony_ci		sel << mc->shift);
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	return *select != val;
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic const char *max98090_perf_pwr_text[] =
4398c2ecf20Sopenharmony_ci	{ "High Performance", "Low Power" };
4408c2ecf20Sopenharmony_cistatic const char *max98090_pwr_perf_text[] =
4418c2ecf20Sopenharmony_ci	{ "Low Power", "High Performance" };
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_vcmbandgap_enum,
4448c2ecf20Sopenharmony_ci			    M98090_REG_BIAS_CONTROL,
4458c2ecf20Sopenharmony_ci			    M98090_VCM_MODE_SHIFT,
4468c2ecf20Sopenharmony_ci			    max98090_pwr_perf_text);
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_cistatic const char *max98090_osr128_text[] = { "64*fs", "128*fs" };
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_osr128_enum,
4518c2ecf20Sopenharmony_ci			    M98090_REG_ADC_CONTROL,
4528c2ecf20Sopenharmony_ci			    M98090_OSR128_SHIFT,
4538c2ecf20Sopenharmony_ci			    max98090_osr128_text);
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_cistatic const char *max98090_mode_text[] = { "Voice", "Music" };
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_mode_enum,
4588c2ecf20Sopenharmony_ci			    M98090_REG_FILTER_CONFIG,
4598c2ecf20Sopenharmony_ci			    M98090_MODE_SHIFT,
4608c2ecf20Sopenharmony_ci			    max98090_mode_text);
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_filter_dmic34mode_enum,
4638c2ecf20Sopenharmony_ci			    M98090_REG_FILTER_CONFIG,
4648c2ecf20Sopenharmony_ci			    M98090_FLT_DMIC34MODE_SHIFT,
4658c2ecf20Sopenharmony_ci			    max98090_mode_text);
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_cistatic const char *max98090_drcatk_text[] =
4688c2ecf20Sopenharmony_ci	{ "0.5ms", "1ms", "5ms", "10ms", "25ms", "50ms", "100ms", "200ms" };
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_drcatk_enum,
4718c2ecf20Sopenharmony_ci			    M98090_REG_DRC_TIMING,
4728c2ecf20Sopenharmony_ci			    M98090_DRCATK_SHIFT,
4738c2ecf20Sopenharmony_ci			    max98090_drcatk_text);
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_cistatic const char *max98090_drcrls_text[] =
4768c2ecf20Sopenharmony_ci	{ "8s", "4s", "2s", "1s", "0.5s", "0.25s", "0.125s", "0.0625s" };
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_drcrls_enum,
4798c2ecf20Sopenharmony_ci			    M98090_REG_DRC_TIMING,
4808c2ecf20Sopenharmony_ci			    M98090_DRCRLS_SHIFT,
4818c2ecf20Sopenharmony_ci			    max98090_drcrls_text);
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_cistatic const char *max98090_alccmp_text[] =
4848c2ecf20Sopenharmony_ci	{ "1:1", "1:1.5", "1:2", "1:4", "1:INF" };
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_alccmp_enum,
4878c2ecf20Sopenharmony_ci			    M98090_REG_DRC_COMPRESSOR,
4888c2ecf20Sopenharmony_ci			    M98090_DRCCMP_SHIFT,
4898c2ecf20Sopenharmony_ci			    max98090_alccmp_text);
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_cistatic const char *max98090_drcexp_text[] = { "1:1", "2:1", "3:1" };
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_drcexp_enum,
4948c2ecf20Sopenharmony_ci			    M98090_REG_DRC_EXPANDER,
4958c2ecf20Sopenharmony_ci			    M98090_DRCEXP_SHIFT,
4968c2ecf20Sopenharmony_ci			    max98090_drcexp_text);
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_dac_perfmode_enum,
4998c2ecf20Sopenharmony_ci			    M98090_REG_DAC_CONTROL,
5008c2ecf20Sopenharmony_ci			    M98090_PERFMODE_SHIFT,
5018c2ecf20Sopenharmony_ci			    max98090_perf_pwr_text);
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_dachp_enum,
5048c2ecf20Sopenharmony_ci			    M98090_REG_DAC_CONTROL,
5058c2ecf20Sopenharmony_ci			    M98090_DACHP_SHIFT,
5068c2ecf20Sopenharmony_ci			    max98090_pwr_perf_text);
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(max98090_adchp_enum,
5098c2ecf20Sopenharmony_ci			    M98090_REG_ADC_CONTROL,
5108c2ecf20Sopenharmony_ci			    M98090_ADCHP_SHIFT,
5118c2ecf20Sopenharmony_ci			    max98090_pwr_perf_text);
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_snd_controls[] = {
5148c2ecf20Sopenharmony_ci	SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum),
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	SOC_SINGLE("DMIC MIC Comp Filter Config", M98090_REG_DIGITAL_MIC_CONFIG,
5178c2ecf20Sopenharmony_ci		M98090_DMIC_COMP_SHIFT, M98090_DMIC_COMP_NUM - 1, 0),
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	SOC_SINGLE_EXT_TLV("MIC1 Boost Volume",
5208c2ecf20Sopenharmony_ci		M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT,
5218c2ecf20Sopenharmony_ci		M98090_MIC_PA1EN_NUM - 1, 0, max98090_get_enab_tlv,
5228c2ecf20Sopenharmony_ci		max98090_put_enab_tlv, max98090_micboost_tlv),
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_ci	SOC_SINGLE_EXT_TLV("MIC2 Boost Volume",
5258c2ecf20Sopenharmony_ci		M98090_REG_MIC2_INPUT_LEVEL, M98090_MIC_PA2EN_SHIFT,
5268c2ecf20Sopenharmony_ci		M98090_MIC_PA2EN_NUM - 1, 0, max98090_get_enab_tlv,
5278c2ecf20Sopenharmony_ci		max98090_put_enab_tlv, max98090_micboost_tlv),
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("MIC1 Volume", M98090_REG_MIC1_INPUT_LEVEL,
5308c2ecf20Sopenharmony_ci		M98090_MIC_PGAM1_SHIFT, M98090_MIC_PGAM1_NUM - 1, 1,
5318c2ecf20Sopenharmony_ci		max98090_mic_tlv),
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("MIC2 Volume", M98090_REG_MIC2_INPUT_LEVEL,
5348c2ecf20Sopenharmony_ci		M98090_MIC_PGAM2_SHIFT, M98090_MIC_PGAM2_NUM - 1, 1,
5358c2ecf20Sopenharmony_ci		max98090_mic_tlv),
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ci	SOC_SINGLE_RANGE_TLV("LINEA Single Ended Volume",
5388c2ecf20Sopenharmony_ci		M98090_REG_LINE_INPUT_LEVEL, M98090_MIXG135_SHIFT, 0,
5398c2ecf20Sopenharmony_ci		M98090_MIXG135_NUM - 1, 1, max98090_line_single_ended_tlv),
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci	SOC_SINGLE_RANGE_TLV("LINEB Single Ended Volume",
5428c2ecf20Sopenharmony_ci		M98090_REG_LINE_INPUT_LEVEL, M98090_MIXG246_SHIFT, 0,
5438c2ecf20Sopenharmony_ci		M98090_MIXG246_NUM - 1, 1, max98090_line_single_ended_tlv),
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	SOC_SINGLE_RANGE_TLV("LINEA Volume", M98090_REG_LINE_INPUT_LEVEL,
5468c2ecf20Sopenharmony_ci		M98090_LINAPGA_SHIFT, 0, M98090_LINAPGA_NUM - 1, 1,
5478c2ecf20Sopenharmony_ci		max98090_line_tlv),
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci	SOC_SINGLE_RANGE_TLV("LINEB Volume", M98090_REG_LINE_INPUT_LEVEL,
5508c2ecf20Sopenharmony_ci		M98090_LINBPGA_SHIFT, 0, M98090_LINBPGA_NUM - 1, 1,
5518c2ecf20Sopenharmony_ci		max98090_line_tlv),
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci	SOC_SINGLE("LINEA Ext Resistor Gain Mode", M98090_REG_INPUT_MODE,
5548c2ecf20Sopenharmony_ci		M98090_EXTBUFA_SHIFT, M98090_EXTBUFA_NUM - 1, 0),
5558c2ecf20Sopenharmony_ci	SOC_SINGLE("LINEB Ext Resistor Gain Mode", M98090_REG_INPUT_MODE,
5568c2ecf20Sopenharmony_ci		M98090_EXTBUFB_SHIFT, M98090_EXTBUFB_NUM - 1, 0),
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ADCL Boost Volume", M98090_REG_LEFT_ADC_LEVEL,
5598c2ecf20Sopenharmony_ci		M98090_AVLG_SHIFT, M98090_AVLG_NUM - 1, 0,
5608c2ecf20Sopenharmony_ci		max98090_avg_tlv),
5618c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ADCR Boost Volume", M98090_REG_RIGHT_ADC_LEVEL,
5628c2ecf20Sopenharmony_ci		M98090_AVRG_SHIFT, M98090_AVLG_NUM - 1, 0,
5638c2ecf20Sopenharmony_ci		max98090_avg_tlv),
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ADCL Volume", M98090_REG_LEFT_ADC_LEVEL,
5668c2ecf20Sopenharmony_ci		M98090_AVL_SHIFT, M98090_AVL_NUM - 1, 1,
5678c2ecf20Sopenharmony_ci		max98090_av_tlv),
5688c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ADCR Volume", M98090_REG_RIGHT_ADC_LEVEL,
5698c2ecf20Sopenharmony_ci		M98090_AVR_SHIFT, M98090_AVR_NUM - 1, 1,
5708c2ecf20Sopenharmony_ci		max98090_av_tlv),
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci	SOC_ENUM("ADC Oversampling Rate", max98090_osr128_enum),
5738c2ecf20Sopenharmony_ci	SOC_SINGLE("ADC Quantizer Dither", M98090_REG_ADC_CONTROL,
5748c2ecf20Sopenharmony_ci		M98090_ADCDITHER_SHIFT, M98090_ADCDITHER_NUM - 1, 0),
5758c2ecf20Sopenharmony_ci	SOC_ENUM("ADC High Performance Mode", max98090_adchp_enum),
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci	SOC_SINGLE("DAC Mono Mode", M98090_REG_IO_CONFIGURATION,
5788c2ecf20Sopenharmony_ci		M98090_DMONO_SHIFT, M98090_DMONO_NUM - 1, 0),
5798c2ecf20Sopenharmony_ci	SOC_SINGLE("SDIN Mode", M98090_REG_IO_CONFIGURATION,
5808c2ecf20Sopenharmony_ci		M98090_SDIEN_SHIFT, M98090_SDIEN_NUM - 1, 0),
5818c2ecf20Sopenharmony_ci	SOC_SINGLE("SDOUT Mode", M98090_REG_IO_CONFIGURATION,
5828c2ecf20Sopenharmony_ci		M98090_SDOEN_SHIFT, M98090_SDOEN_NUM - 1, 0),
5838c2ecf20Sopenharmony_ci	SOC_SINGLE("SDOUT Hi-Z Mode", M98090_REG_IO_CONFIGURATION,
5848c2ecf20Sopenharmony_ci		M98090_HIZOFF_SHIFT, M98090_HIZOFF_NUM - 1, 1),
5858c2ecf20Sopenharmony_ci	SOC_ENUM("Filter Mode", max98090_mode_enum),
5868c2ecf20Sopenharmony_ci	SOC_SINGLE("Record Path DC Blocking", M98090_REG_FILTER_CONFIG,
5878c2ecf20Sopenharmony_ci		M98090_AHPF_SHIFT, M98090_AHPF_NUM - 1, 0),
5888c2ecf20Sopenharmony_ci	SOC_SINGLE("Playback Path DC Blocking", M98090_REG_FILTER_CONFIG,
5898c2ecf20Sopenharmony_ci		M98090_DHPF_SHIFT, M98090_DHPF_NUM - 1, 0),
5908c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Digital BQ Volume", M98090_REG_ADC_BIQUAD_LEVEL,
5918c2ecf20Sopenharmony_ci		M98090_AVBQ_SHIFT, M98090_AVBQ_NUM - 1, 1, max98090_dv_tlv),
5928c2ecf20Sopenharmony_ci	SOC_SINGLE_EXT_TLV("Digital Sidetone Volume",
5938c2ecf20Sopenharmony_ci		M98090_REG_ADC_SIDETONE, M98090_DVST_SHIFT,
5948c2ecf20Sopenharmony_ci		M98090_DVST_NUM - 1, 1, max98090_get_enab_tlv,
5958c2ecf20Sopenharmony_ci		max98090_put_enab_tlv, max98090_sdg_tlv),
5968c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Digital Coarse Volume", M98090_REG_DAI_PLAYBACK_LEVEL,
5978c2ecf20Sopenharmony_ci		M98090_DVG_SHIFT, M98090_DVG_NUM - 1, 0,
5988c2ecf20Sopenharmony_ci		max98090_dvg_tlv),
5998c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Digital Volume", M98090_REG_DAI_PLAYBACK_LEVEL,
6008c2ecf20Sopenharmony_ci		M98090_DV_SHIFT, M98090_DV_NUM - 1, 1,
6018c2ecf20Sopenharmony_ci		max98090_dv_tlv),
6028c2ecf20Sopenharmony_ci	SND_SOC_BYTES("EQ Coefficients", M98090_REG_EQUALIZER_BASE, 105),
6038c2ecf20Sopenharmony_ci	SOC_SINGLE("Digital EQ 3 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
6048c2ecf20Sopenharmony_ci		M98090_EQ3BANDEN_SHIFT, M98090_EQ3BANDEN_NUM - 1, 0),
6058c2ecf20Sopenharmony_ci	SOC_SINGLE("Digital EQ 5 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
6068c2ecf20Sopenharmony_ci		M98090_EQ5BANDEN_SHIFT, M98090_EQ5BANDEN_NUM - 1, 0),
6078c2ecf20Sopenharmony_ci	SOC_SINGLE("Digital EQ 7 Band Switch", M98090_REG_DSP_FILTER_ENABLE,
6088c2ecf20Sopenharmony_ci		M98090_EQ7BANDEN_SHIFT, M98090_EQ7BANDEN_NUM - 1, 0),
6098c2ecf20Sopenharmony_ci	SOC_SINGLE("Digital EQ Clipping Detection", M98090_REG_DAI_PLAYBACK_LEVEL_EQ,
6108c2ecf20Sopenharmony_ci		M98090_EQCLPN_SHIFT, M98090_EQCLPN_NUM - 1,
6118c2ecf20Sopenharmony_ci		1),
6128c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Digital EQ Volume", M98090_REG_DAI_PLAYBACK_LEVEL_EQ,
6138c2ecf20Sopenharmony_ci		M98090_DVEQ_SHIFT, M98090_DVEQ_NUM - 1, 1,
6148c2ecf20Sopenharmony_ci		max98090_dv_tlv),
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci	SOC_SINGLE("ALC Enable", M98090_REG_DRC_TIMING,
6178c2ecf20Sopenharmony_ci		M98090_DRCEN_SHIFT, M98090_DRCEN_NUM - 1, 0),
6188c2ecf20Sopenharmony_ci	SOC_ENUM("ALC Attack Time", max98090_drcatk_enum),
6198c2ecf20Sopenharmony_ci	SOC_ENUM("ALC Release Time", max98090_drcrls_enum),
6208c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ALC Make Up Volume", M98090_REG_DRC_GAIN,
6218c2ecf20Sopenharmony_ci		M98090_DRCG_SHIFT, M98090_DRCG_NUM - 1, 0,
6228c2ecf20Sopenharmony_ci		max98090_alcmakeup_tlv),
6238c2ecf20Sopenharmony_ci	SOC_ENUM("ALC Compression Ratio", max98090_alccmp_enum),
6248c2ecf20Sopenharmony_ci	SOC_ENUM("ALC Expansion Ratio", max98090_drcexp_enum),
6258c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ALC Compression Threshold Volume",
6268c2ecf20Sopenharmony_ci		M98090_REG_DRC_COMPRESSOR, M98090_DRCTHC_SHIFT,
6278c2ecf20Sopenharmony_ci		M98090_DRCTHC_NUM - 1, 1, max98090_alccomp_tlv),
6288c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("ALC Expansion Threshold Volume",
6298c2ecf20Sopenharmony_ci		M98090_REG_DRC_EXPANDER, M98090_DRCTHE_SHIFT,
6308c2ecf20Sopenharmony_ci		M98090_DRCTHE_NUM - 1, 1, max98090_drcexp_tlv),
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	SOC_ENUM("DAC HP Playback Performance Mode",
6338c2ecf20Sopenharmony_ci		max98090_dac_perfmode_enum),
6348c2ecf20Sopenharmony_ci	SOC_ENUM("DAC High Performance Mode", max98090_dachp_enum),
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Headphone Left Mixer Volume",
6378c2ecf20Sopenharmony_ci		M98090_REG_HP_CONTROL, M98090_MIXHPLG_SHIFT,
6388c2ecf20Sopenharmony_ci		M98090_MIXHPLG_NUM - 1, 1, max98090_mixout_tlv),
6398c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Headphone Right Mixer Volume",
6408c2ecf20Sopenharmony_ci		M98090_REG_HP_CONTROL, M98090_MIXHPRG_SHIFT,
6418c2ecf20Sopenharmony_ci		M98090_MIXHPRG_NUM - 1, 1, max98090_mixout_tlv),
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Speaker Left Mixer Volume",
6448c2ecf20Sopenharmony_ci		M98090_REG_SPK_CONTROL, M98090_MIXSPLG_SHIFT,
6458c2ecf20Sopenharmony_ci		M98090_MIXSPLG_NUM - 1, 1, max98090_mixout_tlv),
6468c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Speaker Right Mixer Volume",
6478c2ecf20Sopenharmony_ci		M98090_REG_SPK_CONTROL, M98090_MIXSPRG_SHIFT,
6488c2ecf20Sopenharmony_ci		M98090_MIXSPRG_NUM - 1, 1, max98090_mixout_tlv),
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Receiver Left Mixer Volume",
6518c2ecf20Sopenharmony_ci		M98090_REG_RCV_LOUTL_CONTROL, M98090_MIXRCVLG_SHIFT,
6528c2ecf20Sopenharmony_ci		M98090_MIXRCVLG_NUM - 1, 1, max98090_mixout_tlv),
6538c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("Receiver Right Mixer Volume",
6548c2ecf20Sopenharmony_ci		M98090_REG_LOUTR_CONTROL, M98090_MIXRCVRG_SHIFT,
6558c2ecf20Sopenharmony_ci		M98090_MIXRCVRG_NUM - 1, 1, max98090_mixout_tlv),
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_ci	SOC_DOUBLE_R_TLV("Headphone Volume", M98090_REG_LEFT_HP_VOLUME,
6588c2ecf20Sopenharmony_ci		M98090_REG_RIGHT_HP_VOLUME, M98090_HPVOLL_SHIFT,
6598c2ecf20Sopenharmony_ci		M98090_HPVOLL_NUM - 1, 0, max98090_hp_tlv),
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci	SOC_DOUBLE_R_RANGE_TLV("Speaker Volume",
6628c2ecf20Sopenharmony_ci		M98090_REG_LEFT_SPK_VOLUME, M98090_REG_RIGHT_SPK_VOLUME,
6638c2ecf20Sopenharmony_ci		M98090_SPVOLL_SHIFT, 24, M98090_SPVOLL_NUM - 1 + 24,
6648c2ecf20Sopenharmony_ci		0, max98090_spk_tlv),
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_ci	SOC_DOUBLE_R_TLV("Receiver Volume", M98090_REG_RCV_LOUTL_VOLUME,
6678c2ecf20Sopenharmony_ci		M98090_REG_LOUTR_VOLUME, M98090_RCVLVOL_SHIFT,
6688c2ecf20Sopenharmony_ci		M98090_RCVLVOL_NUM - 1, 0, max98090_rcv_lout_tlv),
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	SOC_SINGLE("Headphone Left Switch", M98090_REG_LEFT_HP_VOLUME,
6718c2ecf20Sopenharmony_ci		M98090_HPLM_SHIFT, 1, 1),
6728c2ecf20Sopenharmony_ci	SOC_SINGLE("Headphone Right Switch", M98090_REG_RIGHT_HP_VOLUME,
6738c2ecf20Sopenharmony_ci		M98090_HPRM_SHIFT, 1, 1),
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci	SOC_SINGLE("Speaker Left Switch", M98090_REG_LEFT_SPK_VOLUME,
6768c2ecf20Sopenharmony_ci		M98090_SPLM_SHIFT, 1, 1),
6778c2ecf20Sopenharmony_ci	SOC_SINGLE("Speaker Right Switch", M98090_REG_RIGHT_SPK_VOLUME,
6788c2ecf20Sopenharmony_ci		M98090_SPRM_SHIFT, 1, 1),
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci	SOC_SINGLE("Receiver Left Switch", M98090_REG_RCV_LOUTL_VOLUME,
6818c2ecf20Sopenharmony_ci		M98090_RCVLM_SHIFT, 1, 1),
6828c2ecf20Sopenharmony_ci	SOC_SINGLE("Receiver Right Switch", M98090_REG_LOUTR_VOLUME,
6838c2ecf20Sopenharmony_ci		M98090_RCVRM_SHIFT, 1, 1),
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci	SOC_SINGLE("Zero-Crossing Detection", M98090_REG_LEVEL_CONTROL,
6868c2ecf20Sopenharmony_ci		M98090_ZDENN_SHIFT, M98090_ZDENN_NUM - 1, 1),
6878c2ecf20Sopenharmony_ci	SOC_SINGLE("Enhanced Vol Smoothing", M98090_REG_LEVEL_CONTROL,
6888c2ecf20Sopenharmony_ci		M98090_VS2ENN_SHIFT, M98090_VS2ENN_NUM - 1, 1),
6898c2ecf20Sopenharmony_ci	SOC_SINGLE("Volume Adjustment Smoothing", M98090_REG_LEVEL_CONTROL,
6908c2ecf20Sopenharmony_ci		M98090_VSENN_SHIFT, M98090_VSENN_NUM - 1, 1),
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci	SND_SOC_BYTES("Biquad Coefficients", M98090_REG_RECORD_BIQUAD_BASE, 15),
6938c2ecf20Sopenharmony_ci	SOC_SINGLE("Biquad Switch", M98090_REG_DSP_FILTER_ENABLE,
6948c2ecf20Sopenharmony_ci		M98090_ADCBQEN_SHIFT, M98090_ADCBQEN_NUM - 1, 0),
6958c2ecf20Sopenharmony_ci};
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98091_snd_controls[] = {
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_ci	SOC_SINGLE("DMIC34 Zeropad", M98090_REG_SAMPLE_RATE,
7008c2ecf20Sopenharmony_ci		M98090_DMIC34_ZEROPAD_SHIFT,
7018c2ecf20Sopenharmony_ci		M98090_DMIC34_ZEROPAD_NUM - 1, 0),
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci	SOC_ENUM("Filter DMIC34 Mode", max98090_filter_dmic34mode_enum),
7048c2ecf20Sopenharmony_ci	SOC_SINGLE("DMIC34 DC Blocking", M98090_REG_FILTER_CONFIG,
7058c2ecf20Sopenharmony_ci		M98090_FLT_DMIC34HPF_SHIFT,
7068c2ecf20Sopenharmony_ci		M98090_FLT_DMIC34HPF_NUM - 1, 0),
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("DMIC3 Boost Volume", M98090_REG_DMIC3_VOLUME,
7098c2ecf20Sopenharmony_ci		M98090_DMIC_AV3G_SHIFT, M98090_DMIC_AV3G_NUM - 1, 0,
7108c2ecf20Sopenharmony_ci		max98090_avg_tlv),
7118c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("DMIC4 Boost Volume", M98090_REG_DMIC4_VOLUME,
7128c2ecf20Sopenharmony_ci		M98090_DMIC_AV4G_SHIFT, M98090_DMIC_AV4G_NUM - 1, 0,
7138c2ecf20Sopenharmony_ci		max98090_avg_tlv),
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("DMIC3 Volume", M98090_REG_DMIC3_VOLUME,
7168c2ecf20Sopenharmony_ci		M98090_DMIC_AV3_SHIFT, M98090_DMIC_AV3_NUM - 1, 1,
7178c2ecf20Sopenharmony_ci		max98090_av_tlv),
7188c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("DMIC4 Volume", M98090_REG_DMIC4_VOLUME,
7198c2ecf20Sopenharmony_ci		M98090_DMIC_AV4_SHIFT, M98090_DMIC_AV4_NUM - 1, 1,
7208c2ecf20Sopenharmony_ci		max98090_av_tlv),
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_ci	SND_SOC_BYTES("DMIC34 Biquad Coefficients",
7238c2ecf20Sopenharmony_ci		M98090_REG_DMIC34_BIQUAD_BASE, 15),
7248c2ecf20Sopenharmony_ci	SOC_SINGLE("DMIC34 Biquad Switch", M98090_REG_DSP_FILTER_ENABLE,
7258c2ecf20Sopenharmony_ci		M98090_DMIC34BQEN_SHIFT, M98090_DMIC34BQEN_NUM - 1, 0),
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci	SOC_SINGLE_TLV("DMIC34 BQ PreAttenuation Volume",
7288c2ecf20Sopenharmony_ci		M98090_REG_DMIC34_BQ_PREATTEN, M98090_AV34BQ_SHIFT,
7298c2ecf20Sopenharmony_ci		M98090_AV34BQ_NUM - 1, 1, max98090_dv_tlv),
7308c2ecf20Sopenharmony_ci};
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_cistatic int max98090_micinput_event(struct snd_soc_dapm_widget *w,
7338c2ecf20Sopenharmony_ci				 struct snd_kcontrol *kcontrol, int event)
7348c2ecf20Sopenharmony_ci{
7358c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
7368c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci	unsigned int val = snd_soc_component_read(component, w->reg);
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci	if (w->reg == M98090_REG_MIC1_INPUT_LEVEL)
7418c2ecf20Sopenharmony_ci		val = (val & M98090_MIC_PA1EN_MASK) >> M98090_MIC_PA1EN_SHIFT;
7428c2ecf20Sopenharmony_ci	else
7438c2ecf20Sopenharmony_ci		val = (val & M98090_MIC_PA2EN_MASK) >> M98090_MIC_PA2EN_SHIFT;
7448c2ecf20Sopenharmony_ci
7458c2ecf20Sopenharmony_ci	if (val >= 1) {
7468c2ecf20Sopenharmony_ci		if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) {
7478c2ecf20Sopenharmony_ci			max98090->pa1en = val - 1; /* Update for volatile */
7488c2ecf20Sopenharmony_ci		} else {
7498c2ecf20Sopenharmony_ci			max98090->pa2en = val - 1; /* Update for volatile */
7508c2ecf20Sopenharmony_ci		}
7518c2ecf20Sopenharmony_ci	}
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_ci	switch (event) {
7548c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMU:
7558c2ecf20Sopenharmony_ci		/* If turning on, set to most recently selected volume */
7568c2ecf20Sopenharmony_ci		if (w->reg == M98090_REG_MIC1_INPUT_LEVEL)
7578c2ecf20Sopenharmony_ci			val = max98090->pa1en + 1;
7588c2ecf20Sopenharmony_ci		else
7598c2ecf20Sopenharmony_ci			val = max98090->pa2en + 1;
7608c2ecf20Sopenharmony_ci		break;
7618c2ecf20Sopenharmony_ci	case SND_SOC_DAPM_POST_PMD:
7628c2ecf20Sopenharmony_ci		/* If turning off, turn off */
7638c2ecf20Sopenharmony_ci		val = 0;
7648c2ecf20Sopenharmony_ci		break;
7658c2ecf20Sopenharmony_ci	default:
7668c2ecf20Sopenharmony_ci		return -EINVAL;
7678c2ecf20Sopenharmony_ci	}
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_ci	if (w->reg == M98090_REG_MIC1_INPUT_LEVEL)
7708c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA1EN_MASK,
7718c2ecf20Sopenharmony_ci			val << M98090_MIC_PA1EN_SHIFT);
7728c2ecf20Sopenharmony_ci	else
7738c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA2EN_MASK,
7748c2ecf20Sopenharmony_ci			val << M98090_MIC_PA2EN_SHIFT);
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_ci	return 0;
7778c2ecf20Sopenharmony_ci}
7788c2ecf20Sopenharmony_ci
7798c2ecf20Sopenharmony_cistatic int max98090_shdn_event(struct snd_soc_dapm_widget *w,
7808c2ecf20Sopenharmony_ci				 struct snd_kcontrol *kcontrol, int event)
7818c2ecf20Sopenharmony_ci{
7828c2ecf20Sopenharmony_ci	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
7838c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci	if (event & SND_SOC_DAPM_POST_PMU)
7868c2ecf20Sopenharmony_ci		max98090->shdn_pending = true;
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_ci	return 0;
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ci}
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_cistatic const char *mic1_mux_text[] = { "IN12", "IN56" };
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(mic1_mux_enum,
7958c2ecf20Sopenharmony_ci			    M98090_REG_INPUT_MODE,
7968c2ecf20Sopenharmony_ci			    M98090_EXTMIC1_SHIFT,
7978c2ecf20Sopenharmony_ci			    mic1_mux_text);
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_mic1_mux =
8008c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("MIC1 Mux", mic1_mux_enum);
8018c2ecf20Sopenharmony_ci
8028c2ecf20Sopenharmony_cistatic const char *mic2_mux_text[] = { "IN34", "IN56" };
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(mic2_mux_enum,
8058c2ecf20Sopenharmony_ci			    M98090_REG_INPUT_MODE,
8068c2ecf20Sopenharmony_ci			    M98090_EXTMIC2_SHIFT,
8078c2ecf20Sopenharmony_ci			    mic2_mux_text);
8088c2ecf20Sopenharmony_ci
8098c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_mic2_mux =
8108c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("MIC2 Mux", mic2_mux_enum);
8118c2ecf20Sopenharmony_ci
8128c2ecf20Sopenharmony_cistatic const char *dmic_mux_text[] = { "ADC", "DMIC" };
8138c2ecf20Sopenharmony_ci
8148c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_VIRT_DECL(dmic_mux_enum, dmic_mux_text);
8158c2ecf20Sopenharmony_ci
8168c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_dmic_mux =
8178c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("DMIC Mux", dmic_mux_enum);
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci/* LINEA mixer switch */
8208c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_linea_mixer_controls[] = {
8218c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN1 Switch", M98090_REG_LINE_INPUT_CONFIG,
8228c2ecf20Sopenharmony_ci		M98090_IN1SEEN_SHIFT, 1, 0),
8238c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN3 Switch", M98090_REG_LINE_INPUT_CONFIG,
8248c2ecf20Sopenharmony_ci		M98090_IN3SEEN_SHIFT, 1, 0),
8258c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN5 Switch", M98090_REG_LINE_INPUT_CONFIG,
8268c2ecf20Sopenharmony_ci		M98090_IN5SEEN_SHIFT, 1, 0),
8278c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN34 Switch", M98090_REG_LINE_INPUT_CONFIG,
8288c2ecf20Sopenharmony_ci		M98090_IN34DIFF_SHIFT, 1, 0),
8298c2ecf20Sopenharmony_ci};
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci/* LINEB mixer switch */
8328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_lineb_mixer_controls[] = {
8338c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN2 Switch", M98090_REG_LINE_INPUT_CONFIG,
8348c2ecf20Sopenharmony_ci		M98090_IN2SEEN_SHIFT, 1, 0),
8358c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN4 Switch", M98090_REG_LINE_INPUT_CONFIG,
8368c2ecf20Sopenharmony_ci		M98090_IN4SEEN_SHIFT, 1, 0),
8378c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN6 Switch", M98090_REG_LINE_INPUT_CONFIG,
8388c2ecf20Sopenharmony_ci		M98090_IN6SEEN_SHIFT, 1, 0),
8398c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN56 Switch", M98090_REG_LINE_INPUT_CONFIG,
8408c2ecf20Sopenharmony_ci		M98090_IN56DIFF_SHIFT, 1, 0),
8418c2ecf20Sopenharmony_ci};
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci/* Left ADC mixer switch */
8448c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_left_adc_mixer_controls[] = {
8458c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN12 Switch", M98090_REG_LEFT_ADC_MIXER,
8468c2ecf20Sopenharmony_ci		M98090_MIXADL_IN12DIFF_SHIFT, 1, 0),
8478c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN34 Switch", M98090_REG_LEFT_ADC_MIXER,
8488c2ecf20Sopenharmony_ci		M98090_MIXADL_IN34DIFF_SHIFT, 1, 0),
8498c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN56 Switch", M98090_REG_LEFT_ADC_MIXER,
8508c2ecf20Sopenharmony_ci		M98090_MIXADL_IN65DIFF_SHIFT, 1, 0),
8518c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_LEFT_ADC_MIXER,
8528c2ecf20Sopenharmony_ci		M98090_MIXADL_LINEA_SHIFT, 1, 0),
8538c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_LEFT_ADC_MIXER,
8548c2ecf20Sopenharmony_ci		M98090_MIXADL_LINEB_SHIFT, 1, 0),
8558c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_LEFT_ADC_MIXER,
8568c2ecf20Sopenharmony_ci		M98090_MIXADL_MIC1_SHIFT, 1, 0),
8578c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_LEFT_ADC_MIXER,
8588c2ecf20Sopenharmony_ci		M98090_MIXADL_MIC2_SHIFT, 1, 0),
8598c2ecf20Sopenharmony_ci};
8608c2ecf20Sopenharmony_ci
8618c2ecf20Sopenharmony_ci/* Right ADC mixer switch */
8628c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_right_adc_mixer_controls[] = {
8638c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN12 Switch", M98090_REG_RIGHT_ADC_MIXER,
8648c2ecf20Sopenharmony_ci		M98090_MIXADR_IN12DIFF_SHIFT, 1, 0),
8658c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN34 Switch", M98090_REG_RIGHT_ADC_MIXER,
8668c2ecf20Sopenharmony_ci		M98090_MIXADR_IN34DIFF_SHIFT, 1, 0),
8678c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("IN56 Switch", M98090_REG_RIGHT_ADC_MIXER,
8688c2ecf20Sopenharmony_ci		M98090_MIXADR_IN65DIFF_SHIFT, 1, 0),
8698c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_RIGHT_ADC_MIXER,
8708c2ecf20Sopenharmony_ci		M98090_MIXADR_LINEA_SHIFT, 1, 0),
8718c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_RIGHT_ADC_MIXER,
8728c2ecf20Sopenharmony_ci		M98090_MIXADR_LINEB_SHIFT, 1, 0),
8738c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_RIGHT_ADC_MIXER,
8748c2ecf20Sopenharmony_ci		M98090_MIXADR_MIC1_SHIFT, 1, 0),
8758c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_RIGHT_ADC_MIXER,
8768c2ecf20Sopenharmony_ci		M98090_MIXADR_MIC2_SHIFT, 1, 0),
8778c2ecf20Sopenharmony_ci};
8788c2ecf20Sopenharmony_ci
8798c2ecf20Sopenharmony_cistatic const char *lten_mux_text[] = { "Normal", "Loopthrough" };
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(ltenl_mux_enum,
8828c2ecf20Sopenharmony_ci			    M98090_REG_IO_CONFIGURATION,
8838c2ecf20Sopenharmony_ci			    M98090_LTEN_SHIFT,
8848c2ecf20Sopenharmony_ci			    lten_mux_text);
8858c2ecf20Sopenharmony_ci
8868c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(ltenr_mux_enum,
8878c2ecf20Sopenharmony_ci			    M98090_REG_IO_CONFIGURATION,
8888c2ecf20Sopenharmony_ci			    M98090_LTEN_SHIFT,
8898c2ecf20Sopenharmony_ci			    lten_mux_text);
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_ltenl_mux =
8928c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum);
8938c2ecf20Sopenharmony_ci
8948c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_ltenr_mux =
8958c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("LTENR Mux", ltenr_mux_enum);
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_cistatic const char *lben_mux_text[] = { "Normal", "Loopback" };
8988c2ecf20Sopenharmony_ci
8998c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(lbenl_mux_enum,
9008c2ecf20Sopenharmony_ci			    M98090_REG_IO_CONFIGURATION,
9018c2ecf20Sopenharmony_ci			    M98090_LBEN_SHIFT,
9028c2ecf20Sopenharmony_ci			    lben_mux_text);
9038c2ecf20Sopenharmony_ci
9048c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(lbenr_mux_enum,
9058c2ecf20Sopenharmony_ci			    M98090_REG_IO_CONFIGURATION,
9068c2ecf20Sopenharmony_ci			    M98090_LBEN_SHIFT,
9078c2ecf20Sopenharmony_ci			    lben_mux_text);
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_lbenl_mux =
9108c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum);
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_lbenr_mux =
9138c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("LBENR Mux", lbenr_mux_enum);
9148c2ecf20Sopenharmony_ci
9158c2ecf20Sopenharmony_cistatic const char *stenl_mux_text[] = { "Normal", "Sidetone Left" };
9168c2ecf20Sopenharmony_ci
9178c2ecf20Sopenharmony_cistatic const char *stenr_mux_text[] = { "Normal", "Sidetone Right" };
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(stenl_mux_enum,
9208c2ecf20Sopenharmony_ci			    M98090_REG_ADC_SIDETONE,
9218c2ecf20Sopenharmony_ci			    M98090_DSTSL_SHIFT,
9228c2ecf20Sopenharmony_ci			    stenl_mux_text);
9238c2ecf20Sopenharmony_ci
9248c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(stenr_mux_enum,
9258c2ecf20Sopenharmony_ci			    M98090_REG_ADC_SIDETONE,
9268c2ecf20Sopenharmony_ci			    M98090_DSTSR_SHIFT,
9278c2ecf20Sopenharmony_ci			    stenr_mux_text);
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_stenl_mux =
9308c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("STENL Mux", stenl_mux_enum);
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_stenr_mux =
9338c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("STENR Mux", stenr_mux_enum);
9348c2ecf20Sopenharmony_ci
9358c2ecf20Sopenharmony_ci/* Left speaker mixer switch */
9368c2ecf20Sopenharmony_cistatic const struct
9378c2ecf20Sopenharmony_ci	snd_kcontrol_new max98090_left_speaker_mixer_controls[] = {
9388c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_LEFT_SPK_MIXER,
9398c2ecf20Sopenharmony_ci		M98090_MIXSPL_DACL_SHIFT, 1, 0),
9408c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_LEFT_SPK_MIXER,
9418c2ecf20Sopenharmony_ci		M98090_MIXSPL_DACR_SHIFT, 1, 0),
9428c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_LEFT_SPK_MIXER,
9438c2ecf20Sopenharmony_ci		M98090_MIXSPL_LINEA_SHIFT, 1, 0),
9448c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_LEFT_SPK_MIXER,
9458c2ecf20Sopenharmony_ci		M98090_MIXSPL_LINEB_SHIFT, 1, 0),
9468c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_LEFT_SPK_MIXER,
9478c2ecf20Sopenharmony_ci		M98090_MIXSPL_MIC1_SHIFT, 1, 0),
9488c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_LEFT_SPK_MIXER,
9498c2ecf20Sopenharmony_ci		M98090_MIXSPL_MIC2_SHIFT, 1, 0),
9508c2ecf20Sopenharmony_ci};
9518c2ecf20Sopenharmony_ci
9528c2ecf20Sopenharmony_ci/* Right speaker mixer switch */
9538c2ecf20Sopenharmony_cistatic const struct
9548c2ecf20Sopenharmony_ci	snd_kcontrol_new max98090_right_speaker_mixer_controls[] = {
9558c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_RIGHT_SPK_MIXER,
9568c2ecf20Sopenharmony_ci		M98090_MIXSPR_DACL_SHIFT, 1, 0),
9578c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_RIGHT_SPK_MIXER,
9588c2ecf20Sopenharmony_ci		M98090_MIXSPR_DACR_SHIFT, 1, 0),
9598c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_RIGHT_SPK_MIXER,
9608c2ecf20Sopenharmony_ci		M98090_MIXSPR_LINEA_SHIFT, 1, 0),
9618c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_RIGHT_SPK_MIXER,
9628c2ecf20Sopenharmony_ci		M98090_MIXSPR_LINEB_SHIFT, 1, 0),
9638c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_RIGHT_SPK_MIXER,
9648c2ecf20Sopenharmony_ci		M98090_MIXSPR_MIC1_SHIFT, 1, 0),
9658c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_RIGHT_SPK_MIXER,
9668c2ecf20Sopenharmony_ci		M98090_MIXSPR_MIC2_SHIFT, 1, 0),
9678c2ecf20Sopenharmony_ci};
9688c2ecf20Sopenharmony_ci
9698c2ecf20Sopenharmony_ci/* Left headphone mixer switch */
9708c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_left_hp_mixer_controls[] = {
9718c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_LEFT_HP_MIXER,
9728c2ecf20Sopenharmony_ci		M98090_MIXHPL_DACL_SHIFT, 1, 0),
9738c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_LEFT_HP_MIXER,
9748c2ecf20Sopenharmony_ci		M98090_MIXHPL_DACR_SHIFT, 1, 0),
9758c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_LEFT_HP_MIXER,
9768c2ecf20Sopenharmony_ci		M98090_MIXHPL_LINEA_SHIFT, 1, 0),
9778c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_LEFT_HP_MIXER,
9788c2ecf20Sopenharmony_ci		M98090_MIXHPL_LINEB_SHIFT, 1, 0),
9798c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_LEFT_HP_MIXER,
9808c2ecf20Sopenharmony_ci		M98090_MIXHPL_MIC1_SHIFT, 1, 0),
9818c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_LEFT_HP_MIXER,
9828c2ecf20Sopenharmony_ci		M98090_MIXHPL_MIC2_SHIFT, 1, 0),
9838c2ecf20Sopenharmony_ci};
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci/* Right headphone mixer switch */
9868c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_right_hp_mixer_controls[] = {
9878c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_RIGHT_HP_MIXER,
9888c2ecf20Sopenharmony_ci		M98090_MIXHPR_DACL_SHIFT, 1, 0),
9898c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_RIGHT_HP_MIXER,
9908c2ecf20Sopenharmony_ci		M98090_MIXHPR_DACR_SHIFT, 1, 0),
9918c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_RIGHT_HP_MIXER,
9928c2ecf20Sopenharmony_ci		M98090_MIXHPR_LINEA_SHIFT, 1, 0),
9938c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_RIGHT_HP_MIXER,
9948c2ecf20Sopenharmony_ci		M98090_MIXHPR_LINEB_SHIFT, 1, 0),
9958c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_RIGHT_HP_MIXER,
9968c2ecf20Sopenharmony_ci		M98090_MIXHPR_MIC1_SHIFT, 1, 0),
9978c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_RIGHT_HP_MIXER,
9988c2ecf20Sopenharmony_ci		M98090_MIXHPR_MIC2_SHIFT, 1, 0),
9998c2ecf20Sopenharmony_ci};
10008c2ecf20Sopenharmony_ci
10018c2ecf20Sopenharmony_ci/* Left receiver mixer switch */
10028c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_left_rcv_mixer_controls[] = {
10038c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_RCV_LOUTL_MIXER,
10048c2ecf20Sopenharmony_ci		M98090_MIXRCVL_DACL_SHIFT, 1, 0),
10058c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_RCV_LOUTL_MIXER,
10068c2ecf20Sopenharmony_ci		M98090_MIXRCVL_DACR_SHIFT, 1, 0),
10078c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_RCV_LOUTL_MIXER,
10088c2ecf20Sopenharmony_ci		M98090_MIXRCVL_LINEA_SHIFT, 1, 0),
10098c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_RCV_LOUTL_MIXER,
10108c2ecf20Sopenharmony_ci		M98090_MIXRCVL_LINEB_SHIFT, 1, 0),
10118c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_RCV_LOUTL_MIXER,
10128c2ecf20Sopenharmony_ci		M98090_MIXRCVL_MIC1_SHIFT, 1, 0),
10138c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_RCV_LOUTL_MIXER,
10148c2ecf20Sopenharmony_ci		M98090_MIXRCVL_MIC2_SHIFT, 1, 0),
10158c2ecf20Sopenharmony_ci};
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci/* Right receiver mixer switch */
10188c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_right_rcv_mixer_controls[] = {
10198c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Left DAC Switch", M98090_REG_LOUTR_MIXER,
10208c2ecf20Sopenharmony_ci		M98090_MIXRCVR_DACL_SHIFT, 1, 0),
10218c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("Right DAC Switch", M98090_REG_LOUTR_MIXER,
10228c2ecf20Sopenharmony_ci		M98090_MIXRCVR_DACR_SHIFT, 1, 0),
10238c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEA Switch", M98090_REG_LOUTR_MIXER,
10248c2ecf20Sopenharmony_ci		M98090_MIXRCVR_LINEA_SHIFT, 1, 0),
10258c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("LINEB Switch", M98090_REG_LOUTR_MIXER,
10268c2ecf20Sopenharmony_ci		M98090_MIXRCVR_LINEB_SHIFT, 1, 0),
10278c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC1 Switch", M98090_REG_LOUTR_MIXER,
10288c2ecf20Sopenharmony_ci		M98090_MIXRCVR_MIC1_SHIFT, 1, 0),
10298c2ecf20Sopenharmony_ci	SOC_DAPM_SINGLE("MIC2 Switch", M98090_REG_LOUTR_MIXER,
10308c2ecf20Sopenharmony_ci		M98090_MIXRCVR_MIC2_SHIFT, 1, 0),
10318c2ecf20Sopenharmony_ci};
10328c2ecf20Sopenharmony_ci
10338c2ecf20Sopenharmony_cistatic const char *linmod_mux_text[] = { "Left Only", "Left and Right" };
10348c2ecf20Sopenharmony_ci
10358c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(linmod_mux_enum,
10368c2ecf20Sopenharmony_ci			    M98090_REG_LOUTR_MIXER,
10378c2ecf20Sopenharmony_ci			    M98090_LINMOD_SHIFT,
10388c2ecf20Sopenharmony_ci			    linmod_mux_text);
10398c2ecf20Sopenharmony_ci
10408c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_linmod_mux =
10418c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("LINMOD Mux", linmod_mux_enum);
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_cistatic const char *mixhpsel_mux_text[] = { "DAC Only", "HP Mixer" };
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_ci/*
10468c2ecf20Sopenharmony_ci * This is a mux as it selects the HP output, but to DAPM it is a Mixer enable
10478c2ecf20Sopenharmony_ci */
10488c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(mixhplsel_mux_enum,
10498c2ecf20Sopenharmony_ci			    M98090_REG_HP_CONTROL,
10508c2ecf20Sopenharmony_ci			    M98090_MIXHPLSEL_SHIFT,
10518c2ecf20Sopenharmony_ci			    mixhpsel_mux_text);
10528c2ecf20Sopenharmony_ci
10538c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_mixhplsel_mux =
10548c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("MIXHPLSEL Mux", mixhplsel_mux_enum);
10558c2ecf20Sopenharmony_ci
10568c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(mixhprsel_mux_enum,
10578c2ecf20Sopenharmony_ci			    M98090_REG_HP_CONTROL,
10588c2ecf20Sopenharmony_ci			    M98090_MIXHPRSEL_SHIFT,
10598c2ecf20Sopenharmony_ci			    mixhpsel_mux_text);
10608c2ecf20Sopenharmony_ci
10618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new max98090_mixhprsel_mux =
10628c2ecf20Sopenharmony_ci	SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum);
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
10658c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("MIC1"),
10668c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("MIC2"),
10678c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMICL"),
10688c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMICR"),
10698c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN1"),
10708c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN2"),
10718c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN3"),
10728c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN4"),
10738c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN5"),
10748c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN6"),
10758c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN12"),
10768c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN34"),
10778c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("IN56"),
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("MICBIAS", M98090_REG_INPUT_ENABLE,
10808c2ecf20Sopenharmony_ci		M98090_MBEN_SHIFT, 0, NULL, 0),
10818c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("SHDN", M98090_REG_DEVICE_SHUTDOWN,
10828c2ecf20Sopenharmony_ci		M98090_SHDNN_SHIFT, 0, NULL, 0),
10838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("SDIEN", M98090_REG_IO_CONFIGURATION,
10848c2ecf20Sopenharmony_ci		M98090_SDIEN_SHIFT, 0, NULL, 0),
10858c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("SDOEN", M98090_REG_IO_CONFIGURATION,
10868c2ecf20Sopenharmony_ci		M98090_SDOEN_SHIFT, 0, NULL, 0),
10878c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMICL_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
10888c2ecf20Sopenharmony_ci		 M98090_DIGMICL_SHIFT, 0, max98090_shdn_event,
10898c2ecf20Sopenharmony_ci			SND_SOC_DAPM_POST_PMU),
10908c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMICR_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
10918c2ecf20Sopenharmony_ci		 M98090_DIGMICR_SHIFT, 0, max98090_shdn_event,
10928c2ecf20Sopenharmony_ci			 SND_SOC_DAPM_POST_PMU),
10938c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("AHPF", M98090_REG_FILTER_CONFIG,
10948c2ecf20Sopenharmony_ci		M98090_AHPF_SHIFT, 0, NULL, 0),
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci/*
10978c2ecf20Sopenharmony_ci * Note: Sysclk and misc power supplies are taken care of by SHDN
10988c2ecf20Sopenharmony_ci */
10998c2ecf20Sopenharmony_ci
11008c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("MIC1 Mux", SND_SOC_NOPM,
11018c2ecf20Sopenharmony_ci		0, 0, &max98090_mic1_mux),
11028c2ecf20Sopenharmony_ci
11038c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("MIC2 Mux", SND_SOC_NOPM,
11048c2ecf20Sopenharmony_ci		0, 0, &max98090_mic2_mux),
11058c2ecf20Sopenharmony_ci
11068c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("DMIC Mux", SND_SOC_NOPM, 0, 0, &max98090_dmic_mux),
11078c2ecf20Sopenharmony_ci
11088c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_E("MIC1 Input", M98090_REG_MIC1_INPUT_LEVEL,
11098c2ecf20Sopenharmony_ci		M98090_MIC_PA1EN_SHIFT, 0, NULL, 0, max98090_micinput_event,
11108c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
11118c2ecf20Sopenharmony_ci
11128c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA_E("MIC2 Input", M98090_REG_MIC2_INPUT_LEVEL,
11138c2ecf20Sopenharmony_ci		M98090_MIC_PA2EN_SHIFT, 0, NULL, 0, max98090_micinput_event,
11148c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("LINEA Mixer", SND_SOC_NOPM, 0, 0,
11178c2ecf20Sopenharmony_ci		&max98090_linea_mixer_controls[0],
11188c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_linea_mixer_controls)),
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("LINEB Mixer", SND_SOC_NOPM, 0, 0,
11218c2ecf20Sopenharmony_ci		&max98090_lineb_mixer_controls[0],
11228c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_lineb_mixer_controls)),
11238c2ecf20Sopenharmony_ci
11248c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("LINEA Input", M98090_REG_INPUT_ENABLE,
11258c2ecf20Sopenharmony_ci		M98090_LINEAEN_SHIFT, 0, NULL, 0),
11268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("LINEB Input", M98090_REG_INPUT_ENABLE,
11278c2ecf20Sopenharmony_ci		M98090_LINEBEN_SHIFT, 0, NULL, 0),
11288c2ecf20Sopenharmony_ci
11298c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Left ADC Mixer", SND_SOC_NOPM, 0, 0,
11308c2ecf20Sopenharmony_ci		&max98090_left_adc_mixer_controls[0],
11318c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_left_adc_mixer_controls)),
11328c2ecf20Sopenharmony_ci
11338c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Right ADC Mixer", SND_SOC_NOPM, 0, 0,
11348c2ecf20Sopenharmony_ci		&max98090_right_adc_mixer_controls[0],
11358c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_right_adc_mixer_controls)),
11368c2ecf20Sopenharmony_ci
11378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC_E("ADCL", NULL, M98090_REG_INPUT_ENABLE,
11388c2ecf20Sopenharmony_ci		M98090_ADLEN_SHIFT, 0, max98090_shdn_event,
11398c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU),
11408c2ecf20Sopenharmony_ci	SND_SOC_DAPM_ADC_E("ADCR", NULL, M98090_REG_INPUT_ENABLE,
11418c2ecf20Sopenharmony_ci		M98090_ADREN_SHIFT, 0, max98090_shdn_event,
11428c2ecf20Sopenharmony_ci		SND_SOC_DAPM_POST_PMU),
11438c2ecf20Sopenharmony_ci
11448c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_OUT("AIFOUTL", "HiFi Capture", 0,
11458c2ecf20Sopenharmony_ci		SND_SOC_NOPM, 0, 0),
11468c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_OUT("AIFOUTR", "HiFi Capture", 1,
11478c2ecf20Sopenharmony_ci		SND_SOC_NOPM, 0, 0),
11488c2ecf20Sopenharmony_ci
11498c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("LBENL Mux", SND_SOC_NOPM,
11508c2ecf20Sopenharmony_ci		0, 0, &max98090_lbenl_mux),
11518c2ecf20Sopenharmony_ci
11528c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("LBENR Mux", SND_SOC_NOPM,
11538c2ecf20Sopenharmony_ci		0, 0, &max98090_lbenr_mux),
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("LTENL Mux", SND_SOC_NOPM,
11568c2ecf20Sopenharmony_ci		0, 0, &max98090_ltenl_mux),
11578c2ecf20Sopenharmony_ci
11588c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("LTENR Mux", SND_SOC_NOPM,
11598c2ecf20Sopenharmony_ci		0, 0, &max98090_ltenr_mux),
11608c2ecf20Sopenharmony_ci
11618c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("STENL Mux", SND_SOC_NOPM,
11628c2ecf20Sopenharmony_ci		0, 0, &max98090_stenl_mux),
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("STENR Mux", SND_SOC_NOPM,
11658c2ecf20Sopenharmony_ci		0, 0, &max98090_stenr_mux),
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_IN("AIFINL", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
11688c2ecf20Sopenharmony_ci	SND_SOC_DAPM_AIF_IN("AIFINR", "HiFi Playback", 1, SND_SOC_NOPM, 0, 0),
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DACL", NULL, M98090_REG_OUTPUT_ENABLE,
11718c2ecf20Sopenharmony_ci		M98090_DALEN_SHIFT, 0),
11728c2ecf20Sopenharmony_ci	SND_SOC_DAPM_DAC("DACR", NULL, M98090_REG_OUTPUT_ENABLE,
11738c2ecf20Sopenharmony_ci		M98090_DAREN_SHIFT, 0),
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Left Headphone Mixer", SND_SOC_NOPM, 0, 0,
11768c2ecf20Sopenharmony_ci		&max98090_left_hp_mixer_controls[0],
11778c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_left_hp_mixer_controls)),
11788c2ecf20Sopenharmony_ci
11798c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Right Headphone Mixer", SND_SOC_NOPM, 0, 0,
11808c2ecf20Sopenharmony_ci		&max98090_right_hp_mixer_controls[0],
11818c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_right_hp_mixer_controls)),
11828c2ecf20Sopenharmony_ci
11838c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Left Speaker Mixer", SND_SOC_NOPM, 0, 0,
11848c2ecf20Sopenharmony_ci		&max98090_left_speaker_mixer_controls[0],
11858c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_left_speaker_mixer_controls)),
11868c2ecf20Sopenharmony_ci
11878c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Right Speaker Mixer", SND_SOC_NOPM, 0, 0,
11888c2ecf20Sopenharmony_ci		&max98090_right_speaker_mixer_controls[0],
11898c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_right_speaker_mixer_controls)),
11908c2ecf20Sopenharmony_ci
11918c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Left Receiver Mixer", SND_SOC_NOPM, 0, 0,
11928c2ecf20Sopenharmony_ci		&max98090_left_rcv_mixer_controls[0],
11938c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_left_rcv_mixer_controls)),
11948c2ecf20Sopenharmony_ci
11958c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIXER("Right Receiver Mixer", SND_SOC_NOPM, 0, 0,
11968c2ecf20Sopenharmony_ci		&max98090_right_rcv_mixer_controls[0],
11978c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_right_rcv_mixer_controls)),
11988c2ecf20Sopenharmony_ci
11998c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("LINMOD Mux", SND_SOC_NOPM, 0, 0,
12008c2ecf20Sopenharmony_ci		&max98090_linmod_mux),
12018c2ecf20Sopenharmony_ci
12028c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("MIXHPLSEL Mux", SND_SOC_NOPM, 0, 0,
12038c2ecf20Sopenharmony_ci		&max98090_mixhplsel_mux),
12048c2ecf20Sopenharmony_ci
12058c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MUX("MIXHPRSEL Mux", SND_SOC_NOPM, 0, 0,
12068c2ecf20Sopenharmony_ci		&max98090_mixhprsel_mux),
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("HP Left Out", M98090_REG_OUTPUT_ENABLE,
12098c2ecf20Sopenharmony_ci		M98090_HPLEN_SHIFT, 0, NULL, 0),
12108c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("HP Right Out", M98090_REG_OUTPUT_ENABLE,
12118c2ecf20Sopenharmony_ci		M98090_HPREN_SHIFT, 0, NULL, 0),
12128c2ecf20Sopenharmony_ci
12138c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("SPK Left Out", M98090_REG_OUTPUT_ENABLE,
12148c2ecf20Sopenharmony_ci		M98090_SPLEN_SHIFT, 0, NULL, 0),
12158c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("SPK Right Out", M98090_REG_OUTPUT_ENABLE,
12168c2ecf20Sopenharmony_ci		M98090_SPREN_SHIFT, 0, NULL, 0),
12178c2ecf20Sopenharmony_ci
12188c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("RCV Left Out", M98090_REG_OUTPUT_ENABLE,
12198c2ecf20Sopenharmony_ci		M98090_RCVLEN_SHIFT, 0, NULL, 0),
12208c2ecf20Sopenharmony_ci	SND_SOC_DAPM_PGA("RCV Right Out", M98090_REG_OUTPUT_ENABLE,
12218c2ecf20Sopenharmony_ci		M98090_RCVREN_SHIFT, 0, NULL, 0),
12228c2ecf20Sopenharmony_ci
12238c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("HPL"),
12248c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("HPR"),
12258c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("SPKL"),
12268c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("SPKR"),
12278c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("RCVL"),
12288c2ecf20Sopenharmony_ci	SND_SOC_DAPM_OUTPUT("RCVR"),
12298c2ecf20Sopenharmony_ci};
12308c2ecf20Sopenharmony_ci
12318c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget max98091_dapm_widgets[] = {
12328c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC3"),
12338c2ecf20Sopenharmony_ci	SND_SOC_DAPM_INPUT("DMIC4"),
12348c2ecf20Sopenharmony_ci
12358c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMIC3_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
12368c2ecf20Sopenharmony_ci		 M98090_DIGMIC3_SHIFT, 0, NULL, 0),
12378c2ecf20Sopenharmony_ci	SND_SOC_DAPM_SUPPLY("DMIC4_ENA", M98090_REG_DIGITAL_MIC_ENABLE,
12388c2ecf20Sopenharmony_ci		 M98090_DIGMIC4_SHIFT, 0, NULL, 0),
12398c2ecf20Sopenharmony_ci};
12408c2ecf20Sopenharmony_ci
12418c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route max98090_dapm_routes[] = {
12428c2ecf20Sopenharmony_ci	{"MIC1 Input", NULL, "MIC1"},
12438c2ecf20Sopenharmony_ci	{"MIC2 Input", NULL, "MIC2"},
12448c2ecf20Sopenharmony_ci
12458c2ecf20Sopenharmony_ci	{"DMICL", NULL, "DMICL_ENA"},
12468c2ecf20Sopenharmony_ci	{"DMICL", NULL, "DMICR_ENA"},
12478c2ecf20Sopenharmony_ci	{"DMICR", NULL, "DMICL_ENA"},
12488c2ecf20Sopenharmony_ci	{"DMICR", NULL, "DMICR_ENA"},
12498c2ecf20Sopenharmony_ci	{"DMICL", NULL, "AHPF"},
12508c2ecf20Sopenharmony_ci	{"DMICR", NULL, "AHPF"},
12518c2ecf20Sopenharmony_ci
12528c2ecf20Sopenharmony_ci	/* MIC1 input mux */
12538c2ecf20Sopenharmony_ci	{"MIC1 Mux", "IN12", "IN12"},
12548c2ecf20Sopenharmony_ci	{"MIC1 Mux", "IN56", "IN56"},
12558c2ecf20Sopenharmony_ci
12568c2ecf20Sopenharmony_ci	/* MIC2 input mux */
12578c2ecf20Sopenharmony_ci	{"MIC2 Mux", "IN34", "IN34"},
12588c2ecf20Sopenharmony_ci	{"MIC2 Mux", "IN56", "IN56"},
12598c2ecf20Sopenharmony_ci
12608c2ecf20Sopenharmony_ci	{"MIC1 Input", NULL, "MIC1 Mux"},
12618c2ecf20Sopenharmony_ci	{"MIC2 Input", NULL, "MIC2 Mux"},
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_ci	/* Left ADC input mixer */
12648c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "IN12 Switch", "IN12"},
12658c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "IN34 Switch", "IN34"},
12668c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "IN56 Switch", "IN56"},
12678c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "LINEA Switch", "LINEA Input"},
12688c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "LINEB Switch", "LINEB Input"},
12698c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "MIC1 Switch", "MIC1 Input"},
12708c2ecf20Sopenharmony_ci	{"Left ADC Mixer", "MIC2 Switch", "MIC2 Input"},
12718c2ecf20Sopenharmony_ci
12728c2ecf20Sopenharmony_ci	/* Right ADC input mixer */
12738c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "IN12 Switch", "IN12"},
12748c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "IN34 Switch", "IN34"},
12758c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "IN56 Switch", "IN56"},
12768c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "LINEA Switch", "LINEA Input"},
12778c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "LINEB Switch", "LINEB Input"},
12788c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "MIC1 Switch", "MIC1 Input"},
12798c2ecf20Sopenharmony_ci	{"Right ADC Mixer", "MIC2 Switch", "MIC2 Input"},
12808c2ecf20Sopenharmony_ci
12818c2ecf20Sopenharmony_ci	/* Line A input mixer */
12828c2ecf20Sopenharmony_ci	{"LINEA Mixer", "IN1 Switch", "IN1"},
12838c2ecf20Sopenharmony_ci	{"LINEA Mixer", "IN3 Switch", "IN3"},
12848c2ecf20Sopenharmony_ci	{"LINEA Mixer", "IN5 Switch", "IN5"},
12858c2ecf20Sopenharmony_ci	{"LINEA Mixer", "IN34 Switch", "IN34"},
12868c2ecf20Sopenharmony_ci
12878c2ecf20Sopenharmony_ci	/* Line B input mixer */
12888c2ecf20Sopenharmony_ci	{"LINEB Mixer", "IN2 Switch", "IN2"},
12898c2ecf20Sopenharmony_ci	{"LINEB Mixer", "IN4 Switch", "IN4"},
12908c2ecf20Sopenharmony_ci	{"LINEB Mixer", "IN6 Switch", "IN6"},
12918c2ecf20Sopenharmony_ci	{"LINEB Mixer", "IN56 Switch", "IN56"},
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_ci	{"LINEA Input", NULL, "LINEA Mixer"},
12948c2ecf20Sopenharmony_ci	{"LINEB Input", NULL, "LINEB Mixer"},
12958c2ecf20Sopenharmony_ci
12968c2ecf20Sopenharmony_ci	/* Inputs */
12978c2ecf20Sopenharmony_ci	{"ADCL", NULL, "Left ADC Mixer"},
12988c2ecf20Sopenharmony_ci	{"ADCR", NULL, "Right ADC Mixer"},
12998c2ecf20Sopenharmony_ci	{"ADCL", NULL, "SHDN"},
13008c2ecf20Sopenharmony_ci	{"ADCR", NULL, "SHDN"},
13018c2ecf20Sopenharmony_ci
13028c2ecf20Sopenharmony_ci	{"DMIC Mux", "ADC", "ADCL"},
13038c2ecf20Sopenharmony_ci	{"DMIC Mux", "ADC", "ADCR"},
13048c2ecf20Sopenharmony_ci	{"DMIC Mux", "DMIC", "DMICL"},
13058c2ecf20Sopenharmony_ci	{"DMIC Mux", "DMIC", "DMICR"},
13068c2ecf20Sopenharmony_ci
13078c2ecf20Sopenharmony_ci	{"LBENL Mux", "Normal", "DMIC Mux"},
13088c2ecf20Sopenharmony_ci	{"LBENL Mux", "Loopback", "LTENL Mux"},
13098c2ecf20Sopenharmony_ci	{"LBENR Mux", "Normal", "DMIC Mux"},
13108c2ecf20Sopenharmony_ci	{"LBENR Mux", "Loopback", "LTENR Mux"},
13118c2ecf20Sopenharmony_ci
13128c2ecf20Sopenharmony_ci	{"AIFOUTL", NULL, "LBENL Mux"},
13138c2ecf20Sopenharmony_ci	{"AIFOUTR", NULL, "LBENR Mux"},
13148c2ecf20Sopenharmony_ci	{"AIFOUTL", NULL, "SHDN"},
13158c2ecf20Sopenharmony_ci	{"AIFOUTR", NULL, "SHDN"},
13168c2ecf20Sopenharmony_ci	{"AIFOUTL", NULL, "SDOEN"},
13178c2ecf20Sopenharmony_ci	{"AIFOUTR", NULL, "SDOEN"},
13188c2ecf20Sopenharmony_ci
13198c2ecf20Sopenharmony_ci	{"LTENL Mux", "Normal", "AIFINL"},
13208c2ecf20Sopenharmony_ci	{"LTENL Mux", "Loopthrough", "LBENL Mux"},
13218c2ecf20Sopenharmony_ci	{"LTENR Mux", "Normal", "AIFINR"},
13228c2ecf20Sopenharmony_ci	{"LTENR Mux", "Loopthrough", "LBENR Mux"},
13238c2ecf20Sopenharmony_ci
13248c2ecf20Sopenharmony_ci	{"DACL", NULL, "LTENL Mux"},
13258c2ecf20Sopenharmony_ci	{"DACR", NULL, "LTENR Mux"},
13268c2ecf20Sopenharmony_ci
13278c2ecf20Sopenharmony_ci	{"STENL Mux", "Sidetone Left", "ADCL"},
13288c2ecf20Sopenharmony_ci	{"STENL Mux", "Sidetone Left", "DMICL"},
13298c2ecf20Sopenharmony_ci	{"STENR Mux", "Sidetone Right", "ADCR"},
13308c2ecf20Sopenharmony_ci	{"STENR Mux", "Sidetone Right", "DMICR"},
13318c2ecf20Sopenharmony_ci	{"DACL", NULL, "STENL Mux"},
13328c2ecf20Sopenharmony_ci	{"DACR", NULL, "STENR Mux"},
13338c2ecf20Sopenharmony_ci
13348c2ecf20Sopenharmony_ci	{"AIFINL", NULL, "SHDN"},
13358c2ecf20Sopenharmony_ci	{"AIFINR", NULL, "SHDN"},
13368c2ecf20Sopenharmony_ci	{"AIFINL", NULL, "SDIEN"},
13378c2ecf20Sopenharmony_ci	{"AIFINR", NULL, "SDIEN"},
13388c2ecf20Sopenharmony_ci	{"DACL", NULL, "SHDN"},
13398c2ecf20Sopenharmony_ci	{"DACR", NULL, "SHDN"},
13408c2ecf20Sopenharmony_ci
13418c2ecf20Sopenharmony_ci	/* Left headphone output mixer */
13428c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "Left DAC Switch", "DACL"},
13438c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "Right DAC Switch", "DACR"},
13448c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "MIC1 Switch", "MIC1 Input"},
13458c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "MIC2 Switch", "MIC2 Input"},
13468c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "LINEA Switch", "LINEA Input"},
13478c2ecf20Sopenharmony_ci	{"Left Headphone Mixer", "LINEB Switch", "LINEB Input"},
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	/* Right headphone output mixer */
13508c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "Left DAC Switch", "DACL"},
13518c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "Right DAC Switch", "DACR"},
13528c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "MIC1 Switch", "MIC1 Input"},
13538c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "MIC2 Switch", "MIC2 Input"},
13548c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "LINEA Switch", "LINEA Input"},
13558c2ecf20Sopenharmony_ci	{"Right Headphone Mixer", "LINEB Switch", "LINEB Input"},
13568c2ecf20Sopenharmony_ci
13578c2ecf20Sopenharmony_ci	/* Left speaker output mixer */
13588c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "Left DAC Switch", "DACL"},
13598c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "Right DAC Switch", "DACR"},
13608c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "MIC1 Switch", "MIC1 Input"},
13618c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "MIC2 Switch", "MIC2 Input"},
13628c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "LINEA Switch", "LINEA Input"},
13638c2ecf20Sopenharmony_ci	{"Left Speaker Mixer", "LINEB Switch", "LINEB Input"},
13648c2ecf20Sopenharmony_ci
13658c2ecf20Sopenharmony_ci	/* Right speaker output mixer */
13668c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "Left DAC Switch", "DACL"},
13678c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "Right DAC Switch", "DACR"},
13688c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "MIC1 Switch", "MIC1 Input"},
13698c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "MIC2 Switch", "MIC2 Input"},
13708c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "LINEA Switch", "LINEA Input"},
13718c2ecf20Sopenharmony_ci	{"Right Speaker Mixer", "LINEB Switch", "LINEB Input"},
13728c2ecf20Sopenharmony_ci
13738c2ecf20Sopenharmony_ci	/* Left Receiver output mixer */
13748c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "Left DAC Switch", "DACL"},
13758c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "Right DAC Switch", "DACR"},
13768c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "MIC1 Switch", "MIC1 Input"},
13778c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "MIC2 Switch", "MIC2 Input"},
13788c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "LINEA Switch", "LINEA Input"},
13798c2ecf20Sopenharmony_ci	{"Left Receiver Mixer", "LINEB Switch", "LINEB Input"},
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_ci	/* Right Receiver output mixer */
13828c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "Left DAC Switch", "DACL"},
13838c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "Right DAC Switch", "DACR"},
13848c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "MIC1 Switch", "MIC1 Input"},
13858c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "MIC2 Switch", "MIC2 Input"},
13868c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "LINEA Switch", "LINEA Input"},
13878c2ecf20Sopenharmony_ci	{"Right Receiver Mixer", "LINEB Switch", "LINEB Input"},
13888c2ecf20Sopenharmony_ci
13898c2ecf20Sopenharmony_ci	{"MIXHPLSEL Mux", "HP Mixer", "Left Headphone Mixer"},
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_ci	/*
13928c2ecf20Sopenharmony_ci	 * Disable this for lowest power if bypassing
13938c2ecf20Sopenharmony_ci	 * the DAC with an analog signal
13948c2ecf20Sopenharmony_ci	 */
13958c2ecf20Sopenharmony_ci	{"HP Left Out", NULL, "DACL"},
13968c2ecf20Sopenharmony_ci	{"HP Left Out", NULL, "MIXHPLSEL Mux"},
13978c2ecf20Sopenharmony_ci
13988c2ecf20Sopenharmony_ci	{"MIXHPRSEL Mux", "HP Mixer", "Right Headphone Mixer"},
13998c2ecf20Sopenharmony_ci
14008c2ecf20Sopenharmony_ci	/*
14018c2ecf20Sopenharmony_ci	 * Disable this for lowest power if bypassing
14028c2ecf20Sopenharmony_ci	 * the DAC with an analog signal
14038c2ecf20Sopenharmony_ci	 */
14048c2ecf20Sopenharmony_ci	{"HP Right Out", NULL, "DACR"},
14058c2ecf20Sopenharmony_ci	{"HP Right Out", NULL, "MIXHPRSEL Mux"},
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_ci	{"SPK Left Out", NULL, "Left Speaker Mixer"},
14088c2ecf20Sopenharmony_ci	{"SPK Right Out", NULL, "Right Speaker Mixer"},
14098c2ecf20Sopenharmony_ci	{"RCV Left Out", NULL, "Left Receiver Mixer"},
14108c2ecf20Sopenharmony_ci
14118c2ecf20Sopenharmony_ci	{"LINMOD Mux", "Left and Right", "Right Receiver Mixer"},
14128c2ecf20Sopenharmony_ci	{"LINMOD Mux", "Left Only",  "Left Receiver Mixer"},
14138c2ecf20Sopenharmony_ci	{"RCV Right Out", NULL, "LINMOD Mux"},
14148c2ecf20Sopenharmony_ci
14158c2ecf20Sopenharmony_ci	{"HPL", NULL, "HP Left Out"},
14168c2ecf20Sopenharmony_ci	{"HPR", NULL, "HP Right Out"},
14178c2ecf20Sopenharmony_ci	{"SPKL", NULL, "SPK Left Out"},
14188c2ecf20Sopenharmony_ci	{"SPKR", NULL, "SPK Right Out"},
14198c2ecf20Sopenharmony_ci	{"RCVL", NULL, "RCV Left Out"},
14208c2ecf20Sopenharmony_ci	{"RCVR", NULL, "RCV Right Out"},
14218c2ecf20Sopenharmony_ci};
14228c2ecf20Sopenharmony_ci
14238c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route max98091_dapm_routes[] = {
14248c2ecf20Sopenharmony_ci	/* DMIC inputs */
14258c2ecf20Sopenharmony_ci	{"DMIC3", NULL, "DMIC3_ENA"},
14268c2ecf20Sopenharmony_ci	{"DMIC4", NULL, "DMIC4_ENA"},
14278c2ecf20Sopenharmony_ci	{"DMIC3", NULL, "AHPF"},
14288c2ecf20Sopenharmony_ci	{"DMIC4", NULL, "AHPF"},
14298c2ecf20Sopenharmony_ci};
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_cistatic int max98090_add_widgets(struct snd_soc_component *component)
14328c2ecf20Sopenharmony_ci{
14338c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
14348c2ecf20Sopenharmony_ci	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
14358c2ecf20Sopenharmony_ci
14368c2ecf20Sopenharmony_ci	snd_soc_add_component_controls(component, max98090_snd_controls,
14378c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_snd_controls));
14388c2ecf20Sopenharmony_ci
14398c2ecf20Sopenharmony_ci	if (max98090->devtype == MAX98091) {
14408c2ecf20Sopenharmony_ci		snd_soc_add_component_controls(component, max98091_snd_controls,
14418c2ecf20Sopenharmony_ci			ARRAY_SIZE(max98091_snd_controls));
14428c2ecf20Sopenharmony_ci	}
14438c2ecf20Sopenharmony_ci
14448c2ecf20Sopenharmony_ci	snd_soc_dapm_new_controls(dapm, max98090_dapm_widgets,
14458c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_dapm_widgets));
14468c2ecf20Sopenharmony_ci
14478c2ecf20Sopenharmony_ci	snd_soc_dapm_add_routes(dapm, max98090_dapm_routes,
14488c2ecf20Sopenharmony_ci		ARRAY_SIZE(max98090_dapm_routes));
14498c2ecf20Sopenharmony_ci
14508c2ecf20Sopenharmony_ci	if (max98090->devtype == MAX98091) {
14518c2ecf20Sopenharmony_ci		snd_soc_dapm_new_controls(dapm, max98091_dapm_widgets,
14528c2ecf20Sopenharmony_ci			ARRAY_SIZE(max98091_dapm_widgets));
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_ci		snd_soc_dapm_add_routes(dapm, max98091_dapm_routes,
14558c2ecf20Sopenharmony_ci			ARRAY_SIZE(max98091_dapm_routes));
14568c2ecf20Sopenharmony_ci	}
14578c2ecf20Sopenharmony_ci
14588c2ecf20Sopenharmony_ci	return 0;
14598c2ecf20Sopenharmony_ci}
14608c2ecf20Sopenharmony_ci
14618c2ecf20Sopenharmony_cistatic const int pclk_rates[] = {
14628c2ecf20Sopenharmony_ci	12000000, 12000000, 13000000, 13000000,
14638c2ecf20Sopenharmony_ci	16000000, 16000000, 19200000, 19200000
14648c2ecf20Sopenharmony_ci};
14658c2ecf20Sopenharmony_ci
14668c2ecf20Sopenharmony_cistatic const int lrclk_rates[] = {
14678c2ecf20Sopenharmony_ci	8000, 16000, 8000, 16000,
14688c2ecf20Sopenharmony_ci	8000, 16000, 8000, 16000
14698c2ecf20Sopenharmony_ci};
14708c2ecf20Sopenharmony_ci
14718c2ecf20Sopenharmony_cistatic const int user_pclk_rates[] = {
14728c2ecf20Sopenharmony_ci	13000000, 13000000, 19200000, 19200000,
14738c2ecf20Sopenharmony_ci};
14748c2ecf20Sopenharmony_ci
14758c2ecf20Sopenharmony_cistatic const int user_lrclk_rates[] = {
14768c2ecf20Sopenharmony_ci	44100, 48000, 44100, 48000,
14778c2ecf20Sopenharmony_ci};
14788c2ecf20Sopenharmony_ci
14798c2ecf20Sopenharmony_cistatic const unsigned long long ni_value[] = {
14808c2ecf20Sopenharmony_ci	3528, 768, 441, 8
14818c2ecf20Sopenharmony_ci};
14828c2ecf20Sopenharmony_ci
14838c2ecf20Sopenharmony_cistatic const unsigned long long mi_value[] = {
14848c2ecf20Sopenharmony_ci	8125, 1625, 1500, 25
14858c2ecf20Sopenharmony_ci};
14868c2ecf20Sopenharmony_ci
14878c2ecf20Sopenharmony_cistatic void max98090_configure_bclk(struct snd_soc_component *component)
14888c2ecf20Sopenharmony_ci{
14898c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
14908c2ecf20Sopenharmony_ci	unsigned long long ni;
14918c2ecf20Sopenharmony_ci	int i;
14928c2ecf20Sopenharmony_ci
14938c2ecf20Sopenharmony_ci	if (!max98090->sysclk) {
14948c2ecf20Sopenharmony_ci		dev_err(component->dev, "No SYSCLK configured\n");
14958c2ecf20Sopenharmony_ci		return;
14968c2ecf20Sopenharmony_ci	}
14978c2ecf20Sopenharmony_ci
14988c2ecf20Sopenharmony_ci	if (!max98090->bclk || !max98090->lrclk) {
14998c2ecf20Sopenharmony_ci		dev_err(component->dev, "No audio clocks configured\n");
15008c2ecf20Sopenharmony_ci		return;
15018c2ecf20Sopenharmony_ci	}
15028c2ecf20Sopenharmony_ci
15038c2ecf20Sopenharmony_ci	/* Skip configuration when operating as slave */
15048c2ecf20Sopenharmony_ci	if (!(snd_soc_component_read(component, M98090_REG_MASTER_MODE) &
15058c2ecf20Sopenharmony_ci		M98090_MAS_MASK)) {
15068c2ecf20Sopenharmony_ci		return;
15078c2ecf20Sopenharmony_ci	}
15088c2ecf20Sopenharmony_ci
15098c2ecf20Sopenharmony_ci	/* Check for supported PCLK to LRCLK ratios */
15108c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(pclk_rates); i++) {
15118c2ecf20Sopenharmony_ci		if ((pclk_rates[i] == max98090->sysclk) &&
15128c2ecf20Sopenharmony_ci			(lrclk_rates[i] == max98090->lrclk)) {
15138c2ecf20Sopenharmony_ci			dev_dbg(component->dev,
15148c2ecf20Sopenharmony_ci				"Found supported PCLK to LRCLK rates 0x%x\n",
15158c2ecf20Sopenharmony_ci				i + 0x8);
15168c2ecf20Sopenharmony_ci
15178c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15188c2ecf20Sopenharmony_ci				M98090_FREQ_MASK,
15198c2ecf20Sopenharmony_ci				(i + 0x8) << M98090_FREQ_SHIFT);
15208c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15218c2ecf20Sopenharmony_ci				M98090_USE_M1_MASK, 0);
15228c2ecf20Sopenharmony_ci			return;
15238c2ecf20Sopenharmony_ci		}
15248c2ecf20Sopenharmony_ci	}
15258c2ecf20Sopenharmony_ci
15268c2ecf20Sopenharmony_ci	/* Check for user calculated MI and NI ratios */
15278c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(user_pclk_rates); i++) {
15288c2ecf20Sopenharmony_ci		if ((user_pclk_rates[i] == max98090->sysclk) &&
15298c2ecf20Sopenharmony_ci			(user_lrclk_rates[i] == max98090->lrclk)) {
15308c2ecf20Sopenharmony_ci			dev_dbg(component->dev,
15318c2ecf20Sopenharmony_ci				"Found user supported PCLK to LRCLK rates\n");
15328c2ecf20Sopenharmony_ci			dev_dbg(component->dev, "i %d ni %lld mi %lld\n",
15338c2ecf20Sopenharmony_ci				i, ni_value[i], mi_value[i]);
15348c2ecf20Sopenharmony_ci
15358c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15368c2ecf20Sopenharmony_ci				M98090_FREQ_MASK, 0);
15378c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15388c2ecf20Sopenharmony_ci				M98090_USE_M1_MASK,
15398c2ecf20Sopenharmony_ci					1 << M98090_USE_M1_SHIFT);
15408c2ecf20Sopenharmony_ci
15418c2ecf20Sopenharmony_ci			snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB,
15428c2ecf20Sopenharmony_ci				(ni_value[i] >> 8) & 0x7F);
15438c2ecf20Sopenharmony_ci			snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB,
15448c2ecf20Sopenharmony_ci				ni_value[i] & 0xFF);
15458c2ecf20Sopenharmony_ci			snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_MI_MSB,
15468c2ecf20Sopenharmony_ci				(mi_value[i] >> 8) & 0x7F);
15478c2ecf20Sopenharmony_ci			snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_MI_LSB,
15488c2ecf20Sopenharmony_ci				mi_value[i] & 0xFF);
15498c2ecf20Sopenharmony_ci
15508c2ecf20Sopenharmony_ci			return;
15518c2ecf20Sopenharmony_ci		}
15528c2ecf20Sopenharmony_ci	}
15538c2ecf20Sopenharmony_ci
15548c2ecf20Sopenharmony_ci	/*
15558c2ecf20Sopenharmony_ci	 * Calculate based on MI = 65536 (not as good as either method above)
15568c2ecf20Sopenharmony_ci	 */
15578c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15588c2ecf20Sopenharmony_ci		M98090_FREQ_MASK, 0);
15598c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
15608c2ecf20Sopenharmony_ci		M98090_USE_M1_MASK, 0);
15618c2ecf20Sopenharmony_ci
15628c2ecf20Sopenharmony_ci	/*
15638c2ecf20Sopenharmony_ci	 * Configure NI when operating as master
15648c2ecf20Sopenharmony_ci	 * Note: There is a small, but significant audio quality improvement
15658c2ecf20Sopenharmony_ci	 * by calculating ni and mi.
15668c2ecf20Sopenharmony_ci	 */
15678c2ecf20Sopenharmony_ci	ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL)
15688c2ecf20Sopenharmony_ci			* (unsigned long long int)max98090->lrclk;
15698c2ecf20Sopenharmony_ci	do_div(ni, (unsigned long long int)max98090->sysclk);
15708c2ecf20Sopenharmony_ci	dev_info(component->dev, "No better method found\n");
15718c2ecf20Sopenharmony_ci	dev_info(component->dev, "Calculating ni %lld with mi 65536\n", ni);
15728c2ecf20Sopenharmony_ci	snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB,
15738c2ecf20Sopenharmony_ci		(ni >> 8) & 0x7F);
15748c2ecf20Sopenharmony_ci	snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB, ni & 0xFF);
15758c2ecf20Sopenharmony_ci}
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_cistatic int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai,
15788c2ecf20Sopenharmony_ci				 unsigned int fmt)
15798c2ecf20Sopenharmony_ci{
15808c2ecf20Sopenharmony_ci	struct snd_soc_component *component = codec_dai->component;
15818c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
15828c2ecf20Sopenharmony_ci	struct max98090_cdata *cdata;
15838c2ecf20Sopenharmony_ci	u8 regval;
15848c2ecf20Sopenharmony_ci
15858c2ecf20Sopenharmony_ci	max98090->dai_fmt = fmt;
15868c2ecf20Sopenharmony_ci	cdata = &max98090->dai[0];
15878c2ecf20Sopenharmony_ci
15888c2ecf20Sopenharmony_ci	if (fmt != cdata->fmt) {
15898c2ecf20Sopenharmony_ci		cdata->fmt = fmt;
15908c2ecf20Sopenharmony_ci
15918c2ecf20Sopenharmony_ci		regval = 0;
15928c2ecf20Sopenharmony_ci		switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
15938c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_CBS_CFS:
15948c2ecf20Sopenharmony_ci			/* Set to slave mode PLL - MAS mode off */
15958c2ecf20Sopenharmony_ci			snd_soc_component_write(component,
15968c2ecf20Sopenharmony_ci				M98090_REG_CLOCK_RATIO_NI_MSB, 0x00);
15978c2ecf20Sopenharmony_ci			snd_soc_component_write(component,
15988c2ecf20Sopenharmony_ci				M98090_REG_CLOCK_RATIO_NI_LSB, 0x00);
15998c2ecf20Sopenharmony_ci			snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE,
16008c2ecf20Sopenharmony_ci				M98090_USE_M1_MASK, 0);
16018c2ecf20Sopenharmony_ci			max98090->master = false;
16028c2ecf20Sopenharmony_ci			break;
16038c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_CBM_CFM:
16048c2ecf20Sopenharmony_ci			/* Set to master mode */
16058c2ecf20Sopenharmony_ci			if (max98090->tdm_slots == 4) {
16068c2ecf20Sopenharmony_ci				/* TDM */
16078c2ecf20Sopenharmony_ci				regval |= M98090_MAS_MASK |
16088c2ecf20Sopenharmony_ci					M98090_BSEL_64;
16098c2ecf20Sopenharmony_ci			} else if (max98090->tdm_slots == 3) {
16108c2ecf20Sopenharmony_ci				/* TDM */
16118c2ecf20Sopenharmony_ci				regval |= M98090_MAS_MASK |
16128c2ecf20Sopenharmony_ci					M98090_BSEL_48;
16138c2ecf20Sopenharmony_ci			} else {
16148c2ecf20Sopenharmony_ci				/* Few TDM slots, or No TDM */
16158c2ecf20Sopenharmony_ci				regval |= M98090_MAS_MASK |
16168c2ecf20Sopenharmony_ci					M98090_BSEL_32;
16178c2ecf20Sopenharmony_ci			}
16188c2ecf20Sopenharmony_ci			max98090->master = true;
16198c2ecf20Sopenharmony_ci			break;
16208c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_CBS_CFM:
16218c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_CBM_CFS:
16228c2ecf20Sopenharmony_ci		default:
16238c2ecf20Sopenharmony_ci			dev_err(component->dev, "DAI clock mode unsupported");
16248c2ecf20Sopenharmony_ci			return -EINVAL;
16258c2ecf20Sopenharmony_ci		}
16268c2ecf20Sopenharmony_ci		snd_soc_component_write(component, M98090_REG_MASTER_MODE, regval);
16278c2ecf20Sopenharmony_ci
16288c2ecf20Sopenharmony_ci		regval = 0;
16298c2ecf20Sopenharmony_ci		switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
16308c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_I2S:
16318c2ecf20Sopenharmony_ci			regval |= M98090_DLY_MASK;
16328c2ecf20Sopenharmony_ci			break;
16338c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_LEFT_J:
16348c2ecf20Sopenharmony_ci			break;
16358c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_RIGHT_J:
16368c2ecf20Sopenharmony_ci			regval |= M98090_RJ_MASK;
16378c2ecf20Sopenharmony_ci			break;
16388c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_DSP_A:
16398c2ecf20Sopenharmony_ci			/* Not supported mode */
16408c2ecf20Sopenharmony_ci		default:
16418c2ecf20Sopenharmony_ci			dev_err(component->dev, "DAI format unsupported");
16428c2ecf20Sopenharmony_ci			return -EINVAL;
16438c2ecf20Sopenharmony_ci		}
16448c2ecf20Sopenharmony_ci
16458c2ecf20Sopenharmony_ci		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
16468c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_NB_NF:
16478c2ecf20Sopenharmony_ci			break;
16488c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_NB_IF:
16498c2ecf20Sopenharmony_ci			regval |= M98090_WCI_MASK;
16508c2ecf20Sopenharmony_ci			break;
16518c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_IB_NF:
16528c2ecf20Sopenharmony_ci			regval |= M98090_BCI_MASK;
16538c2ecf20Sopenharmony_ci			break;
16548c2ecf20Sopenharmony_ci		case SND_SOC_DAIFMT_IB_IF:
16558c2ecf20Sopenharmony_ci			regval |= M98090_BCI_MASK|M98090_WCI_MASK;
16568c2ecf20Sopenharmony_ci			break;
16578c2ecf20Sopenharmony_ci		default:
16588c2ecf20Sopenharmony_ci			dev_err(component->dev, "DAI invert mode unsupported");
16598c2ecf20Sopenharmony_ci			return -EINVAL;
16608c2ecf20Sopenharmony_ci		}
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_ci		/*
16638c2ecf20Sopenharmony_ci		 * This accommodates an inverted logic in the MAX98090 chip
16648c2ecf20Sopenharmony_ci		 * for Bit Clock Invert (BCI). The inverted logic is only
16658c2ecf20Sopenharmony_ci		 * seen for the case of TDM mode. The remaining cases have
16668c2ecf20Sopenharmony_ci		 * normal logic.
16678c2ecf20Sopenharmony_ci		 */
16688c2ecf20Sopenharmony_ci		if (max98090->tdm_slots > 1)
16698c2ecf20Sopenharmony_ci			regval ^= M98090_BCI_MASK;
16708c2ecf20Sopenharmony_ci
16718c2ecf20Sopenharmony_ci		snd_soc_component_write(component,
16728c2ecf20Sopenharmony_ci			M98090_REG_INTERFACE_FORMAT, regval);
16738c2ecf20Sopenharmony_ci	}
16748c2ecf20Sopenharmony_ci
16758c2ecf20Sopenharmony_ci	return 0;
16768c2ecf20Sopenharmony_ci}
16778c2ecf20Sopenharmony_ci
16788c2ecf20Sopenharmony_cistatic int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai,
16798c2ecf20Sopenharmony_ci	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
16808c2ecf20Sopenharmony_ci{
16818c2ecf20Sopenharmony_ci	struct snd_soc_component *component = codec_dai->component;
16828c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
16838c2ecf20Sopenharmony_ci	struct max98090_cdata *cdata;
16848c2ecf20Sopenharmony_ci	cdata = &max98090->dai[0];
16858c2ecf20Sopenharmony_ci
16868c2ecf20Sopenharmony_ci	if (slots < 0 || slots > 4)
16878c2ecf20Sopenharmony_ci		return -EINVAL;
16888c2ecf20Sopenharmony_ci
16898c2ecf20Sopenharmony_ci	max98090->tdm_slots = slots;
16908c2ecf20Sopenharmony_ci	max98090->tdm_width = slot_width;
16918c2ecf20Sopenharmony_ci
16928c2ecf20Sopenharmony_ci	if (max98090->tdm_slots > 1) {
16938c2ecf20Sopenharmony_ci		/* SLOTL SLOTR SLOTDLY */
16948c2ecf20Sopenharmony_ci		snd_soc_component_write(component, M98090_REG_TDM_FORMAT,
16958c2ecf20Sopenharmony_ci			0 << M98090_TDM_SLOTL_SHIFT |
16968c2ecf20Sopenharmony_ci			1 << M98090_TDM_SLOTR_SHIFT |
16978c2ecf20Sopenharmony_ci			0 << M98090_TDM_SLOTDLY_SHIFT);
16988c2ecf20Sopenharmony_ci
16998c2ecf20Sopenharmony_ci		/* FSW TDM */
17008c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_TDM_CONTROL,
17018c2ecf20Sopenharmony_ci			M98090_TDM_MASK,
17028c2ecf20Sopenharmony_ci			M98090_TDM_MASK);
17038c2ecf20Sopenharmony_ci	}
17048c2ecf20Sopenharmony_ci
17058c2ecf20Sopenharmony_ci	/*
17068c2ecf20Sopenharmony_ci	 * Normally advisable to set TDM first, but this permits either order
17078c2ecf20Sopenharmony_ci	 */
17088c2ecf20Sopenharmony_ci	cdata->fmt = 0;
17098c2ecf20Sopenharmony_ci	max98090_dai_set_fmt(codec_dai, max98090->dai_fmt);
17108c2ecf20Sopenharmony_ci
17118c2ecf20Sopenharmony_ci	return 0;
17128c2ecf20Sopenharmony_ci}
17138c2ecf20Sopenharmony_ci
17148c2ecf20Sopenharmony_cistatic int max98090_set_bias_level(struct snd_soc_component *component,
17158c2ecf20Sopenharmony_ci				   enum snd_soc_bias_level level)
17168c2ecf20Sopenharmony_ci{
17178c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
17188c2ecf20Sopenharmony_ci	int ret;
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_ci	switch (level) {
17218c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_ON:
17228c2ecf20Sopenharmony_ci		break;
17238c2ecf20Sopenharmony_ci
17248c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_PREPARE:
17258c2ecf20Sopenharmony_ci		/*
17268c2ecf20Sopenharmony_ci		 * SND_SOC_BIAS_PREPARE is called while preparing for a
17278c2ecf20Sopenharmony_ci		 * transition to ON or away from ON. If current bias_level
17288c2ecf20Sopenharmony_ci		 * is SND_SOC_BIAS_ON, then it is preparing for a transition
17298c2ecf20Sopenharmony_ci		 * away from ON. Disable the clock in that case, otherwise
17308c2ecf20Sopenharmony_ci		 * enable it.
17318c2ecf20Sopenharmony_ci		 */
17328c2ecf20Sopenharmony_ci		if (IS_ERR(max98090->mclk))
17338c2ecf20Sopenharmony_ci			break;
17348c2ecf20Sopenharmony_ci
17358c2ecf20Sopenharmony_ci		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) {
17368c2ecf20Sopenharmony_ci			clk_disable_unprepare(max98090->mclk);
17378c2ecf20Sopenharmony_ci		} else {
17388c2ecf20Sopenharmony_ci			ret = clk_prepare_enable(max98090->mclk);
17398c2ecf20Sopenharmony_ci			if (ret)
17408c2ecf20Sopenharmony_ci				return ret;
17418c2ecf20Sopenharmony_ci		}
17428c2ecf20Sopenharmony_ci		break;
17438c2ecf20Sopenharmony_ci
17448c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_STANDBY:
17458c2ecf20Sopenharmony_ci		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
17468c2ecf20Sopenharmony_ci			ret = regcache_sync(max98090->regmap);
17478c2ecf20Sopenharmony_ci			if (ret != 0) {
17488c2ecf20Sopenharmony_ci				dev_err(component->dev,
17498c2ecf20Sopenharmony_ci					"Failed to sync cache: %d\n", ret);
17508c2ecf20Sopenharmony_ci				return ret;
17518c2ecf20Sopenharmony_ci			}
17528c2ecf20Sopenharmony_ci		}
17538c2ecf20Sopenharmony_ci		break;
17548c2ecf20Sopenharmony_ci
17558c2ecf20Sopenharmony_ci	case SND_SOC_BIAS_OFF:
17568c2ecf20Sopenharmony_ci		/* Set internal pull-up to lowest power mode */
17578c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT,
17588c2ecf20Sopenharmony_ci			M98090_JDWK_MASK, M98090_JDWK_MASK);
17598c2ecf20Sopenharmony_ci		regcache_mark_dirty(max98090->regmap);
17608c2ecf20Sopenharmony_ci		break;
17618c2ecf20Sopenharmony_ci	}
17628c2ecf20Sopenharmony_ci	return 0;
17638c2ecf20Sopenharmony_ci}
17648c2ecf20Sopenharmony_ci
17658c2ecf20Sopenharmony_cistatic const int dmic_divisors[] = { 2, 3, 4, 5, 6, 8 };
17668c2ecf20Sopenharmony_ci
17678c2ecf20Sopenharmony_cistatic const int comp_lrclk_rates[] = {
17688c2ecf20Sopenharmony_ci	8000, 16000, 32000, 44100, 48000, 96000
17698c2ecf20Sopenharmony_ci};
17708c2ecf20Sopenharmony_ci
17718c2ecf20Sopenharmony_cistruct dmic_table {
17728c2ecf20Sopenharmony_ci	int pclk;
17738c2ecf20Sopenharmony_ci	struct {
17748c2ecf20Sopenharmony_ci		int freq;
17758c2ecf20Sopenharmony_ci		int comp[6]; /* One each for 8, 16, 32, 44.1, 48, and 96 kHz */
17768c2ecf20Sopenharmony_ci	} settings[6]; /* One for each dmic divisor. */
17778c2ecf20Sopenharmony_ci};
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_cistatic const struct dmic_table dmic_table[] = { /* One for each pclk freq. */
17808c2ecf20Sopenharmony_ci	{
17818c2ecf20Sopenharmony_ci		.pclk = 11289600,
17828c2ecf20Sopenharmony_ci		.settings = {
17838c2ecf20Sopenharmony_ci			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
17848c2ecf20Sopenharmony_ci			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
17858c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
17868c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 6, 6, 6, 6 } },
17878c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
17888c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
17898c2ecf20Sopenharmony_ci		},
17908c2ecf20Sopenharmony_ci	},
17918c2ecf20Sopenharmony_ci	{
17928c2ecf20Sopenharmony_ci		.pclk = 12000000,
17938c2ecf20Sopenharmony_ci		.settings = {
17948c2ecf20Sopenharmony_ci			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
17958c2ecf20Sopenharmony_ci			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
17968c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
17978c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
17988c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
17998c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
18008c2ecf20Sopenharmony_ci		}
18018c2ecf20Sopenharmony_ci	},
18028c2ecf20Sopenharmony_ci	{
18038c2ecf20Sopenharmony_ci		.pclk = 12288000,
18048c2ecf20Sopenharmony_ci		.settings = {
18058c2ecf20Sopenharmony_ci			{ .freq = 2, .comp = { 7, 8, 3, 3, 3, 3 } },
18068c2ecf20Sopenharmony_ci			{ .freq = 1, .comp = { 7, 8, 2, 2, 2, 2 } },
18078c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
18088c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 6, 6, 6, 6 } },
18098c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
18108c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 3, 3, 3, 3 } },
18118c2ecf20Sopenharmony_ci		}
18128c2ecf20Sopenharmony_ci	},
18138c2ecf20Sopenharmony_ci	{
18148c2ecf20Sopenharmony_ci		.pclk = 13000000,
18158c2ecf20Sopenharmony_ci		.settings = {
18168c2ecf20Sopenharmony_ci			{ .freq = 2, .comp = { 7, 8, 1, 1, 1, 1 } },
18178c2ecf20Sopenharmony_ci			{ .freq = 1, .comp = { 7, 8, 0, 0, 0, 0 } },
18188c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
18198c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 4, 4, 5, 5 } },
18208c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
18218c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 1, 1, 1, 1 } },
18228c2ecf20Sopenharmony_ci		}
18238c2ecf20Sopenharmony_ci	},
18248c2ecf20Sopenharmony_ci	{
18258c2ecf20Sopenharmony_ci		.pclk = 19200000,
18268c2ecf20Sopenharmony_ci		.settings = {
18278c2ecf20Sopenharmony_ci			{ .freq = 2, .comp = { 0, 0, 0, 0, 0, 0 } },
18288c2ecf20Sopenharmony_ci			{ .freq = 1, .comp = { 7, 8, 1, 1, 1, 1 } },
18298c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
18308c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 2, 2, 3, 3 } },
18318c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 1, 1, 2, 2 } },
18328c2ecf20Sopenharmony_ci			{ .freq = 0, .comp = { 7, 8, 5, 5, 6, 6 } },
18338c2ecf20Sopenharmony_ci		}
18348c2ecf20Sopenharmony_ci	},
18358c2ecf20Sopenharmony_ci};
18368c2ecf20Sopenharmony_ci
18378c2ecf20Sopenharmony_cistatic int max98090_find_divisor(int target_freq, int pclk)
18388c2ecf20Sopenharmony_ci{
18398c2ecf20Sopenharmony_ci	int current_diff = INT_MAX;
18408c2ecf20Sopenharmony_ci	int test_diff = INT_MAX;
18418c2ecf20Sopenharmony_ci	int divisor_index = 0;
18428c2ecf20Sopenharmony_ci	int i;
18438c2ecf20Sopenharmony_ci
18448c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(dmic_divisors); i++) {
18458c2ecf20Sopenharmony_ci		test_diff = abs(target_freq - (pclk / dmic_divisors[i]));
18468c2ecf20Sopenharmony_ci		if (test_diff < current_diff) {
18478c2ecf20Sopenharmony_ci			current_diff = test_diff;
18488c2ecf20Sopenharmony_ci			divisor_index = i;
18498c2ecf20Sopenharmony_ci		}
18508c2ecf20Sopenharmony_ci	}
18518c2ecf20Sopenharmony_ci
18528c2ecf20Sopenharmony_ci	return divisor_index;
18538c2ecf20Sopenharmony_ci}
18548c2ecf20Sopenharmony_ci
18558c2ecf20Sopenharmony_cistatic int max98090_find_closest_pclk(int pclk)
18568c2ecf20Sopenharmony_ci{
18578c2ecf20Sopenharmony_ci	int m1;
18588c2ecf20Sopenharmony_ci	int m2;
18598c2ecf20Sopenharmony_ci	int i;
18608c2ecf20Sopenharmony_ci
18618c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(dmic_table); i++) {
18628c2ecf20Sopenharmony_ci		if (pclk == dmic_table[i].pclk)
18638c2ecf20Sopenharmony_ci			return i;
18648c2ecf20Sopenharmony_ci		if (pclk < dmic_table[i].pclk) {
18658c2ecf20Sopenharmony_ci			if (i == 0)
18668c2ecf20Sopenharmony_ci				return i;
18678c2ecf20Sopenharmony_ci			m1 = pclk - dmic_table[i-1].pclk;
18688c2ecf20Sopenharmony_ci			m2 = dmic_table[i].pclk - pclk;
18698c2ecf20Sopenharmony_ci			if (m1 < m2)
18708c2ecf20Sopenharmony_ci				return i - 1;
18718c2ecf20Sopenharmony_ci			else
18728c2ecf20Sopenharmony_ci				return i;
18738c2ecf20Sopenharmony_ci		}
18748c2ecf20Sopenharmony_ci	}
18758c2ecf20Sopenharmony_ci
18768c2ecf20Sopenharmony_ci	return -EINVAL;
18778c2ecf20Sopenharmony_ci}
18788c2ecf20Sopenharmony_ci
18798c2ecf20Sopenharmony_cistatic int max98090_configure_dmic(struct max98090_priv *max98090,
18808c2ecf20Sopenharmony_ci				   int target_dmic_clk, int pclk, int fs)
18818c2ecf20Sopenharmony_ci{
18828c2ecf20Sopenharmony_ci	int micclk_index;
18838c2ecf20Sopenharmony_ci	int pclk_index;
18848c2ecf20Sopenharmony_ci	int dmic_freq;
18858c2ecf20Sopenharmony_ci	int dmic_comp;
18868c2ecf20Sopenharmony_ci	int i;
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_ci	pclk_index = max98090_find_closest_pclk(pclk);
18898c2ecf20Sopenharmony_ci	if (pclk_index < 0)
18908c2ecf20Sopenharmony_ci		return pclk_index;
18918c2ecf20Sopenharmony_ci
18928c2ecf20Sopenharmony_ci	micclk_index = max98090_find_divisor(target_dmic_clk, pclk);
18938c2ecf20Sopenharmony_ci
18948c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(comp_lrclk_rates) - 1; i++) {
18958c2ecf20Sopenharmony_ci		if (fs <= (comp_lrclk_rates[i] + comp_lrclk_rates[i+1]) / 2)
18968c2ecf20Sopenharmony_ci			break;
18978c2ecf20Sopenharmony_ci	}
18988c2ecf20Sopenharmony_ci
18998c2ecf20Sopenharmony_ci	dmic_freq = dmic_table[pclk_index].settings[micclk_index].freq;
19008c2ecf20Sopenharmony_ci	dmic_comp = dmic_table[pclk_index].settings[micclk_index].comp[i];
19018c2ecf20Sopenharmony_ci
19028c2ecf20Sopenharmony_ci	regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_ENABLE,
19038c2ecf20Sopenharmony_ci			   M98090_MICCLK_MASK,
19048c2ecf20Sopenharmony_ci			   micclk_index << M98090_MICCLK_SHIFT);
19058c2ecf20Sopenharmony_ci
19068c2ecf20Sopenharmony_ci	regmap_update_bits(max98090->regmap, M98090_REG_DIGITAL_MIC_CONFIG,
19078c2ecf20Sopenharmony_ci			   M98090_DMIC_COMP_MASK | M98090_DMIC_FREQ_MASK,
19088c2ecf20Sopenharmony_ci			   dmic_comp << M98090_DMIC_COMP_SHIFT |
19098c2ecf20Sopenharmony_ci			   dmic_freq << M98090_DMIC_FREQ_SHIFT);
19108c2ecf20Sopenharmony_ci
19118c2ecf20Sopenharmony_ci	return 0;
19128c2ecf20Sopenharmony_ci}
19138c2ecf20Sopenharmony_ci
19148c2ecf20Sopenharmony_cistatic int max98090_dai_startup(struct snd_pcm_substream *substream,
19158c2ecf20Sopenharmony_ci				struct snd_soc_dai *dai)
19168c2ecf20Sopenharmony_ci{
19178c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
19188c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
19198c2ecf20Sopenharmony_ci	unsigned int fmt = max98090->dai_fmt;
19208c2ecf20Sopenharmony_ci
19218c2ecf20Sopenharmony_ci	/* Remove 24-bit format support if it is not in right justified mode. */
19228c2ecf20Sopenharmony_ci	if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_RIGHT_J) {
19238c2ecf20Sopenharmony_ci		substream->runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE;
19248c2ecf20Sopenharmony_ci		snd_pcm_hw_constraint_msbits(substream->runtime, 0, 16, 16);
19258c2ecf20Sopenharmony_ci	}
19268c2ecf20Sopenharmony_ci	return 0;
19278c2ecf20Sopenharmony_ci}
19288c2ecf20Sopenharmony_ci
19298c2ecf20Sopenharmony_cistatic int max98090_dai_hw_params(struct snd_pcm_substream *substream,
19308c2ecf20Sopenharmony_ci				   struct snd_pcm_hw_params *params,
19318c2ecf20Sopenharmony_ci				   struct snd_soc_dai *dai)
19328c2ecf20Sopenharmony_ci{
19338c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
19348c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
19358c2ecf20Sopenharmony_ci	struct max98090_cdata *cdata;
19368c2ecf20Sopenharmony_ci
19378c2ecf20Sopenharmony_ci	cdata = &max98090->dai[0];
19388c2ecf20Sopenharmony_ci	max98090->bclk = snd_soc_params_to_bclk(params);
19398c2ecf20Sopenharmony_ci	if (params_channels(params) == 1)
19408c2ecf20Sopenharmony_ci		max98090->bclk *= 2;
19418c2ecf20Sopenharmony_ci
19428c2ecf20Sopenharmony_ci	max98090->lrclk = params_rate(params);
19438c2ecf20Sopenharmony_ci
19448c2ecf20Sopenharmony_ci	switch (params_width(params)) {
19458c2ecf20Sopenharmony_ci	case 16:
19468c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT,
19478c2ecf20Sopenharmony_ci			M98090_WS_MASK, 0);
19488c2ecf20Sopenharmony_ci		break;
19498c2ecf20Sopenharmony_ci	default:
19508c2ecf20Sopenharmony_ci		return -EINVAL;
19518c2ecf20Sopenharmony_ci	}
19528c2ecf20Sopenharmony_ci
19538c2ecf20Sopenharmony_ci	if (max98090->master)
19548c2ecf20Sopenharmony_ci		max98090_configure_bclk(component);
19558c2ecf20Sopenharmony_ci
19568c2ecf20Sopenharmony_ci	cdata->rate = max98090->lrclk;
19578c2ecf20Sopenharmony_ci
19588c2ecf20Sopenharmony_ci	/* Update filter mode */
19598c2ecf20Sopenharmony_ci	if (max98090->lrclk < 24000)
19608c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG,
19618c2ecf20Sopenharmony_ci			M98090_MODE_MASK, 0);
19628c2ecf20Sopenharmony_ci	else
19638c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG,
19648c2ecf20Sopenharmony_ci			M98090_MODE_MASK, M98090_MODE_MASK);
19658c2ecf20Sopenharmony_ci
19668c2ecf20Sopenharmony_ci	/* Update sample rate mode */
19678c2ecf20Sopenharmony_ci	if (max98090->lrclk < 50000)
19688c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG,
19698c2ecf20Sopenharmony_ci			M98090_DHF_MASK, 0);
19708c2ecf20Sopenharmony_ci	else
19718c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG,
19728c2ecf20Sopenharmony_ci			M98090_DHF_MASK, M98090_DHF_MASK);
19738c2ecf20Sopenharmony_ci
19748c2ecf20Sopenharmony_ci	max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk,
19758c2ecf20Sopenharmony_ci				max98090->lrclk);
19768c2ecf20Sopenharmony_ci
19778c2ecf20Sopenharmony_ci	return 0;
19788c2ecf20Sopenharmony_ci}
19798c2ecf20Sopenharmony_ci
19808c2ecf20Sopenharmony_ci/*
19818c2ecf20Sopenharmony_ci * PLL / Sysclk
19828c2ecf20Sopenharmony_ci */
19838c2ecf20Sopenharmony_cistatic int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
19848c2ecf20Sopenharmony_ci				   int clk_id, unsigned int freq, int dir)
19858c2ecf20Sopenharmony_ci{
19868c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
19878c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
19888c2ecf20Sopenharmony_ci
19898c2ecf20Sopenharmony_ci	/* Requested clock frequency is already setup */
19908c2ecf20Sopenharmony_ci	if (freq == max98090->sysclk)
19918c2ecf20Sopenharmony_ci		return 0;
19928c2ecf20Sopenharmony_ci
19938c2ecf20Sopenharmony_ci	if (!IS_ERR(max98090->mclk)) {
19948c2ecf20Sopenharmony_ci		freq = clk_round_rate(max98090->mclk, freq);
19958c2ecf20Sopenharmony_ci		clk_set_rate(max98090->mclk, freq);
19968c2ecf20Sopenharmony_ci	}
19978c2ecf20Sopenharmony_ci
19988c2ecf20Sopenharmony_ci	/* Setup clocks for slave mode, and using the PLL
19998c2ecf20Sopenharmony_ci	 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
20008c2ecf20Sopenharmony_ci	 *		 0x02 (when master clk is 20MHz to 40MHz)..
20018c2ecf20Sopenharmony_ci	 *		 0x03 (when master clk is 40MHz to 60MHz)..
20028c2ecf20Sopenharmony_ci	 */
20038c2ecf20Sopenharmony_ci	if ((freq >= 10000000) && (freq <= 20000000)) {
20048c2ecf20Sopenharmony_ci		snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK,
20058c2ecf20Sopenharmony_ci			M98090_PSCLK_DIV1);
20068c2ecf20Sopenharmony_ci		max98090->pclk = freq;
20078c2ecf20Sopenharmony_ci	} else if ((freq > 20000000) && (freq <= 40000000)) {
20088c2ecf20Sopenharmony_ci		snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK,
20098c2ecf20Sopenharmony_ci			M98090_PSCLK_DIV2);
20108c2ecf20Sopenharmony_ci		max98090->pclk = freq >> 1;
20118c2ecf20Sopenharmony_ci	} else if ((freq > 40000000) && (freq <= 60000000)) {
20128c2ecf20Sopenharmony_ci		snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK,
20138c2ecf20Sopenharmony_ci			M98090_PSCLK_DIV4);
20148c2ecf20Sopenharmony_ci		max98090->pclk = freq >> 2;
20158c2ecf20Sopenharmony_ci	} else {
20168c2ecf20Sopenharmony_ci		dev_err(component->dev, "Invalid master clock frequency\n");
20178c2ecf20Sopenharmony_ci		return -EINVAL;
20188c2ecf20Sopenharmony_ci	}
20198c2ecf20Sopenharmony_ci
20208c2ecf20Sopenharmony_ci	max98090->sysclk = freq;
20218c2ecf20Sopenharmony_ci
20228c2ecf20Sopenharmony_ci	return 0;
20238c2ecf20Sopenharmony_ci}
20248c2ecf20Sopenharmony_ci
20258c2ecf20Sopenharmony_cistatic int max98090_dai_mute(struct snd_soc_dai *codec_dai, int mute,
20268c2ecf20Sopenharmony_ci			     int direction)
20278c2ecf20Sopenharmony_ci{
20288c2ecf20Sopenharmony_ci	struct snd_soc_component *component = codec_dai->component;
20298c2ecf20Sopenharmony_ci	int regval;
20308c2ecf20Sopenharmony_ci
20318c2ecf20Sopenharmony_ci	regval = mute ? M98090_DVM_MASK : 0;
20328c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_DAI_PLAYBACK_LEVEL,
20338c2ecf20Sopenharmony_ci		M98090_DVM_MASK, regval);
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_ci	return 0;
20368c2ecf20Sopenharmony_ci}
20378c2ecf20Sopenharmony_ci
20388c2ecf20Sopenharmony_cistatic int max98090_dai_trigger(struct snd_pcm_substream *substream, int cmd,
20398c2ecf20Sopenharmony_ci				struct snd_soc_dai *dai)
20408c2ecf20Sopenharmony_ci{
20418c2ecf20Sopenharmony_ci	struct snd_soc_component *component = dai->component;
20428c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci	switch (cmd) {
20458c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_START:
20468c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_RESUME:
20478c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
20488c2ecf20Sopenharmony_ci		if (!max98090->master && snd_soc_dai_active(dai) == 1)
20498c2ecf20Sopenharmony_ci			queue_delayed_work(system_power_efficient_wq,
20508c2ecf20Sopenharmony_ci					   &max98090->pll_det_enable_work,
20518c2ecf20Sopenharmony_ci					   msecs_to_jiffies(10));
20528c2ecf20Sopenharmony_ci		break;
20538c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_STOP:
20548c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_SUSPEND:
20558c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
20568c2ecf20Sopenharmony_ci		if (!max98090->master && snd_soc_dai_active(dai) == 1)
20578c2ecf20Sopenharmony_ci			schedule_work(&max98090->pll_det_disable_work);
20588c2ecf20Sopenharmony_ci		break;
20598c2ecf20Sopenharmony_ci	default:
20608c2ecf20Sopenharmony_ci		break;
20618c2ecf20Sopenharmony_ci	}
20628c2ecf20Sopenharmony_ci
20638c2ecf20Sopenharmony_ci	return 0;
20648c2ecf20Sopenharmony_ci}
20658c2ecf20Sopenharmony_ci
20668c2ecf20Sopenharmony_cistatic void max98090_pll_det_enable_work(struct work_struct *work)
20678c2ecf20Sopenharmony_ci{
20688c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 =
20698c2ecf20Sopenharmony_ci		container_of(work, struct max98090_priv,
20708c2ecf20Sopenharmony_ci			     pll_det_enable_work.work);
20718c2ecf20Sopenharmony_ci	struct snd_soc_component *component = max98090->component;
20728c2ecf20Sopenharmony_ci	unsigned int status, mask;
20738c2ecf20Sopenharmony_ci
20748c2ecf20Sopenharmony_ci	/*
20758c2ecf20Sopenharmony_ci	 * Clear status register in order to clear possibly already occurred
20768c2ecf20Sopenharmony_ci	 * PLL unlock. If PLL hasn't still locked, the status will be set
20778c2ecf20Sopenharmony_ci	 * again and PLL unlock interrupt will occur.
20788c2ecf20Sopenharmony_ci	 * Note this will clear all status bits
20798c2ecf20Sopenharmony_ci	 */
20808c2ecf20Sopenharmony_ci	regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status);
20818c2ecf20Sopenharmony_ci
20828c2ecf20Sopenharmony_ci	/*
20838c2ecf20Sopenharmony_ci	 * Queue jack work in case jack state has just changed but handler
20848c2ecf20Sopenharmony_ci	 * hasn't run yet
20858c2ecf20Sopenharmony_ci	 */
20868c2ecf20Sopenharmony_ci	regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask);
20878c2ecf20Sopenharmony_ci	status &= mask;
20888c2ecf20Sopenharmony_ci	if (status & M98090_JDET_MASK)
20898c2ecf20Sopenharmony_ci		queue_delayed_work(system_power_efficient_wq,
20908c2ecf20Sopenharmony_ci				   &max98090->jack_work,
20918c2ecf20Sopenharmony_ci				   msecs_to_jiffies(100));
20928c2ecf20Sopenharmony_ci
20938c2ecf20Sopenharmony_ci	/* Enable PLL unlock interrupt */
20948c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S,
20958c2ecf20Sopenharmony_ci			    M98090_IULK_MASK,
20968c2ecf20Sopenharmony_ci			    1 << M98090_IULK_SHIFT);
20978c2ecf20Sopenharmony_ci}
20988c2ecf20Sopenharmony_ci
20998c2ecf20Sopenharmony_cistatic void max98090_pll_det_disable_work(struct work_struct *work)
21008c2ecf20Sopenharmony_ci{
21018c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 =
21028c2ecf20Sopenharmony_ci		container_of(work, struct max98090_priv, pll_det_disable_work);
21038c2ecf20Sopenharmony_ci	struct snd_soc_component *component = max98090->component;
21048c2ecf20Sopenharmony_ci
21058c2ecf20Sopenharmony_ci	cancel_delayed_work_sync(&max98090->pll_det_enable_work);
21068c2ecf20Sopenharmony_ci
21078c2ecf20Sopenharmony_ci	/* Disable PLL unlock interrupt */
21088c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S,
21098c2ecf20Sopenharmony_ci			    M98090_IULK_MASK, 0);
21108c2ecf20Sopenharmony_ci}
21118c2ecf20Sopenharmony_ci
21128c2ecf20Sopenharmony_cistatic void max98090_pll_work(struct max98090_priv *max98090)
21138c2ecf20Sopenharmony_ci{
21148c2ecf20Sopenharmony_ci	struct snd_soc_component *component = max98090->component;
21158c2ecf20Sopenharmony_ci	unsigned int pll;
21168c2ecf20Sopenharmony_ci	int i;
21178c2ecf20Sopenharmony_ci
21188c2ecf20Sopenharmony_ci	if (!snd_soc_component_active(component))
21198c2ecf20Sopenharmony_ci		return;
21208c2ecf20Sopenharmony_ci
21218c2ecf20Sopenharmony_ci	dev_info_ratelimited(component->dev, "PLL unlocked\n");
21228c2ecf20Sopenharmony_ci
21238c2ecf20Sopenharmony_ci	/*
21248c2ecf20Sopenharmony_ci	 * As the datasheet suggested, the maximum PLL lock time should be
21258c2ecf20Sopenharmony_ci	 * 7 msec.  The workaround resets the codec softly by toggling SHDN
21268c2ecf20Sopenharmony_ci	 * off and on if PLL failed to lock for 10 msec.  Notably, there is
21278c2ecf20Sopenharmony_ci	 * no suggested hold time for SHDN off.
21288c2ecf20Sopenharmony_ci	 */
21298c2ecf20Sopenharmony_ci
21308c2ecf20Sopenharmony_ci	/* Toggle shutdown OFF then ON */
21318c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
21328c2ecf20Sopenharmony_ci			    M98090_SHDNN_MASK, 0);
21338c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
21348c2ecf20Sopenharmony_ci			    M98090_SHDNN_MASK, M98090_SHDNN_MASK);
21358c2ecf20Sopenharmony_ci
21368c2ecf20Sopenharmony_ci	for (i = 0; i < 10; ++i) {
21378c2ecf20Sopenharmony_ci		/* Give PLL time to lock */
21388c2ecf20Sopenharmony_ci		usleep_range(1000, 1200);
21398c2ecf20Sopenharmony_ci
21408c2ecf20Sopenharmony_ci		/* Check lock status */
21418c2ecf20Sopenharmony_ci		pll = snd_soc_component_read(
21428c2ecf20Sopenharmony_ci				component, M98090_REG_DEVICE_STATUS);
21438c2ecf20Sopenharmony_ci		if (!(pll & M98090_ULK_MASK))
21448c2ecf20Sopenharmony_ci			break;
21458c2ecf20Sopenharmony_ci	}
21468c2ecf20Sopenharmony_ci}
21478c2ecf20Sopenharmony_ci
21488c2ecf20Sopenharmony_cistatic void max98090_jack_work(struct work_struct *work)
21498c2ecf20Sopenharmony_ci{
21508c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = container_of(work,
21518c2ecf20Sopenharmony_ci		struct max98090_priv,
21528c2ecf20Sopenharmony_ci		jack_work.work);
21538c2ecf20Sopenharmony_ci	struct snd_soc_component *component = max98090->component;
21548c2ecf20Sopenharmony_ci	int status = 0;
21558c2ecf20Sopenharmony_ci	int reg;
21568c2ecf20Sopenharmony_ci
21578c2ecf20Sopenharmony_ci	/* Read a second time */
21588c2ecf20Sopenharmony_ci	if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) {
21598c2ecf20Sopenharmony_ci
21608c2ecf20Sopenharmony_ci		/* Strong pull up allows mic detection */
21618c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT,
21628c2ecf20Sopenharmony_ci			M98090_JDWK_MASK, 0);
21638c2ecf20Sopenharmony_ci
21648c2ecf20Sopenharmony_ci		msleep(50);
21658c2ecf20Sopenharmony_ci
21668c2ecf20Sopenharmony_ci		reg = snd_soc_component_read(component, M98090_REG_JACK_STATUS);
21678c2ecf20Sopenharmony_ci
21688c2ecf20Sopenharmony_ci		/* Weak pull up allows only insertion detection */
21698c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT,
21708c2ecf20Sopenharmony_ci			M98090_JDWK_MASK, M98090_JDWK_MASK);
21718c2ecf20Sopenharmony_ci	} else {
21728c2ecf20Sopenharmony_ci		reg = snd_soc_component_read(component, M98090_REG_JACK_STATUS);
21738c2ecf20Sopenharmony_ci	}
21748c2ecf20Sopenharmony_ci
21758c2ecf20Sopenharmony_ci	reg = snd_soc_component_read(component, M98090_REG_JACK_STATUS);
21768c2ecf20Sopenharmony_ci
21778c2ecf20Sopenharmony_ci	switch (reg & (M98090_LSNS_MASK | M98090_JKSNS_MASK)) {
21788c2ecf20Sopenharmony_ci		case M98090_LSNS_MASK | M98090_JKSNS_MASK:
21798c2ecf20Sopenharmony_ci			dev_dbg(component->dev, "No Headset Detected\n");
21808c2ecf20Sopenharmony_ci
21818c2ecf20Sopenharmony_ci			max98090->jack_state = M98090_JACK_STATE_NO_HEADSET;
21828c2ecf20Sopenharmony_ci
21838c2ecf20Sopenharmony_ci			status |= 0;
21848c2ecf20Sopenharmony_ci
21858c2ecf20Sopenharmony_ci			break;
21868c2ecf20Sopenharmony_ci
21878c2ecf20Sopenharmony_ci		case 0:
21888c2ecf20Sopenharmony_ci			if (max98090->jack_state ==
21898c2ecf20Sopenharmony_ci				M98090_JACK_STATE_HEADSET) {
21908c2ecf20Sopenharmony_ci
21918c2ecf20Sopenharmony_ci				dev_dbg(component->dev,
21928c2ecf20Sopenharmony_ci					"Headset Button Down Detected\n");
21938c2ecf20Sopenharmony_ci
21948c2ecf20Sopenharmony_ci				/*
21958c2ecf20Sopenharmony_ci				 * max98090_headset_button_event(codec)
21968c2ecf20Sopenharmony_ci				 * could be defined, then called here.
21978c2ecf20Sopenharmony_ci				 */
21988c2ecf20Sopenharmony_ci
21998c2ecf20Sopenharmony_ci				status |= SND_JACK_HEADSET;
22008c2ecf20Sopenharmony_ci				status |= SND_JACK_BTN_0;
22018c2ecf20Sopenharmony_ci
22028c2ecf20Sopenharmony_ci				break;
22038c2ecf20Sopenharmony_ci			}
22048c2ecf20Sopenharmony_ci
22058c2ecf20Sopenharmony_ci			/* Line is reported as Headphone */
22068c2ecf20Sopenharmony_ci			/* Nokia Headset is reported as Headphone */
22078c2ecf20Sopenharmony_ci			/* Mono Headphone is reported as Headphone */
22088c2ecf20Sopenharmony_ci			dev_dbg(component->dev, "Headphone Detected\n");
22098c2ecf20Sopenharmony_ci
22108c2ecf20Sopenharmony_ci			max98090->jack_state = M98090_JACK_STATE_HEADPHONE;
22118c2ecf20Sopenharmony_ci
22128c2ecf20Sopenharmony_ci			status |= SND_JACK_HEADPHONE;
22138c2ecf20Sopenharmony_ci
22148c2ecf20Sopenharmony_ci			break;
22158c2ecf20Sopenharmony_ci
22168c2ecf20Sopenharmony_ci		case M98090_JKSNS_MASK:
22178c2ecf20Sopenharmony_ci			dev_dbg(component->dev, "Headset Detected\n");
22188c2ecf20Sopenharmony_ci
22198c2ecf20Sopenharmony_ci			max98090->jack_state = M98090_JACK_STATE_HEADSET;
22208c2ecf20Sopenharmony_ci
22218c2ecf20Sopenharmony_ci			status |= SND_JACK_HEADSET;
22228c2ecf20Sopenharmony_ci
22238c2ecf20Sopenharmony_ci			break;
22248c2ecf20Sopenharmony_ci
22258c2ecf20Sopenharmony_ci		default:
22268c2ecf20Sopenharmony_ci			dev_dbg(component->dev, "Unrecognized Jack Status\n");
22278c2ecf20Sopenharmony_ci			break;
22288c2ecf20Sopenharmony_ci	}
22298c2ecf20Sopenharmony_ci
22308c2ecf20Sopenharmony_ci	snd_soc_jack_report(max98090->jack, status,
22318c2ecf20Sopenharmony_ci			    SND_JACK_HEADSET | SND_JACK_BTN_0);
22328c2ecf20Sopenharmony_ci}
22338c2ecf20Sopenharmony_ci
22348c2ecf20Sopenharmony_cistatic irqreturn_t max98090_interrupt(int irq, void *data)
22358c2ecf20Sopenharmony_ci{
22368c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = data;
22378c2ecf20Sopenharmony_ci	struct snd_soc_component *component = max98090->component;
22388c2ecf20Sopenharmony_ci	int ret;
22398c2ecf20Sopenharmony_ci	unsigned int mask;
22408c2ecf20Sopenharmony_ci	unsigned int active;
22418c2ecf20Sopenharmony_ci
22428c2ecf20Sopenharmony_ci	/* Treat interrupt before codec is initialized as spurious */
22438c2ecf20Sopenharmony_ci	if (component == NULL)
22448c2ecf20Sopenharmony_ci		return IRQ_NONE;
22458c2ecf20Sopenharmony_ci
22468c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "***** max98090_interrupt *****\n");
22478c2ecf20Sopenharmony_ci
22488c2ecf20Sopenharmony_ci	ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask);
22498c2ecf20Sopenharmony_ci
22508c2ecf20Sopenharmony_ci	if (ret != 0) {
22518c2ecf20Sopenharmony_ci		dev_err(component->dev,
22528c2ecf20Sopenharmony_ci			"failed to read M98090_REG_INTERRUPT_S: %d\n",
22538c2ecf20Sopenharmony_ci			ret);
22548c2ecf20Sopenharmony_ci		return IRQ_NONE;
22558c2ecf20Sopenharmony_ci	}
22568c2ecf20Sopenharmony_ci
22578c2ecf20Sopenharmony_ci	ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active);
22588c2ecf20Sopenharmony_ci
22598c2ecf20Sopenharmony_ci	if (ret != 0) {
22608c2ecf20Sopenharmony_ci		dev_err(component->dev,
22618c2ecf20Sopenharmony_ci			"failed to read M98090_REG_DEVICE_STATUS: %d\n",
22628c2ecf20Sopenharmony_ci			ret);
22638c2ecf20Sopenharmony_ci		return IRQ_NONE;
22648c2ecf20Sopenharmony_ci	}
22658c2ecf20Sopenharmony_ci
22668c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "active=0x%02x mask=0x%02x -> active=0x%02x\n",
22678c2ecf20Sopenharmony_ci		active, mask, active & mask);
22688c2ecf20Sopenharmony_ci
22698c2ecf20Sopenharmony_ci	active &= mask;
22708c2ecf20Sopenharmony_ci
22718c2ecf20Sopenharmony_ci	if (!active)
22728c2ecf20Sopenharmony_ci		return IRQ_NONE;
22738c2ecf20Sopenharmony_ci
22748c2ecf20Sopenharmony_ci	if (active & M98090_CLD_MASK)
22758c2ecf20Sopenharmony_ci		dev_err(component->dev, "M98090_CLD_MASK\n");
22768c2ecf20Sopenharmony_ci
22778c2ecf20Sopenharmony_ci	if (active & M98090_SLD_MASK)
22788c2ecf20Sopenharmony_ci		dev_dbg(component->dev, "M98090_SLD_MASK\n");
22798c2ecf20Sopenharmony_ci
22808c2ecf20Sopenharmony_ci	if (active & M98090_ULK_MASK) {
22818c2ecf20Sopenharmony_ci		dev_dbg(component->dev, "M98090_ULK_MASK\n");
22828c2ecf20Sopenharmony_ci		max98090_pll_work(max98090);
22838c2ecf20Sopenharmony_ci	}
22848c2ecf20Sopenharmony_ci
22858c2ecf20Sopenharmony_ci	if (active & M98090_JDET_MASK) {
22868c2ecf20Sopenharmony_ci		dev_dbg(component->dev, "M98090_JDET_MASK\n");
22878c2ecf20Sopenharmony_ci
22888c2ecf20Sopenharmony_ci		pm_wakeup_event(component->dev, 100);
22898c2ecf20Sopenharmony_ci
22908c2ecf20Sopenharmony_ci		queue_delayed_work(system_power_efficient_wq,
22918c2ecf20Sopenharmony_ci				   &max98090->jack_work,
22928c2ecf20Sopenharmony_ci				   msecs_to_jiffies(100));
22938c2ecf20Sopenharmony_ci	}
22948c2ecf20Sopenharmony_ci
22958c2ecf20Sopenharmony_ci	if (active & M98090_DRCACT_MASK)
22968c2ecf20Sopenharmony_ci		dev_dbg(component->dev, "M98090_DRCACT_MASK\n");
22978c2ecf20Sopenharmony_ci
22988c2ecf20Sopenharmony_ci	if (active & M98090_DRCCLP_MASK)
22998c2ecf20Sopenharmony_ci		dev_err(component->dev, "M98090_DRCCLP_MASK\n");
23008c2ecf20Sopenharmony_ci
23018c2ecf20Sopenharmony_ci	return IRQ_HANDLED;
23028c2ecf20Sopenharmony_ci}
23038c2ecf20Sopenharmony_ci
23048c2ecf20Sopenharmony_ci/**
23058c2ecf20Sopenharmony_ci * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ
23068c2ecf20Sopenharmony_ci *
23078c2ecf20Sopenharmony_ci * @component:  MAX98090 component
23088c2ecf20Sopenharmony_ci * @jack:   jack to report detection events on
23098c2ecf20Sopenharmony_ci *
23108c2ecf20Sopenharmony_ci * Enable microphone detection via IRQ on the MAX98090.  If GPIOs are
23118c2ecf20Sopenharmony_ci * being used to bring out signals to the processor then only platform
23128c2ecf20Sopenharmony_ci * data configuration is needed for MAX98090 and processor GPIOs should
23138c2ecf20Sopenharmony_ci * be configured using snd_soc_jack_add_gpios() instead.
23148c2ecf20Sopenharmony_ci *
23158c2ecf20Sopenharmony_ci * If no jack is supplied detection will be disabled.
23168c2ecf20Sopenharmony_ci */
23178c2ecf20Sopenharmony_ciint max98090_mic_detect(struct snd_soc_component *component,
23188c2ecf20Sopenharmony_ci	struct snd_soc_jack *jack)
23198c2ecf20Sopenharmony_ci{
23208c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
23218c2ecf20Sopenharmony_ci
23228c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "max98090_mic_detect\n");
23238c2ecf20Sopenharmony_ci
23248c2ecf20Sopenharmony_ci	max98090->jack = jack;
23258c2ecf20Sopenharmony_ci	if (jack) {
23268c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S,
23278c2ecf20Sopenharmony_ci			M98090_IJDET_MASK,
23288c2ecf20Sopenharmony_ci			1 << M98090_IJDET_SHIFT);
23298c2ecf20Sopenharmony_ci	} else {
23308c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S,
23318c2ecf20Sopenharmony_ci			M98090_IJDET_MASK,
23328c2ecf20Sopenharmony_ci			0);
23338c2ecf20Sopenharmony_ci	}
23348c2ecf20Sopenharmony_ci
23358c2ecf20Sopenharmony_ci	/* Send an initial empty report */
23368c2ecf20Sopenharmony_ci	snd_soc_jack_report(max98090->jack, 0,
23378c2ecf20Sopenharmony_ci			    SND_JACK_HEADSET | SND_JACK_BTN_0);
23388c2ecf20Sopenharmony_ci
23398c2ecf20Sopenharmony_ci	queue_delayed_work(system_power_efficient_wq,
23408c2ecf20Sopenharmony_ci			   &max98090->jack_work,
23418c2ecf20Sopenharmony_ci			   msecs_to_jiffies(100));
23428c2ecf20Sopenharmony_ci
23438c2ecf20Sopenharmony_ci	return 0;
23448c2ecf20Sopenharmony_ci}
23458c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(max98090_mic_detect);
23468c2ecf20Sopenharmony_ci
23478c2ecf20Sopenharmony_ci#define MAX98090_RATES SNDRV_PCM_RATE_8000_96000
23488c2ecf20Sopenharmony_ci#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
23498c2ecf20Sopenharmony_ci
23508c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops max98090_dai_ops = {
23518c2ecf20Sopenharmony_ci	.startup = max98090_dai_startup,
23528c2ecf20Sopenharmony_ci	.set_sysclk = max98090_dai_set_sysclk,
23538c2ecf20Sopenharmony_ci	.set_fmt = max98090_dai_set_fmt,
23548c2ecf20Sopenharmony_ci	.set_tdm_slot = max98090_set_tdm_slot,
23558c2ecf20Sopenharmony_ci	.hw_params = max98090_dai_hw_params,
23568c2ecf20Sopenharmony_ci	.mute_stream = max98090_dai_mute,
23578c2ecf20Sopenharmony_ci	.trigger = max98090_dai_trigger,
23588c2ecf20Sopenharmony_ci	.no_capture_mute = 1,
23598c2ecf20Sopenharmony_ci};
23608c2ecf20Sopenharmony_ci
23618c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver max98090_dai[] = {
23628c2ecf20Sopenharmony_ci{
23638c2ecf20Sopenharmony_ci	.name = "HiFi",
23648c2ecf20Sopenharmony_ci	.playback = {
23658c2ecf20Sopenharmony_ci		.stream_name = "HiFi Playback",
23668c2ecf20Sopenharmony_ci		.channels_min = 2,
23678c2ecf20Sopenharmony_ci		.channels_max = 2,
23688c2ecf20Sopenharmony_ci		.rates = MAX98090_RATES,
23698c2ecf20Sopenharmony_ci		.formats = MAX98090_FORMATS,
23708c2ecf20Sopenharmony_ci	},
23718c2ecf20Sopenharmony_ci	.capture = {
23728c2ecf20Sopenharmony_ci		.stream_name = "HiFi Capture",
23738c2ecf20Sopenharmony_ci		.channels_min = 1,
23748c2ecf20Sopenharmony_ci		.channels_max = 2,
23758c2ecf20Sopenharmony_ci		.rates = MAX98090_RATES,
23768c2ecf20Sopenharmony_ci		.formats = MAX98090_FORMATS,
23778c2ecf20Sopenharmony_ci	},
23788c2ecf20Sopenharmony_ci	 .ops = &max98090_dai_ops,
23798c2ecf20Sopenharmony_ci}
23808c2ecf20Sopenharmony_ci};
23818c2ecf20Sopenharmony_ci
23828c2ecf20Sopenharmony_cistatic int max98090_probe(struct snd_soc_component *component)
23838c2ecf20Sopenharmony_ci{
23848c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
23858c2ecf20Sopenharmony_ci	struct max98090_cdata *cdata;
23868c2ecf20Sopenharmony_ci	enum max98090_type devtype;
23878c2ecf20Sopenharmony_ci	int ret = 0;
23888c2ecf20Sopenharmony_ci	int err;
23898c2ecf20Sopenharmony_ci	unsigned int micbias;
23908c2ecf20Sopenharmony_ci
23918c2ecf20Sopenharmony_ci	dev_dbg(component->dev, "max98090_probe\n");
23928c2ecf20Sopenharmony_ci
23938c2ecf20Sopenharmony_ci	max98090->mclk = devm_clk_get(component->dev, "mclk");
23948c2ecf20Sopenharmony_ci	if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER)
23958c2ecf20Sopenharmony_ci		return -EPROBE_DEFER;
23968c2ecf20Sopenharmony_ci
23978c2ecf20Sopenharmony_ci	max98090->component = component;
23988c2ecf20Sopenharmony_ci
23998c2ecf20Sopenharmony_ci	/* Reset the codec, the DSP core, and disable all interrupts */
24008c2ecf20Sopenharmony_ci	max98090_reset(max98090);
24018c2ecf20Sopenharmony_ci
24028c2ecf20Sopenharmony_ci	/* Initialize private data */
24038c2ecf20Sopenharmony_ci
24048c2ecf20Sopenharmony_ci	max98090->sysclk = (unsigned)-1;
24058c2ecf20Sopenharmony_ci	max98090->pclk = (unsigned)-1;
24068c2ecf20Sopenharmony_ci	max98090->master = false;
24078c2ecf20Sopenharmony_ci
24088c2ecf20Sopenharmony_ci	cdata = &max98090->dai[0];
24098c2ecf20Sopenharmony_ci	cdata->rate = (unsigned)-1;
24108c2ecf20Sopenharmony_ci	cdata->fmt  = (unsigned)-1;
24118c2ecf20Sopenharmony_ci
24128c2ecf20Sopenharmony_ci	max98090->lin_state = 0;
24138c2ecf20Sopenharmony_ci	max98090->pa1en = 0;
24148c2ecf20Sopenharmony_ci	max98090->pa2en = 0;
24158c2ecf20Sopenharmony_ci
24168c2ecf20Sopenharmony_ci	ret = snd_soc_component_read(component, M98090_REG_REVISION_ID);
24178c2ecf20Sopenharmony_ci	if (ret < 0) {
24188c2ecf20Sopenharmony_ci		dev_err(component->dev, "Failed to read device revision: %d\n",
24198c2ecf20Sopenharmony_ci			ret);
24208c2ecf20Sopenharmony_ci		goto err_access;
24218c2ecf20Sopenharmony_ci	}
24228c2ecf20Sopenharmony_ci
24238c2ecf20Sopenharmony_ci	if ((ret >= M98090_REVA) && (ret <= M98090_REVA + 0x0f)) {
24248c2ecf20Sopenharmony_ci		devtype = MAX98090;
24258c2ecf20Sopenharmony_ci		dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret);
24268c2ecf20Sopenharmony_ci	} else if ((ret >= M98091_REVA) && (ret <= M98091_REVA + 0x0f)) {
24278c2ecf20Sopenharmony_ci		devtype = MAX98091;
24288c2ecf20Sopenharmony_ci		dev_info(component->dev, "MAX98091 REVID=0x%02x\n", ret);
24298c2ecf20Sopenharmony_ci	} else {
24308c2ecf20Sopenharmony_ci		devtype = MAX98090;
24318c2ecf20Sopenharmony_ci		dev_err(component->dev, "Unrecognized revision 0x%02x\n", ret);
24328c2ecf20Sopenharmony_ci	}
24338c2ecf20Sopenharmony_ci
24348c2ecf20Sopenharmony_ci	if (max98090->devtype != devtype) {
24358c2ecf20Sopenharmony_ci		dev_warn(component->dev, "Mismatch in DT specified CODEC type.\n");
24368c2ecf20Sopenharmony_ci		max98090->devtype = devtype;
24378c2ecf20Sopenharmony_ci	}
24388c2ecf20Sopenharmony_ci
24398c2ecf20Sopenharmony_ci	max98090->jack_state = M98090_JACK_STATE_NO_HEADSET;
24408c2ecf20Sopenharmony_ci
24418c2ecf20Sopenharmony_ci	INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work);
24428c2ecf20Sopenharmony_ci	INIT_DELAYED_WORK(&max98090->pll_det_enable_work,
24438c2ecf20Sopenharmony_ci			  max98090_pll_det_enable_work);
24448c2ecf20Sopenharmony_ci	INIT_WORK(&max98090->pll_det_disable_work,
24458c2ecf20Sopenharmony_ci		  max98090_pll_det_disable_work);
24468c2ecf20Sopenharmony_ci
24478c2ecf20Sopenharmony_ci	/* Enable jack detection */
24488c2ecf20Sopenharmony_ci	snd_soc_component_write(component, M98090_REG_JACK_DETECT,
24498c2ecf20Sopenharmony_ci		M98090_JDETEN_MASK | M98090_JDEB_25MS);
24508c2ecf20Sopenharmony_ci
24518c2ecf20Sopenharmony_ci	/*
24528c2ecf20Sopenharmony_ci	 * Clear any old interrupts.
24538c2ecf20Sopenharmony_ci	 * An old interrupt ocurring prior to installing the ISR
24548c2ecf20Sopenharmony_ci	 * can keep a new interrupt from generating a trigger.
24558c2ecf20Sopenharmony_ci	 */
24568c2ecf20Sopenharmony_ci	snd_soc_component_read(component, M98090_REG_DEVICE_STATUS);
24578c2ecf20Sopenharmony_ci
24588c2ecf20Sopenharmony_ci	/* High Performance is default */
24598c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_DAC_CONTROL,
24608c2ecf20Sopenharmony_ci		M98090_DACHP_MASK,
24618c2ecf20Sopenharmony_ci		1 << M98090_DACHP_SHIFT);
24628c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_DAC_CONTROL,
24638c2ecf20Sopenharmony_ci		M98090_PERFMODE_MASK,
24648c2ecf20Sopenharmony_ci		0 << M98090_PERFMODE_SHIFT);
24658c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_ADC_CONTROL,
24668c2ecf20Sopenharmony_ci		M98090_ADCHP_MASK,
24678c2ecf20Sopenharmony_ci		1 << M98090_ADCHP_SHIFT);
24688c2ecf20Sopenharmony_ci
24698c2ecf20Sopenharmony_ci	/* Turn on VCM bandgap reference */
24708c2ecf20Sopenharmony_ci	snd_soc_component_write(component, M98090_REG_BIAS_CONTROL,
24718c2ecf20Sopenharmony_ci		M98090_VCM_MODE_MASK);
24728c2ecf20Sopenharmony_ci
24738c2ecf20Sopenharmony_ci	err = device_property_read_u32(component->dev, "maxim,micbias", &micbias);
24748c2ecf20Sopenharmony_ci	if (err) {
24758c2ecf20Sopenharmony_ci		micbias = M98090_MBVSEL_2V8;
24768c2ecf20Sopenharmony_ci		dev_info(component->dev, "use default 2.8v micbias\n");
24778c2ecf20Sopenharmony_ci	} else if (micbias > M98090_MBVSEL_2V8) {
24788c2ecf20Sopenharmony_ci		dev_err(component->dev, "micbias out of range 0x%x\n", micbias);
24798c2ecf20Sopenharmony_ci		micbias = M98090_MBVSEL_2V8;
24808c2ecf20Sopenharmony_ci	}
24818c2ecf20Sopenharmony_ci
24828c2ecf20Sopenharmony_ci	snd_soc_component_update_bits(component, M98090_REG_MIC_BIAS_VOLTAGE,
24838c2ecf20Sopenharmony_ci		M98090_MBVSEL_MASK, micbias);
24848c2ecf20Sopenharmony_ci
24858c2ecf20Sopenharmony_ci	max98090_add_widgets(component);
24868c2ecf20Sopenharmony_ci
24878c2ecf20Sopenharmony_cierr_access:
24888c2ecf20Sopenharmony_ci	return ret;
24898c2ecf20Sopenharmony_ci}
24908c2ecf20Sopenharmony_ci
24918c2ecf20Sopenharmony_cistatic void max98090_remove(struct snd_soc_component *component)
24928c2ecf20Sopenharmony_ci{
24938c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
24948c2ecf20Sopenharmony_ci
24958c2ecf20Sopenharmony_ci	cancel_delayed_work_sync(&max98090->jack_work);
24968c2ecf20Sopenharmony_ci	cancel_delayed_work_sync(&max98090->pll_det_enable_work);
24978c2ecf20Sopenharmony_ci	cancel_work_sync(&max98090->pll_det_disable_work);
24988c2ecf20Sopenharmony_ci	max98090->component = NULL;
24998c2ecf20Sopenharmony_ci}
25008c2ecf20Sopenharmony_ci
25018c2ecf20Sopenharmony_cistatic void max98090_seq_notifier(struct snd_soc_component *component,
25028c2ecf20Sopenharmony_ci	enum snd_soc_dapm_type event, int subseq)
25038c2ecf20Sopenharmony_ci{
25048c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component);
25058c2ecf20Sopenharmony_ci
25068c2ecf20Sopenharmony_ci	if (max98090->shdn_pending) {
25078c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
25088c2ecf20Sopenharmony_ci				M98090_SHDNN_MASK, 0);
25098c2ecf20Sopenharmony_ci		msleep(40);
25108c2ecf20Sopenharmony_ci		snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN,
25118c2ecf20Sopenharmony_ci				M98090_SHDNN_MASK, M98090_SHDNN_MASK);
25128c2ecf20Sopenharmony_ci		max98090->shdn_pending = false;
25138c2ecf20Sopenharmony_ci	}
25148c2ecf20Sopenharmony_ci}
25158c2ecf20Sopenharmony_ci
25168c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver soc_component_dev_max98090 = {
25178c2ecf20Sopenharmony_ci	.probe			= max98090_probe,
25188c2ecf20Sopenharmony_ci	.remove			= max98090_remove,
25198c2ecf20Sopenharmony_ci	.seq_notifier		= max98090_seq_notifier,
25208c2ecf20Sopenharmony_ci	.set_bias_level		= max98090_set_bias_level,
25218c2ecf20Sopenharmony_ci	.idle_bias_on		= 1,
25228c2ecf20Sopenharmony_ci	.use_pmdown_time	= 1,
25238c2ecf20Sopenharmony_ci	.endianness		= 1,
25248c2ecf20Sopenharmony_ci	.non_legacy_dai_naming	= 1,
25258c2ecf20Sopenharmony_ci};
25268c2ecf20Sopenharmony_ci
25278c2ecf20Sopenharmony_cistatic const struct regmap_config max98090_regmap = {
25288c2ecf20Sopenharmony_ci	.reg_bits = 8,
25298c2ecf20Sopenharmony_ci	.val_bits = 8,
25308c2ecf20Sopenharmony_ci
25318c2ecf20Sopenharmony_ci	.max_register = MAX98090_MAX_REGISTER,
25328c2ecf20Sopenharmony_ci	.reg_defaults = max98090_reg,
25338c2ecf20Sopenharmony_ci	.num_reg_defaults = ARRAY_SIZE(max98090_reg),
25348c2ecf20Sopenharmony_ci	.volatile_reg = max98090_volatile_register,
25358c2ecf20Sopenharmony_ci	.readable_reg = max98090_readable_register,
25368c2ecf20Sopenharmony_ci	.cache_type = REGCACHE_RBTREE,
25378c2ecf20Sopenharmony_ci};
25388c2ecf20Sopenharmony_ci
25398c2ecf20Sopenharmony_cistatic int max98090_i2c_probe(struct i2c_client *i2c,
25408c2ecf20Sopenharmony_ci				 const struct i2c_device_id *i2c_id)
25418c2ecf20Sopenharmony_ci{
25428c2ecf20Sopenharmony_ci	struct max98090_priv *max98090;
25438c2ecf20Sopenharmony_ci	const struct acpi_device_id *acpi_id;
25448c2ecf20Sopenharmony_ci	kernel_ulong_t driver_data = 0;
25458c2ecf20Sopenharmony_ci	int ret;
25468c2ecf20Sopenharmony_ci
25478c2ecf20Sopenharmony_ci	pr_debug("max98090_i2c_probe\n");
25488c2ecf20Sopenharmony_ci
25498c2ecf20Sopenharmony_ci	max98090 = devm_kzalloc(&i2c->dev, sizeof(struct max98090_priv),
25508c2ecf20Sopenharmony_ci		GFP_KERNEL);
25518c2ecf20Sopenharmony_ci	if (max98090 == NULL)
25528c2ecf20Sopenharmony_ci		return -ENOMEM;
25538c2ecf20Sopenharmony_ci
25548c2ecf20Sopenharmony_ci	if (ACPI_HANDLE(&i2c->dev)) {
25558c2ecf20Sopenharmony_ci		acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table,
25568c2ecf20Sopenharmony_ci					    &i2c->dev);
25578c2ecf20Sopenharmony_ci		if (!acpi_id) {
25588c2ecf20Sopenharmony_ci			dev_err(&i2c->dev, "No driver data\n");
25598c2ecf20Sopenharmony_ci			return -EINVAL;
25608c2ecf20Sopenharmony_ci		}
25618c2ecf20Sopenharmony_ci		driver_data = acpi_id->driver_data;
25628c2ecf20Sopenharmony_ci	} else if (i2c_id) {
25638c2ecf20Sopenharmony_ci		driver_data = i2c_id->driver_data;
25648c2ecf20Sopenharmony_ci	}
25658c2ecf20Sopenharmony_ci
25668c2ecf20Sopenharmony_ci	max98090->devtype = driver_data;
25678c2ecf20Sopenharmony_ci	i2c_set_clientdata(i2c, max98090);
25688c2ecf20Sopenharmony_ci	max98090->pdata = i2c->dev.platform_data;
25698c2ecf20Sopenharmony_ci
25708c2ecf20Sopenharmony_ci	ret = of_property_read_u32(i2c->dev.of_node, "maxim,dmic-freq",
25718c2ecf20Sopenharmony_ci				   &max98090->dmic_freq);
25728c2ecf20Sopenharmony_ci	if (ret < 0)
25738c2ecf20Sopenharmony_ci		max98090->dmic_freq = MAX98090_DEFAULT_DMIC_FREQ;
25748c2ecf20Sopenharmony_ci
25758c2ecf20Sopenharmony_ci	max98090->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap);
25768c2ecf20Sopenharmony_ci	if (IS_ERR(max98090->regmap)) {
25778c2ecf20Sopenharmony_ci		ret = PTR_ERR(max98090->regmap);
25788c2ecf20Sopenharmony_ci		dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
25798c2ecf20Sopenharmony_ci		goto err_enable;
25808c2ecf20Sopenharmony_ci	}
25818c2ecf20Sopenharmony_ci
25828c2ecf20Sopenharmony_ci	ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
25838c2ecf20Sopenharmony_ci		max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
25848c2ecf20Sopenharmony_ci		"max98090_interrupt", max98090);
25858c2ecf20Sopenharmony_ci	if (ret < 0) {
25868c2ecf20Sopenharmony_ci		dev_err(&i2c->dev, "request_irq failed: %d\n",
25878c2ecf20Sopenharmony_ci			ret);
25888c2ecf20Sopenharmony_ci		return ret;
25898c2ecf20Sopenharmony_ci	}
25908c2ecf20Sopenharmony_ci
25918c2ecf20Sopenharmony_ci	ret = devm_snd_soc_register_component(&i2c->dev,
25928c2ecf20Sopenharmony_ci			&soc_component_dev_max98090, max98090_dai,
25938c2ecf20Sopenharmony_ci			ARRAY_SIZE(max98090_dai));
25948c2ecf20Sopenharmony_cierr_enable:
25958c2ecf20Sopenharmony_ci	return ret;
25968c2ecf20Sopenharmony_ci}
25978c2ecf20Sopenharmony_ci
25988c2ecf20Sopenharmony_cistatic void max98090_i2c_shutdown(struct i2c_client *i2c)
25998c2ecf20Sopenharmony_ci{
26008c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev);
26018c2ecf20Sopenharmony_ci
26028c2ecf20Sopenharmony_ci	/*
26038c2ecf20Sopenharmony_ci	 * Enable volume smoothing, disable zero cross.  This will cause
26048c2ecf20Sopenharmony_ci	 * a quick 40ms ramp to mute on shutdown.
26058c2ecf20Sopenharmony_ci	 */
26068c2ecf20Sopenharmony_ci	regmap_write(max98090->regmap,
26078c2ecf20Sopenharmony_ci		M98090_REG_LEVEL_CONTROL, M98090_VSENN_MASK);
26088c2ecf20Sopenharmony_ci	regmap_write(max98090->regmap,
26098c2ecf20Sopenharmony_ci		M98090_REG_DEVICE_SHUTDOWN, 0x00);
26108c2ecf20Sopenharmony_ci	msleep(40);
26118c2ecf20Sopenharmony_ci}
26128c2ecf20Sopenharmony_ci
26138c2ecf20Sopenharmony_cistatic int max98090_i2c_remove(struct i2c_client *client)
26148c2ecf20Sopenharmony_ci{
26158c2ecf20Sopenharmony_ci	max98090_i2c_shutdown(client);
26168c2ecf20Sopenharmony_ci
26178c2ecf20Sopenharmony_ci	return 0;
26188c2ecf20Sopenharmony_ci}
26198c2ecf20Sopenharmony_ci
26208c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
26218c2ecf20Sopenharmony_cistatic int max98090_runtime_resume(struct device *dev)
26228c2ecf20Sopenharmony_ci{
26238c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = dev_get_drvdata(dev);
26248c2ecf20Sopenharmony_ci
26258c2ecf20Sopenharmony_ci	regcache_cache_only(max98090->regmap, false);
26268c2ecf20Sopenharmony_ci
26278c2ecf20Sopenharmony_ci	max98090_reset(max98090);
26288c2ecf20Sopenharmony_ci
26298c2ecf20Sopenharmony_ci	regcache_sync(max98090->regmap);
26308c2ecf20Sopenharmony_ci
26318c2ecf20Sopenharmony_ci	return 0;
26328c2ecf20Sopenharmony_ci}
26338c2ecf20Sopenharmony_ci
26348c2ecf20Sopenharmony_cistatic int max98090_runtime_suspend(struct device *dev)
26358c2ecf20Sopenharmony_ci{
26368c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = dev_get_drvdata(dev);
26378c2ecf20Sopenharmony_ci
26388c2ecf20Sopenharmony_ci	regcache_cache_only(max98090->regmap, true);
26398c2ecf20Sopenharmony_ci
26408c2ecf20Sopenharmony_ci	return 0;
26418c2ecf20Sopenharmony_ci}
26428c2ecf20Sopenharmony_ci#endif
26438c2ecf20Sopenharmony_ci
26448c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
26458c2ecf20Sopenharmony_cistatic int max98090_resume(struct device *dev)
26468c2ecf20Sopenharmony_ci{
26478c2ecf20Sopenharmony_ci	struct max98090_priv *max98090 = dev_get_drvdata(dev);
26488c2ecf20Sopenharmony_ci	unsigned int status;
26498c2ecf20Sopenharmony_ci
26508c2ecf20Sopenharmony_ci	regcache_mark_dirty(max98090->regmap);
26518c2ecf20Sopenharmony_ci
26528c2ecf20Sopenharmony_ci	max98090_reset(max98090);
26538c2ecf20Sopenharmony_ci
26548c2ecf20Sopenharmony_ci	/* clear IRQ status */
26558c2ecf20Sopenharmony_ci	regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &status);
26568c2ecf20Sopenharmony_ci
26578c2ecf20Sopenharmony_ci	regcache_sync(max98090->regmap);
26588c2ecf20Sopenharmony_ci
26598c2ecf20Sopenharmony_ci	return 0;
26608c2ecf20Sopenharmony_ci}
26618c2ecf20Sopenharmony_ci#endif
26628c2ecf20Sopenharmony_ci
26638c2ecf20Sopenharmony_cistatic const struct dev_pm_ops max98090_pm = {
26648c2ecf20Sopenharmony_ci	SET_RUNTIME_PM_OPS(max98090_runtime_suspend,
26658c2ecf20Sopenharmony_ci		max98090_runtime_resume, NULL)
26668c2ecf20Sopenharmony_ci	SET_SYSTEM_SLEEP_PM_OPS(NULL, max98090_resume)
26678c2ecf20Sopenharmony_ci};
26688c2ecf20Sopenharmony_ci
26698c2ecf20Sopenharmony_cistatic const struct i2c_device_id max98090_i2c_id[] = {
26708c2ecf20Sopenharmony_ci	{ "max98090", MAX98090 },
26718c2ecf20Sopenharmony_ci	{ "max98091", MAX98091 },
26728c2ecf20Sopenharmony_ci	{ }
26738c2ecf20Sopenharmony_ci};
26748c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, max98090_i2c_id);
26758c2ecf20Sopenharmony_ci
26768c2ecf20Sopenharmony_cistatic const struct of_device_id max98090_of_match[] = {
26778c2ecf20Sopenharmony_ci	{ .compatible = "maxim,max98090", },
26788c2ecf20Sopenharmony_ci	{ .compatible = "maxim,max98091", },
26798c2ecf20Sopenharmony_ci	{ }
26808c2ecf20Sopenharmony_ci};
26818c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, max98090_of_match);
26828c2ecf20Sopenharmony_ci
26838c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI
26848c2ecf20Sopenharmony_cistatic const struct acpi_device_id max98090_acpi_match[] = {
26858c2ecf20Sopenharmony_ci	{ "193C9890", MAX98090 },
26868c2ecf20Sopenharmony_ci	{ }
26878c2ecf20Sopenharmony_ci};
26888c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, max98090_acpi_match);
26898c2ecf20Sopenharmony_ci#endif
26908c2ecf20Sopenharmony_ci
26918c2ecf20Sopenharmony_cistatic struct i2c_driver max98090_i2c_driver = {
26928c2ecf20Sopenharmony_ci	.driver = {
26938c2ecf20Sopenharmony_ci		.name = "max98090",
26948c2ecf20Sopenharmony_ci		.pm = &max98090_pm,
26958c2ecf20Sopenharmony_ci		.of_match_table = of_match_ptr(max98090_of_match),
26968c2ecf20Sopenharmony_ci		.acpi_match_table = ACPI_PTR(max98090_acpi_match),
26978c2ecf20Sopenharmony_ci	},
26988c2ecf20Sopenharmony_ci	.probe  = max98090_i2c_probe,
26998c2ecf20Sopenharmony_ci	.shutdown = max98090_i2c_shutdown,
27008c2ecf20Sopenharmony_ci	.remove = max98090_i2c_remove,
27018c2ecf20Sopenharmony_ci	.id_table = max98090_i2c_id,
27028c2ecf20Sopenharmony_ci};
27038c2ecf20Sopenharmony_ci
27048c2ecf20Sopenharmony_cimodule_i2c_driver(max98090_i2c_driver);
27058c2ecf20Sopenharmony_ci
27068c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ALSA SoC MAX98090 driver");
27078c2ecf20Sopenharmony_ciMODULE_AUTHOR("Peter Hsiang, Jesse Marroqin, Jerry Wong");
27088c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
2709