From patchwork Thu Jan 22 23:47:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatol Pomozov X-Patchwork-Id: 5689871 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03AD6C058D for ; Thu, 22 Jan 2015 23:48:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27EEA2015A for ; Thu, 22 Jan 2015 23:48:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 02AE2200FE for ; Thu, 22 Jan 2015 23:48:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B3011265460; Fri, 23 Jan 2015 00:48:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 C8225265344; Fri, 23 Jan 2015 00:47:46 +0100 (CET) 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 06292265325; Fri, 23 Jan 2015 00:47:42 +0100 (CET) Received: from mail-qa0-f74.google.com (mail-qa0-f74.google.com [209.85.216.74]) by alsa0.perex.cz (Postfix) with ESMTP id 464B026530D for ; Fri, 23 Jan 2015 00:47:35 +0100 (CET) Received: by mail-qa0-f74.google.com with SMTP id x12so321768qac.1 for ; Thu, 22 Jan 2015 15:47:34 -0800 (PST) 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=FYmQD/W7r3zRUdpIAHdynZh2tqOq2Tbz+y+NoY9MnFM=; b=CPHqaF8JVW2xnxAaIHgosvX6K2Cu1V90olRIPSdPsUURD5L+w6gvGvECBR0Jryn8Yh ySdHm4lM61N6decdAySBCnFanghzmT3vqhICO1uI4EDOsPJhqGSWyi1PbORGIBOogkP2 fVLlOdSG6mNbEtGQ5PWi45TQf7F2NRfqrphXZWRU6sF3HTS/Eq0DD0j58lTs1aMKsMIq Wjy5ouZ9ClENYoaF36fmZo1nzGr0nD14oDDZ6d3xB4fAo6HO70AMbwiko9keF5jgf0ne D54Buejw78sQ0Ey+/jo1bE2SqSqHiqXe4L2pUs1pwGrpgRZ70ZAwWKXoZjd7u/r5gmA9 5TnA== X-Gm-Message-State: ALoCoQnBi6H/rdrHa7cPwHk1ALawjqoRtQnlgqTY9Pe1K7FvsbYNXghydZQOwGRr0p6v05xYkBPCPaUWluL74Gq+Frrxa2U4qvhjCBGZ7mDDPhGm+QltpG+SqqEX84uITaXeLQJ4hrda4+FwUsj8fUCJDy4vQmO8BnjdxBFf77CZDzFeIAblDYw= X-Received: by 10.236.2.227 with SMTP id 63mr3172072yhf.12.1421970454305; Thu, 22 Jan 2015 15:47:34 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id v10si1402056qcf.3.2015.01.22.15.47.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 15:47:34 -0800 (PST) Received: from anatol.mtv.corp.google.com ([172.22.64.197]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id X1hKkJte.1; Thu, 22 Jan 2015 15:47:34 -0800 Received: by anatol.mtv.corp.google.com (Postfix, from userid 67983) id 753FC1003AC; Thu, 22 Jan 2015 15:47:33 -0800 (PST) From: Anatol Pomozov To: alsa-devel@alsa-project.org, broonie@kernel.org, dgreid@chromium.org Date: Thu, 22 Jan 2015 15:47:24 -0800 Message-Id: <1421970444-15939-1-git-send-email-anatol.pomozov@gmail.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c Cc: Anatol Pomozov Subject: [alsa-devel] [PATCH] ASoC: ts3a227e: Add dts property that allows to specify micbias voltage 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 The voltage controls key press threshold. Signed-off-by: Anatol Pomozov --- .../devicetree/bindings/sound/ts3a227e.txt | 5 ++++ sound/soc/codecs/ts3a227e.c | 27 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/ts3a227e.txt b/Documentation/devicetree/bindings/sound/ts3a227e.txt index e8bf23e..a836881 100644 --- a/Documentation/devicetree/bindings/sound/ts3a227e.txt +++ b/Documentation/devicetree/bindings/sound/ts3a227e.txt @@ -13,6 +13,11 @@ Required properties: - interrupt-parent: The parent interrupt controller - interrupts: Interrupt number for /INT pin from the 227e +Optional properies: + - ti,micbias: Intended MICBIAS voltage (datasheet section 9.6.7). + Select 0/1/2/3/4/5/6/7 to specify MACBIAS voltage + 2.1V/2.2V/2.3V/2.4V/2.5V/2.6V/2.7V/2.8V + Default value is "1" (2.2V). Examples: diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c index 54d431c..5ecfa31 100644 --- a/sound/soc/codecs/ts3a227e.c +++ b/sound/soc/codecs/ts3a227e.c @@ -79,6 +79,10 @@ static const int ts3a227e_buttons[] = { /* TS3A227E_REG_SETTING_2 0x05 */ #define KP_ENABLE 0x04 +/* TS3A227E_REG_SETTING_3 0x06 */ +#define MICBIAS_SETTING_SFT (3) +#define MICBIAS_SETTING_MASK (0x7 << MICBIAS_SETTING_SFT) + /* TS3A227E_REG_ACCESSORY_STATUS 0x0b */ #define TYPE_3_POLE 0x01 #define TYPE_4_POLE_OMTP 0x02 @@ -248,6 +252,21 @@ static const struct regmap_config ts3a227e_regmap_config = { .num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults), }; +static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np) +{ + u32 micbias; + int err; + + err = of_property_read_u32(np, "ti,micbias", &micbias); + if (!err) { + regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3, + MICBIAS_SETTING_MASK, + (micbias & 0x07) << MICBIAS_SETTING_SFT); + } + + return 0; +} + static int ts3a227e_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -266,6 +285,14 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c, if (IS_ERR(ts3a227e->regmap)) return PTR_ERR(ts3a227e->regmap); + if (dev->of_node) { + ret = ts3a227e_parse_dt(ts3a227e, dev->of_node); + if (ret) { + dev_err(dev, "Failed to parse device tree: %d\n", ret); + return ret; + } + } + ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, "TS3A227E", ts3a227e);