diff options
author | Anatol Pomozov <anatol.pomozov@gmail.com> | 2015-01-22 18:47:24 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-27 13:32:14 -0500 |
commit | 39552d7ad1409d07ef278a97adbfbee02a272d25 (patch) | |
tree | cc3170e07494a58c75201a35221e36302ab77610 | |
parent | ddf9ea21f5fa0832c9711ae13dd467d1f5c4cd87 (diff) |
ASoC: ts3a227e: Add dts property that allows to specify micbias voltage
The voltage controls key press threshold.
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/sound/ts3a227e.txt | 5 | ||||
-rw-r--r-- | sound/soc/codecs/ts3a227e.c | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/ts3a227e.txt b/Documentation/devicetree/bindings/sound/ts3a227e.txt index e8bf23eb1803..a836881d9608 100644 --- a/Documentation/devicetree/bindings/sound/ts3a227e.txt +++ b/Documentation/devicetree/bindings/sound/ts3a227e.txt | |||
@@ -13,6 +13,11 @@ Required properties: | |||
13 | - interrupt-parent: The parent interrupt controller | 13 | - interrupt-parent: The parent interrupt controller |
14 | - interrupts: Interrupt number for /INT pin from the 227e | 14 | - interrupts: Interrupt number for /INT pin from the 227e |
15 | 15 | ||
16 | Optional properies: | ||
17 | - ti,micbias: Intended MICBIAS voltage (datasheet section 9.6.7). | ||
18 | Select 0/1/2/3/4/5/6/7 to specify MACBIAS voltage | ||
19 | 2.1V/2.2V/2.3V/2.4V/2.5V/2.6V/2.7V/2.8V | ||
20 | Default value is "1" (2.2V). | ||
16 | 21 | ||
17 | Examples: | 22 | Examples: |
18 | 23 | ||
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index b55034f63de5..65f8ec2094fb 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c | |||
@@ -79,6 +79,10 @@ static const int ts3a227e_buttons[] = { | |||
79 | /* TS3A227E_REG_SETTING_2 0x05 */ | 79 | /* TS3A227E_REG_SETTING_2 0x05 */ |
80 | #define KP_ENABLE 0x04 | 80 | #define KP_ENABLE 0x04 |
81 | 81 | ||
82 | /* TS3A227E_REG_SETTING_3 0x06 */ | ||
83 | #define MICBIAS_SETTING_SFT (3) | ||
84 | #define MICBIAS_SETTING_MASK (0x7 << MICBIAS_SETTING_SFT) | ||
85 | |||
82 | /* TS3A227E_REG_ACCESSORY_STATUS 0x0b */ | 86 | /* TS3A227E_REG_ACCESSORY_STATUS 0x0b */ |
83 | #define TYPE_3_POLE 0x01 | 87 | #define TYPE_3_POLE 0x01 |
84 | #define TYPE_4_POLE_OMTP 0x02 | 88 | #define TYPE_4_POLE_OMTP 0x02 |
@@ -248,6 +252,21 @@ static const struct regmap_config ts3a227e_regmap_config = { | |||
248 | .num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults), | 252 | .num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults), |
249 | }; | 253 | }; |
250 | 254 | ||
255 | static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np) | ||
256 | { | ||
257 | u32 micbias; | ||
258 | int err; | ||
259 | |||
260 | err = of_property_read_u32(np, "ti,micbias", &micbias); | ||
261 | if (!err) { | ||
262 | regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3, | ||
263 | MICBIAS_SETTING_MASK, | ||
264 | (micbias & 0x07) << MICBIAS_SETTING_SFT); | ||
265 | } | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
251 | static int ts3a227e_i2c_probe(struct i2c_client *i2c, | 270 | static int ts3a227e_i2c_probe(struct i2c_client *i2c, |
252 | const struct i2c_device_id *id) | 271 | const struct i2c_device_id *id) |
253 | { | 272 | { |
@@ -265,6 +284,14 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c, | |||
265 | if (IS_ERR(ts3a227e->regmap)) | 284 | if (IS_ERR(ts3a227e->regmap)) |
266 | return PTR_ERR(ts3a227e->regmap); | 285 | return PTR_ERR(ts3a227e->regmap); |
267 | 286 | ||
287 | if (dev->of_node) { | ||
288 | ret = ts3a227e_parse_dt(ts3a227e, dev->of_node); | ||
289 | if (ret) { | ||
290 | dev_err(dev, "Failed to parse device tree: %d\n", ret); | ||
291 | return ret; | ||
292 | } | ||
293 | } | ||
294 | |||
268 | ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt, | 295 | ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt, |
269 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 296 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
270 | "TS3A227E", ts3a227e); | 297 | "TS3A227E", ts3a227e); |