aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/sta32x.h34
-rw-r--r--sound/soc/codecs/sta32x.c30
2 files changed, 55 insertions, 9 deletions
diff --git a/include/sound/sta32x.h b/include/sound/sta32x.h
new file mode 100644
index 000000000000..45d7477c049b
--- /dev/null
+++ b/include/sound/sta32x.h
@@ -0,0 +1,34 @@
1/*
2 * Platform data for ST STA32x ASoC codec driver.
3 *
4 * Copyright: 2011 Raumfeld GmbH
5 * Author: Johannes Stezenbach <js@sig21.net>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12#ifndef __LINUX_SND__STA32X_H
13#define __LINUX_SND__STA32X_H
14
15#define STA32X_OCFG_2CH 0
16#define STA32X_OCFG_2_1CH 1
17#define STA32X_OCFG_1CH 3
18
19#define STA32X_OM_CH1 0
20#define STA32X_OM_CH2 1
21#define STA32X_OM_CH3 2
22
23#define STA32X_THERMAL_ADJUSTMENT_ENABLE 1
24#define STA32X_THERMAL_RECOVERY_ENABLE 2
25
26struct sta32x_platform_data {
27 int output_conf;
28 int ch1_output_mapping;
29 int ch2_output_mapping;
30 int ch3_output_mapping;
31 int thermal_conf;
32};
33
34#endif /* __LINUX_SND__STA32X_H */
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index d2f37152f940..97091e3b9a0b 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -35,6 +35,7 @@
35#include <sound/initval.h> 35#include <sound/initval.h>
36#include <sound/tlv.h> 36#include <sound/tlv.h>
37 37
38#include <sound/sta32x.h>
38#include "sta32x.h" 39#include "sta32x.h"
39 40
40#define STA32X_RATES (SNDRV_PCM_RATE_32000 | \ 41#define STA32X_RATES (SNDRV_PCM_RATE_32000 | \
@@ -73,6 +74,7 @@ static const char *sta32x_supply_names[] = {
73struct sta32x_priv { 74struct sta32x_priv {
74 struct regulator_bulk_data supplies[ARRAY_SIZE(sta32x_supply_names)]; 75 struct regulator_bulk_data supplies[ARRAY_SIZE(sta32x_supply_names)];
75 struct snd_soc_codec *codec; 76 struct snd_soc_codec *codec;
77 struct sta32x_platform_data *pdata;
76 78
77 unsigned int mclk; 79 unsigned int mclk;
78 unsigned int format; 80 unsigned int format;
@@ -775,9 +777,10 @@ static int sta32x_resume(struct snd_soc_codec *codec)
775static int sta32x_probe(struct snd_soc_codec *codec) 777static int sta32x_probe(struct snd_soc_codec *codec)
776{ 778{
777 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); 779 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
778 int i, ret = 0; 780 int i, ret = 0, thermal = 0;
779 781
780 sta32x->codec = codec; 782 sta32x->codec = codec;
783 sta32x->pdata = dev_get_platdata(codec->dev);
781 784
782 /* regulators */ 785 /* regulators */
783 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++) 786 for (i = 0; i < ARRAY_SIZE(sta32x->supplies); i++)
@@ -820,25 +823,34 @@ static int sta32x_probe(struct snd_soc_codec *codec)
820 snd_soc_cache_write(codec, STA32X_AUTO3, 0x00); 823 snd_soc_cache_write(codec, STA32X_AUTO3, 0x00);
821 snd_soc_cache_write(codec, STA32X_C3CFG, 0x40); 824 snd_soc_cache_write(codec, STA32X_C3CFG, 0x40);
822 825
823 /* FIXME enable thermal warning adjustment and recovery */ 826 /* set thermal warning adjustment and recovery */
827 if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_ADJUSTMENT_ENABLE))
828 thermal |= STA32X_CONFA_TWAB;
829 if (!(sta32x->pdata->thermal_conf & STA32X_THERMAL_RECOVERY_ENABLE))
830 thermal |= STA32X_CONFA_TWRB;
824 snd_soc_update_bits(codec, STA32X_CONFA, 831 snd_soc_update_bits(codec, STA32X_CONFA,
825 STA32X_CONFA_TWAB | STA32X_CONFA_TWRB, 0); 832 STA32X_CONFA_TWAB | STA32X_CONFA_TWRB,
833 thermal);
826 834
827 /* FIXME select 2.1 mode */ 835 /* select output configuration */
828 snd_soc_update_bits(codec, STA32X_CONFF, 836 snd_soc_update_bits(codec, STA32X_CONFF,
829 STA32X_CONFF_OCFG_MASK, 837 STA32X_CONFF_OCFG_MASK,
830 1 << STA32X_CONFF_OCFG_SHIFT); 838 sta32x->pdata->output_conf
839 << STA32X_CONFF_OCFG_SHIFT);
831 840
832 /* FIXME channel to output mapping */ 841 /* channel to output mapping */
833 snd_soc_update_bits(codec, STA32X_C1CFG, 842 snd_soc_update_bits(codec, STA32X_C1CFG,
834 STA32X_CxCFG_OM_MASK, 843 STA32X_CxCFG_OM_MASK,
835 0 << STA32X_CxCFG_OM_SHIFT); 844 sta32x->pdata->ch1_output_mapping
845 << STA32X_CxCFG_OM_SHIFT);
836 snd_soc_update_bits(codec, STA32X_C2CFG, 846 snd_soc_update_bits(codec, STA32X_C2CFG,
837 STA32X_CxCFG_OM_MASK, 847 STA32X_CxCFG_OM_MASK,
838 1 << STA32X_CxCFG_OM_SHIFT); 848 sta32x->pdata->ch2_output_mapping
849 << STA32X_CxCFG_OM_SHIFT);
839 snd_soc_update_bits(codec, STA32X_C3CFG, 850 snd_soc_update_bits(codec, STA32X_C3CFG,
840 STA32X_CxCFG_OM_MASK, 851 STA32X_CxCFG_OM_MASK,
841 2 << STA32X_CxCFG_OM_SHIFT); 852 sta32x->pdata->ch3_output_mapping
853 << STA32X_CxCFG_OM_SHIFT);
842 854
843 /* initialize coefficient shadow RAM with reset values */ 855 /* initialize coefficient shadow RAM with reset values */
844 for (i = 4; i <= 49; i += 5) 856 for (i = 4; i <= 49; i += 5)