From patchwork Thu Sep 11 15:08:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatol Pomozov X-Patchwork-Id: 4888941 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 0D155C0338 for ; Thu, 11 Sep 2014 15:17:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C253E2025A for ; Thu, 11 Sep 2014 15:17:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1D8D420251 for ; Thu, 11 Sep 2014 15:17:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0996826568C; Thu, 11 Sep 2014 17:17:02 +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 667942656BA; Thu, 11 Sep 2014 17:14:32 +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 B82D32656D0; Thu, 11 Sep 2014 17:14:31 +0200 (CEST) Received: from mail-pa0-f73.google.com (mail-pa0-f73.google.com [209.85.220.73]) by alsa0.perex.cz (Postfix) with ESMTP id A8C582656BA for ; Thu, 11 Sep 2014 17:08:57 +0200 (CEST) Received: by mail-pa0-f73.google.com with SMTP id kx10so1413019pab.0 for ; Thu, 11 Sep 2014 08:08:56 -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=7g8M7EOb04VNNV/BSf1ot642tXhxleaa03+WgjgyOJU=; b=lsYuryXvDhZ13kBD8dRebvwtCXQgWUz5fiTBCifymC8nHbQ10S4/kdseVIm1RUdI00 rW02ssVaftYXMO1y6oILP4RmqK0wCsZ/Mvr8MzccdfOe9uF/euewUn9UXxXcxRxZbqgp 8Ddogli9ivYgvbeRlY95wKiNyG7viRtlbc8K7Vxn1cMxoPUai09HLIuhI3iM+Nvn8NKP 9ua89rjDtFeAdQldVxVjBR9hYpkcs0tCRZj8v1RYD2dmjXZrF+dwjA1haxC/Qk23+j1C Ofdti0pL7/BVaEjHAFOI9roZMFRDZ+c1zgIC84OyBVf8lzGJAtteBzKbxZbmI+UQgFCN V06w== X-Gm-Message-State: ALoCoQnCTpuKSEHP2Z+jZNch/dNVbJ5vQu1wM3VwbFUCWNpH67i+B5p2Mp0xYB6oFWNSArNhqT3wxQSJGpF1Pivbmlv//aiRJ4Rg5HZ0WKs5N/GB4ZIJNg0Vzp4X/uAQUooIJZmvKJvj0IRMuigTInWOFj/vk0uhtFmyCVQGqbkpB6eOt5ajE0E= X-Received: by 10.66.196.193 with SMTP id io1mr770610pac.28.1410448136092; Thu, 11 Sep 2014 08:08:56 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id e24si48700yhe.3.2014.09.11.08.08.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Sep 2014 08:08:56 -0700 (PDT) Received: from anatol.mtv.corp.google.com ([172.22.64.197]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 8nZkmtoV.1; Thu, 11 Sep 2014 08:08:55 -0700 Received: by anatol.mtv.corp.google.com (Postfix, from userid 67983) id 1CE7E100394; Thu, 11 Sep 2014 08:08:55 -0700 (PDT) From: Anatol Pomozov To: alsa-devel@alsa-project.org Date: Thu, 11 Sep 2014 08:08:38 -0700 Message-Id: <1410448118-39936-1-git-send-email-anatol.pomozov@gmail.com> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 Cc: oder_chiou@realtek.com, bardliao@realtek.com, Anatol Pomozov , broonie@linaro.org Subject: [alsa-devel] [PATCH] 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 From: Anatol Pomozov 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 | 2 ++ 3 files changed, 85 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..572a42c --- /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 = <0x1c>; + 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 40a49ef..cf41e89 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3365,6 +3366,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) { @@ -3383,6 +3402,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 8791ab9..3c1b4dc 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1441,6 +1441,8 @@ struct rt5677_priv { int pll_src; int pll_in; int pll_out; + + int pow_ldo2; /* POW_LDO2 pin */ }; #endif /* __RT5677_H__ */