10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/device.h>
13 #include <linux/i2c.h>
15 #include <linux/slab.h>
33 static const char *
const ad193x_deemp[] = {
"None",
"48kHz",
"44.1kHz",
"32kHz"};
35 static const struct soc_enum ad193x_deemp_enum =
72 SOC_ENUM(
"Playback Deemphasis", ad193x_deemp_enum),
90 {
"DAC",
NULL,
"SYSCLK" },
91 {
"ADC",
NULL,
"SYSCLK" },
92 {
"DAC",
NULL,
"ADC_PWR" },
93 {
"ADC",
NULL,
"ADC_PWR" },
94 {
"DAC1OUT",
NULL,
"DAC" },
95 {
"DAC2OUT",
NULL,
"DAC" },
96 {
"DAC3OUT",
NULL,
"DAC" },
97 {
"DAC4OUT",
NULL,
"DAC" },
98 {
"ADC",
NULL,
"ADC1IN" },
99 {
"ADC",
NULL,
"ADC2IN" },
100 {
"SYSCLK",
NULL,
"PLL_PWR" },
153 static int ad193x_set_dai_fmt(
struct snd_soc_dai *codec_dai,
157 unsigned int adc_serfmt = 0;
158 unsigned int adc_fmt = 0;
159 unsigned int dac_fmt = 0;
227 static int ad193x_set_dai_sysclk(
struct snd_soc_dai *codec_dai,
228 int clk_id,
unsigned int freq,
int dir)
231 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
247 int word_len = 0, master_rate = 0;
249 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
294 .hw_params = ad193x_hw_params,
295 .digital_mute = ad193x_mute,
296 .set_tdm_slot = ad193x_set_tdm_slot,
297 .set_sysclk = ad193x_set_dai_sysclk,
298 .set_fmt = ad193x_set_dai_fmt,
303 .name =
"ad193x-hifi",
305 .stream_name =
"Playback",
313 .stream_name =
"Capture",
320 .ops = &ad193x_dai_ops,
325 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
331 dev_err(codec->
dev,
"failed to set cache I/O: %d\n", ret);
355 .probe = ad193x_probe,
356 .controls = ad193x_snd_controls,
357 .num_controls =
ARRAY_SIZE(ad193x_snd_controls),
358 .dapm_widgets = ad193x_dapm_widgets,
359 .num_dapm_widgets =
ARRAY_SIZE(ad193x_dapm_widgets),
360 .dapm_routes = audio_paths,
364 static bool adau193x_reg_volatile(
struct device *
dev,
unsigned int reg)
369 #if defined(CONFIG_SPI_MASTER)
371 static const struct regmap_config ad193x_spi_regmap_config = {
374 .read_flag_mask = 0x09,
375 .write_flag_mask = 0x08,
378 .volatile_reg = adau193x_reg_volatile,
391 if (IS_ERR(ad193x->
regmap))
392 return PTR_ERR(ad193x->
regmap);
394 spi_set_drvdata(spi, ad193x);
406 static struct spi_driver ad193x_spi_driver = {
411 .probe = ad193x_spi_probe,
416 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
418 static const struct regmap_config ad193x_i2c_regmap_config = {
423 .volatile_reg = adau193x_reg_volatile,
444 if (IS_ERR(ad193x->
regmap))
445 return PTR_ERR(ad193x->
regmap);
447 i2c_set_clientdata(client, ad193x);
459 static struct i2c_driver ad193x_i2c_driver = {
463 .probe = ad193x_i2c_probe,
465 .id_table = ad193x_id,
469 static int __init ad193x_modinit(
void)
473 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
474 ret = i2c_add_driver(&ad193x_i2c_driver);
481 #if defined(CONFIG_SPI_MASTER)
492 static void __exit ad193x_modexit(
void)
494 #if defined(CONFIG_SPI_MASTER)
495 spi_unregister_driver(&ad193x_spi_driver);
498 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)