* [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API
@ 2017-09-01 16:15 Andy Shevchenko
2017-09-01 16:15 ` [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-09-01 16:15 UTC (permalink / raw)
To: Nicolas Ferre, alsa-devel, Takashi Iwai, Jaroslav Kysela; +Cc: Andy Shevchenko
Convert the driver to use GPIO descriptor API.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
sound/atmel/ac97c.c | 70 ++++++++---------------------------------------------
1 file changed, 10 insertions(+), 60 deletions(-)
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 5ffefac2fa8f..380025887aef 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -12,16 +12,15 @@
#include <linux/bitmap.h>
#include <linux/device.h>
#include <linux/atmel_pdc.h>
+#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
-#include <linux/gpio.h>
#include <linux/types.h>
#include <linux/io.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/of_device.h>
#include <sound/core.h>
@@ -29,7 +28,6 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/ac97_codec.h>
-#include <sound/atmel-ac97c.h>
#include <sound/memalloc.h>
#include "ac97c.h"
@@ -56,7 +54,7 @@ struct atmel_ac97c {
void __iomem *regs;
int irq;
int opened;
- int reset_pin;
+ struct gpio_desc *reset_pin;
};
#define get_chip(card) ((struct atmel_ac97c *)(card)->private_data)
@@ -700,11 +698,11 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
ac97c_writel(chip, CAMR, 0);
ac97c_writel(chip, COMR, 0);
- if (gpio_is_valid(chip->reset_pin)) {
- gpio_set_value(chip->reset_pin, 0);
+ if (!IS_ERR(chip->reset_pin)) {
+ gpiod_set_value(chip->reset_pin, 0);
/* AC97 v2.2 specifications says minimum 1 us. */
udelay(2);
- gpio_set_value(chip->reset_pin, 1);
+ gpiod_set_value(chip->reset_pin, 1);
} else {
ac97c_writel(chip, MR, AC97C_MR_WRST | AC97C_MR_ENA);
udelay(2);
@@ -712,45 +710,18 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
}
}
-#ifdef CONFIG_OF
static const struct of_device_id atmel_ac97c_dt_ids[] = {
{ .compatible = "atmel,at91sam9263-ac97c", },
{ }
};
MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids);
-static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev)
-{
- struct ac97c_platform_data *pdata;
- struct device_node *node = dev->of_node;
-
- if (!node) {
- dev_err(dev, "Device does not have associated DT data\n");
- return ERR_PTR(-EINVAL);
- }
-
- pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata)
- return ERR_PTR(-ENOMEM);
-
- pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2);
-
- return pdata;
-}
-#else
-static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev)
-{
- dev_err(dev, "no platform data defined\n");
- return ERR_PTR(-ENXIO);
-}
-#endif
-
static int atmel_ac97c_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct snd_card *card;
struct atmel_ac97c *chip;
struct resource *regs;
- struct ac97c_platform_data *pdata;
struct clk *pclk;
static struct snd_ac97_bus_ops ops = {
.write = atmel_ac97c_write,
@@ -765,13 +736,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
return -ENXIO;
}
- pdata = dev_get_platdata(&pdev->dev);
- if (!pdata) {
- pdata = atmel_ac97c_probe_dt(&pdev->dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- }
-
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
dev_dbg(&pdev->dev, "could not get irq: %d\n", irq);
@@ -821,17 +785,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
goto err_ioremap;
}
- if (gpio_is_valid(pdata->reset_pin)) {
- if (gpio_request(pdata->reset_pin, "reset_pin")) {
- dev_dbg(&pdev->dev, "reset pin not available\n");
- chip->reset_pin = -ENODEV;
- } else {
- gpio_direction_output(pdata->reset_pin, 1);
- chip->reset_pin = pdata->reset_pin;
- }
- } else {
- chip->reset_pin = -EINVAL;
- }
+ chip->reset_pin = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_OUT_HIGH);
+ if (IS_ERR(chip->reset_pin))
+ dev_dbg(dev, "reset pin not available\n");
atmel_ac97c_reset(chip);
@@ -871,9 +827,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
return 0;
err_ac97_bus:
- if (gpio_is_valid(chip->reset_pin))
- gpio_free(chip->reset_pin);
-
iounmap(chip->regs);
err_ioremap:
free_irq(irq, chip);
@@ -916,9 +869,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev)
struct snd_card *card = platform_get_drvdata(pdev);
struct atmel_ac97c *chip = get_chip(card);
- if (gpio_is_valid(chip->reset_pin))
- gpio_free(chip->reset_pin);
-
ac97c_writel(chip, CAMR, 0);
ac97c_writel(chip, COMR, 0);
ac97c_writel(chip, MR, 0);
@@ -939,7 +889,7 @@ static struct platform_driver atmel_ac97c_driver = {
.driver = {
.name = "atmel_ac97c",
.pm = ATMEL_AC97C_PM_OPS,
- .of_match_table = of_match_ptr(atmel_ac97c_dt_ids),
+ .of_match_table = atmel_ac97c_dt_ids,
},
};
module_platform_driver(atmel_ac97c_driver);
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal
2017-09-01 16:15 [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Andy Shevchenko
@ 2017-09-01 16:15 ` Andy Shevchenko
2017-09-04 9:58 ` Takashi Iwai
2017-09-02 10:58 ` [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Alexandre Belloni
2017-09-04 9:57 ` Takashi Iwai
2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2017-09-01 16:15 UTC (permalink / raw)
To: Nicolas Ferre, alsa-devel, Takashi Iwai, Jaroslav Kysela; +Cc: Andy Shevchenko
The ALSA related include header files are left overs after the commit
020c5260c2b1 ("ALSA: atmel: Remove AVR32 bits from the driver")
Fixes: 020c5260c2b1 ("ALSA: atmel: Remove AVR32 bits from the driver")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/sound/atmel-abdac.h | 23 -----------------------
include/sound/atmel-ac97c.h | 38 --------------------------------------
2 files changed, 61 deletions(-)
delete mode 100644 include/sound/atmel-abdac.h
delete mode 100644 include/sound/atmel-ac97c.h
diff --git a/include/sound/atmel-abdac.h b/include/sound/atmel-abdac.h
deleted file mode 100644
index a8f735d677fa..000000000000
--- a/include/sound/atmel-abdac.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Driver for the Atmel Audio Bitstream DAC (ABDAC)
- *
- * Copyright (C) 2009 Atmel Corporation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-#ifndef __INCLUDE_SOUND_ATMEL_ABDAC_H
-#define __INCLUDE_SOUND_ATMEL_ABDAC_H
-
-#include <linux/platform_data/dma-dw.h>
-
-/**
- * struct atmel_abdac_pdata - board specific ABDAC configuration
- * @dws: DMA slave interface to use for sound playback.
- */
-struct atmel_abdac_pdata {
- struct dw_dma_slave dws;
-};
-
-#endif /* __INCLUDE_SOUND_ATMEL_ABDAC_H */
diff --git a/include/sound/atmel-ac97c.h b/include/sound/atmel-ac97c.h
deleted file mode 100644
index f2a1cdc37661..000000000000
--- a/include/sound/atmel-ac97c.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Driver for the Atmel AC97C controller
- *
- * Copyright (C) 2005-2009 Atmel Corporation
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-#ifndef __INCLUDE_SOUND_ATMEL_AC97C_H
-#define __INCLUDE_SOUND_ATMEL_AC97C_H
-
-#include <linux/platform_data/dma-dw.h>
-
-#define AC97C_CAPTURE 0x01
-#define AC97C_PLAYBACK 0x02
-#define AC97C_BOTH (AC97C_CAPTURE | AC97C_PLAYBACK)
-
-/**
- * struct atmel_ac97c_pdata - board specific AC97C configuration
- * @rx_dws: DMA slave interface to use for sound capture.
- * @tx_dws: DMA slave interface to use for sound playback.
- * @reset_pin: GPIO pin wired to the reset input on the external AC97 codec,
- * optional to use, set to -ENODEV if not in use. AC97 layer will
- * try to do a software reset of the external codec anyway.
- *
- * If the user do not want to use a DMA channel for playback or capture, i.e.
- * only one feature is required on the board. The slave for playback or capture
- * can be set to NULL. The AC97C driver will take use of this when setting up
- * the sound streams.
- */
-struct ac97c_platform_data {
- struct dw_dma_slave rx_dws;
- struct dw_dma_slave tx_dws;
- int reset_pin;
-};
-
-#endif /* __INCLUDE_SOUND_ATMEL_AC97C_H */
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API
2017-09-01 16:15 [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Andy Shevchenko
2017-09-01 16:15 ` [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal Andy Shevchenko
@ 2017-09-02 10:58 ` Alexandre Belloni
2017-09-04 7:49 ` Andy Shevchenko
2017-09-04 9:57 ` Takashi Iwai
2 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2017-09-02 10:58 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: alsa-devel, Nicolas Ferre, Takashi Iwai
Hi Andy,
On which platform did you test your patches?
On 01/09/2017 at 19:15:06 +0300, Andy Shevchenko wrote:
> Convert the driver to use GPIO descriptor API.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> sound/atmel/ac97c.c | 70 ++++++++---------------------------------------------
> 1 file changed, 10 insertions(+), 60 deletions(-)
>
> diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
> index 5ffefac2fa8f..380025887aef 100644
> --- a/sound/atmel/ac97c.c
> +++ b/sound/atmel/ac97c.c
> @@ -12,16 +12,15 @@
> #include <linux/bitmap.h>
> #include <linux/device.h>
> #include <linux/atmel_pdc.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/init.h>
> #include <linux/interrupt.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> #include <linux/mutex.h>
> -#include <linux/gpio.h>
> #include <linux/types.h>
> #include <linux/io.h>
> #include <linux/of.h>
> -#include <linux/of_gpio.h>
> #include <linux/of_device.h>
>
> #include <sound/core.h>
> @@ -29,7 +28,6 @@
> #include <sound/pcm.h>
> #include <sound/pcm_params.h>
> #include <sound/ac97_codec.h>
> -#include <sound/atmel-ac97c.h>
> #include <sound/memalloc.h>
>
> #include "ac97c.h"
> @@ -56,7 +54,7 @@ struct atmel_ac97c {
> void __iomem *regs;
> int irq;
> int opened;
> - int reset_pin;
> + struct gpio_desc *reset_pin;
> };
>
> #define get_chip(card) ((struct atmel_ac97c *)(card)->private_data)
> @@ -700,11 +698,11 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
> ac97c_writel(chip, CAMR, 0);
> ac97c_writel(chip, COMR, 0);
>
> - if (gpio_is_valid(chip->reset_pin)) {
> - gpio_set_value(chip->reset_pin, 0);
> + if (!IS_ERR(chip->reset_pin)) {
> + gpiod_set_value(chip->reset_pin, 0);
> /* AC97 v2.2 specifications says minimum 1 us. */
> udelay(2);
> - gpio_set_value(chip->reset_pin, 1);
> + gpiod_set_value(chip->reset_pin, 1);
> } else {
> ac97c_writel(chip, MR, AC97C_MR_WRST | AC97C_MR_ENA);
> udelay(2);
> @@ -712,45 +710,18 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
> }
> }
>
> -#ifdef CONFIG_OF
> static const struct of_device_id atmel_ac97c_dt_ids[] = {
> { .compatible = "atmel,at91sam9263-ac97c", },
> { }
> };
> MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids);
>
> -static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev)
> -{
> - struct ac97c_platform_data *pdata;
> - struct device_node *node = dev->of_node;
> -
> - if (!node) {
> - dev_err(dev, "Device does not have associated DT data\n");
> - return ERR_PTR(-EINVAL);
> - }
> -
> - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> - if (!pdata)
> - return ERR_PTR(-ENOMEM);
> -
> - pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2);
> -
> - return pdata;
> -}
> -#else
> -static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev)
> -{
> - dev_err(dev, "no platform data defined\n");
> - return ERR_PTR(-ENXIO);
> -}
> -#endif
> -
> static int atmel_ac97c_probe(struct platform_device *pdev)
> {
> + struct device *dev = &pdev->dev;
> struct snd_card *card;
> struct atmel_ac97c *chip;
> struct resource *regs;
> - struct ac97c_platform_data *pdata;
> struct clk *pclk;
> static struct snd_ac97_bus_ops ops = {
> .write = atmel_ac97c_write,
> @@ -765,13 +736,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> return -ENXIO;
> }
>
> - pdata = dev_get_platdata(&pdev->dev);
> - if (!pdata) {
> - pdata = atmel_ac97c_probe_dt(&pdev->dev);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - }
> -
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> dev_dbg(&pdev->dev, "could not get irq: %d\n", irq);
> @@ -821,17 +785,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> goto err_ioremap;
> }
>
> - if (gpio_is_valid(pdata->reset_pin)) {
> - if (gpio_request(pdata->reset_pin, "reset_pin")) {
> - dev_dbg(&pdev->dev, "reset pin not available\n");
> - chip->reset_pin = -ENODEV;
> - } else {
> - gpio_direction_output(pdata->reset_pin, 1);
> - chip->reset_pin = pdata->reset_pin;
> - }
> - } else {
> - chip->reset_pin = -EINVAL;
> - }
> + chip->reset_pin = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_OUT_HIGH);
> + if (IS_ERR(chip->reset_pin))
> + dev_dbg(dev, "reset pin not available\n");
>
> atmel_ac97c_reset(chip);
>
> @@ -871,9 +827,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
> return 0;
>
> err_ac97_bus:
> - if (gpio_is_valid(chip->reset_pin))
> - gpio_free(chip->reset_pin);
> -
> iounmap(chip->regs);
> err_ioremap:
> free_irq(irq, chip);
> @@ -916,9 +869,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev)
> struct snd_card *card = platform_get_drvdata(pdev);
> struct atmel_ac97c *chip = get_chip(card);
>
> - if (gpio_is_valid(chip->reset_pin))
> - gpio_free(chip->reset_pin);
> -
> ac97c_writel(chip, CAMR, 0);
> ac97c_writel(chip, COMR, 0);
> ac97c_writel(chip, MR, 0);
> @@ -939,7 +889,7 @@ static struct platform_driver atmel_ac97c_driver = {
> .driver = {
> .name = "atmel_ac97c",
> .pm = ATMEL_AC97C_PM_OPS,
> - .of_match_table = of_match_ptr(atmel_ac97c_dt_ids),
> + .of_match_table = atmel_ac97c_dt_ids,
> },
> };
> module_platform_driver(atmel_ac97c_driver);
> --
> 2.14.1
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API
2017-09-02 10:58 ` [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Alexandre Belloni
@ 2017-09-04 7:49 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2017-09-04 7:49 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: alsa-devel, Nicolas Ferre, Takashi Iwai
On Sat, 2017-09-02 at 12:58 +0200, Alexandre Belloni wrote:
> Hi Andy,
>
> On which platform did you test your patches?
Since I have only AVR32 board and its gone, so the obvious answer is
none. Only compile-tested.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API
2017-09-01 16:15 [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Andy Shevchenko
2017-09-01 16:15 ` [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal Andy Shevchenko
2017-09-02 10:58 ` [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Alexandre Belloni
@ 2017-09-04 9:57 ` Takashi Iwai
2 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2017-09-04 9:57 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: alsa-devel, Nicolas Ferre
On Fri, 01 Sep 2017 18:15:06 +0200,
Andy Shevchenko wrote:
>
> Convert the driver to use GPIO descriptor API.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied, thanks.
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal
2017-09-01 16:15 ` [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal Andy Shevchenko
@ 2017-09-04 9:58 ` Takashi Iwai
0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2017-09-04 9:58 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: alsa-devel, Nicolas Ferre
On Fri, 01 Sep 2017 18:15:07 +0200,
Andy Shevchenko wrote:
>
> The ALSA related include header files are left overs after the commit
>
> 020c5260c2b1 ("ALSA: atmel: Remove AVR32 bits from the driver")
>
> Fixes: 020c5260c2b1 ("ALSA: atmel: Remove AVR32 bits from the driver")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied, thanks.
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-04 9:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 16:15 [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Andy Shevchenko
2017-09-01 16:15 ` [PATCH v2 2/2] ALSA: atmel: Remove leftovers of AVR32 removal Andy Shevchenko
2017-09-04 9:58 ` Takashi Iwai
2017-09-02 10:58 ` [PATCH v2 1/2] ALSA: atmel: convert AC97c driver to GPIO descriptor API Alexandre Belloni
2017-09-04 7:49 ` Andy Shevchenko
2017-09-04 9:57 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.