Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1725567 > unrolled thread

[PATCH v6 00/12] AC97 device/driver model revamp

Started byRobert Jarzmik <robert.jarzmik@free.fr>
First post2017-09-02 22:00 +0200
Last post2017-09-02 22:00 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v6 00/12] AC97 device/driver model revamp Robert Jarzmik <robert.jarzmik@free.fr> - 2017-09-02 22:00 +0200
    [PATCH v6 11/12] ASoC: wm9705: add ac97 new bus support Robert Jarzmik <robert.jarzmik@free.fr> - 2017-09-02 22:00 +0200
    [PATCH v6 04/12] ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic Robert Jarzmik <robert.jarzmik@free.fr> - 2017-09-02 22:00 +0200

#1725567 — [PATCH v6 00/12] AC97 device/driver model revamp

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-09-02 22:00 +0200
Subject[PATCH v6 00/12] AC97 device/driver model revamp
Message-ID<ulmKd-74M-5@gated-at.bofh.it>
Hi Lars, Mark, Charles, Lee,

This is a revision for Lee, only targetted at wm97xx-core changes suggested by
Lee. I hope I have every concern covered Lee, just le me know if it suits you.

For easier spotting, I included in [1] the diff from the last serie.

I kept Charles ack for patch 6/12 following Lee's review, if you don't agree
Charles, I'll remove it.

Cheers.

--
Robert

Robert Jarzmik (12):
  ALSA: ac97: split out the generic ac97 registers
  ALSA: ac97: add an ac97 bus
  ASoC: add new ac97 bus support
  ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic
  Input: wm97xx: split out touchscreen registering
  mfd: wm97xx-core: core support for wm97xx Codec
  Input: wm97xx: add new AC97 bus support
  ASoC: wm9713: add ac97 new bus support
  ASoC: wm9712: add ac97 new bus support
  ASoC: wm9705: add private structure
  ASoC: wm9705: add ac97 new bus support
  ASoC: pxa: switch to new ac97 bus support

 drivers/input/touchscreen/Kconfig       |   2 +-
 drivers/input/touchscreen/wm97xx-core.c | 252 ++++++++++-----
 drivers/mfd/Kconfig                     |  14 +
 drivers/mfd/Makefile                    |   1 +
 drivers/mfd/wm97xx-core.c               | 379 ++++++++++++++++++++++
 include/linux/mfd/wm97xx.h              |  25 ++
 include/sound/ac97/codec.h              | 118 +++++++
 include/sound/ac97/compat.h             |  20 ++
 include/sound/ac97/controller.h         |  85 +++++
 include/sound/ac97/regs.h               | 262 ++++++++++++++++
 include/sound/ac97_codec.h              | 239 +-------------
 include/sound/pxa2xx-lib.h              |  15 +-
 sound/Kconfig                           |   2 +
 sound/Makefile                          |   1 +
 sound/ac97/Kconfig                      |  19 ++
 sound/ac97/Makefile                     |   8 +
 sound/ac97/ac97_core.h                  |  16 +
 sound/ac97/bus.c                        | 539 ++++++++++++++++++++++++++++++++
 sound/ac97/codec.c                      |  15 +
 sound/ac97/snd_ac97_compat.c            | 108 +++++++
 sound/arm/Kconfig                       |   1 -
 sound/arm/pxa2xx-ac97-lib.c             |  37 ++-
 sound/arm/pxa2xx-ac97.c                 |  35 ++-
 sound/soc/codecs/Kconfig                |   9 +-
 sound/soc/codecs/wm9705.c               |  61 ++--
 sound/soc/codecs/wm9712.c               |  39 ++-
 sound/soc/codecs/wm9713.c               |  39 ++-
 sound/soc/pxa/Kconfig                   |   5 +-
 sound/soc/pxa/pxa2xx-ac97.c             |  46 ++-
 29 files changed, 1978 insertions(+), 414 deletions(-)
 create mode 100644 drivers/mfd/wm97xx-core.c
 create mode 100644 include/linux/mfd/wm97xx.h
 create mode 100644 include/sound/ac97/codec.h
 create mode 100644 include/sound/ac97/compat.h
 create mode 100644 include/sound/ac97/controller.h
 create mode 100644 include/sound/ac97/regs.h
 create mode 100644 sound/ac97/Kconfig
 create mode 100644 sound/ac97/Makefile
 create mode 100644 sound/ac97/ac97_core.h
 create mode 100644 sound/ac97/bus.c
 create mode 100644 sound/ac97/codec.c
 create mode 100644 sound/ac97/snd_ac97_compat.c

