Skip to contentSkip to conversation

ASoC: WM8903: Add wm8903_set_gpio

PATCH Superseded Mark Brown 5 participants 45 messages Jan 19, 2011 – Jan 26, 2011 3 messages not in the archive

Subsystems (6)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mark Brown

author
#2 lore raw
Quoted 1 line · Stephen Warren

From: Stephen Warren <[email protected]>

This should be implemented using gpiolib - see WM8962 for an example of this. That way the control can be plugged into more other subsystems in the kernel (probably including whenever I or someone else gets around to it a widget like the one you open code in a later patch). I know some of the drivers do export the GPIOs using custom APIs but that's something that should be fixed.

Quoted 2 lines

Also, fix platform_data handling to have an explicit "don't touch this pin" option.

This should've been a separate patch since it's OK to go in as-is.

Quoted 1 line

Temporarily hack out the mic detection platform_data handling for simplicity

There's no patch restoring the functionality...

Quoted 1 line

tesing the GPIO changes. Should the write-sequencer enabling be conditional?

Yes. It's not actually enabling the write sequencer itself, it's enabling a low rate clock that's shared between a number of functions in the device including jack detection. Without the clock jack detection will not function.

author
#3 lore raw

Re: [PATCH 0/3] Tegra: Add internal speaker support

In reply to a message not in the archive
Quoted 6 lines · Stephen Warren

a) Is this the right way to expose GPIO APIs from a codec? The tlv320aic3 seems to do it this way, but wm8962.c uses the generic GPIO API. I shied away from the latter, since I wasn't sure how to name the WM8903's GPIOs in the gpio_* calls. I suppose it'd need a bunch of GPIO driver platform data to hook it all together and name GPIOs from a mach-tegra/include header file, but if this is the way to go, I need to read up on that more.

What naming is required for the GPIOs? GPIOs are referred to by number in Linux.

Quoted 5 lines

b) Is the WM8903 platform_data handling full fleshed out; simply by having platform_data, WM8903_WSEQ_ENA is set, whereas without any pdata, it isn't. Should this be conditional, or should I always have specified some platform data for Tegra, and I'm just getting lucky that it works without any?

Ah, your comment about the sequencer is clearer now. This is not enabling the write sequencer, that'll be done transiently when required if it's not set here. It's enabling a clock which is used by several parts of the chip including the write sequencer all the time so that the mic detection can function in the absence of any other software managing it. This is why it's conditional on microphone detection being configured, other functions can have this clock disabled most of the time.

#4 lore raw

Re: [PATCH 0/3] Tegra: Add internal speaker support

Quoted 11 lines · Mark Brown
Quoted 6 lines · Stephen Warren

a) Is this the right way to expose GPIO APIs from a codec? The tlv320aic3 seems to do it this way, but wm8962.c uses the generic GPIO API. I shied away from the latter, since I wasn't sure how to name the WM8903's GPIOs in the gpio_* calls. I suppose it'd need a bunch of GPIO driver platform data to hook it all together and name GPIOs from a mach-tegra/include header file, but if this is the way to go, I need to read up on that more.

What naming is required for the GPIOs? GPIOs are referred to by number in Linux.

Naming/numbering mean the same thing to me; I have to pass a number to gpio_request/gpio_set_value, either by hard-coded number or name (i.e. #define referring to some number).

I'll go read up on gpiolib some more to see how those API-level numbers get mapped to a specific controller and GPIO number.

Signature · 1 line
nvpublic

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#6 lore raw

Re: [PATCH 0/3] Tegra: Add internal speaker support

Quoted 8 lines · Colin Cross
Quoted 2 lines · Stephen Warren

I'll go read up on gpiolib some more to see how those API-level numbers get mapped to a specific controller and GPIO number.

They usually come in through platform data from the board file. See Olof's recent Tegra sdhci patches for an example. Tegra GPIO names are defined in arch/arm/mach-tegra/gpio-names.h.

Yup, and gpiolib also supports automatic assignment of numbers if you specify -1 as the base number though that's a lot less useful within the kernel.

Acked-by
#7 lore raw

Re: [PATCH 0/3] Tegra: Add internal speaker support

In reply to a message not in the archive
Quoted 14 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Harmony has headers on the board for an internal speaker and internal mic. I've started looking at enabling these, along with full jack detection etc. This first set of patches is an RFC (Request For Comments) on whether it's the correct direction, particularly with respect to:

a) Is this the right way to expose GPIO APIs from a codec? The tlv320aic3 seems to do it this way, but wm8962.c uses the generic GPIO API. I shied away from the latter, since I wasn't sure how to name the WM8903's GPIOs in the gpio_* calls. I suppose it'd need a bunch of GPIO driver platform data to hook it all together and name GPIOs from a mach-tegra/include header file, but if this is the way to go, I need to read up on that more.

Quoted 8 lines

b) Is the WM8903 platform_data handling full fleshed out; simply by having platform_data, WM8903_WSEQ_ENA is set, whereas without any pdata, it isn't. Should this be conditional, or should I always have specified some platform data for Tegra, and I'm just getting lucky that it works without any?

Thanks for any coments.

2 & 3 look fine and

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#8 lore raw

v2 cover Tegra: Harmony: Add internal speaker support

In reply to a message not in the archive

Harmony has headers on the board for an internal speaker and internal mic. This patch series adds various infra-structure, and enables usage of the internal speaker.

The patch series includes both changes to code within the ASoC subsystem and Tegra subsystem, the latter provided only for context when reading the ASoC changes. Would you prefer I separated these so that the ASoC maintainers can grab a whole series and apply it, rather than just a subset of the patches?

While patch 2 is physically located in the Tegra subsystem, I'd consider it part of the ASoC driver. Can such a change be checked into the ASoC tree? This new header file will be required to build to ASoC driver once the following patches are in. I was considering placing this in include/sound, following the example of various codecs, but it doesn't seem a good idea to pollute that directory with platform-specific files. The current location for the file follows the example of s3c24xx/simtec. Perhaps it should be in sound/soc/tegra?

Stephen Warren (4):
ASoC: WM8903: Expose GPIOs through gpiolib
ARM: tegra: Add Harmony sound platform data type
ARM: tegra: Platform data fixes for ASoC driver updates
ASoC: tegra: Harmony: Support the internal speaker

 arch/arm/mach-tegra/board-harmony.c              |   31 ++++++
 arch/arm/mach-tegra/gpio-names.h                 |    2 +
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 ++++
 include/sound/wm8903.h                           |    7 +-
 sound/soc/codecs/wm8903.c                        |  117 +++++++++++++++++++++-
 sound/soc/tegra/harmony.c                        |   89 ++++++++++++++--
 6 files changed, 251 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h
#9 lore raw

PATCH v2 1/4 ASoC: WM8903: Expose GPIOs through gpiolib

Also, fix platform_data GPIO handling to have an explicit "don't touch this pin" option.

---
 include/sound/wm8903.h    |    7 ++-
 sound/soc/codecs/wm8903.c |  117 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 121 insertions(+), 3 deletions(-)
include/sound/wm8903.h +5 -2
index b4a0db2..c835f2c 100644
@@ -12,7 +12,7 @@
 #define __LINUX_SND_WM8903_H
 
 /* Used to enable configuration of a GPIO to all zeros */
-#define WM8903_GPIO_NO_CONFIG 0x8000
+#define WM8903_GPIO_NO_CONFIG 0x10000
 
 /*
  * R6 (0x06) - Mic Bias Control 0
@@ -231,6 +231,8 @@
 #define WM8903_GP5_DB_SHIFT                          0  /* GP5_DB */
 #define WM8903_GP5_DB_WIDTH                          1  /* GP5_DB */
 
+#define WM8903_NUM_GPIO 5
+
 struct wm8903_platform_data {
 	bool irq_active_low;   /* Set if IRQ active low, default high */
 
@@ -243,7 +245,8 @@ struct wm8903_platform_data {
 
 	int micdet_delay;      /* Delay after microphone detection (ms) */
 
-	u32 gpio_cfg[5];       /* Default register values for GPIO pin mux */
+	int gpio_base;
+	u32 gpio_cfg[WM8903_NUM_GPIO]; /* Default register values for GPIO pin mux */
 };
 
 #endif
sound/soc/codecs/wm8903.c +116 -1

171 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#10 lore raw

Re: [PATCH v2 1/4] ASoC: WM8903: Expose GPIOs through gpiolib

On Wed, Jan 19, 2011 at 01:50:02PM -0700, Stephen Warren wrote:

This looks good, one query and one minor omission though.

include/sound/wm8903.h line 15

Quoted 3 lines

/* Used to enable configuration of a GPIO to all zeros */

include/sound/wm8903.h +1 -1
-#define WM8903_GPIO_NO_CONFIG 0x8000
+#define WM8903_GPIO_NO_CONFIG 0x10000

Why this change? The top bit in the registers is never actually used, really they're all 15 bit.

Quoted 9 lines
sound/soc/codecs/wm8903.c +8 -0
+static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
+{
+	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
+	struct snd_soc_codec *codec = wm8903->codec;
+
+	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
+				   WM8903_GP1_DIR_MASK, WM8903_GP1_DIR);
+}
 

sound/soc/codecs/wm8903.c static int wm8903_resume(struct snd_soc_codec *codec) · line 1688

Quoted 10 lines
sound/soc/codecs/wm8903.c +10 -0
+static int wm8903_gpio_direction_out(struct gpio_chip *chip,
+				     unsigned offset, int value)
+{
+	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
+	struct snd_soc_codec *codec = wm8903->codec;
+
+	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
+				   WM8903_GP1_DIR_MASK | WM8903_GP1_LVL_MASK,
+				   value << WM8903_GP2_LVL_SHIFT);
+}

These should also set GPn_FN - to zero for GPIO output, 3 for GPIO input. Otherwise changing between input and output mode at runtime won't do the right thing. As a side effect of that you probably wouldn't need to specify the GPIO configuration in platform data.

#11 lore raw

Re: [PATCH v2 1/4] ASoC: WM8903: Expose GPIOs through gpiolib

Mark Brown wrote on Thursday, January 20, 2011 4:53 AM:

Quoted 11 lines · Stephen Warren

This looks good, one query and one minor omission though.

include/sound/wm8903.h line 15

Quoted 3 lines

/* Used to enable configuration of a GPIO to all zeros */

include/sound/wm8903.h +1 -1
-#define WM8903_GPIO_NO_CONFIG 0x8000
+#define WM8903_GPIO_NO_CONFIG 0x10000

Why this change? The top bit in the registers is never actually used, really they're all 15 bit.

Some other registers appear to have bit 15 defined, so I made sure this flag was completely outside any valid register bits.

Although mainly, I just made it consistent with wm8962.h, which I assume picked that value for the same reason.

That said, the original value was OK for the GPIO registers, so I can revert that if you want.

Quoted 9 lines
Quoted 8 lines
sound/soc/codecs/wm8903.c +8 -0
+static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
+{
+	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
+	struct snd_soc_codec *codec = wm8903->codec;
+
+	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
+				   WM8903_GP1_DIR_MASK, WM8903_GP1_DIR);
+}
Quoted 15 lines

sound/soc/codecs/wm8903.c static int wm8903_resume(struct snd_soc_codec *codec) · line 1688

Quoted 10 lines
sound/soc/codecs/wm8903.c +10 -0
+static int wm8903_gpio_direction_out(struct gpio_chip *chip,
+				     unsigned offset, int value)
+{
+	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
+	struct snd_soc_codec *codec = wm8903->codec;
+
+	return snd_soc_update_bits(codec, WM8903_GPIO_CONTROL_1 + offset,
+				   WM8903_GP1_DIR_MASK | WM8903_GP1_LVL_MASK,
+				   value << WM8903_GP2_LVL_SHIFT);
+}

These should also set GPn_FN - to zero for GPIO output, 3 for GPIO input. Otherwise changing between input and output mode at runtime won't do the right thing. As a side effect of that you probably wouldn't need to specify the GPIO configuration in platform data.

Ooops. I didn't notice that. How does this interact with bit 7; GPn_DIR? I assume both need to be set appropriately since they're both defined bits.

Signature · 1 line
nvpublic
author
#12 lore raw

Re: [PATCH v2 1/4] ASoC: WM8903: Expose GPIOs through gpiolib

Quoted 2 lines · Stephen Warren

Although mainly, I just made it consistent with wm8962.h, which I assume picked that value for the same reason.

8962 has a very different register map as it has compatiblity with some very old devices.

Quoted 2 lines

That said, the original value was OK for the GPIO registers, so I can revert that if you want.

It did stick out as a bit random.

Quoted 7 lines
Quoted 4 lines

These should also set GPn_FN - to zero for GPIO output, 3 for GPIO input. Otherwise changing between input and output mode at runtime won't do the right thing. As a side effect of that you probably wouldn't need to specify the GPIO configuration in platform data.

Ooops. I didn't notice that. How does this interact with bit 7; GPn_DIR? I assume both need to be set appropriately since they're both defined bits.

Yes, one controls the function and the other controls the pad mode.

#13 lore raw

PATCH v2 2/4 ARM: tegra: Add Harmony sound platform data type

In reply to Stephen Warren
---
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h
arch/arm/mach-tegra/include/mach/harmony_audio.h new file +19 -0
new file mode 100644
index 0000000..5c46391
@@ -0,0 +1,19 @@
+/*
+ * arch/arm/mach-tegra/include/mach/harmony_audio.h
+ *
+ * Copyright 2011 NVIDIA, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+struct harmony_audio_platform_data {
+	int gpio_spkr_en;
+};
Signature · 1 line
1.7.1
#14 lore raw

PATCH v2 3/4 ARM: tegra: Platform data fixes for ASoC driver updates

In reply to Stephen Warren

The WM8903 driver now needs platform data in order to correctly expose its GPIOs through gpiolib.

The top-level ASoC driver now needs a platform device in order to provide infra-structure to pass in platform data.

The top-level ASoC driver now needs platform data in order to be informed which GPIO IDs to use.

This is all needed to allow the top-level ASoC driver to configure the WM8903's GPIO3 as an output GPIO, and enable it as appropriate. This is the enable signal for the external speaker amplifier chips.

---
 arch/arm/mach-tegra/board-harmony.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/gpio-names.h    |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/board-harmony.c +31 -0
index 2696a20..c5a4ae0 100644
@@ -2,6 +2,7 @@
  * arch/arm/mach-tegra/board-harmony.c
  *
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (C) 2011 NVIDIA, Inc.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -24,12 +25,15 @@
 #include <linux/i2c.h>
 #include <linux/io.h>
 
+#include <sound/wm8903.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include <asm/setup.h>
 
 #include <mach/gpio.h>
+#include <mach/harmony_audio.h>
 #include <mach/i2c.h>
 #include <mach/iomap.h>
 #include <mach/irqs.h>
@@ -53,6 +57,8 @@
 #define ATAG_NVIDIA_PRESERVED_MEM_N	2
 #define ATAG_NVIDIA_FORCE_32		0x7fffffff
 
+#define GPIO_WM8903(_x_) (TEGRA_MAX_GPIO + 1 + (_x_))
+
 struct tag_tegra {
 	__u32 bootarg_key;
 	__u32 bootarg_len;
@@ -112,9 +118,33 @@ static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
 	.bus_clk_rate	= { 400000, 0 },
 };
 
+static struct wm8903_platform_data harmony_wm8903_pdata = {
+	.gpio_base = GPIO_WM8903(0),
+	.gpio_cfg = {
+		WM8903_GPIO_NO_CONFIG,
+		WM8903_GPIO_NO_CONFIG,
+		0,
+		WM8903_GPIO_NO_CONFIG,
+		WM8903_GPIO_NO_CONFIG,
+	},
+};
+
 static struct i2c_board_info __initdata harmony_i2c_bus1_board_info[] = {
 	{
 		I2C_BOARD_INFO("wm8903", 0x1a),
+		.platform_data = &harmony_wm8903_pdata,
+	},
+};
+
+static struct harmony_audio_platform_data harmony_audio_pdata = {
+	.gpio_spkr_en = GPIO_WM8903(2),
+};
+
+static struct platform_device harmony_audio_device = {
+	.name   = "tegra-snd-harmony",
+	.id     = 0,
+	.dev    = {
+		.platform_data  = &harmony_audio_pdata,
 	},
 };
 
@@ -127,6 +157,7 @@ static struct platform_device *harmony_devices[] __initdata = {
 	&tegra_i2s_device1,
 	&tegra_das_device,
 	&tegra_pcm_device,
+	&harmony_audio_device,
 };
 
 static void __init tegra_harmony_fixup(struct machine_desc *desc,
arch/arm/mach-tegra/gpio-names.h +2 -0
index f28220a..e8b5cf3 100644
@@ -244,4 +244,6 @@
 #define TEGRA_GPIO_PBB6		222
 #define TEGRA_GPIO_PBB7		223
 
+#define TEGRA_MAX_GPIO		TEGRA_GPIO_PBB7
+
 #endif
Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 4/4 ASoC: tegra: Harmony: Support the internal speaker

In reply to Stephen Warren

Add DAPM widget definitions, and code to control the speaker amplifier GPIO to the Harmony machine driver. Currently, this path is always enabled, while playback is active, since jack detection isn't yet implemented.

The driver initialization path has been reworked a little, and a new driver/device introduced, in order to allow platform data to be passed in, currently containing just the speaker enable GPIO ID.

The GPIO is only requested during _init, since that's the first time it is guaranteed that the WM8903 module is loaded, probed, and hence has exported its GPIO chip.

---
 sound/soc/tegra/harmony.c |   89 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 78 insertions(+), 11 deletions(-)
sound/soc/tegra/harmony.c +78 -11
index b160b71..0e44dd6 100644
@@ -2,7 +2,7 @@
  * harmony.c - Harmony machine ASoC driver
  *
  * Author: Stephen Warren <[email protected]>
- * Copyright (C) 2010 - NVIDIA, Inc.
+ * Copyright (C) 2010-2011 - NVIDIA, Inc.
  *
  * Based on code copyright/by:
  *
@@ -29,7 +29,14 @@
  */
 
 #include <asm/mach-types.h>
+
+#include <linux/gpio.h>
 #include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <mach/harmony_audio.h>
+
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -40,9 +47,12 @@
 #include "tegra_pcm.h"
 #include "tegra_asoc_utils.h"
 
-#define PREFIX "ASoC Harmony: "
+#define DRV_NAME "tegra-snd-harmony"
+#define PREFIX DRV_NAME ": "
 
+static struct harmony_audio_platform_data *pdata;
 static struct platform_device *harmony_snd_device;
+static int gpio_spkr_en_requested;
 
 static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
@@ -107,7 +117,19 @@ static struct snd_soc_ops harmony_asoc_ops = {
 	.hw_params = harmony_asoc_hw_params,
 };
 
+static int harmony_event_int_spk(struct snd_soc_dapm_widget *w,
+					struct snd_kcontrol *k, int event)
+{
+	if (SND_SOC_DAPM_EVENT_ON(event))
+		gpio_set_value_cansleep(pdata->gpio_spkr_en, 1);
+	else
+		gpio_set_value_cansleep(pdata->gpio_spkr_en, 0);
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
+	SND_SOC_DAPM_SPK("Int Spk", harmony_event_int_spk),
 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
 	SND_SOC_DAPM_MIC("Mic Jack", NULL),
 };
@@ -115,6 +137,10 @@ static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
 static const struct snd_soc_dapm_route harmony_audio_map[] = {
 	{"Headphone Jack", NULL, "HPOUTR"},
 	{"Headphone Jack", NULL, "HPOUTL"},
+	{"Int Spk", NULL, "ROP"},
+	{"Int Spk", NULL, "RON"},
+	{"Int Spk", NULL, "LOP"},
+	{"Int Spk", NULL, "LON"},
 	{"Mic Bias", NULL, "Mic Jack"},
 	{"IN1L", NULL, "Mic Bias"},
 };
@@ -123,6 +149,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	int ret;
 
 	snd_soc_dapm_new_controls(dapm, harmony_dapm_widgets,
 					ARRAY_SIZE(harmony_dapm_widgets));
@@ -131,9 +158,19 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 				ARRAY_SIZE(harmony_audio_map));
 
 	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
+	snd_soc_dapm_enable_pin(dapm, "Int Spk");
 	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
 	snd_soc_dapm_sync(dapm);
 
+	ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
+	if (ret) {
+		pr_err(PREFIX "cannot get spkr_en gpio\n");
+		return ret;
+	}
+	gpio_spkr_en_requested = 1;
+
+	gpio_direction_output(pdata->gpio_spkr_en, 0);
+
 	return 0;
 }
 
@@ -154,13 +191,19 @@ static struct snd_soc_card snd_soc_harmony = {
 	.num_links = 1,
 };
 
-static int __init harmony_soc_modinit(void)
+static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 {
 	int ret;
 
-	if (!machine_is_harmony()) {
-		pr_err(PREFIX "Not running on Tegra Harmony!\n");
-		return -ENODEV;
+	if (pdev->id != 0) {
+		dev_err(&pdev->dev, "ID %d out of range\n", pdev->id);
+		return -EINVAL;
+	}
+
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data supplied\n");
+		return -EINVAL;
 	}
 
 	ret = tegra_asoc_utils_init();
@@ -173,7 +216,7 @@ static int __init harmony_soc_modinit(void)
 	 */
 	harmony_snd_device = platform_device_alloc("soc-audio", -1);
 	if (harmony_snd_device == NULL) {
-		pr_err(PREFIX "platform_device_alloc failed\n");
+		dev_err(&pdev->dev, "platform_device_alloc failed\n");
 		ret = -ENOMEM;
 		goto err_clock_utils;
 	}
@@ -182,7 +225,7 @@ static int __init harmony_soc_modinit(void)
 
 	ret = platform_device_add(harmony_snd_device);
 	if (ret) {
-		pr_err(PREFIX "platform_device_add failed (%d)\n",
+		dev_err(&pdev->dev, "platform_device_add failed (%d)\n",
 			ret);
 		goto err_device_put;
 	}
@@ -195,15 +238,39 @@ err_clock_utils:
 	tegra_asoc_utils_fini();
 	return ret;
 }
-module_init(harmony_soc_modinit);
 
-static void __exit harmony_soc_modexit(void)
+static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 {
 	platform_device_unregister(harmony_snd_device);
 
+	if (gpio_spkr_en_requested)
+		gpio_free(pdata->gpio_spkr_en);
+
 	tegra_asoc_utils_fini();
+
+	return 0;
+}
+
+static struct platform_driver tegra_snd_harmony_driver = {
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+	},
+	.probe = tegra_snd_harmony_probe,
+	.remove = __devexit_p(tegra_snd_harmony_remove),
+};
+
+static int __init snd_tegra_harmony_init(void)
+{
+	return platform_driver_register(&tegra_snd_harmony_driver);
+}
+module_init(snd_tegra_harmony_init);
+
+static void __exit snd_tegra_harmony_exit(void)
+{
+	platform_driver_unregister(&tegra_snd_harmony_driver);
 }
-module_exit(harmony_soc_modexit);
+module_exit(snd_tegra_harmony_exit);
 
 MODULE_AUTHOR("Stephen Warren <[email protected]>");
 MODULE_DESCRIPTION("Harmony machine ASoC driver");
Signature · 1 line
1.7.1
author
#16 lore raw

Re: [PATCH v2 4/4] ASoC: tegra: Harmony: Support the internal speaker

