sh7760-ac97.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #include "../codecs/ac97.h"
  17. #define IPSEL 0xFE400034
  18. /* platform specific structs can be declared here */
  19. extern struct snd_soc_dai sh4_hac_dai[2];
  20. extern struct snd_soc_platform sh7760_soc_platform;
  21. static int machine_init(struct snd_soc_codec *codec)
  22. {
  23. snd_soc_dapm_sync(codec);
  24. return 0;
  25. }
  26. static struct snd_soc_dai_link sh7760_ac97_dai = {
  27. .name = "AC97",
  28. .stream_name = "AC97 HiFi",
  29. .cpu_dai = &sh4_hac_dai[0], /* HAC0 */
  30. .codec_dai = &ac97_dai,
  31. .init = machine_init,
  32. .ops = NULL,
  33. };
  34. static struct snd_soc_card sh7760_ac97_soc_machine = {
  35. .name = "SH7760 AC97",
  36. .platform = &sh7760_soc_platform,
  37. .dai_link = &sh7760_ac97_dai,
  38. .num_links = 1,
  39. };
  40. static struct snd_soc_device sh7760_ac97_snd_devdata = {
  41. .card = &sh7760_ac97_soc_machine,
  42. .codec_dev = &soc_codec_dev_ac97,
  43. };
  44. static struct platform_device *sh7760_ac97_snd_device;
  45. static int __init sh7760_ac97_init(void)
  46. {
  47. int ret;
  48. unsigned short ipsel;
  49. /* enable both AC97 controllers in pinmux reg */
  50. ipsel = ctrl_inw(IPSEL);
  51. ctrl_outw(ipsel | (3 << 10), IPSEL);
  52. ret = -ENOMEM;
  53. sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
  54. if (!sh7760_ac97_snd_device)
  55. goto out;
  56. platform_set_drvdata(sh7760_ac97_snd_device,
  57. &sh7760_ac97_snd_devdata);
  58. sh7760_ac97_snd_devdata.dev = &sh7760_ac97_snd_device->dev;
  59. ret = platform_device_add(sh7760_ac97_snd_device);
  60. if (ret)
  61. platform_device_put(sh7760_ac97_snd_device);
  62. out:
  63. return ret;
  64. }
  65. static void __exit sh7760_ac97_exit(void)
  66. {
  67. platform_device_unregister(sh7760_ac97_snd_device);
  68. }
  69. module_init(sh7760_ac97_init);
  70. module_exit(sh7760_ac97_exit);
  71. MODULE_LICENSE("GPL");
  72. MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
  73. MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");