-- 
2.11.0

[1] Diff from the previous serie
---8>---
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 5ffe4f4dfa10..6d175698a49a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1635,7 +1635,6 @@ config MFD_WM97xx
 	select AC97_BUS_COMPAT
 	depends on AC97_BUS_NEW
 	help
-
 	  The WM9705, WM9712 and WM9713 is a highly integrated hi-fi CODEC
 	  designed for smartphone applications.  As well as audio functionality
 	  it has on board GPIO and a touchscreen functionality which is
diff --git a/drivers/mfd/wm97xx-core.c b/drivers/mfd/wm97xx-core.c
index 473bbf9510e5..66e477fffd43 100644
--- a/drivers/mfd/wm97xx-core.c
+++ b/drivers/mfd/wm97xx-core.c
@@ -1,7 +1,7 @@
 /*
  * Wolfson WM97xx -- Core device
  *
- * Copyright (C) 2016 Robert Jarzmik
+ * Copyright (C) 2017 Robert Jarzmik
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,14 +14,13 @@
  *  - a GPIO block
  */
 
-#include <linux/module.h>
-
 #include <linux/device.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/wm97xx.h>
-#include <linux/wm97xx.h>
+#include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/wm97xx.h>
 #include <sound/ac97/codec.h>
 #include <sound/ac97/compat.h>
 
@@ -34,6 +33,7 @@ struct wm97xx_priv {
 	struct regmap *regmap;
 	struct snd_ac97 *ac97;
 	struct device *dev;
+	struct wm97xx_platform_data codec_pdata;
 };
 
 static bool wm97xx_readable_reg(struct device *dev, unsigned int reg)
@@ -108,33 +108,14 @@ static const struct regmap_config wm9705_regmap_config = {
 	.writeable_reg = wm97xx_writeable_reg,
 };
 
