[PATCH] General fix for Palm27x aSoC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Firstly, this patch makes the palm27x asoc driver a little more sane. Also,
since all affected devices use GPIO95 as AC97_nRESET, this patch sets that
properly. Affected are PalmT5, TX and LifeDrive.

Please consider applying, it's against Russells tree. If Eric wants to merge 
it, I can remake it.

Thanks.
From 0b12db7ca6b45bd3fd74a89c58a754a30dd84960 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@xxxxxxxxx>
Date: Sun, 12 Apr 2009 18:50:01 +0200
Subject: [PATCH] General fix for Palm27x aSoC driver

Firstly, this patch makes the palm27x asoc driver a little more sane. Also,
since all affected devices use GPIO95 as AC97_nRESET, this patch sets that
properly. Affected are PalmT5, TX and LifeDrive.

Signed-off-by: Marek Vasut <marek.vasut@xxxxxxxxx>
---
 arch/arm/mach-pxa/include/mach/palmasoc.h |    7 +---
 arch/arm/mach-pxa/palmld.c                |   43 ++++++++++++++++++++++++--
 arch/arm/mach-pxa/palmt5.c                |   43 ++++++++++++++++++++++++--
 arch/arm/mach-pxa/palmtx.c                |   48 ++++++++++++++++++++++++++++-
 sound/soc/pxa/palm27x.c                   |   27 ++++++++++++++--
 5 files changed, 151 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/palmasoc.h b/arch/arm/mach-pxa/include/mach/palmasoc.h
index 6c4b1f7..58afb30 100644
--- a/arch/arm/mach-pxa/include/mach/palmasoc.h
+++ b/arch/arm/mach-pxa/include/mach/palmasoc.h
@@ -1,13 +1,8 @@
 #ifndef _INCLUDE_PALMASOC_H_
 #define _INCLUDE_PALMASOC_H_
+
 struct palm27x_asoc_info {
 	int	jack_gpio;
 };
 
-#ifdef CONFIG_SND_PXA2XX_SOC_PALM27X
-void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data);
-#else
-static inline void palm27x_asoc_set_pdata(struct palm27x_asoc_info *data) {}
-#endif
-
 #endif
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 8587477..a34840a 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -38,6 +38,8 @@
 #include <mach/pxa27x_keypad.h>
 #include <mach/palmasoc.h>
 
+#include <sound/pxa2xx-lib.h>
+
 #include "generic.h"
 #include "devices.h"
 
@@ -476,10 +478,43 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 /******************************************************************************
  * aSoC audio
  ******************************************************************************/
-static struct palm27x_asoc_info palm27x_asoc_pdata = {
+static struct palm27x_asoc_info palmld_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
+static struct pxa2xx_ac97_platform_data palmld_ac97_pdata = {
+	.reset_gpio	= 95,
+};
+
+static struct platform_device palmld_pxa2xx_pcm = {
+	.name = "pxa2xx-pcm",
+	.id   = -1,
+};
+
+static struct platform_device palmld_pxa2xx_ac97 = {
+	.name = "pxa2xx-ac97",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmld_ac97_pdata,
+	},
+};
+
+static struct platform_device palmld_wm9712_codec = {
+	.name = "wm9712-codec",
+	.id   = -1,
+	.dev  = {
+		.parent		= &palmld_pxa2xx_ac97.dev,
+	},
+};
+
+static struct platform_device palmld_asoc = {
+	.name = "palm27x-asoc",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmld_asoc_pdata,
+	},
+};
+
 /******************************************************************************
  * Framebuffer
  ******************************************************************************/
