ASoC: jack: Basic GPIO descriptor conversion
This patch does basic GPIO descriptor conversion to soc-jack. Even the GPIOs are still passed and requested using legacy GPIO numbers the driver internals are converted to use GPIO descriptor API. Motivation for this is to prepare soc-jack so that it will allow registering jack GPIO pins using both GPIO descriptors and legacy GPIO numbers. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
c9eaa447e7
commit
50dfb69d1b
2 changed files with 12 additions and 8 deletions
|
@ -606,6 +606,7 @@ struct snd_soc_jack_gpio {
|
||||||
|
|
||||||
struct snd_soc_jack *jack;
|
struct snd_soc_jack *jack;
|
||||||
struct delayed_work work;
|
struct delayed_work work;
|
||||||
|
struct gpio_desc *desc;
|
||||||
|
|
||||||
void *data;
|
void *data;
|
||||||
int (*jack_status_check)(void *data);
|
int (*jack_status_check)(void *data);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <sound/jack.h>
|
#include <sound/jack.h>
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
@ -240,7 +241,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
|
||||||
int enable;
|
int enable;
|
||||||
int report;
|
int report;
|
||||||
|
|
||||||
enable = gpio_get_value_cansleep(gpio->gpio);
|
enable = gpiod_get_value_cansleep(gpio->desc);
|
||||||
if (gpio->invert)
|
if (gpio->invert)
|
||||||
enable = !enable;
|
enable = !enable;
|
||||||
|
|
||||||
|
@ -314,14 +315,16 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto undo;
|
goto undo;
|
||||||
|
|
||||||
ret = gpio_direction_input(gpios[i].gpio);
|
gpios[i].desc = gpio_to_desc(gpios[i].gpio);
|
||||||
|
|
||||||
|
ret = gpiod_direction_input(gpios[i].desc);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
|
INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
|
||||||
gpios[i].jack = jack;
|
gpios[i].jack = jack;
|
||||||
|
|
||||||
ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio),
|
ret = request_any_context_irq(gpiod_to_irq(gpios[i].desc),
|
||||||
gpio_handler,
|
gpio_handler,
|
||||||
IRQF_TRIGGER_RISING |
|
IRQF_TRIGGER_RISING |
|
||||||
IRQF_TRIGGER_FALLING,
|
IRQF_TRIGGER_FALLING,
|
||||||
|
@ -331,7 +334,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (gpios[i].wake) {
|
if (gpios[i].wake) {
|
||||||
ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1);
|
ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
dev_err(jack->codec->dev, "ASoC: "
|
dev_err(jack->codec->dev, "ASoC: "
|
||||||
"Failed to mark GPIO %d as wake source: %d\n",
|
"Failed to mark GPIO %d as wake source: %d\n",
|
||||||
|
@ -339,7 +342,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expose GPIO value over sysfs for diagnostic purposes */
|
/* Expose GPIO value over sysfs for diagnostic purposes */
|
||||||
gpio_export(gpios[i].gpio, false);
|
gpiod_export(gpios[i].desc, false);
|
||||||
|
|
||||||
/* Update initial jack status */
|
/* Update initial jack status */
|
||||||
schedule_delayed_work(&gpios[i].work,
|
schedule_delayed_work(&gpios[i].work,
|
||||||
|
@ -372,10 +375,10 @@ void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
gpio_unexport(gpios[i].gpio);
|
gpiod_unexport(gpios[i].desc);
|
||||||
free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
|
free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]);
|
||||||
cancel_delayed_work_sync(&gpios[i].work);
|
cancel_delayed_work_sync(&gpios[i].work);
|
||||||
gpio_free(gpios[i].gpio);
|
gpiod_put(gpios[i].desc);
|
||||||
gpios[i].jack = NULL;
|
gpios[i].jack = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue