sh7760-ac97.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Generic AC97 sound support for SH7760
  4. //
  5. // (c) 2007 Manuel Lauss
  6. #include <linux/module.h>
  7. #include <linux/moduleparam.h>
  8. #include <linux/platform_device.h>
  9. #include <sound/core.h>
  10. #include <sound/pcm.h>
  11. #include <sound/soc.h>
  12. #include <asm/io.h>
  13. #define IPSEL 0xFE400034
  14. SND_SOC_DAILINK_DEFS(ac97,
  15. DAILINK_COMP_ARRAY(COMP_CPU("hac-dai.0")), /* HAC0 */
  16. DAILINK_COMP_ARRAY(COMP_CODEC("ac97-codec", "ac97-hifi")),
  17. DAILINK_COMP_ARRAY(COMP_PLATFORM("sh7760-pcm-audio")));
  18. static struct snd_soc_dai_link sh7760_ac97_dai = {
  19. .name = "AC97",
  20. .stream_name = "AC97 HiFi",
  21. SND_SOC_DAILINK_REG(ac97),
  22. };
  23. static struct snd_soc_card sh7760_ac97_soc_machine = {
  24. .name = "SH7760 AC97",
  25. .owner = THIS_MODULE,
  26. .dai_link = &sh7760_ac97_dai,
  27. .num_links = 1,
  28. };
  29. static struct platform_device *sh7760_ac97_snd_device;
  30. static int __init sh7760_ac97_init(void)
  31. {
  32. int ret;
  33. unsigned short ipsel;
  34. /* enable both AC97 controllers in pinmux reg */
  35. ipsel = __raw_readw(IPSEL);
  36. __raw_writew(ipsel | (3 << 10), IPSEL);
  37. ret = -ENOMEM;
  38. sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
  39. if (!sh7760_ac97_snd_device)
  40. goto out;
  41. platform_set_drvdata(sh7760_ac97_snd_device,
  42. &sh7760_ac97_soc_machine);
  43. ret = platform_device_add(sh7760_ac97_snd_device);
  44. if (ret)
  45. platform_device_put(sh7760_ac97_snd_device);
  46. out:
  47. return ret;
  48. }
  49. static void __exit sh7760_ac97_exit(void)
  50. {
  51. platform_device_unregister(sh7760_ac97_snd_device);
  52. }
  53. module_init(sh7760_ac97_init);
  54. module_exit(sh7760_ac97_exit);
  55. MODULE_LICENSE("GPL v2");
  56. MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
  57. MODULE_AUTHOR("Manuel Lauss <[email protected]>");