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

ASoC: Convert PCM codecs to GPIO descriptors

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

Three remaining TI PCM codecs use the old GPIO API in
different ways, fix them all up and move over to
<linux/gpio/consumer.h> and get rid of <linux/gpio.h>.

+40 -76
-1
sound/soc/codecs/pcm1681.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/slab.h> 11 11 #include <linux/delay.h> 12 - #include <linux/gpio.h> 13 12 #include <linux/i2c.h> 14 13 #include <linux/regmap.h> 15 14 #include <linux/of.h>
+32 -29
sound/soc/codecs/pcm3008.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/kernel.h> 16 16 #include <linux/device.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/consumer.h> 18 18 #include <linux/slab.h> 19 19 #include <linux/module.h> 20 20 #include <sound/core.h> ··· 22 22 #include <sound/initval.h> 23 23 #include <sound/soc.h> 24 24 25 - #include "pcm3008.h" 25 + struct pcm3008 { 26 + struct gpio_desc *dem0_pin; 27 + struct gpio_desc *dem1_pin; 28 + struct gpio_desc *pdad_pin; 29 + struct gpio_desc *pdda_pin; 30 + }; 26 31 27 32 static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w, 28 33 struct snd_kcontrol *kcontrol, 29 34 int event) 30 35 { 31 36 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 32 - struct pcm3008_setup_data *setup = component->dev->platform_data; 37 + struct pcm3008 *pcm = component->dev->platform_data; 33 38 34 - gpio_set_value_cansleep(setup->pdda_pin, 35 - SND_SOC_DAPM_EVENT_ON(event)); 39 + gpiod_set_value_cansleep(pcm->pdda_pin, 40 + SND_SOC_DAPM_EVENT_ON(event)); 36 41 37 42 return 0; 38 43 } ··· 47 42 int event) 48 43 { 49 44 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 50 - struct pcm3008_setup_data *setup = component->dev->platform_data; 45 + struct pcm3008 *pcm = component->dev->platform_data; 51 46 52 - gpio_set_value_cansleep(setup->pdad_pin, 53 - SND_SOC_DAPM_EVENT_ON(event)); 47 + gpiod_set_value_cansleep(pcm->pdad_pin, 48 + SND_SOC_DAPM_EVENT_ON(event)); 54 49 55 50 return 0; 56 51 } ··· 111 106 112 107 static int pcm3008_codec_probe(struct platform_device *pdev) 113 108 { 114 - struct pcm3008_setup_data *setup = pdev->dev.platform_data; 115 - int ret; 109 + struct device *dev = &pdev->dev; 110 + struct pcm3008 *pcm; 116 111 117 - if (!setup) 118 - return -EINVAL; 112 + pcm = devm_kzalloc(dev, sizeof(*pcm), GFP_KERNEL); 113 + if (!pcm) 114 + return -ENOMEM; 115 + platform_set_drvdata(pdev, pcm); 119 116 120 117 /* DEM1 DEM0 DE-EMPHASIS_MODE 121 118 * Low Low De-emphasis 44.1 kHz ON ··· 127 120 */ 128 121 129 122 /* Configure DEM0 GPIO (turning OFF DAC De-emphasis). */ 130 - ret = devm_gpio_request_one(&pdev->dev, setup->dem0_pin, 131 - GPIOF_OUT_INIT_HIGH, "codec_dem0"); 132 - if (ret != 0) 133 - return ret; 123 + pcm->dem0_pin = devm_gpiod_get(dev, "dem0", GPIOD_OUT_HIGH); 124 + if (IS_ERR(pcm->dem0_pin)) 125 + return PTR_ERR(pcm->dem0_pin); 134 126 135 127 /* Configure DEM1 GPIO (turning OFF DAC De-emphasis). */ 136 - ret = devm_gpio_request_one(&pdev->dev, setup->dem1_pin, 137 - GPIOF_OUT_INIT_LOW, "codec_dem1"); 138 - if (ret != 0) 139 - return ret; 128 + pcm->dem1_pin = devm_gpiod_get(dev, "dem1", GPIOD_OUT_LOW); 129 + if (IS_ERR(pcm->dem1_pin)) 130 + return PTR_ERR(pcm->dem1_pin); 140 131 141 132 /* Configure PDAD GPIO. */ 142 - ret = devm_gpio_request_one(&pdev->dev, setup->pdad_pin, 143 - GPIOF_OUT_INIT_LOW, "codec_pdad"); 144 - if (ret != 0) 145 - return ret; 133 + pcm->pdad_pin = devm_gpiod_get(dev, "pdad", GPIOD_OUT_LOW); 134 + if (IS_ERR(pcm->pdad_pin)) 135 + return PTR_ERR(pcm->pdad_pin); 146 136 147 137 /* Configure PDDA GPIO. */ 148 - ret = devm_gpio_request_one(&pdev->dev, setup->pdda_pin, 149 - GPIOF_OUT_INIT_LOW, "codec_pdda"); 150 - if (ret != 0) 151 - return ret; 138 + pcm->pdda_pin = devm_gpiod_get(dev, "pdda", GPIOD_OUT_LOW); 139 + if (IS_ERR(pcm->pdda_pin)) 140 + return PTR_ERR(pcm->pdda_pin); 152 141 153 - return devm_snd_soc_register_component(&pdev->dev, 142 + return devm_snd_soc_register_component(dev, 154 143 &soc_component_dev_pcm3008, &pcm3008_dai, 1); 155 144 } 156 145
-19
sound/soc/codecs/pcm3008.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * PCM3008 ALSA SoC Layer 4 - * 5 - * Author: Hugo Villeneuve 6 - * Copyright (C) 2008 Lyrtech inc 7 - */ 8 - 9 - #ifndef __LINUX_SND_SOC_PCM3008_H 10 - #define __LINUX_SND_SOC_PCM3008_H 11 - 12 - struct pcm3008_setup_data { 13 - unsigned dem0_pin; 14 - unsigned dem1_pin; 15 - unsigned pdad_pin; 16 - unsigned pdda_pin; 17 - }; 18 - 19 - #endif
+7 -21
sound/soc/codecs/pcm6240.c
··· 14 14 15 15 #include <linux/unaligned.h> 16 16 #include <linux/firmware.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/consumer.h> 18 18 #include <linux/i2c.h> 19 19 #include <linux/module.h> 20 20 #include <linux/of_irq.h> ··· 2035 2035 2036 2036 static void pcmdevice_remove(struct pcmdevice_priv *pcm_dev) 2037 2037 { 2038 - if (gpio_is_valid(pcm_dev->irq_info.gpio)) { 2039 - gpio_free(pcm_dev->irq_info.gpio); 2040 - free_irq(pcm_dev->irq_info.nmb, pcm_dev); 2041 - } 2038 + if (pcm_dev->irq) 2039 + free_irq(pcm_dev->irq, pcm_dev); 2042 2040 mutex_destroy(&pcm_dev->codec_lock); 2043 2041 } 2044 2042 ··· 2107 2109 ndev = 1; 2108 2110 dev_addrs[0] = i2c->addr; 2109 2111 } 2110 - pcm_dev->irq_info.gpio = of_irq_get(np, 0); 2112 + pcm_dev->irq = of_irq_get(np, 0); 2111 2113 2112 2114 for (i = 0; i < ndev; i++) 2113 2115 pcm_dev->addr[i] = dev_addrs[i]; ··· 2130 2132 2131 2133 if (pcm_dev->chip_id == PCM1690) 2132 2134 goto skip_interrupt; 2133 - if (gpio_is_valid(pcm_dev->irq_info.gpio)) { 2134 - dev_dbg(pcm_dev->dev, "irq-gpio = %d", pcm_dev->irq_info.gpio); 2135 - 2136 - ret = gpio_request(pcm_dev->irq_info.gpio, "PCMDEV-IRQ"); 2137 - if (!ret) { 2138 - int gpio = pcm_dev->irq_info.gpio; 2139 - 2140 - gpio_direction_input(gpio); 2141 - pcm_dev->irq_info.nmb = gpio_to_irq(gpio); 2142 - 2143 - } else 2144 - dev_err(pcm_dev->dev, "%s: GPIO %d request error\n", 2145 - __func__, pcm_dev->irq_info.gpio); 2135 + if (pcm_dev->irq) { 2136 + dev_dbg(pcm_dev->dev, "irq = %d", pcm_dev->irq); 2146 2137 } else 2147 - dev_err(pcm_dev->dev, "Looking up irq-gpio failed %d\n", 2148 - pcm_dev->irq_info.gpio); 2138 + dev_err(pcm_dev->dev, "No irq provided\n"); 2149 2139 2150 2140 skip_interrupt: 2151 2141 ret = devm_snd_soc_register_component(&i2c->dev,
+1 -6
sound/soc/codecs/pcm6240.h
··· 208 208 struct pcmdevice_config_info **cfg_info; 209 209 }; 210 210 211 - struct pcmdevice_irqinfo { 212 - int gpio; 213 - int nmb; 214 - }; 215 - 216 211 struct pcmdevice_priv { 217 212 struct snd_soc_component *component; 218 213 struct i2c_client *client; ··· 216 221 struct gpio_desc *hw_rst; 217 222 struct regmap *regmap; 218 223 struct pcmdevice_regbin regbin; 219 - struct pcmdevice_irqinfo irq_info; 224 + int irq; 220 225 unsigned int addr[PCMDEVICE_MAX_I2C_DEVICES]; 221 226 unsigned int chip_id; 222 227 int cur_conf;