aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/soc/soc-ac97.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-ac97.c')
-rw-r--r--sound/soc/soc-ac97.c90
1 files changed, 32 insertions, 58 deletions
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index 65db083e242b..4e4fe29ade50 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -14,10 +14,9 @@
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/export.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
#include <linux/init.h>
-#include <linux/of_gpio.h>
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#include <linux/slab.h>
@@ -29,17 +28,9 @@ struct snd_ac97_reset_cfg {
struct pinctrl_state *pstate_reset;
struct pinctrl_state *pstate_warm_reset;
struct pinctrl_state *pstate_run;
- int gpio_sdata;
- int gpio_sync;
- int gpio_reset;
-};
-
-struct snd_ac97_gpio_priv {
-#ifdef CONFIG_GPIOLIB
- struct gpio_chip gpio_chip;
-#endif
- unsigned int gpios_set;
- struct snd_soc_component *component;
+ struct gpio_desc *reset_gpio;
+ struct gpio_desc *sdata_gpio;
+ struct gpio_desc *sync_gpio;
};
static struct snd_ac97_bus soc_ac97_bus = {
@@ -52,6 +43,12 @@ static void soc_ac97_device_release(struct device *dev)
}
#ifdef CONFIG_GPIOLIB
+struct snd_ac97_gpio_priv {
+ struct gpio_chip gpio_chip;
+ unsigned int gpios_set;
+ struct snd_soc_component *component;
+};
+
static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip)
{
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
@@ -59,7 +56,7 @@ static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip
return gpio_priv->component;
}
-static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
+static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned int offset)
{
if (offset >= AC97_NUM_GPIOS)
return -EINVAL;
@@ -68,7 +65,7 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset)
}
static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip,
- unsigned offset)
+ unsigned int offset)
{
struct snd_soc_component *component = gpio_to_component(chip);
@@ -77,7 +74,7 @@ static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip,
1 << offset, 1 << offset);
}
-static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset)
+static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct snd_soc_component *component = gpio_to_component(chip);
int ret;
@@ -90,7 +87,7 @@ static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset)
return !!(ret & (1 << offset));
}
-static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset,
+static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset,
int value)
{
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
@@ -270,11 +267,11 @@ static void snd_soc_ac97_warm_reset(struct snd_ac97 *ac97)
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_warm_reset);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 1);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 1);
udelay(10);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 0);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 0);
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_run);
msleep(2);
@@ -286,13 +283,13 @@ static void snd_soc_ac97_reset(struct snd_ac97 *ac97)
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_reset);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_sync, 0);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_sdata, 0);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_reset, 0);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.sync_gpio, 0);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.sdata_gpio, 0);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.reset_gpio, 0);
udelay(10);
- gpio_direction_output(snd_ac97_rst_cfg.gpio_reset, 1);
+ gpiod_direction_output_raw(snd_ac97_rst_cfg.reset_gpio, 1);
pinctrl_select_state(pctl, snd_ac97_rst_cfg.pstate_run);
msleep(2);
@@ -303,8 +300,6 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
{
struct pinctrl *p;
struct pinctrl_state *state;
- int gpio;
- int ret;
p = devm_pinctrl_get(dev);
if (IS_ERR(p)) {
@@ -334,41 +329,20 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
}
cfg->pstate_run = state;
- gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 0);
- if (gpio < 0) {
- dev_err(dev, "Can't find ac97-sync gpio\n");
- return gpio;
- }
- ret = devm_gpio_request(dev, gpio, "AC97 link sync");
- if (ret) {
- dev_err(dev, "Failed requesting ac97-sync gpio\n");
- return ret;
- }
- cfg->gpio_sync = gpio;
+ cfg->sync_gpio = devm_gpiod_get_index(dev, "ac97", 0, GPIOD_ASIS);
+ if (IS_ERR(cfg->sync_gpio))
+ return dev_err_probe(dev, PTR_ERR(cfg->sync_gpio), "Can't find ac97-sync gpio\n");
+ gpiod_set_consumer_name(cfg->sync_gpio, "AC97 link sync");
- gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 1);
- if (gpio < 0) {
- dev_err(dev, "Can't find ac97-sdata gpio %d\n", gpio);
- return gpio;
- }
- ret = devm_gpio_request(dev, gpio, "AC97 link sdata");
- if (ret) {
- dev_err(dev, "Failed requesting ac97-sdata gpio\n");
- return ret;
- }
- cfg->gpio_sdata = gpio;
+ cfg->sdata_gpio = devm_gpiod_get_index(dev, "ac97", 1, GPIOD_ASIS);
+ if (IS_ERR(cfg->sdata_gpio))
+ return dev_err_probe(dev, PTR_ERR(cfg->sdata_gpio), "Can't find ac97-sdata gpio\n");
+ gpiod_set_consumer_name(cfg->sdata_gpio, "AC97 link sdata");
- gpio = of_get_named_gpio(dev->of_node, "ac97-gpios", 2);
- if (gpio < 0) {
- dev_err(dev, "Can't find ac97-reset gpio\n");
- return gpio;
- }
- ret = devm_gpio_request(dev, gpio, "AC97 link reset");
- if (ret) {
- dev_err(dev, "Failed requesting ac97-reset gpio\n");
- return ret;
- }
- cfg->gpio_reset = gpio;
+ cfg->reset_gpio = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_ASIS);
+ if (IS_ERR(cfg->reset_gpio))
+ return dev_err_probe(dev, PTR_ERR(cfg->reset_gpio), "Can't find ac97-reset gpio\n");
+ gpiod_set_consumer_name(cfg->reset_gpio, "AC97 link reset");
return 0;
}