ASoC: sgtl5000: Add MicBias voltage support

Some systems may require to specify a bias different than default (1.25V).
This adds a property in sgtl5000 codec.
The property is specified in milli-volts so that it is coherent with datasheet.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index c417b4a..59336f6 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -140,6 +140,7 @@
 	struct clk *mclk;
 	int revision;
 	u8 micbias_resistor;
+	u8 micbias_voltage;
 };
 
 /*
@@ -1342,6 +1343,9 @@
 			SGTL5000_BIAS_R_MASK,
 			sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);
 
+	snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
+			SGTL5000_BIAS_R_MASK,
+			sgtl5000->micbias_voltage << SGTL5000_BIAS_R_SHIFT);
 	/*
 	 * disable DAP
 	 * TODO:
@@ -1511,10 +1515,19 @@
 			/* default is 4Kohms */
 			sgtl5000->micbias_resistor = 2;
 		}
+		if (!of_property_read_u32(np,
+			"micbias-voltage-m-volts", &value)) {
+			/* 1250mV => 0 */
+			/* steps of 250mV */
+			if ((value >= 1250) && (value <= 3000))
+				sgtl5000->micbias_voltage = (value / 250) - 5;
+			else {
+				sgtl5000->micbias_voltage = 0;
 				dev_err(&client->dev,
 					"Unsuitable MicBias resistor\n");
 			}
 		} else {
+			sgtl5000->micbias_voltage = 0;
 		}
 	}