-static int wm9705_register(struct wm97xx_priv *wm97xx,
-			   struct wm97xx_pdata *pdata)
-{
-	static struct wm97xx_platform_data codec_pdata;
-	static const struct mfd_cell cells[] = {
-		{
-			.name = "wm9705-codec",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-		{
-			.name = "wm97xx-ts",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-	};
-
-	codec_pdata.ac97 = wm97xx->ac97;
-	codec_pdata.regmap = devm_regmap_init_ac97(wm97xx->ac97,
-						   &wm9705_regmap_config);
-	codec_pdata.batt_pdata = pdata->batt_pdata;
-	if (IS_ERR(codec_pdata.regmap))
-		return PTR_ERR(codec_pdata.regmap);
-
-	return devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE, cells,
-				    ARRAY_SIZE(cells), NULL, 0, NULL);
-}
+static struct mfd_cell wm9705_cells[] = {
+	{
+		.name = "wm9705-codec",
+	},
+	{
+		.name = "wm97xx-ts",
+	},
+};
 
 static bool wm9712_volatile_reg(struct device *dev, unsigned int reg)
 {
@@ -199,33 +180,14 @@ static const struct regmap_config wm9712_regmap_config = {
 	.writeable_reg = wm97xx_writeable_reg,
 };
 
-static int wm9712_register(struct wm97xx_priv *wm97xx,
-			   struct wm97xx_pdata *pdata)
-{
-	static struct wm97xx_platform_data codec_pdata;
-	static const struct mfd_cell cells[] = {
-		{
-			.name = "wm9712-codec",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-		{
-			.name = "wm97xx-ts",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-	};
-
-	codec_pdata.ac97 = wm97xx->ac97;
-	codec_pdata.regmap = devm_regmap_init_ac97(wm97xx->ac97,
-						   &wm9712_regmap_config);
-	codec_pdata.batt_pdata = pdata->batt_pdata;
-	if (IS_ERR(codec_pdata.regmap))
-		return PTR_ERR(codec_pdata.regmap);
-
-	return devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE, cells,
-				    ARRAY_SIZE(cells), NULL, 0, NULL);
-}
+static struct mfd_cell wm9712_cells[] = {
+	{
+		.name = "wm9712-codec",
+	},
+	{
+		.name = "wm97xx-ts",
+	},
+};
 
 static const struct reg_default wm9713_reg_defaults[] = {
 	{ 0x02, 0x8080 },	/* Speaker Output Volume */
@@ -293,39 +255,23 @@ static const struct regmap_config wm9713_regmap_config = {
 	.writeable_reg = wm97xx_writeable_reg,
 };
 
-static int wm9713_register(struct wm97xx_priv *wm97xx,
-			   struct wm97xx_pdata *pdata)
-{
-	static struct wm97xx_platform_data codec_pdata;
-	static const struct mfd_cell cells[] = {
-		{
-			.name = "wm9713-codec",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-		{
-			.name = "wm97xx-ts",
-			.platform_data = &codec_pdata,
-			.pdata_size = sizeof(codec_pdata),
-		},
-	};
-
-	codec_pdata.ac97 = wm97xx->ac97;
-	codec_pdata.regmap = devm_regmap_init_ac97(wm97xx->ac97,
-						   &wm9713_regmap_config);
-	codec_pdata.batt_pdata = pdata->batt_pdata;
-	if (IS_ERR(codec_pdata.regmap))
-		return PTR_ERR(codec_pdata.regmap);
-
-	return devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE, cells,
-				    ARRAY_SIZE(cells), NULL, 0, NULL);
-}
+static struct mfd_cell wm9713_cells[] = {
+	{
+		.name = "wm9713-codec",
+	},
+	{
+		.name = "wm97xx-ts",
+	},
+};
 
 static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 {
 	struct wm97xx_priv *wm97xx;
-	int ret;
-	void *pdata = snd_ac97_codec_get_platdata(adev);
+	const struct regmap_config *config;
+	struct wm97xx_platform_data *codec_pdata;
+	struct mfd_cell *cells;
+	int ret = 0, nb_cells, i;
+	struct wm97xx_pdata *pdata = snd_ac97_codec_get_platdata(adev);
 
 	wm97xx = devm_kzalloc(ac97_codec_dev2dev(adev),
 			      sizeof(*wm97xx), GFP_KERNEL);
@@ -342,20 +288,48 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 	dev_info(wm97xx->dev, "wm97xx core found, id=0x%x\n",
 		 adev->vendor_id);
 
+	codec_pdata = &wm97xx->codec_pdata;
+	codec_pdata->ac97 = wm97xx->ac97;
+	codec_pdata->batt_pdata = pdata->batt_pdata;
+
 	switch (adev->vendor_id) {
 	case WM9705_VENDOR_ID:
-		ret = wm9705_register(wm97xx, pdata);
+		config = &wm9705_regmap_config;
+		cells = wm9705_cells;
+		nb_cells = ARRAY_SIZE(wm9705_cells);
 		break;
 	case WM9712_VENDOR_ID:
-		ret = wm9712_register(wm97xx, pdata);
+		config = &wm9712_regmap_config;
+		cells = wm9712_cells;
+		nb_cells = ARRAY_SIZE(wm9712_cells);
 		break;
 	case WM9713_VENDOR_ID:
-		ret = wm9713_register(wm97xx, pdata);
+		config = &wm9713_regmap_config;
+		cells = wm9713_cells;
+		nb_cells = ARRAY_SIZE(wm9713_cells);
 		break;
 	default:
+		config = NULL;
+	}
+
+	for (i = 0; i < nb_cells; i++) {
+		cells[i].platform_data = codec_pdata;
+		cells[i].pdata_size = sizeof(*codec_pdata);
+	}
+
+	if (config) {
+		codec_pdata->regmap =
+			devm_regmap_init_ac97(wm97xx->ac97, config);
+		if (IS_ERR(codec_pdata->regmap))
+			ret = PTR_ERR(codec_pdata->regmap);
+	} else {
 		ret = -ENODEV;
 	}
 
+	if (!ret)
+		ret = devm_mfd_add_devices(wm97xx->dev, PLATFORM_DEVID_NONE,
+					   cells, nb_cells, NULL, 0, NULL);
+
 	if (ret)
 		snd_ac97_compat_release(wm97xx->ac97);
 
diff --git a/include/linux/mfd/wm97xx.h b/include/linux/mfd/wm97xx.h
index 627322f14d48..45fb54f19d09 100644
--- a/include/linux/mfd/wm97xx.h
+++ b/include/linux/mfd/wm97xx.h
@@ -1,17 +1,12 @@
 /*
  * wm97xx client interface
  *
- * Copyright (C) 2016 Robert Jarzmik
+ * Copyright (C) 2017 Robert Jarzmik
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #ifndef __LINUX_MFD_WM97XX_H
@@ -27,5 +22,4 @@ struct wm97xx_platform_data {
 	struct wm97xx_batt_pdata *batt_pdata;
 };
 
-
 #endif

[toc] | [next] | [standalone]


#1725568 — [PATCH v6 11/12] ASoC: wm9705: add ac97 new bus support

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-09-02 22:00 +0200
Subject[PATCH v6 11/12] ASoC: wm9705: add ac97 new bus support
Message-ID<ulmKe-74M-39@gated-at.bofh.it>
In reply to#1725567
Add support for the new ac97 bus model, where devices are automatically
discovered on AC-Links.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Since v4:
 - added #ifdef spotted by Charles
 - tentatively kept Charles's ack
---
 sound/soc/codecs/Kconfig  |  3 ++-
 sound/soc/codecs/wm9705.c | 37 +++++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index f17af3592785..1d69a1c1f896 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -205,7 +205,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_WM8998 if MFD_WM8998
 	select SND_SOC_WM9081 if I2C
 	select SND_SOC_WM9090 if I2C
-	select SND_SOC_WM9705 if SND_SOC_AC97_BUS
+	select SND_SOC_WM9705 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
 	select SND_SOC_WM9712 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
 	select SND_SOC_WM9713 if (SND_SOC_AC97_BUS || SND_SOC_AC97_BUS_NEW)
         help
@@ -1083,6 +1083,7 @@ config SND_SOC_WM9090
 config SND_SOC_WM9705
 	tristate
 	select REGMAP_AC97
+	select AC97_BUS_COMPAT if AC97_BUS_NEW
 
 config SND_SOC_WM9712
 	tristate
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c
index 08477d040028..46b5a77c53e4 100644
--- a/sound/soc/codecs/wm9705.c
+++ b/sound/soc/codecs/wm9705.c
@@ -11,6 +11,7 @@
 
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/mfd/wm97xx.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -18,6 +19,8 @@
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
+#include <sound/ac97/codec.h>
+#include <sound/ac97/compat.h>
 #include <sound/initval.h>
 #include <sound/soc.h>
 
@@ -26,6 +29,7 @@
 
 struct wm9705_priv {
 	struct snd_ac97 *ac97;
+	struct wm97xx_platform_data *mfd_pdata;
 };
 
 static const struct reg_default wm9705_reg_defaults[] = {
@@ -319,17 +323,24 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
 	struct regmap *regmap;
 	int ret;
 
-	wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
-					      WM9705_VENDOR_ID_MASK);
-	if (IS_ERR(wm9705->ac97)) {
-		dev_err(codec->dev, "Failed to register AC97 codec\n");
-		return PTR_ERR(wm9705->ac97);
-	}
-
-	regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
-	if (IS_ERR(regmap)) {
-		ret = PTR_ERR(regmap);
-		goto err_free_ac97_codec;
+	if (wm9705->mfd_pdata) {
+		wm9705->ac97 = wm9705->mfd_pdata->ac97;
+		regmap = wm9705->mfd_pdata->regmap;
+	} else {
+#ifdef CONFIG_SND_SOC_AC97_BUS
+		wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID,
+						      WM9705_VENDOR_ID_MASK);
+		if (IS_ERR(wm9705->ac97)) {
+			dev_err(codec->dev, "Failed to register AC97 codec\n");
+			return PTR_ERR(wm9705->ac97);
+		}
+
+		regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config);
+		if (IS_ERR(regmap)) {
+			ret = PTR_ERR(regmap);
+			goto err_free_ac97_codec;
+		}
+#endif
 	}
 
 	snd_soc_codec_set_drvdata(codec, wm9705->ac97);
@@ -346,7 +357,8 @@ static int wm9705_soc_remove(struct snd_soc_codec *codec)
 	struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec);
 
 	snd_soc_codec_exit_regmap(codec);
-	snd_soc_free_ac97_codec(wm9705->ac97);
+	if (!wm9705->mfd_pdata)
+		snd_soc_free_ac97_codec(wm9705->ac97);
 	return 0;
 }
 
@@ -374,6 +386,7 @@ static int wm9705_probe(struct platform_device *pdev)
 	if (wm9705 == NULL)
 		return -ENOMEM;
 
+	wm9705->mfd_pdata = dev_get_platdata(&pdev->dev);
 	platform_set_drvdata(pdev, wm9705);
 
 	return snd_soc_register_codec(&pdev->dev,
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1725569 — [PATCH v6 04/12] ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic

FromRobert Jarzmik <robert.jarzmik@free.fr>
Date2017-09-02 22:00 +0200
Subject[PATCH v6 04/12] ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic
Message-ID<ulmKf-74M-41@gated-at.bofh.it>
In reply to#1725567
All pxa library functions don't use the input parameters for nothing but
slot number. This simplifies their prototypes, and makes them usable by
both the legacy ac97 bus and the new ac97 bus.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 include/sound/pxa2xx-lib.h  | 15 +++++++++------
 sound/arm/pxa2xx-ac97-lib.c | 37 +++++++++++++++++++++----------------
 sound/arm/pxa2xx-ac97.c     | 35 +++++++++++++++++++++++++++--------
 sound/soc/pxa/pxa2xx-ac97.c | 32 ++++++++++++++++++++++++++------
 4 files changed, 83 insertions(+), 36 deletions(-)

diff --git a/include/sound/pxa2xx-lib.h b/include/sound/pxa2xx-lib.h
index 6ef629bde164..85352becec7c 100644
--- a/include/sound/pxa2xx-lib.h
+++ b/include/sound/pxa2xx-lib.h
@@ -1,10 +1,13 @@
 #ifndef PXA2XX_LIB_H
 #define PXA2XX_LIB_H
 
+#include <uapi/sound/asound.h>
 #include <linux/platform_device.h>
-#include <sound/ac97_codec.h>
 
 /* PCM */
+struct snd_pcm_substream;
+struct snd_pcm_hw_params;
+struct snd_pcm;
 
 extern int __pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params);
@@ -21,12 +24,12 @@ extern void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm);
 
 /* AC97 */
 
-extern unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg);
-extern void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val);
+extern int pxa2xx_ac97_read(int slot, unsigned short reg);
+extern int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val);
 
