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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: Convert remaining Realtek codecs to GPIO

Merge series from Linus Walleij <linus.walleij@linaro.org>:

After dropping unused headers a few Realtek devices
actually using the GPIO descriptors remain.

Converting them to use optional GPIO descriptors is
pretty straight-forward.

+68 -91
-2
include/sound/rt5665.h
··· 31 31 bool in3_diff; 32 32 bool in4_diff; 33 33 34 - int ldo1_en; /* GPIO for LDO1_EN */ 35 - 36 34 enum rt5665_dmic1_data_pin dmic1_data_pin; 37 35 enum rt5665_dmic2_data_pin dmic2_data_pin; 38 36 enum rt5665_jd_src jd_src;
-3
include/sound/rt5668.h
··· 25 25 }; 26 26 27 27 struct rt5668_platform_data { 28 - 29 - int ldo1_en; /* GPIO for LDO1_EN */ 30 - 31 28 enum rt5668_dmic1_data_pin dmic1_data_pin; 32 29 enum rt5668_dmic1_clk_pin dmic1_clk_pin; 33 30 enum rt5668_jd_src jd_src;
-3
include/sound/rt5682.h
··· 31 31 }; 32 32 33 33 struct rt5682_platform_data { 34 - 35 - int ldo1_en; /* GPIO for LDO1_EN */ 36 - 37 34 enum rt5682_dmic1_data_pin dmic1_data_pin; 38 35 enum rt5682_dmic1_clk_pin dmic1_clk_pin; 39 36 enum rt5682_jd_src jd_src;
-3
include/sound/rt5682s.h
··· 32 32 }; 33 33 34 34 struct rt5682s_platform_data { 35 - 36 - int ldo1_en; /* GPIO for LDO1_EN */ 37 - 38 35 enum rt5682s_dmic1_data_pin dmic1_data_pin; 39 36 enum rt5682s_dmic1_clk_pin dmic1_clk_pin; 40 37 enum rt5682s_jd_src jd_src;
+15 -40
sound/soc/codecs/rt5640.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/delay.h> 14 14 #include <linux/pm.h> 15 - #include <linux/gpio.h> 15 + #include <linux/gpio/consumer.h> 16 16 #include <linux/i2c.h> 17 17 #include <linux/regmap.h> 18 18 #include <linux/of.h> 19 - #include <linux/of_gpio.h> 20 19 #include <linux/platform_device.h> 21 20 #include <linux/spi/spi.h> 22 21 #include <linux/acpi.h> ··· 2811 2812 rt5640_reset(component); 2812 2813 regcache_cache_only(rt5640->regmap, true); 2813 2814 regcache_mark_dirty(rt5640->regmap); 2814 - if (gpio_is_valid(rt5640->ldo1_en)) 2815 - gpio_set_value_cansleep(rt5640->ldo1_en, 0); 2815 + if (rt5640->ldo1_en) 2816 + gpiod_set_value_cansleep(rt5640->ldo1_en, 0); 2816 2817 2817 2818 return 0; 2818 2819 } ··· 2821 2822 { 2822 2823 struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); 2823 2824 2824 - if (gpio_is_valid(rt5640->ldo1_en)) { 2825 - gpio_set_value_cansleep(rt5640->ldo1_en, 1); 2825 + if (rt5640->ldo1_en) { 2826 + gpiod_set_value_cansleep(rt5640->ldo1_en, 1); 2826 2827 msleep(400); 2827 2828 } 2828 2829 ··· 2985 2986 MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); 2986 2987 #endif 2987 2988 2988 - static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) 2989 - { 2990 - rt5640->ldo1_en = of_get_named_gpio(np, "realtek,ldo1-en-gpios", 0); 2991 - /* 2992 - * LDO1_EN is optional (it may be statically tied on the board). 2993 - * -ENOENT means that the property doesn't exist, i.e. there is no 2994 - * GPIO, so is not an error. Any other error code means the property 2995 - * exists, but could not be parsed. 2996 - */ 2997 - if (!gpio_is_valid(rt5640->ldo1_en) && 2998 - (rt5640->ldo1_en != -ENOENT)) 2999 - return rt5640->ldo1_en; 3000 - 3001 - return 0; 3002 - } 3003 - 3004 2989 static int rt5640_i2c_probe(struct i2c_client *i2c) 3005 2990 { 3006 2991 struct rt5640_priv *rt5640; ··· 2998 3015 return -ENOMEM; 2999 3016 i2c_set_clientdata(i2c, rt5640); 3000 3017 3001 - if (i2c->dev.of_node) { 3002 - ret = rt5640_parse_dt(rt5640, i2c->dev.of_node); 3003 - if (ret) 3004 - return ret; 3005 - } else 3006 - rt5640->ldo1_en = -EINVAL; 3018 + rt5640->ldo1_en = devm_gpiod_get_optional(&i2c->dev, 3019 + "realtek,ldo1-en", 3020 + GPIOD_OUT_HIGH); 3021 + if (IS_ERR(rt5640->ldo1_en)) 3022 + return PTR_ERR(rt5640->ldo1_en); 3023 + 3024 + if (rt5640->ldo1_en) { 3025 + gpiod_set_consumer_name(rt5640->ldo1_en, "RT5640 LDO1_EN"); 3026 + msleep(400); 3027 + } 3007 3028 3008 3029 rt5640->regmap = devm_regmap_init_i2c(i2c, &rt5640_regmap); 3009 3030 if (IS_ERR(rt5640->regmap)) { ··· 3015 3028 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 3016 3029 ret); 3017 3030 return ret; 3018 - } 3019 - 3020 - if (gpio_is_valid(rt5640->ldo1_en)) { 3021 - ret = devm_gpio_request_one(&i2c->dev, rt5640->ldo1_en, 3022 - GPIOF_OUT_INIT_HIGH, 3023 - "RT5640 LDO1_EN"); 3024 - if (ret < 0) { 3025 - dev_err(&i2c->dev, "Failed to request LDO1_EN %d: %d\n", 3026 - rt5640->ldo1_en, ret); 3027 - return ret; 3028 - } 3029 - msleep(400); 3030 3031 } 3031 3032 3032 3033 regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val);
+1 -1
sound/soc/codecs/rt5640.h
··· 2138 2138 struct regmap *regmap; 2139 2139 struct clk *mclk; 2140 2140 2141 - int ldo1_en; /* GPIO for LDO1_EN */ 2141 + struct gpio_desc *ldo1_en; /* GPIO for LDO1_EN */ 2142 2142 int irq; 2143 2143 int jd_gpio_irq; 2144 2144 int sysclk;
+8 -9
sound/soc/codecs/rt5665.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/regulator/consumer.h> 21 20 #include <linux/mutex.h> 22 21 #include <sound/core.h> ··· 4658 4659 of_property_read_u32(dev->of_node, "realtek,jd-src", 4659 4660 &rt5665->pdata.jd_src); 4660 4661 4661 - rt5665->pdata.ldo1_en = of_get_named_gpio(dev->of_node, 4662 - "realtek,ldo1-en-gpios", 0); 4663 - 4664 4662 return 0; 4665 4663 } 4666 4664 ··· 4791 4795 return ret; 4792 4796 } 4793 4797 4794 - if (gpio_is_valid(rt5665->pdata.ldo1_en)) { 4795 - if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en, 4796 - GPIOF_OUT_INIT_HIGH, "rt5665")) 4797 - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); 4798 + 4799 + rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, 4800 + "realtek,ldo1-en", 4801 + GPIOD_OUT_HIGH); 4802 + if (IS_ERR(rt5665->gpiod_ldo1_en)) { 4803 + dev_err(&i2c->dev, "Failed gpio request ldo1_en\n"); 4804 + return PTR_ERR(rt5665->gpiod_ldo1_en); 4798 4805 } 4799 4806 4800 4807 /* Sleep for 300 ms miniumum */
+8 -9
sound/soc/codecs/rt5668.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/regulator/consumer.h> 21 20 #include <linux/mutex.h> 22 21 #include <sound/core.h> ··· 42 43 struct rt5668_priv { 43 44 struct snd_soc_component *component; 44 45 struct rt5668_platform_data pdata; 46 + struct gpio_desc *ldo1_en; 45 47 struct regmap *regmap; 46 48 struct snd_soc_jack *hs_jack; 47 49 struct regulator_bulk_data supplies[RT5668_NUM_SUPPLIES]; ··· 2393 2393 of_property_read_u32(dev->of_node, "realtek,jd-src", 2394 2394 &rt5668->pdata.jd_src); 2395 2395 2396 - rt5668->pdata.ldo1_en = of_get_named_gpio(dev->of_node, 2397 - "realtek,ldo1-en-gpios", 0); 2398 - 2399 2396 return 0; 2400 2397 } 2401 2398 ··· 2494 2497 return ret; 2495 2498 } 2496 2499 2497 - if (gpio_is_valid(rt5668->pdata.ldo1_en)) { 2498 - if (devm_gpio_request_one(&i2c->dev, rt5668->pdata.ldo1_en, 2499 - GPIOF_OUT_INIT_HIGH, "rt5668")) 2500 - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); 2500 + rt5668->ldo1_en = devm_gpiod_get_optional(&i2c->dev, 2501 + "realtek,ldo1-en", 2502 + GPIOD_OUT_HIGH); 2503 + if (IS_ERR(rt5668->ldo1_en)) { 2504 + dev_err(&i2c->dev, "Fail gpio request ldo1_en\n"); 2505 + return PTR_ERR(rt5668->ldo1_en); 2501 2506 } 2502 2507 2503 2508 /* Sleep for 300 ms miniumum */
+4 -7
sound/soc/codecs/rt5682-i2c.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/mutex.h> 21 20 #include <sound/core.h> 22 21 #include <sound/pcm.h> ··· 169 170 return ret; 170 171 } 171 172 172 - if (gpio_is_valid(rt5682->pdata.ldo1_en)) { 173 - if (devm_gpio_request_one(&i2c->dev, rt5682->pdata.ldo1_en, 174 - GPIOF_OUT_INIT_HIGH, "rt5682")) 175 - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); 176 - } 173 + ret = rt5682_get_ldo1(rt5682, &i2c->dev); 174 + if (ret) 175 + return ret; 177 176 178 177 /* Sleep for 300 ms miniumum */ 179 178 usleep_range(300000, 350000);
+5
sound/soc/codecs/rt5682-sdw.c
··· 320 320 return ret; 321 321 } 322 322 323 + 324 + ret = rt5682_get_ldo1(rt5682, dev); 325 + if (ret) 326 + return ret; 327 + 323 328 regcache_cache_only(rt5682->sdw_regmap, true); 324 329 regcache_cache_only(rt5682->regmap, true); 325 330
+15 -5
sound/soc/codecs/rt5682.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/mutex.h> 21 20 #include <sound/core.h> 22 21 #include <sound/pcm.h> ··· 3093 3094 device_property_read_u32(dev, "realtek,dmic-delay-ms", 3094 3095 &rt5682->pdata.dmic_delay); 3095 3096 3096 - rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node, 3097 - "realtek,ldo1-en-gpios", 0); 3098 - 3099 3097 if (device_property_read_string_array(dev, "clock-output-names", 3100 3098 rt5682->pdata.dai_clk_names, 3101 3099 RT5682_DAI_NUM_CLKS) < 0) ··· 3106 3110 return 0; 3107 3111 } 3108 3112 EXPORT_SYMBOL_GPL(rt5682_parse_dt); 3113 + 3114 + int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev) 3115 + { 3116 + rt5682->ldo1_en = devm_gpiod_get_optional(dev, 3117 + "realtek,ldo1-en", 3118 + GPIOD_OUT_HIGH); 3119 + if (IS_ERR(rt5682->ldo1_en)) { 3120 + dev_err(dev, "Fail gpio request ldo1_en\n"); 3121 + return PTR_ERR(rt5682->ldo1_en); 3122 + } 3123 + 3124 + return 0; 3125 + } 3126 + EXPORT_SYMBOL_GPL(rt5682_get_ldo1); 3109 3127 3110 3128 void rt5682_calibrate(struct rt5682_priv *rt5682) 3111 3129 {
+3
sound/soc/codecs/rt5682.h
··· 11 11 12 12 #include <sound/rt5682.h> 13 13 #include <linux/regulator/consumer.h> 14 + #include <linux/gpio/consumer.h> 14 15 #include <linux/clk.h> 15 16 #include <linux/clkdev.h> 16 17 #include <linux/clk-provider.h> ··· 1431 1430 struct snd_soc_component *component; 1432 1431 struct device *i2c_dev; 1433 1432 struct rt5682_platform_data pdata; 1433 + struct gpio_desc *ldo1_en; 1434 1434 struct regmap *regmap; 1435 1435 struct regmap *sdw_regmap; 1436 1436 struct snd_soc_jack *hs_jack; ··· 1483 1481 void rt5682_calibrate(struct rt5682_priv *rt5682); 1484 1482 void rt5682_reset(struct rt5682_priv *rt5682); 1485 1483 int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev); 1484 + int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev); 1486 1485 1487 1486 int rt5682_register_dai_clks(struct rt5682_priv *rt5682); 1488 1487
+7 -9
sound/soc/codecs/rt5682s.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/mutex.h> 21 20 #include <sound/core.h> 22 21 #include <sound/pcm.h> ··· 2972 2973 device_property_read_u32(dev, "realtek,amic-delay-ms", 2973 2974 &rt5682s->pdata.amic_delay); 2974 2975 2975 - rt5682s->pdata.ldo1_en = of_get_named_gpio(dev->of_node, 2976 - "realtek,ldo1-en-gpios", 0); 2977 - 2978 2976 if (device_property_read_string_array(dev, "clock-output-names", 2979 2977 rt5682s->pdata.dai_clk_names, 2980 2978 RT5682S_DAI_NUM_CLKS) < 0) ··· 3168 3172 return ret; 3169 3173 } 3170 3174 3171 - if (gpio_is_valid(rt5682s->pdata.ldo1_en)) { 3172 - if (devm_gpio_request_one(&i2c->dev, rt5682s->pdata.ldo1_en, 3173 - GPIOF_OUT_INIT_HIGH, "rt5682s")) 3174 - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); 3175 + rt5682s->ldo1_en = devm_gpiod_get_optional(&i2c->dev, 3176 + "realtek,ldo1-en", 3177 + GPIOD_OUT_HIGH); 3178 + if (IS_ERR(rt5682s->ldo1_en)) { 3179 + dev_err(&i2c->dev, "Fail gpio request ldo1_en\n"); 3180 + return PTR_ERR(rt5682s->ldo1_en); 3175 3181 } 3176 3182 3177 3183 /* Sleep for 50 ms minimum */
+2
sound/soc/codecs/rt5682s.h
··· 11 11 12 12 #include <sound/rt5682s.h> 13 13 #include <linux/regulator/consumer.h> 14 + #include <linux/gpio/consumer.h> 14 15 #include <linux/clk.h> 15 16 #include <linux/clkdev.h> 16 17 #include <linux/clk-provider.h> ··· 1447 1446 struct rt5682s_priv { 1448 1447 struct snd_soc_component *component; 1449 1448 struct rt5682s_platform_data pdata; 1449 + struct gpio_desc *ldo1_en; 1450 1450 struct regmap *regmap; 1451 1451 struct snd_soc_jack *hs_jack; 1452 1452 struct regulator_bulk_data supplies[RT5682S_NUM_SUPPLIES];