sound/soc/tegra/harmony.c static struct snd_soc_ops harmony_asoc_ops = { · line 126

Quoted 4 lines · Stephen Warren
sound/soc/tegra/harmony.c +4 -0
+	if (SND_SOC_DAPM_EVENT_ON(event))
+		gpio_set_value_cansleep(pdata->gpio_spkr_en, 1);
+	else
+		gpio_set_value_cansleep(pdata->gpio_spkr_en, 0);

Very minor stylistic thing but you could say:

	gpio_set_value_cansleep(pdata->gpio_spkr_en,
				SND_SOC_DAPM_EVENT_ON(event));

instead.

author
#17 lore raw

Re: [PATCH v2 4/4] ASoC: tegra: Harmony: Support the internal speaker

In reply to Stephen Warren

sound/soc/tegra/harmony.c static struct snd_soc_card snd_soc_harmony = { · line 194

Quoted 2 lines · Stephen Warren
sound/soc/tegra/harmony.c +1 -1
-static int __init harmony_soc_modinit(void)
+static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)

Unrelated change...

sound/soc/tegra/harmony.c static struct snd_soc_card snd_soc_harmony = { · line 206

Quoted 12 lines
sound/soc/tegra/harmony.c +9 -3
-	if (!machine_is_harmony()) {
-		pr_err(PREFIX "Not running on Tegra Harmony!\n");
-		return -ENODEV;
+	if (pdev->id != 0) {
+		dev_err(&pdev->dev, "ID %d out of range\n", pdev->id);
+		return -EINVAL;
+	}
+
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data supplied\n");
+		return -EINVAL;

Unless you have more than one sound card your device ID should be -1. I'd also be inclined to keep the machine_is_harmony() check here for paranoia.

With the recently added exposure of snd_soc_register_card() you *should* just be able allocate a regular platform device with a regular name in your arch/arm code and then register that directly with the ASoC core - something like:

int __devinit harmony_audio_probe(struct platform_device *pdev)

{
	/* Do GPIO stuff */

	card->dev = &pdev->dev;
	snd_soc_register_card(&snd_soc_harmony);

	/* Error handling */
}

ought to do the trick, and is much neater and more idiomatic than the soc-audio stuff.

#18 lore raw

Re: [PATCH v2 4/4] ASoC: tegra: Harmony: Support the internal speaker

Mark Brown wrote on Tuesday, January 25, 2011 1:30 PM:

Quoted 8 lines · Stephen Warren

Review

Quoted 3 lines
(quoted diff) +1 -1
-static int __init harmony_soc_modinit(void)
+static __devinit int tegra_snd_harmony_probe(struct platform_device

*pdev)

Unrelated change...

Yeah, I guess I should separate the device probing rework into a separate patch.

Quoted 16 lines

...
With the recently added exposure of snd_soc_register_card() you *should* just be able allocate a regular platform device with a regular name in your arch/arm code and then register that directly with the ASoC core - something like:

int __devinit harmony_audio_probe(struct platform_device *pdev)

{
	/* Do GPIO stuff */

	card->dev = &pdev->dev;
	snd_soc_register_card(&snd_soc_harmony);

	/* Error handling */
}
Quoted 2 lines

ought to do the trick, and is much neater and more idiomatic than the soc-audio stuff.

With the existing soc-audio structure, one has to:

	platform_set_drvdata(harmony_snd_device, &snd_soc_harmony);

I assume there's no need for this when registering via snd_soc_register_card; In other words, I'm free to use dev_set_drvdata on the platform_device/device so I can get rid of all the globals in harmony.y while I'm at it?

I do see some internal use of set_drvdata/get_drvdata in soc-core.c. It looks like that's restricted to when the soc-audio platform_device is used, but I don't know if that's just co-incidence, or if it's a guarantee of the API. Can you confirm this?

Thanks.

--
nvpublic

author
#19 lore raw

Re: [PATCH v2 4/4] ASoC: tegra: Harmony: Support the internal speaker

Quoted 4 lines · Stephen Warren

With the existing soc-audio structure, one has to:

	platform_set_drvdata(harmony_snd_device, &snd_soc_harmony);
Quoted 8 lines

I assume there's no need for this when registering via snd_soc_register_card; In other words, I'm free to use dev_set_drvdata on the platform_device/device so I can get rid of all the globals in harmony.y while I'm at it?

I do see some internal use of set_drvdata/get_drvdata in soc-core.c. It looks like that's restricted to when the soc-audio platform_device is used, but I don't know if that's just co-incidence, or if it's a guarantee of the API. Can you confirm this?

Oh, bah. The code is currently broken - suspend and resume are still using the platform device. I'll post a patch later today which removes this requirement and adds callbacks for you to use.

Acked-by on the v2 series
#20 lore raw

Re: [PATCH v2 0/4] Tegra: Harmony: Add internal speaker support

In reply to Stephen Warren
Quoted 25 lines · Stephen Warren

Harmony has headers on the board for an internal speaker and internal mic. This patch series adds various infra-structure, and enables usage of the internal speaker.

The patch series includes both changes to code within the ASoC subsystem and Tegra subsystem, the latter provided only for context when reading the ASoC changes. Would you prefer I separated these so that the ASoC maintainers can grab a whole series and apply it, rather than just a subset of the patches?

While patch 2 is physically located in the Tegra subsystem, I'd consider it part of the ASoC driver. Can such a change be checked into the ASoC tree? This new header file will be required to build to ASoC driver once the following patches are in. I was considering placing this in include/sound, following the example of various codecs, but it doesn't seem a good idea to pollute that directory with platform-specific files. The current location for the file follows the example of s3c24xx/simtec. Perhaps it should be in sound/soc/tegra?

Stephen Warren (4):
ASoC: WM8903: Expose GPIOs through gpiolib
ARM: tegra: Add Harmony sound platform data type
ARM: tegra: Platform data fixes for ASoC driver updates
ASoC: tegra: Harmony: Support the internal speaker

Quoted 9 lines
 arch/arm/mach-tegra/board-harmony.c              |   31 ++++++
 arch/arm/mach-tegra/gpio-names.h                 |    2 +
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 ++++
 include/sound/wm8903.h                           |    7 +-
 sound/soc/codecs/wm8903.c                        |  117 +++++++++++++++++++++-
 sound/soc/tegra/harmony.c                        |   89 ++++++++++++++--
 6 files changed, 251 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h

All

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#21 lore raw

v3 cover Tegra: Harmony: Add internal speaker support

In reply to a message not in the archive

Harmony has headers on the board for an internal speaker and internal mic. This patch series adds various infra-structure, and enables usage of the internal speaker.

The patch series includes both changes to code within the ASoC subsystem and Tegra subsystem, the latter provided only for context when reading the ASoC changes. Would you prefer I separated these so that the ASoC maintainers can grab a whole series and apply it, rather than just a subset of the patches?

While patch 2 is physically located in the Tegra subsystem, I'd consider it part of the ASoC driver. Can such a change be checked into the ASoC tree? This new header file will be required to build to ASoC driver once the following patches are in. I was considering placing this in include/sound, following the example of various codecs, but it doesn't seem a good idea to pollute that directory with platform-specific files. The current location for the file follows the example of s3c24xx/simtec. Perhaps it should be in sound/soc/tegra?

Changelog:

* v3:
* Reverted change to WM8903_GPIO_NO_CONFIG
* Program WM8903_GP1_FN_MASK in direction_{input,output}
* Simplify harmony_event_int_spk
* Didn't remove GPIO entries from harmony_wm8903_pdata, since this also sets up all the other fields to 0 too.

Stephen Warren (4):
ASoC: WM8903: Expose GPIOs through gpiolib
ARM: tegra: Add Harmony sound platform data type
ARM: tegra: Platform data fixes for ASoC driver updates
ASoC: tegra: Harmony: Support the internal speaker

 arch/arm/mach-tegra/board-harmony.c              |   31 ++++++
 arch/arm/mach-tegra/gpio-names.h                 |    2 +
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 ++++
 include/sound/wm8903.h                           |   20 ++++-
 sound/soc/codecs/wm8903.c                        |  126 +++++++++++++++++++++-
 sound/soc/tegra/harmony.c                        |   87 +++++++++++++--
 6 files changed, 272 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h
#22 lore raw

PATCH v3 1/4 ASoC: WM8903: Expose GPIOs through gpiolib

Also, fix platform_data GPIO handling to have an explicit "don't touch this pin" option.

Add #defines for the GPIO pin functions.

---
 include/sound/wm8903.h    |   20 +++++++-
 sound/soc/codecs/wm8903.c |  126 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 144 insertions(+), 2 deletions(-)
include/sound/wm8903.h +19 -1
index b4a0db2..86172cf 100644
@@ -37,6 +37,21 @@
 #define WM8903_MICBIAS_ENA_WIDTH                     1  /* MICBIAS_ENA */
 
 /*
+ * WM8903_GPn_FN values
+ *
+ * See datasheets for list of valid values per pin
+ */
+#define WM8903_GPn_FN_GPIO_OUTPUT                    0
+#define WM8903_GPn_FN_BCLK                           1
+#define WM8903_GPn_FN_IRQ_OUTPT                      2
+#define WM8903_GPn_FN_GPIO_INPUT                     3
+#define WM8903_GPn_FN_MICBIAS_CURRENT_DETECT         4
+#define WM8903_GPn_FN_MICBIAS_SHORT_DETECT           5
+#define WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT             6
+#define WM8903_GPn_FN_FLL_LOCK_OUTPUT                8
+#define WM8903_GPn_FN_FLL_CLOCK_OUTPUT               9
+
+/*
  * R116 (0x74) - GPIO Control 1
  */
 #define WM8903_GP1_FN_MASK                      0x1F00  /* GP1_FN - [12:8] */
@@ -231,6 +246,8 @@
 #define WM8903_GP5_DB_SHIFT                          0  /* GP5_DB */
 #define WM8903_GP5_DB_WIDTH                          1  /* GP5_DB */
 
+#define WM8903_NUM_GPIO 5
+
 struct wm8903_platform_data {
 	bool irq_active_low;   /* Set if IRQ active low, default high */
 
@@ -243,7 +260,8 @@ struct wm8903_platform_data {
 
 	int micdet_delay;      /* Delay after microphone detection (ms) */
 
-	u32 gpio_cfg[5];       /* Default register values for GPIO pin mux */
+	int gpio_base;
+	u32 gpio_cfg[WM8903_NUM_GPIO]; /* Default register values for GPIO pin mux */
 };
 
 #endif
sound/soc/codecs/wm8903.c +125 -1

180 lines not on this page · raw message

Signature · 1 line
1.7.1
author Applied
#23 lore raw

Re: [PATCH v3 1/4] ASoC: WM8903: Expose GPIOs through gpiolib

Quoted 6 lines · Stephen Warren

Also, fix platform_data GPIO handling to have an explicit "don't touch this pin" option.

Add #defines for the GPIO pin functions.

Applied this one, thanks.

#24 lore raw

PATCH v3 2/4 ARM: tegra: Add Harmony sound platform data type

In reply to Stephen Warren
---
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h
arch/arm/mach-tegra/include/mach/harmony_audio.h new file +19 -0
new file mode 100644
index 0000000..5c46391
@@ -0,0 +1,19 @@
+/*
+ * arch/arm/mach-tegra/include/mach/harmony_audio.h
+ *
+ * Copyright 2011 NVIDIA, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+struct harmony_audio_platform_data {
+	int gpio_spkr_en;
+};
Signature · 1 line
1.7.1
#25 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Quoted 34 lines · Stephen Warren

---
 arch/arm/mach-tegra/include/mach/harmony_audio.h |   19 +++++++++++++++++++

 1 files changed, 19 insertions(+), 0 deletions(-)

 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h

arch/arm/mach-tegra/include/mach/harmony_audio.h new file +19 -1
new file mode 100644
index 0000000..5c46391
@@ -0,0 +1,19 @@
+/*
+ * arch/arm/mach-tegra/include/mach/harmony_audio.h
+ *
+ * Copyright 2011 NVIDIA, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+struct harmony_audio_platform_data {
+       int gpio_spkr_en;
+};
--

1.7.1

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Does this file really belong in mach-tegra if its for a driver that is in a common directory (drivers/sound/soc)? Putting it in include/linux would solve all your tree-ordering problems.

#26 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Colin Cross wrote on Friday, January 21, 2011 11:43 AM:

Quoted 7 lines · Stephen Warren
Quoted 1 line

 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h

Does this file really belong in mach-tegra if its for a driver that is in a common directory (drivers/sound/soc)? Putting it in include/linux would solve all your tree-ordering problems.

Colin,

Re: The location I chose; I followed an existing example of another ASoC driver. Perhaps there is a more appropriate location, although the ASoC maintainers didn't point one out.

I'm afraid I don't understand how moving the file would solve the dependency issues though:

There's a change in sound/soc/... that needs this new file.

There's a change in arch/arm/mach-tegra/... that needs this new file.

Both those two changes would typically get checked into two separate git repositories.

As far as I can tell, we could:

a) Check the new file into both repositories, and git will hopefully just merge them together in the next merge window. Mark pointed out a long time ago that this is generally frowned upon though.

b) Check the change into just one repository, e.g. ASoC since it's ready to accept the sound/soc/... changes that rely on it, and then have Tegra's for-next merge that (or merge linux-next after it's filtered up there, although I'm not sure if merging linux-next is workable with git?) (or merge directly from ASoC's for-2.6.39) and only then apply the arch/arm/tegra changes that rely on it. Mark pointed out a long time ago that such cross- subsystem merges are very rare, although it sounded like they do happen sometimes.

c) Only check in the sound/soc/... changes, wait until they're in 2.6.39-rc1 and hence can be picked up from there for Tegra's for-next, and then check in the Tegra changes that rely on it. This would delay the complete changes until 2.6.40:-(

I'm still in the dark how this normally works; it seems like it must be pretty common to add a new driver to the driver repository, with that driver defining a new platform_data type, and also needing to add code to the architecture/chip repository to provide that platform_data, and hopefully have both those things go in in parallel, rather than being staged across two kernel releases.

Signature · 1 line
nvpublic
#27 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Quoted 45 lines · Stephen Warren

Colin Cross wrote on Friday, January 21, 2011 11:43 AM:

Quoted 7 lines · Stephen Warren
Quoted 1 line

 create mode 100644 arch/arm/mach-tegra/include/mach/harmony_audio.h

Does this file really belong in mach-tegra if its for a driver that is in a common directory (drivers/sound/soc)?  Putting it in include/linux would solve all your tree-ordering problems.

Colin,

Re: The location I chose; I followed an existing example of another ASoC driver. Perhaps there is a more appropriate location, although the ASoC maintainers didn't point one out.

I'm afraid I don't understand how moving the file would solve the dependency issues though:

There's a change in sound/soc/... that needs this new file.

There's a change in arch/arm/mach-tegra/... that needs this new file.

Both those two changes would typically get checked into two separate git repositories.

As far as I can tell, we could:

a) Check the new file into both repositories, and git will hopefully just merge them together in the next merge window. Mark pointed out a long time ago that this is generally frowned upon though.

b) Check the change into just one repository, e.g. ASoC since it's ready to accept the sound/soc/... changes that rely on it, and then have Tegra's for-next merge that (or merge linux-next after it's filtered up there, although I'm not sure if merging linux-next is workable with git?) (or merge directly from ASoC's for-2.6.39) and only then apply the arch/arm/tegra changes that rely on it. Mark pointed out a long time ago that such cross- subsystem merges are very rare, although it sounded like they do happen sometimes.

c) Only check in the sound/soc/... changes, wait until they're in 2.6.39-rc1 and hence can be picked up from there for Tegra's for-next, and then check in the Tegra changes that rely on it. This would delay the complete changes until 2.6.40:-(

Quoted 6 lines

I'm still in the dark how this normally works; it seems like it must be pretty common to add a new driver to the driver repository, with that driver defining a new platform_data type, and also needing to add code to the architecture/chip repository to provide that platform_data, and hopefully have both those things go in in parallel, rather than being staged across two kernel releases.

Could the same platform_data patch go into both ASoC and Tegra? It would fall out in the merge, no matter who gets pulled first. If we go that route, whichever place you put the header, one of the trees will have an include file that is in the other tree's directory.

I still think the header makes more sense in include/sound than mach-tegra, but if the ASoC maintainers prefer it in mach-tegra, consider the patch Acked-by: Colin Cross <[email protected]> for inclusion in the ASoC tree.

author
#28 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Quoted 4 lines · Colin Cross

Could the same platform_data patch go into both ASoC and Tegra? It would fall out in the merge, no matter who gets pulled first. If we go that route, whichever place you put the header, one of the trees will have an include file that is in the other tree's directory.

The usual thing here would be a branch that gets merged into both trees (to avoid the commit getting duplicated) or to only apply in one tree and let things sort themselves out in -next and the merge window.

Quoted 4 lines

I still think the header makes more sense in include/sound than mach-tegra, but if the ASoC maintainers prefer it in mach-tegra, consider the patch Acked-by: Colin Cross <[email protected]> for inclusion in the ASoC tree.

The general style for architecture specific headers is that they get included in architecture specific directories to avoid general namespace pollution.

#29 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Mark Brown wrote on Sent: Friday, January 21, 2011 4:42 PM:

Quoted 11 lines · Colin Cross
Quoted 5 lines

Could the same platform_data patch go into both ASoC and Tegra? It would fall out in the merge, no matter who gets pulled first. If we go that route, whichever place you put the header, one of the trees will have an include file that is in the other tree's directory.

The usual thing here would be a branch that gets merged into both trees (to avoid the commit getting duplicated) or to only apply in one tree and let things sort themselves out in -next and the merge window.

Ah yes, I do remember you mentioning that before. Now I realize exactly what you mean.

I'm quite happy to create a branch for this, cherry-pick my change onto it, and tell you where it is, so you can merge from it.

What should I base the branch off; since it's a simple file add, I guess the current mainline tree would be fine.

I assume there are no specific requirements for where the branch is hosted; i.e. something you can git clone over HTTP from my personal server would be fine?

Thanks!

Signature · 1 line
nvpublic
#30 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Quoted 7 lines · Stephen Warren

Mark Brown wrote on Sent: Friday, January 21, 2011 4:42 PM:

Quoted 3 lines

The usual thing here would be a branch that gets merged into both trees (to avoid the commit getting duplicated) or to only apply in one tree and let things sort themselves out in -next and the merge window.

Ah yes, I do remember you mentioning that before. Now I realize exactly what you mean.

Sounds overly complicated to me since you don't already have a tree hosted somewhere.

Mark; why don't you apply it with Colin's acked-by, and Colin can just cherry-pick from that for-next branch?

-Olof

#31 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Olof Johansson wrote on Friday, January 21, 2011 10:15 PM:

Quoted 7 lines · Stephen Warren
Quoted 5 lines

Mark Brown wrote on Sent: Friday, January 21, 2011 4:42 PM:

Quoted 3 lines

The usual thing here would be a branch that gets merged into both trees (to avoid the commit getting duplicated) or to only apply in one tree and let things sort themselves out in -next and the merge window.

Quoted 5 lines
Quoted 2 lines

Ah yes, I do remember you mentioning that before. Now I realize exactly what you mean.

Sounds overly complicated to me since you don't already have a tree hosted somewhere.

Well, I did push a kernel repo to my personal server, which would do fine for this purpose assuming there's no requirement for it to stick around for any specific amount of time etc.

Signature · 1 line
nvpublic
#32 lore raw

Re: [PATCH v3 2/4] ARM: tegra: Add Harmony sound platform data type

Quoted 11 lines · Stephen Warren

Olof Johansson wrote on Friday, January 21, 2011 10:15 PM:

Quoted 10 lines · Stephen Warren
Quoted 7 lines

Mark Brown wrote on Sent: Friday, January 21, 2011 4:42 PM:

Quoted 3 lines

The usual thing here would be a branch that gets merged into both trees (to avoid the commit getting duplicated) or to only apply in one tree and let things sort themselves out in -next and the merge window.

Ah yes, I do remember you mentioning that before. Now I realize exactly what you mean.

Quoted 6 lines
Quoted 2 lines

Sounds overly complicated to me since you don't already have a tree hosted somewhere.

Well, I did push a kernel repo to my personal server, which would do fine for this purpose assuming there's no requirement for it to stick around for any specific amount of time etc.

Ok, that works too :)

-Olof

#33 lore raw

PATCH v3 3/4 ARM: tegra: Platform data fixes for ASoC driver updates

In reply to Stephen Warren

The WM8903 driver now needs platform data in order to correctly expose its GPIOs through gpiolib.

The top-level ASoC driver now needs a platform device in order to provide infra-structure to pass in platform data.

The top-level ASoC driver now needs platform data in order to be informed which GPIO IDs to use.

This is all needed to allow the top-level ASoC driver to configure the WM8903's GPIO3 as an output GPIO, and enable it as appropriate. This is the enable signal for the external speaker amplifier chips.

---
 arch/arm/mach-tegra/board-harmony.c |   31 +++++++++++++++++++++++++++++++
 arch/arm/mach-tegra/gpio-names.h    |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/board-harmony.c +31 -0
index 2696a20..c5a4ae0 100644
@@ -2,6 +2,7 @@
  * arch/arm/mach-tegra/board-harmony.c
  *
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (C) 2011 NVIDIA, Inc.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -24,12 +25,15 @@
 #include <linux/i2c.h>
 #include <linux/io.h>
 
+#include <sound/wm8903.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include <asm/setup.h>
 
 #include <mach/gpio.h>
+#include <mach/harmony_audio.h>
 #include <mach/i2c.h>
 #include <mach/iomap.h>
 #include <mach/irqs.h>
@@ -53,6 +57,8 @@
 #define ATAG_NVIDIA_PRESERVED_MEM_N	2
 #define ATAG_NVIDIA_FORCE_32		0x7fffffff
 
+#define GPIO_WM8903(_x_) (TEGRA_MAX_GPIO + 1 + (_x_))
+
 struct tag_tegra {
 	__u32 bootarg_key;
 	__u32 bootarg_len;
@@ -112,9 +118,33 @@ static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
 	.bus_clk_rate	= { 400000, 0 },
 };
 
+static struct wm8903_platform_data harmony_wm8903_pdata = {
+	.gpio_base = GPIO_WM8903(0),
+	.gpio_cfg = {
+		WM8903_GPIO_NO_CONFIG,
+		WM8903_GPIO_NO_CONFIG,
+		0,
+		WM8903_GPIO_NO_CONFIG,
+		WM8903_GPIO_NO_CONFIG,
+	},
+};
+
 static struct i2c_board_info __initdata harmony_i2c_bus1_board_info[] = {
 	{
 		I2C_BOARD_INFO("wm8903", 0x1a),
+		.platform_data = &harmony_wm8903_pdata,
+	},
+};
+
+static struct harmony_audio_platform_data harmony_audio_pdata = {
+	.gpio_spkr_en = GPIO_WM8903(2),
+};
+
+static struct platform_device harmony_audio_device = {
+	.name   = "tegra-snd-harmony",
+	.id     = 0,
+	.dev    = {
+		.platform_data  = &harmony_audio_pdata,
 	},
 };
 
@@ -127,6 +157,7 @@ static struct platform_device *harmony_devices[] __initdata = {
 	&tegra_i2s_device1,
 	&tegra_das_device,
 	&tegra_pcm_device,
+	&harmony_audio_device,
 };
 
 static void __init tegra_harmony_fixup(struct machine_desc *desc,
arch/arm/mach-tegra/gpio-names.h +2 -0
index f28220a..e8b5cf3 100644
@@ -244,4 +244,6 @@
 #define TEGRA_GPIO_PBB6		222
 #define TEGRA_GPIO_PBB7		223
 
+#define TEGRA_MAX_GPIO		TEGRA_GPIO_PBB7
+
 #endif
Signature · 1 line
1.7.1
author
#34 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 2 lines · Stephen Warren

The WM8903 driver now needs platform data in order to correctly expose its GPIOs through gpiolib.

This isn't really a fix - it's enabling a new feature that wasn't previously supported, describing it as a fix is misleading as that'd suggest it should be applied to the release branch as a bugfix which would cause build issues.

I'm happy with this version of the series, I guess Liam will be too. Ideally someone from the Tegra side should sign off on the arch/arm side - that'll need to go through the same tree as the ASoC side for build dependencies.

Acked-by
#35 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 9 lines · Mark Brown
Quoted 2 lines · Stephen Warren

The WM8903 driver now needs platform data in order to correctly expose its GPIOs through gpiolib.

This isn't really a fix - it's enabling a new feature that wasn't previously supported, describing it as a fix is misleading as that'd suggest it should be applied to the release branch as a bugfix which would cause build issues.

Quoted 4 lines

I'm happy with this version of the series, I guess Liam will be too. Ideally someone from the Tegra side should sign off on the arch/arm side - that'll need to go through the same tree as the ASoC side for build dependencies.

I'm happy with this too.

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#36 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

In reply to Mark Brown

[I apologize if the email formatting is terrible; my usual system is broken right now. I hope this is plain text]

Mark Brown wrote on Thursday, January 20, 2011 14:22:

Quoted 6 lines · Stephen Warren
Quoted 2 lines

The WM8903 driver now needs platform data in order to correctly expose its GPIOs through gpiolib.

This isn't really a fix - it's enabling a new feature that wasn't previously supported

Agreed. I'll reword this when I submit it for inclusion in the Tegra tree.

Quoted 4 lines

I'm happy with this version of the series, I guess Liam will be too. Ideally someone from the Tegra side should sign off on the arch/arm side - that'll need to go through the same tree as the ASoC side for build dependencies.

I assume you're only talking about:

a882c75eadfcdc56f47962dd3f7870d6def62847
ARM: tegra: Add Harmony sound platform data type

The other arch/arm patches won't apply anywhere yet since they build on top of various other patches that haven't been submitted for or applied to the linux-tegra tree yet.

CC += Colin/Erik to ack/nack the header addition mentioned above.

Thanks

Signature · 1 line
nvpublic
author
#37 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 9 lines · Stephen Warren
Quoted 4 lines

I'm happy with this version of the series, I guess Liam will be too. Ideally someone from the Tegra side should sign off on the arch/arm side - that'll need to go through the same tree as the ASoC side for build dependencies.

I assume you're only talking about:

a882c75eadfcdc56f47962dd3f7870d6def62847
ARM: tegra: Add Harmony sound platform data type

That and the addition of the defines for function codes IIRC.

Quoted 3 lines

The other arch/arm patches won't apply anywhere yet since they build on top of various other patches that haven't been submitted for or applied to the linux-tegra tree yet.

Oh, I see. I hadn't realised there wer eother dependencies, please ensure you mention any such dependencies in the changlogs so we avoid introducing breakage.

#38 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Mark Brown wrote on Friday, January 21, 2011 10:50:

Quoted 7 lines · Stephen Warren
Quoted 5 lines
Quoted 5 lines

I'm happy with this version of the series, I guess Liam will be too. Ideally someone from the Tegra side should sign off on the arch/arm side - that'll need to go through the same tree as the ASoC side for build dependencies.

Quoted 6 lines
Quoted 4 lines

I assume you're only talking about:

a882c75eadfcdc56f47962dd3f7870d6def62847
ARM: tegra: Add Harmony sound platform data type

That and the addition of the defines for function codes IIRC.

The wm8903 GPIO function defines? They're in wm8903.h and don't rely on anything else. The arch/arm patches don't rely on these defines.

Quoted 7 lines
Quoted 3 lines

The other arch/arm patches won't apply anywhere yet since they build on top of various other patches that haven't been submitted for or applied to the linux-tegra tree yet.

Oh, I see. I hadn't realised there wer eother dependencies, please ensure you mention any such dependencies in the changlogs so we avoid introducing breakage.

That was the intent of what I wrote in the "cover letter" "patch".

To be explicit, the only dependency is that the patch quoted above, which adds some platform data types, needs to be checked in to te ASoC tree rather than the usual ARM tree, before the following ASoC patch is applied:

ASoC: tegra: Harmony: Support th internal speaker

Every other ASoC patch I've submitted doesn't rely on anything outside the ASoC tree to compile, although actually running it usefully obviously requires the arch/arm changes.

Hope this clears things up!

--
nvpublic

author
#39 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 7 lines · Stephen Warren

Mark Brown wrote on Friday, January 21, 2011 10:50:

Quoted 3 lines

Oh, I see. I hadn't realised there wer eother dependencies, please ensure you mention any such dependencies in the changlogs so we avoid introducing breakage.

That was the intent of what I wrote in the "cover letter" "patch".

It doesn't refer to anything outside the series itself and the current state of the relevant trees, which seemed to be what you were saying...

It'd also be helpful if you could stop burying patches in old threads - it makes it hard to find the most recent stuff.

Quoted 4 lines

To be explicit, the only dependency is that the patch quoted above, which adds some platform data types, needs to be checked in to te ASoC tree rather than the usual ARM tree, before the following ASoC patch is applied:

...but possibly not?

#40 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 2 lines · Mark Brown

It'd also be helpful if you could stop burying patches in old threads - it makes it hard to find the most recent stuff.

Sorry. I read somewhere that threading updates into the existing thread was the preferred way. I'll stop doing it.

Quoted 6 lines
Quoted 4 lines

To be explicit, the only dependency is that the patch quoted above, which adds some platform data types, needs to be checked in to te ASoC tree rather than the usual ARM tree, before the following ASoC patch is applied:

...but possibly not?

Sorry, I don't follow. Possibly not what? Are you saying:

a) Possibly not the only dependency? It's certainly the only one I know of.

b) Possibly not that it needs to be checked into the ASoC git repo, even though the header is located somewhere the Tegra git repo owns?

I'm fine moving the header into some directory that ASoC owns, and fixing my arch/arm/mach-tegra patch for the new location. That would mean that when I submit the Tegra changes to the Tegra tree, the Tegra trees needs to have picked up the ASoC changes first, but that's fine I think? At the least, it defers any issue until later.

Otherwise, yes, that patch is needed befoer the ASoC patch that uses it, or there will be a build break, if anyone enables building that driver.

Signature · 1 line
nvpublic
author
#41 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 8 lines · Stephen Warren

Mark Brown wrote:

Sorry, I don't follow. Possibly not what? Are you saying:

a) Possibly not the only dependency? It's certainly the only one I know of.

b) Possibly not that it needs to be checked into the ASoC git repo, even though the header is located somewhere the Tegra git repo owns?

You said in <[email protected]>:

| The other arch/arm patches won't apply anywhere yet since they build
| on top of various other patches that haven't been submitted for or
| applied to the linux-tegra tree yet.

referring to patches 2 and 3 of the series. To me that says that these patches won't apply to either the Tegra or ASoC trees as they stand as they depend on patches you have not yet submitted.

#42 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 9 lines · Mark Brown
Quoted 6 lines

Sorry, I don't follow. Possibly not what? Are you saying:

a) Possibly not the only dependency? It's certainly the only one I know of.

b) Possibly not that it needs to be checked into the ASoC git repo, even though the header is located somewhere the Tegra git repo owns?

You said in <[email protected]>:

Quoted 7 lines
| The other arch/arm patches won't apply anywhere yet since they build
| on top of various other patches that haven't been submitted for or
| applied to the linux-tegra tree yet.

referring to patches 2 and 3 of the series. To me that says that these patches won't apply to either the Tegra or ASoC trees as they stand as they depend on patches you have not yet submitted.

Patch 1 (wm8903 GPIO support) has no dependencies.

Patch 2 (add header to define Harmony ASoC driver's platform_data) doesn't depend on anything else, but is required by patches 3 and 4.

This is the patch which is in a path owned by the Tegra tree, but needs to be checked into the ASoC tree to enable patch 4 to be checked in there.

Patch 3 (Adds various platform data to arch/arm/mach-tegra) depends on patch 2, and should be checked into the Tegra for-next tree at some later time. You can ignore this patch; I presented it simply to show a complete set of patches. Sorry if the cover letter wasn't clear on this point.

Patch 4 (Adds internal speaker support to ASoC driver) depends on patch 2 being in the ASoC tree somehow. Hence, why you asked the Tegra maintainers to sign off on checking patch 2 into the ASoC tree, as I understand it.

Signature · 1 line
nvpublic
author
#43 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 4 lines · Stephen Warren

Patch 3 (Adds various platform data to arch/arm/mach-tegra) depends on patch 2, and should be checked into the Tegra for-next tree at some later time. You can ignore this patch; I presented it simply to show a complete set of patches. Sorry if the cover letter wasn't clear on this point.

I've no problem carrying that in ASoC if Colin is happy with it, it seems much easier to do that than to have to remember to apply it to the Tegra tree after the 2.6.39 merge window.

Quoted 3 lines

Patch 4 (Adds internal speaker support to ASoC driver) depends on patch 2 being in the ASoC tree somehow. Hence, why you asked the Tegra maintainers to sign off on checking patch 2 into the ASoC tree, as I understand it.

Yes. It was your subsequent reply about stuff not having been submitted that made me think that there were still more dependencies I wasn't aware of.

#44 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 10 lines · Mark Brown
Quoted 4 lines · Stephen Warren

Patch 3 (Adds various platform data to arch/arm/mach-tegra) depends on patch 2, and should be checked into the Tegra for-next tree at some later time. You can ignore this patch; I presented it simply to show a complete set of patches. Sorry if the cover letter wasn't clear on this point.

I've no problem carrying that in ASoC if Colin is happy with it, it seems much easier to do that than to have to remember to apply it to the Tegra tree after the 2.6.39 merge window.

I'd like to get everything, or at least most of this, into 2.6.39 if at all possible. I guess getting just the basic driver (i.e. before this addition of internal speaker support) would be OK though, since none of the patches for the basic driver have any cross-subsystem dependencies.

For the basic driver: Everything is already in the ASoC tree. I'll be pushing patches to support it (i.e. add the required platform_data, and possibly various Tegra infra-structure such as clock configuration additions and fixes etc.) to the Tegra for-next tree once it's open to accept patches:

The problem is that the Tegra for-next branch isn't yet open for submissions, (I was originally directed to provide patches against linux-tegra-2.6.36 and just recently directed to provided patches against linux-tegra-2.6.37) so I've been queueing up all the arch/arm-mach-tegra patches for submission once Tegra for-next opens. Colin and Erik have said offline that this will be soon.

Hence, the arch/arm-mach-tegra changes in this patchset (excluding the simple standalone addition of that one new header) build on code that is neither in ASoC's nor Tegra's for-next branch. Hence, you won't be able to carry that patch yourself since it won't apply, even with manual merging I suspect.

Sorry the situation is so confusing. I hope this explains some of the background.

Signature · 1 line
nvpublic
author
#45 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Quoted 4 lines · Stephen Warren

Hence, the arch/arm-mach-tegra changes in this patchset (excluding the simple standalone addition of that one new header) build on code that is neither in ASoC's nor Tegra's for-next branch. Hence, you won't be able to carry that patch yourself since it won't apply, even with manual merging I suspect.

So just to be absolutely clear, there really are external dependencies for the arch/arm bits of this patch series that go beyond the patch series itself? That's the information I was asking to be flagged on future submissions.

#46 lore raw

Re: [PATCH v3 3/4] ARM: tegra: Platform data fixes for ASoC driver updates

Mark Brown wrote on Friday, January 21, 2011 11:58 AM:

Quoted 8 lines · Stephen Warren
Quoted 6 lines

Hence, the arch/arm-mach-tegra changes in this patchset (excluding the simple standalone addition of that one new header) build on code that is neither in ASoC's nor Tegra's for-next branch. Hence, you won't be able to carry that patch yourself since it won't apply, even with manual merging I suspect.

Quoted 4 lines

So just to be absolutely clear, there really are external dependencies for the arch/arm bits of this patch series that go beyond the patch series itself? That's the information I was asking to be flagged on future submissions.

Yes, the arch/arm bits (except that standalone patch to add the new header) depend on a variety of other patches from before this patchset. Those other patches fix a few missing things in the mainline Tegra support and/or simply add platform devices and platform data for the new ASoC driver. At least some of those patches will have to be reworked a little once Tegra's for-next comes on line.

The sound/soc bits don't depend on anything except what's already in the ACoC for-2.6.39 branch.

Signature · 1 line
nvpublic
#47 lore raw

PATCH v3 4/4 ASoC: tegra: Harmony: Support the internal speaker

In reply to Stephen Warren

Add DAPM widget definitions, and code to control the speaker amplifier GPIO to the Harmony machine driver. Currently, this path is always enabled, while playback is active, since jack detection isn't yet implemented.

The driver initialization path has been reworked a little, and a new driver/device introduced, in order to allow platform data to be passed in, currently containing just the speaker enable GPIO ID.

The GPIO is only requested during _init, since that's the first time it is guaranteed that the WM8903 module is loaded, probed, and hence has exported its GPIO chip.

---
 sound/soc/tegra/harmony.c |   87 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 76 insertions(+), 11 deletions(-)
sound/soc/tegra/harmony.c +76 -11
index b160b71..e424997 100644
@@ -2,7 +2,7 @@
  * harmony.c - Harmony machine ASoC driver
  *
  * Author: Stephen Warren <[email protected]>
- * Copyright (C) 2010 - NVIDIA, Inc.
+ * Copyright (C) 2010-2011 - NVIDIA, Inc.
  *
  * Based on code copyright/by:
  *
@@ -29,7 +29,14 @@
  */
 
 #include <asm/mach-types.h>
+
+#include <linux/gpio.h>
 #include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <mach/harmony_audio.h>
+
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -40,9 +47,12 @@
 #include "tegra_pcm.h"
 #include "tegra_asoc_utils.h"
 
-#define PREFIX "ASoC Harmony: "
+#define DRV_NAME "tegra-snd-harmony"
+#define PREFIX DRV_NAME ": "
 
+static struct harmony_audio_platform_data *pdata;
 static struct platform_device *harmony_snd_device;
+static int gpio_spkr_en_requested;
 
 static int harmony_asoc_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
@@ -107,7 +117,17 @@ static struct snd_soc_ops harmony_asoc_ops = {
 	.hw_params = harmony_asoc_hw_params,
 };
 
+static int harmony_event_int_spk(struct snd_soc_dapm_widget *w,
+					struct snd_kcontrol *k, int event)
+{
+	gpio_set_value_cansleep(pdata->gpio_spkr_en,
+				!!SND_SOC_DAPM_EVENT_ON(event));
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
+	SND_SOC_DAPM_SPK("Int Spk", harmony_event_int_spk),
 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
 	SND_SOC_DAPM_MIC("Mic Jack", NULL),
 };
@@ -115,6 +135,10 @@ static const struct snd_soc_dapm_widget harmony_dapm_widgets[] = {
 static const struct snd_soc_dapm_route harmony_audio_map[] = {
 	{"Headphone Jack", NULL, "HPOUTR"},
 	{"Headphone Jack", NULL, "HPOUTL"},
+	{"Int Spk", NULL, "ROP"},
+	{"Int Spk", NULL, "RON"},
+	{"Int Spk", NULL, "LOP"},
+	{"Int Spk", NULL, "LON"},
 	{"Mic Bias", NULL, "Mic Jack"},
 	{"IN1L", NULL, "Mic Bias"},
 };
@@ -123,6 +147,7 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	int ret;
 
 	snd_soc_dapm_new_controls(dapm, harmony_dapm_widgets,
 					ARRAY_SIZE(harmony_dapm_widgets));
@@ -131,9 +156,19 @@ static int harmony_asoc_init(struct snd_soc_pcm_runtime *rtd)
 				ARRAY_SIZE(harmony_audio_map));
 
 	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
+	snd_soc_dapm_enable_pin(dapm, "Int Spk");
 	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
 	snd_soc_dapm_sync(dapm);
 
+	ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
+	if (ret) {
+		pr_err(PREFIX "cannot get spkr_en gpio\n");
+		return ret;
+	}
+	gpio_spkr_en_requested = 1;
+
+	gpio_direction_output(pdata->gpio_spkr_en, 0);
+
 	return 0;
 }
 
@@ -154,13 +189,19 @@ static struct snd_soc_card snd_soc_harmony = {
 	.num_links = 1,
 };
 
-static int __init harmony_soc_modinit(void)
+static __devinit int tegra_snd_harmony_probe(struct platform_device *pdev)
 {
 	int ret;
 
-	if (!machine_is_harmony()) {
-		pr_err(PREFIX "Not running on Tegra Harmony!\n");
-		return -ENODEV;
+	if (pdev->id != 0) {
+		dev_err(&pdev->dev, "ID %d out of range\n", pdev->id);
+		return -EINVAL;
+	}
+
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data supplied\n");
+		return -EINVAL;
 	}
 
 	ret = tegra_asoc_utils_init();
@@ -173,7 +214,7 @@ static int __init harmony_soc_modinit(void)
 	 */
 	harmony_snd_device = platform_device_alloc("soc-audio", -1);
 	if (harmony_snd_device == NULL) {
-		pr_err(PREFIX "platform_device_alloc failed\n");
+		dev_err(&pdev->dev, "platform_device_alloc failed\n");
 		ret = -ENOMEM;
 		goto err_clock_utils;
 	}
@@ -182,7 +223,7 @@ static int __init harmony_soc_modinit(void)
 
 	ret = platform_device_add(harmony_snd_device);
 	if (ret) {
-		pr_err(PREFIX "platform_device_add failed (%d)\n",
+		dev_err(&pdev->dev, "platform_device_add failed (%d)\n",
 			ret);
 		goto err_device_put;
 	}
@@ -195,15 +236,39 @@ err_clock_utils:
 	tegra_asoc_utils_fini();
 	return ret;
 }
-module_init(harmony_soc_modinit);
 
-static void __exit harmony_soc_modexit(void)
+static int __devexit tegra_snd_harmony_remove(struct platform_device *pdev)
 {
 	platform_device_unregister(harmony_snd_device);
 
+	if (gpio_spkr_en_requested)
+		gpio_free(pdata->gpio_spkr_en);
+
 	tegra_asoc_utils_fini();
+
+	return 0;
+}
+
+static struct platform_driver tegra_snd_harmony_driver = {
+	.driver = {
+		.name = DRV_NAME,
+		.owner = THIS_MODULE,
+	},
+	.probe = tegra_snd_harmony_probe,
+	.remove = __devexit_p(tegra_snd_harmony_remove),
+};
+
+static int __init snd_tegra_harmony_init(void)
+{
+	return platform_driver_register(&tegra_snd_harmony_driver);
+}
+module_init(snd_tegra_harmony_init);
+
+static void __exit snd_tegra_harmony_exit(void)
+{
+	platform_driver_unregister(&tegra_snd_harmony_driver);
 }
-module_exit(harmony_soc_modexit);
+module_exit(snd_tegra_harmony_exit);
 
 MODULE_AUTHOR("Stephen Warren <[email protected]>");
 MODULE_DESCRIPTION("Harmony machine ASoC driver");
Signature · 1 line
1.7.1