Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp973294pxb; Tue, 17 Aug 2021 00:14:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygb1DqPIDQmrwnGUeJii6/QegkgcNbZ6O4LSds78DeW8F5gNc2AR8t4+STJHfkHnqhI/bj X-Received: by 2002:a5d:9855:: with SMTP id p21mr1874741ios.206.1629184458847; Tue, 17 Aug 2021 00:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629184458; cv=none; d=google.com; s=arc-20160816; b=1KerXaAXuvKxjR4vQNyquDostJKA92xtE8Bv1rk9qCboKRMC5vP09eGNu4pR2Wz5/3 qDt4tUt5Sd8Z5XFgs5YUkYka+f7ZpDACmSj1O11e3Ktx9+Z+f7/8DPHoswx8CVEPW9JI fswuf1f6/Fe7Z14rTq+RnsASI4PaH7ZedQCv0WtWCCkOXGIDOoGuYgh5emxdxfnM9Z+E vyVUgOTMHF6s30fjoVfzpxujNi4OTWS1TjbrY8M1cp/nayUqNoUhCGxphWnR79RRu2mJ Jxfj9B5RLIOHjJa8f2aPU6T8auGOppeSzoBh+ZAJU7/D56kTbZ5x6OGaA3TLcBT7wERe CWtQ== 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 :dkim-signature; bh=4/94n/KGPF1vmUxfP+ZmhtXHWFk9voOY4f3v9/jT4is=; b=MqMVLAEA4/QPLcpcAU4RuGbpuGjVlLUpvrljn+ePJRhP3U0pg7cPd47a3NqQcT97gj OJC1/8te1/idEEXDPAu3qhQSWFyFgDoL7R+BjEgowvdzGrsogFZ9o3rp+4aBcz3heh/6 efgtlpUlL47jcK2L/oahGNuEpLA6NOZmjwXLwyrndwXjMdF2ERg5mZn4zirnq/CDXJ+v xsNiZ2ZjIwE2pVv5+eKdos+DaTqzofPv/lRqz+F0HQoBFoMF8npMQtA7urEdlPpxpdRp eHlcjyNBtUK/KDFQ2hj9gxQHauYUs7H5G7iuYJfIthVCV6Wccn/lTaLD5PqRpS7agL/F QJ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b="uh/WT0kl"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="FW/xpWtM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k34si1577067jav.61.2021.08.17.00.14.06; Tue, 17 Aug 2021 00:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b="uh/WT0kl"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="FW/xpWtM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234695AbhHQHNE (ORCPT + 99 others); Tue, 17 Aug 2021 03:13:04 -0400 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]:56939 "EHLO wnew2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbhHQHNA (ORCPT ); Tue, 17 Aug 2021 03:13:00 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id 1EB592B008FF; Tue, 17 Aug 2021 03:12:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 17 Aug 2021 03:12:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=4/94n/KGPF1vmUxfP+ZmhtXHWFk 9voOY4f3v9/jT4is=; b=uh/WT0klq5f6AqZrCKiOYaWIVTyNbpINzrtrQWQrLOy zn9iPa50CPXgWfj9REM4+u/o6KZ05onXMh9T3ya3y2vnVLlx4S+4OhWCD1SN+2r6 5Y08YS8DbneXf1/LymasxgzXw9aaACgiTIGVMVaye5OBs2WMxK8vgiEY7b6Js9X2 rhc38CJMkhgIZruXfdMuLxyh8pJrpAjceQxgFFsEYAxXuZilQmOrcfX+9BVEhSrq aqQFGR6tzEQ58PX7Oim1BhRppUIrzGEMO5VRenPl6lPj2LSqIlmJ64xvH2gULD5t GYnrq6VN+RSIzJ1X5hedDfkwHoHrRnJoGqs3/LBWobg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=4/94n/ KGPF1vmUxfP+ZmhtXHWFk9voOY4f3v9/jT4is=; b=FW/xpWtMyCM+KWUn6W7Fxp uT9cvwaaAGJOdTyVTLjJRwrc78g6+U9CEIqmqh0pznc/DvKBTFROwK9Bf9AH05cw g/lM9H4gglFclCvsAMMWUB4HDsEqSCGaOX87fMpX/Fh4LWhlH/PVHACcM621Ox/L NgnTdO5E/nV1vWVGmg3sSg1VtePekVqxfLJiEGw1nhh5RBQhsocW1ax61Y1YjIf3 lN8vOJf56+xoKNIA59JNtyphd/B7eLavR+SNDkuogrN8nBnjpDb9FEVZVAjdq52u 8Jl2yk07dDQ6HEdhb7fjhKDMYwTayR7Jakw4eHaF+hrb9tEkvN5s7fqduPMD67ag == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrledvgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepuedtgfejueduheevgfevvdettdduleffgfffkeeltdffkeegudekjeeuveei gedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Aug 2021 03:12:22 -0400 (EDT) Date: Tue, 17 Aug 2021 09:12:20 +0200 From: Maxime Ripard To: =?utf-8?B?54+t5rab?= Cc: lgirdwood@gmail.com, Mark Brown , perex@perex.cz, tiwai@suse.com, wens@csie.org, jernej.skrabec@gmail.com, p.zabel@pengutronix.de, Samuel Holland , krzk@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v6 1/2] ASoC: sunxi: Add Allwinner H6 Digital MIC driver Message-ID: <20210817071220.idoxpwzbpemdjqdz@gilmour> References: <20210711122055.4529-1-fengzheng923@gmail.com> <20210715074750.ewbggulc5kast6ez@gilmour> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yncixzh4whlvhxud" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --yncixzh4whlvhxud Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sun, Aug 01, 2021 at 05:47:46PM +0800, =E7=8F=AD=E6=B6=9B wrote: > > > + /* DMIC num is N+1 */ > > > + regmap_update_bits(host->regmap, SUN50I_DMIC_CH_NUM, > > > + SUN50I_DMIC_CH_NUM_N_MASK, > > > + SUN50I_DMIC_CH_NUM_N(channels - 1)); > > > + host->chan_en =3D (1 << channels) - 1; > > > + regmap_write(host->regmap, SUN50I_DMIC_HPF_CTRL, host->chan_en); > > > > Do we need to store the channels bitmask in the main structure? It looks > > fairly easy to generate, so I guess we could just use a macro >=20 > I need to store channels bitmask and use it in sun50i_dmic_trigger functi= on. But you don't need it outside of hw_params. The channel setup is typically done in hw_params, not in the trigger hook. [...] > > > + /* Clocks */ > > > + host->bus_clk =3D devm_clk_get(&pdev->dev, "bus"); > > > + if (IS_ERR(host->bus_clk)) > > > + return dev_err_probe(&pdev->dev, PTR_ERR(host->bus_clk), > > > + "failed to get bus clock.\n"); > > > + > > > + host->dmic_clk =3D devm_clk_get(&pdev->dev, "mod"); > > > + if (IS_ERR(host->dmic_clk)) > > > + return dev_err_probe(&pdev->dev, PTR_ERR(host->dmic_clk= ), > > > + "failed to get dmic clock.\n"); > > > + > > > + host->dma_params_rx.addr =3D res->start + SUN50I_DMIC_DATA; > > > + host->dma_params_rx.maxburst =3D 8; > > > + > > > + platform_set_drvdata(pdev, host); > > > + > > > + host->rst =3D devm_reset_control_get_optional_exclusive(&pdev->= dev, NULL); > > > + if (IS_ERR(host->rst)) > > > + return dev_err_probe(&pdev->dev, PTR_ERR(host->rst), > > > + "Failed to get reset.\n"); > > > > Your binding states that the reset is mandatory so you don't need the > > optional variant. > > > > > + reset_control_deassert(host->rst); > > > > Can't this be moved to the runtime_pm hooks? >=20 > Is this necessary? I see that most of the driver files execute > reset_control_deassert in the probe function, and reset_control_assert > in the remove function. Your driver seems to not rely on the fact that the device remains powered between each run anyway, so yeah, that way you will completely power it down. > > > > > + ret =3D devm_snd_soc_register_component(&pdev->dev, > > > + &sun50i_dmic_component, &sun50i_dmic_da= i, 1); > > > > Your second line should be aligned on the opening parenthesis > > > > > + if (ret) > > > + return dev_err_probe(&pdev->dev, ret, > > > + "failed to register component.\n"); > > > + > > > + pm_runtime_enable(&pdev->dev); > > > + if (!pm_runtime_enabled(&pdev->dev)) { > > > + ret =3D sun50i_dmic_runtime_resume(&pdev->dev); > > > + if (ret) > > > + goto err_unregister; > > > + } > > > > We have a depends on PM on some drivers already, so I guess it would > > just make sense to add one more here instead of dealing with whether > > runtime_pm is compiled in or not. >=20 > I don't understand. I am referring to the sun4i-spdif.c file. Which > driver files should I refer to? That whole logic is there to enable the device is CONFIG_PM is not enabled (and thus the calls to pm_runtime_* won't do anything). Just add a depends on PM to your Kconfig entry, and call pm_runtime_enable there. Maxime --yncixzh4whlvhxud Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYRthVAAKCRDj7w1vZxhR xV5tAQDgo2PFfMG3oI+WJpwKhRvxyNOZwsTG3w/3ZeravzZx4AEA8cAL7Kk9k3li rT0wIeYDdfx6CDXMjnnGlqzr/0YvlAs= =VTo/ -----END PGP SIGNATURE----- --yncixzh4whlvhxud--