aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/atmel
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-16 15:49:16 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-18 06:55:22 -0500
commit5998102b9095fdb7c67755812038612afea315c5 (patch)
tree9b536a80336f526d7a7d206d272527f6789e449e /sound/soc/atmel
parenta8035c8f04477895207b92915b908344749be336 (diff)
ASoC: Refactor WM8731 device registration
Move the WM8731 driver to use a more standard device registration scheme where the device can be registered independantly of the ASoC probe. As a transition measure push the current manual code for registering the WM8731 into the individual machine driver probes. This allows separate patches to update the relevant architecture files with less risk of merge issues. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/atmel')
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index aa524235fd98..173a239a541c 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -36,6 +36,7 @@
36#include <linux/timer.h> 36#include <linux/timer.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/i2c.h>
39 40
40#include <linux/atmel-ssc.h> 41#include <linux/atmel-ssc.h>
41 42
@@ -280,15 +281,41 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
280 .set_bias_level = at91sam9g20ek_set_bias_level, 281 .set_bias_level = at91sam9g20ek_set_bias_level,
281}; 282};
282 283
283static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = { 284/*
284 .i2c_bus = 0, 285 * FIXME: This is a temporary bodge to avoid cross-tree merge issues.
285 .i2c_address = 0x1b, 286 * New drivers should register the wm8731 I2C device in the machine
286}; 287 * setup code (under arch/arm for ARM systems).
288 */
289static int wm8731_i2c_register(void)
290{
291 struct i2c_board_info info;
292 struct i2c_adapter *adapter;
293 struct i2c_client *client;
294
295 memset(&info, 0, sizeof(struct i2c_board_info));
296 info.addr = 0x1b;
297 strlcpy(info.type, "wm8731", I2C_NAME_SIZE);
298
299 adapter = i2c_get_adapter(0);
300 if (!adapter) {
301 printk(KERN_ERR "can't get i2c adapter 0\n");
302 return -ENODEV;
303 }
304
305 client = i2c_new_device(adapter, &info);
306 i2c_put_adapter(adapter);
307 if (!client) {
308 printk(KERN_ERR "can't add i2c device at 0x%x\n",
309 (unsigned int)info.addr);
310 return -ENODEV;
311 }
312
313 return 0;
314}
287 315
288static struct snd_soc_device at91sam9g20ek_snd_devdata = { 316static struct snd_soc_device at91sam9g20ek_snd_devdata = {
289 .card = &snd_soc_at91sam9g20ek, 317 .card = &snd_soc_at91sam9g20ek,
290 .codec_dev = &soc_codec_dev_wm8731, 318 .codec_dev = &soc_codec_dev_wm8731,
291 .codec_data = &at91sam9g20ek_wm8731_setup,
292}; 319};
293 320
294static struct platform_device *at91sam9g20ek_snd_device; 321static struct platform_device *at91sam9g20ek_snd_device;
@@ -340,6 +367,10 @@ static int __init at91sam9g20ek_init(void)
340 } 367 }
341 ssc_p->ssc = ssc; 368 ssc_p->ssc = ssc;
342 369
370 ret = wm8731_i2c_register();
371 if (ret != 0)
372 goto err_ssc;
373
343 at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); 374 at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1);
344 if (!at91sam9g20ek_snd_device) { 375 if (!at91sam9g20ek_snd_device) {
345 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 376 printk(KERN_ERR "ASoC: Platform device allocation failed\n");
@@ -359,6 +390,8 @@ static int __init at91sam9g20ek_init(void)
359 return ret; 390 return ret;
360 391
361err_ssc: 392err_ssc:
393 ssc_free(ssc);
394 ssc_p->ssc = NULL;
362err_mclk: 395err_mclk:
363 clk_put(mclk); 396 clk_put(mclk);
364 mclk = NULL; 397 mclk = NULL;