aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBard Liao <bardliao@realtek.com>2014-11-11 04:59:50 -0500
committerMark Brown <broonie@kernel.org>2014-11-11 07:07:13 -0500
commit0cf1863219b474e82af9cb1f6715a0bbfa3fdf1a (patch)
tree1235900c2f1ffa9cd60908c196d3e3ac221c32f3
parentf114040e3ea6e07372334ade75d1ee0775c355e1 (diff)
ASoC: rt5670: add rt5672 codec support
rt5672 is very similar to rt5670. Therefore we use one codec driver to support both codecs. The difference between rt5670 and rt5672 is there is some difference in their dapm routing table. Signed-off-by: Bard Liao <bardliao@realtek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5670.c71
-rw-r--r--sound/soc/codecs/rt5670.h6
2 files changed, 65 insertions, 12 deletions
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index ba9d9b4d4857..066b58317c24 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -1595,29 +1595,40 @@ static const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = {
1595 /* PDM */ 1595 /* PDM */
1596 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5670_PWR_DIG2, 1596 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5670_PWR_DIG2,
1597 RT5670_PWR_PDM1_BIT, 0, NULL, 0), 1597 RT5670_PWR_PDM1_BIT, 0, NULL, 0),
1598 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5670_PWR_DIG2,
1599 RT5670_PWR_PDM2_BIT, 0, NULL, 0),
1600 1598
1601 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL, 1599 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL,
1602 RT5670_M_PDM1_L_SFT, 1, &rt5670_pdm1_l_mux), 1600 RT5670_M_PDM1_L_SFT, 1, &rt5670_pdm1_l_mux),
1603 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL, 1601 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL,
1604 RT5670_M_PDM1_R_SFT, 1, &rt5670_pdm1_r_mux), 1602 RT5670_M_PDM1_R_SFT, 1, &rt5670_pdm1_r_mux),
1605 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL,
1606 RT5670_M_PDM2_L_SFT, 1, &rt5670_pdm2_l_mux),
1607 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL,
1608 RT5670_M_PDM2_R_SFT, 1, &rt5670_pdm2_r_mux),
1609 1603
1610 /* Output Lines */ 1604 /* Output Lines */
1611 SND_SOC_DAPM_OUTPUT("HPOL"), 1605 SND_SOC_DAPM_OUTPUT("HPOL"),
1612 SND_SOC_DAPM_OUTPUT("HPOR"), 1606 SND_SOC_DAPM_OUTPUT("HPOR"),
1613 SND_SOC_DAPM_OUTPUT("LOUTL"), 1607 SND_SOC_DAPM_OUTPUT("LOUTL"),
1614 SND_SOC_DAPM_OUTPUT("LOUTR"), 1608 SND_SOC_DAPM_OUTPUT("LOUTR"),
1609};
1610
1611static const struct snd_soc_dapm_widget rt5670_specific_dapm_widgets[] = {
1612 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5670_PWR_DIG2,
1613 RT5670_PWR_PDM2_BIT, 0, NULL, 0),
1614 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL,
1615 RT5670_M_PDM2_L_SFT, 1, &rt5670_pdm2_l_mux),
1616 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL,
1617 RT5670_M_PDM2_R_SFT, 1, &rt5670_pdm2_r_mux),
1615 SND_SOC_DAPM_OUTPUT("PDM1L"), 1618 SND_SOC_DAPM_OUTPUT("PDM1L"),
1616 SND_SOC_DAPM_OUTPUT("PDM1R"), 1619 SND_SOC_DAPM_OUTPUT("PDM1R"),
1617 SND_SOC_DAPM_OUTPUT("PDM2L"), 1620 SND_SOC_DAPM_OUTPUT("PDM2L"),
1618 SND_SOC_DAPM_OUTPUT("PDM2R"), 1621 SND_SOC_DAPM_OUTPUT("PDM2R"),
1619}; 1622};
1620 1623
1624static const struct snd_soc_dapm_widget rt5672_specific_dapm_widgets[] = {
1625 SND_SOC_DAPM_PGA("SPO Amp", SND_SOC_NOPM, 0, 0, NULL, 0),
1626 SND_SOC_DAPM_OUTPUT("SPOLP"),
1627 SND_SOC_DAPM_OUTPUT("SPOLN"),
1628 SND_SOC_DAPM_OUTPUT("SPORP"),
1629 SND_SOC_DAPM_OUTPUT("SPORN"),
1630};
1631
1621static const struct snd_soc_dapm_route rt5670_dapm_routes[] = { 1632static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
1622 { "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc }, 1633 { "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc },
1623 { "ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc }, 1634 { "ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc },
@@ -1970,12 +1981,6 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
1970 { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" }, 1981 { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
1971 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" }, 1982 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
1972 { "PDM1 R Mux", NULL, "PDM1 Power" }, 1983 { "PDM1 R Mux", NULL, "PDM1 Power" },
1973 { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
1974 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
1975 { "PDM2 L Mux", NULL, "PDM2 Power" },
1976 { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
1977 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
1978 { "PDM2 R Mux", NULL, "PDM2 Power" },
1979 1984
1980 { "HP Amp", NULL, "HPO MIX" }, 1985 { "HP Amp", NULL, "HPO MIX" },
1981 { "HP Amp", NULL, "Mic Det Power" }, 1986 { "HP Amp", NULL, "Mic Det Power" },
@@ -1993,13 +1998,30 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
1993 { "LOUTR", NULL, "LOUT R Playback" }, 1998 { "LOUTR", NULL, "LOUT R Playback" },
1994 { "LOUTL", NULL, "Improve HP Amp Drv" }, 1999 { "LOUTL", NULL, "Improve HP Amp Drv" },
1995 { "LOUTR", NULL, "Improve HP Amp Drv" }, 2000 { "LOUTR", NULL, "Improve HP Amp Drv" },
2001};
1996 2002
2003static const struct snd_soc_dapm_route rt5670_specific_dapm_routes[] = {
2004 { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
2005 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
2006 { "PDM2 L Mux", NULL, "PDM2 Power" },
2007 { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
2008 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
2009 { "PDM2 R Mux", NULL, "PDM2 Power" },
1997 { "PDM1L", NULL, "PDM1 L Mux" }, 2010 { "PDM1L", NULL, "PDM1 L Mux" },
1998 { "PDM1R", NULL, "PDM1 R Mux" }, 2011 { "PDM1R", NULL, "PDM1 R Mux" },
1999 { "PDM2L", NULL, "PDM2 L Mux" }, 2012 { "PDM2L", NULL, "PDM2 L Mux" },
2000 { "PDM2R", NULL, "PDM2 R Mux" }, 2013 { "PDM2R", NULL, "PDM2 R Mux" },
2001}; 2014};
2002 2015
2016static const struct snd_soc_dapm_route rt5672_specific_dapm_routes[] = {
2017 { "SPO Amp", NULL, "PDM1 L Mux" },
2018 { "SPO Amp", NULL, "PDM1 R Mux" },
2019 { "SPOLP", NULL, "SPO Amp" },
2020 { "SPOLN", NULL, "SPO Amp" },
2021 { "SPORP", NULL, "SPO Amp" },
2022 { "SPORN", NULL, "SPO Amp" },
2023};
2024
2003static int rt5670_hw_params(struct snd_pcm_substream *substream, 2025static int rt5670_hw_params(struct snd_pcm_substream *substream,
2004 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 2026 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
2005{ 2027{
@@ -2331,6 +2353,29 @@ static int rt5670_probe(struct snd_soc_codec *codec)
2331{ 2353{
2332 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 2354 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
2333 2355
2356 switch (snd_soc_read(codec, RT5670_RESET) & RT5670_ID_MASK) {
2357 case RT5670_ID_5670:
2358 case RT5670_ID_5671:
2359 snd_soc_dapm_new_controls(&codec->dapm,
2360 rt5670_specific_dapm_widgets,
2361 ARRAY_SIZE(rt5670_specific_dapm_widgets));
2362 snd_soc_dapm_add_routes(&codec->dapm,
2363 rt5670_specific_dapm_routes,
2364 ARRAY_SIZE(rt5670_specific_dapm_routes));
2365 break;
2366 case RT5670_ID_5672:
2367 snd_soc_dapm_new_controls(&codec->dapm,
2368 rt5672_specific_dapm_widgets,
2369 ARRAY_SIZE(rt5672_specific_dapm_widgets));
2370 snd_soc_dapm_add_routes(&codec->dapm,
2371 rt5672_specific_dapm_routes,
2372 ARRAY_SIZE(rt5672_specific_dapm_routes));
2373 break;
2374 default:
2375 dev_err(codec->dev,
2376 "The driver is for RT5670 RT5671 or RT5672 only\n");
2377 return -ENODEV;
2378 }
2334 rt5670->codec = codec; 2379 rt5670->codec = codec;
2335 2380
2336 return 0; 2381 return 0;
@@ -2452,6 +2497,8 @@ static const struct regmap_config rt5670_regmap = {
2452 2497
2453static const struct i2c_device_id rt5670_i2c_id[] = { 2498static const struct i2c_device_id rt5670_i2c_id[] = {
2454 { "rt5670", 0 }, 2499 { "rt5670", 0 },
2500 { "rt5671", 0 },
2501 { "rt5672", 0 },
2455 { } 2502 { }
2456}; 2503};
2457MODULE_DEVICE_TABLE(i2c, rt5670_i2c_id); 2504MODULE_DEVICE_TABLE(i2c, rt5670_i2c_id);
diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h
index a0b5c855b492..d11b9c207e26 100644
--- a/sound/soc/codecs/rt5670.h
+++ b/sound/soc/codecs/rt5670.h
@@ -228,6 +228,12 @@
228#define RT5670_R_VOL_MASK (0x3f) 228#define RT5670_R_VOL_MASK (0x3f)
229#define RT5670_R_VOL_SFT 0 229#define RT5670_R_VOL_SFT 0
230 230
231/* SW Reset & Device ID (0x00) */
232#define RT5670_ID_MASK (0x3 << 1)
233#define RT5670_ID_5670 (0x0 << 1)
234#define RT5670_ID_5672 (0x1 << 1)
235#define RT5670_ID_5671 (0x2 << 1)
236
231/* Combo Jack Control 1 (0x0a) */ 237/* Combo Jack Control 1 (0x0a) */
232#define RT5670_CBJ_BST1_MASK (0xf << 12) 238#define RT5670_CBJ_BST1_MASK (0xf << 12)
233#define RT5670_CBJ_BST1_SFT (12) 239#define RT5670_CBJ_BST1_SFT (12)