diff options
-rw-r--r-- | sound/soc/codecs/cs4270.c | 92 | ||||
-rw-r--r-- | sound/soc/fsl/Kconfig | 3 |
2 files changed, 29 insertions, 66 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index f1aa0c34421c..2e4ce04925e2 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
@@ -12,11 +12,7 @@ | |||
12 | * | 12 | * |
13 | * Current features/limitations: | 13 | * Current features/limitations: |
14 | * | 14 | * |
15 | * 1) Software mode is supported. Stand-alone mode is automatically | 15 | * 1) Software mode is supported. Stand-alone mode is not supported. |
16 | * selected if I2C is disabled or if a CS4270 is not found on the I2C | ||
17 | * bus. However, stand-alone mode is only partially implemented because | ||
18 | * there is no mechanism yet for this driver and the machine driver to | ||
19 | * communicate the values of the M0, M1, MCLK1, and MCLK2 pins. | ||
20 | * 2) Only I2C is supported, not SPI | 16 | * 2) Only I2C is supported, not SPI |
21 | * 3) Only Master mode is supported, not Slave. | 17 | * 3) Only Master mode is supported, not Slave. |
22 | * 4) The machine driver's 'startup' function must call | 18 | * 4) The machine driver's 'startup' function must call |
@@ -33,14 +29,6 @@ | |||
33 | #include <sound/initval.h> | 29 | #include <sound/initval.h> |
34 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
35 | 31 | ||
36 | #include "cs4270.h" | ||
37 | |||
38 | /* If I2C is defined, then we support software mode. However, if we're | ||
39 | not compiled as module but I2C is, then we can't use I2C calls. */ | ||
40 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | ||
41 | #define USE_I2C | ||
42 | #endif | ||
43 | |||
44 | /* Private data for the CS4270 */ | 32 | /* Private data for the CS4270 */ |
45 | struct cs4270_private { | 33 | struct cs4270_private { |
46 | unsigned int mclk; /* Input frequency of the MCLK pin */ | 34 | unsigned int mclk; /* Input frequency of the MCLK pin */ |
@@ -60,8 +48,6 @@ struct cs4270_private { | |||
60 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \ | 48 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \ |
61 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE) | 49 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE) |
62 | 50 | ||
63 | #ifdef USE_I2C | ||
64 | |||
65 | /* CS4270 registers addresses */ | 51 | /* CS4270 registers addresses */ |
66 | #define CS4270_CHIPID 0x01 /* Chip ID */ | 52 | #define CS4270_CHIPID 0x01 /* Chip ID */ |
67 | #define CS4270_PWRCTL 0x02 /* Power Control */ | 53 | #define CS4270_PWRCTL 0x02 /* Power Control */ |
@@ -272,17 +258,6 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
272 | } | 258 | } |
273 | 259 | ||
274 | /* | 260 | /* |
275 | * A list of addresses on which this CS4270 could use. I2C addresses are | ||
276 | * 7 bits. For the CS4270, the upper four bits are always 1001, and the | ||
277 | * lower three bits are determined via the AD2, AD1, and AD0 pins | ||
278 | * (respectively). | ||
279 | */ | ||
280 | static const unsigned short normal_i2c[] = { | ||
281 | 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, I2C_CLIENT_END | ||
282 | }; | ||
283 | I2C_CLIENT_INSMOD; | ||
284 | |||
285 | /* | ||
286 | * Pre-fill the CS4270 register cache. | 261 | * Pre-fill the CS4270 register cache. |
287 | * | 262 | * |
288 | * We use the auto-increment feature of the CS4270 to read all registers in | 263 | * We use the auto-increment feature of the CS4270 to read all registers in |
@@ -476,7 +451,6 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, | |||
476 | } | 451 | } |
477 | 452 | ||
478 | #ifdef CONFIG_SND_SOC_CS4270_HWMUTE | 453 | #ifdef CONFIG_SND_SOC_CS4270_HWMUTE |
479 | |||
480 | /* | 454 | /* |
481 | * Set the CS4270 external mute | 455 | * Set the CS4270 external mute |
482 | * | 456 | * |
@@ -501,32 +475,16 @@ static int cs4270_mute(struct snd_soc_dai *dai, int mute) | |||
501 | 475 | ||
502 | return snd_soc_write(codec, CS4270_MUTE, reg6); | 476 | return snd_soc_write(codec, CS4270_MUTE, reg6); |
503 | } | 477 | } |
504 | 478 | #else | |
479 | #define cs4270_mute NULL | ||
505 | #endif | 480 | #endif |
506 | 481 | ||
507 | static int cs4270_i2c_probe(struct i2c_client *, const struct i2c_device_id *); | ||
508 | |||
509 | /* A list of non-DAPM controls that the CS4270 supports */ | 482 | /* A list of non-DAPM controls that the CS4270 supports */ |
510 | static const struct snd_kcontrol_new cs4270_snd_controls[] = { | 483 | static const struct snd_kcontrol_new cs4270_snd_controls[] = { |
511 | SOC_DOUBLE_R("Master Playback Volume", | 484 | SOC_DOUBLE_R("Master Playback Volume", |
512 | CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1) | 485 | CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1) |
513 | }; | 486 | }; |
514 | 487 | ||
515 | static const struct i2c_device_id cs4270_id[] = { | ||
516 | {"cs4270", 0}, | ||
517 | {} | ||
518 | }; | ||
519 | MODULE_DEVICE_TABLE(i2c, cs4270_id); | ||
520 | |||
521 | static struct i2c_driver cs4270_i2c_driver = { | ||
522 | .driver = { | ||
523 | .name = "CS4270 I2C", | ||
524 | .owner = THIS_MODULE, | ||
525 | }, | ||
526 | .id_table = cs4270_id, | ||
527 | .probe = cs4270_i2c_probe, | ||
528 | }; | ||
529 | |||
530 | /* | 488 | /* |
531 | * Global variable to store socdev for i2c probe function. | 489 | * Global variable to store socdev for i2c probe function. |
532 | * | 490 | * |
@@ -633,7 +591,20 @@ error: | |||
633 | return ret; | 591 | return ret; |
634 | } | 592 | } |
635 | 593 | ||
636 | #endif /* USE_I2C*/ | 594 | static const struct i2c_device_id cs4270_id[] = { |
595 | {"cs4270", 0}, | ||
596 | {} | ||
597 | }; | ||
598 | MODULE_DEVICE_TABLE(i2c, cs4270_id); | ||
599 | |||
600 | static struct i2c_driver cs4270_i2c_driver = { | ||
601 | .driver = { | ||
602 | .name = "cs4270", | ||
603 | .owner = THIS_MODULE, | ||
604 | }, | ||
605 | .id_table = cs4270_id, | ||
606 | .probe = cs4270_i2c_probe, | ||
607 | }; | ||
637 | 608 | ||
638 | struct snd_soc_dai cs4270_dai = { | 609 | struct snd_soc_dai cs4270_dai = { |
639 | .name = "CS4270", | 610 | .name = "CS4270", |
@@ -698,7 +669,6 @@ static int cs4270_probe(struct platform_device *pdev) | |||
698 | goto error_free_codec; | 669 | goto error_free_codec; |
699 | } | 670 | } |
700 | 671 | ||
701 | #ifdef USE_I2C | ||
702 | cs4270_socdev = socdev; | 672 | cs4270_socdev = socdev; |
703 | 673 | ||
704 | ret = i2c_add_driver(&cs4270_i2c_driver); | 674 | ret = i2c_add_driver(&cs4270_i2c_driver); |
@@ -708,20 +678,16 @@ static int cs4270_probe(struct platform_device *pdev) | |||
708 | } | 678 | } |
709 | 679 | ||
710 | /* Did we find a CS4270 on the I2C bus? */ | 680 | /* Did we find a CS4270 on the I2C bus? */ |
711 | if (codec->control_data) { | 681 | if (!codec->control_data) { |
712 | /* Initialize codec ops */ | 682 | printk(KERN_ERR "cs4270: failed to attach driver"); |
713 | cs4270_dai.ops.hw_params = cs4270_hw_params; | 683 | goto error_del_driver; |
714 | cs4270_dai.ops.set_sysclk = cs4270_set_dai_sysclk; | 684 | } |
715 | cs4270_dai.ops.set_fmt = cs4270_set_dai_fmt; | 685 | |
716 | #ifdef CONFIG_SND_SOC_CS4270_HWMUTE | 686 | /* Initialize codec ops */ |
717 | cs4270_dai.ops.digital_mute = cs4270_mute; | 687 | cs4270_dai.ops.hw_params = cs4270_hw_params; |
718 | #endif | 688 | cs4270_dai.ops.set_sysclk = cs4270_set_dai_sysclk; |
719 | } else | 689 | cs4270_dai.ops.set_fmt = cs4270_set_dai_fmt; |
720 | printk(KERN_INFO "cs4270: no I2C device found, " | 690 | cs4270_dai.ops.digital_mute = cs4270_mute; |
721 | "using stand-alone mode\n"); | ||
722 | #else | ||
723 | printk(KERN_INFO "cs4270: I2C disabled, using stand-alone mode\n"); | ||
724 | #endif | ||
725 | 691 | ||
726 | ret = snd_soc_init_card(socdev); | 692 | ret = snd_soc_init_card(socdev); |
727 | if (ret < 0) { | 693 | if (ret < 0) { |
@@ -732,11 +698,9 @@ static int cs4270_probe(struct platform_device *pdev) | |||
732 | return 0; | 698 | return 0; |
733 | 699 | ||
734 | error_del_driver: | 700 | error_del_driver: |
735 | #ifdef USE_I2C | ||
736 | i2c_del_driver(&cs4270_i2c_driver); | 701 | i2c_del_driver(&cs4270_i2c_driver); |
737 | 702 | ||
738 | error_free_pcms: | 703 | error_free_pcms: |
739 | #endif | ||
740 | snd_soc_free_pcms(socdev); | 704 | snd_soc_free_pcms(socdev); |
741 | 705 | ||
742 | error_free_codec: | 706 | error_free_codec: |
@@ -752,9 +716,7 @@ static int cs4270_remove(struct platform_device *pdev) | |||
752 | 716 | ||
753 | snd_soc_free_pcms(socdev); | 717 | snd_soc_free_pcms(socdev); |
754 | 718 | ||
755 | #ifdef USE_I2C | ||
756 | i2c_del_driver(&cs4270_i2c_driver); | 719 | i2c_del_driver(&cs4270_i2c_driver); |
757 | #endif | ||
758 | 720 | ||
759 | kfree(socdev->codec); | 721 | kfree(socdev->codec); |
760 | socdev->codec = NULL; | 722 | socdev->codec = NULL; |
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index c7c78c39cfed..9fc908283371 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
@@ -10,7 +10,8 @@ config SND_SOC_MPC8610 | |||
10 | 10 | ||
11 | config SND_SOC_MPC8610_HPCD | 11 | config SND_SOC_MPC8610_HPCD |
12 | tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" | 12 | tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" |
13 | depends on MPC8610_HPCD | 13 | # I2C is necessary for the CS4270 driver |
14 | depends on MPC8610_HPCD && I2C | ||
14 | select SND_SOC_MPC8610 | 15 | select SND_SOC_MPC8610 |
15 | select SND_SOC_CS4270 | 16 | select SND_SOC_CS4270 |
16 | select SND_SOC_CS4270_VD33_ERRATA | 17 | select SND_SOC_CS4270_VD33_ERRATA |