diff options
| -rw-r--r-- | Documentation/devicetree/bindings/sound/rt5677.txt | 2 | ||||
| -rw-r--r-- | sound/soc/codecs/rt5677.c | 32 | ||||
| -rw-r--r-- | sound/soc/codecs/rt5677.h | 1 |
3 files changed, 33 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt index 740ff771aa8b..f07078997f87 100644 --- a/Documentation/devicetree/bindings/sound/rt5677.txt +++ b/Documentation/devicetree/bindings/sound/rt5677.txt | |||
| @@ -18,6 +18,7 @@ Required properties: | |||
| 18 | Optional properties: | 18 | Optional properties: |
| 19 | 19 | ||
| 20 | - realtek,pow-ldo2-gpio : The GPIO that controls the CODEC's POW_LDO2 pin. | 20 | - realtek,pow-ldo2-gpio : The GPIO that controls the CODEC's POW_LDO2 pin. |
| 21 | - realtek,reset-gpio : The GPIO that controls the CODEC's RESET pin. | ||
| 21 | 22 | ||
| 22 | - realtek,in1-differential | 23 | - realtek,in1-differential |
| 23 | - realtek,in2-differential | 24 | - realtek,in2-differential |
| @@ -70,6 +71,7 @@ rt5677 { | |||
| 70 | 71 | ||
| 71 | realtek,pow-ldo2-gpio = | 72 | realtek,pow-ldo2-gpio = |
| 72 | <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; | 73 | <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; |
| 74 | realtek,reset-gpio = <&gpio TEGRA_GPIO(BB, 3) GPIO_ACTIVE_LOW>; | ||
| 73 | realtek,in1-differential = "true"; | 75 | realtek,in1-differential = "true"; |
| 74 | realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ | 76 | realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ |
| 75 | realtek,jd2-gpio = <3>; /* Enables Jack detection for GPIO6 */ | 77 | realtek,jd2-gpio = <3>; /* Enables Jack detection for GPIO6 */ |
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index c73105e75c1a..aba00fd8dfc4 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c | |||
| @@ -4763,6 +4763,8 @@ static int rt5677_remove(struct snd_soc_codec *codec) | |||
| 4763 | regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); | 4763 | regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); |
| 4764 | if (gpio_is_valid(rt5677->pow_ldo2)) | 4764 | if (gpio_is_valid(rt5677->pow_ldo2)) |
| 4765 | gpio_set_value_cansleep(rt5677->pow_ldo2, 0); | 4765 | gpio_set_value_cansleep(rt5677->pow_ldo2, 0); |
| 4766 | if (gpio_is_valid(rt5677->reset_pin)) | ||
| 4767 | gpio_set_value_cansleep(rt5677->reset_pin, 0); | ||
| 4766 | 4768 | ||
| 4767 | return 0; | 4769 | return 0; |
| 4768 | } | 4770 | } |
| @@ -4778,6 +4780,8 @@ static int rt5677_suspend(struct snd_soc_codec *codec) | |||
| 4778 | 4780 | ||
| 4779 | if (gpio_is_valid(rt5677->pow_ldo2)) | 4781 | if (gpio_is_valid(rt5677->pow_ldo2)) |
| 4780 | gpio_set_value_cansleep(rt5677->pow_ldo2, 0); | 4782 | gpio_set_value_cansleep(rt5677->pow_ldo2, 0); |
| 4783 | if (gpio_is_valid(rt5677->reset_pin)) | ||
| 4784 | gpio_set_value_cansleep(rt5677->reset_pin, 0); | ||
| 4781 | } | 4785 | } |
| 4782 | 4786 | ||
| 4783 | return 0; | 4787 | return 0; |
| @@ -4788,10 +4792,13 @@ static int rt5677_resume(struct snd_soc_codec *codec) | |||
| 4788 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | 4792 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); |
| 4789 | 4793 | ||
| 4790 | if (!rt5677->dsp_vad_en) { | 4794 | if (!rt5677->dsp_vad_en) { |
| 4791 | if (gpio_is_valid(rt5677->pow_ldo2)) { | 4795 | if (gpio_is_valid(rt5677->pow_ldo2)) |
| 4792 | gpio_set_value_cansleep(rt5677->pow_ldo2, 1); | 4796 | gpio_set_value_cansleep(rt5677->pow_ldo2, 1); |
| 4797 | if (gpio_is_valid(rt5677->reset_pin)) | ||
| 4798 | gpio_set_value_cansleep(rt5677->reset_pin, 1); | ||
| 4799 | if (gpio_is_valid(rt5677->pow_ldo2) || | ||
| 4800 | gpio_is_valid(rt5677->reset_pin)) | ||
| 4793 | msleep(10); | 4801 | msleep(10); |
| 4794 | } | ||
| 4795 | 4802 | ||
| 4796 | regcache_cache_only(rt5677->regmap, false); | 4803 | regcache_cache_only(rt5677->regmap, false); |
| 4797 | regcache_sync(rt5677->regmap); | 4804 | regcache_sync(rt5677->regmap); |
| @@ -5029,6 +5036,8 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) | |||
| 5029 | 5036 | ||
| 5030 | rt5677->pow_ldo2 = of_get_named_gpio(np, | 5037 | rt5677->pow_ldo2 = of_get_named_gpio(np, |
| 5031 | "realtek,pow-ldo2-gpio", 0); | 5038 | "realtek,pow-ldo2-gpio", 0); |
| 5039 | rt5677->reset_pin = of_get_named_gpio(np, | ||
| 5040 | "realtek,reset-gpio", 0); | ||
| 5032 | 5041 | ||
| 5033 | /* | 5042 | /* |
| 5034 | * POW_LDO2 is optional (it may be statically tied on the board). | 5043 | * 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) | |||
| 5039 | if (!gpio_is_valid(rt5677->pow_ldo2) && | 5048 | if (!gpio_is_valid(rt5677->pow_ldo2) && |
| 5040 | (rt5677->pow_ldo2 != -ENOENT)) | 5049 | (rt5677->pow_ldo2 != -ENOENT)) |
| 5041 | return rt5677->pow_ldo2; | 5050 | return rt5677->pow_ldo2; |
| 5051 | if (!gpio_is_valid(rt5677->reset_pin) && | ||
| 5052 | (rt5677->reset_pin != -ENOENT)) | ||
| 5053 | return rt5677->reset_pin; | ||
| 5042 | 5054 | ||
| 5043 | of_property_read_u8_array(np, "realtek,gpio-config", | 5055 | of_property_read_u8_array(np, "realtek,gpio-config", |
| 5044 | rt5677->pdata.gpio_config, RT5677_GPIO_NUM); | 5056 | rt5677->pdata.gpio_config, RT5677_GPIO_NUM); |
| @@ -5140,6 +5152,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, | |||
| 5140 | } | 5152 | } |
| 5141 | } else { | 5153 | } else { |
| 5142 | rt5677->pow_ldo2 = -EINVAL; | 5154 | rt5677->pow_ldo2 = -EINVAL; |
| 5155 | rt5677->reset_pin = -EINVAL; | ||
| 5143 | } | 5156 | } |
| 5144 | 5157 | ||
| 5145 | if (gpio_is_valid(rt5677->pow_ldo2)) { | 5158 | if (gpio_is_valid(rt5677->pow_ldo2)) { |
| @@ -5151,6 +5164,21 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, | |||
| 5151 | rt5677->pow_ldo2, ret); | 5164 | rt5677->pow_ldo2, ret); |
| 5152 | return ret; | 5165 | return ret; |
| 5153 | } | 5166 | } |
| 5167 | } | ||
| 5168 | |||
| 5169 | if (gpio_is_valid(rt5677->reset_pin)) { | ||
| 5170 | ret = devm_gpio_request_one(&i2c->dev, rt5677->reset_pin, | ||
| 5171 | GPIOF_OUT_INIT_HIGH, | ||
| 5172 | "RT5677 RESET"); | ||
| 5173 | if (ret < 0) { | ||
| 5174 | dev_err(&i2c->dev, "Failed to request RESET %d: %d\n", | ||
| 5175 | rt5677->reset_pin, ret); | ||
| 5176 | return ret; | ||
| 5177 | } | ||
| 5178 | } | ||
| 5179 | |||
| 5180 | if (gpio_is_valid(rt5677->pow_ldo2) || | ||
| 5181 | gpio_is_valid(rt5677->reset_pin)) { | ||
| 5154 | /* Wait a while until I2C bus becomes available. The datasheet | 5182 | /* Wait a while until I2C bus becomes available. The datasheet |
| 5155 | * does not specify the exact we should wait but startup | 5183 | * does not specify the exact we should wait but startup |
| 5156 | * sequence mentiones at least a few milliseconds. | 5184 | * sequence mentiones at least a few milliseconds. |
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index 62571d071a8d..7eca38a23255 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h | |||
| @@ -1776,6 +1776,7 @@ struct rt5677_priv { | |||
| 1776 | int pll_in; | 1776 | int pll_in; |
| 1777 | int pll_out; | 1777 | int pll_out; |
| 1778 | int pow_ldo2; /* POW_LDO2 pin */ | 1778 | int pow_ldo2; /* POW_LDO2 pin */ |
| 1779 | int reset_pin; /* RESET pin */ | ||
| 1779 | enum rt5677_type type; | 1780 | enum rt5677_type type; |
| 1780 | #ifdef CONFIG_GPIOLIB | 1781 | #ifdef CONFIG_GPIOLIB |
| 1781 | struct gpio_chip gpio_chip; | 1782 | struct gpio_chip gpio_chip; |
