| OLD | NEW |
| 1 /* | 1 /* |
| 2 * neo1973_gta02_wm8753.c -- SoC audio for Openmoko Freerunner(GTA02) | 2 * neo1973_gta02_wm8753.c -- SoC audio for Openmoko Freerunner(GTA02) |
| 3 * | 3 * |
| 4 * Copyright 2007 Openmoko Inc | 4 * Copyright 2007 Openmoko Inc |
| 5 * Author: Graeme Gregory <graeme@openmoko.org> | 5 * Author: Graeme Gregory <graeme@openmoko.org> |
| 6 * Copyright 2007 Wolfson Microelectronics PLC. | 6 * Copyright 2007 Wolfson Microelectronics PLC. |
| 7 * Author: Graeme Gregory <linux@wolfsonmicro.com> | 7 * Author: Graeme Gregory <linux@wolfsonmicro.com> |
| 8 * Copyright 2009 Wolfson Microelectronics | 8 * Copyright 2009 Wolfson Microelectronics |
| 9 * | 9 * |
| 10 * This program is free software; you can redistribute it and/or modify it | 10 * This program is free software; you can redistribute it and/or modify it |
| 11 * under the terms of the GNU General Public License as published by the | 11 * under the terms of the GNU General Public License as published by the |
| 12 * Free Software Foundation; either version 2 of the License, or (at your | 12 * Free Software Foundation; either version 2 of the License, or (at your |
| 13 * option) any later version. | 13 * option) any later version. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #include <linux/module.h> | |
| 17 #include <linux/moduleparam.h> | |
| 18 #include <linux/timer.h> | |
| 19 #include <linux/interrupt.h> | |
| 20 #include <linux/platform_device.h> | |
| 21 #include <linux/gpio.h> | 16 #include <linux/gpio.h> |
| 22 #include <sound/core.h> | 17 |
| 23 #include <sound/pcm.h> | |
| 24 #include <sound/soc.h> | 18 #include <sound/soc.h> |
| 25 #include <sound/soc-dapm.h> | |
| 26 | 19 |
| 27 #include <asm/mach-types.h> | 20 #include <asm/mach-types.h> |
| 21 #include <plat/regs-iis.h> |
| 22 #include <mach/gta02.h> |
| 28 | 23 |
| 29 #include <plat/regs-iis.h> | |
| 30 | |
| 31 #include <mach/regs-clock.h> | |
| 32 #include <asm/io.h> | |
| 33 #include <mach/gta02.h> | |
| 34 #include "../codecs/wm8753.h" | 24 #include "../codecs/wm8753.h" |
| 35 #include "s3c-dma.h" | |
| 36 #include "s3c24xx-i2s.h" | 25 #include "s3c24xx-i2s.h" |
| 37 | 26 |
| 38 static struct snd_soc_card neo1973_gta02; | 27 static struct snd_soc_card neo1973_gta02; |
| 39 | 28 |
| 40 static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream, | 29 static int neo1973_gta02_hifi_hw_params(struct snd_pcm_substream *substream, |
| 41 struct snd_pcm_hw_params *params) | 30 struct snd_pcm_hw_params *params) |
| 42 { | 31 { |
| 43 struct snd_soc_pcm_runtime *rtd = substream->private_data; | 32 struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 44 struct snd_soc_dai *codec_dai = rtd->codec_dai; | 33 struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 45 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 34 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 lm4853_set_spk), | 315 lm4853_set_spk), |
| 327 }; | 316 }; |
| 328 | 317 |
| 329 /* | 318 /* |
| 330 * This is an example machine initialisation for a wm8753 connected to a | 319 * This is an example machine initialisation for a wm8753 connected to a |
| 331 * neo1973 GTA02. | 320 * neo1973 GTA02. |
| 332 */ | 321 */ |
| 333 static int neo1973_gta02_wm8753_init(struct snd_soc_pcm_runtime *rtd) | 322 static int neo1973_gta02_wm8753_init(struct snd_soc_pcm_runtime *rtd) |
| 334 { | 323 { |
| 335 struct snd_soc_codec *codec = rtd->codec; | 324 struct snd_soc_codec *codec = rtd->codec; |
| 325 struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 336 int err; | 326 int err; |
| 337 | 327 |
| 338 /* set up NC codec pins */ | 328 /* set up NC codec pins */ |
| 339 » snd_soc_dapm_nc_pin(codec, "OUT3"); | 329 » snd_soc_dapm_nc_pin(dapm, "OUT3"); |
| 340 » snd_soc_dapm_nc_pin(codec, "OUT4"); | 330 » snd_soc_dapm_nc_pin(dapm, "OUT4"); |
| 341 » snd_soc_dapm_nc_pin(codec, "LINE1"); | 331 » snd_soc_dapm_nc_pin(dapm, "LINE1"); |
| 342 » snd_soc_dapm_nc_pin(codec, "LINE2"); | 332 » snd_soc_dapm_nc_pin(dapm, "LINE2"); |
| 343 | 333 |
| 344 /* Add neo1973 gta02 specific widgets */ | 334 /* Add neo1973 gta02 specific widgets */ |
| 345 » snd_soc_dapm_new_controls(codec, wm8753_dapm_widgets, | 335 » snd_soc_dapm_new_controls(dapm, wm8753_dapm_widgets, |
| 346 ARRAY_SIZE(wm8753_dapm_widgets)); | 336 ARRAY_SIZE(wm8753_dapm_widgets)); |
| 347 | 337 |
| 348 /* add neo1973 gta02 specific controls */ | 338 /* add neo1973 gta02 specific controls */ |
| 349 err = snd_soc_add_controls(codec, wm8753_neo1973_gta02_controls, | 339 err = snd_soc_add_controls(codec, wm8753_neo1973_gta02_controls, |
| 350 ARRAY_SIZE(wm8753_neo1973_gta02_controls)); | 340 ARRAY_SIZE(wm8753_neo1973_gta02_controls)); |
| 351 | 341 |
| 352 if (err < 0) | 342 if (err < 0) |
| 353 return err; | 343 return err; |
| 354 | 344 |
| 355 /* set up neo1973 gta02 specific audio path audio_map */ | 345 /* set up neo1973 gta02 specific audio path audio_map */ |
| 356 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | 346 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
| 357 | 347 |
| 358 /* set endpoints to default off mode */ | 348 /* set endpoints to default off mode */ |
| 359 » snd_soc_dapm_disable_pin(codec, "Stereo Out"); | 349 » snd_soc_dapm_disable_pin(dapm, "Stereo Out"); |
| 360 » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); | 350 » snd_soc_dapm_disable_pin(dapm, "GSM Line Out"); |
| 361 » snd_soc_dapm_disable_pin(codec, "GSM Line In"); | 351 » snd_soc_dapm_disable_pin(dapm, "GSM Line In"); |
| 362 » snd_soc_dapm_disable_pin(codec, "Headset Mic"); | 352 » snd_soc_dapm_disable_pin(dapm, "Headset Mic"); |
| 363 » snd_soc_dapm_disable_pin(codec, "Handset Mic"); | 353 » snd_soc_dapm_disable_pin(dapm, "Handset Mic"); |
| 364 » snd_soc_dapm_disable_pin(codec, "Handset Spk"); | 354 » snd_soc_dapm_disable_pin(dapm, "Handset Spk"); |
| 365 | 355 |
| 366 /* allow audio paths from the GSM modem to run during suspend */ | 356 /* allow audio paths from the GSM modem to run during suspend */ |
| 367 » snd_soc_dapm_ignore_suspend(codec, "Stereo Out"); | 357 » snd_soc_dapm_ignore_suspend(dapm, "Stereo Out"); |
| 368 » snd_soc_dapm_ignore_suspend(codec, "GSM Line Out"); | 358 » snd_soc_dapm_ignore_suspend(dapm, "GSM Line Out"); |
| 369 » snd_soc_dapm_ignore_suspend(codec, "GSM Line In"); | 359 » snd_soc_dapm_ignore_suspend(dapm, "GSM Line In"); |
| 370 » snd_soc_dapm_ignore_suspend(codec, "Headset Mic"); | 360 » snd_soc_dapm_ignore_suspend(dapm, "Headset Mic"); |
| 371 » snd_soc_dapm_ignore_suspend(codec, "Handset Mic"); | 361 » snd_soc_dapm_ignore_suspend(dapm, "Handset Mic"); |
| 372 » snd_soc_dapm_ignore_suspend(codec, "Handset Spk"); | 362 » snd_soc_dapm_ignore_suspend(dapm, "Handset Spk"); |
| 373 | 363 |
| 374 » snd_soc_dapm_sync(codec); | 364 » snd_soc_dapm_sync(dapm); |
| 375 | 365 |
| 376 return 0; | 366 return 0; |
| 377 } | 367 } |
| 378 | 368 |
| 379 /* | 369 /* |
| 380 * BT Codec DAI | 370 * BT Codec DAI |
| 381 */ | 371 */ |
| 382 static struct snd_soc_dai_driver bt_dai = { | 372 static struct snd_soc_dai_driver bt_dai = { |
| 383 .name = "bluetooth-dai", | 373 .name = "bluetooth-dai", |
| 384 .playback = { | 374 .playback = { |
| 385 .channels_min = 1, | 375 .channels_min = 1, |
| 386 .channels_max = 1, | 376 .channels_max = 1, |
| 387 .rates = SNDRV_PCM_RATE_8000, | 377 .rates = SNDRV_PCM_RATE_8000, |
| 388 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 378 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
| 389 .capture = { | 379 .capture = { |
| 390 .channels_min = 1, | 380 .channels_min = 1, |
| 391 .channels_max = 1, | 381 .channels_max = 1, |
| 392 .rates = SNDRV_PCM_RATE_8000, | 382 .rates = SNDRV_PCM_RATE_8000, |
| 393 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | 383 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, |
| 394 }; | 384 }; |
| 395 | 385 |
| 396 static struct snd_soc_dai_link neo1973_gta02_dai[] = { | 386 static struct snd_soc_dai_link neo1973_gta02_dai[] = { |
| 397 { /* Hifi Playback - for similatious use with voice below */ | 387 { /* Hifi Playback - for similatious use with voice below */ |
| 398 .name = "WM8753", | 388 .name = "WM8753", |
| 399 .stream_name = "WM8753 HiFi", | 389 .stream_name = "WM8753 HiFi", |
| 400 » .cpu_dai_name = "s3c24xx-i2s", | 390 » .cpu_dai_name = "s3c24xx-iis", |
| 401 .codec_dai_name = "wm8753-hifi", | 391 .codec_dai_name = "wm8753-hifi", |
| 402 .init = neo1973_gta02_wm8753_init, | 392 .init = neo1973_gta02_wm8753_init, |
| 403 » .platform_name = "s3c24xx-pcm-audio", | 393 » .platform_name = "samsung-audio", |
| 404 » .codec_name = "wm8753-codec.0-0x1a", | 394 » .codec_name = "wm8753-codec.0-001a", |
| 405 .ops = &neo1973_gta02_hifi_ops, | 395 .ops = &neo1973_gta02_hifi_ops, |
| 406 }, | 396 }, |
| 407 { /* Voice via BT */ | 397 { /* Voice via BT */ |
| 408 .name = "Bluetooth", | 398 .name = "Bluetooth", |
| 409 .stream_name = "Voice", | 399 .stream_name = "Voice", |
| 410 .cpu_dai_name = "bluetooth-dai", | 400 .cpu_dai_name = "bluetooth-dai", |
| 411 .codec_dai_name = "wm8753-voice", | 401 .codec_dai_name = "wm8753-voice", |
| 412 .ops = &neo1973_gta02_voice_ops, | 402 .ops = &neo1973_gta02_voice_ops, |
| 413 » .codec_name = "wm8753-codec.0-0x1a", | 403 » .codec_name = "wm8753-codec.0-001a", |
| 414 » .platform_name = "s3c24xx-pcm-audio", | 404 » .platform_name = "samsung-audio", |
| 415 }, | 405 }, |
| 416 }; | 406 }; |
| 417 | 407 |
| 418 static struct snd_soc_card neo1973_gta02 = { | 408 static struct snd_soc_card neo1973_gta02 = { |
| 419 .name = "neo1973-gta02", | 409 .name = "neo1973-gta02", |
| 420 .dai_link = neo1973_gta02_dai, | 410 .dai_link = neo1973_gta02_dai, |
| 421 .num_links = ARRAY_SIZE(neo1973_gta02_dai), | 411 .num_links = ARRAY_SIZE(neo1973_gta02_dai), |
| 422 }; | 412 }; |
| 423 | 413 |
| 424 static struct platform_device *neo1973_gta02_snd_device; | 414 static struct platform_device *neo1973_gta02_snd_device; |
| 425 | 415 |
| 426 static int __init neo1973_gta02_init(void) | 416 static int __init neo1973_gta02_init(void) |
| 427 { | 417 { |
| 428 int ret; | 418 int ret; |
| 429 | 419 |
| 430 if (!machine_is_neo1973_gta02()) { | 420 if (!machine_is_neo1973_gta02()) { |
| 431 printk(KERN_INFO | 421 printk(KERN_INFO |
| 432 "Only GTA02 is supported by this ASoC driver\n"); | 422 "Only GTA02 is supported by this ASoC driver\n"); |
| 433 return -ENODEV; | 423 return -ENODEV; |
| 434 } | 424 } |
| 435 | 425 |
| 436 neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1); | 426 neo1973_gta02_snd_device = platform_device_alloc("soc-audio", -1); |
| 437 if (!neo1973_gta02_snd_device) | 427 if (!neo1973_gta02_snd_device) |
| 438 return -ENOMEM; | 428 return -ENOMEM; |
| 439 | 429 |
| 440 /* register bluetooth DAI here */ | 430 /* register bluetooth DAI here */ |
| 441 » ret = snd_soc_register_dai(&neo1973_gta02_snd_device->dev, -1, &bt_dai); | 431 » ret = snd_soc_register_dai(&neo1973_gta02_snd_device->dev, &bt_dai); |
| 442 » if (ret) { | 432 » if (ret) |
| 443 » » platform_device_put(neo1973_gta02_snd_device); | 433 » » goto err_put_device; |
| 444 » » return ret; | |
| 445 » } | |
| 446 | 434 |
| 447 platform_set_drvdata(neo1973_gta02_snd_device, &neo1973_gta02); | 435 platform_set_drvdata(neo1973_gta02_snd_device, &neo1973_gta02); |
| 448 ret = platform_device_add(neo1973_gta02_snd_device); | 436 ret = platform_device_add(neo1973_gta02_snd_device); |
| 449 | 437 |
| 450 » if (ret) { | 438 » if (ret) |
| 451 » » platform_device_put(neo1973_gta02_snd_device); | 439 » » goto err_unregister_dai; |
| 452 » » return ret; | |
| 453 » } | |
| 454 | 440 |
| 455 /* Initialise GPIOs used by amp */ | 441 /* Initialise GPIOs used by amp */ |
| 456 ret = gpio_request(GTA02_GPIO_HP_IN, "GTA02_HP_IN"); | 442 ret = gpio_request(GTA02_GPIO_HP_IN, "GTA02_HP_IN"); |
| 457 if (ret) { | 443 if (ret) { |
| 458 pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_
HP_IN); | 444 pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_
HP_IN); |
| 459 » » goto err_unregister_device; | 445 » » goto err_del_device; |
| 460 } | 446 } |
| 461 | 447 |
| 462 ret = gpio_direction_output(GTA02_GPIO_HP_IN, 1); | 448 ret = gpio_direction_output(GTA02_GPIO_HP_IN, 1); |
| 463 if (ret) { | 449 if (ret) { |
| 464 pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO
_HP_IN); | 450 pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO
_HP_IN); |
| 465 goto err_free_gpio_hp_in; | 451 goto err_free_gpio_hp_in; |
| 466 } | 452 } |
| 467 | 453 |
| 468 ret = gpio_request(GTA02_GPIO_AMP_SHUT, "GTA02_AMP_SHUT"); | 454 ret = gpio_request(GTA02_GPIO_AMP_SHUT, "GTA02_AMP_SHUT"); |
| 469 if (ret) { | 455 if (ret) { |
| 470 pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_
AMP_SHUT); | 456 pr_err("gta02_wm8753: Failed to register GPIO %d\n", GTA02_GPIO_
AMP_SHUT); |
| 471 goto err_free_gpio_hp_in; | 457 goto err_free_gpio_hp_in; |
| 472 } | 458 } |
| 473 | 459 |
| 474 ret = gpio_direction_output(GTA02_GPIO_AMP_SHUT, 1); | 460 ret = gpio_direction_output(GTA02_GPIO_AMP_SHUT, 1); |
| 475 if (ret) { | 461 if (ret) { |
| 476 pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO
_AMP_SHUT); | 462 pr_err("gta02_wm8753: Failed to configure GPIO %d\n", GTA02_GPIO
_AMP_SHUT); |
| 477 goto err_free_gpio_amp_shut; | 463 goto err_free_gpio_amp_shut; |
| 478 } | 464 } |
| 479 | 465 |
| 480 return 0; | 466 return 0; |
| 481 | 467 |
| 482 err_free_gpio_amp_shut: | 468 err_free_gpio_amp_shut: |
| 483 gpio_free(GTA02_GPIO_AMP_SHUT); | 469 gpio_free(GTA02_GPIO_AMP_SHUT); |
| 484 err_free_gpio_hp_in: | 470 err_free_gpio_hp_in: |
| 485 gpio_free(GTA02_GPIO_HP_IN); | 471 gpio_free(GTA02_GPIO_HP_IN); |
| 486 err_unregister_device: | 472 err_del_device: |
| 487 » platform_device_unregister(neo1973_gta02_snd_device); | 473 » platform_device_del(neo1973_gta02_snd_device); |
| 474 err_unregister_dai: |
| 475 » snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); |
| 476 err_put_device: |
| 477 » platform_device_put(neo1973_gta02_snd_device); |
| 488 return ret; | 478 return ret; |
| 489 } | 479 } |
| 490 module_init(neo1973_gta02_init); | 480 module_init(neo1973_gta02_init); |
| 491 | 481 |
| 492 static void __exit neo1973_gta02_exit(void) | 482 static void __exit neo1973_gta02_exit(void) |
| 493 { | 483 { |
| 494 » snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev, -1); | 484 » snd_soc_unregister_dai(&neo1973_gta02_snd_device->dev); |
| 495 platform_device_unregister(neo1973_gta02_snd_device); | 485 platform_device_unregister(neo1973_gta02_snd_device); |
| 496 gpio_free(GTA02_GPIO_HP_IN); | 486 gpio_free(GTA02_GPIO_HP_IN); |
| 497 gpio_free(GTA02_GPIO_AMP_SHUT); | 487 gpio_free(GTA02_GPIO_AMP_SHUT); |
| 498 } | 488 } |
| 499 module_exit(neo1973_gta02_exit); | 489 module_exit(neo1973_gta02_exit); |
| 500 | 490 |
| 501 /* Module information */ | 491 /* Module information */ |
| 502 MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org"); | 492 MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org"); |
| 503 MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 GTA02"); | 493 MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973 GTA02"); |
| 504 MODULE_LICENSE("GPL"); | 494 MODULE_LICENSE("GPL"); |
| OLD | NEW |