Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp860299rwe; Fri, 14 Apr 2023 10:36:14 -0700 (PDT) X-Google-Smtp-Source: AKy350ZH2SUGO0xcWEV7qMW8qxtNBWWwyqwmZXC4tw07SbFffMPARPWDm6guCiZ4emCSisosgVoO X-Received: by 2002:a05:6a20:1589:b0:ec:c8c2:36b7 with SMTP id h9-20020a056a20158900b000ecc8c236b7mr5306527pzj.14.1681493773864; Fri, 14 Apr 2023 10:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681493773; cv=none; d=google.com; s=arc-20160816; b=b6sdftLKAEuNHjactbx1BDBNNfMVSQaROYDUA0xk0JXEn5aTqbQcCse/305rNURU7m Xb8EX7vZRACXF3BIyZQp3/+rfRtBNsZWTTUb2jw+2g8mkGJ9JSkQeaeMERrtmIJla53R qug8mWjcUhtwn+uMC7bmn3HNOWMF0FbQEmzXTTLlz+iIICcMR3/b2CJDO0tOGnPl03WE bG3m8axjxAUUOQKQ2AvH83TsG3s12EWybSskGESnDafxA/NGEKvCmbfWoUG5P20X1B4h SDNGHNROLlWsXm5Spw2sw6+HmaKgkt2RRh1cPkDiSaTaREqLiTZNGU3syE3UeLlYC/aC XqFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sQEAD42COl3t3IqepvnLTgRCYVNG0C1kmzsrrnnd5kU=; b=fxB3/Z/RuoM3DZ3JDi4b6MiyD08dnPAO4+Dq+DLeUPVa3u/BGNHGkEJA55xkgs1XSr Rxf5meJ2BvU7mb0MwHG932Y1Th9pRw8SaOZqyDFSOS8Ph9+nhonCETrV+zkaVyxc8Ets /51L9Y8+glIM/KS+xmN5UxloIHCwPMzY/+vDxsMZ2KjNbhNrTOpOjbS2BaSz/cTMdsu4 3B/GwY5m74L+AfJYQHHGbxL2jXt3c9KHaCgJ+FxPA7/JVtTir1VItJp75DcAioGo70iU rpW3e3LeCPysJRA5fNBZJpol3AHr3Hf/4DV71jr3aZNT5ajUMSIxPzyXXIpKFkkokauW QKFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FHyrqHeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a63e113000000b0051b85b5a3d1si304546pgh.127.2023.04.14.10.36.00; Fri, 14 Apr 2023 10:36:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FHyrqHeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbjDNRfb (ORCPT + 99 others); Fri, 14 Apr 2023 13:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjDNRf3 (ORCPT ); Fri, 14 Apr 2023 13:35:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A17F355AB; Fri, 14 Apr 2023 10:35:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3C35F6497A; Fri, 14 Apr 2023 17:35:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD973C433EF; Fri, 14 Apr 2023 17:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681493724; bh=PdlPchlBqq3ipIe1/5avWeUUYeo8hYM1C6FOgpJVePE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FHyrqHeYFDR408+DVbywqdFdI5GZKpRRQe+rslBVGoCMgTxqF+CAtyTC9jcAKomNz PfFasrHSeJp341AxUycZArVFXHXCW5TKn0Xb7ZilD+q0ehTk+irIq11PYbUZ9zGrLp 6ThJGCgMv0RNeESv03yDmCQkKpWF5K+DteXEi1L5vP5NsKJD66qxtdJMwmyuIzqsPm QOlGK2hVNdQjwc0VTI3v9X5qNkB/wJe46FODMI+uKTk2DaWJWNqm7N7Ku5hkZzfgUm hHItTYOL1nkJ/zA7/RHzNc0O/EnkLC5HZIV0/fiT8fJce/ObiPD6Z1SxOrlqOjQIoa mQtJQBmKqECTg== Date: Fri, 14 Apr 2023 18:35:18 +0100 From: Mark Brown To: =?utf-8?B?UGF3ZcWC?= Anikiel Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com Subject: Re: [PATCH 5/9] ASoC: ssm2602: Add workaround for playback with external MCLK Message-ID: References: <20230414140203.707729-1-pan@semihalf.com> <20230414140203.707729-6-pan@semihalf.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EH6yRfJ9i6hhIpAh" Content-Disposition: inline In-Reply-To: <20230414140203.707729-6-pan@semihalf.com> X-Cookie: One Bell System - it works. X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EH6yRfJ9i6hhIpAh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 14, 2023 at 04:01:59PM +0200, Pawe=C5=82 Anikiel wrote: > Apply a workaround for what seems to be a hardware quirk: when using > an external MCLK signal, powering on Output and DAC for the first time > produces output distortions unless they're powered together with whole > chip power. This doesn't seem coherent, these are multiple register writes so clearly can't be done at the same moment as initial power on. Clearly there's some other constraint here. > The workaround powers them on in probe for the first time, as doing it > later may be impossible (e.g. when starting playback while recording, > whole chip power will already be on). It doesn't do that, it powers them on at component probe. > Here are some sequences run at the very start before a sw reset (and > later using one of the NOT OK sequences from above): >=20 > ssmset 0x09 0x01 # core > ssmset 0x06 0x07 # chip, out, dac > OK I can't tell what any of this is trying to say, especially given all the magic numbers, and obviously no actual use of the driver should be writing directly to the register map. > + /* Workaround for what seems to be a hardware quirk: when using an > + * external MCLK signal, powering on Output and DAC for the first > + * time produces output distortions unless they're powered together > + * with whole chip power. We power them here for the first time, > + * as doing it later may be impossible (e.g. when starting playback > + * while recording, whole chip power will already be on) > + */ > + regmap_write(ssm2602->regmap, SSM2602_ACTIVE, 0x01); > + regmap_write(ssm2602->regmap, SSM2602_PWR, 0x07); > + regmap_write(ssm2602->regmap, SSM2602_RESET, 0x00); > + The rest of the driver uses symbolic names for register values, this code should too. =20 This also seems buggy in that it writes non-default values to the hardware then does a reset, meaning that the cache and hardware values will be out of sync, and since it only happens on probe there will be an issue after suspend if power is removed. It looks like this would be most comfortably implemented as a register patch applied as soon as the regmap is instantiated. See regmap_register_patch(). --EH6yRfJ9i6hhIpAh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmQ5jtUACgkQJNaLcl1U h9Ajkwf+ODUCBkDtTHlEW7Kmhees6SWhoER3fk+u//I4yyeodw2AopWmhSQaUs0m k5/cPXokWbQaCDic+hod7YejaAtDGHj3lDH9s4CAsE9SRtuYV1SCL8N94LN6ZETG /3MlDr+ScZ+ga+8OsSQVvGMfYZlSuRlTiUJmocRWO5dJ/thyDzh/89QdgGfQt0eo g6asIK+pLjG4N7Pl20E/bAG5sG1AHGkYiAxOLVD6vsXzcBZT+GoI5xYxD2rleRNi cAN5Og3SghfLXhZNQeDBZ4/7mjCF/AwymoAsPuYwQRkWeWdZh29gOhPqSUD/Mzss EtMguFBBN3y1NPRsMRBqzvmFV4TkcQ== =zZC1 -----END PGP SIGNATURE----- --EH6yRfJ9i6hhIpAh--