From patchwork Wed Nov 13 12:47:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 179301 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp9548698ilf; Wed, 13 Nov 2019 04:46:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxmFL1Qo+hcstHrvg19T1VCx/XQhewF+rLPriokT1gkRJ0tltAg8H2cEq0dxD0IylAHIyzA X-Received: by 2002:a17:906:d939:: with SMTP id rn25mr2471350ejb.147.1573649203062; Wed, 13 Nov 2019 04:46:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573649203; cv=none; d=google.com; s=arc-20160816; b=kpQcqBTJXPv+Y4BDF16EHlJcJ4tXh1Nzj5eyHrqpQlJHVtxtR8i6bzfMzmkt0WxrvS YHumhV/YClqOc5tP8xqvapMnmFim57PQFVPobS7va7DQzU0bN2wiWJzn4rX1nhmxn5pZ o8FjHsts2+/KYbKa7wVhSga3MhxJP4RsQBeYEDu8c1SrRrLIRefnpJSPfvWqnmRfkpD6 B9M+991Rjfeur4TJI1RtnNpg3rtY4p4lVEhOioNV0AbvmbbhAWB5Y30f6RT+/A2tXRIu 5vqIKE7mhC2BdPfDl3/vSKi2m9H5WJid0cBREyP9sxUJw/dzqsctZopiC5AWgJcYD4s0 Higw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8aQ8N44hvS+8dZKUfv1GLSveBB3IfB2708I6w+E/VzA=; b=Wk5e0frcyL63caV/v6eCJW57k4dMxiAOF3FIBkCVKLyeOkXDlFTT3AEgZ8qSEZzvbl OrH/38LrslsgNgWpTf5u7E+up+OKtJpArqpPuPUpApn9rDzJVRf+t+acqQDsr32C66Le zj0eBMKWVmrAlEH9pxXpii8IF7iFmtfKaYDibee+WWGD1n61LyLgILJJ8ZNn+t1WHFGA ljgZt42ypbl1ZaxJFPDlbf7lEnGoNR7GXtETMamRmvzpAGj9h3nLoCm1zuJa1MnpmWxy 8wpY1NF8XgVPr5H6F1UP1PBkM0QLBYkzgtMpYDysrh/b1gnx6xlMMOZskNKFykrdVA/6 gSgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ksFivVFH; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 u93si1408198edc.184.2019.11.13.04.46.42; Wed, 13 Nov 2019 04:46:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=ksFivVFH; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1726066AbfKMMqd (ORCPT + 8 others); Wed, 13 Nov 2019 07:46:33 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:36726 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbfKMMqd (ORCPT ); Wed, 13 Nov 2019 07:46:33 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xADCkOMl013610; Wed, 13 Nov 2019 06:46:24 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573649184; bh=8aQ8N44hvS+8dZKUfv1GLSveBB3IfB2708I6w+E/VzA=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ksFivVFHjffDLgFQK0dN/YY0iep7idsI/DJK/M/3mk93CKCkhIgEQqNhoLzsn2gjK Ps3l0mE/gdj4EamWZiPCU0Xuh0pqqyW9WuYgxsoWPWZ0ePUGOatN+mXBLGcwYVbF44 JJaGT1SdVkbAH/+HKxEVhflAyfKwSGxJdgZcETg4= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xADCkNK4115042 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Nov 2019 06:46:23 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 13 Nov 2019 06:46:05 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 13 Nov 2019 06:46:06 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id xADCkIGF127078; Wed, 13 Nov 2019 06:46:21 -0600 From: Peter Ujfalusi To: , CC: , , , , , Subject: [PATCH 1/2] bindings: sound: pcm3168a: Document optional RST gpio Date: Wed, 13 Nov 2019 14:47:33 +0200 Message-ID: <20191113124734.27984-2-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191113124734.27984-1-peter.ujfalusi@ti.com> References: <20191113124734.27984-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On boards where the RST line is not pulled up, but it is connected to a GPIO line this property must present in order to be able to enable the codec. Signed-off-by: Peter Ujfalusi --- Documentation/devicetree/bindings/sound/ti,pcm3168a.txt | 7 +++++++ 1 file changed, 7 insertions(+) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt index 5d9cb84c661d..f30aebc7603a 100644 --- a/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt +++ b/Documentation/devicetree/bindings/sound/ti,pcm3168a.txt @@ -25,6 +25,12 @@ Required properties: For required properties on SPI/I2C, consult SPI/I2C device tree documentation +Optional properties: + + - rst-gpios : Optional RST gpio line for the codec + RST = low: device power-down + RST = high: device is enabled + Examples: i2c0: i2c0@0 { @@ -34,6 +40,7 @@ i2c0: i2c0@0 { pcm3168a: audio-codec@44 { compatible = "ti,pcm3168a"; reg = <0x44>; + rst-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; clocks = <&clk_core CLK_AUDIO>; clock-names = "scki"; VDD1-supply = <&supply3v3>; From patchwork Wed Nov 13 12:47:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 179300 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp9548651ilf; Wed, 13 Nov 2019 04:46:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzyg5ALBgXTvURMWHeJo5hZ6XFRV2KczRxmIDtS0ONN/OvO/G++uPQCn/i+OwItYN0utHgv X-Received: by 2002:a50:a2c5:: with SMTP id 63mr3401002edm.48.1573649200797; Wed, 13 Nov 2019 04:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573649200; cv=none; d=google.com; s=arc-20160816; b=VIEyOymm1YxXKChtyV6pgdYiYx9ZO/vnN/jGugxVUx5g2JPM5MIrHM0NW3nfXKk3Ah 1rrtSR7BiNoRB5JrxgDcQh8xxYO+8VEBCJEDyvp/b6MxZRusX2RmZb3Qq8R2xty1AL9n 6TyWti5RbJ8k2LpBo4cwrK5fxWn0SFiTceKpGlzmGAwGYJ1S5YPWlHostw/owm7/2MGP rNMhyOC+piaLj9CJA9L2srM+P6WFUjcJwFDTS2yO53TbNHRu/grU8J4r1cqMuXA0Or7R vOGVfIBsYVSKXOma+pLdodbKRriGPAlrZxmASyBDITrjGLoQF2x6Z2nD67pLG1SlKtqY HZdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KcStxR+XaqqutrtFiRj7KO9BKQOGxi+kB1kiTLkhTJs=; b=t5EoCYEyrzVh7H86RR/3YmZomzrq9h3C1BBjZKQzl2ApnOP+49JBfnDWBb1Zq9D9wB fFZauIRZYlJhPz89s/yWBtugSSl02CO0kKvpLI0NWJ+jPEJPveSMRW7LUwVrTRn3aIIR bOkTS3uYPH9SznkJT+ngmlfiuL+uQjqch5duHQgd/t9pU1/eBWLEiH8ktIQjcUu3FUCj L7Yx4fqvdl9Ttba7HrrlCx6n/HTNSmYb5ljI9NukqswK6l+VDy2y04koEux4Z0es5oI1 qTifAEIqCX9pXVSz7kXpWf1trWIkIP7MMF8hNO8VSy/4laQADq8gKcQuzC7BgfcnRVrR CO+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MT7FUd3+; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 u93si1408198edc.184.2019.11.13.04.46.40; Wed, 13 Nov 2019 04:46:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=MT7FUd3+; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1726979AbfKMMqf (ORCPT + 8 others); Wed, 13 Nov 2019 07:46:35 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:36728 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbfKMMqf (ORCPT ); Wed, 13 Nov 2019 07:46:35 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xADCkQLH013616; Wed, 13 Nov 2019 06:46:26 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1573649186; bh=KcStxR+XaqqutrtFiRj7KO9BKQOGxi+kB1kiTLkhTJs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MT7FUd3+UFVzd4m9y37DYwp2DyEjjT/C3LjwIsTbh0KEWs9MHo6hzGBrOFtUBwIhg R6OnecrLkcAtMoT5bvb35d5Iztd9sg7B5YtFKnRE6kvmTiBurqK8v65CaZX/18CY8w bAOeNwoCEWldGyzca/00wQstFSfEbgfdfnSvrFHc= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xADCkQvw081427 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Nov 2019 06:46:26 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Wed, 13 Nov 2019 06:46:08 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Wed, 13 Nov 2019 06:46:25 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id xADCkIGG127078; Wed, 13 Nov 2019 06:46:23 -0600 From: Peter Ujfalusi To: , CC: , , , , , Subject: [PATCH 2/2] ASoC: pcm3168a: Add support for optional RST gpio handling Date: Wed, 13 Nov 2019 14:47:34 +0200 Message-ID: <20191113124734.27984-3-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191113124734.27984-1-peter.ujfalusi@ti.com> References: <20191113124734.27984-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org In case the RST line is connected to a GPIO line it needs to be pulled high when the driver probes to be able to use the codec. Add support also for cases when more than one codec is is controlled by the same GPIO line by requesting the gpio with GPIOD_FLAGS_BIT_NONEXCLUSIVE. Signed-off-by: Peter Ujfalusi --- asoc: pcm3168a rst --- sound/soc/codecs/pcm3168a.c | 38 +++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index 313500ab36df..f3475134b519 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include #include @@ -59,6 +61,7 @@ struct pcm3168a_priv { struct regulator_bulk_data supplies[PCM3168A_NUM_SUPPLIES]; struct regmap *regmap; struct clk *scki; + struct gpio_desc *gpio_rst; unsigned long sysclk; struct pcm3168a_io_params io_params[2]; @@ -643,6 +646,7 @@ static bool pcm3168a_readable_register(struct device *dev, unsigned int reg) static bool pcm3168a_volatile_register(struct device *dev, unsigned int reg) { switch (reg) { + case PCM3168A_RST_SMODE: case PCM3168A_DAC_ZERO: case PCM3168A_ADC_OV: return true; @@ -702,6 +706,21 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, pcm3168a); + /* + * Request the RST gpio line as non exclusive as the same reset line + * might be connected to multiple pcm3168a codec + */ + pcm3168a->gpio_rst = devm_gpiod_get_optional(dev, "rst", + GPIOD_OUT_HIGH | + GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(pcm3168a->gpio_rst)) { + ret = PTR_ERR(pcm3168a->gpio_rst); + if (ret != -EPROBE_DEFER ) + dev_err(dev, "failed to acquire RST gpio: %d\n", ret); + + return ret; + } + pcm3168a->scki = devm_clk_get(dev, "scki"); if (IS_ERR(pcm3168a->scki)) { ret = PTR_ERR(pcm3168a->scki); @@ -743,10 +762,18 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) goto err_regulator; } - ret = pcm3168a_reset(pcm3168a); - if (ret) { - dev_err(dev, "Failed to reset device: %d\n", ret); - goto err_regulator; + if (pcm3168a->gpio_rst) { + /* + * The device is taken out from reset via GPIO line, wait for + * 3846 SCKI clock cycles for the internal reset de-assertion + */ + msleep(DIV_ROUND_UP(3846 * 1000, pcm3168a->sysclk)); + } else { + ret = pcm3168a_reset(pcm3168a); + if (ret) { + dev_err(dev, "Failed to reset device: %d\n", ret); + goto err_regulator; + } } pm_runtime_set_active(dev); @@ -785,6 +812,9 @@ static void pcm3168a_disable(struct device *dev) void pcm3168a_remove(struct device *dev) { + struct pcm3168a_priv *pcm3168a = dev_get_drvdata(dev); + + gpiod_set_value_cansleep(pcm3168a->gpio_rst, 0); pm_runtime_disable(dev); #ifndef CONFIG_PM pcm3168a_disable(dev);