]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: rt5677: Add reset-gpio dts option
authorAnatol Pomozov <anatol.pomozov@gmail.com>
Wed, 13 May 2015 15:25:15 +0000 (08:25 -0700)
committerMark Brown <broonie@kernel.org>
Sat, 16 May 2015 12:13:04 +0000 (13:13 +0100)
It allows to configure codec's RESET pin gpio

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Documentation/devicetree/bindings/sound/rt5677.txt
sound/soc/codecs/rt5677.c
sound/soc/codecs/rt5677.h

index 740ff771aa8b319ceeb1b282635534859cdec1db..f07078997f87e0185cb3a2518893d97885ded472 100644 (file)
@@ -18,6 +18,7 @@ Required properties:
 Optional properties:
 
 - realtek,pow-ldo2-gpio : The GPIO that controls the CODEC's POW_LDO2 pin.
+- realtek,reset-gpio : The GPIO that controls the CODEC's RESET pin.
 
 - realtek,in1-differential
 - realtek,in2-differential
@@ -70,6 +71,7 @@ rt5677 {
 
        realtek,pow-ldo2-gpio =
                <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>;
+       realtek,reset-gpio = <&gpio TEGRA_GPIO(BB, 3) GPIO_ACTIVE_LOW>;
        realtek,in1-differential = "true";
        realtek,gpio-config = /bits/ 8  <0 0 0 0 0 2>;   /* pull up GPIO6 */
        realtek,jd2-gpio = <3>;  /* Enables Jack detection for GPIO6 */
index c73105e75c1aa61916d15f18acd06a1a2425050f..aba00fd8dfc40228c6e10e5bb0a4a18b311046b9 100644 (file)
@@ -4763,6 +4763,8 @@ static int rt5677_remove(struct snd_soc_codec *codec)
        regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec);
        if (gpio_is_valid(rt5677->pow_ldo2))
                gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
+       if (gpio_is_valid(rt5677->reset_pin))
+               gpio_set_value_cansleep(rt5677->reset_pin, 0);
 
        return 0;
 }
@@ -4778,6 +4780,8 @@ static int rt5677_suspend(struct snd_soc_codec *codec)
 
                if (gpio_is_valid(rt5677->pow_ldo2))
                        gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
+               if (gpio_is_valid(rt5677->reset_pin))
+                       gpio_set_value_cansleep(rt5677->reset_pin, 0);
        }
 
        return 0;
@@ -4788,10 +4792,13 @@ static int rt5677_resume(struct snd_soc_codec *codec)
        struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
 
        if (!rt5677->dsp_vad_en) {
-               if (gpio_is_valid(rt5677->pow_ldo2)) {
+               if (gpio_is_valid(rt5677->pow_ldo2))
                        gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
+               if (gpio_is_valid(rt5677->reset_pin))
+                       gpio_set_value_cansleep(rt5677->reset_pin, 1);
+               if (gpio_is_valid(rt5677->pow_ldo2) ||
+                   gpio_is_valid(rt5677->reset_pin))
                        msleep(10);
-               }
 
                regcache_cache_only(rt5677->regmap, false);
                regcache_sync(rt5677->regmap);
@@ -5029,6 +5036,8 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np)
 
        rt5677->pow_ldo2 = of_get_named_gpio(np,
                                        "realtek,pow-ldo2-gpio", 0);
+       rt5677->reset_pin = of_get_named_gpio(np,
+                                       "realtek,reset-gpio", 0);
 
        /*
         * POW_LDO2 is optional (it may be statically tied on the board).
@@ -5039,6 +5048,9 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np)
        if (!gpio_is_valid(rt5677->pow_ldo2) &&
                        (rt5677->pow_ldo2 != -ENOENT))
                return rt5677->pow_ldo2;
+       if (!gpio_is_valid(rt5677->reset_pin) &&
+                       (rt5677->reset_pin != -ENOENT))
+               return rt5677->reset_pin;
 
        of_property_read_u8_array(np, "realtek,gpio-config",
                rt5677->pdata.gpio_config, RT5677_GPIO_NUM);
@@ -5140,6 +5152,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
                }
        } else {
                rt5677->pow_ldo2 = -EINVAL;
+               rt5677->reset_pin = -EINVAL;
        }
 
        if (gpio_is_valid(rt5677->pow_ldo2)) {
@@ -5151,6 +5164,21 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
                                rt5677->pow_ldo2, ret);
                        return ret;
                }
+       }
+
+       if (gpio_is_valid(rt5677->reset_pin)) {
+               ret = devm_gpio_request_one(&i2c->dev, rt5677->reset_pin,
+                                           GPIOF_OUT_INIT_HIGH,
+                                           "RT5677 RESET");
+               if (ret < 0) {
+                       dev_err(&i2c->dev, "Failed to request RESET %d: %d\n",
+                               rt5677->reset_pin, ret);
+                       return ret;
+               }
+       }
+
+       if (gpio_is_valid(rt5677->pow_ldo2) ||
+           gpio_is_valid(rt5677->reset_pin)) {
                /* Wait a while until I2C bus becomes available. The datasheet
                 * does not specify the exact we should wait but startup
                 * sequence mentiones at least a few milliseconds.
index 62571d071a8d69af8e2c988c3ee5b88666debb23..7eca38a2325566469aa96f8d019dc4fefbc9328d 100644 (file)
@@ -1776,6 +1776,7 @@ struct rt5677_priv {
        int pll_in;
        int pll_out;
        int pow_ldo2; /* POW_LDO2 pin */
+       int reset_pin; /* RESET pin */
        enum rt5677_type type;
 #ifdef CONFIG_GPIOLIB
        struct gpio_chip gpio_chip;