ASoC: rt1308-sdw: update the preset settings
authorShuming Fan <shumingf@realtek.com>
Wed, 19 Oct 2022 09:57:31 +0000 (17:57 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 19 Oct 2022 12:39:33 +0000 (13:39 +0100)
This patch updates the pad control and checks the
hardware version to set the different preset settings.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
Link: https://lore.kernel.org/r/20221019095731.31101-1-shumingf@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt1308-sdw.c
sound/soc/codecs/rt1308-sdw.h
sound/soc/codecs/rt1308.h

index 5c29416..f99aed3 100644 (file)
@@ -50,6 +50,7 @@ static bool rt1308_volatile_register(struct device *dev, unsigned int reg)
        case 0x3008:
        case 0x300a:
        case 0xc000:
+       case 0xc710:
        case 0xc860 ... 0xc863:
        case 0xc870 ... 0xc873:
                return true;
@@ -200,6 +201,7 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
 {
        struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
        int ret = 0;
+       unsigned int tmp;
 
        if (rt1308->hw_init)
                return 0;
@@ -231,6 +233,10 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
        /* sw reset */
        regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0);
 
+       regmap_read(rt1308->regmap, 0xc710, &tmp);
+       rt1308->hw_ver = tmp;
+       dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver);
+
        /* initial settings */
        regmap_write(rt1308->regmap, 0xc103, 0xc0);
        regmap_write(rt1308->regmap, 0xc030, 0x17);
@@ -246,8 +252,14 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
        regmap_write(rt1308->regmap, 0xc062, 0x05);
        regmap_write(rt1308->regmap, 0xc171, 0x07);
        regmap_write(rt1308->regmap, 0xc173, 0x0d);
-       regmap_write(rt1308->regmap, 0xc311, 0x7f);
-       regmap_write(rt1308->regmap, 0xc900, 0x90);
+       if (rt1308->hw_ver == RT1308_VER_C) {
+               regmap_write(rt1308->regmap, 0xc311, 0x7f);
+               regmap_write(rt1308->regmap, 0xc300, 0x09);
+       } else {
+               regmap_write(rt1308->regmap, 0xc311, 0x4f);
+               regmap_write(rt1308->regmap, 0xc300, 0x0b);
+       }
+       regmap_write(rt1308->regmap, 0xc900, 0x5a);
        regmap_write(rt1308->regmap, 0xc1a0, 0x84);
        regmap_write(rt1308->regmap, 0xc1a1, 0x01);
        regmap_write(rt1308->regmap, 0xc360, 0x78);
@@ -257,7 +269,6 @@ static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
        regmap_write(rt1308->regmap, 0xc070, 0x00);
        regmap_write(rt1308->regmap, 0xc100, 0xd7);
        regmap_write(rt1308->regmap, 0xc101, 0xd7);
-       regmap_write(rt1308->regmap, 0xc300, 0x09);
 
        if (rt1308->first_hw_init) {
                regcache_cache_bypass(rt1308->regmap, false);
index 6668e19..f88f52e 100644 (file)
@@ -163,6 +163,7 @@ struct rt1308_sdw_priv {
        bool first_hw_init;
        int rx_mask;
        int slots;
+       int hw_ver;
 };
 
 struct sdw_stream_data {
index ff7c423..d3a0f91 100644 (file)
@@ -286,4 +286,9 @@ enum {
        RT1308_AIFS
 };
 
+enum rt1308_hw_ver {
+       RT1308_VER_C = 2,
+       RT1308_VER_D
+};
+
 #endif         /* end of _RT1308_H_ */