[alsa-devel] [PATCH 0/3] Convert to use snd_soc_register_card()
Convert to use snd_soc_register_card(), and enable it
Change the id for the gpio i2c to let it work
Bo Shen (3): ASoC: sam9g20-wm8731: convert to use snd_soc_register_card() ASoC: sam9g20: using platform device for audio part i2c: change the id to let the i2c-gpio work
arch/arm/mach-at91/at91sam9260_devices.c | 11 ++++++- arch/arm/mach-at91/board-sam9g20ek.c | 17 ++++++++++ sound/soc/atmel/sam9g20_wm8731.c | 51 +++++++++++++----------------- 3 files changed, 49 insertions(+), 30 deletions(-)
Signed-off-by: Bo Shen voice.shen@atmel.com --- sound/soc/atmel/sam9g20_wm8731.c | 51 ++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index c883514..e5e27db 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -195,22 +195,15 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { .set_bias_level = at91sam9g20ek_set_bias_level, };
-static struct platform_device *at91sam9g20ek_snd_device; - -static int __init at91sam9g20ek_init(void) +static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev) { struct clk *pllb; + struct snd_soc_card *card = &snd_soc_at91sam9g20ek; int ret;
if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) return -ENODEV;
- ret = atmel_ssc_set_audio(0); - if (ret != 0) { - pr_err("Failed to set SSC 0 for audio: %d\n", ret); - return ret; - } - /* * Codec MCLK is supplied by PCK0 - set it up. */ @@ -236,26 +229,14 @@ static int __init at91sam9g20ek_init(void)
clk_set_rate(mclk, MCLK_RATE);
- at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); - if (!at91sam9g20ek_snd_device) { - printk(KERN_ERR "ASoC: Platform device allocation failed\n"); - ret = -ENOMEM; - goto err_mclk; - } - - platform_set_drvdata(at91sam9g20ek_snd_device, - &snd_soc_at91sam9g20ek); - - ret = platform_device_add(at91sam9g20ek_snd_device); + card->dev = &pdev->dev; + ret = snd_soc_register_card(card); if (ret) { - printk(KERN_ERR "ASoC: Platform device allocation failed\n"); - goto err_device_add; + printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n"); }
return ret;
-err_device_add: - platform_device_put(at91sam9g20ek_snd_device); err_mclk: clk_put(mclk); mclk = NULL; @@ -263,18 +244,30 @@ err: return ret; }
-static void __exit at91sam9g20ek_exit(void) +static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev) { - platform_device_unregister(at91sam9g20ek_snd_device); - at91sam9g20ek_snd_device = NULL; + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); clk_put(mclk); mclk = NULL; + + return 0; }
-module_init(at91sam9g20ek_init); -module_exit(at91sam9g20ek_exit); +static struct platform_driver at91sam9g20ek_audio_driver = { + .driver = { + .name = "at91sam9g20ek-audio", + .owner = THIS_MODULE, + }, + .probe = at91sam9g20ek_audio_probe, + .remove = __devexit_p(at91sam9g20ek_audio_remove), +}; + +module_platform_driver(at91sam9g20ek_audio_driver);
/* Module information */ MODULE_AUTHOR("Sedji Gaouaou sedji.gaouaou@atmel.com"); MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731"); +MODULE_ALIAS("platform:at91sam9g20ek-audio"); MODULE_LICENSE("GPL");
On Thu, Oct 11, 2012 at 10:38:15AM +0800, Bo Shen wrote:
Signed-off-by: Bo Shen voice.shen@atmel.com
Applied, thanks.
Signed-off-by: Bo Shen voice.shen@atmel.com --- arch/arm/mach-at91/at91sam9260_devices.c | 9 +++++++++ arch/arm/mach-at91/board-sam9g20ek.c | 17 +++++++++++++++++ 2 files changed, 26 insertions(+)
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index a76b868..0f24cfb 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -768,6 +768,14 @@ static inline void configure_ssc_pins(unsigned pins) at91_set_A_periph(AT91_PIN_PB21, 1); }
+static struct platform_device at91sam9260_ssc_dai_device = { + .name = "atmel-ssc-dai", + .id = 0, + .dev = { + .parent = &(at91sam9260_ssc_device.dev), + }, +}; + /* * SSC controllers are accessed through library code, instead of any * kind of all-singing/all-dancing driver. For example one could be @@ -792,6 +800,7 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) }
platform_device_register(pdev); + platform_device_register(&at91sam9260_ssc_dai_device); }
#else diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c index 3ab2b86..5b6a6f9 100644 --- a/arch/arm/mach-at91/board-sam9g20ek.c +++ b/arch/arm/mach-at91/board-sam9g20ek.c @@ -353,6 +353,22 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = { }, };
+static struct platform_device sam9g20ek_pcm_device = { + .name = "atmel-pcm-audio", + .id = -1, +}; + +static struct platform_device sam9g20ek_audio_device = { + .name = "at91sam9g20ek-audio", + .id = -1, +}; + +static void __init ek_add_device_audio(void) +{ + platform_device_register(&sam9g20ek_pcm_device); + platform_device_register(&sam9g20ek_audio_device); +} +
static void __init ek_board_init(void) { @@ -394,6 +410,7 @@ static void __init ek_board_init(void) at91_set_B_periph(AT91_PIN_PC1, 0); /* SSC (for WM8731) */ at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); + ek_add_device_audio(); }
MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
On Thu, Oct 11, 2012 at 10:38:16AM +0800, Bo Shen wrote:
Signed-off-by: Bo Shen voice.shen@atmel.com
Applied, thanks.
Signed-off-by: Bo Shen voice.shen@atmel.com --- arch/arm/mach-at91/at91sam9260_devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 0f24cfb..805ef95 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
static struct platform_device at91sam9260_twi_device = { .name = "i2c-gpio", - .id = -1, + .id = 0, .dev.platform_data = &pdata, };
On Thu, Oct 11, 2012 at 10:38:17AM +0800, Bo Shen wrote:
static struct platform_device at91sam9260_twi_device = { .name = "i2c-gpio",
- .id = -1,
- .id = 0, .dev.platform_data = &pdata,
};
Why would this have any effect on the operation of the i2c-gpio driver? This suggests i2c-gpio is buggy.
Hi Mark,
On 10/11/2012 15:11, Mark Brown wrote:
On Thu, Oct 11, 2012 at 10:38:17AM +0800, Bo Shen wrote:
static struct platform_device at91sam9260_twi_device = { .name = "i2c-gpio",
- .id = -1,
- .id = 0, .dev.platform_data = &pdata, };
Why would this have any effect on the operation of the i2c-gpio driver? This suggests i2c-gpio is buggy.
This cause i2c devices can not register to the i2c bus which the device want.
I will send this patch to i2c maintainer.
Thanks
BR, Bo Shen
participants (2)
-
Bo Shen
-
Mark Brown