23 #include <linux/module.h>
24 #include <linux/errno.h>
25 #include <linux/device.h>
26 #include <linux/i2c.h>
29 #include <linux/slab.h>
37 static const struct reg_default wm9090_reg_defaults[] = {
81 static bool wm9090_volatile(
struct device *
dev,
unsigned int reg)
96 static bool wm9090_readable(
struct device *
dev,
unsigned int reg)
151 dev_dbg(codec->
dev,
"Waiting for DC servo...\n");
156 dev_dbg(codec->
dev,
"DC servo status: %x\n", reg);
158 != WM9090_DCS_CAL_COMPLETE_MASK && count < 1000);
160 if ((reg & WM9090_DCS_CAL_COMPLETE_MASK)
161 != WM9090_DCS_CAL_COMPLETE_MASK)
162 dev_err(codec->
dev,
"Timed out waiting for DC Servo\n");
165 static const unsigned int in_tlv[] = {
171 static const unsigned int mix_tlv[] = {
177 static const unsigned int spkboost_tlv[] = {
285 wait_for_dc_servo(codec);
374 {
"IN1A PGA",
NULL,
"IN1+" },
375 {
"IN2A PGA",
NULL,
"IN2+" },
377 {
"SPKMIX",
"IN1A Switch",
"IN1A PGA" },
378 {
"SPKMIX",
"IN2A Switch",
"IN2A PGA" },
380 {
"MIXOUTL",
"IN1A Switch",
"IN1A PGA" },
381 {
"MIXOUTL",
"IN2A Switch",
"IN2A PGA" },
383 {
"MIXOUTR",
"IN1A Switch",
"IN1A PGA" },
384 {
"MIXOUTR",
"IN2A Switch",
"IN2A PGA" },
386 {
"HP PGA",
NULL,
"OSC" },
387 {
"HP PGA",
NULL,
"MIXOUTL" },
388 {
"HP PGA",
NULL,
"MIXOUTR" },
390 {
"HPL",
NULL,
"HP PGA" },
391 {
"HPR",
NULL,
"HP PGA" },
393 {
"SPKPGA",
NULL,
"OSC" },
394 {
"SPKPGA",
NULL,
"SPKMIX" },
396 {
"SPKOUT",
"Mixer Switch",
"SPKPGA" },
398 {
"Speaker",
NULL,
"SPKOUT" },
402 {
"IN1B PGA",
NULL,
"IN1-" },
404 {
"SPKMIX",
"IN1B Switch",
"IN1B PGA" },
405 {
"MIXOUTL",
"IN1B Switch",
"IN1B PGA" },
406 {
"MIXOUTR",
"IN1B Switch",
"IN1B PGA" },
410 {
"IN1A PGA",
NULL,
"IN1-" },
414 {
"IN2B PGA",
NULL,
"IN2-" },
416 {
"SPKMIX",
"IN2B Switch",
"IN2B PGA" },
417 {
"MIXOUTL",
"IN2B Switch",
"IN2B PGA" },
418 {
"MIXOUTR",
"IN2B Switch",
"IN2B PGA" },
422 {
"IN2A PGA",
NULL,
"IN2-" },
427 struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec);
439 if (wm9090->
pdata.lin1_diff) {
449 if (wm9090->
pdata.lin2_diff) {
459 if (wm9090->
pdata.agc_ena) {
462 wm9090->
pdata.agc[i]);
478 static int wm9090_set_bias_level(
struct snd_soc_codec *codec,
481 struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec);
531 dev_err(codec->
dev,
"Failed to set cache I/O: %d\n", ret);
565 wm9090_add_controls(codec);
585 #define wm9090_suspend NULL
586 #define wm9090_resume NULL
597 .probe = wm9090_probe,
598 .remove = wm9090_remove,
601 .set_bias_level = wm9090_set_bias_level,
604 static const struct regmap_config wm9090_regmap = {
609 .volatile_reg = wm9090_volatile,
610 .readable_reg = wm9090_readable,
613 .reg_defaults = wm9090_reg_defaults,
614 .num_reg_defaults =
ARRAY_SIZE(wm9090_reg_defaults),
618 static int wm9090_i2c_probe(
struct i2c_client *i2c,
626 if (wm9090 ==
NULL) {
627 dev_err(&i2c->
dev,
"Can not allocate memory\n");
632 if (IS_ERR(wm9090->
regmap)) {
633 ret = PTR_ERR(wm9090->
regmap);
634 dev_err(&i2c->
dev,
"Failed to allocate regmap: %d\n", ret);
642 dev_err(&i2c->
dev,
"Device is not a WM9090, ID=%x\n", reg);
651 if (i2c->
dev.platform_data)
653 sizeof(wm9090->
pdata));
655 i2c_set_clientdata(i2c, wm9090);
658 &soc_codec_dev_wm9090,
NULL, 0);
660 dev_err(&i2c->
dev,
"Failed to register CODEC: %d\n", ret);
673 struct wm9090_priv *wm9090 = i2c_get_clientdata(i2c);
688 static struct i2c_driver wm9090_i2c_driver = {
693 .probe = wm9090_i2c_probe,
695 .id_table = wm9090_id,