-extern bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97);
-extern bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97);
-extern void pxa2xx_ac97_finish_reset(struct snd_ac97 *ac97);
+extern bool pxa2xx_ac97_try_warm_reset(void);
+extern bool pxa2xx_ac97_try_cold_reset(void);
+extern void pxa2xx_ac97_finish_reset(void);
 
 extern int pxa2xx_ac97_hw_suspend(void);
 extern int pxa2xx_ac97_hw_resume(void);
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
index 39c3969ac1c7..5950a9e218d9 100644
--- a/sound/arm/pxa2xx-ac97-lib.c
+++ b/sound/arm/pxa2xx-ac97-lib.c
@@ -20,7 +20,6 @@
 #include <linux/io.h>
 #include <linux/gpio.h>
 
-#include <sound/ac97_codec.h>
 #include <sound/pxa2xx-lib.h>
 
 #include <mach/irqs.h>
@@ -46,38 +45,41 @@ extern void pxa27x_configure_ac97reset(int reset_gpio, bool to_gpio);
  * 1 jiffy timeout if interrupt never comes).
  */
 
-unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
+int pxa2xx_ac97_read(int slot, unsigned short reg)
 {
-	unsigned short val = -1;
+	int val = -ENODEV;
 	volatile u32 *reg_addr;
 
+	if (slot > 0)
+		return -ENODEV;
+
 	mutex_lock(&car_mutex);
 
 	/* set up primary or secondary codec space */
 	if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
-		reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+		reg_addr = slot ? &SMC_REG_BASE : &PMC_REG_BASE;
 	else
-		reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+		reg_addr = slot ? &SAC_REG_BASE : &PAC_REG_BASE;
 	reg_addr += (reg >> 1);
 
 	/* start read access across the ac97 link */
 	GSR = GSR_CDONE | GSR_SDONE;
 	gsr_bits = 0;
-	val = *reg_addr;
+	val = (*reg_addr & 0xffff);
 	if (reg == AC97_GPIO_STATUS)
 		goto out;
 	if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 &&
 	    !((GSR | gsr_bits) & GSR_SDONE)) {
 		printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n",
 				__func__, reg, GSR | gsr_bits);
