18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/module.h> 78c2ecf20Sopenharmony_ci#include <linux/moduleparam.h> 88c2ecf20Sopenharmony_ci#include <linux/init.h> 98c2ecf20Sopenharmony_ci#include <linux/delay.h> 108c2ecf20Sopenharmony_ci#include <linux/pm.h> 118c2ecf20Sopenharmony_ci#include <linux/i2c.h> 128c2ecf20Sopenharmony_ci#include <linux/slab.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci#include <linux/regmap.h> 158c2ecf20Sopenharmony_ci#include <sound/core.h> 168c2ecf20Sopenharmony_ci#include <sound/pcm.h> 178c2ecf20Sopenharmony_ci#include <sound/pcm_params.h> 188c2ecf20Sopenharmony_ci#include <sound/soc.h> 198c2ecf20Sopenharmony_ci#include <sound/tlv.h> 208c2ecf20Sopenharmony_ci#include "ml26124.h" 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define DVOL_CTL_DVMUTE_ON BIT(4) /* Digital volume MUTE On */ 238c2ecf20Sopenharmony_ci#define DVOL_CTL_DVMUTE_OFF 0 /* Digital volume MUTE Off */ 248c2ecf20Sopenharmony_ci#define ML26124_SAI_NO_DELAY BIT(1) 258c2ecf20Sopenharmony_ci#define ML26124_SAI_FRAME_SYNC (BIT(5) | BIT(0)) /* For mono (Telecodec) */ 268c2ecf20Sopenharmony_ci#define ML26134_CACHESIZE 212 278c2ecf20Sopenharmony_ci#define ML26124_VMID BIT(1) 288c2ecf20Sopenharmony_ci#define ML26124_RATES (SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_32000 |\ 298c2ecf20Sopenharmony_ci SNDRV_PCM_RATE_48000) 308c2ecf20Sopenharmony_ci#define ML26124_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |\ 318c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S32_LE) 328c2ecf20Sopenharmony_ci#define ML26124_NUM_REGISTER ML26134_CACHESIZE 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct ml26124_priv { 358c2ecf20Sopenharmony_ci u32 mclk; 368c2ecf20Sopenharmony_ci u32 rate; 378c2ecf20Sopenharmony_ci struct regmap *regmap; 388c2ecf20Sopenharmony_ci int clk_in; 398c2ecf20Sopenharmony_ci struct snd_pcm_substream *substream; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct clk_coeff { 438c2ecf20Sopenharmony_ci u32 mclk; 448c2ecf20Sopenharmony_ci u32 rate; 458c2ecf20Sopenharmony_ci u8 pllnl; 468c2ecf20Sopenharmony_ci u8 pllnh; 478c2ecf20Sopenharmony_ci u8 pllml; 488c2ecf20Sopenharmony_ci u8 pllmh; 498c2ecf20Sopenharmony_ci u8 plldiv; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* ML26124 configuration */ 538c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(digital_tlv, -7150, 50, 0); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(alclvl, -2250, 150, 0); 568c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(mingain, -1200, 600, 0); 578c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(maxgain, -675, 600, 0); 588c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(boost_vol, -1200, 75, 0); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic const char * const ml26124_companding[] = {"16bit PCM", "u-law", 618c2ecf20Sopenharmony_ci "A-law"}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(ml26124_adc_companding_enum, 648c2ecf20Sopenharmony_ci ML26124_SAI_TRANS_CTL, 6, ml26124_companding); 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(ml26124_dac_companding_enum, 678c2ecf20Sopenharmony_ci ML26124_SAI_RCV_CTL, 6, ml26124_companding); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new ml26124_snd_controls[] = { 708c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Capture Digital Volume", ML26124_RECORD_DIG_VOL, 0, 718c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 728c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Playback Digital Volume", ML26124_PLBAK_DIG_VOL, 0, 738c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 748c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Digital Boost Volume", ML26124_DIGI_BOOST_VOL, 0, 758c2ecf20Sopenharmony_ci 0x3f, 0, boost_vol), 768c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("EQ Band0 Volume", ML26124_EQ_GAIN_BRAND0, 0, 778c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 788c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("EQ Band1 Volume", ML26124_EQ_GAIN_BRAND1, 0, 798c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 808c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("EQ Band2 Volume", ML26124_EQ_GAIN_BRAND2, 0, 818c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 828c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("EQ Band3 Volume", ML26124_EQ_GAIN_BRAND3, 0, 838c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 848c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("EQ Band4 Volume", ML26124_EQ_GAIN_BRAND4, 0, 858c2ecf20Sopenharmony_ci 0xff, 1, digital_tlv), 868c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("ALC Target Level", ML26124_ALC_TARGET_LEV, 0, 878c2ecf20Sopenharmony_ci 0xf, 1, alclvl), 888c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("ALC Min Input Volume", ML26124_ALC_MAXMIN_GAIN, 0, 898c2ecf20Sopenharmony_ci 7, 0, mingain), 908c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("ALC Max Input Volume", ML26124_ALC_MAXMIN_GAIN, 4, 918c2ecf20Sopenharmony_ci 7, 1, maxgain), 928c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Playback Limiter Min Input Volume", 938c2ecf20Sopenharmony_ci ML26124_PL_MAXMIN_GAIN, 0, 7, 0, mingain), 948c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Playback Limiter Max Input Volume", 958c2ecf20Sopenharmony_ci ML26124_PL_MAXMIN_GAIN, 4, 7, 1, maxgain), 968c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("Playback Boost Volume", ML26124_PLYBAK_BOST_VOL, 0, 978c2ecf20Sopenharmony_ci 0x3f, 0, boost_vol), 988c2ecf20Sopenharmony_ci SOC_SINGLE("DC High Pass Filter Switch", ML26124_FILTER_EN, 0, 1, 0), 998c2ecf20Sopenharmony_ci SOC_SINGLE("Noise High Pass Filter Switch", ML26124_FILTER_EN, 1, 1, 0), 1008c2ecf20Sopenharmony_ci SOC_SINGLE("ZC Switch", ML26124_PW_ZCCMP_PW_MNG, 1, 1018c2ecf20Sopenharmony_ci 1, 0), 1028c2ecf20Sopenharmony_ci SOC_SINGLE("EQ Band0 Switch", ML26124_FILTER_EN, 2, 1, 0), 1038c2ecf20Sopenharmony_ci SOC_SINGLE("EQ Band1 Switch", ML26124_FILTER_EN, 3, 1, 0), 1048c2ecf20Sopenharmony_ci SOC_SINGLE("EQ Band2 Switch", ML26124_FILTER_EN, 4, 1, 0), 1058c2ecf20Sopenharmony_ci SOC_SINGLE("EQ Band3 Switch", ML26124_FILTER_EN, 5, 1, 0), 1068c2ecf20Sopenharmony_ci SOC_SINGLE("EQ Band4 Switch", ML26124_FILTER_EN, 6, 1, 0), 1078c2ecf20Sopenharmony_ci SOC_SINGLE("Play Limiter", ML26124_DVOL_CTL, 0, 1, 0), 1088c2ecf20Sopenharmony_ci SOC_SINGLE("Capture Limiter", ML26124_DVOL_CTL, 1, 1, 0), 1098c2ecf20Sopenharmony_ci SOC_SINGLE("Digital Volume Fade Switch", ML26124_DVOL_CTL, 3, 1, 0), 1108c2ecf20Sopenharmony_ci SOC_SINGLE("Digital Switch", ML26124_DVOL_CTL, 4, 1, 0), 1118c2ecf20Sopenharmony_ci SOC_ENUM("DAC Companding", ml26124_dac_companding_enum), 1128c2ecf20Sopenharmony_ci SOC_ENUM("ADC Companding", ml26124_adc_companding_enum), 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new ml26124_output_mixer_controls[] = { 1168c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC Switch", ML26124_SPK_AMP_OUT, 1, 1, 0), 1178c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Line in loopback Switch", ML26124_SPK_AMP_OUT, 3, 1, 1188c2ecf20Sopenharmony_ci 0), 1198c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("PGA Switch", ML26124_SPK_AMP_OUT, 5, 1, 0), 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci/* Input mux */ 1238c2ecf20Sopenharmony_cistatic const char * const ml26124_input_select[] = {"Analog MIC SingleEnded in", 1248c2ecf20Sopenharmony_ci "Digital MIC in", "Analog MIC Differential in"}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(ml26124_insel_enum, 1278c2ecf20Sopenharmony_ci ML26124_MIC_IF_CTL, 0, ml26124_input_select); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new ml26124_input_mux_controls = 1308c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Input Select", ml26124_insel_enum); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new ml26124_line_control = 1338c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Switch", ML26124_PW_LOUT_PW_MNG, 1, 1, 0); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget ml26124_dapm_widgets[] = { 1368c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("MCLKEN", ML26124_CLK_EN, 0, 0, NULL, 0), 1378c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("PLLEN", ML26124_CLK_EN, 1, 0, NULL, 0), 1388c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("PLLOE", ML26124_CLK_EN, 2, 0, NULL, 0), 1398c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("MICBIAS", ML26124_PW_REF_PW_MNG, 2, 0, NULL, 0), 1408c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Output Mixer", SND_SOC_NOPM, 0, 0, 1418c2ecf20Sopenharmony_ci &ml26124_output_mixer_controls[0], 1428c2ecf20Sopenharmony_ci ARRAY_SIZE(ml26124_output_mixer_controls)), 1438c2ecf20Sopenharmony_ci SND_SOC_DAPM_DAC("DAC", "Playback", ML26124_PW_DAC_PW_MNG, 1, 0), 1448c2ecf20Sopenharmony_ci SND_SOC_DAPM_ADC("ADC", "Capture", ML26124_PW_IN_PW_MNG, 1, 0), 1458c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("PGA", ML26124_PW_IN_PW_MNG, 3, 0, NULL, 0), 1468c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0, 1478c2ecf20Sopenharmony_ci &ml26124_input_mux_controls), 1488c2ecf20Sopenharmony_ci SND_SOC_DAPM_SWITCH("Line Out Enable", SND_SOC_NOPM, 0, 0, 1498c2ecf20Sopenharmony_ci &ml26124_line_control), 1508c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("MDIN"), 1518c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("MIN"), 1528c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("LIN"), 1538c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("SPOUT"), 1548c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("LOUT"), 1558c2ecf20Sopenharmony_ci}; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route ml26124_intercon[] = { 1588c2ecf20Sopenharmony_ci /* Supply */ 1598c2ecf20Sopenharmony_ci {"DAC", NULL, "MCLKEN"}, 1608c2ecf20Sopenharmony_ci {"ADC", NULL, "MCLKEN"}, 1618c2ecf20Sopenharmony_ci {"DAC", NULL, "PLLEN"}, 1628c2ecf20Sopenharmony_ci {"ADC", NULL, "PLLEN"}, 1638c2ecf20Sopenharmony_ci {"DAC", NULL, "PLLOE"}, 1648c2ecf20Sopenharmony_ci {"ADC", NULL, "PLLOE"}, 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci /* output mixer */ 1678c2ecf20Sopenharmony_ci {"Output Mixer", "DAC Switch", "DAC"}, 1688c2ecf20Sopenharmony_ci {"Output Mixer", "Line in loopback Switch", "LIN"}, 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci /* outputs */ 1718c2ecf20Sopenharmony_ci {"LOUT", NULL, "Output Mixer"}, 1728c2ecf20Sopenharmony_ci {"SPOUT", NULL, "Output Mixer"}, 1738c2ecf20Sopenharmony_ci {"Line Out Enable", NULL, "LOUT"}, 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci /* input */ 1768c2ecf20Sopenharmony_ci {"ADC", NULL, "Input Mux"}, 1778c2ecf20Sopenharmony_ci {"Input Mux", "Analog MIC SingleEnded in", "PGA"}, 1788c2ecf20Sopenharmony_ci {"Input Mux", "Analog MIC Differential in", "PGA"}, 1798c2ecf20Sopenharmony_ci {"PGA", NULL, "MIN"}, 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* PLLOutputFreq(Hz) = InputMclkFreq(Hz) * PLLM / (PLLN * PLLDIV) */ 1838c2ecf20Sopenharmony_cistatic const struct clk_coeff coeff_div[] = { 1848c2ecf20Sopenharmony_ci {12288000, 16000, 0xc, 0x0, 0x20, 0x0, 0x4}, 1858c2ecf20Sopenharmony_ci {12288000, 32000, 0xc, 0x0, 0x20, 0x0, 0x4}, 1868c2ecf20Sopenharmony_ci {12288000, 48000, 0xc, 0x0, 0x30, 0x0, 0x4}, 1878c2ecf20Sopenharmony_ci}; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic const struct reg_default ml26124_reg[] = { 1908c2ecf20Sopenharmony_ci /* CLOCK control Register */ 1918c2ecf20Sopenharmony_ci {0x00, 0x00 }, /* Sampling Rate */ 1928c2ecf20Sopenharmony_ci {0x02, 0x00}, /* PLL NL */ 1938c2ecf20Sopenharmony_ci {0x04, 0x00}, /* PLLNH */ 1948c2ecf20Sopenharmony_ci {0x06, 0x00}, /* PLLML */ 1958c2ecf20Sopenharmony_ci {0x08, 0x00}, /* MLLMH */ 1968c2ecf20Sopenharmony_ci {0x0a, 0x00}, /* PLLDIV */ 1978c2ecf20Sopenharmony_ci {0x0c, 0x00}, /* Clock Enable */ 1988c2ecf20Sopenharmony_ci {0x0e, 0x00}, /* CLK Input/Output Control */ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci /* System Control Register */ 2018c2ecf20Sopenharmony_ci {0x10, 0x00}, /* Software RESET */ 2028c2ecf20Sopenharmony_ci {0x12, 0x00}, /* Record/Playback Run */ 2038c2ecf20Sopenharmony_ci {0x14, 0x00}, /* Mic Input/Output control */ 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci /* Power Management Register */ 2068c2ecf20Sopenharmony_ci {0x20, 0x00}, /* Reference Power Management */ 2078c2ecf20Sopenharmony_ci {0x22, 0x00}, /* Input Power Management */ 2088c2ecf20Sopenharmony_ci {0x24, 0x00}, /* DAC Power Management */ 2098c2ecf20Sopenharmony_ci {0x26, 0x00}, /* SP-AMP Power Management */ 2108c2ecf20Sopenharmony_ci {0x28, 0x00}, /* LINEOUT Power Management */ 2118c2ecf20Sopenharmony_ci {0x2a, 0x00}, /* VIDEO Power Management */ 2128c2ecf20Sopenharmony_ci {0x2e, 0x00}, /* AC-CMP Power Management */ 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci /* Analog reference Control Register */ 2158c2ecf20Sopenharmony_ci {0x30, 0x04}, /* MICBIAS Voltage Control */ 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci /* Input/Output Amplifier Control Register */ 2188c2ecf20Sopenharmony_ci {0x32, 0x10}, /* MIC Input Volume */ 2198c2ecf20Sopenharmony_ci {0x38, 0x00}, /* Mic Boost Volume */ 2208c2ecf20Sopenharmony_ci {0x3a, 0x33}, /* Speaker AMP Volume */ 2218c2ecf20Sopenharmony_ci {0x48, 0x00}, /* AMP Volume Control Function Enable */ 2228c2ecf20Sopenharmony_ci {0x4a, 0x00}, /* Amplifier Volume Fader Control */ 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /* Analog Path Control Register */ 2258c2ecf20Sopenharmony_ci {0x54, 0x00}, /* Speaker AMP Output Control */ 2268c2ecf20Sopenharmony_ci {0x5a, 0x00}, /* Mic IF Control */ 2278c2ecf20Sopenharmony_ci {0xe8, 0x01}, /* Mic Select Control */ 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci /* Audio Interface Control Register */ 2308c2ecf20Sopenharmony_ci {0x60, 0x00}, /* SAI-Trans Control */ 2318c2ecf20Sopenharmony_ci {0x62, 0x00}, /* SAI-Receive Control */ 2328c2ecf20Sopenharmony_ci {0x64, 0x00}, /* SAI Mode select */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci /* DSP Control Register */ 2358c2ecf20Sopenharmony_ci {0x66, 0x01}, /* Filter Func Enable */ 2368c2ecf20Sopenharmony_ci {0x68, 0x00}, /* Volume Control Func Enable */ 2378c2ecf20Sopenharmony_ci {0x6A, 0x00}, /* Mixer & Volume Control*/ 2388c2ecf20Sopenharmony_ci {0x6C, 0xff}, /* Record Digital Volume */ 2398c2ecf20Sopenharmony_ci {0x70, 0xff}, /* Playback Digital Volume */ 2408c2ecf20Sopenharmony_ci {0x72, 0x10}, /* Digital Boost Volume */ 2418c2ecf20Sopenharmony_ci {0x74, 0xe7}, /* EQ gain Band0 */ 2428c2ecf20Sopenharmony_ci {0x76, 0xe7}, /* EQ gain Band1 */ 2438c2ecf20Sopenharmony_ci {0x78, 0xe7}, /* EQ gain Band2 */ 2448c2ecf20Sopenharmony_ci {0x7A, 0xe7}, /* EQ gain Band3 */ 2458c2ecf20Sopenharmony_ci {0x7C, 0xe7}, /* EQ gain Band4 */ 2468c2ecf20Sopenharmony_ci {0x7E, 0x00}, /* HPF2 CutOff*/ 2478c2ecf20Sopenharmony_ci {0x80, 0x00}, /* EQ Band0 Coef0L */ 2488c2ecf20Sopenharmony_ci {0x82, 0x00}, /* EQ Band0 Coef0H */ 2498c2ecf20Sopenharmony_ci {0x84, 0x00}, /* EQ Band0 Coef0L */ 2508c2ecf20Sopenharmony_ci {0x86, 0x00}, /* EQ Band0 Coef0H */ 2518c2ecf20Sopenharmony_ci {0x88, 0x00}, /* EQ Band1 Coef0L */ 2528c2ecf20Sopenharmony_ci {0x8A, 0x00}, /* EQ Band1 Coef0H */ 2538c2ecf20Sopenharmony_ci {0x8C, 0x00}, /* EQ Band1 Coef0L */ 2548c2ecf20Sopenharmony_ci {0x8E, 0x00}, /* EQ Band1 Coef0H */ 2558c2ecf20Sopenharmony_ci {0x90, 0x00}, /* EQ Band2 Coef0L */ 2568c2ecf20Sopenharmony_ci {0x92, 0x00}, /* EQ Band2 Coef0H */ 2578c2ecf20Sopenharmony_ci {0x94, 0x00}, /* EQ Band2 Coef0L */ 2588c2ecf20Sopenharmony_ci {0x96, 0x00}, /* EQ Band2 Coef0H */ 2598c2ecf20Sopenharmony_ci {0x98, 0x00}, /* EQ Band3 Coef0L */ 2608c2ecf20Sopenharmony_ci {0x9A, 0x00}, /* EQ Band3 Coef0H */ 2618c2ecf20Sopenharmony_ci {0x9C, 0x00}, /* EQ Band3 Coef0L */ 2628c2ecf20Sopenharmony_ci {0x9E, 0x00}, /* EQ Band3 Coef0H */ 2638c2ecf20Sopenharmony_ci {0xA0, 0x00}, /* EQ Band4 Coef0L */ 2648c2ecf20Sopenharmony_ci {0xA2, 0x00}, /* EQ Band4 Coef0H */ 2658c2ecf20Sopenharmony_ci {0xA4, 0x00}, /* EQ Band4 Coef0L */ 2668c2ecf20Sopenharmony_ci {0xA6, 0x00}, /* EQ Band4 Coef0H */ 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci /* ALC Control Register */ 2698c2ecf20Sopenharmony_ci {0xb0, 0x00}, /* ALC Mode */ 2708c2ecf20Sopenharmony_ci {0xb2, 0x02}, /* ALC Attack Time */ 2718c2ecf20Sopenharmony_ci {0xb4, 0x03}, /* ALC Decay Time */ 2728c2ecf20Sopenharmony_ci {0xb6, 0x00}, /* ALC Hold Time */ 2738c2ecf20Sopenharmony_ci {0xb8, 0x0b}, /* ALC Target Level */ 2748c2ecf20Sopenharmony_ci {0xba, 0x70}, /* ALC Max/Min Gain */ 2758c2ecf20Sopenharmony_ci {0xbc, 0x00}, /* Noise Gate Threshold */ 2768c2ecf20Sopenharmony_ci {0xbe, 0x00}, /* ALC ZeroCross TimeOut */ 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci /* Playback Limiter Control Register */ 2798c2ecf20Sopenharmony_ci {0xc0, 0x04}, /* PL Attack Time */ 2808c2ecf20Sopenharmony_ci {0xc2, 0x05}, /* PL Decay Time */ 2818c2ecf20Sopenharmony_ci {0xc4, 0x0d}, /* PL Target Level */ 2828c2ecf20Sopenharmony_ci {0xc6, 0x70}, /* PL Max/Min Gain */ 2838c2ecf20Sopenharmony_ci {0xc8, 0x10}, /* Playback Boost Volume */ 2848c2ecf20Sopenharmony_ci {0xca, 0x00}, /* PL ZeroCross TimeOut */ 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* Video Amplifier Control Register */ 2878c2ecf20Sopenharmony_ci {0xd0, 0x01}, /* VIDEO AMP Gain Control */ 2888c2ecf20Sopenharmony_ci {0xd2, 0x01}, /* VIDEO AMP Setup 1 */ 2898c2ecf20Sopenharmony_ci {0xd4, 0x01}, /* VIDEO AMP Control2 */ 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci/* Get sampling rate value of sampling rate setting register (0x0) */ 2938c2ecf20Sopenharmony_cistatic inline int get_srate(int rate) 2948c2ecf20Sopenharmony_ci{ 2958c2ecf20Sopenharmony_ci int srate; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci switch (rate) { 2988c2ecf20Sopenharmony_ci case 16000: 2998c2ecf20Sopenharmony_ci srate = 3; 3008c2ecf20Sopenharmony_ci break; 3018c2ecf20Sopenharmony_ci case 32000: 3028c2ecf20Sopenharmony_ci srate = 6; 3038c2ecf20Sopenharmony_ci break; 3048c2ecf20Sopenharmony_ci case 48000: 3058c2ecf20Sopenharmony_ci srate = 8; 3068c2ecf20Sopenharmony_ci break; 3078c2ecf20Sopenharmony_ci default: 3088c2ecf20Sopenharmony_ci return -EINVAL; 3098c2ecf20Sopenharmony_ci } 3108c2ecf20Sopenharmony_ci return srate; 3118c2ecf20Sopenharmony_ci} 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistatic inline int get_coeff(int mclk, int rate) 3148c2ecf20Sopenharmony_ci{ 3158c2ecf20Sopenharmony_ci int i; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { 3188c2ecf20Sopenharmony_ci if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) 3198c2ecf20Sopenharmony_ci return i; 3208c2ecf20Sopenharmony_ci } 3218c2ecf20Sopenharmony_ci return -EINVAL; 3228c2ecf20Sopenharmony_ci} 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_cistatic int ml26124_hw_params(struct snd_pcm_substream *substream, 3258c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *hw_params, 3268c2ecf20Sopenharmony_ci struct snd_soc_dai *dai) 3278c2ecf20Sopenharmony_ci{ 3288c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 3298c2ecf20Sopenharmony_ci struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); 3308c2ecf20Sopenharmony_ci int i = get_coeff(priv->mclk, params_rate(hw_params)); 3318c2ecf20Sopenharmony_ci int srate; 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci if (i < 0) 3348c2ecf20Sopenharmony_ci return i; 3358c2ecf20Sopenharmony_ci priv->substream = substream; 3368c2ecf20Sopenharmony_ci priv->rate = params_rate(hw_params); 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci if (priv->clk_in) { 3398c2ecf20Sopenharmony_ci switch (priv->mclk / params_rate(hw_params)) { 3408c2ecf20Sopenharmony_ci case 256: 3418c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_CLK_CTL, 3428c2ecf20Sopenharmony_ci BIT(0) | BIT(1), 1); 3438c2ecf20Sopenharmony_ci break; 3448c2ecf20Sopenharmony_ci case 512: 3458c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_CLK_CTL, 3468c2ecf20Sopenharmony_ci BIT(0) | BIT(1), 2); 3478c2ecf20Sopenharmony_ci break; 3488c2ecf20Sopenharmony_ci case 1024: 3498c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_CLK_CTL, 3508c2ecf20Sopenharmony_ci BIT(0) | BIT(1), 3); 3518c2ecf20Sopenharmony_ci break; 3528c2ecf20Sopenharmony_ci default: 3538c2ecf20Sopenharmony_ci dev_err(component->dev, "Unsupported MCLKI\n"); 3548c2ecf20Sopenharmony_ci break; 3558c2ecf20Sopenharmony_ci } 3568c2ecf20Sopenharmony_ci } else { 3578c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_CLK_CTL, 3588c2ecf20Sopenharmony_ci BIT(0) | BIT(1), 0); 3598c2ecf20Sopenharmony_ci } 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci srate = get_srate(params_rate(hw_params)); 3628c2ecf20Sopenharmony_ci if (srate < 0) 3638c2ecf20Sopenharmony_ci return srate; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_SMPLING_RATE, 0xf, srate); 3668c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PLLNL, 0xff, coeff_div[i].pllnl); 3678c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PLLNH, 0x1, coeff_div[i].pllnh); 3688c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PLLML, 0xff, coeff_div[i].pllml); 3698c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh); 3708c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv); 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci return 0; 3738c2ecf20Sopenharmony_ci} 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_cistatic int ml26124_mute(struct snd_soc_dai *dai, int mute, int direction) 3768c2ecf20Sopenharmony_ci{ 3778c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 3788c2ecf20Sopenharmony_ci struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci switch (priv->substream->stream) { 3818c2ecf20Sopenharmony_ci case SNDRV_PCM_STREAM_CAPTURE: 3828c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(0), 1); 3838c2ecf20Sopenharmony_ci break; 3848c2ecf20Sopenharmony_ci case SNDRV_PCM_STREAM_PLAYBACK: 3858c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(1), 2); 3868c2ecf20Sopenharmony_ci break; 3878c2ecf20Sopenharmony_ci } 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci if (mute) 3908c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), 3918c2ecf20Sopenharmony_ci DVOL_CTL_DVMUTE_ON); 3928c2ecf20Sopenharmony_ci else 3938c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), 3948c2ecf20Sopenharmony_ci DVOL_CTL_DVMUTE_OFF); 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci return 0; 3978c2ecf20Sopenharmony_ci} 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_cistatic int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, 4008c2ecf20Sopenharmony_ci unsigned int fmt) 4018c2ecf20Sopenharmony_ci{ 4028c2ecf20Sopenharmony_ci unsigned char mode; 4038c2ecf20Sopenharmony_ci struct snd_soc_component *component = codec_dai->component; 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci /* set master/slave audio interface */ 4068c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 4078c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_CBM_CFM: 4088c2ecf20Sopenharmony_ci mode = 1; 4098c2ecf20Sopenharmony_ci break; 4108c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_CBS_CFS: 4118c2ecf20Sopenharmony_ci mode = 0; 4128c2ecf20Sopenharmony_ci break; 4138c2ecf20Sopenharmony_ci default: 4148c2ecf20Sopenharmony_ci return -EINVAL; 4158c2ecf20Sopenharmony_ci } 4168c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_SAI_MODE_SEL, BIT(0), mode); 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci /* interface format */ 4198c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 4208c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_I2S: 4218c2ecf20Sopenharmony_ci break; 4228c2ecf20Sopenharmony_ci default: 4238c2ecf20Sopenharmony_ci return -EINVAL; 4248c2ecf20Sopenharmony_ci } 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci /* clock inversion */ 4278c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 4288c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_NB_NF: 4298c2ecf20Sopenharmony_ci break; 4308c2ecf20Sopenharmony_ci default: 4318c2ecf20Sopenharmony_ci return -EINVAL; 4328c2ecf20Sopenharmony_ci } 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci return 0; 4358c2ecf20Sopenharmony_ci} 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_cistatic int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai, 4388c2ecf20Sopenharmony_ci int clk_id, unsigned int freq, int dir) 4398c2ecf20Sopenharmony_ci{ 4408c2ecf20Sopenharmony_ci struct snd_soc_component *component = codec_dai->component; 4418c2ecf20Sopenharmony_ci struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci switch (clk_id) { 4448c2ecf20Sopenharmony_ci case ML26124_USE_PLLOUT: 4458c2ecf20Sopenharmony_ci priv->clk_in = ML26124_USE_PLLOUT; 4468c2ecf20Sopenharmony_ci break; 4478c2ecf20Sopenharmony_ci case ML26124_USE_MCLKI: 4488c2ecf20Sopenharmony_ci priv->clk_in = ML26124_USE_MCLKI; 4498c2ecf20Sopenharmony_ci break; 4508c2ecf20Sopenharmony_ci default: 4518c2ecf20Sopenharmony_ci return -EINVAL; 4528c2ecf20Sopenharmony_ci } 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci priv->mclk = freq; 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci return 0; 4578c2ecf20Sopenharmony_ci} 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_cistatic int ml26124_set_bias_level(struct snd_soc_component *component, 4608c2ecf20Sopenharmony_ci enum snd_soc_bias_level level) 4618c2ecf20Sopenharmony_ci{ 4628c2ecf20Sopenharmony_ci struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci switch (level) { 4658c2ecf20Sopenharmony_ci case SND_SOC_BIAS_ON: 4668c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, 4678c2ecf20Sopenharmony_ci ML26124_R26_MASK, ML26124_BLT_PREAMP_ON); 4688c2ecf20Sopenharmony_ci msleep(100); 4698c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, 4708c2ecf20Sopenharmony_ci ML26124_R26_MASK, 4718c2ecf20Sopenharmony_ci ML26124_MICBEN_ON | ML26124_BLT_ALL_ON); 4728c2ecf20Sopenharmony_ci break; 4738c2ecf20Sopenharmony_ci case SND_SOC_BIAS_PREPARE: 4748c2ecf20Sopenharmony_ci break; 4758c2ecf20Sopenharmony_ci case SND_SOC_BIAS_STANDBY: 4768c2ecf20Sopenharmony_ci /* VMID ON */ 4778c2ecf20Sopenharmony_ci if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { 4788c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, 4798c2ecf20Sopenharmony_ci ML26124_VMID, ML26124_VMID); 4808c2ecf20Sopenharmony_ci msleep(500); 4818c2ecf20Sopenharmony_ci regcache_sync(priv->regmap); 4828c2ecf20Sopenharmony_ci } 4838c2ecf20Sopenharmony_ci break; 4848c2ecf20Sopenharmony_ci case SND_SOC_BIAS_OFF: 4858c2ecf20Sopenharmony_ci /* VMID OFF */ 4868c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, 4878c2ecf20Sopenharmony_ci ML26124_VMID, 0); 4888c2ecf20Sopenharmony_ci break; 4898c2ecf20Sopenharmony_ci } 4908c2ecf20Sopenharmony_ci return 0; 4918c2ecf20Sopenharmony_ci} 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops ml26124_dai_ops = { 4948c2ecf20Sopenharmony_ci .hw_params = ml26124_hw_params, 4958c2ecf20Sopenharmony_ci .mute_stream = ml26124_mute, 4968c2ecf20Sopenharmony_ci .set_fmt = ml26124_set_dai_fmt, 4978c2ecf20Sopenharmony_ci .set_sysclk = ml26124_set_dai_sysclk, 4988c2ecf20Sopenharmony_ci .no_capture_mute = 1, 4998c2ecf20Sopenharmony_ci}; 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver ml26124_dai = { 5028c2ecf20Sopenharmony_ci .name = "ml26124-hifi", 5038c2ecf20Sopenharmony_ci .playback = { 5048c2ecf20Sopenharmony_ci .stream_name = "Playback", 5058c2ecf20Sopenharmony_ci .channels_min = 1, 5068c2ecf20Sopenharmony_ci .channels_max = 2, 5078c2ecf20Sopenharmony_ci .rates = ML26124_RATES, 5088c2ecf20Sopenharmony_ci .formats = ML26124_FORMATS,}, 5098c2ecf20Sopenharmony_ci .capture = { 5108c2ecf20Sopenharmony_ci .stream_name = "Capture", 5118c2ecf20Sopenharmony_ci .channels_min = 1, 5128c2ecf20Sopenharmony_ci .channels_max = 2, 5138c2ecf20Sopenharmony_ci .rates = ML26124_RATES, 5148c2ecf20Sopenharmony_ci .formats = ML26124_FORMATS,}, 5158c2ecf20Sopenharmony_ci .ops = &ml26124_dai_ops, 5168c2ecf20Sopenharmony_ci .symmetric_rates = 1, 5178c2ecf20Sopenharmony_ci}; 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_cistatic int ml26124_probe(struct snd_soc_component *component) 5208c2ecf20Sopenharmony_ci{ 5218c2ecf20Sopenharmony_ci /* Software Reset */ 5228c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 1); 5238c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 0); 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci return 0; 5268c2ecf20Sopenharmony_ci} 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver soc_component_dev_ml26124 = { 5298c2ecf20Sopenharmony_ci .probe = ml26124_probe, 5308c2ecf20Sopenharmony_ci .set_bias_level = ml26124_set_bias_level, 5318c2ecf20Sopenharmony_ci .controls = ml26124_snd_controls, 5328c2ecf20Sopenharmony_ci .num_controls = ARRAY_SIZE(ml26124_snd_controls), 5338c2ecf20Sopenharmony_ci .dapm_widgets = ml26124_dapm_widgets, 5348c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(ml26124_dapm_widgets), 5358c2ecf20Sopenharmony_ci .dapm_routes = ml26124_intercon, 5368c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(ml26124_intercon), 5378c2ecf20Sopenharmony_ci .suspend_bias_off = 1, 5388c2ecf20Sopenharmony_ci .idle_bias_on = 1, 5398c2ecf20Sopenharmony_ci .use_pmdown_time = 1, 5408c2ecf20Sopenharmony_ci .endianness = 1, 5418c2ecf20Sopenharmony_ci .non_legacy_dai_naming = 1, 5428c2ecf20Sopenharmony_ci}; 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_cistatic const struct regmap_config ml26124_i2c_regmap = { 5458c2ecf20Sopenharmony_ci .val_bits = 8, 5468c2ecf20Sopenharmony_ci .reg_bits = 8, 5478c2ecf20Sopenharmony_ci .max_register = ML26124_NUM_REGISTER, 5488c2ecf20Sopenharmony_ci .reg_defaults = ml26124_reg, 5498c2ecf20Sopenharmony_ci .num_reg_defaults = ARRAY_SIZE(ml26124_reg), 5508c2ecf20Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 5518c2ecf20Sopenharmony_ci .write_flag_mask = 0x01, 5528c2ecf20Sopenharmony_ci}; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_cistatic int ml26124_i2c_probe(struct i2c_client *i2c, 5558c2ecf20Sopenharmony_ci const struct i2c_device_id *id) 5568c2ecf20Sopenharmony_ci{ 5578c2ecf20Sopenharmony_ci struct ml26124_priv *priv; 5588c2ecf20Sopenharmony_ci int ret; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); 5618c2ecf20Sopenharmony_ci if (!priv) 5628c2ecf20Sopenharmony_ci return -ENOMEM; 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci i2c_set_clientdata(i2c, priv); 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci priv->regmap = devm_regmap_init_i2c(i2c, &ml26124_i2c_regmap); 5678c2ecf20Sopenharmony_ci if (IS_ERR(priv->regmap)) { 5688c2ecf20Sopenharmony_ci ret = PTR_ERR(priv->regmap); 5698c2ecf20Sopenharmony_ci dev_err(&i2c->dev, "regmap_init_i2c() failed: %d\n", ret); 5708c2ecf20Sopenharmony_ci return ret; 5718c2ecf20Sopenharmony_ci } 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci return devm_snd_soc_register_component(&i2c->dev, 5748c2ecf20Sopenharmony_ci &soc_component_dev_ml26124, &ml26124_dai, 1); 5758c2ecf20Sopenharmony_ci} 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_cistatic const struct i2c_device_id ml26124_i2c_id[] = { 5788c2ecf20Sopenharmony_ci { "ml26124", 0 }, 5798c2ecf20Sopenharmony_ci { } 5808c2ecf20Sopenharmony_ci}; 5818c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, ml26124_i2c_id); 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_cistatic struct i2c_driver ml26124_i2c_driver = { 5848c2ecf20Sopenharmony_ci .driver = { 5858c2ecf20Sopenharmony_ci .name = "ml26124", 5868c2ecf20Sopenharmony_ci }, 5878c2ecf20Sopenharmony_ci .probe = ml26124_i2c_probe, 5888c2ecf20Sopenharmony_ci .id_table = ml26124_i2c_id, 5898c2ecf20Sopenharmony_ci}; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_cimodule_i2c_driver(ml26124_i2c_driver); 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ciMODULE_AUTHOR("Tomoya MORINAGA <tomoya.rohm@gmail.com>"); 5948c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("LAPIS Semiconductor ML26124 ALSA SoC codec driver"); 5958c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 596