ASoC: arizona: Add support for setting the output volume limits
[sfrench/cifs-2.6.git] / sound / soc / codecs / arizona.c
index e6967385dccb8264be7968a4dbe10f49f90a3587..b3375e19598a8372dbedbb4e012cb343d5c0fbdb 100644 (file)
@@ -372,6 +372,22 @@ int arizona_init_common(struct arizona *arizona)
 }
 EXPORT_SYMBOL_GPL(arizona_init_common);
 
+int arizona_init_vol_limit(struct arizona *arizona)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(arizona->pdata.out_vol_limit); ++i) {
+               if (arizona->pdata.out_vol_limit[i])
+                       regmap_update_bits(arizona->regmap,
+                                          ARIZONA_DAC_VOLUME_LIMIT_1L + i * 4,
+                                          ARIZONA_OUT1L_VOL_LIM_MASK,
+                                          arizona->pdata.out_vol_limit[i]);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(arizona_init_vol_limit);
+
 const char * const arizona_mixer_texts[ARIZONA_NUM_MIXER_INPUTS] = {
        "None",
        "Tone Generator 1",
@@ -2810,6 +2826,15 @@ int arizona_of_get_audio_pdata(struct arizona *arizona)
                count++;
        }
 
+       count = 0;
+       of_property_for_each_u32(np, "wlf,out-volume-limit", prop, cur, val) {
+               if (count == ARRAY_SIZE(pdata->out_vol_limit))
+                       break;
+
+               pdata->out_vol_limit[count] = val;
+               count++;
+       }
+
        ret = of_property_read_u32_array(np, "wlf,spk-fmt",
                                         pdm_val, ARRAY_SIZE(pdm_val));