-		val = -1;
+		val = -ETIMEDOUT;
 		goto out;
 	}
 
 	/* valid data now */
 	GSR = GSR_CDONE | GSR_SDONE;
 	gsr_bits = 0;
-	val = *reg_addr;
+	val = (*reg_addr & 0xffff);
 	/* but we've just started another cycle... */
 	wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
 
@@ -86,29 +88,32 @@ out:	mutex_unlock(&car_mutex);
 }
 EXPORT_SYMBOL_GPL(pxa2xx_ac97_read);
 
-void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
-			unsigned short val)
+int pxa2xx_ac97_write(int slot, unsigned short reg, unsigned short val)
 {
 	volatile u32 *reg_addr;
+	int ret = 0;
 
 	mutex_lock(&car_mutex);
 
 	/* set up primary or secondary codec space */
 	if (cpu_is_pxa25x() && reg == AC97_GPIO_STATUS)
-		reg_addr = ac97->num ? &SMC_REG_BASE : &PMC_REG_BASE;
+		reg_addr = slot ? &SMC_REG_BASE : &PMC_REG_BASE;
 	else
-		reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
+		reg_addr = slot ? &SAC_REG_BASE : &PAC_REG_BASE;
 	reg_addr += (reg >> 1);
 
 	GSR = GSR_CDONE | GSR_SDONE;
 	gsr_bits = 0;
 	*reg_addr = val;
 	if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 &&
-	    !((GSR | gsr_bits) & GSR_CDONE))
+	    !((GSR | gsr_bits) & GSR_CDONE)) {
 		printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n",
 				__func__, reg, GSR | gsr_bits);
