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

TOMOYO Linux Cross Reference
Linux/sound/soc/tegra/tegra_wm8903.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/tegra/tegra_wm8903.c (Architecture sparc) and /sound/soc/tegra/tegra_wm8903.c (Architecture ppc)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * tegra_wm8903.c - Tegra machine ASoC driver       3  * tegra_wm8903.c - Tegra machine ASoC driver for boards using WM8903 codec.
  4  *                                                  4  *
  5  * Author: Stephen Warren <swarren@nvidia.com>      5  * Author: Stephen Warren <swarren@nvidia.com>
  6  * Copyright (C) 2010-2012 - NVIDIA, Inc.           6  * Copyright (C) 2010-2012 - NVIDIA, Inc.
  7  *                                                  7  *
  8  * Based on code copyright/by:                      8  * Based on code copyright/by:
  9  *                                                  9  *
 10  * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd.        10  * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd.
 11  *                                                 11  *
 12  * Copyright 2007 Wolfson Microelectronics PLC     12  * Copyright 2007 Wolfson Microelectronics PLC.
 13  * Author: Graeme Gregory                          13  * Author: Graeme Gregory
 14  *         graeme.gregory@wolfsonmicro.com or      14  *         graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
 15  */                                                15  */
 16                                                    16 
 17 #include <linux/gpio/consumer.h>                   17 #include <linux/gpio/consumer.h>
 18 #include <linux/of.h>                              18 #include <linux/of.h>
 19 #include <linux/module.h>                          19 #include <linux/module.h>
 20 #include <linux/platform_device.h>                 20 #include <linux/platform_device.h>
 21                                                    21 
 22 #include <sound/core.h>                            22 #include <sound/core.h>
 23 #include <sound/jack.h>                            23 #include <sound/jack.h>
 24 #include <sound/soc.h>                             24 #include <sound/soc.h>
 25                                                    25 
 26 #include "../codecs/wm8903.h"                      26 #include "../codecs/wm8903.h"
 27                                                    27 
 28 #include "tegra_asoc_machine.h"                    28 #include "tegra_asoc_machine.h"
 29                                                    29 
 30 static struct snd_soc_jack_pin tegra_wm8903_mi     30 static struct snd_soc_jack_pin tegra_wm8903_mic_jack_pins[] = {
 31         { .pin = "Mic Jack", .mask = SND_JACK_     31         { .pin = "Mic Jack", .mask = SND_JACK_MICROPHONE },
 32 };                                                 32 };
 33                                                    33 
 34 static unsigned int tegra_wm8903_mclk_rate(uns     34 static unsigned int tegra_wm8903_mclk_rate(unsigned int srate)
 35 {                                                  35 {
 36         unsigned int mclk;                         36         unsigned int mclk;
 37                                                    37 
 38         switch (srate) {                           38         switch (srate) {
 39         case 64000:                                39         case 64000:
 40         case 88200:                                40         case 88200:
 41         case 96000:                                41         case 96000:
 42                 mclk = 128 * srate;                42                 mclk = 128 * srate;
 43                 break;                             43                 break;
 44         default:                                   44         default:
 45                 mclk = 256 * srate;                45                 mclk = 256 * srate;
 46                 break;                             46                 break;
 47         }                                          47         }
 48         /* FIXME: Codec only requires >= 3MHz      48         /* FIXME: Codec only requires >= 3MHz if OSR==0 */
 49         while (mclk < 6000000)                     49         while (mclk < 6000000)
 50                 mclk *= 2;                         50                 mclk *= 2;
 51                                                    51 
 52         return mclk;                               52         return mclk;
 53 }                                                  53 }
 54                                                    54 
 55 static int tegra_wm8903_init(struct snd_soc_pc     55 static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 56 {                                                  56 {
 57         struct tegra_machine *machine = snd_so     57         struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card);
 58         struct snd_soc_card *card = rtd->card;     58         struct snd_soc_card *card = rtd->card;
 59         int err;                                   59         int err;
 60                                                    60 
 61         /*                                         61         /*
 62          * Older version of machine driver was     62          * Older version of machine driver was ignoring GPIO polarity,
 63          * forcing it to active-low.  This mea     63          * forcing it to active-low.  This means that all older device-trees
 64          * which set the polarity to active-hi     64          * which set the polarity to active-high are wrong and we need to fix
 65          * them up.                                65          * them up.
 66          */                                        66          */
 67         if (machine->asoc->hp_jack_gpio_active     67         if (machine->asoc->hp_jack_gpio_active_low) {
 68                 bool active_low = gpiod_is_act     68                 bool active_low = gpiod_is_active_low(machine->gpiod_hp_det);
 69                                                    69 
 70                 machine->hp_jack_gpio->invert      70                 machine->hp_jack_gpio->invert = !active_low;
 71         }                                          71         }
 72                                                    72 
 73         err = tegra_asoc_machine_init(rtd);        73         err = tegra_asoc_machine_init(rtd);
 74         if (err)                                   74         if (err)
 75                 return err;                        75                 return err;
 76                                                    76 
 77         if (!machine->gpiod_mic_det && machine     77         if (!machine->gpiod_mic_det && machine->asoc->add_mic_jack) {
 78                 struct snd_soc_dai *codec_dai      78                 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
 79                 struct snd_soc_component *comp     79                 struct snd_soc_component *component = codec_dai->component;
 80                 int shrt = 0;                      80                 int shrt = 0;
 81                                                    81 
 82                 err = snd_soc_card_jack_new_pi     82                 err = snd_soc_card_jack_new_pins(rtd->card, "Mic Jack",
 83                                                    83                                                  SND_JACK_MICROPHONE,
 84                                                    84                                                  machine->mic_jack,
 85                                                    85                                                  tegra_wm8903_mic_jack_pins,
 86                                                    86                                                  ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
 87                 if (err) {                         87                 if (err) {
 88                         dev_err(rtd->dev, "Mic     88                         dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err);
 89                         return err;                89                         return err;
 90                 }                                  90                 }
 91                                                    91 
 92                 if (of_property_read_bool(card     92                 if (of_property_read_bool(card->dev->of_node, "nvidia,headset"))
 93                         shrt = SND_JACK_MICROP     93                         shrt = SND_JACK_MICROPHONE;
 94                                                    94 
 95                 wm8903_mic_detect(component, m     95                 wm8903_mic_detect(component, machine->mic_jack,
 96                                   SND_JACK_MIC     96                                   SND_JACK_MICROPHONE, shrt);
 97         }                                          97         }
 98                                                    98 
 99         snd_soc_dapm_force_enable_pin(&card->d     99         snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS");
100                                                   100 
101         return 0;                                 101         return 0;
102 }                                                 102 }
103                                                   103 
104 static int tegra_wm8903_remove(struct snd_soc_    104 static int tegra_wm8903_remove(struct snd_soc_card *card)
105 {                                                 105 {
106         struct snd_soc_dai_link *link = &card-    106         struct snd_soc_dai_link *link = &card->dai_link[0];
107         struct snd_soc_pcm_runtime *rtd = snd_    107         struct snd_soc_pcm_runtime *rtd = snd_soc_get_pcm_runtime(card, link);
108         struct snd_soc_dai *codec_dai = snd_so    108         struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
109         struct snd_soc_component *component =     109         struct snd_soc_component *component = codec_dai->component;
110                                                   110 
111         wm8903_mic_detect(component, NULL, 0,     111         wm8903_mic_detect(component, NULL, 0, 0);
112                                                   112 
113         return 0;                                 113         return 0;
114 }                                                 114 }
115                                                   115 
116 SND_SOC_DAILINK_DEFS(hifi,                        116 SND_SOC_DAILINK_DEFS(hifi,
117         DAILINK_COMP_ARRAY(COMP_EMPTY()),         117         DAILINK_COMP_ARRAY(COMP_EMPTY()),
118         DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "w    118         DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8903-hifi")),
119         DAILINK_COMP_ARRAY(COMP_EMPTY()));        119         DAILINK_COMP_ARRAY(COMP_EMPTY()));
120                                                   120 
121 static struct snd_soc_dai_link tegra_wm8903_da    121 static struct snd_soc_dai_link tegra_wm8903_dai = {
122         .name = "WM8903",                         122         .name = "WM8903",
123         .stream_name = "WM8903 PCM",              123         .stream_name = "WM8903 PCM",
124         .init = tegra_wm8903_init,                124         .init = tegra_wm8903_init,
125         .dai_fmt = SND_SOC_DAIFMT_I2S |           125         .dai_fmt = SND_SOC_DAIFMT_I2S |
126                    SND_SOC_DAIFMT_NB_NF |         126                    SND_SOC_DAIFMT_NB_NF |
127                    SND_SOC_DAIFMT_CBS_CFS,        127                    SND_SOC_DAIFMT_CBS_CFS,
128         SND_SOC_DAILINK_REG(hifi),                128         SND_SOC_DAILINK_REG(hifi),
129 };                                                129 };
130                                                   130 
131 static struct snd_soc_card snd_soc_tegra_wm890    131 static struct snd_soc_card snd_soc_tegra_wm8903 = {
132         .components = "codec:wm8903",             132         .components = "codec:wm8903",
133         .owner = THIS_MODULE,                     133         .owner = THIS_MODULE,
134         .dai_link = &tegra_wm8903_dai,            134         .dai_link = &tegra_wm8903_dai,
135         .num_links = 1,                           135         .num_links = 1,
136         .remove = tegra_wm8903_remove,            136         .remove = tegra_wm8903_remove,
137         .fully_routed = true,                     137         .fully_routed = true,
138 };                                                138 };
139                                                   139 
140 /* older device-trees used wrong polarity for     140 /* older device-trees used wrong polarity for the headphones-detection GPIO */
141 static const struct tegra_asoc_data tegra_wm89    141 static const struct tegra_asoc_data tegra_wm8903_data_legacy = {
142         .mclk_rate = tegra_wm8903_mclk_rate,      142         .mclk_rate = tegra_wm8903_mclk_rate,
143         .card = &snd_soc_tegra_wm8903,            143         .card = &snd_soc_tegra_wm8903,
144         .hp_jack_gpio_active_low = true,          144         .hp_jack_gpio_active_low = true,
145         .add_common_dapm_widgets = true,          145         .add_common_dapm_widgets = true,
146         .add_common_controls = true,              146         .add_common_controls = true,
147         .add_common_snd_ops = true,               147         .add_common_snd_ops = true,
148         .add_mic_jack = true,                     148         .add_mic_jack = true,
149         .add_hp_jack = true,                      149         .add_hp_jack = true,
150 };                                                150 };
151                                                   151 
152 static const struct tegra_asoc_data tegra_wm89    152 static const struct tegra_asoc_data tegra_wm8903_data = {
153         .mclk_rate = tegra_wm8903_mclk_rate,      153         .mclk_rate = tegra_wm8903_mclk_rate,
154         .card = &snd_soc_tegra_wm8903,            154         .card = &snd_soc_tegra_wm8903,
155         .add_common_dapm_widgets = true,          155         .add_common_dapm_widgets = true,
156         .add_common_controls = true,              156         .add_common_controls = true,
157         .add_common_snd_ops = true,               157         .add_common_snd_ops = true,
158         .add_mic_jack = true,                     158         .add_mic_jack = true,
159         .add_hp_jack = true,                      159         .add_hp_jack = true,
160 };                                                160 };
161                                                   161 
162 static const struct of_device_id tegra_wm8903_    162 static const struct of_device_id tegra_wm8903_of_match[] = {
163         { .compatible = "ad,tegra-audio-plutux    163         { .compatible = "ad,tegra-audio-plutux", .data = &tegra_wm8903_data_legacy },
164         { .compatible = "ad,tegra-audio-wm8903    164         { .compatible = "ad,tegra-audio-wm8903-medcom-wide", .data = &tegra_wm8903_data_legacy },
165         { .compatible = "ad,tegra-audio-wm8903    165         { .compatible = "ad,tegra-audio-wm8903-tec", .data = &tegra_wm8903_data_legacy },
166         { .compatible = "nvidia,tegra-audio-wm    166         { .compatible = "nvidia,tegra-audio-wm8903-cardhu", .data = &tegra_wm8903_data_legacy },
167         { .compatible = "nvidia,tegra-audio-wm    167         { .compatible = "nvidia,tegra-audio-wm8903-harmony", .data = &tegra_wm8903_data_legacy },
168         { .compatible = "nvidia,tegra-audio-wm    168         { .compatible = "nvidia,tegra-audio-wm8903-picasso", .data = &tegra_wm8903_data_legacy },
169         { .compatible = "nvidia,tegra-audio-wm    169         { .compatible = "nvidia,tegra-audio-wm8903-seaboard", .data = &tegra_wm8903_data_legacy },
170         { .compatible = "nvidia,tegra-audio-wm    170         { .compatible = "nvidia,tegra-audio-wm8903-ventana", .data = &tegra_wm8903_data_legacy },
171         { .compatible = "nvidia,tegra-audio-wm    171         { .compatible = "nvidia,tegra-audio-wm8903", .data = &tegra_wm8903_data },
172         {},                                       172         {},
173 };                                                173 };
174 MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match)    174 MODULE_DEVICE_TABLE(of, tegra_wm8903_of_match);
175                                                   175 
176 static struct platform_driver tegra_wm8903_dri    176 static struct platform_driver tegra_wm8903_driver = {
177         .driver = {                               177         .driver = {
178                 .name = "tegra-wm8903",           178                 .name = "tegra-wm8903",
179                 .of_match_table = tegra_wm8903    179                 .of_match_table = tegra_wm8903_of_match,
180                 .pm = &snd_soc_pm_ops,            180                 .pm = &snd_soc_pm_ops,
181         },                                        181         },
182         .probe = tegra_asoc_machine_probe,        182         .probe = tegra_asoc_machine_probe,
183 };                                                183 };
184 module_platform_driver(tegra_wm8903_driver);      184 module_platform_driver(tegra_wm8903_driver);
185                                                   185 
186 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.    186 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
187 MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC     187 MODULE_DESCRIPTION("Tegra+WM8903 machine ASoC driver");
188 MODULE_LICENSE("GPL");                            188 MODULE_LICENSE("GPL");
189                                                   189 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php