From patchwork Wed Sep 17 05:28:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatol Pomozov X-Patchwork-Id: 4922751 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BECF3BEEA5 for ; Wed, 17 Sep 2014 05:29:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4D302015E for ; Wed, 17 Sep 2014 05:29:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7063B20155 for ; Wed, 17 Sep 2014 05:29:34 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 325A02652CF; Wed, 17 Sep 2014 07:29:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0600A26520E; Wed, 17 Sep 2014 07:29:21 +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 E1480265232; Wed, 17 Sep 2014 07:29:19 +0200 (CEST) Received: from mail-ie0-f202.google.com (mail-ie0-f202.google.com [209.85.223.202]) by alsa0.perex.cz (Postfix) with ESMTP id B16E52651CB for ; Wed, 17 Sep 2014 07:29:11 +0200 (CEST) Received: by mail-ie0-f202.google.com with SMTP id rd18so178868iec.3 for ; Tue, 16 Sep 2014 22:29:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/EGR59TNrP1yjf9g1vIDYYW+tMw82Or//UT6bAKIaPw=; b=G0sm+Vac3NPWImzUa14BeCuK588mhaFqO6Vsgv1udX0ZLoXJGu/Q1Yzl2r3S5fGMng aWYUH8zyep6uloutzWUDOfnJsgMWBXZY/iSYa8pE6K+L2lGhWcweXbFAn8swPhVSgGL7 Z0glibi9iaNuuQcqTX6utSOuUYWAhXGkfaqjaUGShzl15D3n1gBuASGuh5gpPl3B1mS+ APL1r0Sw0odJD9lXg1VS8wP9x6McUZNQ6BqXxY76SDA4BXUVq5sZY3BMFCxP5o4koic5 G1An8GjqR6pKsr02rQ6KmPFRrymPCM1wCEFN6f1/qFFsoMcV4Xi6YiTxXM4BPzc1jsIO i1Tw== X-Gm-Message-State: ALoCoQn4jeP9GbU1PFyggQ4myv0Sa3Nhj+MBbgCyEISxY7zkddvbPnDKgppaidy6uUVEIAXbzg0plEgSyZKtiU+I22Ljw2jB3PA2RGeuG7eNEILCxiYN9R9bqsOeZoMqZT4lZ95WpVSBg+7wryQ0JnZalSjrw+mMxQ7QDgiTyIpPaYGF7MN1ky0= X-Received: by 10.182.232.164 with SMTP id tp4mr23955010obc.29.1410931749940; Tue, 16 Sep 2014 22:29:09 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id j25si801277yhb.0.2014.09.16.22.29.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Sep 2014 22:29:09 -0700 (PDT) Received: from anatol.mtv.corp.google.com ([172.22.64.197]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 42Omwt4c.1; Tue, 16 Sep 2014 22:29:09 -0700 Received: by anatol.mtv.corp.google.com (Postfix, from userid 67983) id 0274A1003A8; Tue, 16 Sep 2014 22:29:08 -0700 (PDT) From: Anatol Pomozov To: broonie@kernel.org, lgirdwood@gmail.com Date: Tue, 16 Sep 2014 22:28:58 -0700 Message-Id: <1410931739-6088-1-git-send-email-anatol.pomozov@gmail.com> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, Anatol Pomozov Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5677: Add a configuration option for LDO2_POW pin 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 Some boards have this pin tied to board and do not require any configuration, some other boards allow to enable chip using GPIO. Add an option that tells which GPIO is used to power up the codec. Signed-off-by: Anatol Pomozov --- Documentation/devicetree/bindings/sound/rt5677.txt | 41 +++++++++++++++++++++ sound/soc/codecs/rt5677.c | 42 ++++++++++++++++++++++ sound/soc/codecs/rt5677.h | 1 + 3 files changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rt5677.txt diff --git a/Documentation/devicetree/bindings/sound/rt5677.txt b/Documentation/devicetree/bindings/sound/rt5677.txt new file mode 100644 index 0000000..98509fb --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rt5677.txt @@ -0,0 +1,41 @@ +RT5677 audio CODEC + +This device supports I2C only. + +Required properties: + +- compatible : "realtek,rt5677". + +- reg : The I2C address of the device. + +- interrupts : The CODEC's interrupt output. + +Optional properties: + +- realtek,pow-ldo2-gpio : The GPIO that controls the CODEC's POW_LDO2 pin. + +Pins on the device (for linking into audio routes): + + * IN1P + * IN1N + * IN2P + * IN2N + * MICBIAS1 + * DMIC1 + * DMIC2 + * DMIC3 + * DMIC4 + * LOUT1 + * LOUT2 + * LOUT3 + +Example: + +rt5677 { + compatible = "realtek,rt5677"; + reg = <0x2c>; + interrupt-parent = <&gpio>; + interrupts = ; + realtek,pow-ldo2-gpio = + <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; +}; diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 9847473..fbaceb6 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3495,6 +3496,24 @@ static const struct i2c_device_id rt5677_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); +static int rt5677_parse_dt(struct rt5677_priv *rt5677, struct device_node *np) +{ + rt5677->pow_ldo2 = of_get_named_gpio(np, + "realtek,pow-ldo2-gpio", 0); + + /* + * POW_LDO2 is optional (it may be statically tied on the board). + * -ENOENT means that the property doesn't exist, i.e. there is no + * GPIO, so is not an error. Any other error code means the property + * exists, but could not be parsed. + */ + if (!gpio_is_valid(rt5677->pow_ldo2) && + (rt5677->pow_ldo2 != -ENOENT)) + return rt5677->pow_ldo2; + + return 0; +} + static int rt5677_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -3513,6 +3532,29 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, if (pdata) rt5677->pdata = *pdata; + if (i2c->dev.of_node) { + ret = rt5677_parse_dt(rt5677, i2c->dev.of_node); + if (ret) { + dev_err(&i2c->dev, "Failed to parse device tree: %d\n", + ret); + return ret; + } + } else { + rt5677->pow_ldo2 = -EINVAL; + } + + if (gpio_is_valid(rt5677->pow_ldo2)) { + ret = devm_gpio_request_one(&i2c->dev, rt5677->pow_ldo2, + GPIOF_OUT_INIT_HIGH, + "RT5677 POW_LDO2"); + if (ret < 0) { + dev_err(&i2c->dev, "Failed to request POW_LDO2 %d: %d\n", + rt5677->pow_ldo2, ret); + return ret; + } + msleep(10); + } + rt5677->regmap = devm_regmap_init_i2c(i2c, &rt5677_regmap); if (IS_ERR(rt5677->regmap)) { ret = PTR_ERR(rt5677->regmap); diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index b61b72c..222a4137 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1550,6 +1550,7 @@ struct rt5677_priv { int pll_src; int pll_in; int pll_out; + int pow_ldo2; /* POW_LDO2 pin */ #ifdef CONFIG_GPIOLIB struct gpio_chip gpio_chip; #endif