From patchwork Sat Oct 11 03:46:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatol Pomozov X-Patchwork-Id: 5068241 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DAEC99F30B for ; Sat, 11 Oct 2014 03:47:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D7BE1201FE for ; Sat, 11 Oct 2014 03:47:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 531AD201EC for ; Sat, 11 Oct 2014 03:47:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CEACD2605BB; Sat, 11 Oct 2014 05:47:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id AA0E62605AD; Sat, 11 Oct 2014 05:46:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1625B2605B0; Sat, 11 Oct 2014 05:46:51 +0200 (CEST) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by alsa0.perex.cz (Postfix) with ESMTP id CFE4B2605AC for ; Sat, 11 Oct 2014 05:46:42 +0200 (CEST) Received: by mail-pd0-f173.google.com with SMTP id g10so2666018pdj.4 for ; Fri, 10 Oct 2014 20:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=PCK8SQWaSXveKmFlPz2uFgIlYi8oLrY7zd9SDHu02LQ=; b=Ze5RXm35WcDDMdOSa6BVnw9Brv+uat5Fot4ryba/4mGekIWhRnpJsWxzATkaQzbUvA 4g3bvV4HWj1bw5x4uFEK2SSGWikHDcuI6mnMIFZ12jwmj9jOyBMJa+jEz304IQPqRhcb 70+FR8vo0Pddk6DFkq8f6m1H68xd2ChRCVJ5HrHTv3yPZn8CZBQTKelX9ZahNDqOYtkV Yd141/2EldVzO3B7kCQfq51ToqePbV68BqCXzjmU7VUAtY/at4iqFkMtJc10Cx5TNgxn 2Q6c1BATJ/qUWJZhUfa9MQmfp4seR7aJGMWzWhebFL0u0Nzesb0F04Hz3cNtg79LxMjL CpEg== X-Received: by 10.68.221.102 with SMTP id qd6mr9393405pbc.123.1412999200950; Fri, 10 Oct 2014 20:46:40 -0700 (PDT) Received: from argo.lan (76-198-28-160.lightspeed.sntcca.sbcglobal.net. [76.198.28.160]) by mx.google.com with ESMTPSA id ve10sm4786926pbc.65.2014.10.10.20.46.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Oct 2014 20:46:40 -0700 (PDT) From: Anatol Pomozov To: broonie@kernel.org, oder_chiou@realtek.com Date: Fri, 10 Oct 2014 20:46:36 -0700 Message-Id: <1412999196-14395-1-git-send-email-anatol.pomozov@gmail.com> X-Mailer: git-send-email 2.1.2 Cc: alsa-devel@alsa-project.org, dgreid@chromium.org, Anatol Pomozov Subject: [alsa-devel] [PATCH] ASoC: rt5677: Add option to configure gpio as floating/pullup/pulldown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP gpio_config is array of 6 elements that allows to set GPIO as floating, pullup, pulldown. Sponsored: Google ChromeOS Signed-off-by: Anatol Pomozov --- Documentation/devicetree/bindings/sound/rt5677.txt | 7 ++++ include/sound/rt5677.h | 3 ++ sound/soc/codecs/rt5677.c | 39 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt index 0701b83..f82f0e9 100644 --- a/Documentation/devicetree/bindings/sound/rt5677.txt +++ b/Documentation/devicetree/bindings/sound/rt5677.txt @@ -27,6 +27,12 @@ Optional properties: Boolean. Indicate MIC1/2 input and LOUT1/2/3 outputs are differential, rather than single-ended. +- realtek,gpio-config + Array of six 8bit elements that configures GPIO. + 0 - floating (reset value) + 1 - pull down + 2 - pull up + Pins on the device (for linking into audio routes): * IN1P @@ -56,4 +62,5 @@ rt5677 { realtek,pow-ldo2-gpio = <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; realtek,in1-differential = "true"; + realtek,gpio-config = /bits/ 8 <0 0 0 0 0 2>; /* pull up GPIO6 */ }; diff --git a/include/sound/rt5677.h b/include/sound/rt5677.h index 082670e..a56b429 100644 --- a/include/sound/rt5677.h +++ b/include/sound/rt5677.h @@ -27,6 +27,9 @@ struct rt5677_platform_data { bool lout3_diff; /* DMIC2 clock source selection */ enum rt5677_dmic2_clk dmic2_clk_pin; + + /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */ + u8 gpio_config[6]; }; #endif diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 16aa4d9..a454df3 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) return 0; } +/** Configures the gpio as + * 0 - floating + * 1 - pull down + * 2 - pull up + */ +static void rt5677_gpio_config(struct rt5677_priv *rt5677, unsigned offset, + int value) +{ + int shift; + + switch (offset) { + case RT5677_GPIO1 ... RT5677_GPIO2: + shift = 2 * (1 - offset); + regmap_update_bits(rt5677->regmap, + RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL2, + 0x3 << shift, + (value & 0x3) << shift); + break; + + case RT5677_GPIO3 ... RT5677_GPIO6: + shift = 2 * (9 - offset); + regmap_update_bits(rt5677->regmap, + RT5677_PR_BASE + RT5677_DIG_IN_PIN_ST_CTRL3, + 0x3 << shift, + (value & 0x3) << shift); + break; + + default: + break; + } +} + static struct gpio_chip rt5677_template_chip = { .label = "rt5677", .owner = THIS_MODULE, @@ -3353,6 +3385,7 @@ static void rt5677_free_gpio(struct i2c_client *i2c) static int rt5677_probe(struct snd_soc_codec *codec) { struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + int i; rt5677->codec = codec; @@ -3371,6 +3404,9 @@ static int rt5677_probe(struct snd_soc_codec *codec) regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); + for (i = 0; i < RT5677_GPIO_NUM; i++) + rt5677_gpio_config(rt5677, i, rt5677->pdata.gpio_config[i]); + return 0; } @@ -3590,6 +3626,9 @@ static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) (rt5677->pow_ldo2 != -ENOENT)) return rt5677->pow_ldo2; + of_property_read_u8_array(np, "realtek,gpio-config", + rt5677->pdata.gpio_config, RT5677_GPIO_NUM); + return 0; }