Received: by 10.192.165.148 with SMTP id m20csp3524338imm; Mon, 30 Apr 2018 01:31:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr5CP7SQuIaQYv91H1dc/MeWEeJHgaKJUMmDhjS69vdHrFri9uG+cQRncyn5UYjkfQI6CWf X-Received: by 10.98.74.80 with SMTP id x77mr11219090pfa.142.1525077103861; Mon, 30 Apr 2018 01:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525077103; cv=none; d=google.com; s=arc-20160816; b=yAtgcekAeMdJOvN88YRr78eqG3MfkhcpDH5CtO3Qk9GnTmNgsKpY9xJvYOQAnyetL4 /yfeyqOKfBn1c7QvVFraIdndYJdQjcPA8Nen+ezpWkchv1mSL7P1Fo+3RXNC6FKVfdbi Jv47hW9AEJib2FLhic8NglJxQ5hbQ3mdYWrNxOl/3VaSpTOTpVI+IQwaOSfJdR1QIPv/ Djwxai3qnwiB1KY0qwsyfh4Bd2VGCQXMyIqvPl1gT4Qo660EM5ks382Vi5aqFRU3Ni/Z qLOVLi2lF5DOqdjnZcys32LM0iecr1aYI9WOdl4ycjtyFA8h9wSIAHmxH2Tk+LHG1/vN gYOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=WGM1O/Z7ScKdY0UKskOmQbp46yKL3cHOKeI/4S9xZvk=; b=ln760n7cFY+iy+aOY0Xopdl8qxCCbQRHphWq5uroDz5rbYmLmcwIhoxH9TJGmyFgXQ /e9K33AoGUPDgeFqOmeRMog48zy9JyvADXcWhYlUd2y8y2N4F/0QPsjKY8Vd6Wu5Q7N/ Z+Lqi8Unul6+p1LsSUaV+LcKhaFPn3KLGZw0/w+MNyiS4JrvRwky7xtJOvpL9UEyrR5V VGKeIEhcLTr9rI4jZe6rinHRT1bwfLVOW2OaXsFyyswrrjl6jxyUvjM3mQhLa2K/8K0K RE7a+TdmYKHhaS3dwzCy/5ipQYmQa2ti76bqz2zeQCKWc2eVy2Qzj712SSeCGJtSuOFg Wseg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kEYYwoVE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si5053101pls.278.2018.04.30.01.31.29; Mon, 30 Apr 2018 01:31:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kEYYwoVE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeD3Iax (ORCPT + 99 others); Mon, 30 Apr 2018 04:30:53 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:60020 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbeD3Iav (ORCPT ); Mon, 30 Apr 2018 04:30:51 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w3U8Uam9029665; Mon, 30 Apr 2018 03:30:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1525077036; bh=LcORs1oigTrK5SRG8fCMoKitPKhMV6RRDZ1zwI/Ixwk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kEYYwoVEA6DGTCk+ybLBjxfdnuAmRrjnE2MiHSrUn9FDZSRQwyCd2aq5v2vRBZQQO l5pTatNaK368u/iWHyHt/sMo8BvPcs1jOvai3KMwper1GJvNMEf8CCOKoZ264XCj8T 8N8vLpi7J2wLSAY2waIeGj9O+KkfZT292QTSFbDg= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3U8UZDh030986; Mon, 30 Apr 2018 03:30:35 -0500 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 30 Apr 2018 03:30:35 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 30 Apr 2018 03:30:35 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w3U8UY6X019379; Mon, 30 Apr 2018 03:30:34 -0500 From: Jean-Jacques Hiblot To: , , , , CC: , , , , , Jean-Jacques Hiblot Subject: [PATCH v3 2/3] ASoC: tas6424: Add support for the mute pin Date: Mon, 30 Apr 2018 10:30:17 +0200 Message-ID: <1525077018-15863-3-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525077018-15863-1-git-send-email-jjhiblot@ti.com> References: <1525077018-15863-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mute can be connected to GPIO. In that case we have to drive it to the correct value Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Rob Herring --- .../devicetree/bindings/sound/ti,tas6424.txt | 1 + sound/soc/codecs/tas6424.c | 37 +++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/ti,tas6424.txt b/Documentation/devicetree/bindings/sound/ti,tas6424.txt index df71e41..eacb54f 100644 --- a/Documentation/devicetree/bindings/sound/ti,tas6424.txt +++ b/Documentation/devicetree/bindings/sound/ti,tas6424.txt @@ -7,6 +7,7 @@ Required properties: - reg: I2C slave address - sound-dai-cells: must be equal to 0 - standby-gpios: GPIO used to shut the TAS6424 down. + - mute-gpios: GPIO used to mute all the outputs Example: diff --git a/sound/soc/codecs/tas6424.c b/sound/soc/codecs/tas6424.c index 5abb17f..89fd0c1 100644 --- a/sound/soc/codecs/tas6424.c +++ b/sound/soc/codecs/tas6424.c @@ -45,6 +45,7 @@ struct tas6424_data { unsigned int last_fault2; unsigned int last_warn; struct gpio_desc *standby_gpio; + struct gpio_desc *mute_gpio; }; /* @@ -251,10 +252,16 @@ static int tas6424_set_dai_tdm_slot(struct snd_soc_dai *dai, static int tas6424_mute(struct snd_soc_dai *dai, int mute) { struct snd_soc_component *component = dai->component; + struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component); unsigned int val; dev_dbg(component->dev, "%s() mute=%d\n", __func__, mute); + if (tas6424->mute_gpio) { + gpiod_set_value_cansleep(tas6424->mute_gpio, mute); + return 0; + } + if (mute) val = TAS6424_ALL_STATE_MUTE; else @@ -289,6 +296,7 @@ static int tas6424_power_on(struct snd_soc_component *component) { struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component); int ret; + u8 chan_states; ret = regulator_bulk_enable(ARRAY_SIZE(tas6424->supplies), tas6424->supplies); @@ -305,7 +313,18 @@ static int tas6424_power_on(struct snd_soc_component *component) return ret; } - snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, TAS6424_ALL_STATE_MUTE); + if (tas6424->mute_gpio) { + gpiod_set_value_cansleep(tas6424->mute_gpio, 0); + /* + * channels are muted via the mute pin. Don't also mute + * them via the registers so that subsequent register + * access is not necessary to un-mute the channels + */ + chan_states = TAS6424_ALL_STATE_PLAY; + } else { + chan_states = TAS6424_ALL_STATE_MUTE; + } + snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, chan_states); /* any time we come out of HIZ, the output channels automatically run DC * load diagnostics, wait here until this completes @@ -645,6 +664,22 @@ static int tas6424_i2c_probe(struct i2c_client *client, tas6424->standby_gpio = NULL; } + /* + * Get control of the mute pin and set it HIGH in order to start with + * all the output muted. + * Note: The actual pin polarity is taken care of in the GPIO lib + * according the polarity specified in the DTS. + */ + tas6424->mute_gpio = devm_gpiod_get_optional(dev, "mute", + GPIOD_OUT_HIGH); + if (IS_ERR(tas6424->mute_gpio)) { + if (PTR_ERR(tas6424->mute_gpio) == -EPROBE_DEFER) + return -EPROBE_DEFER; + dev_info(dev, "failed to get nmute GPIO: %ld\n", + PTR_ERR(tas6424->mute_gpio)); + tas6424->mute_gpio = NULL; + } + for (i = 0; i < ARRAY_SIZE(tas6424->supplies); i++) tas6424->supplies[i].supply = tas6424_supply_names[i]; ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(tas6424->supplies), -- 2.7.4