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