Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * 88pm860x-codec.c -- 88PM860x ALSA SoC Audio Driver
0004  *
0005  * Copyright 2010 Marvell International Ltd.
0006  * Author: Haojian Zhuang <haojian.zhuang@marvell.com>
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/module.h>
0011 #include <linux/i2c.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/mfd/88pm860x.h>
0014 #include <linux/slab.h>
0015 #include <linux/delay.h>
0016 #include <linux/regmap.h>
0017 #include <sound/core.h>
0018 #include <sound/pcm.h>
0019 #include <sound/pcm_params.h>
0020 #include <sound/soc.h>
0021 #include <sound/tlv.h>
0022 #include <sound/initval.h>
0023 #include <sound/jack.h>
0024 #include <trace/events/asoc.h>
0025 
0026 #include "88pm860x-codec.h"
0027 
0028 #define MAX_NAME_LEN        20
0029 #define REG_CACHE_SIZE      0x40
0030 #define REG_CACHE_BASE      0xb0
0031 
0032 /* Status Register 1 (0x01) */
0033 #define REG_STATUS_1        0x01
0034 #define MIC_STATUS      (1 << 7)
0035 #define HOOK_STATUS     (1 << 6)
0036 #define HEADSET_STATUS      (1 << 5)
0037 
0038 /* Mic Detection Register (0x37) */
0039 #define REG_MIC_DET     0x37
0040 #define CONTINUOUS_POLLING  (3 << 1)
0041 #define EN_MIC_DET      (1 << 0)
0042 #define MICDET_MASK     0x07
0043 
0044 /* Headset Detection Register (0x38) */
0045 #define REG_HS_DET      0x38
0046 #define EN_HS_DET       (1 << 0)
0047 
0048 /* Misc2 Register (0x42) */
0049 #define REG_MISC2       0x42
0050 #define AUDIO_PLL       (1 << 5)
0051 #define AUDIO_SECTION_RESET (1 << 4)
0052 #define AUDIO_SECTION_ON    (1 << 3)
0053 
0054 /* PCM Interface Register 2 (0xb1) */
0055 #define PCM_INF2_BCLK       (1 << 6)    /* Bit clock polarity */
0056 #define PCM_INF2_FS     (1 << 5)    /* Frame Sync polarity */
0057 #define PCM_INF2_MASTER     (1 << 4)    /* Master / Slave */
0058 #define PCM_INF2_18WL       (1 << 3)    /* 18 / 16 bits */
0059 #define PCM_GENERAL_I2S     0
0060 #define PCM_EXACT_I2S       1
0061 #define PCM_LEFT_I2S        2
0062 #define PCM_RIGHT_I2S       3
0063 #define PCM_SHORT_FS        4
0064 #define PCM_LONG_FS     5
0065 #define PCM_MODE_MASK       7
0066 
0067 /* I2S Interface Register 4 (0xbe) */
0068 #define I2S_EQU_BYP     (1 << 6)
0069 
0070 /* DAC Offset Register (0xcb) */
0071 #define DAC_MUTE        (1 << 7)
0072 #define MUTE_LEFT       (1 << 6)
0073 #define MUTE_RIGHT      (1 << 2)
0074 
0075 /* ADC Analog Register 1 (0xd0) */
0076 #define REG_ADC_ANA_1       0xd0
0077 #define MIC1BIAS_MASK       0x60
0078 
0079 /* Earpiece/Speaker Control Register 2 (0xda) */
0080 #define REG_EAR2        0xda
0081 #define RSYNC_CHANGE        (1 << 2)
0082 
0083 /* Audio Supplies Register 2 (0xdc) */
0084 #define REG_SUPPLIES2       0xdc
0085 #define LDO15_READY     (1 << 4)
0086 #define LDO15_EN        (1 << 3)
0087 #define CPUMP_READY     (1 << 2)
0088 #define CPUMP_EN        (1 << 1)
0089 #define AUDIO_EN        (1 << 0)
0090 #define SUPPLY_MASK     (LDO15_EN | CPUMP_EN | AUDIO_EN)
0091 
0092 /* Audio Enable Register 1 (0xdd) */
0093 #define ADC_MOD_RIGHT       (1 << 1)
0094 #define ADC_MOD_LEFT        (1 << 0)
0095 
0096 /* Audio Enable Register 2 (0xde) */
0097 #define ADC_LEFT        (1 << 5)
0098 #define ADC_RIGHT       (1 << 4)
0099 
0100 /* DAC Enable Register 2 (0xe1) */
0101 #define DAC_LEFT        (1 << 5)
0102 #define DAC_RIGHT       (1 << 4)
0103 #define MODULATOR       (1 << 3)
0104 
0105 /* Shorts Register (0xeb) */
0106 #define REG_SHORTS      0xeb
0107 #define CLR_SHORT_LO2       (1 << 7)
0108 #define SHORT_LO2       (1 << 6)
0109 #define CLR_SHORT_LO1       (1 << 5)
0110 #define SHORT_LO1       (1 << 4)
0111 #define CLR_SHORT_HS2       (1 << 3)
0112 #define SHORT_HS2       (1 << 2)
0113 #define CLR_SHORT_HS1       (1 << 1)
0114 #define SHORT_HS1       (1 << 0)
0115 
0116 /*
0117  * This widget should be just after DAC & PGA in DAPM power-on sequence and
0118  * before DAC & PGA in DAPM power-off sequence.
0119  */
0120 #define PM860X_DAPM_OUTPUT(wname, wevent)   \
0121     SND_SOC_DAPM_PGA_E(wname, SND_SOC_NOPM, 0, 0, NULL, 0, wevent, \
0122                 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD)
0123 
0124 struct pm860x_det {
0125     struct snd_soc_jack *hp_jack;
0126     struct snd_soc_jack *mic_jack;
0127     int         hp_det;
0128     int         mic_det;
0129     int         hook_det;
0130     int         hs_shrt;
0131     int         lo_shrt;
0132 };
0133 
0134 struct pm860x_priv {
0135     unsigned int        sysclk;
0136     unsigned int        pcmclk;
0137     unsigned int        dir;
0138     unsigned int        filter;
0139     struct snd_soc_component *component;
0140     struct i2c_client   *i2c;
0141     struct regmap       *regmap;
0142     struct pm860x_chip  *chip;
0143     struct pm860x_det   det;
0144 
0145     int         irq[4];
0146     unsigned char       name[4][MAX_NAME_LEN+1];
0147 };
0148 
0149 /* -9450dB to 0dB in 150dB steps ( mute instead of -9450dB) */
0150 static const DECLARE_TLV_DB_SCALE(dpga_tlv, -9450, 150, 1);
0151 
0152 /* -9dB to 0db in 3dB steps */
0153 static const DECLARE_TLV_DB_SCALE(adc_tlv, -900, 300, 0);
0154 
0155 /* {-23, -17, -13.5, -11, -9, -6, -3, 0}dB */
0156 static const DECLARE_TLV_DB_RANGE(mic_tlv,
0157     0, 0, TLV_DB_SCALE_ITEM(-2300, 0, 0),
0158     1, 1, TLV_DB_SCALE_ITEM(-1700, 0, 0),
0159     2, 2, TLV_DB_SCALE_ITEM(-1350, 0, 0),
0160     3, 3, TLV_DB_SCALE_ITEM(-1100, 0, 0),
0161     4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0)
0162 );
0163 
0164 /* {0, 0, 0, -6, 0, 6, 12, 18}dB */
0165 static const DECLARE_TLV_DB_RANGE(aux_tlv,
0166     0, 2, TLV_DB_SCALE_ITEM(0, 0, 0),
0167     3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0)
0168 );
0169 
0170 /* {-16, -13, -10, -7, -5.2, -3,3, -2.2, 0}dB, mute instead of -16dB */
0171 static const DECLARE_TLV_DB_RANGE(out_tlv,
0172     0, 3, TLV_DB_SCALE_ITEM(-1600, 300, 1),
0173     4, 4, TLV_DB_SCALE_ITEM(-520, 0, 0),
0174     5, 5, TLV_DB_SCALE_ITEM(-330, 0, 0),
0175     6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0)
0176 );
0177 
0178 static const DECLARE_TLV_DB_RANGE(st_tlv,
0179     0, 1, TLV_DB_SCALE_ITEM(-12041, 602, 0),
0180     2, 3, TLV_DB_SCALE_ITEM(-11087, 250, 0),
0181     4, 5, TLV_DB_SCALE_ITEM(-10643, 158, 0),
0182     6, 7, TLV_DB_SCALE_ITEM(-10351, 116, 0),
0183     8, 9, TLV_DB_SCALE_ITEM(-10133, 92, 0),
0184     10, 13, TLV_DB_SCALE_ITEM(-9958, 70, 0),
0185     14, 17, TLV_DB_SCALE_ITEM(-9689, 53, 0),
0186     18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0)
0187 );
0188 
0189 /* Sidetone Gain = M * 2^(-5-N) */
0190 struct st_gain {
0191     unsigned int    db;
0192     unsigned int    m;
0193     unsigned int    n;
0194 };
0195 
0196 static struct st_gain st_table[] = {
0197     {-12041,  1, 15}, {-11439,  1, 14}, {-11087,  3, 15}, {-10837,  1, 13},
0198     {-10643,  5, 15}, {-10485,  3, 14}, {-10351,  7, 15}, {-10235,  1, 12},
0199     {-10133,  9, 15}, {-10041,  5, 14}, { -9958, 11, 15}, { -9883,  3, 13},
0200     { -9813, 13, 15}, { -9749,  7, 14}, { -9689, 15, 15}, { -9633,  1, 11},
0201     { -9580, 17, 15}, { -9531,  9, 14}, { -9484, 19, 15}, { -9439,  5, 13},
0202     { -9397, 21, 15}, { -9356, 11, 14}, { -9318, 23, 15}, { -9281,  3, 12},
0203     { -9245, 25, 15}, { -9211, 13, 14}, { -9178, 27, 15}, { -9147,  7, 13},
0204     { -9116, 29, 15}, { -9087, 15, 14}, { -9058, 31, 15}, { -9031,  1, 10},
0205     { -8978, 17, 14}, { -8929,  9, 13}, { -8882, 19, 14}, { -8837,  5, 12},
0206     { -8795, 21, 14}, { -8754, 11, 13}, { -8716, 23, 14}, { -8679,  3, 11},
0207     { -8643, 25, 14}, { -8609, 13, 13}, { -8576, 27, 14}, { -8545,  7, 12},
0208     { -8514, 29, 14}, { -8485, 15, 13}, { -8456, 31, 14}, { -8429,  1,  9},
0209     { -8376, 17, 13}, { -8327,  9, 12}, { -8280, 19, 13}, { -8235,  5, 11},
0210     { -8193, 21, 13}, { -8152, 11, 12}, { -8114, 23, 13}, { -8077,  3, 10},
0211     { -8041, 25, 13}, { -8007, 13, 12}, { -7974, 27, 13}, { -7943,  7, 11},
0212     { -7912, 29, 13}, { -7883, 15, 12}, { -7854, 31, 13}, { -7827,  1,  8},
0213     { -7774, 17, 12}, { -7724,  9, 11}, { -7678, 19, 12}, { -7633,  5, 10},
0214     { -7591, 21, 12}, { -7550, 11, 11}, { -7512, 23, 12}, { -7475,  3,  9},
0215     { -7439, 25, 12}, { -7405, 13, 11}, { -7372, 27, 12}, { -7341,  7, 10},
0216     { -7310, 29, 12}, { -7281, 15, 11}, { -7252, 31, 12}, { -7225,  1,  7},
0217     { -7172, 17, 11}, { -7122,  9, 10}, { -7075, 19, 11}, { -7031,  5,  9},
0218     { -6989, 21, 11}, { -6948, 11, 10}, { -6910, 23, 11}, { -6873,  3,  8},
0219     { -6837, 25, 11}, { -6803, 13, 10}, { -6770, 27, 11}, { -6739,  7,  9},
0220     { -6708, 29, 11}, { -6679, 15, 10}, { -6650, 31, 11}, { -6623,  1,  6},
0221     { -6570, 17, 10}, { -6520,  9,  9}, { -6473, 19, 10}, { -6429,  5,  8},
0222     { -6386, 21, 10}, { -6346, 11,  9}, { -6307, 23, 10}, { -6270,  3,  7},
0223     { -6235, 25, 10}, { -6201, 13,  9}, { -6168, 27, 10}, { -6137,  7,  8},
0224     { -6106, 29, 10}, { -6077, 15,  9}, { -6048, 31, 10}, { -6021,  1,  5},
0225     { -5968, 17,  9}, { -5918,  9,  8}, { -5871, 19,  9}, { -5827,  5,  7},
0226     { -5784, 21,  9}, { -5744, 11,  8}, { -5705, 23,  9}, { -5668,  3,  6},
0227     { -5633, 25,  9}, { -5599, 13,  8}, { -5566, 27,  9}, { -5535,  7,  7},
0228     { -5504, 29,  9}, { -5475, 15,  8}, { -5446, 31,  9}, { -5419,  1,  4},
0229     { -5366, 17,  8}, { -5316,  9,  7}, { -5269, 19,  8}, { -5225,  5,  6},
0230     { -5182, 21,  8}, { -5142, 11,  7}, { -5103, 23,  8}, { -5066,  3,  5},
0231     { -5031, 25,  8}, { -4997, 13,  7}, { -4964, 27,  8}, { -4932,  7,  6},
0232     { -4902, 29,  8}, { -4873, 15,  7}, { -4844, 31,  8}, { -4816,  1,  3},
0233     { -4764, 17,  7}, { -4714,  9,  6}, { -4667, 19,  7}, { -4623,  5,  5},
0234     { -4580, 21,  7}, { -4540, 11,  6}, { -4501, 23,  7}, { -4464,  3,  4},
0235     { -4429, 25,  7}, { -4395, 13,  6}, { -4362, 27,  7}, { -4330,  7,  5},
0236     { -4300, 29,  7}, { -4270, 15,  6}, { -4242, 31,  7}, { -4214,  1,  2},
0237     { -4162, 17,  6}, { -4112,  9,  5}, { -4065, 19,  6}, { -4021,  5,  4},
0238     { -3978, 21,  6}, { -3938, 11,  5}, { -3899, 23,  6}, { -3862,  3,  3},
0239     { -3827, 25,  6}, { -3793, 13,  5}, { -3760, 27,  6}, { -3728,  7,  4},
0240     { -3698, 29,  6}, { -3668, 15,  5}, { -3640, 31,  6}, { -3612,  1,  1},
0241     { -3560, 17,  5}, { -3510,  9,  4}, { -3463, 19,  5}, { -3419,  5,  3},
0242     { -3376, 21,  5}, { -3336, 11,  4}, { -3297, 23,  5}, { -3260,  3,  2},
0243     { -3225, 25,  5}, { -3191, 13,  4}, { -3158, 27,  5}, { -3126,  7,  3},
0244     { -3096, 29,  5}, { -3066, 15,  4}, { -3038, 31,  5}, { -3010,  1,  0},
0245     { -2958, 17,  4}, { -2908,  9,  3}, { -2861, 19,  4}, { -2816,  5,  2},
0246     { -2774, 21,  4}, { -2734, 11,  3}, { -2695, 23,  4}, { -2658,  3,  1},
0247     { -2623, 25,  4}, { -2589, 13,  3}, { -2556, 27,  4}, { -2524,  7,  2},
0248     { -2494, 29,  4}, { -2464, 15,  3}, { -2436, 31,  4}, { -2408,  2,  0},
0249     { -2356, 17,  3}, { -2306,  9,  2}, { -2259, 19,  3}, { -2214,  5,  1},
0250     { -2172, 21,  3}, { -2132, 11,  2}, { -2093, 23,  3}, { -2056,  3,  0},
0251     { -2021, 25,  3}, { -1987, 13,  2}, { -1954, 27,  3}, { -1922,  7,  1},
0252     { -1892, 29,  3}, { -1862, 15,  2}, { -1834, 31,  3}, { -1806,  4,  0},
0253     { -1754, 17,  2}, { -1704,  9,  1}, { -1657, 19,  2}, { -1612,  5,  0},
0254     { -1570, 21,  2}, { -1530, 11,  1}, { -1491, 23,  2}, { -1454,  6,  0},
0255     { -1419, 25,  2}, { -1384, 13,  1}, { -1352, 27,  2}, { -1320,  7,  0},
0256     { -1290, 29,  2}, { -1260, 15,  1}, { -1232, 31,  2}, { -1204,  8,  0},
0257     { -1151, 17,  1}, { -1102,  9,  0}, { -1055, 19,  1}, { -1010, 10,  0},
0258     {  -968, 21,  1}, {  -928, 11,  0}, {  -889, 23,  1}, {  -852, 12,  0},
0259     {  -816, 25,  1}, {  -782, 13,  0}, {  -750, 27,  1}, {  -718, 14,  0},
0260     {  -688, 29,  1}, {  -658, 15,  0}, {  -630, 31,  1}, {  -602, 16,  0},
0261     {  -549, 17,  0}, {  -500, 18,  0}, {  -453, 19,  0}, {  -408, 20,  0},
0262     {  -366, 21,  0}, {  -325, 22,  0}, {  -287, 23,  0}, {  -250, 24,  0},
0263     {  -214, 25,  0}, {  -180, 26,  0}, {  -148, 27,  0}, {  -116, 28,  0},
0264     {   -86, 29,  0}, {   -56, 30,  0}, {   -28, 31,  0}, {     0,  0,  0},
0265 };
0266 
0267 static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
0268                    struct snd_ctl_elem_value *ucontrol)
0269 {
0270     struct soc_mixer_control *mc =
0271         (struct soc_mixer_control *)kcontrol->private_value;
0272     struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0273     unsigned int reg = mc->reg;
0274     unsigned int reg2 = mc->rreg;
0275     int val[2], val2[2], i;
0276 
0277     val[0] = snd_soc_component_read(component, reg) & 0x3f;
0278     val[1] = (snd_soc_component_read(component, PM860X_SIDETONE_SHIFT) >> 4) & 0xf;
0279     val2[0] = snd_soc_component_read(component, reg2) & 0x3f;
0280     val2[1] = (snd_soc_component_read(component, PM860X_SIDETONE_SHIFT)) & 0xf;
0281 
0282     for (i = 0; i < ARRAY_SIZE(st_table); i++) {
0283         if ((st_table[i].m == val[0]) && (st_table[i].n == val[1]))
0284             ucontrol->value.integer.value[0] = i;
0285         if ((st_table[i].m == val2[0]) && (st_table[i].n == val2[1]))
0286             ucontrol->value.integer.value[1] = i;
0287     }
0288     return 0;
0289 }
0290 
0291 static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
0292                    struct snd_ctl_elem_value *ucontrol)
0293 {
0294     struct soc_mixer_control *mc =
0295         (struct soc_mixer_control *)kcontrol->private_value;
0296     struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0297     unsigned int reg = mc->reg;
0298     unsigned int reg2 = mc->rreg;
0299     int err;
0300     unsigned int val, val2;
0301 
0302     val = ucontrol->value.integer.value[0];
0303     val2 = ucontrol->value.integer.value[1];
0304 
0305     if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table))
0306         return -EINVAL;
0307 
0308     err = snd_soc_component_update_bits(component, reg, 0x3f, st_table[val].m);
0309     if (err < 0)
0310         return err;
0311     err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0xf0,
0312                   st_table[val].n << 4);
0313     if (err < 0)
0314         return err;
0315 
0316     err = snd_soc_component_update_bits(component, reg2, 0x3f, st_table[val2].m);
0317     if (err < 0)
0318         return err;
0319     err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0x0f,
0320                   st_table[val2].n);
0321     return err;
0322 }
0323 
0324 static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol,
0325                     struct snd_ctl_elem_value *ucontrol)
0326 {
0327     struct soc_mixer_control *mc =
0328         (struct soc_mixer_control *)kcontrol->private_value;
0329     struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0330     unsigned int reg = mc->reg;
0331     unsigned int reg2 = mc->rreg;
0332     unsigned int shift = mc->shift;
0333     int max = mc->max, val, val2;
0334     unsigned int mask = (1 << fls(max)) - 1;
0335 
0336     val = snd_soc_component_read(component, reg) >> shift;
0337     val2 = snd_soc_component_read(component, reg2) >> shift;
0338     ucontrol->value.integer.value[0] = (max - val) & mask;
0339     ucontrol->value.integer.value[1] = (max - val2) & mask;
0340 
0341     return 0;
0342 }
0343 
0344 static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
0345                     struct snd_ctl_elem_value *ucontrol)
0346 {
0347     struct soc_mixer_control *mc =
0348         (struct soc_mixer_control *)kcontrol->private_value;
0349     struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
0350     unsigned int reg = mc->reg;
0351     unsigned int reg2 = mc->rreg;
0352     unsigned int shift = mc->shift;
0353     int max = mc->max;
0354     unsigned int mask = (1 << fls(max)) - 1;
0355     int err;
0356     unsigned int val, val2, val_mask;
0357 
0358     val_mask = mask << shift;
0359     val = ((max - ucontrol->value.integer.value[0]) & mask);
0360     val2 = ((max - ucontrol->value.integer.value[1]) & mask);
0361 
0362     val = val << shift;
0363     val2 = val2 << shift;
0364 
0365     err = snd_soc_component_update_bits(component, reg, val_mask, val);
0366     if (err < 0)
0367         return err;
0368 
0369     err = snd_soc_component_update_bits(component, reg2, val_mask, val2);
0370     return err;
0371 }
0372 
0373 /* DAPM Widget Events */
0374 /*
0375  * A lot registers are belong to RSYNC domain. It requires enabling RSYNC bit
0376  * after updating these registers. Otherwise, these updated registers won't
0377  * be effective.
0378  */
0379 static int pm860x_rsync_event(struct snd_soc_dapm_widget *w,
0380                   struct snd_kcontrol *kcontrol, int event)
0381 {
0382     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
0383 
0384     /*
0385      * In order to avoid current on the load, mute power-on and power-off
0386      * should be transients.
0387      * Unmute by DAC_MUTE. It should be unmuted when DAPM sequence is
0388      * finished.
0389      */
0390     snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, DAC_MUTE, 0);
0391     snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
0392                 RSYNC_CHANGE, RSYNC_CHANGE);
0393     return 0;
0394 }
0395 
0396 static int pm860x_dac_event(struct snd_soc_dapm_widget *w,
0397                 struct snd_kcontrol *kcontrol, int event)
0398 {
0399     struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
0400     unsigned int dac = 0;
0401     int data;
0402 
0403     if (!strcmp(w->name, "Left DAC"))
0404         dac = DAC_LEFT;
0405     if (!strcmp(w->name, "Right DAC"))
0406         dac = DAC_RIGHT;
0407     switch (event) {
0408     case SND_SOC_DAPM_PRE_PMU:
0409         if (dac) {
0410             /* Auto mute in power-on sequence. */
0411             dac |= MODULATOR;
0412             snd_soc_component_update_bits(component, PM860X_DAC_OFFSET,
0413                         DAC_MUTE, DAC_MUTE);
0414             snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
0415                         RSYNC_CHANGE, RSYNC_CHANGE);
0416             /* update dac */
0417             snd_soc_component_update_bits(component, PM860X_DAC_EN_2,
0418                         dac, dac);
0419         }
0420         break;
0421     case SND_SOC_DAPM_PRE_PMD:
0422         if (dac) {
0423             /* Auto mute in power-off sequence. */
0424             snd_soc_component_update_bits(component, PM860X_DAC_OFFSET,
0425                         DAC_MUTE, DAC_MUTE);
0426             snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
0427                         RSYNC_CHANGE, RSYNC_CHANGE);
0428             /* update dac */
0429             data = snd_soc_component_read(component, PM860X_DAC_EN_2);
0430             data &= ~dac;
0431             if (!(data & (DAC_LEFT | DAC_RIGHT)))
0432                 data &= ~MODULATOR;
0433             snd_soc_component_write(component, PM860X_DAC_EN_2, data);
0434         }
0435         break;
0436     }
0437     return 0;
0438 }
0439 
0440 static const char *pm860x_opamp_texts[] = {"-50%", "-25%", "0%", "75%"};
0441 
0442 static const char *pm860x_pa_texts[] = {"-33%", "0%", "33%", "66%"};
0443 
0444 static SOC_ENUM_SINGLE_DECL(pm860x_hs1_opamp_enum,
0445                 PM860X_HS1_CTRL, 5, pm860x_opamp_texts);
0446 
0447 static SOC_ENUM_SINGLE_DECL(pm860x_hs2_opamp_enum,
0448                 PM860X_HS2_CTRL, 5, pm860x_opamp_texts);
0449 
0450 static SOC_ENUM_SINGLE_DECL(pm860x_hs1_pa_enum,
0451                 PM860X_HS1_CTRL, 3, pm860x_pa_texts);
0452 
0453 static SOC_ENUM_SINGLE_DECL(pm860x_hs2_pa_enum,
0454                 PM860X_HS2_CTRL, 3, pm860x_pa_texts);
0455 
0456 static SOC_ENUM_SINGLE_DECL(pm860x_lo1_opamp_enum,
0457                 PM860X_LO1_CTRL, 5, pm860x_opamp_texts);
0458 
0459 static SOC_ENUM_SINGLE_DECL(pm860x_lo2_opamp_enum,
0460                 PM860X_LO2_CTRL, 5, pm860x_opamp_texts);
0461 
0462 static SOC_ENUM_SINGLE_DECL(pm860x_lo1_pa_enum,
0463                 PM860X_LO1_CTRL, 3, pm860x_pa_texts);
0464 
0465 static SOC_ENUM_SINGLE_DECL(pm860x_lo2_pa_enum,
0466                 PM860X_LO2_CTRL, 3, pm860x_pa_texts);
0467 
0468 static SOC_ENUM_SINGLE_DECL(pm860x_spk_pa_enum,
0469                 PM860X_EAR_CTRL_1, 5, pm860x_pa_texts);
0470 
0471 static SOC_ENUM_SINGLE_DECL(pm860x_ear_pa_enum,
0472                 PM860X_EAR_CTRL_2, 0, pm860x_pa_texts);
0473 
0474 static SOC_ENUM_SINGLE_DECL(pm860x_spk_ear_opamp_enum,
0475                 PM860X_EAR_CTRL_1, 3, pm860x_opamp_texts);
0476 
0477 static const struct snd_kcontrol_new pm860x_snd_controls[] = {
0478     SOC_DOUBLE_R_TLV("ADC Capture Volume", PM860X_ADC_ANA_2,
0479             PM860X_ADC_ANA_3, 6, 3, 0, adc_tlv),
0480     SOC_DOUBLE_TLV("AUX Capture Volume", PM860X_ADC_ANA_3, 0, 3, 7, 0,
0481             aux_tlv),
0482     SOC_SINGLE_TLV("MIC1 Capture Volume", PM860X_ADC_ANA_2, 0, 7, 0,
0483             mic_tlv),
0484     SOC_SINGLE_TLV("MIC3 Capture Volume", PM860X_ADC_ANA_2, 3, 7, 0,
0485             mic_tlv),
0486     SOC_DOUBLE_R_EXT_TLV("Sidetone Volume", PM860X_SIDETONE_L_GAIN,
0487                  PM860X_SIDETONE_R_GAIN, 0, ARRAY_SIZE(st_table)-1,
0488                  0, snd_soc_get_volsw_2r_st,
0489                  snd_soc_put_volsw_2r_st, st_tlv),
0490     SOC_SINGLE_TLV("Speaker Playback Volume", PM860X_EAR_CTRL_1,
0491             0, 7, 0, out_tlv),
0492     SOC_DOUBLE_R_TLV("Line Playback Volume", PM860X_LO1_CTRL,
0493              PM860X_LO2_CTRL, 0, 7, 0, out_tlv),
0494     SOC_DOUBLE_R_TLV("Headset Playback Volume", PM860X_HS1_CTRL,
0495              PM860X_HS2_CTRL, 0, 7, 0, out_tlv),
0496     SOC_DOUBLE_R_EXT_TLV("Hifi Left Playback Volume",
0497                  PM860X_HIFIL_GAIN_LEFT,
0498                  PM860X_HIFIL_GAIN_RIGHT, 0, 63, 0,
0499                  snd_soc_get_volsw_2r_out,
0500                  snd_soc_put_volsw_2r_out, dpga_tlv),
0501     SOC_DOUBLE_R_EXT_TLV("Hifi Right Playback Volume",
0502                  PM860X_HIFIR_GAIN_LEFT,
0503                  PM860X_HIFIR_GAIN_RIGHT, 0, 63, 0,
0504                  snd_soc_get_volsw_2r_out,
0505                  snd_soc_put_volsw_2r_out, dpga_tlv),
0506     SOC_DOUBLE_R_EXT_TLV("Lofi Playback Volume", PM860X_LOFI_GAIN_LEFT,
0507                  PM860X_LOFI_GAIN_RIGHT, 0, 63, 0,
0508                  snd_soc_get_volsw_2r_out,
0509                  snd_soc_put_volsw_2r_out, dpga_tlv),
0510     SOC_ENUM("Headset1 Operational Amplifier Current",
0511          pm860x_hs1_opamp_enum),
0512     SOC_ENUM("Headset2 Operational Amplifier Current",
0513          pm860x_hs2_opamp_enum),
0514     SOC_ENUM("Headset1 Amplifier Current", pm860x_hs1_pa_enum),
0515     SOC_ENUM("Headset2 Amplifier Current", pm860x_hs2_pa_enum),
0516     SOC_ENUM("Lineout1 Operational Amplifier Current",
0517          pm860x_lo1_opamp_enum),
0518     SOC_ENUM("Lineout2 Operational Amplifier Current",
0519          pm860x_lo2_opamp_enum),
0520     SOC_ENUM("Lineout1 Amplifier Current", pm860x_lo1_pa_enum),
0521     SOC_ENUM("Lineout2 Amplifier Current", pm860x_lo2_pa_enum),
0522     SOC_ENUM("Speaker Operational Amplifier Current",
0523          pm860x_spk_ear_opamp_enum),
0524     SOC_ENUM("Speaker Amplifier Current", pm860x_spk_pa_enum),
0525     SOC_ENUM("Earpiece Amplifier Current", pm860x_ear_pa_enum),
0526 };
0527 
0528 /*
0529  * DAPM Controls
0530  */
0531 
0532 /* AUX1 Switch */
0533 static const struct snd_kcontrol_new aux1_switch_controls =
0534     SOC_DAPM_SINGLE("Switch", PM860X_ANA_TO_ANA, 4, 1, 0);
0535 
0536 /* AUX2 Switch */
0537 static const struct snd_kcontrol_new aux2_switch_controls =
0538     SOC_DAPM_SINGLE("Switch", PM860X_ANA_TO_ANA, 5, 1, 0);
0539 
0540 /* Left Ex. PA Switch */
0541 static const struct snd_kcontrol_new lepa_switch_controls =
0542     SOC_DAPM_SINGLE("Switch", PM860X_DAC_EN_2, 2, 1, 0);
0543 
0544 /* Right Ex. PA Switch */
0545 static const struct snd_kcontrol_new repa_switch_controls =
0546     SOC_DAPM_SINGLE("Switch", PM860X_DAC_EN_2, 1, 1, 0);
0547 
0548 /* I2S Mux / Mux9 */
0549 static const char *i2s_din_text[] = {
0550     "DIN", "DIN1",
0551 };
0552 
0553 static SOC_ENUM_SINGLE_DECL(i2s_din_enum,
0554                 PM860X_I2S_IFACE_3, 1, i2s_din_text);
0555 
0556 static const struct snd_kcontrol_new i2s_din_mux =
0557     SOC_DAPM_ENUM("I2S DIN Mux", i2s_din_enum);
0558 
0559 /* I2S Mic Mux / Mux8 */
0560 static const char *i2s_mic_text[] = {
0561     "Ex PA", "ADC",
0562 };
0563 
0564 static SOC_ENUM_SINGLE_DECL(i2s_mic_enum,
0565                 PM860X_I2S_IFACE_3, 4, i2s_mic_text);
0566 
0567 static const struct snd_kcontrol_new i2s_mic_mux =
0568     SOC_DAPM_ENUM("I2S Mic Mux", i2s_mic_enum);
0569 
0570 /* ADCL Mux / Mux2 */
0571 static const char *adcl_text[] = {
0572     "ADCR", "ADCL",
0573 };
0574 
0575 static SOC_ENUM_SINGLE_DECL(adcl_enum,
0576                 PM860X_PCM_IFACE_3, 4, adcl_text);
0577 
0578 static const struct snd_kcontrol_new adcl_mux =
0579     SOC_DAPM_ENUM("ADC Left Mux", adcl_enum);
0580 
0581 /* ADCR Mux / Mux3 */
0582 static const char *adcr_text[] = {
0583     "ADCL", "ADCR",
0584 };
0585 
0586 static SOC_ENUM_SINGLE_DECL(adcr_enum,
0587                 PM860X_PCM_IFACE_3, 2, adcr_text);
0588 
0589 static const struct snd_kcontrol_new adcr_mux =
0590     SOC_DAPM_ENUM("ADC Right Mux", adcr_enum);
0591 
0592 /* ADCR EC Mux / Mux6 */
0593 static const char *adcr_ec_text[] = {
0594     "ADCR", "EC",
0595 };
0596 
0597 static SOC_ENUM_SINGLE_DECL(adcr_ec_enum,
0598                 PM860X_ADC_EN_2, 3, adcr_ec_text);
0599 
0600 static const struct snd_kcontrol_new adcr_ec_mux =
0601     SOC_DAPM_ENUM("ADCR EC Mux", adcr_ec_enum);
0602 
0603 /* EC Mux / Mux4 */
0604 static const char *ec_text[] = {
0605     "Left", "Right", "Left + Right",
0606 };
0607 
0608 static SOC_ENUM_SINGLE_DECL(ec_enum,
0609                 PM860X_EC_PATH, 1, ec_text);
0610 
0611 static const struct snd_kcontrol_new ec_mux =
0612     SOC_DAPM_ENUM("EC Mux", ec_enum);
0613 
0614 static const char *dac_text[] = {
0615     "No input", "Right", "Left", "No input",
0616 };
0617 
0618 /* DAC Headset 1 Mux / Mux10 */
0619 static SOC_ENUM_SINGLE_DECL(dac_hs1_enum,
0620                 PM860X_ANA_INPUT_SEL_1, 0, dac_text);
0621 
0622 static const struct snd_kcontrol_new dac_hs1_mux =
0623     SOC_DAPM_ENUM("DAC HS1 Mux", dac_hs1_enum);
0624 
0625 /* DAC Headset 2 Mux / Mux11 */
0626 static SOC_ENUM_SINGLE_DECL(dac_hs2_enum,
0627                 PM860X_ANA_INPUT_SEL_1, 2, dac_text);
0628 
0629 static const struct snd_kcontrol_new dac_hs2_mux =
0630     SOC_DAPM_ENUM("DAC HS2 Mux", dac_hs2_enum);
0631 
0632 /* DAC Lineout 1 Mux / Mux12 */
0633 static SOC_ENUM_SINGLE_DECL(dac_lo1_enum,
0634                 PM860X_ANA_INPUT_SEL_1, 4, dac_text);
0635 
0636 static const struct snd_kcontrol_new dac_lo1_mux =
0637     SOC_DAPM_ENUM("DAC LO1 Mux", dac_lo1_enum);
0638 
0639 /* DAC Lineout 2 Mux / Mux13 */
0640 static SOC_ENUM_SINGLE_DECL(dac_lo2_enum,
0641                 PM860X_ANA_INPUT_SEL_1, 6, dac_text);
0642 
0643 static const struct snd_kcontrol_new dac_lo2_mux =
0644     SOC_DAPM_ENUM("DAC LO2 Mux", dac_lo2_enum);
0645 
0646 /* DAC Spearker Earphone Mux / Mux14 */
0647 static SOC_ENUM_SINGLE_DECL(dac_spk_ear_enum,
0648                 PM860X_ANA_INPUT_SEL_2, 0, dac_text);
0649 
0650 static const struct snd_kcontrol_new dac_spk_ear_mux =
0651     SOC_DAPM_ENUM("DAC SP Mux", dac_spk_ear_enum);
0652 
0653 /* Headset 1 Mux / Mux15 */
0654 static const char *in_text[] = {
0655     "Digital", "Analog",
0656 };
0657 
0658 static SOC_ENUM_SINGLE_DECL(hs1_enum,
0659                 PM860X_ANA_TO_ANA, 0, in_text);
0660 
0661 static const struct snd_kcontrol_new hs1_mux =
0662     SOC_DAPM_ENUM("Headset1 Mux", hs1_enum);
0663 
0664 /* Headset 2 Mux / Mux16 */
0665 static SOC_ENUM_SINGLE_DECL(hs2_enum,
0666                 PM860X_ANA_TO_ANA, 1, in_text);
0667 
0668 static const struct snd_kcontrol_new hs2_mux =
0669     SOC_DAPM_ENUM("Headset2 Mux", hs2_enum);
0670 
0671 /* Lineout 1 Mux / Mux17 */
0672 static SOC_ENUM_SINGLE_DECL(lo1_enum,
0673                 PM860X_ANA_TO_ANA, 2, in_text);
0674 
0675 static const struct snd_kcontrol_new lo1_mux =
0676     SOC_DAPM_ENUM("Lineout1 Mux", lo1_enum);
0677 
0678 /* Lineout 2 Mux / Mux18 */
0679 static SOC_ENUM_SINGLE_DECL(lo2_enum,
0680                 PM860X_ANA_TO_ANA, 3, in_text);
0681 
0682 static const struct snd_kcontrol_new lo2_mux =
0683     SOC_DAPM_ENUM("Lineout2 Mux", lo2_enum);
0684 
0685 /* Speaker Earpiece Demux */
0686 static const char *spk_text[] = {
0687     "Earpiece", "Speaker",
0688 };
0689 
0690 static SOC_ENUM_SINGLE_DECL(spk_enum,
0691                 PM860X_ANA_TO_ANA, 6, spk_text);
0692 
0693 static const struct snd_kcontrol_new spk_demux =
0694     SOC_DAPM_ENUM("Speaker Earpiece Demux", spk_enum);
0695 
0696 /* MIC Mux / Mux1 */
0697 static const char *mic_text[] = {
0698     "Mic 1", "Mic 2",
0699 };
0700 
0701 static SOC_ENUM_SINGLE_DECL(mic_enum,
0702                 PM860X_ADC_ANA_4, 4, mic_text);
0703 
0704 static const struct snd_kcontrol_new mic_mux =
0705     SOC_DAPM_ENUM("MIC Mux", mic_enum);
0706 
0707 static const struct snd_soc_dapm_widget pm860x_dapm_widgets[] = {
0708     SND_SOC_DAPM_AIF_IN("PCM SDI", "PCM Playback", 0,
0709                 PM860X_ADC_EN_2, 0, 0),
0710     SND_SOC_DAPM_AIF_OUT("PCM SDO", "PCM Capture", 0,
0711                  PM860X_PCM_IFACE_3, 1, 1),
0712 
0713 
0714     SND_SOC_DAPM_AIF_IN("I2S DIN", "I2S Playback", 0,
0715                 SND_SOC_NOPM, 0, 0),
0716     SND_SOC_DAPM_AIF_IN("I2S DIN1", "I2S Playback", 0,
0717                 SND_SOC_NOPM, 0, 0),
0718     SND_SOC_DAPM_AIF_OUT("I2S DOUT", "I2S Capture", 0,
0719                  PM860X_I2S_IFACE_3, 5, 1),
0720     SND_SOC_DAPM_SUPPLY("I2S CLK", PM860X_DAC_EN_2, 0, 0, NULL, 0),
0721     SND_SOC_DAPM_MUX("I2S Mic Mux", SND_SOC_NOPM, 0, 0, &i2s_mic_mux),
0722     SND_SOC_DAPM_MUX("ADC Left Mux", SND_SOC_NOPM, 0, 0, &adcl_mux),
0723     SND_SOC_DAPM_MUX("ADC Right Mux", SND_SOC_NOPM, 0, 0, &adcr_mux),
0724     SND_SOC_DAPM_MUX("EC Mux", SND_SOC_NOPM, 0, 0, &ec_mux),
0725     SND_SOC_DAPM_MUX("ADCR EC Mux", SND_SOC_NOPM, 0, 0, &adcr_ec_mux),
0726     SND_SOC_DAPM_SWITCH("Left EPA", SND_SOC_NOPM, 0, 0,
0727                 &lepa_switch_controls),
0728     SND_SOC_DAPM_SWITCH("Right EPA", SND_SOC_NOPM, 0, 0,
0729                 &repa_switch_controls),
0730 
0731     SND_SOC_DAPM_REG(snd_soc_dapm_supply, "Left ADC MOD", PM860X_ADC_EN_1,
0732              0, 1, 1, 0),
0733     SND_SOC_DAPM_REG(snd_soc_dapm_supply, "Right ADC MOD", PM860X_ADC_EN_1,
0734              1, 1, 1, 0),
0735     SND_SOC_DAPM_ADC("Left ADC", NULL, PM860X_ADC_EN_2, 5, 0),
0736     SND_SOC_DAPM_ADC("Right ADC", NULL, PM860X_ADC_EN_2, 4, 0),
0737 
0738     SND_SOC_DAPM_SWITCH("AUX1 Switch", SND_SOC_NOPM, 0, 0,
0739                 &aux1_switch_controls),
0740     SND_SOC_DAPM_SWITCH("AUX2 Switch", SND_SOC_NOPM, 0, 0,
0741                 &aux2_switch_controls),
0742 
0743     SND_SOC_DAPM_MUX("MIC Mux", SND_SOC_NOPM, 0, 0, &mic_mux),
0744     SND_SOC_DAPM_MICBIAS("Mic1 Bias", PM860X_ADC_ANA_1, 2, 0),
0745     SND_SOC_DAPM_MICBIAS("Mic3 Bias", PM860X_ADC_ANA_1, 7, 0),
0746     SND_SOC_DAPM_PGA("MIC1 Volume", PM860X_ADC_EN_1, 2, 0, NULL, 0),
0747     SND_SOC_DAPM_PGA("MIC3 Volume", PM860X_ADC_EN_1, 3, 0, NULL, 0),
0748     SND_SOC_DAPM_PGA("AUX1 Volume", PM860X_ADC_EN_1, 4, 0, NULL, 0),
0749     SND_SOC_DAPM_PGA("AUX2 Volume", PM860X_ADC_EN_1, 5, 0, NULL, 0),
0750     SND_SOC_DAPM_PGA("Sidetone PGA", PM860X_ADC_EN_2, 1, 0, NULL, 0),
0751     SND_SOC_DAPM_PGA("Lofi PGA", PM860X_ADC_EN_2, 2, 0, NULL, 0),
0752 
0753     SND_SOC_DAPM_INPUT("AUX1"),
0754     SND_SOC_DAPM_INPUT("AUX2"),
0755     SND_SOC_DAPM_INPUT("MIC1P"),
0756     SND_SOC_DAPM_INPUT("MIC1N"),
0757     SND_SOC_DAPM_INPUT("MIC2P"),
0758     SND_SOC_DAPM_INPUT("MIC2N"),
0759     SND_SOC_DAPM_INPUT("MIC3P"),
0760     SND_SOC_DAPM_INPUT("MIC3N"),
0761 
0762     SND_SOC_DAPM_DAC_E("Left DAC", NULL, SND_SOC_NOPM, 0, 0,
0763                pm860x_dac_event,
0764                SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
0765     SND_SOC_DAPM_DAC_E("Right DAC", NULL, SND_SOC_NOPM, 0, 0,
0766                pm860x_dac_event,
0767                SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
0768 
0769     SND_SOC_DAPM_MUX("I2S DIN Mux", SND_SOC_NOPM, 0, 0, &i2s_din_mux),
0770     SND_SOC_DAPM_MUX("DAC HS1 Mux", SND_SOC_NOPM, 0, 0, &dac_hs1_mux),
0771     SND_SOC_DAPM_MUX("DAC HS2 Mux", SND_SOC_NOPM, 0, 0, &dac_hs2_mux),
0772     SND_SOC_DAPM_MUX("DAC LO1 Mux", SND_SOC_NOPM, 0, 0, &dac_lo1_mux),
0773     SND_SOC_DAPM_MUX("DAC LO2 Mux", SND_SOC_NOPM, 0, 0, &dac_lo2_mux),
0774     SND_SOC_DAPM_MUX("DAC SP Mux", SND_SOC_NOPM, 0, 0, &dac_spk_ear_mux),
0775     SND_SOC_DAPM_MUX("Headset1 Mux", SND_SOC_NOPM, 0, 0, &hs1_mux),
0776     SND_SOC_DAPM_MUX("Headset2 Mux", SND_SOC_NOPM, 0, 0, &hs2_mux),
0777     SND_SOC_DAPM_MUX("Lineout1 Mux", SND_SOC_NOPM, 0, 0, &lo1_mux),
0778     SND_SOC_DAPM_MUX("Lineout2 Mux", SND_SOC_NOPM, 0, 0, &lo2_mux),
0779     SND_SOC_DAPM_MUX("Speaker Earpiece Demux", SND_SOC_NOPM, 0, 0,
0780              &spk_demux),
0781 
0782 
0783     SND_SOC_DAPM_PGA("Headset1 PGA", PM860X_DAC_EN_1, 0, 0, NULL, 0),
0784     SND_SOC_DAPM_PGA("Headset2 PGA", PM860X_DAC_EN_1, 1, 0, NULL, 0),
0785     SND_SOC_DAPM_OUTPUT("HS1"),
0786     SND_SOC_DAPM_OUTPUT("HS2"),
0787     SND_SOC_DAPM_PGA("Lineout1 PGA", PM860X_DAC_EN_1, 2, 0, NULL, 0),
0788     SND_SOC_DAPM_PGA("Lineout2 PGA", PM860X_DAC_EN_1, 3, 0, NULL, 0),
0789     SND_SOC_DAPM_OUTPUT("LINEOUT1"),
0790     SND_SOC_DAPM_OUTPUT("LINEOUT2"),
0791     SND_SOC_DAPM_PGA("Earpiece PGA", PM860X_DAC_EN_1, 4, 0, NULL, 0),
0792     SND_SOC_DAPM_OUTPUT("EARP"),
0793     SND_SOC_DAPM_OUTPUT("EARN"),
0794     SND_SOC_DAPM_PGA("Speaker PGA", PM860X_DAC_EN_1, 5, 0, NULL, 0),
0795     SND_SOC_DAPM_OUTPUT("LSP"),
0796     SND_SOC_DAPM_OUTPUT("LSN"),
0797     SND_SOC_DAPM_REG(snd_soc_dapm_supply, "VCODEC", PM860X_AUDIO_SUPPLIES_2,
0798              0, SUPPLY_MASK, SUPPLY_MASK, 0),
0799 
0800     PM860X_DAPM_OUTPUT("RSYNC", pm860x_rsync_event),
0801 };
0802 
0803 static const struct snd_soc_dapm_route pm860x_dapm_routes[] = {
0804     /* supply */
0805     {"Left DAC", NULL, "VCODEC"},
0806     {"Right DAC", NULL, "VCODEC"},
0807     {"Left ADC", NULL, "VCODEC"},
0808     {"Right ADC", NULL, "VCODEC"},
0809     {"Left ADC", NULL, "Left ADC MOD"},
0810     {"Right ADC", NULL, "Right ADC MOD"},
0811 
0812     /* I2S Clock */
0813     {"I2S DIN", NULL, "I2S CLK"},
0814     {"I2S DIN1", NULL, "I2S CLK"},
0815     {"I2S DOUT", NULL, "I2S CLK"},
0816 
0817     /* PCM/AIF1 Inputs */
0818     {"PCM SDO", NULL, "ADC Left Mux"},
0819     {"PCM SDO", NULL, "ADCR EC Mux"},
0820 
0821     /* PCM/AFI2 Outputs */
0822     {"Lofi PGA", NULL, "PCM SDI"},
0823     {"Lofi PGA", NULL, "Sidetone PGA"},
0824     {"Left DAC", NULL, "Lofi PGA"},
0825     {"Right DAC", NULL, "Lofi PGA"},
0826 
0827     /* I2S/AIF2 Inputs */
0828     {"MIC Mux", "Mic 1", "MIC1P"},
0829     {"MIC Mux", "Mic 1", "MIC1N"},
0830     {"MIC Mux", "Mic 2", "MIC2P"},
0831     {"MIC Mux", "Mic 2", "MIC2N"},
0832     {"MIC1 Volume", NULL, "MIC Mux"},
0833     {"MIC3 Volume", NULL, "MIC3P"},
0834     {"MIC3 Volume", NULL, "MIC3N"},
0835     {"Left ADC", NULL, "MIC1 Volume"},
0836     {"Right ADC", NULL, "MIC3 Volume"},
0837     {"ADC Left Mux", "ADCR", "Right ADC"},
0838     {"ADC Left Mux", "ADCL", "Left ADC"},
0839     {"ADC Right Mux", "ADCL", "Left ADC"},
0840     {"ADC Right Mux", "ADCR", "Right ADC"},
0841     {"Left EPA", "Switch", "Left DAC"},
0842     {"Right EPA", "Switch", "Right DAC"},
0843     {"EC Mux", "Left", "Left DAC"},
0844     {"EC Mux", "Right", "Right DAC"},
0845     {"EC Mux", "Left + Right", "Left DAC"},
0846     {"EC Mux", "Left + Right", "Right DAC"},
0847     {"ADCR EC Mux", "ADCR", "ADC Right Mux"},
0848     {"ADCR EC Mux", "EC", "EC Mux"},
0849     {"I2S Mic Mux", "Ex PA", "Left EPA"},
0850     {"I2S Mic Mux", "Ex PA", "Right EPA"},
0851     {"I2S Mic Mux", "ADC", "ADC Left Mux"},
0852     {"I2S Mic Mux", "ADC", "ADCR EC Mux"},
0853     {"I2S DOUT", NULL, "I2S Mic Mux"},
0854 
0855     /* I2S/AIF2 Outputs */
0856     {"I2S DIN Mux", "DIN", "I2S DIN"},
0857     {"I2S DIN Mux", "DIN1", "I2S DIN1"},
0858     {"Left DAC", NULL, "I2S DIN Mux"},
0859     {"Right DAC", NULL, "I2S DIN Mux"},
0860     {"DAC HS1 Mux", "Left", "Left DAC"},
0861     {"DAC HS1 Mux", "Right", "Right DAC"},
0862     {"DAC HS2 Mux", "Left", "Left DAC"},
0863     {"DAC HS2 Mux", "Right", "Right DAC"},
0864     {"DAC LO1 Mux", "Left", "Left DAC"},
0865     {"DAC LO1 Mux", "Right", "Right DAC"},
0866     {"DAC LO2 Mux", "Left", "Left DAC"},
0867     {"DAC LO2 Mux", "Right", "Right DAC"},
0868     {"Headset1 Mux", "Digital", "DAC HS1 Mux"},
0869     {"Headset2 Mux", "Digital", "DAC HS2 Mux"},
0870     {"Lineout1 Mux", "Digital", "DAC LO1 Mux"},
0871     {"Lineout2 Mux", "Digital", "DAC LO2 Mux"},
0872     {"Headset1 PGA", NULL, "Headset1 Mux"},
0873     {"Headset2 PGA", NULL, "Headset2 Mux"},
0874     {"Lineout1 PGA", NULL, "Lineout1 Mux"},
0875     {"Lineout2 PGA", NULL, "Lineout2 Mux"},
0876     {"DAC SP Mux", "Left", "Left DAC"},
0877     {"DAC SP Mux", "Right", "Right DAC"},
0878     {"Speaker Earpiece Demux", "Speaker", "DAC SP Mux"},
0879     {"Speaker PGA", NULL, "Speaker Earpiece Demux"},
0880     {"Earpiece PGA", NULL, "Speaker Earpiece Demux"},
0881 
0882     {"RSYNC", NULL, "Headset1 PGA"},
0883     {"RSYNC", NULL, "Headset2 PGA"},
0884     {"RSYNC", NULL, "Lineout1 PGA"},
0885     {"RSYNC", NULL, "Lineout2 PGA"},
0886     {"RSYNC", NULL, "Speaker PGA"},
0887     {"RSYNC", NULL, "Speaker PGA"},
0888     {"RSYNC", NULL, "Earpiece PGA"},
0889     {"RSYNC", NULL, "Earpiece PGA"},
0890 
0891     {"HS1", NULL, "RSYNC"},
0892     {"HS2", NULL, "RSYNC"},
0893     {"LINEOUT1", NULL, "RSYNC"},
0894     {"LINEOUT2", NULL, "RSYNC"},
0895     {"LSP", NULL, "RSYNC"},
0896     {"LSN", NULL, "RSYNC"},
0897     {"EARP", NULL, "RSYNC"},
0898     {"EARN", NULL, "RSYNC"},
0899 };
0900 
0901 /*
0902  * Use MUTE_LEFT & MUTE_RIGHT to implement digital mute.
0903  * These bits can also be used to mute.
0904  */
0905 static int pm860x_mute_stream(struct snd_soc_dai *codec_dai, int mute, int direction)
0906 {
0907     struct snd_soc_component *component = codec_dai->component;
0908     int data = 0, mask = MUTE_LEFT | MUTE_RIGHT;
0909 
0910     if (mute)
0911         data = mask;
0912     snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, mask, data);
0913     snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2,
0914                 RSYNC_CHANGE, RSYNC_CHANGE);
0915     return 0;
0916 }
0917 
0918 static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream,
0919                 struct snd_pcm_hw_params *params,
0920                 struct snd_soc_dai *dai)
0921 {
0922     struct snd_soc_component *component = dai->component;
0923     unsigned char inf = 0, mask = 0;
0924 
0925     /* bit size */
0926     switch (params_width(params)) {
0927     case 16:
0928         inf &= ~PCM_INF2_18WL;
0929         break;
0930     case 18:
0931         inf |= PCM_INF2_18WL;
0932         break;
0933     default:
0934         return -EINVAL;
0935     }
0936     mask |= PCM_INF2_18WL;
0937     snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf);
0938 
0939     /* sample rate */
0940     switch (params_rate(params)) {
0941     case 8000:
0942         inf = 0;
0943         break;
0944     case 16000:
0945         inf = 3;
0946         break;
0947     case 32000:
0948         inf = 6;
0949         break;
0950     case 48000:
0951         inf = 8;
0952         break;
0953     default:
0954         return -EINVAL;
0955     }
0956     snd_soc_component_update_bits(component, PM860X_PCM_RATE, 0x0f, inf);
0957 
0958     return 0;
0959 }
0960 
0961 static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai,
0962                   unsigned int fmt)
0963 {
0964     struct snd_soc_component *component = codec_dai->component;
0965     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
0966     unsigned char inf = 0, mask = 0;
0967     int ret = -EINVAL;
0968 
0969     mask |= PCM_INF2_BCLK | PCM_INF2_FS | PCM_INF2_MASTER;
0970 
0971     /* set audio interface clocking */
0972     switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
0973     case SND_SOC_DAIFMT_CBP_CFP:
0974     case SND_SOC_DAIFMT_CBP_CFC:
0975         if (pm860x->dir == PM860X_CLK_DIR_OUT) {
0976             inf |= PCM_INF2_MASTER;
0977             ret = 0;
0978         }
0979         break;
0980     case SND_SOC_DAIFMT_CBC_CFC:
0981         if (pm860x->dir == PM860X_CLK_DIR_IN) {
0982             inf &= ~PCM_INF2_MASTER;
0983             ret = 0;
0984         }
0985         break;
0986     }
0987 
0988     switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
0989     case SND_SOC_DAIFMT_I2S:
0990         inf |= PCM_EXACT_I2S;
0991         ret = 0;
0992         break;
0993     }
0994     mask |= PCM_MODE_MASK;
0995     if (ret)
0996         return ret;
0997     snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf);
0998     return 0;
0999 }
1000 
1001 static int pm860x_set_dai_sysclk(struct snd_soc_dai *codec_dai,
1002                  int clk_id, unsigned int freq, int dir)
1003 {
1004     struct snd_soc_component *component = codec_dai->component;
1005     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1006 
1007     if (dir == PM860X_CLK_DIR_OUT)
1008         pm860x->dir = PM860X_CLK_DIR_OUT;
1009     else    /* Slave mode is not supported */
1010         return -EINVAL;
1011 
1012     return 0;
1013 }
1014 
1015 static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream,
1016                 struct snd_pcm_hw_params *params,
1017                 struct snd_soc_dai *dai)
1018 {
1019     struct snd_soc_component *component = dai->component;
1020     unsigned char inf;
1021 
1022     /* bit size */
1023     switch (params_width(params)) {
1024     case 16:
1025         inf = 0;
1026         break;
1027     case 18:
1028         inf = PCM_INF2_18WL;
1029         break;
1030     default:
1031         return -EINVAL;
1032     }
1033     snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, PCM_INF2_18WL, inf);
1034 
1035     /* sample rate */
1036     switch (params_rate(params)) {
1037     case 8000:
1038         inf = 0;
1039         break;
1040     case 11025:
1041         inf = 1;
1042         break;
1043     case 16000:
1044         inf = 3;
1045         break;
1046     case 22050:
1047         inf = 4;
1048         break;
1049     case 32000:
1050         inf = 6;
1051         break;
1052     case 44100:
1053         inf = 7;
1054         break;
1055     case 48000:
1056         inf = 8;
1057         break;
1058     default:
1059         return -EINVAL;
1060     }
1061     snd_soc_component_update_bits(component, PM860X_I2S_IFACE_4, 0xf, inf);
1062 
1063     return 0;
1064 }
1065 
1066 static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai,
1067                   unsigned int fmt)
1068 {
1069     struct snd_soc_component *component = codec_dai->component;
1070     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1071     unsigned char inf = 0, mask = 0;
1072 
1073     mask |= PCM_INF2_BCLK | PCM_INF2_FS | PCM_INF2_MASTER;
1074 
1075     /* set audio interface clocking */
1076     switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
1077     case SND_SOC_DAIFMT_CBP_CFP:
1078         if (pm860x->dir == PM860X_CLK_DIR_OUT)
1079             inf |= PCM_INF2_MASTER;
1080         else
1081             return -EINVAL;
1082         break;
1083     case SND_SOC_DAIFMT_CBC_CFC:
1084         if (pm860x->dir == PM860X_CLK_DIR_IN)
1085             inf &= ~PCM_INF2_MASTER;
1086         else
1087             return -EINVAL;
1088         break;
1089     default:
1090         return -EINVAL;
1091     }
1092 
1093     switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1094     case SND_SOC_DAIFMT_I2S:
1095         inf |= PCM_EXACT_I2S;
1096         break;
1097     default:
1098         return -EINVAL;
1099     }
1100     mask |= PCM_MODE_MASK;
1101     snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, mask, inf);
1102     return 0;
1103 }
1104 
1105 static int pm860x_set_bias_level(struct snd_soc_component *component,
1106                  enum snd_soc_bias_level level)
1107 {
1108     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1109     int data;
1110 
1111     switch (level) {
1112     case SND_SOC_BIAS_ON:
1113         break;
1114 
1115     case SND_SOC_BIAS_PREPARE:
1116         break;
1117 
1118     case SND_SOC_BIAS_STANDBY:
1119         if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
1120             /* Enable Audio PLL & Audio section */
1121             data = AUDIO_PLL | AUDIO_SECTION_ON;
1122             pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
1123             udelay(300);
1124             data = AUDIO_PLL | AUDIO_SECTION_RESET
1125                 | AUDIO_SECTION_ON;
1126             pm860x_reg_write(pm860x->i2c, REG_MISC2, data);
1127         }
1128         break;
1129 
1130     case SND_SOC_BIAS_OFF:
1131         data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON;
1132         pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0);
1133         break;
1134     }
1135     return 0;
1136 }
1137 
1138 static const struct snd_soc_dai_ops pm860x_pcm_dai_ops = {
1139     .mute_stream    = pm860x_mute_stream,
1140     .hw_params  = pm860x_pcm_hw_params,
1141     .set_fmt    = pm860x_pcm_set_dai_fmt,
1142     .set_sysclk = pm860x_set_dai_sysclk,
1143     .no_capture_mute = 1,
1144 };
1145 
1146 static const struct snd_soc_dai_ops pm860x_i2s_dai_ops = {
1147     .mute_stream    = pm860x_mute_stream,
1148     .hw_params  = pm860x_i2s_hw_params,
1149     .set_fmt    = pm860x_i2s_set_dai_fmt,
1150     .set_sysclk = pm860x_set_dai_sysclk,
1151     .no_capture_mute = 1,
1152 };
1153 
1154 #define PM860X_RATES    (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |   \
1155              SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000)
1156 
1157 static struct snd_soc_dai_driver pm860x_dai[] = {
1158     {
1159         /* DAI PCM */
1160         .name   = "88pm860x-pcm",
1161         .id = 1,
1162         .playback = {
1163             .stream_name    = "PCM Playback",
1164             .channels_min   = 2,
1165             .channels_max   = 2,
1166             .rates      = PM860X_RATES,
1167             .formats    = SNDRV_PCM_FMTBIT_S16_LE | \
1168                       SNDRV_PCM_FMTBIT_S18_3LE,
1169         },
1170         .capture = {
1171             .stream_name    = "PCM Capture",
1172             .channels_min   = 2,
1173             .channels_max   = 2,
1174             .rates      = PM860X_RATES,
1175             .formats    = SNDRV_PCM_FMTBIT_S16_LE | \
1176                       SNDRV_PCM_FMTBIT_S18_3LE,
1177         },
1178         .ops    = &pm860x_pcm_dai_ops,
1179     }, {
1180         /* DAI I2S */
1181         .name   = "88pm860x-i2s",
1182         .id = 2,
1183         .playback = {
1184             .stream_name    = "I2S Playback",
1185             .channels_min   = 2,
1186             .channels_max   = 2,
1187             .rates      = SNDRV_PCM_RATE_8000_48000,
1188             .formats    = SNDRV_PCM_FMTBIT_S16_LE | \
1189                       SNDRV_PCM_FMTBIT_S18_3LE,
1190         },
1191         .capture = {
1192             .stream_name    = "I2S Capture",
1193             .channels_min   = 2,
1194             .channels_max   = 2,
1195             .rates      = SNDRV_PCM_RATE_8000_48000,
1196             .formats    = SNDRV_PCM_FMTBIT_S16_LE | \
1197                       SNDRV_PCM_FMTBIT_S18_3LE,
1198         },
1199         .ops    = &pm860x_i2s_dai_ops,
1200     },
1201 };
1202 
1203 static irqreturn_t pm860x_component_handler(int irq, void *data)
1204 {
1205     struct pm860x_priv *pm860x = data;
1206     int status, shrt, report = 0, mic_report = 0;
1207     int mask;
1208 
1209     status = pm860x_reg_read(pm860x->i2c, REG_STATUS_1);
1210     shrt = pm860x_reg_read(pm860x->i2c, REG_SHORTS);
1211     mask = pm860x->det.hs_shrt | pm860x->det.hook_det | pm860x->det.lo_shrt
1212         | pm860x->det.hp_det;
1213 
1214 #ifndef CONFIG_SND_SOC_88PM860X_MODULE
1215     if (status & (HEADSET_STATUS | MIC_STATUS | SHORT_HS1 | SHORT_HS2 |
1216               SHORT_LO1 | SHORT_LO2))
1217         trace_snd_soc_jack_irq(dev_name(pm860x->component->dev));
1218 #endif
1219 
1220     if ((pm860x->det.hp_det & SND_JACK_HEADPHONE)
1221         && (status & HEADSET_STATUS))
1222         report |= SND_JACK_HEADPHONE;
1223 
1224     if ((pm860x->det.mic_det & SND_JACK_MICROPHONE)
1225         && (status & MIC_STATUS))
1226         mic_report |= SND_JACK_MICROPHONE;
1227 
1228     if (pm860x->det.hs_shrt && (shrt & (SHORT_HS1 | SHORT_HS2)))
1229         report |= pm860x->det.hs_shrt;
1230 
1231     if (pm860x->det.hook_det && (status & HOOK_STATUS))
1232         report |= pm860x->det.hook_det;
1233 
1234     if (pm860x->det.lo_shrt && (shrt & (SHORT_LO1 | SHORT_LO2)))
1235         report |= pm860x->det.lo_shrt;
1236 
1237     if (report)
1238         snd_soc_jack_report(pm860x->det.hp_jack, report, mask);
1239     if (mic_report)
1240         snd_soc_jack_report(pm860x->det.mic_jack, SND_JACK_MICROPHONE,
1241                     SND_JACK_MICROPHONE);
1242 
1243     dev_dbg(pm860x->component->dev, "headphone report:0x%x, mask:%x\n",
1244         report, mask);
1245     dev_dbg(pm860x->component->dev, "microphone report:0x%x\n", mic_report);
1246     return IRQ_HANDLED;
1247 }
1248 
1249 int pm860x_hs_jack_detect(struct snd_soc_component *component,
1250               struct snd_soc_jack *jack,
1251               int det, int hook, int hs_shrt, int lo_shrt)
1252 {
1253     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1254     int data;
1255 
1256     pm860x->det.hp_jack = jack;
1257     pm860x->det.hp_det = det;
1258     pm860x->det.hook_det = hook;
1259     pm860x->det.hs_shrt = hs_shrt;
1260     pm860x->det.lo_shrt = lo_shrt;
1261 
1262     if (det & SND_JACK_HEADPHONE)
1263         pm860x_set_bits(pm860x->i2c, REG_HS_DET,
1264                 EN_HS_DET, EN_HS_DET);
1265     /* headset short detect */
1266     if (hs_shrt) {
1267         data = CLR_SHORT_HS2 | CLR_SHORT_HS1;
1268         pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
1269     }
1270     /* Lineout short detect */
1271     if (lo_shrt) {
1272         data = CLR_SHORT_LO2 | CLR_SHORT_LO1;
1273         pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data);
1274     }
1275 
1276     /* sync status */
1277     pm860x_component_handler(0, pm860x);
1278     return 0;
1279 }
1280 EXPORT_SYMBOL_GPL(pm860x_hs_jack_detect);
1281 
1282 int pm860x_mic_jack_detect(struct snd_soc_component *component,
1283                struct snd_soc_jack *jack, int det)
1284 {
1285     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1286 
1287     pm860x->det.mic_jack = jack;
1288     pm860x->det.mic_det = det;
1289 
1290     if (det & SND_JACK_MICROPHONE)
1291         pm860x_set_bits(pm860x->i2c, REG_MIC_DET,
1292                 MICDET_MASK, MICDET_MASK);
1293 
1294     /* sync status */
1295     pm860x_component_handler(0, pm860x);
1296     return 0;
1297 }
1298 EXPORT_SYMBOL_GPL(pm860x_mic_jack_detect);
1299 
1300 static int pm860x_probe(struct snd_soc_component *component)
1301 {
1302     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1303     int i, ret;
1304 
1305     pm860x->component = component;
1306     snd_soc_component_init_regmap(component,  pm860x->regmap);
1307 
1308     for (i = 0; i < 4; i++) {
1309         ret = request_threaded_irq(pm860x->irq[i], NULL,
1310                        pm860x_component_handler, IRQF_ONESHOT,
1311                        pm860x->name[i], pm860x);
1312         if (ret < 0) {
1313             dev_err(component->dev, "Failed to request IRQ!\n");
1314             goto out;
1315         }
1316     }
1317 
1318     return 0;
1319 
1320 out:
1321     while (--i >= 0)
1322         free_irq(pm860x->irq[i], pm860x);
1323     return ret;
1324 }
1325 
1326 static void pm860x_remove(struct snd_soc_component *component)
1327 {
1328     struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component);
1329     int i;
1330 
1331     for (i = 3; i >= 0; i--)
1332         free_irq(pm860x->irq[i], pm860x);
1333 }
1334 
1335 static const struct snd_soc_component_driver soc_component_dev_pm860x = {
1336     .probe          = pm860x_probe,
1337     .remove         = pm860x_remove,
1338     .set_bias_level     = pm860x_set_bias_level,
1339     .controls       = pm860x_snd_controls,
1340     .num_controls       = ARRAY_SIZE(pm860x_snd_controls),
1341     .dapm_widgets       = pm860x_dapm_widgets,
1342     .num_dapm_widgets   = ARRAY_SIZE(pm860x_dapm_widgets),
1343     .dapm_routes        = pm860x_dapm_routes,
1344     .num_dapm_routes    = ARRAY_SIZE(pm860x_dapm_routes),
1345     .idle_bias_on       = 1,
1346     .use_pmdown_time    = 1,
1347     .endianness     = 1,
1348 };
1349 
1350 static int pm860x_codec_probe(struct platform_device *pdev)
1351 {
1352     struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
1353     struct pm860x_priv *pm860x;
1354     struct resource *res;
1355     int i, ret;
1356 
1357     pm860x = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_priv),
1358                   GFP_KERNEL);
1359     if (pm860x == NULL)
1360         return -ENOMEM;
1361 
1362     pm860x->chip = chip;
1363     pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client
1364             : chip->companion;
1365     pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap
1366             : chip->regmap_companion;
1367     platform_set_drvdata(pdev, pm860x);
1368 
1369     for (i = 0; i < 4; i++) {
1370         res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
1371         if (!res) {
1372             dev_err(&pdev->dev, "Failed to get IRQ resources\n");
1373             return -EINVAL;
1374         }
1375         pm860x->irq[i] = res->start + chip->irq_base;
1376         strncpy(pm860x->name[i], res->name, MAX_NAME_LEN);
1377     }
1378 
1379     ret = devm_snd_soc_register_component(&pdev->dev,
1380                      &soc_component_dev_pm860x,
1381                      pm860x_dai, ARRAY_SIZE(pm860x_dai));
1382     if (ret) {
1383         dev_err(&pdev->dev, "Failed to register component\n");
1384         return -EINVAL;
1385     }
1386     return ret;
1387 }
1388 
1389 static int pm860x_codec_remove(struct platform_device *pdev)
1390 {
1391     return 0;
1392 }
1393 
1394 static struct platform_driver pm860x_codec_driver = {
1395     .driver = {
1396         .name   = "88pm860x-codec",
1397     },
1398     .probe  = pm860x_codec_probe,
1399     .remove = pm860x_codec_remove,
1400 };
1401 
1402 module_platform_driver(pm860x_codec_driver);
1403 
1404 MODULE_DESCRIPTION("ASoC 88PM860x driver");
1405 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
1406 MODULE_LICENSE("GPL");
1407 MODULE_ALIAS("platform:88pm860x-codec");
1408