From patchwork Fri Sep 29 15:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Schambacher X-Patchwork-Id: 728569 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3E7E4E77362 for ; Sat, 30 Sep 2023 08:19:32 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 33D41EBE; Sat, 30 Sep 2023 10:18:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 33D41EBE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1696061971; bh=5267xrteeJIj4R0JInOg7X/x3Oyz68W6Tdklr66zM8A=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=Y+KKm6Oi0as3U3Jt7/u04kYhPl8LM76lTL4HTBHZI1shjng+Ct55GrYJ9ZRGfkOw4 LOmFHQrc/hKuPGo4X8ZaN3wNx4zJzdhLTazOIcyqduVEFDjUkdgsUf2SafZcn7ROrW SprJSDUuKRc3Cm6SY4Kil8WmvUiU9TA/m2hreb2c= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D0FDDF805C4; Sat, 30 Sep 2023 10:13:04 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A0F4AF805CA; Sat, 30 Sep 2023 10:13:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C300F801D5; Fri, 29 Sep 2023 17:06:47 +0200 (CEST) Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8D649F800AE for ; Fri, 29 Sep 2023 17:06:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8D649F800AE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=jKrzMxXx Received: by mail-wm1-x343.google.com with SMTP id 5b1f17b1804b1-405524e6769so5127455e9.1 for ; Fri, 29 Sep 2023 08:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695999981; x=1696604781; darn=alsa-project.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I+HDInQo6A1OIfSQ4kDLBbQAIE/uOQhrvXDem09PR3k=; b=jKrzMxXxla7/LkXjr1iTa4RVWGaesUA1WuvszYZhXRjNrsE790fgRpsY2emmbV7ncP nypLlOYwVvTWvj5Ff9aeHVi6URgklDYbBgqtxUeg8Vzd5JQKFbjQCtLMMQQNlPsjEFnD BTCmoF4AHT8PAVpbgQwUaw9acA03vtzhpqHAi3qzNvRKZi6yVh7DVR8jPbg5qPorEEs/ bM8AiiEPWXeUva5MuCIzBxuHIJSLo0ZSLv5UYj1z1aPTN9Wvu+n0mf0yvWfOReG1VbX0 1lWacfJGkIngKiC0NtleLFnotLVeVmMGgUKvDkT4lQ8jHxN5YK4nWPYu5y5F2YbAClgK be/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695999981; x=1696604781; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I+HDInQo6A1OIfSQ4kDLBbQAIE/uOQhrvXDem09PR3k=; b=tInQnsxP/n1xO0HHINkjyAPRCi5XDUW/MuQlq7oIJvb5hYjLOYdJCUmOUWi83X6qQB JmEzGVlaykRPw3Kfk/v1cFD9q6loY3OskVU79o5prCS9kEvel34sIYkvb1FgkzOnM167 LIgi6VK2lTaz871k8Pcupsa4k6Yw4BhfKbVJHoVMkkpjeNYL/xSLDtlzoM0C+3Y3yvY9 k/M63JGEVzHmxMUNVkjcQvFsdsYsRXz0QaMwHav3nCd/EeIn+YhpG8q51XxLWI+jw0/H LLBkaxC1fERwLrgXDtuDMCDd8YerDx0dAnvJv2JadOqdqBVL7yNnndTCVHlUVtVR3ukZ 7Pww== X-Gm-Message-State: AOJu0YzVfiDm5GTCQR8rEf/gc/WXF/tAip8dC64nbtvcRlXrf2b6Cwec sEMkXgRlFyZJtNBICIZVtXk= X-Google-Smtp-Source: AGHT+IFajsTW5J93K/OzzdCwONkeonYv1BhbbEV7MBCbRDZMmPHOe8BVXYC6nzOe54XQkf98bAaeqA== X-Received: by 2002:a7b:cd85:0:b0:402:ebe1:7960 with SMTP id y5-20020a7bcd85000000b00402ebe17960mr4202891wmj.2.1695999980586; Fri, 29 Sep 2023 08:06:20 -0700 (PDT) Received: from localhost ([2a02:810d:1640:10d8:9259:8ee2:26ea:3669]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b00405bbfd5d16sm1606110wma.7.2023.09.29.08.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:06:20 -0700 (PDT) From: Joerg Schambacher To: Cc: a-krasser@ti.com, joerg@hifiberry.com, Joerg Schambacher , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] ASoC: pcm512x: Adds bindings for TAS575x devices Date: Fri, 29 Sep 2023 17:05:55 +0200 Message-Id: <20230929150555.405388-1-joerg.hifiberry@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-MailFrom: joerg.hifiberry@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: VZJLKP57WK4OERCGNZ5KLW2ZBEQ3DI6Y X-Message-ID-Hash: VZJLKP57WK4OERCGNZ5KLW2ZBEQ3DI6Y X-Mailman-Approved-At: Sat, 30 Sep 2023 08:12:52 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The TAS5754/6 power amplifiers use the same pcm512x driver with only minor restictions described in the bindings document. Signed-off-by: Joerg Schambacher --- Documentation/devicetree/bindings/sound/pcm512x.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/pcm512x.txt b/Documentation/devicetree/bindings/sound/pcm512x.txt index 3aae3b41bd8e..77006a4aec4a 100644 --- a/Documentation/devicetree/bindings/sound/pcm512x.txt +++ b/Documentation/devicetree/bindings/sound/pcm512x.txt @@ -1,12 +1,12 @@ -PCM512x audio CODECs +PCM512x and TAS575x audio CODECs/amplifiers These devices support both I2C and SPI (configured with pin strapping -on the board). +on the board). The TAS575x devices only support I2C. Required properties: - - compatible : One of "ti,pcm5121", "ti,pcm5122", "ti,pcm5141" or - "ti,pcm5142" + - compatible : One of "ti,pcm5121", "ti,pcm5122", "ti,pcm5141", + "ti,pcm5142", "ti,tas5754" or "ti,tas5756" - reg : the I2C address of the device for I2C, the chip select number for SPI. @@ -25,6 +25,7 @@ Optional properties: through <6>. The device will be configured for clock input on the given pll-in pin and PLL output on the given pll-out pin. An external connection from the pll-out pin to the SCLK pin is assumed. + Caution: the TAS-desvices only support gpios 1,2 and 3 Examples: From patchwork Fri Sep 29 15:07:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Schambacher X-Patchwork-Id: 728094 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C24F7E7735F for ; Sat, 30 Sep 2023 08:19:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EE7A3EE5; Sat, 30 Sep 2023 10:18:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EE7A3EE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1696061981; bh=/GwX/IkN80mi4PpljxKW5l9Dof5tKihlq6EzA1EAC6k=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=fae1w37VwAaKfPXDPwLXYwwDn94uAsGEDku//LtUwpkGAf8ZczucV/ftfYEXXiFl/ K1KEwHGY+FC6MT8gu+X6dJGCSD8G7fBWyTTyrQTx+Gtqwyqk9LcINBk1e+BjdKJsDh 6F4grUhcYnrJSHQylZx2YzqUj18G7YCOrK4XkV5U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id EFB1DF806A6; Sat, 30 Sep 2023 10:13:10 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id F16D2F805C9; Sat, 30 Sep 2023 10:13:09 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 31C94F801D5; Fri, 29 Sep 2023 17:08:40 +0200 (CEST) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 228FFF800AE for ; Fri, 29 Sep 2023 17:08:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 228FFF800AE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=YM5GkEUy Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-406618d0991so3638205e9.2 for ; Fri, 29 Sep 2023 08:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696000095; x=1696604895; darn=alsa-project.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bR9UWtC1p3mwpIBD1ghImSIQPLTYUb8nPcgzl1u2x8Q=; b=YM5GkEUyAav8TWCDVN8d5q1XGW9cj0frItqnKufcf2w4d+gjJ08Q7jgvwjGMxSFkaT 6FtVEseiEVt76S80P2tfyN27tWK47afPRHtlt1gdNbQiV9hydczxXmvdqRuQG8SdiyTt P0hVeVV5ye/jnREnaUgsdVilp9ycpCCMuUqYfQTOJUbPjwYdci6D2uObm3cuPMjUi51b SKQuFe/4zetIzgV9k3thmq7uvCM/75EyZJ2cpZNXHrP8QolQ19sFzoScll6XpHmkidBQ Jkb6l+LfsExNZ/qj4L65F+UEmAvAsxn8Ug4EaeJ9WsCx3AJZ8OvJbUUkEKkUJZVqSo/y 9zlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000095; x=1696604895; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bR9UWtC1p3mwpIBD1ghImSIQPLTYUb8nPcgzl1u2x8Q=; b=mW3YYXcJJyTjW5zYdwAL3ZgNITua2DGuFBnTfL2q/+NS1+rhJ7OonkGdIgYTEkLU9y M0cevz3w7AANwUsxcuFuSGAYteF7BIsiJgy4xVYjt6U0NV7c7RPYY2vKEj7K0V9yytYr OJILqgomPFQdDk6KWWkY2ooZ+USclmRHU5ri039gpT8NcMpVy+jcdVd13PS2LCOKMfjA ZHS7Z4+gzoYxgjKUs/5c3mMwikEMtgQGEEewcqZW/9CJElKl2KHxEyeXAHrQcDbQNwuM PRYmcI9KEglRIxM4pEoeEUXYFOdcwS9He19EBhkAk8Sy1NSTW7p06jDKf+k+yD0TUsWw KbGg== X-Gm-Message-State: AOJu0YxsxXw1lP6lJgE7XL3wYX4gQODRibWeANWaK2xbPG4tuTNPol/M IUrXEyByFpHh2bdxPSl8DDU= X-Google-Smtp-Source: AGHT+IGHK+tbzpz8K/qw9KIsSxKt/JNBH2C6H1p5LbfKX/BA3YkbegQF5r7zhKiQCMdMtufOfJ1HxQ== X-Received: by 2002:a05:600c:220d:b0:405:3455:567e with SMTP id z13-20020a05600c220d00b004053455567emr3898215wml.5.1696000094652; Fri, 29 Sep 2023 08:08:14 -0700 (PDT) Received: from localhost ([2a02:810d:1640:10d8:9259:8ee2:26ea:3669]) by smtp.gmail.com with ESMTPSA id r1-20020a05600c298100b0040586360a36sm1618613wmd.17.2023.09.29.08.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:08:14 -0700 (PDT) From: Joerg Schambacher To: Cc: a-krasser@ti.com, joerg@hifiberry.com, Joerg Schambacher , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Zhang Qilong , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] ASoC: Adds support for TAS575x to the pcm512x driver Date: Fri, 29 Sep 2023 17:07:20 +0200 Message-Id: <20230929150722.405415-1-joerg.hifiberry@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-MailFrom: joerg.hifiberry@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: LTE7WLILRWSVQK4KDFT3WKULPEVJSJNA X-Message-ID-Hash: LTE7WLILRWSVQK4KDFT3WKULPEVJSJNA X-Mailman-Approved-At: Sat, 30 Sep 2023 08:12:53 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: <> List-Archive: <> List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Enables the existing pcm512x driver to control the almost compatible TAS5754 and -76 amplifers. Both amplifiers support only an I2C interface and the internal PLL must be always on to provide necessary clocks to the amplifier section. Tested on TAS5756 with support from Andreas Arbesser-Krasser from Texas Instruments Signed-off-by: Joerg Schambacher --- sound/soc/codecs/pcm512x-i2c.c | 4 ++++ sound/soc/codecs/pcm512x.c | 36 +++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/pcm512x-i2c.c b/sound/soc/codecs/pcm512x-i2c.c index 5cd2b64b9337..4be476a280e1 100644 --- a/sound/soc/codecs/pcm512x-i2c.c +++ b/sound/soc/codecs/pcm512x-i2c.c @@ -39,6 +39,8 @@ static const struct i2c_device_id pcm512x_i2c_id[] = { { "pcm5122", }, { "pcm5141", }, { "pcm5142", }, + { "tas5754", }, + { "tas5756", }, { } }; MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id); @@ -49,6 +51,8 @@ static const struct of_device_id pcm512x_of_match[] = { { .compatible = "ti,pcm5122", }, { .compatible = "ti,pcm5141", }, { .compatible = "ti,pcm5142", }, + { .compatible = "ti,tas5754", }, + { .compatible = "ti,tas5756", }, { } }; MODULE_DEVICE_TABLE(of, pcm512x_of_match); diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 89059a673cf0..aa8edf87b743 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -48,6 +48,7 @@ struct pcm512x_priv { int mute; struct mutex mutex; unsigned int bclk_ratio; + int force_pll_on; }; /* @@ -1258,10 +1259,34 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return ret; } - ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, - PCM512x_PLLE, 0); + if (!pcm512x->force_pll_on) { + ret = regmap_update_bits(pcm512x->regmap, + PCM512x_PLL_EN, PCM512x_PLLE, 0); + } else { + /* provide minimum PLL config for TAS575x clocking + * and leave PLL enabled + */ + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_0, 0x01); + if (ret != 0) { + dev_err(component->dev, + "Failed to set pll coefficient: %d\n", ret); + return ret; + } + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_COEFF_1, 0x04); + if (ret != 0) { + dev_err(component->dev, + "Failed to set pll coefficient: %d\n", ret); + return ret; + } + ret = regmap_write(pcm512x->regmap, + PCM512x_PLL_EN, 0x01); + dev_dbg(component->dev, "Enabling PLL for TAS575x\n"); + } + if (ret != 0) { - dev_err(component->dev, "Failed to disable pll: %d\n", ret); + dev_err(component->dev, "Failed to set pll mode: %d\n", ret); return ret; } } @@ -1659,6 +1684,11 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) ret = -EINVAL; goto err_pm; } + + if (!strcmp(np->name, "tas5756") || + !strcmp(np->name, "tas5754")) + pcm512x->force_pll_on = 1; + dev_dbg(dev, "Device ID: %s\n", np->name); } #endif