sh7760-ac97.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <asm/io.h>
  15. #define IPSEL 0xFE400034
  16. static struct snd_soc_dai_link sh7760_ac97_dai = {
  17. .name = "AC97",
  18. .stream_name = "AC97 HiFi",
  19. .cpu_dai_name = "hac-dai.0", /* HAC0 */
  20. .codec_dai_name = "ac97-hifi",
  21. .platform_name = "sh7760-pcm-audio",
  22. .codec_name = "ac97-codec",
  23. .ops = NULL,
  24. };
  25. static struct snd_soc_card sh7760_ac97_soc_machine = {
  26. .name = "SH7760 AC97",
  27. .owner = THIS_MODULE,
  28. .dai_link = &sh7760_ac97_dai,
  29. .num_links = 1,
  30. };
  31. static struct platform_device *sh7760_ac97_snd_device;
  32. static int __init sh7760_ac97_init(void)
  33. {
  34. int ret;
  35. unsigned short ipsel;
  36. /* enable both AC97 controllers in pinmux reg */
  37. ipsel = __raw_readw(IPSEL);
  38. __raw_writew(ipsel | (3 << 10), IPSEL);
  39. ret = -ENOMEM;
  40. sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
  41. if (!sh7760_ac97_snd_device)
  42. goto out;
  43. platform_set_drvdata(sh7760_ac97_snd_device,
  44. &sh7760_ac97_soc_machine);
  45. ret = platform_device_add(sh7760_ac97_snd_device);
  46. if (ret)
  47. platform_device_put(sh7760_ac97_snd_device);
  48. out:
  49. return ret;
  50. }
  51. static void __exit sh7760_ac97_exit(void)
  52. {
  53. platform_device_unregister(sh7760_ac97_snd_device);
  54. }
  55. module_init(sh7760_ac97_init);
  56. module_exit(sh7760_ac97_exit);
  57. MODULE_LICENSE("GPL");
  58. MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
  59. MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");