+		ret = -EIO;
+	}
 
 	mutex_unlock(&car_mutex);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(pxa2xx_ac97_write);
 
@@ -188,7 +193,7 @@ static inline void pxa_ac97_cold_pxa3xx(void)
 }
 #endif
 
-bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
+bool pxa2xx_ac97_try_warm_reset(void)
 {
 	unsigned long gsr;
 	unsigned int timeout = 100;
@@ -225,7 +230,7 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97)
 }
 EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset);
 
-bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
+bool pxa2xx_ac97_try_cold_reset(void)
 {
 	unsigned long gsr;
 	unsigned int timeout = 1000;
@@ -263,7 +268,7 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97)
 EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_cold_reset);
 
 
-void pxa2xx_ac97_finish_reset(struct snd_ac97 *ac97)
+void pxa2xx_ac97_finish_reset(void)
 {
 	GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
 	GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index fbd5dad0c484..4bc244c40f80 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -29,19 +29,38 @@
 
 #include "pxa2xx-pcm.h"
 
-static void pxa2xx_ac97_reset(struct snd_ac97 *ac97)
+static void pxa2xx_ac97_legacy_reset(struct snd_ac97 *ac97)
 {
-	if (!pxa2xx_ac97_try_cold_reset(ac97)) {
-		pxa2xx_ac97_try_warm_reset(ac97);
-	}
+	if (!pxa2xx_ac97_try_cold_reset())
+		pxa2xx_ac97_try_warm_reset();
+
+	pxa2xx_ac97_finish_reset();
+}
+
+static unsigned short pxa2xx_ac97_legacy_read(struct snd_ac97 *ac97,
+					      unsigned short reg)
+{
+	int ret;
+
+	ret = pxa2xx_ac97_read(ac97->num, reg);
+	if (ret < 0)
+		return 0;
+	else
+		return (unsigned short)(ret & 0xffff);
+}
+
+static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97,
+				     unsigned short reg, unsigned short val)
+{
+	int __always_unused ret;
 
-	pxa2xx_ac97_finish_reset(ac97);
+	ret = pxa2xx_ac97_write(ac97->num, reg, val);
 }
 
 static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
