Skip to content

Commit 65086ec

Browse files
committed
ASoC: Convert PCM codecs to GPIO descriptors
Merge series from Linus Walleij <[email protected]>: 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>.
2 parents b9d98ae + 17fdf31 commit 65086ec

File tree

5 files changed

+40
-76
lines changed

5 files changed

+40
-76
lines changed

sound/soc/codecs/pcm1681.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <linux/module.h>
1010
#include <linux/slab.h>
1111
#include <linux/delay.h>
12-
#include <linux/gpio.h>
1312
#include <linux/i2c.h>
1413
#include <linux/regmap.h>
1514
#include <linux/of.h>

sound/soc/codecs/pcm3008.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,30 @@
1414
#include <linux/init.h>
1515
#include <linux/kernel.h>
1616
#include <linux/device.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/slab.h>
1919
#include <linux/module.h>
2020
#include <sound/core.h>
2121
#include <sound/pcm.h>
2222
#include <sound/initval.h>
2323
#include <sound/soc.h>
2424

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+
};
2631

2732
static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w,
2833
struct snd_kcontrol *kcontrol,
2934
int event)
3035
{
3136
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;
3338

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));
3641

3742
return 0;
3843
}
@@ -42,10 +47,10 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w,
4247
int event)
4348
{
4449
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
45-
struct pcm3008_setup_data *setup = component->dev->platform_data;
50+
struct pcm3008 *pcm = component->dev->platform_data;
4651

47-
gpio_set_value_cansleep(setup->pdad_pin,
48-
SND_SOC_DAPM_EVENT_ON(event));
52+
gpiod_set_value_cansleep(pcm->pdad_pin,
53+
SND_SOC_DAPM_EVENT_ON(event));
4954

5055
return 0;
5156
}
@@ -106,11 +111,13 @@ static const struct snd_soc_component_driver soc_component_dev_pcm3008 = {
106111

107112
static int pcm3008_codec_probe(struct platform_device *pdev)
108113
{
109-
struct pcm3008_setup_data *setup = pdev->dev.platform_data;
110-
int ret;
114+
struct device *dev = &pdev->dev;
115+
struct pcm3008 *pcm;
111116

112-
if (!setup)
113-
return -EINVAL;
117+
pcm = devm_kzalloc(dev, sizeof(*pcm), GFP_KERNEL);
118+
if (!pcm)
119+
return -ENOMEM;
120+
platform_set_drvdata(pdev, pcm);
114121

115122
/* DEM1 DEM0 DE-EMPHASIS_MODE
116123
* Low Low De-emphasis 44.1 kHz ON
@@ -120,30 +127,26 @@ static int pcm3008_codec_probe(struct platform_device *pdev)
120127
*/
121128

122129
/* Configure DEM0 GPIO (turning OFF DAC De-emphasis). */
123-
ret = devm_gpio_request_one(&pdev->dev, setup->dem0_pin,
124-
GPIOF_OUT_INIT_HIGH, "codec_dem0");
125-
if (ret != 0)
126-
return ret;
130+
pcm->dem0_pin = devm_gpiod_get(dev, "dem0", GPIOD_OUT_HIGH);
131+
if (IS_ERR(pcm->dem0_pin))
132+
return PTR_ERR(pcm->dem0_pin);
127133

128134
/* Configure DEM1 GPIO (turning OFF DAC De-emphasis). */
129-
ret = devm_gpio_request_one(&pdev->dev, setup->dem1_pin,
130-
GPIOF_OUT_INIT_LOW, "codec_dem1");
131-
if (ret != 0)
132-
return ret;
135+
pcm->dem1_pin = devm_gpiod_get(dev, "dem1", GPIOD_OUT_LOW);
136+
if (IS_ERR(pcm->dem1_pin))
137+
return PTR_ERR(pcm->dem1_pin);
133138

134139
/* Configure PDAD GPIO. */
135-
ret = devm_gpio_request_one(&pdev->dev, setup->pdad_pin,
136-
GPIOF_OUT_INIT_LOW, "codec_pdad");
137-
if (ret != 0)
138-
return ret;
140+
pcm->pdad_pin = devm_gpiod_get(dev, "pdad", GPIOD_OUT_LOW);
141+
if (IS_ERR(pcm->pdad_pin))
142+
return PTR_ERR(pcm->pdad_pin);
139143

140144
/* Configure PDDA GPIO. */
141-
ret = devm_gpio_request_one(&pdev->dev, setup->pdda_pin,
142-
GPIOF_OUT_INIT_LOW, "codec_pdda");
143-
if (ret != 0)
144-
return ret;
145+
pcm->pdda_pin = devm_gpiod_get(dev, "pdda", GPIOD_OUT_LOW);
146+
if (IS_ERR(pcm->pdda_pin))
147+
return PTR_ERR(pcm->pdda_pin);
145148

146-
return devm_snd_soc_register_component(&pdev->dev,
149+
return devm_snd_soc_register_component(dev,
147150
&soc_component_dev_pcm3008, &pcm3008_dai, 1);
148151
}
149152

sound/soc/codecs/pcm3008.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

sound/soc/codecs/pcm6240.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <linux/unaligned.h>
1616
#include <linux/firmware.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/i2c.h>
1919
#include <linux/module.h>
2020
#include <linux/of_irq.h>
@@ -2035,10 +2035,8 @@ static const struct regmap_config pcmdevice_i2c_regmap = {
20352035

20362036
static void pcmdevice_remove(struct pcmdevice_priv *pcm_dev)
20372037
{
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);
20422040
mutex_destroy(&pcm_dev->codec_lock);
20432041
}
20442042

@@ -2109,7 +2107,7 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
21092107
ndev = 1;
21102108
dev_addrs[0] = i2c->addr;
21112109
}
2112-
pcm_dev->irq_info.gpio = of_irq_get(np, 0);
2110+
pcm_dev->irq = of_irq_get(np, 0);
21132111

21142112
for (i = 0; i < ndev; i++)
21152113
pcm_dev->addr[i] = dev_addrs[i];
@@ -2132,22 +2130,10 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
21322130

21332131
if (pcm_dev->chip_id == PCM1690)
21342132
goto skip_interrupt;
2135-
if (gpio_is_valid(pcm_dev->irq_info.gpio)) {
2136-
dev_dbg(pcm_dev->dev, "irq-gpio = %d", pcm_dev->irq_info.gpio);
2137-
2138-
ret = gpio_request(pcm_dev->irq_info.gpio, "PCMDEV-IRQ");
2139-
if (!ret) {
2140-
int gpio = pcm_dev->irq_info.gpio;
2141-
2142-
gpio_direction_input(gpio);
2143-
pcm_dev->irq_info.nmb = gpio_to_irq(gpio);
2144-
2145-
} else
2146-
dev_err(pcm_dev->dev, "%s: GPIO %d request error\n",
2147-
__func__, pcm_dev->irq_info.gpio);
2133+
if (pcm_dev->irq) {
2134+
dev_dbg(pcm_dev->dev, "irq = %d", pcm_dev->irq);
21482135
} else
2149-
dev_err(pcm_dev->dev, "Looking up irq-gpio failed %d\n",
2150-
pcm_dev->irq_info.gpio);
2136+
dev_err(pcm_dev->dev, "No irq provided\n");
21512137

21522138
skip_interrupt:
21532139
ret = devm_snd_soc_register_component(&i2c->dev,

sound/soc/codecs/pcm6240.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,6 @@ struct pcmdevice_regbin {
208208
struct pcmdevice_config_info **cfg_info;
209209
};
210210

211-
struct pcmdevice_irqinfo {
212-
int gpio;
213-
int nmb;
214-
};
215-
216211
struct pcmdevice_priv {
217212
struct snd_soc_component *component;
218213
struct i2c_client *client;
@@ -221,7 +216,7 @@ struct pcmdevice_priv {
221216
struct gpio_desc *hw_rst;
222217
struct regmap *regmap;
223218
struct pcmdevice_regbin regbin;
224-
struct pcmdevice_irqinfo irq_info;
219+
int irq;
225220
unsigned int addr[PCMDEVICE_MAX_I2C_DEVICES];
226221
unsigned int chip_id;
227222
int cur_conf;

0 commit comments

Comments
 (0)