sh7760-ac97.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Generic AC97 sound support for SH7760
  3. *
  4. * (c) 2007 Manuel Lauss
  5. *
  6. * Licensed under the GPLv2.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/moduleparam.h>
  10. #include <linux/platform_device.h>
  11. #include <sound/core.h>
  12. #include <sound/pcm.h>
  13. #include <sound/soc.h>
  14. #include <sound/soc-dapm.h>
  15. #include <asm/io.h>
  16. #define IPSEL 0xFE400034
  17. /* platform specific structs can be declared here */
  18. extern struct snd_soc_dai_driver sh4_hac_dai[2];
  19. extern struct snd_soc_platform_driver sh7760_soc_platform;
  20. static int machine_init(struct snd_soc_pcm_runtime *rtd)
  21. {
  22. snd_soc_dapm_sync(rtd->codec);
  23. return 0;
  24. }
  25. static struct snd_soc_dai_link sh7760_ac97_dai = {
  26. .name = "AC97",
  27. .stream_name = "AC97 HiFi",
  28. .cpu_dai_name = "hac-dai.0", /* HAC0 */
  29. .codec_dai_name = "ac97-hifi",
  30. .platform_name = "sh7760-pcm-audio",
  31. .codec_name = "ac97-codec",
  32. .init = machine_init,
  33. .ops = NULL,
  34. };
  35. static struct snd_soc_card sh7760_ac97_soc_machine = {
  36. .name = "SH7760 AC97",
  37. .dai_link = &sh7760_ac97_dai,
  38. .num_links = 1,
  39. };
  40. static struct platform_device *sh7760_ac97_snd_device;
  41. static int __init sh7760_ac97_init(void)
  42. {
  43. int ret;
  44. unsigned short ipsel;
  45. /* enable both AC97 controllers in pinmux reg */
  46. ipsel = __raw_readw(IPSEL);
  47. __raw_writew(ipsel | (3 << 10), IPSEL);
  48. ret = -ENOMEM;
  49. sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
  50. if (!sh7760_ac97_snd_device)
  51. goto out;
  52. platform_set_drvdata(sh7760_ac97_snd_device,
  53. &sh7760_ac97_soc_machine);
  54. ret = platform_device_add(sh7760_ac97_snd_device);
  55. if (ret)
  56. platform_device_put(sh7760_ac97_snd_device);
  57. out:
  58. return ret;
  59. }
  60. static void __exit sh7760_ac97_exit(void)
  61. {
  62. platform_device_unregister(sh7760_ac97_snd_device);
  63. }
  64. module_init(sh7760_ac97_init);
  65. module_exit(sh7760_ac97_exit);
  66. MODULE_LICENSE("GPL");
  67. MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
  68. MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");