@@ -516,6 +551,10 @@ static struct platform_device *devices[] __initdata = {
 	&palmld_backlight,
 	&palmld_leds,
 	&power_supply,
+	&palmld_pxa2xx_pcm,
+	&palmld_pxa2xx_ac97,
+	&palmld_wm9712_codec,
+	&palmld_asoc,
 };
 
 static struct map_desc palmld_io_desc[] __initdata = {
@@ -545,11 +584,9 @@ static void __init palmld_init(void)
 
 	set_pxa_fb_info(&palmld_lcd_screen);
 	pxa_set_mci_info(&palmld_mci_platform_data);
-	pxa_set_ac97_info(NULL);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
 	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
-	palm27x_asoc_set_pdata(&palm27x_asoc_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 9f591cf..74e590b 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -41,6 +41,8 @@
 #include <mach/udc.h>
 #include <mach/palmasoc.h>
 
+#include <sound/pxa2xx-lib.h>
+
 #include "generic.h"
 #include "devices.h"
 
@@ -420,10 +422,43 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 /******************************************************************************
  * aSoC audio
  ******************************************************************************/
-static struct palm27x_asoc_info palm27x_asoc_pdata = {
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
+static struct pxa2xx_ac97_platform_data palmt5_ac97_pdata = {
+	.reset_gpio	= 95,
+};
+
+static struct platform_device palmt5_pxa2xx_pcm = {
+	.name = "pxa2xx-pcm",
+	.id   = -1,
+};
+
+static struct platform_device palmt5_pxa2xx_ac97 = {
+	.name = "pxa2xx-ac97",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmt5_ac97_pdata,
+	},
+};
+
+static struct platform_device palmt5_wm9712_codec = {
+	.name = "wm9712-codec",
+	.id   = -1,
+	.dev  = {
+		.parent		= &palmt5_pxa2xx_ac97.dev,
+	},
+};
+
+static struct platform_device palmt5_asoc = {
+	.name = "palm27x-asoc",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmt5_asoc_pdata,
+	},
+};
+
 /******************************************************************************
  * Framebuffer
  ******************************************************************************/
@@ -459,6 +494,10 @@ static struct platform_device *devices[] __initdata = {
 #endif
 	&palmt5_backlight,
 	&power_supply,
+	&palmt5_pxa2xx_pcm,
+	&palmt5_pxa2xx_ac97,
+	&palmt5_wm9712_codec,
+	&palmt5_asoc,
 };
 
 /* setup udc GPIOs initial state */
@@ -478,11 +517,9 @@ static void __init palmt5_init(void)
 	pxa_set_mci_info(&palmt5_mci_platform_data);
 	palmt5_udc_init();
 	pxa_set_udc_info(&palmt5_udc_info);
-	pxa_set_ac97_info(NULL);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
 	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
-	palm27x_asoc_set_pdata(&palm27x_asoc_pdata);
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 540cd69..fb651d1 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -40,6 +40,9 @@
 #include <mach/irda.h>
 #include <mach/pxa27x_keypad.h>
 #include <mach/udc.h>
+#include <mach/palmasoc.h>
+
+#include <sound/pxa2xx-lib.h>
 
 #include "generic.h"
 #include "devices.h"
@@ -434,6 +437,46 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 };
 
 /******************************************************************************
+ * aSoC audio
+ ******************************************************************************/
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+};
+
+static struct pxa2xx_ac97_platform_data palmtx_ac97_pdata = {
+	.reset_gpio	= 95,
+};
+
+static struct platform_device palmtx_pxa2xx_pcm = {
+	.name = "pxa2xx-pcm",
+	.id   = -1,
+};
+
+static struct platform_device palmtx_pxa2xx_ac97 = {
+	.name = "pxa2xx-ac97",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmtx_ac97_pdata,
+	},
+};
+
+static struct platform_device palmtx_wm9712_codec = {
+	.name = "wm9712-codec",
+	.id   = -1,
+	.dev  = {
+		.parent		= &palmtx_pxa2xx_ac97.dev,
+	},
+};
+
+static struct platform_device palmtx_asoc = {
+	.name = "palm27x-asoc",
+	.id   = -1,
+	.dev  = {
+		.platform_data = &palmtx_asoc_pdata,
+	},
+};
+
+/******************************************************************************
  * Framebuffer
  ******************************************************************************/
 static struct pxafb_mode_info palmtx_lcd_modes[] = {
@@ -468,6 +511,10 @@ static struct platform_device *devices[] __initdata = {
 #endif
 	&palmtx_backlight,
 	&power_supply,
+	&palmtx_pxa2xx_pcm,
+	&palmtx_pxa2xx_ac97,
+	&palmtx_wm9712_codec,
+	&palmtx_asoc,
 };
 
 static struct map_desc palmtx_io_desc[] __initdata = {
@@ -503,7 +550,6 @@ static void __init palmtx_init(void)
 	pxa_set_mci_info(&palmtx_mci_platform_data);
 	palmtx_udc_init();
 	pxa_set_udc_info(&palmtx_udc_info);
-	pxa_set_ac97_info(NULL);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
 	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
index 48a73f6..44fcc4e 100644
--- a/sound/soc/pxa/palm27x.c
+++ b/sound/soc/pxa/palm27x.c
@@ -200,7 +200,7 @@ static struct snd_soc_device palm27x_snd_devdata = {
 
 static struct platform_device *palm27x_snd_device;
 
-static int __init palm27x_asoc_init(void)
+static int palm27x_asoc_probe(struct platform_device *pdev)
 {
 	int ret;
 
@@ -208,6 +208,10 @@ static int __init palm27x_asoc_init(void)
 		machine_is_palmld()))
 		return -ENODEV;
 
+	if (pdev->dev.platform_data)
+		palm27x_ep_gpio = ((struct palm27x_asoc_info *)
+			(pdev->dev.platform_data))->jack_gpio;
+
 	ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
 	if (ret)
 		return ret;
@@ -245,16 +249,31 @@ err_alloc:
 	return ret;
 }
 
-static void __exit palm27x_asoc_exit(void)
+static int __devexit palm27x_asoc_remove(struct platform_device *pdev)
 {
 	free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
 	gpio_free(palm27x_ep_gpio);
 	platform_device_unregister(palm27x_snd_device);
+	return 0;
 }
 
-void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data)
+static struct platform_driver palm27x_wm9712_driver = {
+	.probe		= palm27x_asoc_probe,
+	.remove		= __devexit_p(palm27x_asoc_remove),
+	.driver		= {
+		.name		= "palm27x-asoc",
+		.owner		= THIS_MODULE,
+	},
+};
+
+static int __init palm27x_asoc_init(void)
+{
+	return platform_driver_register(&palm27x_wm9712_driver);
+}
+
+static void __exit palm27x_asoc_exit(void)
 {
-	palm27x_ep_gpio = data->jack_gpio;
+	platform_driver_unregister(&palm27x_wm9712_driver);
 }
 
 module_init(palm27x_asoc_init);
-- 
1.6.2

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux