27 #include <linux/i2c.h>
28 #include <linux/slab.h>
29 #include <linux/module.h>
73 #define PMVCM (1 << 6)
74 #define PMMIN (1 << 5)
75 #define PMDAC (1 << 2)
76 #define PMADL (1 << 0)
79 #define HPMTN (1 << 6)
80 #define PMHPL (1 << 5)
81 #define PMHPR (1 << 4)
84 #define PMPLL (1 << 0)
86 #define PMHP_MASK (PMHPL | PMHPR)
87 #define PMHP PMHP_MASK
90 #define PMADR (1 << 0)
96 #define MGAIN0 (1 << 0)
99 #define ZTM(param) ((param & 0x3) << 4)
100 #define WTM(param) (((param & 0x4) << 4) | ((param & 0x3) << 2))
104 #define LMTH0 (1 << 0)
107 #define PLL3 (1 << 7)
108 #define PLL2 (1 << 6)
109 #define PLL1 (1 << 5)
110 #define PLL0 (1 << 4)
111 #define PLL_MASK (PLL3 | PLL2 | PLL1 | PLL0)
113 #define BCKO_MASK (1 << 3)
114 #define BCKO_64 BCKO_MASK
116 #define DIF_MASK (3 << 0)
118 #define RIGHT_J (1 << 0)
119 #define LEFT_J (2 << 0)
127 #define FS_MASK (FS0 | FS1 | FS2 | FS3)
130 #define BST1 (1 << 3)
133 #define DACH (1 << 0)
148 0, 0xFF, 1, out_tlv),
168 &ak4642_headphone_control),
173 &ak4642_lout_mixer_controls[0],
183 {
"HPOUTL",
NULL,
"HPL Out"},
184 {
"HPOUTR",
NULL,
"HPR Out"},
185 {
"LINEOUT",
NULL,
"LINEOUT Mixer"},
187 {
"HPL Out",
NULL,
"Headphone Enable"},
188 {
"HPR Out",
NULL,
"Headphone Enable"},
190 {
"Headphone Enable",
"Switch",
"DACH"},
192 {
"DACH",
NULL,
"DAC"},
194 {
"LINEOUT Mixer",
"DACL",
"DAC"},
206 static const u8 ak4642_reg[] = {
207 0x00, 0x00, 0x01, 0x00,
208 0x02, 0x00, 0x00, 0x00,
209 0xe1, 0xe1, 0x18, 0x00,
210 0xe1, 0x18, 0x11, 0x08,
211 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00,
219 static const u8 ak4648_reg[] = {
220 0x00, 0x00, 0x01, 0x00,
221 0x02, 0x00, 0x00, 0x00,
222 0xe1, 0xe1, 0x18, 0x00,
223 0xe1, 0x18, 0x11, 0xb8,
224 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x00,
226 0x00, 0x00, 0x00, 0x00,
227 0x00, 0x00, 0x00, 0x00,
228 0x00, 0x00, 0x00, 0x00,
229 0x00, 0x88, 0x88, 0x08,
290 static int ak4642_dai_set_sysclk(
struct snd_soc_dai *codec_dai,
291 int clk_id,
unsigned int freq,
int dir)
323 static int ak4642_dai_set_fmt(
struct snd_soc_dai *dai,
unsigned int fmt)
420 static int ak4642_set_bias_level(
struct snd_soc_codec *codec,
437 .startup = ak4642_dai_startup,
438 .shutdown = ak4642_dai_shutdown,
439 .set_sysclk = ak4642_dai_set_sysclk,
440 .set_fmt = ak4642_dai_set_fmt,
441 .hw_params = ak4642_dai_hw_params,
445 .name =
"ak4642-hifi",
447 .stream_name =
"Playback",
453 .stream_name =
"Capture",
458 .ops = &ak4642_dai_ops,
459 .symmetric_rates = 1,
471 struct ak4642_priv *ak4642 = snd_soc_codec_get_drvdata(codec);
476 dev_err(codec->
dev,
"Failed to set cache I/O: %d\n", ret);
495 .probe = ak4642_probe,
496 .remove = ak4642_remove,
497 .resume = ak4642_resume,
498 .set_bias_level = ak4642_set_bias_level,
499 .reg_cache_default = ak4642_reg,
501 .reg_word_size =
sizeof(
u8),
504 .dapm_routes = ak4642_intercon,
505 .num_dapm_routes =
ARRAY_SIZE(ak4642_intercon),
509 .probe = ak4642_probe,
510 .remove = ak4642_remove,
511 .resume = ak4642_resume,
512 .set_bias_level = ak4642_set_bias_level,
513 .reg_cache_default = ak4648_reg,
515 .reg_word_size =
sizeof(
u8),
518 .dapm_routes = ak4642_intercon,
519 .num_dapm_routes =
ARRAY_SIZE(ak4642_intercon),
522 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
534 i2c_set_clientdata(i2c, ak4642);
557 static struct i2c_driver ak4642_i2c_driver = {
559 .name =
"ak4642-codec",
562 .probe = ak4642_i2c_probe,
564 .id_table = ak4642_i2c_id,
568 static int __init ak4642_modinit(
void)
571 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
572 ret = i2c_add_driver(&ak4642_i2c_driver);
579 static void __exit ak4642_exit(
void)
581 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)