Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2434865ybb; Mon, 30 Mar 2020 06:08:51 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu6e1YBQdc/sGxozlvr8FGo6DK0fUgv1R/uXodFwjrd/C5k+Ya1Rsd6XDPTl9xfQTBy3JlS X-Received: by 2002:aca:5345:: with SMTP id h66mr7677764oib.110.1585573731631; Mon, 30 Mar 2020 06:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585573731; cv=none; d=google.com; s=arc-20160816; b=C8tV6MqR8ikbk4erySs4CIsqlgjPT+58AUwsC/pRiOtvxZW7CSoImMEsFAytWNnYTj qL73lvkY5A9PLukbWzgOn+VUt/06v7gBclYZscxwQJg52VnjjNrhu19HdU0otIWxCkc5 nNG1/F/HGdqlKacb5qdulSgCxpPN6eloLV+32u7lMsX16/1zNJMEmbgUHfm9l8HnshZg 078CYB7V/b+z+V6+FSGRKJfGHan6GBHNgvCOy4oQ3X5JPNkGuDTy/xc6jF2mgI9u71x1 tLyH91O16N9a4hyVXy5gYvLadQTi7XC4dsucN6Sdg9i0zkpqpz9r7ZEQsF+Hw7PTTHUQ Qjnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UPlLyojeCluLgFP08/bKunqvjY3lVGNaJQ1Ua3ag9cw=; b=uL2ooGqiJbB1VpBwen5kq8mfb4JaJNkybYZux8U0qbqy8L/y9ataYzf0prEP8VOzIt G9NhhEnnfOf1NOdDGn9C9vYJ8sUElLqzRob3QarCI4QkNiN+XQ1Uq1s9AaNcAXjsin3P ORkoP9y2dRsxp4saY0dNXgBGFqy1/gAN2YWrT+24pYQA51pyrECNu684yyulL3/ykYBU GkHg9L/uBnzBm2hejtMp5zD5VBr1BiGRKiHCcRXPC8Eus8kOmBKq3lcYGrMUYOldaDtg 2CF6406sXEP7ZPVExYG6eRZAPz5LFvatUQKL7b956BZFwPZ3U8lIDOCpKgeZA6/UyGhf 3XSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=prR33xBA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si5605648oiw.205.2020.03.30.06.08.35; Mon, 30 Mar 2020 06:08:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=prR33xBA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730185AbgC3NHc (ORCPT + 99 others); Mon, 30 Mar 2020 09:07:32 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43949 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729985AbgC3NHc (ORCPT ); Mon, 30 Mar 2020 09:07:32 -0400 Received: by mail-wr1-f65.google.com with SMTP id m11so15651638wrx.10; Mon, 30 Mar 2020 06:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UPlLyojeCluLgFP08/bKunqvjY3lVGNaJQ1Ua3ag9cw=; b=prR33xBATk6NpwOfAC3/IZqOL2a+HH3eEu9jQBtH4zcO4EhwGkMhtpx/p6/PoeQDxo PGK2xDWuAbfq04P6ST7lTC4yBdRkL9Mel0FMxHRNPCHEuuUv9uepB3e7ozDAQfsa0jCu 9meZ2dPUeT+dXD/NkkslhBbL6C1FofAy/W/i7By/wfHDRyucjxtoiKaQQVhIvfgGAyu2 jYkuxAdEtOW91bdh2V3yiGqIr+crkjIFxNw8oZg5nJSrpsLbmOSuhdX6X/yIf6iNQIXT lSEJ6+S6iy5SAaBnJfJg2bYNqkEo3Jn5uhw871GuuWy+cJjpYa/t0VI+1p30vWDGN8Q1 kJQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UPlLyojeCluLgFP08/bKunqvjY3lVGNaJQ1Ua3ag9cw=; b=uHmtvR0p6OPcM/zEgaw3TJv7BvELx3VvRdEWbIYE41JvZ+a5QU0+LKu+nYBM6D+sn0 iphYHrrMHRwQOlL9puhUK9OHH5ftDOkpM16Z71WhzznOJW28Ccvl0Lbmn/avzlAcig5h mbmceoBOVAevsE8hDv2JUU9Tvh7OLDcYo89BR1wG9yQRQlxhVoix/wPm0yazEHaWjkTZ 3lxMG4A12lV0Jc6J2nCr/Pen4i35Xq8QsXnTlQCiEn4BC87kMIL7SBvVpTSWTF/a6wAZ zfOwqlCyinzHIX1EFsexIeMGVdwxAL/I+QJk0DZ4Yerp0rFI0HEaGe6NtNYbjlZCZA3T /qtQ== X-Gm-Message-State: ANhLgQ068zdmcbmr7sH73+46EsnA6y1P2jdb0hYoPfTcDstAZnvmktBu v2Zu+CV7KKQY9Z7cp3y7ZpE= X-Received: by 2002:a5d:46ca:: with SMTP id g10mr14417792wrs.290.1585573647614; Mon, 30 Mar 2020 06:07:27 -0700 (PDT) Received: from localhost (pD9E51CDC.dip0.t-ipconnect.de. [217.229.28.220]) by smtp.gmail.com with ESMTPSA id a192sm22485545wme.5.2020.03.30.06.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 06:07:26 -0700 (PDT) Date: Mon, 30 Mar 2020 15:07:24 +0200 From: Thierry Reding To: Matthias Schiffer Cc: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: (EXT) Re: [PATCH 3/4] pwm: pca9685: initialize all LED registers during probe Message-ID: <20200330130724.GA2431644@ulmo> References: <20200226135229.24929-1-matthias.schiffer@ew.tq-group.com> <20200226135229.24929-3-matthias.schiffer@ew.tq-group.com> <20200226150051.sbopz7uzbdhtccba@pengutronix.de> <74522773dd3e820ab6f38cd83e52c83f1288c04a.camel@ew.tq-group.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline In-Reply-To: <74522773dd3e820ab6f38cd83e52c83f1288c04a.camel@ew.tq-group.com> User-Agent: Mutt/1.13.1 (2019-12-14) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 26, 2020 at 05:13:51PM +0100, Matthias Schiffer wrote: > On Wed, 2020-02-26 at 16:00 +0100, Uwe Kleine-K=C3=B6nig wrote: > > On Wed, Feb 26, 2020 at 02:52:28PM +0100, Matthias Schiffer wrote: > > > Initialize all ON delays to 0 during probe, rather than doing it in > > > pca9685_pwm_enable. > > >=20 > > > Signed-off-by: Matthias Schiffer > > > > > > --- > > > drivers/pwm/pwm-pca9685.c | 14 +++++++------- > > > 1 file changed, 7 insertions(+), 7 deletions(-) > > >=20 > > > diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c > > > index 393ab92aa945..370691b21107 100644 > > > --- a/drivers/pwm/pwm-pca9685.c > > > +++ b/drivers/pwm/pwm-pca9685.c > > > @@ -289,13 +289,6 @@ static int pca9685_pwm_enable(struct pwm_chip > > > *chip, struct pwm_device *pwm) > > > { > > > struct pca9685 *pca =3D to_pca(chip); > > > =20 > > > - /* > > > - * The PWM subsystem does not support a pre-delay. > > > - * So, set the ON-timeout to 0 > > > - */ > > > - regmap_write(pca->regmap, LED_N_ON_L(pwm->hwpwm), 0); > > > - regmap_write(pca->regmap, LED_N_ON_H(pwm->hwpwm), 0); > > > - > > > /* > > > * Clear the full-off bit. > > > * It has precedence over the others and must be off. > > > @@ -388,6 +381,13 @@ static int pca9685_pwm_probe(struct i2c_client > > > *client, > > > regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_L, 0); > > > regmap_write(pca->regmap, PCA9685_ALL_LED_OFF_H, 0); > > > =20 > > > + /* > > > + * The PWM subsystem does not support a pre-delay. > > > + * So, set the ON-timeout to 0 > > > + */ > > > + regmap_write(pca->regmap, PCA9685_ALL_LED_ON_H, 0); > > > + regmap_write(pca->regmap, PCA9685_ALL_LED_ON_L, 0); > > > + > >=20 > > What is a pre-delay: Something like: > > _________ ______ > > _____/ \_________________/ > > ^ ^ > >=20 > > Where ^ marks the period start and then the time between period start > > and the rising signal is the pre-delay? > >=20 > > If so, the IMHO more right approach is to keep the pre-delay until a > > new > > setting is applied and in .get_state ignore the pre-delay. This way > > you > > don't modify the output in .probe() which sounds right. > >=20 >=20 > My approach was to get the hardware into a known state by resetting > most registers (which is what the driver attempted to do so far). If > getting the hardware state via get_state is preferable, I can implement > that instead. I think what Uwe was suggesting was to delay setting these registers until the PWM is actually used. We typically do that in order not to mess with whatever the bootloader may have set up. Consider for example the case where the PWM is used to drive a backlight, which might be showing a splash screen. If you reinitialize the PWM at probe time, the backlight might go dark some time before the kernel gets around to initializing the backlight. For now I think we should just leave this where it is because likely a change in PWM will be followed by a pwm_enable() call with the legacy API. Ideally this driver would be converted to the new atomic PWM API, in which case it'd be best to write the entirety of the hardware registers during ->apply(). Thierry --tKW2IUtsqtDRztdT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAl6B7woACgkQ3SOs138+ s6E1pBAAnG+N21eVrYOAi4fg+13x0D6CzUhyDs2ieFfER1TzR1e7GRA7uwtBEd76 kv21RsKUKUcjunPihaAGnHMI1GWF8cm3AXU4ss2ChWZ1re6uCYKdp2RLJHmHDvM3 KKi7Lsmq36XGCpwEzBhHq9qUYVRlimS+Sy9T+XwFxwU+6SMvCpGA2mgQNQTbh/t8 FZwngg0GFFmaULN1lrdSIjcq4uEaSXOpIRiYIBV1bCV97GQLNRGjcbuzzWIiE2l6 qvqYVVW4cJ6e/Kk9qoCHW4toBVGiQXlXzUwUMPJAtSvWvg1t+f9vxl6b7xz6DkdX 8C94dcf8ag612TNoQVaY9MrEpOU53039bgZTugZSqE4i5hM85wEPlhZmFjJbV5V1 Lv04CAnkeGhUSkgolQK2yFfrhS2UJvaYFC9BnOQakSaje/44SI7ywYCNScQ3pMc0 Mp87A1HkM/4h4dbNhp4lmM5ghyTQbIYbz3h+G/nhaBWW2qOOiXne6jgPdniQKdTS u0R9UEVBhl5me7Fk/9PMWcxxXFjKA+z14INDubRjZmBAjLqWtmBWRb2YfCPq9QAI 9YF68GSoFJp/R83qEv+yOEt1QDvkvzH72MBdHfOaAocu+k+raZl1vEVv+tS3nq+b ouTb2q8TFZCQdiHqTZ8NGfkgogrCeRyLawRdSkEQbZLZoH8u0Z4= =fw4R -----END PGP SIGNATURE----- --tKW2IUtsqtDRztdT--