From patchwork Mon Oct 28 15:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13853692 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C5E51DE3D2; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; cv=none; b=nVhQ1DktEQ8eeZeYPHInoz9JBQ0n1Puk3ECa2Rb1yKvA+ISP/1Icl+f9SVb+2ynLuwj5BxXI5yUJYXKKOpECLD5LZrMkBfYBlZZGx+/UBtiIEZb7KkXl42Zh4J20pYlDKftmoT/DpygfdyXyN6bLsM9vo5iIFFbR58Jue5is0pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; c=relaxed/simple; bh=9yAAeMLN9OIod/3f3TPfdB/RXfFmIQlQOi6c1h8WWQw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lQO9QtSY51fvJ86SH3Sx7LNG518f2Zc6DbauXOohssBGZgmp1u/YE/8gtsbHt+542ed8DPpr/NBr+5jQDoAk464ZxOH2bFLGoLP/SQBwI9NimcAo6dTbM8UQTns6pQ80xLjk7ttA7D6vghfMcKRbPXGD9Zy6PRJsYR9x/U+W0+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OZQ2ZYiK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OZQ2ZYiK" Received: by smtp.kernel.org (Postfix) with ESMTPS id DE9C1C4CEE4; Mon, 28 Oct 2024 15:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730130220; bh=9yAAeMLN9OIod/3f3TPfdB/RXfFmIQlQOi6c1h8WWQw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OZQ2ZYiKYuv5AZLYMtGHfWDODH5eGISqQEoCKEGj1jpchoO14hdK/vq+HBvCYcaF/ hc1azJA48gPjXOpw0l6Qduo+dgwlmIdqlvErlYt7egmuHkWk1aqDlPpHIvK/uHtcgJ J6OklcWMzrMquih/ZKz9XxXlcu90UJv1VJZpNGw71j1lQ7MzC9kjw0IG0irFAsy4HY nQR0RzH/S0BzRRE58Y+dGqeWY/wLL7fTEgVCpgQEgirMWWa3yvaEvOFYSgDeAuz4B3 X6tvPXdvESA/T/oEk2g+uf/NdcAGfxZHIRXnqMfPLzuHJrC1FETP14UKOzoxp3MfzH JFtZWrNsDE1gg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC826D33998; Mon, 28 Oct 2024 15:43:40 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Mon, 28 Oct 2024 16:43:38 +0100 Subject: [PATCH v2 1/4] ASoC: codecs: adau1373: add some kconfig text Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-adau1373-shutdown-v2-1-647f56bbd182@analog.com> References: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> In-Reply-To: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> To: linux-sound@vger.kernel.org, devicetree@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730130219; l=634; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=N9cgwu1zwzbWD0Fw9Jji5tH1Q286lBcXZ7unQPQVoMc=; b=bZajh8COAzo3ueYiEtpERuzBybdCOmSlIp7naGoorXVvjZd5C+Z9EVkceVvWEnCoBCxzxY6qN gJc9NwNPJasCuRral1nBov4XDCHfkC/b6/3y99gxIDYXKOwezGuTFkG X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa Add some text to 'tristate' so that we can actually enable the driver when using things like menuconfig. Signed-off-by: Nuno Sa --- sound/soc/codecs/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6a6125e94d2d..72643907cef7 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -464,7 +464,7 @@ config SND_SOC_ADAU1372_SPI select REGMAP_SPI config SND_SOC_ADAU1373 - tristate + tristate "Analog Devices ADAU1373 CODEC" depends on I2C select SND_SOC_ADAU_UTILS From patchwork Mon Oct 28 15:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13853695 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F8F71DE4C0; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; cv=none; b=L+vCa7+hBgIsoy5PtGSTh3Vo2Wk4ZCJdTZbu49H541a+OG4HlnYd5FDQiuHDnZG7uzSQ2+OiDc1eoGpVAleKGqS7eBQtMimlXoEqBDjN76FrtAPLxI4m+TkWr8pfD7wQ/MSbHT0v7Dz47Q+5QCj2dzpBBimIn/eW9VIUPzeTJ0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; c=relaxed/simple; bh=JZ8SDOTGMdpYsYOVNzjby/fRRlB1xolUofi/4r08bQk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pwCpzlPkxe47/Ji8MQa229mLcHEBwEwgfd1CUDs1pAqSPPaS7WmY5Bw/xDOSOgG/eaLM2ly+kvRHDOy7RnelsIgpGXYlRh4luvOTlkpGbmHKP/HSZVABD+xXIPdu9GjOq02jnPl279h5CZUwaV5FLs8BIKhkQMh4UtVt05JOtAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GR1W1PvY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GR1W1PvY" Received: by smtp.kernel.org (Postfix) with ESMTPS id F00F5C4CEC7; Mon, 28 Oct 2024 15:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730130221; bh=JZ8SDOTGMdpYsYOVNzjby/fRRlB1xolUofi/4r08bQk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GR1W1PvYDMORXjQ1YUaYpSmTjtz+Y366qQUj23P8S/sWMEfNpEknwwuqgbcDhQaQz 4yBe9+ipx6aBhruMAHi7nksyBw4yu7rWwd0xas5RqQBWau7ilGfZg78MOn1T5CMBUu gzdZBrwcgpF8IM2riCi0k2gOEvx4ckFOhd/dwRRJohT34LOT3AnDJsHYigk+rm/WOf XOtkbd58RERuhIEoif3kn3wFaeiNpM5IbvLO9E1v5e/M70tT97ldVa0uZtQJALHJ/g 5GzDI7S0N/NqAzEH8KKUIOUkTHS5+Jo07KiqcoHb6g/Fa6Acc6o3BHTtKZEm6+7/pV bVOhi42Ixm47Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDBCDD33990; Mon, 28 Oct 2024 15:43:40 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Mon, 28 Oct 2024 16:43:39 +0100 Subject: [PATCH v2 2/4] ASoC: dt-bindings: document the adau1373 Codec Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-adau1373-shutdown-v2-2-647f56bbd182@analog.com> References: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> In-Reply-To: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> To: linux-sound@vger.kernel.org, devicetree@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730130219; l=4205; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=e6/jgIZWmuR3Nbe5npqQP5ffqfzdhUaw8odBN01/3Ho=; b=lvBiVXRZY3VExRrlBxINZ1pqhMupcpXaQk5ZpwwgexekX6liDiyNNn0djQ23mLseD9DjN1l7p XP3tv6GnLZxBeAkxMQQkOpib53Ep/fneXSjm7shVDQG2oJxAu4BLnKm X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa Describe the adau1373 Low Power Codec with Speaker and Headphone Amplifier. While at it, properly add a MAINTAINERS entry for ADI sound bindings. Signed-off-by: Nuno Sa Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/sound/adi,adau1373.yaml | 111 +++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 112 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/adi,adau1373.yaml b/Documentation/devicetree/bindings/sound/adi,adau1373.yaml new file mode 100644 index 000000000000..97552bf5d951 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/adi,adau1373.yaml @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/adi,adau1373.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADAU1373 CODEC + +maintainers: + - Nuno Sá + +description: | + Analog Devices ADAU1373 Low power codec with speaker and headphone amplifiers. + https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU1373.pdf + +allOf: + - $ref: dai-common.yaml# + +properties: + compatible: + enum: + - adi,adau1373 + + reg: + maxItems: 1 + + "#sound-dai-cells": + const: 0 + + powerdown-gpios: + description: GPIO used for hardware power-down. + maxItems: 1 + + adi,micbias1-microvolt: + description: + This property sets the microphone bias voltage for the first microphone. + enum: [1800000, 2200000, 2600000, 2900000] + default: 2900000 + + adi,micbias2-microvolt: + description: + This property sets the microphone bias voltage for the second microphone. + enum: [1800000, 2200000, 2600000, 2900000] + default: 2900000 + + adi,input1-differential: + description: This property sets the first analog input as differential. + type: boolean + + adi,input2-differential: + description: This property sets the second analog input as differential. + type: boolean + + adi,input3-differential: + description: This property sets the third analog input as differential. + type: boolean + + adi,input4-differential: + description: This property sets the fourth analog input as differential. + type: boolean + + adi,lineout-differential: + description: This property sets the line output as differential. + type: boolean + + adi,lineout-gnd-sense: + description: This property enables the line output ground sense control. + type: boolean + + adi,drc-settings: + description: + This setting is used to control the dynamic range of the signal. The + device provides a maximum of three full band DRCs with 13 entries each. + $ref: /schemas/types.yaml#/definitions/uint8-array + oneOf: + - minItems: 13 + maxItems: 13 + - minItems: 26 + maxItems: 26 + - minItems: 39 + maxItems: 39 + +required: + - "#sound-dai-cells" + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + audio-codec@1a { + compatible = "adi,adau1373"; + reg = <0x1a>; + #sound-dai-cells = <0>; + powerdown-gpios = <&gpio 100 GPIO_ACTIVE_LOW>; + adi,input2-differential; + adi,input1-differential; + adi,lineout-differential; + adi,micbias2-microvolt = <1800000>; + adi,drc-settings = /bits/ 8 < + 0xff 0xff 0x1 0x2 0xa 0xa 0xd 0x1 0xff 0xff 0x5 0xd 0xff + >; + }; + }; +... diff --git a/MAINTAINERS b/MAINTAINERS index 9d6272c00fbd..24bc5fcac74a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1521,6 +1521,7 @@ L: linux-sound@vger.kernel.org S: Supported W: http://wiki.analog.com/ W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/sound/adi,* F: sound/soc/codecs/ad1* F: sound/soc/codecs/ad7* F: sound/soc/codecs/adau* From patchwork Mon Oct 28 15:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13853694 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F8931DE3CB; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; cv=none; b=t4eF0PKB63oAcA0LdXDwtXlMapTbScff6PO4i2Bd946V1AxvnhrY/pzLpBAG/Ij+caqYnqFNQnmItu3aTzQ/Adhq60m7keKBrpqlNlTE7DHH7TsJsuHgJMZiYI+pODw8RVxOfi/fgy5TOnVT3C2AuIMf+dWvKaQevJE43DdUZMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; c=relaxed/simple; bh=7GmOHS1g7XNGzqE3bVs+gDQsCq+bzr/JABcF7A7pvbU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oQHa7ogPxcRTHEqNpGdCSz+rHin88g27uH+AQ2T9lV18T/RcWSEWmGEPothiOpwAMwC/mxZdG6UE3LzKdJgzJDwOTE2/Mn+1sI14flY1ll5s5cu5zUXd3U5Redzu9S0aUMsTs7WamrO7lY5FKtjSnbtD6DEn6bHa4PfPqumgKT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VQYWQSFf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VQYWQSFf" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0C074C4CEE7; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730130221; bh=7GmOHS1g7XNGzqE3bVs+gDQsCq+bzr/JABcF7A7pvbU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VQYWQSFf0V6PTa1ZTRDoyfHQnnSSkiIZKmIqCmkDg80D5TZoJM1vJxv2yaCn21wTe rYsWq0Rf7GMO83QNC8DCDSFCKplpgO4wYivz8W3KrqnfAUz+qrwhB+tRSOBlxx8rjQ eR9hPz6lXWOIehs6JSWOPhEp42itdMcFX47EjlEnxXSi9EgX3BENbgNqVHngKCwE5D R49/hAmdxc8Ie9MTK6WBZzW360P+axk3qhUhuQJiWumX+QQK4zZVSuqG1cVyikkMKG NZ06ri3aL4MIJOyVQX6JCFdv3Ho65M4D2qKhTmukhXE4WWZFs2ODbu0hqqsqu4W3LI vw3eJNQpNqNDg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F074FD3399B; Mon, 28 Oct 2024 15:43:40 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Mon, 28 Oct 2024 16:43:40 +0100 Subject: [PATCH v2 3/4] ASoC: codecs: adau1373: drop patform_data Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-adau1373-shutdown-v2-3-647f56bbd182@analog.com> References: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> In-Reply-To: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> To: linux-sound@vger.kernel.org, devicetree@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730130219; l=9043; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=dHg5v3Tm4e+iNc4Dk4UiH5t7seHJwVMtM4uWrtlPW8g=; b=+rcNMexDJeHG2riLV3QROGaTxmGhy9RN32tw2AJleMm6ccosy44Kg88NgelFYeokWhYwYxJD+ OCWgvVTGRYHBlGJi4h4/LrtkmQm9lz1LL1Z6Qab38/6ePazgt1L5k1l X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa struct adau1373_platform_data" was not being used by any platform. Hence, drop it and move to firmware based support. All the configurations quirks present in the platform_data are now supported as firmware properties. Signed-off-by: Nuno Sa --- include/sound/adau1373.h | 33 -------- sound/soc/codecs/adau1373.c | 180 ++++++++++++++++++++++++++++++++------------ 2 files changed, 132 insertions(+), 81 deletions(-) diff --git a/include/sound/adau1373.h b/include/sound/adau1373.h deleted file mode 100644 index 4c32ba1328eda..0000000000000 --- a/include/sound/adau1373.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Analog Devices ADAU1373 Audio Codec drive - * - * Copyright 2011 Analog Devices Inc. - * Author: Lars-Peter Clausen - */ - -#ifndef __SOUND_ADAU1373_H__ -#define __SOUND_ADAU1373_H__ - -enum adau1373_micbias_voltage { - ADAU1373_MICBIAS_2_9V = 0, - ADAU1373_MICBIAS_2_2V = 1, - ADAU1373_MICBIAS_2_6V = 2, - ADAU1373_MICBIAS_1_8V = 3, -}; - -#define ADAU1373_DRC_SIZE 13 - -struct adau1373_platform_data { - bool input_differential[4]; - bool lineout_differential; - bool lineout_ground_sense; - - unsigned int num_drc; - uint8_t drc_setting[3][ADAU1373_DRC_SIZE]; - - enum adau1373_micbias_voltage micbias1; - enum adau1373_micbias_voltage micbias2; -}; - -#endif diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index a910e252aa126..9568ff933e12b 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -18,7 +19,6 @@ #include #include #include -#include #include "adau1373.h" #include "adau-utils.h" @@ -30,9 +30,28 @@ struct adau1373_dai { bool clock_provider; }; +enum adau1373_micbias_voltage { + ADAU1373_MICBIAS_2_9V, + ADAU1373_MICBIAS_2_2V, + ADAU1373_MICBIAS_2_6V, + ADAU1373_MICBIAS_1_8V, +}; + +#define ADAU1373_DRC_SIZE 13 + struct adau1373 { struct regmap *regmap; struct adau1373_dai dais[3]; + + bool input_differential[4]; + bool lineout_differential; + bool lineout_ground_sense; + + unsigned int num_drc; + u8 drc_setting[3][ADAU1373_DRC_SIZE]; + + enum adau1373_micbias_voltage micbias1; + enum adau1373_micbias_voltage micbias2; }; #define ADAU1373_INPUT_MODE 0x00 @@ -1332,66 +1351,61 @@ static void adau1373_load_drc_settings(struct adau1373 *adau1373, regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]); } -static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) +static int adau1373_get_micbias(unsigned int val, + enum adau1373_micbias_voltage *micbias) { - switch (micbias) { - case ADAU1373_MICBIAS_2_9V: - case ADAU1373_MICBIAS_2_2V: - case ADAU1373_MICBIAS_2_6V: - case ADAU1373_MICBIAS_1_8V: - return true; + switch (val) { + case 2900000: + *micbias = ADAU1373_MICBIAS_2_9V; + return 0; + case 2200000: + *micbias = ADAU1373_MICBIAS_2_2V; + return 0; + case 2600000: + *micbias = ADAU1373_MICBIAS_2_6V; + return 0; + case 1800000: + *micbias = ADAU1373_MICBIAS_1_8V; + return 0; default: - break; + return -EINVAL; } - return false; } static int adau1373_probe(struct snd_soc_component *component) { struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); - struct adau1373_platform_data *pdata = component->dev->platform_data; - bool lineout_differential = false; unsigned int val; int i; - if (pdata) { - if (pdata->num_drc > ARRAY_SIZE(pdata->drc_setting)) - return -EINVAL; - - if (!adau1373_valid_micbias(pdata->micbias1) || - !adau1373_valid_micbias(pdata->micbias2)) - return -EINVAL; - - for (i = 0; i < pdata->num_drc; ++i) { - adau1373_load_drc_settings(adau1373, i, - pdata->drc_setting[i]); - } - - snd_soc_add_component_controls(component, adau1373_drc_controls, - pdata->num_drc); - - val = 0; - for (i = 0; i < 4; ++i) { - if (pdata->input_differential[i]) - val |= BIT(i); - } - regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val); - - val = 0; - if (pdata->lineout_differential) - val |= ADAU1373_OUTPUT_CTRL_LDIFF; - if (pdata->lineout_ground_sense) - val |= ADAU1373_OUTPUT_CTRL_LNFBEN; - regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val); - - lineout_differential = pdata->lineout_differential; - - regmap_write(adau1373->regmap, ADAU1373_EP_CTRL, - (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | - (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); + for (i = 0; i < adau1373->num_drc; ++i) { + adau1373_load_drc_settings(adau1373, i, + adau1373->drc_setting[i]); } - if (!lineout_differential) { + snd_soc_add_component_controls(component, adau1373_drc_controls, + adau1373->num_drc); + + val = 0; + for (i = 0; i < ARRAY_SIZE(adau1373->input_differential); ++i) { + if (adau1373->input_differential[i]) + val |= BIT(i); + } + regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val); + + val = 0; + if (adau1373->lineout_differential) + val |= ADAU1373_OUTPUT_CTRL_LDIFF; + if (adau1373->lineout_ground_sense) + val |= ADAU1373_OUTPUT_CTRL_LNFBEN; + + regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val); + + regmap_write(adau1373->regmap, ADAU1373_EP_CTRL, + (adau1373->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | + (adau1373->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); + + if (!adau1373->lineout_differential) { snd_soc_add_component_controls(component, adau1373_lineout2_controls, ARRAY_SIZE(adau1373_lineout2_controls)); } @@ -1471,6 +1485,65 @@ static const struct snd_soc_component_driver adau1373_component_driver = { .endianness = 1, }; +static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373) +{ + int ret, drc_count; + unsigned int val; + + if (device_property_present(dev, "adi,input1-differential")) + adau1373->input_differential[0] = true; + if (device_property_present(dev, "adi,input2-differential")) + adau1373->input_differential[1] = true; + if (device_property_present(dev, "adi,input3-differential")) + adau1373->input_differential[2] = true; + if (device_property_present(dev, "adi,input4-differential")) + adau1373->input_differential[3] = true; + + if (device_property_present(dev, "adi,lineout-differential")) + adau1373->lineout_differential = true; + if (device_property_present(dev, "adi,lineout-gnd-sense")) + adau1373->lineout_ground_sense = true; + + ret = device_property_read_u32(dev, "adi,micbias1-microvolt", &val); + if (!ret) { + ret = adau1373_get_micbias(val, &adau1373->micbias1); + if (ret) + return dev_err_probe(dev, ret, + "Failed to get micbias1(%u)\n", val); + } + + ret = device_property_read_u32(dev, "adi,micbias2-microvolt", &val); + if (!ret) { + ret = adau1373_get_micbias(val, &adau1373->micbias2); + if (ret) + return dev_err_probe(dev, ret, + "Failed to get micbias2(%u)\n", val); + } + + drc_count = device_property_count_u8(dev, "adi,drc-settings"); + if (drc_count < 0) + return 0; + if (drc_count % ADAU1373_DRC_SIZE != 0) + return dev_err_probe(dev, -EINVAL, + "DRC count(%u) not multiple of %u\n", + drc_count, ADAU1373_DRC_SIZE); + + adau1373->num_drc = drc_count / ADAU1373_DRC_SIZE; + if (adau1373->num_drc > ARRAY_SIZE(adau1373->drc_setting)) + return dev_err_probe(dev, -EINVAL, + "Too many DRC settings(%u)\n", + adau1373->num_drc); + + ret = device_property_read_u8_array(dev, "adi,drc-settings", + (u8 *)&adau1373->drc_setting[0], + drc_count); + if (ret) + return dev_err_probe(dev, ret, + "Failed to read DRC settings\n"); + + return 0; +} + static int adau1373_i2c_probe(struct i2c_client *client) { struct adau1373 *adau1373; @@ -1489,6 +1562,10 @@ static int adau1373_i2c_probe(struct i2c_client *client) dev_set_drvdata(&client->dev, adau1373); + ret = adau1373_parse_fw(&client->dev, adau1373); + if (ret) + return ret; + ret = devm_snd_soc_register_component(&client->dev, &adau1373_component_driver, adau1373_dai_driver, ARRAY_SIZE(adau1373_dai_driver)); @@ -1501,9 +1578,16 @@ static const struct i2c_device_id adau1373_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, adau1373_i2c_id); +static const struct of_device_id adau1373_of_match[] = { + { .compatible = "adi,adau1373", }, + { } +}; +MODULE_DEVICE_TABLE(of, adau1373_of_match); + static struct i2c_driver adau1373_i2c_driver = { .driver = { .name = "adau1373", + .of_match_table = adau1373_of_match, }, .probe = adau1373_i2c_probe, .id_table = adau1373_i2c_id, From patchwork Mon Oct 28 15:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa via B4 Relay X-Patchwork-Id: 13853696 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DF9B1DE4DE; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; cv=none; b=MdRTFMBWQz93L7bU7djlA/GVx5Z0QyYg9dw9E71AbApncvnwz+Ze26CV6zV7ZZSl2Sj9+6OUwK9+Goa/JbU3jCBXts9SfKIMpdao092dtjSuaXPqhO5Nfv6hKFY7cRb7nbnEYNrKcyJda88YkqmSmKWHymPvsSoLulOpi86thKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730130221; c=relaxed/simple; bh=2x/ZD96RRHOBCxrye3iTWKv5vRtUhfGFCT9vm5h5CAA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OS0Eu+2p3erhfpNnhhXNG55XEFVMSibF+bdFHthqXS7ZfyIku5/3zwxiB8K2Z/RbCBSgbDjy75S3lTXh+aHn4O8OKYGZXR6fLzeO7OOPsizSspb2KOpyHOnW+Ryd/sB3My2YTXTRL1cKGAMZbBHhRNadq1kIry1GVtFOj+iFFiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gHJDIRsG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gHJDIRsG" Received: by smtp.kernel.org (Postfix) with ESMTPS id 18699C4CEEC; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730130221; bh=2x/ZD96RRHOBCxrye3iTWKv5vRtUhfGFCT9vm5h5CAA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gHJDIRsGmOX66i8kO/6XtSKyHN9UQqnP9rleDfFexySAzLqFa0zjxaLliY24glCJN C4a3cgHTMPdFilVNCXYwMNRkZroq1qoySWAQqp90ptLrOSqG5QQjHjMU+3Xo7r6lQU roDuHk9qqccIBzqLHppLqpAbzlrgzYtEOZung6JwcDAIaVtLQ7fojDExbuVx40Nxpg 1HvgVUVJSbPLfWlN6zJ29hCJlCa5AwDHUmS68oF+Ilk//Iw1npf+WoJgDbWCwKTjxi Ini9kueFERShOxfCc2h7bDaZg4kcJFigte6CfPAaCpxSlSp6Uycf2v6wMveV9cr+2u 9XXASEPLCmNxw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E32DD3399D; Mon, 28 Oct 2024 15:43:41 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Mon, 28 Oct 2024 16:43:41 +0100 Subject: [PATCH v2 4/4] ASoC: codecs: adau1373: add powerdown gpio Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-adau1373-shutdown-v2-4-647f56bbd182@analog.com> References: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> In-Reply-To: <20241028-adau1373-shutdown-v2-0-647f56bbd182@analog.com> To: linux-sound@vger.kernel.org, devicetree@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730130219; l=2094; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=l3lW7MaibCAG7NXnOqoYOWvd1BhDU+VCpOJOb6hZNr0=; b=P9AQLYbRT4/dJAYNIHgWRzAYiDqi3kiQm1K0uxO+anv520Spe4z5gu1jBz215/Nv/2LVtso3N gpDhdaWUWdoDKDAdgYWIoFhQ8LjfjvnI2TVzWjmxB/pYC5IVq6xyGpp X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa If the powerdown GPIO is specified, we use it for reset. Otherwise, fallback to a software reset. Signed-off-by: Nuno Sa --- sound/soc/codecs/adau1373.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 9568ff933e12..16b9b2658341 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -1485,6 +1486,11 @@ static const struct snd_soc_component_driver adau1373_component_driver = { .endianness = 1, }; +static void adau1373_reset(void *reset_gpio) +{ + gpiod_set_value_cansleep(reset_gpio, 1); +} + static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373) { int ret, drc_count; @@ -1547,6 +1553,7 @@ static int adau1373_parse_fw(struct device *dev, struct adau1373 *adau1373) static int adau1373_i2c_probe(struct i2c_client *client) { struct adau1373 *adau1373; + struct gpio_desc *gpiod; int ret; adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL); @@ -1558,7 +1565,26 @@ static int adau1373_i2c_probe(struct i2c_client *client) if (IS_ERR(adau1373->regmap)) return PTR_ERR(adau1373->regmap); - regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00); + /* + * If the powerdown GPIO is specified, we use it for reset. Otherwise + * a software reset is done. + */ + gpiod = devm_gpiod_get_optional(&client->dev, "powerdown", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + + if (gpiod) { + gpiod_set_value_cansleep(gpiod, 0); + fsleep(10); + + ret = devm_add_action_or_reset(&client->dev, adau1373_reset, + gpiod); + if (ret) + return ret; + } else { + regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00); + } dev_set_drvdata(&client->dev, adau1373);