aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2017-04-13 11:52:09 -0400
committerMark Brown <broonie@kernel.org>2017-04-21 13:01:38 -0400
commit06bdf385f66a53b335b324e28a43788b03e6f3e3 (patch)
tree1727efbc7f9e2095011561653e89f0f96ea69bc7
parentfbeea237af65c6dceca00886aba30839bc986fd7 (diff)
ASoC: cs35l35: Allow user to configure IMON SCALE
On the chip the IMON signal is a full 24-bits however normally only some of the bits will be sent over the bus. The chip provides a field to select which bits of the IMON will be sent back, this is the only feedback signal that has this feature. Add an additional entry to the cirrus,imon device tree property to allow the IMON scale parameter to be passed. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Brian Austin <brian.austin@cirrus.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/cs35l35.txt4
-rw-r--r--include/sound/cs35l35.h1
-rw-r--r--sound/soc/codecs/cs35l35.c22
-rw-r--r--sound/soc/codecs/cs35l35.h3
4 files changed, 21 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/sound/cs35l35.txt b/Documentation/devicetree/bindings/sound/cs35l35.txt
index 457d176dcee0..016b768bc722 100644
--- a/Documentation/devicetree/bindings/sound/cs35l35.txt
+++ b/Documentation/devicetree/bindings/sound/cs35l35.txt
@@ -118,8 +118,8 @@ Optional Monitor Signal Format sub-node:
118 Sections 7.44 - 7.53 lists values for the depth, location, and frame 118 Sections 7.44 - 7.53 lists values for the depth, location, and frame
119 for each monitoring signal. 119 for each monitoring signal.
120 120
121 - cirrus,imon : 3 8 bit values to set the depth, location, and frame 121 - cirrus,imon : 4 8 bit values to set the depth, location, frame and ADC
122 of the IMON monitor signal. 122 scale of the IMON monitor signal.
123 123
124 - cirrus,vmon : 3 8 bit values to set the depth, location, and frame 124 - cirrus,vmon : 3 8 bit values to set the depth, location, and frame
125 of the VMON monitor signal. 125 of the VMON monitor signal.
diff --git a/include/sound/cs35l35.h b/include/sound/cs35l35.h
index 88744bbd6728..29da899e17e4 100644
--- a/include/sound/cs35l35.h
+++ b/include/sound/cs35l35.h
@@ -57,6 +57,7 @@ struct monitor_cfg {
57 u8 imon_dpth; 57 u8 imon_dpth;
58 u8 imon_loc; 58 u8 imon_loc;
59 u8 imon_frm; 59 u8 imon_frm;
60 u8 imon_scale;
60 u8 vmon_dpth; 61 u8 vmon_dpth;
61 u8 vmon_loc; 62 u8 vmon_loc;
62 u8 vmon_frm; 63 u8 vmon_frm;
diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
index dc6591adc96d..f8aef5869b03 100644
--- a/sound/soc/codecs/cs35l35.c
+++ b/sound/soc/codecs/cs35l35.c
@@ -918,6 +918,11 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec)
918 CS35L35_MON_FRM_MASK, 918 CS35L35_MON_FRM_MASK,
919 monitor_config->imon_frm << 919 monitor_config->imon_frm <<
920 CS35L35_MON_FRM_SHIFT); 920 CS35L35_MON_FRM_SHIFT);
921 regmap_update_bits(cs35l35->regmap,
922 CS35L35_IMON_SCALE_CTL,
923 CS35L35_IMON_SCALE_MASK,
924 monitor_config->imon_scale <<
925 CS35L35_IMON_SCALE_SHIFT);
921 } 926 }
922 if (monitor_config->vpmon_specs) { 927 if (monitor_config->vpmon_specs) {
923 regmap_update_bits(cs35l35->regmap, 928 regmap_update_bits(cs35l35->regmap,
@@ -1161,7 +1166,9 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1161 struct classh_cfg *classh_config = &pdata->classh_algo; 1166 struct classh_cfg *classh_config = &pdata->classh_algo;
1162 struct monitor_cfg *monitor_config = &pdata->mon_cfg; 1167 struct monitor_cfg *monitor_config = &pdata->mon_cfg;
1163 unsigned int val32 = 0; 1168 unsigned int val32 = 0;
1164 u8 monitor_array[3]; 1169 u8 monitor_array[4];
1170 const int imon_array_size = ARRAY_SIZE(monitor_array);
1171 const int mon_array_size = imon_array_size - 1;
1165 int ret = 0; 1172 int ret = 0;
1166 1173
1167 if (!np) 1174 if (!np)
@@ -1302,15 +1309,16 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1302 monitor_config->is_present = signal_format ? true : false; 1309 monitor_config->is_present = signal_format ? true : false;
1303 if (monitor_config->is_present) { 1310 if (monitor_config->is_present) {
1304 ret = of_property_read_u8_array(signal_format, "cirrus,imon", 1311 ret = of_property_read_u8_array(signal_format, "cirrus,imon",
1305 monitor_array, ARRAY_SIZE(monitor_array)); 1312 monitor_array, imon_array_size);
1306 if (!ret) { 1313 if (!ret) {
1307 monitor_config->imon_specs = true; 1314 monitor_config->imon_specs = true;
1308 monitor_config->imon_dpth = monitor_array[0]; 1315 monitor_config->imon_dpth = monitor_array[0];
1309 monitor_config->imon_loc = monitor_array[1]; 1316 monitor_config->imon_loc = monitor_array[1];
1310 monitor_config->imon_frm = monitor_array[2]; 1317 monitor_config->imon_frm = monitor_array[2];
1318 monitor_config->imon_scale = monitor_array[3];
1311 } 1319 }
1312 ret = of_property_read_u8_array(signal_format, "cirrus,vmon", 1320 ret = of_property_read_u8_array(signal_format, "cirrus,vmon",
1313 monitor_array, ARRAY_SIZE(monitor_array)); 1321 monitor_array, mon_array_size);
1314 if (!ret) { 1322 if (!ret) {
1315 monitor_config->vmon_specs = true; 1323 monitor_config->vmon_specs = true;
1316 monitor_config->vmon_dpth = monitor_array[0]; 1324 monitor_config->vmon_dpth = monitor_array[0];
@@ -1318,7 +1326,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1318 monitor_config->vmon_frm = monitor_array[2]; 1326 monitor_config->vmon_frm = monitor_array[2];
1319 } 1327 }
1320 ret = of_property_read_u8_array(signal_format, "cirrus,vpmon", 1328 ret = of_property_read_u8_array(signal_format, "cirrus,vpmon",
1321 monitor_array, ARRAY_SIZE(monitor_array)); 1329 monitor_array, mon_array_size);
1322 if (!ret) { 1330 if (!ret) {
1323 monitor_config->vpmon_specs = true; 1331 monitor_config->vpmon_specs = true;
1324 monitor_config->vpmon_dpth = monitor_array[0]; 1332 monitor_config->vpmon_dpth = monitor_array[0];
@@ -1326,7 +1334,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1326 monitor_config->vpmon_frm = monitor_array[2]; 1334 monitor_config->vpmon_frm = monitor_array[2];
1327 } 1335 }
1328 ret = of_property_read_u8_array(signal_format, "cirrus,vbstmon", 1336 ret = of_property_read_u8_array(signal_format, "cirrus,vbstmon",
1329 monitor_array, ARRAY_SIZE(monitor_array)); 1337 monitor_array, mon_array_size);
1330 if (!ret) { 1338 if (!ret) {
1331 monitor_config->vbstmon_specs = true; 1339 monitor_config->vbstmon_specs = true;
1332 monitor_config->vbstmon_dpth = monitor_array[0]; 1340 monitor_config->vbstmon_dpth = monitor_array[0];
@@ -1334,7 +1342,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1334 monitor_config->vbstmon_frm = monitor_array[2]; 1342 monitor_config->vbstmon_frm = monitor_array[2];
1335 } 1343 }
1336 ret = of_property_read_u8_array(signal_format, "cirrus,vpbrstat", 1344 ret = of_property_read_u8_array(signal_format, "cirrus,vpbrstat",
1337 monitor_array, ARRAY_SIZE(monitor_array)); 1345 monitor_array, mon_array_size);
1338 if (!ret) { 1346 if (!ret) {
1339 monitor_config->vpbrstat_specs = true; 1347 monitor_config->vpbrstat_specs = true;
1340 monitor_config->vpbrstat_dpth = monitor_array[0]; 1348 monitor_config->vpbrstat_dpth = monitor_array[0];
@@ -1342,7 +1350,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,
1342 monitor_config->vpbrstat_frm = monitor_array[2]; 1350 monitor_config->vpbrstat_frm = monitor_array[2];
1343 } 1351 }
1344 ret = of_property_read_u8_array(signal_format, "cirrus,zerofill", 1352 ret = of_property_read_u8_array(signal_format, "cirrus,zerofill",
1345 monitor_array, ARRAY_SIZE(monitor_array)); 1353 monitor_array, mon_array_size);
1346 if (!ret) { 1354 if (!ret) {
1347 monitor_config->zerofill_specs = true; 1355 monitor_config->zerofill_specs = true;
1348 monitor_config->zerofill_dpth = monitor_array[0]; 1356 monitor_config->zerofill_dpth = monitor_array[0];
diff --git a/sound/soc/codecs/cs35l35.h b/sound/soc/codecs/cs35l35.h
index 54e9ac536b20..5a6e43a87c4d 100644
--- a/sound/soc/codecs/cs35l35.h
+++ b/sound/soc/codecs/cs35l35.h
@@ -148,6 +148,9 @@
148#define CS35L35_MON_FRM_MASK 0x80 148#define CS35L35_MON_FRM_MASK 0x80
149#define CS35L35_MON_FRM_SHIFT 7 149#define CS35L35_MON_FRM_SHIFT 7
150 150
151#define CS35L35_IMON_SCALE_MASK 0xF8
152#define CS35L35_IMON_SCALE_SHIFT 3
153
151#define CS35L35_MS_MASK 0x80 154#define CS35L35_MS_MASK 0x80
152#define CS35L35_MS_SHIFT 7 155#define CS35L35_MS_SHIFT 7
153#define CS35L35_SPMODE_MASK 0x40 156#define CS35L35_SPMODE_MASK 0x40