From patchwork Fri Sep 18 11:40:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camel Guo X-Patchwork-Id: 250978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23789C43463 for ; Fri, 18 Sep 2020 11:41:32 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70386208DB for ; Fri, 18 Sep 2020 11:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="kWa8H2X4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=axis.com header.i=@axis.com header.b="iDyjxaey" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70386208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=axis.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 68A0E16CE; Fri, 18 Sep 2020 13:40:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 68A0E16CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1600429289; bh=p4gLwOTXI2+3jP4zc7Yz+ZicFx0pazEsFwsxu1l5wno=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=kWa8H2X4Zf8NtZUJLBSz7TLbU+oadCLPQMKEgcVMxUHilYtSuYbVtF/9Sqk0G+QTh L/0t/724+T9mqcIT4+7X2kH1TItkI7vA4IB/U8K2scI/LLg/E0nEf4mT0JTax5IAEr ClLXHBLKbvsxU/3+b+tAe7VRXGJE6nAb4Lieeh7I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F3EC9F80150; Fri, 18 Sep 2020 13:40:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A33A9F8015C; Fri, 18 Sep 2020 13:40:36 +0200 (CEST) Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 28E71F800E8 for ; Fri, 18 Sep 2020 13:40:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 28E71F800E8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=axis.com header.i=@axis.com header.b="iDyjxaey" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=2871; q=dns/txt; s=axis-central1; t=1600429231; x=1631965231; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nf9xyKjOJLYLLbRB2/HBWzS8DPHd3qUqka4CHMmC6qo=; b=iDyjxaeyQ8I36uhfZa5D374jEeAh772ICWkvd1PAOYGSip95fVGODOFg tyg619EKVOADPnhQY0eOv3iYa3goSgRd46toi8FinEzpjmoVBB3DL5PkS o+qkMggJWWipPTRtm67BHazyQoQPAcaj/fOo1hSnURt1c5JKmGc10/EYU LS30zmyDxPZ6L8esTjDBzo6dIWDYddzbz2dwugplsNHxa6YLVICnV4/eN CFYD74iO/la63DJARyVt9DMoVkgWOUHXRM8cDXjx+DdR18eFn6a+DPsww T+6iBZcbmiOox5HxK7s6k9iiw/LApB02ZWZEjbgJZL0vfZg9ZgzWJLwtc Q==; IronPort-SDR: MeyJ+ipT9q80W1KxznfMpqfE4aU7/yQs4lPs05Y8+BohAR/d1+bypJN+EFkzhVi983AtROHYn3 ym2J9g1K7jb7RiyEiWv2AFz6CT2cr7UMwvuqFW2nI7POTFlt7WidD+GBobSLbfUM+QnFfrtQBT Lbp7AD5Y2+iu9873B8TEGalLKd4h5EMo0qLDNkn4HDHF3PPVh3G4VUWbvWbOJD8BTsgFqckxQ7 sGWCqfgQqZ1zMVP/O9fms0Z2auo9axhc73YzkDFHi8pNqIvtgnJUXO/4iDAQc9lWZPNKIavsF2 Pmo= X-IronPort-AV: E=Sophos;i="5.77,274,1596492000"; d="scan'208";a="12637619" From: Camel Guo To: , , , , Subject: [PATCH v5 1/2] dt-bindings: tlv320adcx140: Add GPIO config and drive config Date: Fri, 18 Sep 2020 13:40:24 +0200 Message-ID: <20200918114025.18205-1-camel.guo@axis.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, kernel@axis.com, linux-kernel@vger.kernel.org, Camel Guo X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Camel Guo Add properties for configuring the General Purpose Input Output (GPIO). There are 2 settings for GPIO, configuration and the output drive type. Signed-off-by: Camel Guo Acked-by: Dan Murphy --- v4: - Rebase v3: - Fix typo - Add Acked-By from Dan .../bindings/sound/tlv320adcx140.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml index e79f8d1891e4..798b366fe6d1 100644 --- a/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml +++ b/Documentation/devicetree/bindings/sound/tlv320adcx140.yaml @@ -140,6 +140,49 @@ patternProperties: 4d - Drive weak low and active high 5d - Drive Hi-Z and active high + ti,gpio-config: + description: | + Defines the configuration and output drive for the General Purpose + Input and Output pin (GPIO1). Its value is a pair, the first value is for + the configuration type and the second value is for the output drive + type. The array is defined as + + configuration for the GPIO pin can be one of the following: + 0 - disabled + 1 - GPIO1 is configured as a general-purpose output (GPO) + 2 - (default) GPIO1 is configured as a device interrupt output (IRQ) + 3 - GPIO1 is configured as a secondary ASI output (SDOUT2) + 4 - GPIO1 is configured as a PDM clock output (PDMCLK) + 8 - GPIO1 is configured as an input to control when MICBIAS turns on or + off (MICBIAS_EN) + 9 - GPIO1 is configured as a general-purpose input (GPI) + 10 - GPIO1 is configured as a master clock input (MCLK) + 11 - GPIO1 is configured as an ASI input for daisy-chain (SDIN) + 12 - GPIO1 is configured as a PDM data input for channel 1 and channel 2 + (PDMDIN1) + 13 - GPIO1 is configured as a PDM data input for channel 3 and channel 4 + (PDMDIN2) + 14 - GPIO1 is configured as a PDM data input for channel 5 and channel 6 + (PDMDIN3) + 15 - GPIO1 is configured as a PDM data input for channel 7 and channel 8 + (PDMDIN4) + + output drive type for the GPIO pin can be one of the following: + 0 - Hi-Z output + 1 - Drive active low and active high + 2 - (default) Drive active low and weak high + 3 - Drive active low and Hi-Z + 4 - Drive weak low and active high + 5 - Drive Hi-Z and active high + + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 2 + maxItems: 2 + items: + maximum: 15 + default: [2, 2] + required: - compatible - reg @@ -156,6 +199,7 @@ examples: ti,mic-bias-source = <6>; ti,pdm-edge-select = <0 1 0 1>; ti,gpi-config = <4 5 6 7>; + ti,gpio-config = <10 2>; ti,gpo-config-1 = <0 0>; ti,gpo-config-2 = <0 0>; reset-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; From patchwork Fri Sep 18 11:40:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camel Guo X-Patchwork-Id: 291669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BDBEC43463 for ; Fri, 18 Sep 2020 11:42:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B15A207D3 for ; Fri, 18 Sep 2020 11:42:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="iSdVMbdy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=axis.com header.i=@axis.com header.b="m+b7uQrA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B15A207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=axis.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2B55016E9; Fri, 18 Sep 2020 13:41:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2B55016E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1600429341; bh=epEkUMlrR/rPoINSjSkduvQq8Pufu608nljokz0EXvg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iSdVMbdyg1FRGf74mySbhCLpe/xe/s9V8twLokfGKN6HbGQZS6XoEecNZz4AIxIKx SJGezlbw/56tzB+LTNeopXgT6KcAw6Vt0XCDx0NqFRh2X/m/msrbe6uON5Pe1hTN5W kerj7FSTkMJf4zI8jNQOR7B+T+ei8rgkVbO13+0A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EB755F8015C; Fri, 18 Sep 2020 13:40:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7AF05F8012D; Fri, 18 Sep 2020 13:40:37 +0200 (CEST) Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8A562F8012D for ; Fri, 18 Sep 2020 13:40:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8A562F8012D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=axis.com header.i=@axis.com header.b="m+b7uQrA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=2756; q=dns/txt; s=axis-central1; t=1600429232; x=1631965232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ew//nIO5dKXvaZr2/EGqobhhCsQ55JTGE+weINnJVVs=; b=m+b7uQrAGCRyYAXI0QInatFVm23DnQ5FEerqFr74ZBNiqpuIkZXNIcQ3 dPBezFWPkQw4dt4N+G3LvI8ZVEVRcsGSkfiJLZhZWYoN2DITlO0o7XUcB UML06SiUnBJXsP2j6QjRbQ/rPuWwIlYQm8lpex9SpvMKEa+rubco2fT3y IgNQxv3k+tADcAwSNGgGBnBpbkJzCcoo0mx3t8SD+QuIVtX0Oxz849lq9 AfVdZ/SKYl4BBr074uNUY9jcwpx/AgHEgz3sCaBJZvu1FdoJ61MGU9uB3 4VishjxzwvnbegzTpbdatMpUXl6UC1Npb+Qv5xDBXj99UMtW9QTvhdtCx Q==; IronPort-SDR: DKC8VO5L1SMacHypEV5JHzAI747iaewCGeQgHSpCHCveVnZOS/TzSoR4GEWOZVWPkTKXVU1aSm Y4uwYAocMzwzDhLcUZOBifmWda1/ttxrtZDLB2Clm8PzVztFAPeY4ahX4EqOaWPUrqUapk+U0q Mv4zE7BZF6lxLd3SbREJvC8r0KzysFZfKSwM9RyU+GU615LnrArMje3VZQ7UWU6jMo2JE0l/WO EfWoE46wX/B7VW5LIMCE1ukk0o8fohIW82hYgBQLkfW9aQRmNjaC+e0aN3dM4bEbx+QjnWsVDt jl4= X-IronPort-AV: E=Sophos;i="5.77,274,1596492000"; d="scan'208";a="12637620" From: Camel Guo To: , , , , Subject: [PATCH v5 2/2] ASoC: tlv320adcx140: Add support for configuring GPIO pin Date: Fri, 18 Sep 2020 13:40:25 +0200 Message-ID: <20200918114025.18205-2-camel.guo@axis.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200918114025.18205-1-camel.guo@axis.com> References: <20200918114025.18205-1-camel.guo@axis.com> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, kernel@axis.com, linux-kernel@vger.kernel.org, Camel Guo X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Camel Guo Add support to configure the GPIO pin to the specific configuration. The GPIO pin can be configured as GPO, IRQ, SDOUT2, PDMCLK, MICBASE_EN, GPI, MCLK, SDIN, PDMDIN1, PDMDIN2, PDMDIN3 or PDMDIN4 and the output drive can be configured with various configuration. Signed-off-by: Camel Guo --- v4: - Rebase and fix merge conflict - Add Acked-by from Dan v3: - Add ADCX140_NUM_GPIO_CFGS avoiding using magic number - Remove unneeded check on ret in adcx140_configure_gpio sound/soc/codecs/tlv320adcx140.c | 40 ++++++++++++++++++++++++++++++++ sound/soc/codecs/tlv320adcx140.h | 5 ++++ 2 files changed, 45 insertions(+) diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c index 28dbd7d5e149..53a80246aee1 100644 --- a/sound/soc/codecs/tlv320adcx140.c +++ b/sound/soc/codecs/tlv320adcx140.c @@ -861,6 +861,42 @@ static int adcx140_configure_gpo(struct adcx140_priv *adcx140) } +static int adcx140_configure_gpio(struct adcx140_priv *adcx140) +{ + int gpio_count = 0; + u32 gpio_outputs[ADCX140_NUM_GPIO_CFGS]; + u32 gpio_output_val = 0; + int ret; + + gpio_count = device_property_count_u32(adcx140->dev, + "ti,gpio-config"); + if (gpio_count == 0) + return 0; + + if (gpio_count != ADCX140_NUM_GPIO_CFGS) + return -EINVAL; + + ret = device_property_read_u32_array(adcx140->dev, "ti,gpio-config", + gpio_outputs, gpio_count); + if (ret) + return ret; + + if (gpio_outputs[0] > ADCX140_GPIO_CFG_MAX) { + dev_err(adcx140->dev, "GPIO config out of range\n"); + return -EINVAL; + } + + if (gpio_outputs[1] > ADCX140_GPIO_DRV_MAX) { + dev_err(adcx140->dev, "GPIO drive out of range\n"); + return -EINVAL; + } + + gpio_output_val = gpio_outputs[0] << ADCX140_GPIO_SHIFT + | gpio_outputs[1]; + + return regmap_write(adcx140->regmap, ADCX140_GPIO_CFG0, gpio_output_val); +} + static int adcx140_codec_probe(struct snd_soc_component *component) { struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component); @@ -958,6 +994,10 @@ static int adcx140_codec_probe(struct snd_soc_component *component) return ret; } + ret = adcx140_configure_gpio(adcx140); + if (ret) + return ret; + ret = adcx140_configure_gpo(adcx140); if (ret) goto out; diff --git a/sound/soc/codecs/tlv320adcx140.h b/sound/soc/codecs/tlv320adcx140.h index 107bd7927d9c..d7d4e3a88b5c 100644 --- a/sound/soc/codecs/tlv320adcx140.h +++ b/sound/soc/codecs/tlv320adcx140.h @@ -148,4 +148,9 @@ #define ADCX140_TX_FILL BIT(0) +#define ADCX140_NUM_GPIO_CFGS 2 +#define ADCX140_GPIO_SHIFT 4 +#define ADCX140_GPIO_CFG_MAX 15 +#define ADCX140_GPIO_DRV_MAX 5 + #endif /* _TLV320ADCX140_ */