-	.read	= pxa2xx_ac97_read,
-	.write	= pxa2xx_ac97_write,
-	.reset	= pxa2xx_ac97_reset,
+	.read	= pxa2xx_ac97_legacy_read,
+	.write	= pxa2xx_ac97_legacy_write,
+	.reset	= pxa2xx_ac97_legacy_reset,
 };
 
 static struct pxad_param pxa2xx_ac97_pcm_out_req = {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 2e2fb1838ec2..b07d64ef49ba 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -29,21 +29,41 @@
 
 static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
 {
-	pxa2xx_ac97_try_warm_reset(ac97);
+	pxa2xx_ac97_try_warm_reset();
 
-	pxa2xx_ac97_finish_reset(ac97);
+	pxa2xx_ac97_finish_reset();
 }
 
 static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
 {
-	pxa2xx_ac97_try_cold_reset(ac97);
+	pxa2xx_ac97_try_cold_reset();
 
-	pxa2xx_ac97_finish_reset(ac97);
+	pxa2xx_ac97_finish_reset();
+}
+
+static unsigned short pxa2xx_ac97_legacy_read(struct snd_ac97 *ac97,
+					      unsigned short reg)
+{
+	int ret;
+
+	ret = pxa2xx_ac97_read(ac97->num, reg);
+	if (ret < 0)
+		return 0;
+	else
+		return (unsigned short)(ret & 0xffff);
+}
+
+static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97,
+				     unsigned short reg, unsigned short val)
+{
+	int ret;
+
+	ret = pxa2xx_ac97_write(ac97->num, reg, val);
 }
 
 static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
-	.read	= pxa2xx_ac97_read,
-	.write	= pxa2xx_ac97_write,
+	.read	= pxa2xx_ac97_legacy_read,
+	.write	= pxa2xx_ac97_legacy_write,
 	.warm_reset	= pxa2xx_ac97_warm_reset,
 	.reset	= pxa2xx_ac97_cold_reset,
 };
-- 
2.11.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web