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: codec: wcd93xx: Convert to GPIO descriptors

Merge series from "Peng Fan (OSS)" <peng.fan@oss.nxp.com>:

of_gpio.h is deprecated, so update driver to use gpiod API.

The current driver use value 0 to assert reset and 1 to deassert reset.
The DTSes in tree that use the codec are using GPIO_ACTIVE_LOW.
So it is safe to use devm_gpiod_get to get GPIO descriptors and
use gpiod_set_value to configure output with value 1 means raw value
0, value 0 means raw value 1.

Note:
I not have devices to test, just my best pratice to do the convertion.

+21 -23
+7 -8
sound/soc/codecs/wcd9335.c
··· 17 17 #include <sound/soc.h> 18 18 #include <sound/pcm_params.h> 19 19 #include <sound/soc-dapm.h> 20 - #include <linux/of_gpio.h> 20 + #include <linux/gpio/consumer.h> 21 21 #include <linux/of.h> 22 22 #include <linux/of_irq.h> 23 23 #include <sound/tlv.h> ··· 331 331 int comp_enabled[COMPANDER_MAX]; 332 332 333 333 int intr1; 334 - int reset_gpio; 334 + struct gpio_desc *reset_gpio; 335 335 struct regulator_bulk_data supplies[WCD9335_MAX_SUPPLY]; 336 336 337 337 unsigned int rx_port_value[WCD9335_RX_MAX]; ··· 4975 4975 static int wcd9335_parse_dt(struct wcd9335_codec *wcd) 4976 4976 { 4977 4977 struct device *dev = wcd->dev; 4978 - struct device_node *np = dev->of_node; 4979 4978 int ret; 4980 4979 4981 - wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); 4982 - if (wcd->reset_gpio < 0) 4983 - return dev_err_probe(dev, wcd->reset_gpio, "Reset GPIO missing from DT\n"); 4980 + wcd->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 4981 + if (IS_ERR(wcd->reset_gpio)) 4982 + return dev_err_probe(dev, PTR_ERR(wcd->reset_gpio), "Reset GPIO missing from DT\n"); 4984 4983 4985 4984 wcd->mclk = devm_clk_get(dev, "mclk"); 4986 4985 if (IS_ERR(wcd->mclk)) ··· 5022 5023 */ 5023 5024 usleep_range(600, 650); 5024 5025 5025 - gpio_direction_output(wcd->reset_gpio, 0); 5026 + gpiod_set_value(wcd->reset_gpio, 1); 5026 5027 msleep(20); 5027 - gpio_set_value(wcd->reset_gpio, 1); 5028 + gpiod_set_value(wcd->reset_gpio, 0); 5028 5029 msleep(20); 5029 5030 5030 5031 return 0;
+6 -7
sound/soc/codecs/wcd938x.c
··· 11 11 #include <linux/pm_runtime.h> 12 12 #include <linux/component.h> 13 13 #include <sound/tlv.h> 14 - #include <linux/of_gpio.h> 15 14 #include <linux/of.h> 16 15 #include <sound/jack.h> 17 16 #include <sound/pcm.h> ··· 170 171 int flyback_cur_det_disable; 171 172 int ear_rx_path; 172 173 int variant; 173 - int reset_gpio; 174 + struct gpio_desc *reset_gpio; 174 175 struct gpio_desc *us_euro_gpio; 175 176 u32 micb1_mv; 176 177 u32 micb2_mv; ··· 3250 3251 struct wcd_mbhc_config *cfg = &wcd938x->mbhc_cfg; 3251 3252 int ret; 3252 3253 3253 - wcd938x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); 3254 - if (wcd938x->reset_gpio < 0) 3255 - return dev_err_probe(dev, wcd938x->reset_gpio, 3254 + wcd938x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 3255 + if (IS_ERR(wcd938x->reset_gpio)) 3256 + return dev_err_probe(dev, PTR_ERR(wcd938x->reset_gpio), 3256 3257 "Failed to get reset gpio\n"); 3257 3258 3258 3259 wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", ··· 3296 3297 3297 3298 static int wcd938x_reset(struct wcd938x_priv *wcd938x) 3298 3299 { 3299 - gpio_direction_output(wcd938x->reset_gpio, 0); 3300 + gpiod_set_value(wcd938x->reset_gpio, 1); 3300 3301 /* 20us sleep required after pulling the reset gpio to LOW */ 3301 3302 usleep_range(20, 30); 3302 - gpio_set_value(wcd938x->reset_gpio, 1); 3303 + gpiod_set_value(wcd938x->reset_gpio, 0); 3303 3304 /* 20us sleep required after pulling the reset gpio to HIGH */ 3304 3305 usleep_range(20, 30); 3305 3306
+8 -8
sound/soc/codecs/wcd939x.c
··· 15 15 #include <linux/pm_runtime.h> 16 16 #include <linux/component.h> 17 17 #include <sound/tlv.h> 18 - #include <linux/of_gpio.h> 19 18 #include <linux/of_graph.h> 20 19 #include <linux/of.h> 21 20 #include <sound/jack.h> ··· 200 201 u32 hph_mode; 201 202 u32 tx_mode[TX_ADC_MAX]; 202 203 int variant; 203 - int reset_gpio; 204 + struct gpio_desc *reset_gpio; 204 205 u32 micb1_mv; 205 206 u32 micb2_mv; 206 207 u32 micb3_mv; ··· 3238 3239 #endif /* CONFIG_TYPEC */ 3239 3240 int ret; 3240 3241 3241 - wcd939x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); 3242 - if (wcd939x->reset_gpio < 0) 3243 - return dev_err_probe(dev, wcd939x->reset_gpio, 3244 - "Failed to get reset gpio\n"); 3242 + wcd939x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 3243 + if (IS_ERR(wcd939x->reset_gpio)) { 3244 + ret = PTR_ERR(wcd939x->reset_gpio); 3245 + return dev_err_probe(dev, ret, "Failed to get reset gpio\n"); 3246 + } 3245 3247 3246 3248 wcd939x->supplies[0].supply = "vdd-rxtx"; 3247 3249 wcd939x->supplies[1].supply = "vdd-io"; ··· 3290 3290 3291 3291 static int wcd939x_reset(struct wcd939x_priv *wcd939x) 3292 3292 { 3293 - gpio_direction_output(wcd939x->reset_gpio, 0); 3293 + gpiod_set_value(wcd939x->reset_gpio, 1); 3294 3294 /* 20us sleep required after pulling the reset gpio to LOW */ 3295 3295 usleep_range(20, 30); 3296 - gpio_set_value(wcd939x->reset_gpio, 1); 3296 + gpiod_set_value(wcd939x->reset_gpio, 0); 3297 3297 /* 20us sleep required after pulling the reset gpio to HIGH */ 3298 3298 usleep_range(20, 30); 3299 3299