Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include "../codecs/wm8940.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include "pxa2xx-i2s.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static int imote2_asoc_hw_params(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 				 struct snd_pcm_hw_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	unsigned int clk = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	switch (params_rate(params)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	case 8000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	case 16000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	case 48000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	case 96000:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		clk = 12288000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	case 11025:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	case 22050:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	case 44100:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		clk = 11289600;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	ret = snd_soc_dai_set_sysclk(codec_dai, 0, clk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 				     SND_SOC_CLOCK_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	/* set the I2S system clock as input (unused) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	ret = snd_soc_dai_set_sysclk(cpu_dai, PXA2XX_I2S_SYSCLK, clk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		SND_SOC_CLOCK_OUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static const struct snd_soc_ops imote2_asoc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	.hw_params = imote2_asoc_hw_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) SND_SOC_DAILINK_DEFS(wm8940,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-i2s")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	DAILINK_COMP_ARRAY(COMP_CODEC("wm8940-codec.0-0034",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 				      "wm8940-hifi")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static struct snd_soc_dai_link imote2_dai = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	.name = "WM8940",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	.stream_name = "WM8940",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		   SND_SOC_DAIFMT_CBS_CFS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	.ops = &imote2_asoc_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	SND_SOC_DAILINK_REG(wm8940),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static struct snd_soc_card imote2 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	.name = "Imote2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	.dai_link = &imote2_dai,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	.num_links = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static int imote2_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	struct snd_soc_card *card = &imote2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	card->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	ret = devm_snd_soc_register_card(&pdev->dev, card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static struct platform_driver imote2_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 		.name	= "imote2-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) 		.pm     = &snd_soc_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	.probe		= imote2_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) module_platform_driver(imote2_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) MODULE_AUTHOR("Jonathan Cameron");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) MODULE_DESCRIPTION("ALSA SoC Imote 2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) MODULE_ALIAS("platform:imote2-audio");