sh7760-ac97.c 2.1 KB

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