diff options
author | Anatol Pomozov <anatol.pomozov@gmail.com> | 2014-10-10 23:46:36 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-20 07:22:20 -0400 |
commit | 40eb90a18e93fbd4fd0e6892b31241356c3c8e43 (patch) | |
tree | 401f2d17cb15f745d8f31a7045bff61be7315f15 | |
parent | 80fff6bf65dcae62255bdb592603dfc247c8cacf (diff) |
ASoC: rt5677: Add option to configure gpio as floating/pullup/pulldown
gpio_config is array of 6 elements that allows to set GPIO as
floating, pullup, pulldown.
Sponsored: Google ChromeOS
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | Documentation/devicetree/bindings/sound/rt5677.txt | 7 | ||||
-rw-r--r-- | include/sound/rt5677.h | 3 | ||||
-rw-r--r-- | sound/soc/codecs/rt5677.c | 39 |
3 files changed, 49 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt index 0701b834fc73..f82f0e906cd9 100644 --- a/Documentation/devicetree/bindings/sound/rt5677.txt +++ b/Documentation/devicetree/bindings/sound/rt5677.txt | |||
@@ -27,6 +27,12 @@ Optional properties: | |||
27 | Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential, | 27 | Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential, |
28 | rather than single-ended. | 28 | rather than single-ended. |
29 | 29 | ||
30 | - realtek,gpio-config | ||
31 | Array of six 8bit elements that configures GPIO. | ||
32 | 0 - floating (reset value) | ||
33 | 1 - pull down | ||
34 | 2 - pull up | ||
35 | |||
30 | Pins on the device (for linking into audio routes): | 36 | Pins on the device (for linking into audio routes): |
31 | 37 | ||
32 | * IN1P | 38 | * IN1P |
@@ -56,4 +62,5 @@ rt5677 { | |||
56 | realtek,pow-ldo2-gpio = | 62 | realtek,pow-ldo2-gpio = |
57 | <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; | 63 | <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; |
58 | realtek,in1-differential = "true"; | 64 | realtek,in1-differential = "true"; |
65 | realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ | ||
59 | }; | 66 | }; |
diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h index 082670e3a353..a56b429a1dbc 100644 --- a/include/sound/rt5677.h +++ b/include/sound/rt5677.h | |||
@@ -27,6 +27,9 @@ struct rt5677_platform_data { | |||
27 | bool lout3_diff; | 27 | bool lout3_diff; |
28 | /* DMIC2 clock source selection */ | 28 | /* DMIC2 clock source selection */ |
29 | enum rt5677_dmic2_clk dmic2_clk_pin; | 29 | enum rt5677_dmic2_clk dmic2_clk_pin; |
30 | |||
31 | /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */ | ||
32 | u8 gpio_config[6]; | ||
30 | }; | 33 | }; |
31 | 34 | ||
32 | #endif | 35 | #endif |
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 16aa4d99a713..a454df39b7a5 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c | |||
@@ -3309,6 +3309,38 @@ static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset) | |||
3309 | return 0; | 3309 | return 0; |
3310 | } | 3310 | } |
3311 | 3311 | ||
3312 | /** Configures the gpio as | ||
3313 | * 0 - floating | ||
3314 | * 1 - pull down | ||
3315 | * 2 - pull up | ||
3316 | */ | ||
3317 | static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, | ||
3318 | int value) | ||
3319 | { | ||
3320 | int shift; | ||
3321 | |||
3322 | switch (offset) { | ||
3323 | case RT5677_GPIO1 ... RT5677_GPIO2: | ||
3324 | shift = 2 * (1 - offset); | ||
3325 | regmap_update_bits(rt5677->regmap, | ||
3326 | RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2, | ||
3327 | 0x3 << shift, | ||
3328 | (value & 0x3) << shift); | ||
3329 | break; | ||
3330 | |||
3331 | case RT5677_GPIO3 ... RT5677_GPIO6: | ||
3332 | shift = 2 * (9 - offset); | ||
3333 | regmap_update_bits(rt5677->regmap, | ||
3334 | RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3, | ||
3335 | 0x3 << shift, | ||
3336 | (value & 0x3) << shift); | ||
3337 | break; | ||
3338 | |||
3339 | default: | ||
3340 | break; | ||
3341 | } | ||
3342 | } | ||
3343 | |||
3312 | static struct gpio_chip rt5677_template_chip = { | 3344 | static struct gpio_chip rt5677_template_chip = { |
3313 | .label = "rt5677", | 3345 | .label = "rt5677", |
3314 | .owner = THIS_MODULE, | 3346 | .owner = THIS_MODULE, |
@@ -3353,6 +3385,7 @@ static void rt5677_free_gpio(struct i2c_client *i2c) | |||
3353 | static int rt5677_probe(struct snd_soc_codec *codec) | 3385 | static int rt5677_probe(struct snd_soc_codec *codec) |
3354 | { | 3386 | { |
3355 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | 3387 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); |
3388 | int i; | ||
3356 | 3389 | ||
3357 | rt5677->codec = codec; | 3390 | rt5677->codec = codec; |
3358 | 3391 | ||
@@ -3371,6 +3404,9 @@ static int rt5677_probe(struct snd_soc_codec *codec) | |||
3371 | regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); | 3404 | regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); |
3372 | regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); | 3405 | regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); |
3373 | 3406 | ||
3407 | for (i = 0; i < RT5677_GPIO_NUM; i++) | ||
3408 | rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]); | ||
3409 | |||
3374 | return 0; | 3410 | return 0; |
3375 | } | 3411 | } |
3376 | 3412 | ||
@@ -3590,6 +3626,9 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) | |||
3590 | (rt5677->pow_ldo2 != -ENOENT)) | 3626 | (rt5677->pow_ldo2 != -ENOENT)) |
3591 | return rt5677->pow_ldo2; | 3627 | return rt5677->pow_ldo2; |
3592 | 3628 | ||
3629 | of_property_read_u8_array(np, "realtek,gpio-config", | ||
3630 | rt5677->pdata.gpio_config, RT5677_GPIO_NUM); | ||
3631 | |||
3593 | return 0; | 3632 | return 0; |
3594 | } | 3633 | } |
3595 | 3634 | ||