diff options
author | Danny Milosavljevic <dannym@scratchpost.org> | 2016-09-22 03:13:13 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-09-24 14:15:37 -0400 |
commit | c1d5065a0bd09bac783120b73bfa768ba6a493d9 (patch) | |
tree | 674733a5bde9835c90ea2696b8ef60cfcf959a40 | |
parent | 4f0c4e99312d8887483474d60e47ab4e24713114 (diff) |
ASoC: sun4i-codec: Add custom regmap configs
The A20 has a few extra registers that the A10 doesn't have.
Therefore, use different regmaps for A10 as compared to A20.
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/sunxi/sun4i-codec.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 9d8c027f7c55..eb6808842208 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c | |||
@@ -680,12 +680,37 @@ static const struct regmap_config sun4i_codec_regmap_config = { | |||
680 | .reg_bits = 32, | 680 | .reg_bits = 32, |
681 | .reg_stride = 4, | 681 | .reg_stride = 4, |
682 | .val_bits = 32, | 682 | .val_bits = 32, |
683 | .max_register = SUN4I_CODEC_ADC_RXCNT, | ||
684 | }; | ||
685 | |||
686 | static const struct regmap_config sun7i_codec_regmap_config = { | ||
687 | .reg_bits = 32, | ||
688 | .reg_stride = 4, | ||
689 | .val_bits = 32, | ||
683 | .max_register = SUN7I_CODEC_AC_MIC_PHONE_CAL, | 690 | .max_register = SUN7I_CODEC_AC_MIC_PHONE_CAL, |
684 | }; | 691 | }; |
685 | 692 | ||
693 | struct sun4i_codec_quirks { | ||
694 | const struct regmap_config *regmap_config; | ||
695 | }; | ||
696 | |||
697 | static const struct sun4i_codec_quirks sun4i_codec_quirks = { | ||
698 | .regmap_config = &sun4i_codec_regmap_config, | ||
699 | }; | ||
700 | |||
701 | static const struct sun4i_codec_quirks sun7i_codec_quirks = { | ||
702 | .regmap_config = &sun7i_codec_regmap_config, | ||
703 | }; | ||
704 | |||
686 | static const struct of_device_id sun4i_codec_of_match[] = { | 705 | static const struct of_device_id sun4i_codec_of_match[] = { |
687 | { .compatible = "allwinner,sun4i-a10-codec" }, | 706 | { |
688 | { .compatible = "allwinner,sun7i-a20-codec" }, | 707 | .compatible = "allwinner,sun4i-a10-codec", |
708 | .data = &sun4i_codec_quirks, | ||
709 | }, | ||
710 | { | ||
711 | .compatible = "allwinner,sun7i-a20-codec", | ||
712 | .data = &sun7i_codec_quirks, | ||
713 | }, | ||
689 | {} | 714 | {} |
690 | }; | 715 | }; |
691 | MODULE_DEVICE_TABLE(of, sun4i_codec_of_match); | 716 | MODULE_DEVICE_TABLE(of, sun4i_codec_of_match); |
@@ -758,6 +783,7 @@ static int sun4i_codec_probe(struct platform_device *pdev) | |||
758 | { | 783 | { |
759 | struct snd_soc_card *card; | 784 | struct snd_soc_card *card; |
760 | struct sun4i_codec *scodec; | 785 | struct sun4i_codec *scodec; |
786 | const struct sun4i_codec_quirks *quirks; | ||
761 | struct resource *res; | 787 | struct resource *res; |
762 | void __iomem *base; | 788 | void __iomem *base; |
763 | int ret; | 789 | int ret; |
@@ -775,8 +801,14 @@ static int sun4i_codec_probe(struct platform_device *pdev) | |||
775 | return PTR_ERR(base); | 801 | return PTR_ERR(base); |
776 | } | 802 | } |
777 | 803 | ||
804 | quirks = of_device_get_match_data(&pdev->dev); | ||
805 | if (quirks == NULL) { | ||
806 | dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); | ||
807 | return -ENODEV; | ||
808 | } | ||
809 | |||
778 | scodec->regmap = devm_regmap_init_mmio(&pdev->dev, base, | 810 | scodec->regmap = devm_regmap_init_mmio(&pdev->dev, base, |
779 | &sun4i_codec_regmap_config); | 811 | quirks->regmap_config); |
780 | if (IS_ERR(scodec->regmap)) { | 812 | if (IS_ERR(scodec->regmap)) { |
781 | dev_err(&pdev->dev, "Failed to create our regmap\n"); | 813 | dev_err(&pdev->dev, "Failed to create our regmap\n"); |
782 | return PTR_ERR(scodec->regmap); | 814 | return PTR_ERR(scodec->regmap); |