Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: rt5677: Add reset-gpio dts option

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>

authored by

Anatol Pomozov and committed by
Mark Brown
b3b10e99 5220f7fb

+33 -2
+2
Documentation/devicetree/bindings/sound/rt5677.txt
··· 18 18 Optional properties: 19 19 20 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 23 - realtek,in1-differential 23 24 - realtek,in2-differential ··· 71 70 72 71 realtek,pow-ldo2-gpio = 73 72 <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; 73 + realtek,reset-gpio = <&gpio TEGRA_GPIO(BB, 3) GPIO_ACTIVE_LOW>; 74 74 realtek,in1-differential = "true"; 75 75 realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ 76 76 realtek,jd2-gpio = <3>; /* Enables Jack detection for GPIO6 */
+30 -2
sound/soc/codecs/rt5677.c
··· 4763 4763 regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); 4764 4764 if (gpio_is_valid(rt5677->pow_ldo2)) 4765 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 4769 return 0; 4768 4770 } ··· 4780 4778 4781 4779 if (gpio_is_valid(rt5677->pow_ldo2)) 4782 4780 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4781 + if (gpio_is_valid(rt5677->reset_pin)) 4782 + gpio_set_value_cansleep(rt5677->reset_pin, 0); 4783 4783 } 4784 4784 4785 4785 return 0; ··· 4792 4788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4793 4789 4794 4790 if (!rt5677->dsp_vad_en) { 4795 - if (gpio_is_valid(rt5677->pow_ldo2)) { 4791 + if (gpio_is_valid(rt5677->pow_ldo2)) 4796 4792 gpio_set_value_cansleep(rt5677->pow_ldo2, 1); 4793 + if (gpio_is_valid(rt5677->reset_pin)) 4794 + gpio_set_value_cansleep(rt5677->reset_pin, 1); 4795 + if (gpio_is_valid(rt5677->pow_ldo2) || 4796 + gpio_is_valid(rt5677->reset_pin)) 4797 4797 msleep(10); 4798 - } 4799 4798 4800 4799 regcache_cache_only(rt5677->regmap, false); 4801 4800 regcache_sync(rt5677->regmap); ··· 5036 5029 5037 5030 rt5677->pow_ldo2 = of_get_named_gpio(np, 5038 5031 "realtek,pow-ldo2-gpio", 0); 5032 + rt5677->reset_pin = of_get_named_gpio(np, 5033 + "realtek,reset-gpio", 0); 5039 5034 5040 5035 /* 5041 5036 * POW_LDO2 is optional (it may be statically tied on the board). ··· 5048 5039 if (!gpio_is_valid(rt5677->pow_ldo2) && 5049 5040 (rt5677->pow_ldo2 != -ENOENT)) 5050 5041 return rt5677->pow_ldo2; 5042 + if (!gpio_is_valid(rt5677->reset_pin) && 5043 + (rt5677->reset_pin != -ENOENT)) 5044 + return rt5677->reset_pin; 5051 5045 5052 5046 of_property_read_u8_array(np, "realtek,gpio-config", 5053 5047 rt5677->pdata.gpio_config, RT5677_GPIO_NUM); ··· 5152 5140 } 5153 5141 } else { 5154 5142 rt5677->pow_ldo2 = -EINVAL; 5143 + rt5677->reset_pin = -EINVAL; 5155 5144 } 5156 5145 5157 5146 if (gpio_is_valid(rt5677->pow_ldo2)) { ··· 5164 5151 rt5677->pow_ldo2, ret); 5165 5152 return ret; 5166 5153 } 5154 + } 5155 + 5156 + if (gpio_is_valid(rt5677->reset_pin)) { 5157 + ret = devm_gpio_request_one(&i2c->dev, rt5677->reset_pin, 5158 + GPIOF_OUT_INIT_HIGH, 5159 + "RT5677 RESET"); 5160 + if (ret < 0) { 5161 + dev_err(&i2c->dev, "Failed to request RESET %d: %d\n", 5162 + rt5677->reset_pin, ret); 5163 + return ret; 5164 + } 5165 + } 5166 + 5167 + if (gpio_is_valid(rt5677->pow_ldo2) || 5168 + gpio_is_valid(rt5677->reset_pin)) { 5167 5169 /* Wait a while until I2C bus becomes available. The datasheet 5168 5170 * does not specify the exact we should wait but startup 5169 5171 * sequence mentiones at least a few milliseconds.
+1
sound/soc/codecs/rt5677.h
··· 1776 1776 int pll_in; 1777 1777 int pll_out; 1778 1778 int pow_ldo2; /* POW_LDO2 pin */ 1779 + int reset_pin; /* RESET pin */ 1779 1780 enum rt5677_type type; 1780 1781 #ifdef CONFIG_GPIOLIB 1781 1782 struct gpio_chip gpio_chip;