~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/samsung/snow.c

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * ASoC machine driver for Snow boards
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU General Public License
  6  * version 2 as published by the Free Software Foundation.
  7  *
  8  * This program is distributed in the hope that it will be useful, but
  9  * WITHOUT ANY WARRANTY; without even the implied warranty of
 10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 11  * General Public License for more details.
 12  */
 13 
 14 #include <linux/module.h>
 15 #include <linux/platform_device.h>
 16 #include <linux/of.h>
 17 #include <linux/of_device.h>
 18 
 19 #include <sound/soc.h>
 20 
 21 #include "i2s.h"
 22 
 23 #define FIN_PLL_RATE            24000000
 24 
 25 static struct snd_soc_dai_link snow_dai[] = {
 26         {
 27                 .name = "Primary",
 28                 .stream_name = "Primary",
 29                 .codec_dai_name = "HiFi",
 30                 .dai_fmt = SND_SOC_DAIFMT_I2S |
 31                                 SND_SOC_DAIFMT_NB_NF |
 32                                 SND_SOC_DAIFMT_CBS_CFS,
 33         },
 34 };
 35 
 36 static int snow_late_probe(struct snd_soc_card *card)
 37 {
 38         struct snd_soc_pcm_runtime *rtd;
 39         struct snd_soc_dai *codec_dai;
 40         struct snd_soc_dai *cpu_dai;
 41         int ret;
 42 
 43         rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
 44         codec_dai = rtd->codec_dai;
 45         cpu_dai = rtd->cpu_dai;
 46 
 47         /* Set the MCLK rate for the codec */
 48         ret = snd_soc_dai_set_sysclk(codec_dai, 0,
 49                                         FIN_PLL_RATE, SND_SOC_CLOCK_IN);
 50         if (ret < 0)
 51                 return ret;
 52 
 53         /* Select I2S Bus clock to set RCLK and BCLK */
 54         ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_RCLKSRC_0,
 55                                         0, SND_SOC_CLOCK_IN);
 56         if (ret < 0)
 57                 return ret;
 58 
 59         return 0;
 60 }
 61 
 62 static struct snd_soc_card snow_snd = {
 63         .name = "Snow-I2S",
 64         .owner = THIS_MODULE,
 65         .dai_link = snow_dai,
 66         .num_links = ARRAY_SIZE(snow_dai),
 67 
 68         .late_probe = snow_late_probe,
 69 };
 70 
 71 static int snow_probe(struct platform_device *pdev)
 72 {
 73         struct snd_soc_card *card = &snow_snd;
 74         struct device_node *i2s_node, *codec_node;
 75         int i, ret;
 76 
 77         i2s_node = of_parse_phandle(pdev->dev.of_node,
 78                                     "samsung,i2s-controller", 0);
 79         if (!i2s_node) {
 80                 dev_err(&pdev->dev,
 81                         "Property 'i2s-controller' missing or invalid\n");
 82                 return -EINVAL;
 83         }
 84 
 85         codec_node = of_parse_phandle(pdev->dev.of_node,
 86                                       "samsung,audio-codec", 0);
 87         if (!codec_node) {
 88                 dev_err(&pdev->dev,
 89                         "Property 'audio-codec' missing or invalid\n");
 90                 return -EINVAL;
 91         }
 92 
 93         for (i = 0; i < ARRAY_SIZE(snow_dai); i++) {
 94                 snow_dai[i].codec_of_node = codec_node;
 95                 snow_dai[i].cpu_of_node = i2s_node;
 96                 snow_dai[i].platform_of_node = i2s_node;
 97         }
 98 
 99         card->dev = &pdev->dev;
100 
101         /* Update card-name if provided through DT, else use default name */
102         snd_soc_of_parse_card_name(card, "samsung,model");
103 
104         ret = devm_snd_soc_register_card(&pdev->dev, card);
105         if (ret) {
106                 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
107                 return ret;
108         }
109 
110         return ret;
111 }
112 
113 static const struct of_device_id snow_of_match[] = {
114         { .compatible = "google,snow-audio-max98090", },
115         { .compatible = "google,snow-audio-max98091", },
116         { .compatible = "google,snow-audio-max98095", },
117         {},
118 };
119 MODULE_DEVICE_TABLE(of, snow_of_match);
120 
121 static struct platform_driver snow_driver = {
122         .driver = {
123                 .name = "snow-audio",
124                 .pm = &snd_soc_pm_ops,
125                 .of_match_table = snow_of_match,
126         },
127         .probe = snow_probe,
128 };
129 
130 module_platform_driver(snow_driver);
131 
132 MODULE_DESCRIPTION("ALSA SoC Audio machine driver for Snow");
133 MODULE_LICENSE("GPL");
134 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp