From patchwork Wed May 8 10:58:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DA62C04FFE for ; Wed, 8 May 2024 11:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mmrJjPkS1gzMKv7vR80xCDnsxO/oqoLNZB73+mOsK3k=; b=JwyQoRHCWswvXG gmADBU5INLqbuZfm9XwUAJ/13eaTEZxXedqNAPuq53Lv3jRglcIiXP4A1BdT0UX/Q3VqXwk8H+Yfe zBWJjYWm2e4GwWQtsqhrd+pgeFxtTcM7SReihKvkHFBhSS3MsHjA8LctaXFhU/AnmPiQx8fLFPfv+ E4qo0EUoIqwKZiMU6Wu2uxEMeSd7W1kY+3tzkDnJ7MdHm5f/pIUrwgJj+3G2Vjgr5cmXVCC57ppom ma7DMYeopJoPcDMvyPOlPGoLw5s4wom7ki7RE3H8KXUpp1xpnIEuce9W0IUFT2u8qYR7xDxYrCYZi dFITxJOZia+Zs3K+3oxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f36-0000000F5wg-1FcW; Wed, 08 May 2024 11:01:24 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f34-0000000F5vT-08oD for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:23 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a59cf8140d0so816732566b.3 for ; Wed, 08 May 2024 04:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166079; x=1715770879; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GBQXsZU35VYhqiFUuzQSMRWlgIZsYX5osBGZyaRNZAc=; b=N5SuepT3jHM+jDNlmFBh3wHAA4zZpkqaLrHhaLtuyUwb+Nea6If7QUzS3ltexhTT1q 3vh8+YqCdd9wuBSanPspPSJQBSZ/1PiJClmq0e4d3NvHkJ9s9fDTMgPC1fBtHDYTpbek kexr3WZgTByXATPDVkwm+CkJi/b8pYLkyr40c8NZq89cPqgCqzB3VDnOr1Qb7qotPaGl vpr6DRvi7JW+sAHa9VdCOq5xnlVDf8bBB8bIRdbEO+sMMcWnZ0VUB17ZJgGTBjb/TJmj f2ExvSA9UuPRlLKRDI3kl95ukLPAiJFqsigflmjghMOELuikdmCnpi7/9jSyfJuF2Jkc Tfpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166079; x=1715770879; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GBQXsZU35VYhqiFUuzQSMRWlgIZsYX5osBGZyaRNZAc=; b=qGXquJ8+VpgghUyloL2lm7K76NqiIuNZxOtWmoaF9439uzKY+agUWMNOkToG6OhPoZ jnnK+DGHkb/CKdSrRuK4kuv7mg8rvPbo2k2a3oipkjDLhSVMyWvycLNH96BMr6WAiwZq uPh4rb4ojdEtL9x0kLcncmwIQhWJZAd0jYp0Wu8dRg3CwfkyYwuJsEeUGuDLjLtevIIk Wlm6yROg8xOo5aT3tPBte7YdUJSkzWvofIyB8Er78D4txyZvVxPr9rc3wtPKu2dcVIG5 1Zj4O0yWfBzQ86FWk+P1og6AWBNoHSW+SI/rFVYOE39ed0twRu9qyFsh2l3sfNN41aIT nzKw== X-Forwarded-Encrypted: i=1; AJvYcCWtgIMtPxLRSH5dmQXnQ5avWIjOqdR2TGfSjATqomWXvp87WNDw59zbVNFDajMmugLBZYhXAnKx02lqIE97djxnUHk1GKTdRc26JPdK+IMiuvGJ+sM= X-Gm-Message-State: AOJu0YzLCaovT82fyLwvZrFkCp1trRUK6+lsWPF6JBs2+kIXHfbtT4W0 xBPxMaEZruasmggZjI7H8b/1BJmN9A8bNHuaUP4NyGPcq6r02Nwa X-Google-Smtp-Source: AGHT+IFgeu/s+KC8rDn6htjx+jvP1Y3rc1ZlgtfjnZ0vURY07Nu9Xv35QHBlM4I/VNTBm/3YvoUPAA== X-Received: by 2002:a50:ab59:0:b0:570:3b8:a990 with SMTP id 4fb4d7f45d1cf-5731da6977emr1667758a12.39.1715166079292; Wed, 08 May 2024 04:01:19 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:18 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:49 +0200 Subject: [PATCH v2 1/7] ASoC: dt-bindings: samsung,midas-audio: Add headset mic bias supply MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-1-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=1024; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=oxZAMqMqlKlTjZ/d/nZ7mM8CRcGM1aALJhSvZTlSCIE=; b=K1veHz6hjzCU7royAnxjqrMCC0z9fIknAhe0rQDN3eWSJhF3ZkHUPxbS3lAcGY5M1qORpIsuP pD4Lape6OslD+fk6fUGab9UEaED1Tl0U0keF0AjW3Lq1k9isWgrReLQ X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040122_148524_22BD7015 X-CRM114-Status: GOOD ( 11.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some devices use a separate mic bias supply (also referred to as "ear mic bias") to enable/disable the headset mic. Add the DT property headset-mic-bias-supply to allow for specifying this supply. Signed-off-by: Artur Weber --- Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml b/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml index 6ec80f529d84..6ed53dd0bb53 100644 --- a/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml +++ b/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml @@ -53,6 +53,9 @@ properties: submic-bias-supply: description: Supply for the micbias on the Sub microphone + headset-mic-bias-supply: + description: Supply for the micbias on the Headset microphone + fm-sel-gpios: maxItems: 1 description: GPIO pin for FM selection From patchwork Wed May 8 10:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7FCA0C25B5F for ; Wed, 8 May 2024 11:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=76f67HnUMIYcFttVBgKasmPwyncM6lN93WaEfElvVXM=; b=yUS+MvuHgTM2Dm J8N75qtmbSe3rLOevQzlWvOtCliF+McsfrLulDDd0297jcs9w10dlWUWj4IfXtidOBQQHf7v+S548 B2lIKAl04oir5lJbbJrgbtMSnBYB9Xhkeue0CED5DCQwvKe3KbX9gb9I0tSeQvkSNt3NUBGHveRUY 4HMlgBcKP638vBHlrp5EOYn4VPOLzdcQs2tZaTg1lGlcxdpDkULRehUilmv6UKUGxz+2p6OgjYYf/ GHuiIJf4LNZj3/zy5I3AUGWI+KLUEn1B1cmyC1rV8i6uSTieIP04SkCyQoRu1N0V9wv8UIkXUlM8G iHKG7fMf6Y9oSoNZ2x9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3A-0000000F5z6-1vEO; Wed, 08 May 2024 11:01:28 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f34-0000000F5vU-0957 for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:24 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a59cdf7cd78so852571466b.0 for ; Wed, 08 May 2024 04:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166080; x=1715770880; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bT4moxnFWMX+ROOOxuh3w595mSjqjEQ1yI4SN/pV6pw=; b=eTElpwxuAvF634RJ5sAoNibQsvA/cx9sRgDkV33iDtA1OE6UgPse1kkN2ohf1/+CV4 qXSx8/ribExq3SusfeELDQO+9dkr4umWGKEGQwJslnOvAF/w4Y93U5X0KLGAZVkrVIFs IC929UEyBa71aiShgfnqtKZvR5OIXbujBezVImHBz65Yl/I9/ZUlkA5SIPHwt0/aDZ1q AewJG6Phn3jGjQJ9CqIIh3eKrKXjl9p1ySTFnUtJvL0w4fY64vzHgOH4zcI4ynoBdCAk OOdwaVUOwOHzwq8BAEtl/35p29rI6d1CITHSM7BbWZviJmlZ+7IPHN75Ssp8goBx8/tN 0ViA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166080; x=1715770880; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bT4moxnFWMX+ROOOxuh3w595mSjqjEQ1yI4SN/pV6pw=; b=ITr6KfTl8fEg6/GridxzxyRW5ssoxik6iXaZsrLHjkG4ixhjoBgpkz4ilJK1H8CI3D OFco41Y9+qVLCN939+D6hf0cQ37V2eIq56WfwtUcrA+nv4enJbvuv6tZxsN+WoGgaF0r OB7ZMdGuanQQdkhzgC5nA7FWF5KLROs502A8drUR6k4kn5RHd/DBcbdVpDSLmZNQNjt3 c0S4/YkjMRTaLLyYZbcPlVztclygjwbqUNfQPTCEOeLx13ZUAu9vxOxtcaGUpqh2KIHY 6FHLS09ExbteWYzb/h4T7VnUwRBrzysUSb1Z2KE9kErTfpAe7VLQnFZkv2XylRWlxIh/ XgZQ== X-Forwarded-Encrypted: i=1; AJvYcCX3lvueGXhz/rSKvr5ZdInm0EuSyF5su4E1bEulfXn9sfEOiuyk/DpTRmSunXvWu1u4mOEO704pjAYIeYeS6Yn54y5YDqCshKqFPJ/73a085aHG3No= X-Gm-Message-State: AOJu0YzWOqGHTwFkwMHTis2FLO0GmLA6ARnA+VIr0G7MvSnoxzTppZMv i+KVmrlMvbWLtle5Zc2YyHl6AyEL1BgNs8hvgd5j8bMUFobNHHtMDSpaZg== X-Google-Smtp-Source: AGHT+IGyZZH2dVq+LOe0zaf4rz7kDLtf4v4iLQC8umEfCOPDmCDuJtUXH0SpHIqe1/sL73DxJ3vqeQ== X-Received: by 2002:a50:ab49:0:b0:570:1ea8:c50a with SMTP id 4fb4d7f45d1cf-5731d9cd410mr1935750a12.6.1715166080555; Wed, 08 May 2024 04:01:20 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:20 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:50 +0200 Subject: [PATCH v2 2/7] ASoC: dt-bindings: samsung,midas-audio: Add GPIO-based headset jack detection MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-2-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=2135; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=x4CRj3HPQjjxV02Uhbn39jzTSMCqAM5BsNr5zZc40mM=; b=zsZQ0yeh7zg0Ep6m1GYQPRjfMq2PTI5dByvyZhsHCpPeLOEvFLhyar0/PfAzi8k6j4w1bXraj /eDPEpjzkwMAq1iMHceo6NnRRQvuVdZXpOxSY/0HEXQIzSIoLMG5QuW X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040122_154675_518C9862 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some Samsung devices that share the midas-audio driver use a GPIO-based approach to headset jack detection, as opposed to using the built-in jack detection provided by the wm8994 driver. This setup uses two GPIOs (one for jack detection and another for key detection) and an ADC channel for determining the jack type or button pressed. Add DT configuration values that allow for describing these setups. Signed-off-by: Artur Weber --- Changes in v2: - Added vendor prefix to threshold properties - Dropped pipe (|) character from description: field --- .../bindings/sound/samsung,midas-audio.yaml | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml b/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml index 6ed53dd0bb53..6b760a73e8bf 100644 --- a/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml +++ b/Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml @@ -64,6 +64,36 @@ properties: maxItems: 1 description: GPIO pin for line out selection + headset-detect-gpios: + maxItems: 1 + description: GPIO for detection of headset insertion + + headset-key-gpios: + maxItems: 1 + description: GPIO for detection of headset key press + + io-channels: + maxItems: 1 + description: IO channel to read micbias voltage for headset detection + + io-channel-names: + const: headset-detect + + samsung,headset-4pole-threshold-microvolt: + minItems: 2 + maxItems: 2 + description: + Array containing minimum and maximum IO channel value for 4-pole + (with microphone/button) headsets. If the IO channel value is + outside of this range, a 3-pole headset is assumed. + + samsung,headset-button-threshold-microvolt: + minItems: 3 + maxItems: 3 + description: + Array of minimum (inclusive) IO channel values for headset button + detection, in order: "Media", "Volume Up" and "Volume Down". + required: - compatible - cpu From patchwork Wed May 8 10:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBE27C19F4F for ; Wed, 8 May 2024 11:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B0lMdIH2xu2dxxf7VBpS1/0SzHDX78A+d901ecGOnrc=; b=Ie8DeVh4zfz615 plKehPEsa8hxNlnnWJe3X7xg944+inO2R6XPk278am0RoH7R+9LtMxMoAp2jKb3wbPqWQwSq/DkFm 0TFHH39McYEbE+bxeqeInB32HpAYVxsbgVsDmOkEN8XXt0McpYnwEKjiAzcOLlvFbblfFRR2vITSd TE7P21RekN4NEcsZufJpg0uH5hBYMO5b1/2EDqQ8u+CvW6jgXI+VDP2VJFt4BvSeGnwmx9xo8VXJd dEQW7zwJJH0KcTFanwg9ERsURW4RfbL4pcJX+c2N32x/ooEawmV3XQkuDdJYvL5bGgIR0NRnXQxw7 AN3nGw00eAd5IvMiB3Ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3B-0000000F5zi-2o4g; Wed, 08 May 2024 11:01:29 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f35-0000000F5wD-0q1T for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:24 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a59cc765c29so783230666b.3 for ; Wed, 08 May 2024 04:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166082; x=1715770882; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EUmoS//RS/NzAGvmwPir69ysTLwZDq4qcPlEK/AGs3g=; b=YRMDyYArgcdfjKhrqAwM7kGOMdQZ0TOwseDbLKYgkZGkIkTC9EubkN7TkXhY/2GGk6 cj9PdgsDoauggYePU0nRpYc/xGZpGX6sjtFiwPICwv3G03o74uUpi7hX73OA4vmLEp3X FFqCw1nxQUmcngLhOlvuEdBCICBT3k4FxztFxaayjO9iOyNaTKnUdNuYh3Skg3n3yysW 0KCBJ3shwOyNzlR2PV74D3mmpEFHJhKKyrRIOJYUhNehx/Q6T5Jp9XxNi/dgzozbzltN UOW5Qcpi5x/QEcfK+5Z4Z7amp8vo1tj7F1zDnCrUqo0EnMSGDfkSqtZ3OeaE+EJKNoMv oi4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166082; x=1715770882; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUmoS//RS/NzAGvmwPir69ysTLwZDq4qcPlEK/AGs3g=; b=woHJjxESJ64c2K+OXbBw0p/xo1uR+wCxmtVkDwA9jxAifec8MhSoZiNhAawiLPZ5TM 3GJZU8LlaMOMvkCq8ZYmRcWoeT5KkuVD8tXst6p1ZvCckyyuZC/FAOosB5CTl418g4H9 KYKh+iQDgnfHvXPqB9Nl3AeYL1b33/Z3I0CcF1LMz/I/bv+idnTxcIFMssqo3umCmbrs 5MVx5nXbtKulcwPv+g3weezT7k6HWuiWQ+ta7dUd40P7ZzG8G2QakCSRkvmp46zwcKeb pd9E0Wh5f9mF6pdYY/JOzQmnlRz1bm0x7AfcLzMQsSMeF3x59aWRejMA4heHN/KyEB8N b5+w== X-Forwarded-Encrypted: i=1; AJvYcCUOkb03os1M8C23Uxo+RWEZraQ2Y/WQp2TUk6qysIPTiEU2W2NuIEHV3gSNmTHn55b0JhlKRXPquXuLh4pzpNpBG90hH3v32/Ltxd+yPftP31K09vA= X-Gm-Message-State: AOJu0YwWu+BQlCaGpHptPb0n8gj5AqmoVZDvRorgAz6VKMD8+tP42kDW IpZjryvFAW8kGsgm3Zw1BKY1TZrSqBwAoV2X3BM5L92MuRu/FBKxcBltGg== X-Google-Smtp-Source: AGHT+IFpa08if4ZV9EcVB9Vu0FNL1rhqQENCxKWqxLruW9MtTmzQE21qpCft0G/5NCYFuAFYkQ7HKg== X-Received: by 2002:a50:8e4f:0:b0:572:983e:4ff2 with SMTP id 4fb4d7f45d1cf-5731da6b398mr1572580a12.34.1715166081904; Wed, 08 May 2024 04:01:21 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:21 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:51 +0200 Subject: [PATCH v2 3/7] ASoC: samsung: midas_wm1811: Add headset mic bias supply support MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-3-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=2705; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=vuYNtCSoGcmTk8GfhvJhaoNcv6Dz56BFdGIefFxXzuk=; b=C9o5Z/2OQb6j2lE2jgdzRhl3b23clo+4hlUt1ZBA0i0TeRIuu/ycDQLUWV3DXOpmG7lS51aJt w5uuXAvDZEOCcAC2iAzkH1PZKsY/Se7deOh5m8oFoPnrXyEJypdVsxb X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040123_327686_756463B5 X-CRM114-Status: GOOD ( 18.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some devices use a headset mic bias supply (sometimes referred to as "ear mic bias") to enable/disable the headset mic. Add support for getting the supply from DT and setting it up accordingly to the value of the Headset Mic switch. Signed-off-by: Artur Weber --- Changes in v2: - Added this commit --- sound/soc/samsung/midas_wm1811.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1811.c index f31244156ff6..ab0a4804b45e 100644 --- a/sound/soc/samsung/midas_wm1811.c +++ b/sound/soc/samsung/midas_wm1811.c @@ -29,6 +29,7 @@ struct midas_priv { struct regulator *reg_mic_bias; struct regulator *reg_submic_bias; + struct regulator *reg_headset_mic_bias; struct gpio_desc *gpio_fm_sel; struct gpio_desc *gpio_lineout_sel; unsigned int fll1_rate; @@ -201,6 +202,25 @@ static int midas_submic_bias(struct snd_soc_dapm_widget *w, return 0; } +static int midas_headset_mic_bias(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_card *card = w->dapm->card; + struct midas_priv *priv = snd_soc_card_get_drvdata(card); + + if (!priv->reg_headset_mic_bias) + return 0; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + return regulator_enable(priv->reg_headset_mic_bias); + case SND_SOC_DAPM_POST_PMD: + return regulator_disable(priv->reg_headset_mic_bias); + } + + return 0; +} + static int midas_fm_set(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -271,7 +291,7 @@ static const struct snd_soc_dapm_widget midas_dapm_widgets[] = { SND_SOC_DAPM_LINE("FM In", midas_fm_set), SND_SOC_DAPM_HP("Headphone", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Headset Mic", midas_headset_mic_bias), SND_SOC_DAPM_MIC("Main Mic", midas_mic_bias), SND_SOC_DAPM_MIC("Sub Mic", midas_submic_bias), }; @@ -455,6 +475,17 @@ static int midas_probe(struct platform_device *pdev) return PTR_ERR(priv->reg_submic_bias); } + priv->reg_headset_mic_bias = devm_regulator_get_optional(dev, + "headset-mic-bias"); + if (IS_ERR(priv->reg_headset_mic_bias)) { + ret = PTR_ERR(priv->reg_headset_mic_bias); + if (ret == -ENODEV) + priv->reg_headset_mic_bias = NULL; + else + return dev_err_probe(dev, ret, + "Failed to get headset mic bias regulator\n"); + } + priv->gpio_fm_sel = devm_gpiod_get_optional(dev, "fm-sel", GPIOD_OUT_HIGH); if (IS_ERR(priv->gpio_fm_sel)) { dev_err(dev, "Failed to get FM selection GPIO\n"); From patchwork Wed May 8 10:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF6B1C04FFE for ; Wed, 8 May 2024 11:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XiYmFZnIp8fbOo29fT1YzgCO8Hw3aWLe18c80Uj0JeY=; b=40/tHggyl4ShL4 JoIS8p6UoVf/ofP1t0puJdR07P9IGYW9acAdtoo15riGrweVYnaGhnaCuNljgH+483OVS0wzRvrjJ HDgAZFQ699qRlatWnX91sPJQMS1EyHerTMcowJfJJfhl3Kq/M9ny744wpyQ8PfOxYZ4i8hHkw8k3c l7IP+WKBUkx/I68xYyAjJpvw/OqiA1pBI2fd7v2mRUqMXA0EG6tvjyPt8cmOXXKsz6ZfeFOa/HqtV zLblRwnI8LN0k/F0vghYBU9R4MBfQjNgAqc79lac19s/kr2KfiIPq/7Y3xsuSEmHSrjL4MePuFq/B 4avf5J1utNbuFBGzOr7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3M-0000000F67l-3LQa; Wed, 08 May 2024 11:01:40 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f38-0000000F5wY-0uK0 for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:27 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a59cf0bda27so377635066b.0 for ; Wed, 08 May 2024 04:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166083; x=1715770883; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=poVyIDrS2b/ZXWDdTK9RH0R8g9cefahYbIBUWzC1UWE=; b=XLghOOqkBU3VJS299i4+9JZIO8sV/+MSMe5BF2wpCb55yYIP6JVIDLVXOrU0evbbrN dNVezNl+Anxnm9m9s8LNbJP7OkSu2LeGwIQBJx7JL4vVmqowRIXz3atgPj6Z0Fxsz+FZ W1/8e+nImGFylgrctT/A187FH2Zn7Lkb9yHXGNxWH1VVUtIVVxzJMXMq7p+/iCZZ8nsl mLq+bWT59F+ZOCshm6saW/aryiqwYFbnaNSzr3GgLtj4/u6W1mmt9nVcPi7jLDQ0dSbF WL3MB7kZFko23zNtvkKvmEEYgIunSeKV+AntDGskgsu8LazWBhfoGiIxm8c5hUelqiin a5yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166083; x=1715770883; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=poVyIDrS2b/ZXWDdTK9RH0R8g9cefahYbIBUWzC1UWE=; b=I6kGBk3ZkKUqR5e1eZDUBPUghLBzgIEvSwk4uwTo8OjLts5ZzHQMhxTIhjU5/GIxvo fnn5+rFddam8xhzGfhAAwo+xgx4Sqv9tZwz0w1gB0pbh5/k0WyUUEgLTSEP9yeAiJhai DNKT9ufALIgcKBX6Yg9kEzAe4eFIvVozD13E4sOcEh0IGP6zcBl+UEhGOkVX09gotYu/ VpAAGGSDuEEKCiimpfR73vQHR4oR20HNYCso8TttinelVpNiH3YKGIviZddPoB+rLWNT mcW4bcHDgyMKUgtbbCr3zBaolkNcSKK5chvOMAtZzSM1xfGjQOa8u68cbzktUixw+hom rxLg== X-Forwarded-Encrypted: i=1; AJvYcCWtV+dCnfrq9/iwG71ALNBmsrGsnL702IxqWxTjHFOJmJUN3RbhclYJIR0+YAM+4bXb83Ip6FW2jjrgA/waQ8J20tmH6ItuU058rAIacdUd8EkMIfQ= X-Gm-Message-State: AOJu0Yxbhm4xS6sTI3pO7r4UPYY5ySBA+wij6Xv9wa/Kmeiaund2U0U9 nlSM2QK0sDBfjUw4NT45aIWEkQkl/b0tkhW3/0wbvWPhyk15qQxZ X-Google-Smtp-Source: AGHT+IErlStSHhT96t/fwnFEZHJuSLP/+wFJhG8ZdY2sMgKbw/O8rSpOa93NRwjSXZruRQb51QZNkA== X-Received: by 2002:a50:baa4:0:b0:572:325a:8515 with SMTP id 4fb4d7f45d1cf-5731da69864mr2264617a12.36.1715166083131; Wed, 08 May 2024 04:01:23 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:22 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:52 +0200 Subject: [PATCH v2 4/7] ASoC: samsung: midas_wm1811: Add GPIO-based headset jack detection MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-4-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=12054; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=tvVeHRzJ1CkifWQbFGlvF0EVZIoz7vxKkkPUGFuk7jM=; b=V677zzpo8A7us92yAktmq5gJ+zyaHEVr7Zft2eFcqj3mrO1MOtjS/95kPwIwYR4ypCfWpwUHC uhHCuobK+CsC+PXlwA4nqSae+/5+hzhAktw2rS+3V+8q2YEHSuPSw5P X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040126_293028_33CAA08F X-CRM114-Status: GOOD ( 35.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some Samsung devices that use the midas_wm1811 driver use a GPIO-based method for detecting whether the headset jack is plugged in, as well as detecting which headset buttons are pressed. There are two GPIOs: a "headset detect" GPIO responsible for detecting jack insertion, and a "headset key" GPIO which triggers when a button on the headset is pressed. The plug type and the button pressed are determined based on information from an ADC channel. The headset mic is enabled by a headset mic bias regulator. Add support for the GPIO-based headset jack detection mechanism, and make it configurable from the device tree. This implementation borrows somewhat from the aries_wm8994.c driver, though there are a few changes to make the code cleaner, and to add support for DT-based configuration. Notably, a dependency on IIO is introduced, to accommodate the ADC reading requirement. Signed-off-by: Artur Weber --- Changes in v2: - Added separate headset mic bias regulator - Added samsung preset to threshold properties - Replaced dev_err+return with return dev_err_probe where needed --- sound/soc/samsung/Kconfig | 2 +- sound/soc/samsung/midas_wm1811.c | 286 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 277 insertions(+), 11 deletions(-) diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 93c2b1b08d0a..4b1ea7b2c796 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -140,7 +140,7 @@ config SND_SOC_SAMSUNG_ARIES_WM8994 config SND_SOC_SAMSUNG_MIDAS_WM1811 tristate "SoC I2S Audio support for Midas boards" - depends on SND_SOC_SAMSUNG + depends on SND_SOC_SAMSUNG && IIO select SND_SAMSUNG_I2S select SND_SOC_WM8994 help diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1811.c index ab0a4804b45e..ce94550ee32e 100644 --- a/sound/soc/samsung/midas_wm1811.c +++ b/sound/soc/samsung/midas_wm1811.c @@ -7,7 +7,9 @@ #include #include +#include #include +#include #include #include #include @@ -32,6 +34,9 @@ struct midas_priv { struct regulator *reg_headset_mic_bias; struct gpio_desc *gpio_fm_sel; struct gpio_desc *gpio_lineout_sel; + struct gpio_desc *gpio_headset_detect; + struct gpio_desc *gpio_headset_key; + struct iio_channel *adc_headset_detect; unsigned int fll1_rate; struct snd_soc_jack headset_jack; @@ -48,6 +53,131 @@ static struct snd_soc_jack_pin headset_jack_pins[] = { }, }; +/* + * min_mv/max_mv values in this struct are set up based on DT values. + */ +static struct snd_soc_jack_zone headset_jack_zones[] = { + { .jack_type = SND_JACK_HEADPHONE, }, + { .jack_type = SND_JACK_HEADSET, }, + { .jack_type = SND_JACK_HEADPHONE, }, +}; + +/* + * This is used for manual detection in headset_key_check, we reuse the + * structure since it's convenient. + * + * min_mv/max_mv values in this struct are set up based on DT values. + */ +static struct snd_soc_jack_zone headset_key_zones[] = { + { .jack_type = SND_JACK_BTN_0, }, /* Media */ + { .jack_type = SND_JACK_BTN_1, }, /* Volume Up */ + { .jack_type = SND_JACK_BTN_2, }, /* Volume Down */ +}; + +static int headset_jack_check(void *data) +{ + struct midas_priv *priv = (struct midas_priv *) data; + int adc, jack_type, ret; + int bias_already_on = 0; + + if (!gpiod_get_value_cansleep(priv->gpio_headset_detect)) + return 0; + + if (priv->reg_headset_mic_bias) { + /* + * Get state of Headset Mic switch by checking the headset mic + * bias regulator + */ + bias_already_on = \ + regulator_is_enabled(priv->reg_headset_mic_bias); + + /* + * If it's not enabled yet, temporarily enable headset mic bias + * for ADC measurement + */ + if (bias_already_on < 0) + pr_err("%s: Failed to get headset mic bias state: %d", + __func__, ret); + else if (!bias_already_on) { + ret = regulator_enable(priv->reg_headset_mic_bias); + if (ret) + pr_err("%s: Failed to enable micbias: %d\n", + __func__, ret); + } + } + + /* Sleep for a small amount of time to get the value to stabilize */ + msleep(20); + + ret = iio_read_channel_processed(priv->adc_headset_detect, &adc); + if (ret) { + pr_err("%s: Failed to read ADC (%d), assuming headphones\n", + __func__, ret); + return SND_JACK_HEADPHONE; + } + pr_debug("%s: ADC value is %d\n", __func__, adc); + + jack_type = snd_soc_jack_get_type(&priv->headset_jack, adc); + + /* + * Revert the headset mic bias supply to its previous state + * (i.e. if it was disabled before the check, disable it again) + */ + if (priv->reg_headset_mic_bias && bias_already_on == 0) { + ret = regulator_disable(priv->reg_headset_mic_bias); + if (ret) + pr_err("%s: Failed to disable micbias: %d\n", + __func__, ret); + } + + return jack_type; +} + +static int headset_key_check(void *data) +{ + struct midas_priv *priv = (struct midas_priv *) data; + int adc, i, ret; + + if (!gpiod_get_value_cansleep(priv->gpio_headset_key)) + return 0; + + /* Filter out keypresses when 4 pole jack not detected */ + if (!(priv->headset_jack.status & SND_JACK_MICROPHONE)) + return 0; + + ret = iio_read_channel_processed(priv->adc_headset_detect, &adc); + if (ret) { + pr_err("%s: Failed to read ADC (%d), can't detect key type\n", + __func__, ret); + return 0; + } + pr_debug("%s: ADC value is %d\n", __func__, adc); + + for (i = 0; i < ARRAY_SIZE(headset_key_zones); i++) { + if (adc >= headset_key_zones[i].min_mv && + adc <= headset_key_zones[i].max_mv) { + return headset_key_zones[i].jack_type; + } + } + + return 0; +} + +static struct snd_soc_jack_gpio headset_gpio[] = { + { + .name = "Headset Jack", + .report = SND_JACK_HEADSET, + .debounce_time = 150, + .jack_status_check = headset_jack_check, + }, + { + .name = "Headset Key", + .report = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, + .debounce_time = 30, + .jack_status_check = headset_key_check, + }, +}; + static int midas_start_fll1(struct snd_soc_pcm_runtime *rtd, unsigned int rate) { struct snd_soc_card *card = rtd->card; @@ -335,18 +465,67 @@ static int midas_late_probe(struct snd_soc_card *card) return ret; } - ret = snd_soc_card_jack_new_pins(card, "Headset", - SND_JACK_HEADSET | SND_JACK_MECHANICAL | - SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | - SND_JACK_BTN_3 | SND_JACK_BTN_4 | SND_JACK_BTN_5, - &priv->headset_jack, - headset_jack_pins, - ARRAY_SIZE(headset_jack_pins)); - if (ret) + if (!priv->gpio_headset_detect) { + ret = snd_soc_card_jack_new_pins(card, "Headset", + SND_JACK_HEADSET | SND_JACK_MECHANICAL | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | + SND_JACK_BTN_4 | SND_JACK_BTN_5, + &priv->headset_jack, + headset_jack_pins, + ARRAY_SIZE(headset_jack_pins)); + if (ret) + return ret; + + wm8958_mic_detect(aif1_dai->component, &priv->headset_jack, + NULL, NULL, NULL, NULL); + } else { + /* Some devices (n8000, t310) use a GPIO to detect the jack. */ + ret = snd_soc_card_jack_new_pins(card, "Headset", + SND_JACK_HEADSET | SND_JACK_BTN_0 | + SND_JACK_BTN_1 | SND_JACK_BTN_2, + &priv->headset_jack, + headset_jack_pins, + ARRAY_SIZE(headset_jack_pins)); + if (ret) { + dev_err(card->dev, + "Failed to set up headset pins: %d\n", ret); + return ret; + } + + ret = snd_soc_jack_add_zones(&priv->headset_jack, + ARRAY_SIZE(headset_jack_zones), + headset_jack_zones); + if (ret) { + dev_err(card->dev, + "Failed to set up headset zones: %d\n", ret); + return ret; + } + + headset_gpio[0].data = priv; + headset_gpio[0].desc = priv->gpio_headset_detect; + + headset_gpio[1].data = priv; + headset_gpio[1].desc = priv->gpio_headset_key; + + snd_jack_set_key(priv->headset_jack.jack, + SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(priv->headset_jack.jack, + SND_JACK_BTN_1, KEY_VOLUMEUP); + snd_jack_set_key(priv->headset_jack.jack, + SND_JACK_BTN_2, KEY_VOLUMEDOWN); + + ret = snd_soc_jack_add_gpios(&priv->headset_jack, + ARRAY_SIZE(headset_gpio), + headset_gpio); + if (ret) + dev_err(card->dev, + "Failed to set up headset jack GPIOs: %d\n", + ret); + return ret; + } - wm8958_mic_detect(aif1_dai->component, &priv->headset_jack, - NULL, NULL, NULL, NULL); return 0; } @@ -453,6 +632,9 @@ static int midas_probe(struct platform_device *pdev) struct snd_soc_card *card = &midas_card; struct device *dev = &pdev->dev; static struct snd_soc_dai_link *dai_link; + enum iio_chan_type channel_type; + u32 fourpole_threshold[2]; + u32 button_threshold[3]; struct midas_priv *priv; int ret, i; @@ -499,6 +681,90 @@ static int midas_probe(struct platform_device *pdev) return PTR_ERR(priv->gpio_lineout_sel); } + priv->gpio_headset_detect = devm_gpiod_get_optional(dev, + "headset-detect", GPIOD_IN); + if (IS_ERR(priv->gpio_headset_detect)) + return dev_err_probe(dev, PTR_ERR(priv->gpio_headset_detect), + "Failed to get headset jack detect GPIO\n"); + + if (priv->gpio_headset_detect) { + priv->adc_headset_detect = devm_iio_channel_get(dev, + "headset-detect"); + if (IS_ERR(priv->adc_headset_detect)) + return dev_err_probe(dev, + PTR_ERR(priv->adc_headset_detect), + "Failed to get ADC channel\n"); + + ret = iio_get_channel_type(priv->adc_headset_detect, + &channel_type); + if (ret) { + dev_err(dev, "Failed to get ADC channel type\n"); + return ret; + } + + if (channel_type != IIO_VOLTAGE) { + dev_err(dev, "ADC channel is not voltage\n"); + return ret; + } + + priv->gpio_headset_key = devm_gpiod_get(dev, "headset-key", + GPIOD_IN); + if (IS_ERR(priv->gpio_headset_key)) + return dev_err_probe(dev, + PTR_ERR(priv->gpio_headset_key), + "Failed to get headset key GPIO\n"); + + ret = of_property_read_u32_array(dev->of_node, + "samsung,headset-4pole-threshold-microvolt", + fourpole_threshold, + ARRAY_SIZE(fourpole_threshold)); + if (ret) { + dev_err(dev, "Failed to get 4-pole jack detection threshold\n"); + return ret; + } + + if (fourpole_threshold[0] > fourpole_threshold[1]) { + dev_err(dev, "Invalid 4-pole jack detection threshold value\n"); + return -EINVAL; + } + + headset_jack_zones[0].max_mv = (fourpole_threshold[0]); + headset_jack_zones[1].min_mv = (fourpole_threshold[0] + 1); + + headset_jack_zones[1].max_mv = (fourpole_threshold[1]); + headset_jack_zones[2].min_mv = (fourpole_threshold[1] + 1); + + ret = of_property_read_u32_array(dev->of_node, + "samsung,headset-button-threshold-microvolt", + button_threshold, + ARRAY_SIZE(button_threshold)); + if (ret) { + dev_err(dev, "Failed to get headset button detection threshold\n"); + return ret; + } + + if (button_threshold[0] > button_threshold[1] || + button_threshold[1] > button_threshold[2]) { + dev_err(dev, "Invalid headset button detection threshold value\n"); + return -EINVAL; + } + + for (i = 0; i < 3; i++) { + if (i != 0 && button_threshold[i] <= 0) { + dev_err(dev, "Invalid headset button detection threshold value\n"); + return -EINVAL; + } + + headset_key_zones[i].min_mv = button_threshold[i]; + + if (i == 2) + headset_key_zones[i].max_mv = UINT_MAX; + else + headset_key_zones[i].max_mv = \ + (button_threshold[i+1] - 1); + } + } + ret = snd_soc_of_parse_card_name(card, "model"); if (ret < 0) { dev_err(dev, "Card name is not specified\n"); From patchwork Wed May 8 10:58:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A09BC41513 for ; Wed, 8 May 2024 11:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=r0Vy7rj+TEgTBsLt8Nrgmv+Mj3phSpBTtIhIQd6ejTs=; b=AT8zO8H0Dx3wYq QGfC7SBMhz7oE/dXzwMAjUOLkJ0bhNIlnfam69OQaH8nhRjyRbeUYzI57yEJVZ751YqO+80MK76aI dYAYWh7PdIWzE8/4L/5oT73RotR/bQISD9UEvxvUEh8RMzAgncHMK/Dx+KX3bJ8jBN1Y0GjqE1A45 4DzJcSBNlEma6j/vTqJW3mtBgRsM6cli7vtDLFdB5DkYFl8TWN68ygaQwZztTaVWFF+8wlPYmt/km sPh8qT/VZtbWKI2j2hcotm/DH3Gd+29Zk7FeQlB/G01bdAxgrw9gcX1M71HwiRehyWooHAmJj4u3z yl9eaVFJ11L2s6WRT4pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3S-0000000F6C0-0Dgz; Wed, 08 May 2024 11:01:46 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f39-0000000F5xB-0tQS for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:28 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a59b81d087aso929922166b.3 for ; Wed, 08 May 2024 04:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166085; x=1715770885; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eh0hh6ynZxtBGDzmGDI5+hS0xKp2HfOEvcy4GZsRfWo=; b=CYyhb0r1v2sSgssqtHK2A8FS7+2FhmR/4olJA9ovqkKQCcghrzPfwhXjQAmM1ZijDD 8l8JmiGBJ6TLl6uWrfI2E9Wy6C9AIZZTSRMm76OQhX5WLxq2fNkrKdspSvpQs/e1x/qt R+DmAeKFn5nTwLZ61cxI7+oQX1hLSY2f2IkPKVOZufdf1WXOxxcFe9MRzU0CPxJWTuQj p2qu63Z/UttdgxCdS6n1Xtlnrd5U01EWc1UFba05+sp3N/TArUfV0xt779v0zytHfCVu eWR28rSoP6xHrAGegL3CqYZOvOvvqU/3DTXBzR83dZ1MdRnGF4mE3dbKdlcw4C1e/+wl JpPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166085; x=1715770885; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eh0hh6ynZxtBGDzmGDI5+hS0xKp2HfOEvcy4GZsRfWo=; b=c7q26Qk6Tm3K8KcTl1CrW7d2XNeKMTJDceM47M0qJvezRpf/zrnqSetooEuVwFoDuM gNchttPHp7ZkzDeAMUL/t5fB/JPLy386q48iwo/0LdkoyIm/fyhqj+QyzpD37I8DmfOb 5M2ZxpLx6nCbYNsXUIPzdsfHoJQsVQREOkU3fiyv2xAFnEl/op9LuwsN7eEUpXmEaU86 r8N+6fyCRK7louUJStgAMQTuHPXNMgOMzQsOOXEsUA0NLZE8OgLgSS9jL4Z8e0vUGH+E qNqFu7X0HBcRf3Tk2D8QG+hHmJBkDuGXnUv6/JWjwaDDEste9A9BwPS3VpoNIgDUpz+C QK5g== X-Forwarded-Encrypted: i=1; AJvYcCWyISTpeocOP8FkrbldmLXNpEmcuFnpnhkch267dCPv5E7CS4J0I9zrVrXokfZ4Vp5ZdBNRuvv5b0wRvcNvr2Dik2P0OLQcMz3yM/1h2rc3nZPggy4= X-Gm-Message-State: AOJu0Yxd0sGQI6sESXstrbWPNSSBPp0iBOazREKSU4BXyrbVxhYV8/UZ UV0vowqZF3Dh27kGloEdZvYn94ssObBuOu5Cq0Tnkm57F6H4YZZ2 X-Google-Smtp-Source: AGHT+IEBwQsbB5ly9Co7wAOpW5LM6EH159oeIG9hfELSBdMplK0VTNfidDLRoB93iPYNNHuID+ms/g== X-Received: by 2002:a50:d7db:0:b0:56e:7722:553 with SMTP id 4fb4d7f45d1cf-5731d9d9ecbmr1973462a12.24.1715166084426; Wed, 08 May 2024 04:01:24 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:24 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:53 +0200 Subject: [PATCH v2 5/7] ASoC: samsung: midas_wm1811: Use dev_err_probe where appropriate MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-5-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=2433; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=zl7AH36vmygEV4JVzP5ZRpRVT0yrltHsi0L0sBPvpeI=; b=fe+pSCvp0hASloJ0sPUz+l38OVaL8jW3+JqL69/Fa0Vyl+oCbv43o8wgqeZZwlLvsGsOL8qOh to+MdKSo025DMN6qoynkF5EzPkUi5GX8nq5bbd2hLMj8pAZXpr+03D7 X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040127_320277_D7F5A6D3 X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since we're already using it in the newly-added GPIO requests for jack detection, extend it to the previous checks as well. Signed-off-by: Artur Weber --- Changes in v2: - Added this commit --- sound/soc/samsung/midas_wm1811.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1811.c index ce94550ee32e..91f4be98723c 100644 --- a/sound/soc/samsung/midas_wm1811.c +++ b/sound/soc/samsung/midas_wm1811.c @@ -646,16 +646,14 @@ static int midas_probe(struct platform_device *pdev) card->dev = dev; priv->reg_mic_bias = devm_regulator_get(dev, "mic-bias"); - if (IS_ERR(priv->reg_mic_bias)) { - dev_err(dev, "Failed to get mic bias regulator\n"); - return PTR_ERR(priv->reg_mic_bias); - } + if (IS_ERR(priv->reg_mic_bias)) + return dev_err_probe(dev, PTR_ERR(priv->reg_mic_bias), + "Failed to get mic bias regulator\n"); priv->reg_submic_bias = devm_regulator_get(dev, "submic-bias"); - if (IS_ERR(priv->reg_submic_bias)) { - dev_err(dev, "Failed to get submic bias regulator\n"); - return PTR_ERR(priv->reg_submic_bias); - } + if (IS_ERR(priv->reg_submic_bias)) + return dev_err_probe(dev, PTR_ERR(priv->reg_submic_bias), + "Failed to get submic bias regulator\n"); priv->reg_headset_mic_bias = devm_regulator_get_optional(dev, "headset-mic-bias"); @@ -669,17 +667,15 @@ static int midas_probe(struct platform_device *pdev) } priv->gpio_fm_sel = devm_gpiod_get_optional(dev, "fm-sel", GPIOD_OUT_HIGH); - if (IS_ERR(priv->gpio_fm_sel)) { - dev_err(dev, "Failed to get FM selection GPIO\n"); - return PTR_ERR(priv->gpio_fm_sel); - } + if (IS_ERR(priv->gpio_fm_sel)) + return dev_err_probe(dev, PTR_ERR(priv->gpio_fm_sel), + "Failed to get FM selection GPIO\n"); priv->gpio_lineout_sel = devm_gpiod_get_optional(dev, "lineout-sel", GPIOD_OUT_HIGH); - if (IS_ERR(priv->gpio_lineout_sel)) { - dev_err(dev, "Failed to get line out selection GPIO\n"); - return PTR_ERR(priv->gpio_lineout_sel); - } + if (IS_ERR(priv->gpio_lineout_sel)) + return dev_err_probe(dev, PTR_ERR(priv->gpio_lineout_sel), + "Failed to get line out selection GPIO\n"); priv->gpio_headset_detect = devm_gpiod_get_optional(dev, "headset-detect", GPIOD_IN); From patchwork Wed May 8 10:58:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CBEFC04FFE for ; Wed, 8 May 2024 11:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SWY06hrm5bjbKCr6hQAB0nhBd8shTfSndJlLbFUA+sg=; b=F5olHtawMt7EKt +kvafOQLUxniJOmi0ypTn0LFNv3dACLwTIxMK53oVMAqCLN6L0aTiHHmicCodt3YiWzCaCPz3Y3GU OZnQnJ4Sm9RZkoKashDybZEILPeuaoVTRXfxyHmpIDUx7FchN/P1g7FDd5Oa9NDsZlODLAneOczWu kQUwOLVKVIaDKW7EjHjGAb5B3T4g9rywV6vk8EzRAk9DETi3/kTQ9waVjhFetvBr4g+tFzVfVfvkp pi68dFuXgMwMpq9Qa53CDfBYvq9Mv/HJtool0gsCgJYVQfEN+pNSxAAnAKm9MjsxIHPEK8TjS1N6a A+f1wutXn1UkzTO/vuWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3U-0000000F6Ee-3Zi4; Wed, 08 May 2024 11:01:49 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3D-0000000F5yG-2u8a for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:35 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-51fc01b6fe7so3849322e87.0 for ; Wed, 08 May 2024 04:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166086; x=1715770886; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JckYzcWe8w+0grZPS9NysF8GgHh7PfoFNUhYz6cHvfw=; b=ZYQ8qCi/HK+5ZXkYeJ8SqK7a54brnfItzXW2FExSZOKFO+KAjgtCrzgsyEzhaC3rPW U08JfWYVTJItofgQsKoWvto/M3Di0f4vLX9fPF5+GpSdsRnXH3d83Cp+bS55wAI+fy4R fxA9627tNNN1hrBCOVdGBhNfiINzef1EJNj4DrtG8elABqaewsQqeD6biHAPOLI/F7xD CSCv/UNRlBDD8eW5P4i6dX4Zh7VVmj5ccvgdVrC5W4xIOcsBVHhrALX+MgYK91tWr8mK hLH5xh2T2aCkrjHnUcQHwF1Zr38gVp1tTrxzrjpmSd3bVNg4JgQL4bmMAgTPbniwDXvu MwNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166086; x=1715770886; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JckYzcWe8w+0grZPS9NysF8GgHh7PfoFNUhYz6cHvfw=; b=Hz8sORgOKRLNEA41OhwNCMWUf4s95ctMJOEdeeeRxU/FTApodmvwN4knksyzJuBByb oFKsy94Cn4mqGJvfOiWJKvG47Rnr61zMpEh2LZG2s3TraS1H58opqH+nB1fZMc1HpsC+ Xbmo4Gg202V9SEkIws8q2dqZaW/ZfCoqijLkZQSLbBJO6U5gBWyzA/3NWpwnYT05TtkQ sAUaROlF54HciZOnbpbPIk5LIRTYGVFH16Z79d3vZXGuAoKWLlp5iibzR4dRdl2c6vAA AyxHmhpLdiDFmJB4CCxYHu6uRrImbjFQ2EW8yj7n/z9xpzu9evEz/5mizAIQ1a1bH1aw 4zIQ== X-Forwarded-Encrypted: i=1; AJvYcCXtGt01PJUG5qiRSnpveyVZQ1gK4U6NcVJFmM7a7sfkERhotL9jJEm9f07uH+CU1m/58+ImOphAbeEyjnr8FEK1osVEJAmZZ5GIO/N5x9Rubdy3s1k= X-Gm-Message-State: AOJu0YwHQDpaDIaJNYbycZzL5D/YnNpqT7jlWVEhswNf3uA2FhKMLzha 3n7ls5LhOBh6+3WDlNEsPLBRzsMTLp1Gi2UgoID9At4an2G+JuXL X-Google-Smtp-Source: AGHT+IGeO76uQCED1J00VN9QCAey1wfpGDo3fQs8/bwbKEbtAP/7na2lzT5MZkH/YfwFEC18bO8Zag== X-Received: by 2002:a05:6512:40e:b0:518:9362:f63 with SMTP id 2adb3069b0e04-5217b5a6837mr1384384e87.0.1715166085711; Wed, 08 May 2024 04:01:25 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:25 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:54 +0200 Subject: [PATCH v2 6/7] ARM: dts: samsung: exynos4212-tab3: Fix headset mic, add jack detection MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-6-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=1934; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=7ghoUuP1F66lo5lQILjtg4IgiT6Z0TAcd0jCIemjWlQ=; b=l0DFXbMoynUW/3tl/JJn+d4FFNg8IhQpMsG9UJeOU2kGTDNLpMYNTOAalpniOTbooBzyKlSiZ P9EqRrOaA4YA0I/fq2SM0f9GJDPc5NwRz+qYyqlEMUZfFI//F0HjlH5 X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040132_560717_05854948 X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Set up headset mic bias regulator and add the necessary properties to the samsung,midas-audio node to allow for headset jack detection. Signed-off-by: Artur Weber --- Changes in v2: - Added headset mic bias regulator - Added samsung prefix to threshold properties - Dropped wm1811 config changes --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index e5254e32aa8f..8dc81112172c 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -294,11 +294,30 @@ submic_bias_reg: voltage-regulator-5 { regulator-max-microvolt = <2800000>; }; + earmic_bias_reg: voltage-regulator-6 { + compatible = "regulator-fixed"; + regulator-name = "EAR_MICBIAS_LDO_2.8V"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + gpio = <&gpm0 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + sound: sound { compatible = "samsung,midas-audio"; model = "TAB3"; mic-bias-supply = <&mic_bias_reg>; submic-bias-supply = <&submic_bias_reg>; + headset-mic-bias-supply = <&earmic_bias_reg>; + + lineout-sel-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>; + + headset-detect-gpios = <&gpx0 4 GPIO_ACTIVE_LOW>; + headset-key-gpios = <&gpx3 6 GPIO_ACTIVE_LOW>; + samsung,headset-4pole-threshold-microvolt = <710 2000>; + samsung,headset-button-threshold-microvolt = <0 130 260>; + io-channel-names = "headset-detect"; + io-channels = <&adc 0>; audio-routing = "HP", "HPOUT1L", "HP", "HPOUT1R", @@ -345,6 +364,11 @@ wlan_pwrseq: sdhci3-pwrseq { }; }; +&adc { + vdd-supply = <&ldo3_reg>; + status = "okay"; +}; + &bus_acp { devfreq = <&bus_dmc>; status = "okay"; From patchwork Wed May 8 10:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13658554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82F43C04FFE for ; Wed, 8 May 2024 11:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=09qw2h200GMATPkHKtKo8c7gc56Qu+U43sppBXGUlWw=; b=Cfy8mTukNZy81M Iq17+nELHP9a7ekKdykjg4DzJrYmouBaqppxHFrHx12Lbo1UVyI2RGGyX4IfagbrDxmsMvRByNT6Z KsuVEU1VxNbYKi6f0IBtyBt3p5PLuBrp8U3cdWHV9m8wFKodobb9BxsJiDY0iGOsFPlz1AfgWQYnp gIKFFAk+Y0l8pBRuFLU4AT9YMGh7BgtCW/PwWy4tLhScOu2k1ISmoDEsxeHMKVnkzF/EXjq8BJmQr R6A/P9a/1ANXCz1KNAHcUd7E1LappQyLLhFaq9+RWUng41w39A0ZTOMCPXpaLbsy0VTak24GbuL03 dB+2HEnaZStaA+7+uosQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3Y-0000000F6HM-0QCM; Wed, 08 May 2024 11:01:52 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4f3G-0000000F5yz-2tRK for linux-arm-kernel@lists.infradead.org; Wed, 08 May 2024 11:01:36 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a5200afe39eso1110560366b.1 for ; Wed, 08 May 2024 04:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715166087; x=1715770887; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1xXdtLXh9Wq/U+DCcvi3Zl9MvXXMxZj9qmUG/1NN6b8=; b=Xl5B0A8ceAngxzR4oZtnPAfSWbHiNTw654nRZ/Culs/iE1eTb+5a7IwJBE+SV7YCun o6fDQI0vck29NFOqYtmUZDosAxRsMAczCoZwkPs/4RiG0ReAhNSCDrgCQ6XxmYSFTfbN hHCBcf2Ai932XhQtEYEZm3Js3nz6O9u1E9707NuudWzF9SXtTTePvJQZcGObAzDHGt+d HOBbEfFa9/WTiw3qto0li7kTdMsnTH5mY9yz181uezIIXVh2Dk9gNzy9gesk6Qocvk5/ ZH0eWg4+uFrbUUnjGezmV2yzuLLmyjkc3+WZSLsHy3PeXjJQqsM64oL5ZO5j7xUOiVMl mUvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715166087; x=1715770887; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1xXdtLXh9Wq/U+DCcvi3Zl9MvXXMxZj9qmUG/1NN6b8=; b=wugvX7K8MYZybzCEmSrpBwihOPOn544aqCsL18dGHuJFZaWBVIhVbo37Plhbrn5Fv9 wHZV7rhx5I32WKHj9YewYYUIttgKVgGgpQP0xbCyUqDpkHAFg/+Bif7d/ectuhLx2LWd 7OrZwWTWqShW12TBa4vhP8Npfe67pA11IcydKAxqIb3lfGwoPQZu/e+sMf2RAB02nKGi GB4fum/vpPTNiIHiFoogYeK5qrtX09Mj2AX4K9wUvB3y+jCbYMZdV4AS6xI/GdJ75YYu N10tcieoxxsDAwyKEnmF442FQLqpGZtOEI/PGICafygNH/m4HdI1LlcNuyd++ZZPZB88 ZH3A== X-Forwarded-Encrypted: i=1; AJvYcCW/hs6tfgpp/O7rcuaAWC3jPRrh7L9lEbBw99hoye6G+hKsHMYQ6jL0rFUsYOwBubipLYXrM1AWowLvuN0z/I/qAP1KJajkkV5DRa/HEwWHo8Qn3zo= X-Gm-Message-State: AOJu0YziHISuZqjhuPoZkjOR2BleJU3s6nHtbxtHGluLNCPfZPjS+xQ5 Bp+2E4MBukivL8sWy1eEd2NHKI7Oy5qqZ+B6hPmJdW3d9JbN00E5 X-Google-Smtp-Source: AGHT+IHSvqngLWudU2mq3sRdhAXsMHPmyVHOgZ0v5JQdfowG5AeyhCGC/cKuo86niykSWYIXOiqDig== X-Received: by 2002:a50:a699:0:b0:572:664c:83f2 with SMTP id 4fb4d7f45d1cf-5731da68d64mr1873313a12.27.1715166087014; Wed, 08 May 2024 04:01:27 -0700 (PDT) Received: from hex.my.domain (83.8.126.253.ipv4.supernova.orange.pl. [83.8.126.253]) by smtp.gmail.com with ESMTPSA id m6-20020a056402510600b005726b58a436sm7455793edd.30.2024.05.08.04.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:01:26 -0700 (PDT) From: Artur Weber Date: Wed, 08 May 2024 12:58:55 +0200 Subject: [PATCH v2 7/7] ARM: dts: samsung: exynos4212-tab3: Fix up wm1811 codec config MIME-Version: 1.0 Message-Id: <20240508-midas-wm1811-gpio-jack-v2-7-b4d36cd02c6e@gmail.com> References: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> In-Reply-To: <20240508-midas-wm1811-gpio-jack-v2-0-b4d36cd02c6e@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715166076; l=1054; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=UL/4N8rXRM70GUqix5tPsZFEQGhkMZHDmI2ayaFJGlM=; b=7BPWy7GfZUBZ3TTXDAlEmhxr7SnPBBZ9ehQ1CJLgWoE87M699gDN5kcEDVe31eaoWB0oP2YD5 Aj6UHKKMILGCsBtWyvT/a6q3VshUe0QJDlyqa8bnGA8MeXyc3wPf4XJ X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_040134_832570_94FFA112 X-CRM114-Status: GOOD ( 11.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Drop incorrect interrupt parent and add MCLK2 clock. Signed-off-by: Artur Weber --- Changes in v2: - Split out wm1811 changes from midas-audio config change patch --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index 8dc81112172c..20e5e7ba6b92 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -529,12 +529,11 @@ &i2c_4 { wm1811: audio-codec@1a { compatible = "wlf,wm1811"; reg = <0x1a>; - clocks = <&pmu_system_controller 0>; - clock-names = "MCLK1"; + clocks = <&pmu_system_controller 0>, + <&s5m8767_osc S2MPS11_CLK_BT>; + clock-names = "MCLK1", "MCLK2"; interrupt-controller; #interrupt-cells = <2>; - interrupt-parent = <&gpx3>; - interrupts = <6 IRQ_TYPE_LEVEL_HIGH>; gpio-controller; #gpio-cells = <2>;