Received: by 10.192.165.148 with SMTP id m20csp3522434imm; Mon, 30 Apr 2018 01:29:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKyFVP/G/ucAXL8hR/p5UhNb0yi8XmwsAUFzXW+pxC+IykZ7Mv0jvhFfzbc1eYZ/rt1ZZd X-Received: by 2002:a63:887:: with SMTP id 129-v6mr9251227pgi.17.1525076967115; Mon, 30 Apr 2018 01:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525076967; cv=none; d=google.com; s=arc-20160816; b=XKDLEoxitr6AWmzM2ChkpX1zlfzmxVrGh3m4ttFyJjkQZbJmWQdRAeho/Et9zjFiMe TZuT8nosq9lgSiS2WOLsvvAP81r5BOrO9vTc0IA2L8yMNogfjzxI2b3DyvPZm8tcssK1 80Z3AI8sWzZkI1G/eeYlWO5/J45jyNsiA1IIYnV7UzttHELCeMas748ZcDmoDUOM72ZK SkA1ZhkkqVz+FHyBqrVozFN2g4jRwCiPj8x2jJHtCg/2P5L0sjWJZX7fYISpyFn8iOKP DdWWrC8deKkTB22ANbz5dlBFcNfbsZTQa75iR8fXKRiXFrPJElDen+c0Sgrs6bTKvOlw 1NvA== 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:arc-authentication-results; bh=3YL/QZjUMnvQL+FWdR5P81t8Bb59rNBbbrdNOEUKLgI=; b=D4Y9Z0hpxpKNmUh8VvdQHqeCCkJSXSbfu5amvgHkXA0HUE/D6Jz6UJABKg41SMKTLt oe/sKsIEXmkSDXzP2nBMLhOg/xiQOL4uzJVckX6p8DT0ZkmRGD/TxG5zmkUs2OryCV/+ A24gYrwmsuj1KWHMZP47izerkzTPWKpf5/QJ/J2FiSle54gU12H0KLORSCOTlI2bJwtF 4vaDBgAWe75qCaZ3D961oUJQWVLet0V8wIKaggeGxc9tzfdnMZJNsbeZAXnOxtC6eMXn ziFyoi7EZ6Rgwu4QojopSTe8LbBOBXhE+JFz/RBd5RWQcTthwo/CfQ065hXQPS8+Y0cH HSUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=G1Vh8zka; 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 q127-v6si5868506pga.71.2018.04.30.01.29.13; Mon, 30 Apr 2018 01:29:27 -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=G1Vh8zka; 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 S1752799AbeD3I2L (ORCPT + 99 others); Mon, 30 Apr 2018 04:28:11 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:39630 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752354AbeD3I1x (ORCPT ); Mon, 30 Apr 2018 04:27:53 -0400 Received: by mail-wm0-f51.google.com with SMTP id f8so2327108wmc.4; Mon, 30 Apr 2018 01:27:52 -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=3YL/QZjUMnvQL+FWdR5P81t8Bb59rNBbbrdNOEUKLgI=; b=G1Vh8zkaOgd4uC7dRPhR3c+YfnqdgePxmGegXwIcs8Rrw3rs7DqaTC5IuptM32QKQW sSGq/VFrSM1bDQ2XWNTwzdu0ds01Lp8X+j9bq5XwDyTTbko79tD9HbYji/3VOdq5zkxg gB55TMgC+H8KOpyc5jDvaMbJoY5nZ4txoGMLqaHiTZlQfNMzxiI2Ayr2O2vt65cVNIxp 5gYQW1xkEpJzooZl9Jidw8J9FGItp4w+Vrrgt0651EkOpRoDoIRVrEyJkl9RXpc2U1sh IYXPqKpf81s8fxHZ79gewNjXwoovryusVyWyUCYPM0T57ysqN2mI0bi3Bjlo8PNw4kN3 jPRw== 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=3YL/QZjUMnvQL+FWdR5P81t8Bb59rNBbbrdNOEUKLgI=; b=nK8K5oEEYcOfxNxjRuDCa+hmX7rk1HaKBZ9B6tXeoXwfAtIR1V3ZQHLwIBz2bw9+Ic q3SJh49FklXzeg94XU7avLgeYlqQatpw1s8+XQznUI3Ohe/oeGJHDsgzumeAeF6jmK7w TQZATKJodMrD1UbAYHvJps3oJmAdYG0JyA+7Q/VHSiWbDmiTJGoVzgiJANu1p9uaiE2P 2yFhLnz6EI77X0fObfAPEDfgUYMypvtY8yRNnZdSauodce+ZlXctjcw9iho/ufemJRxK SV8yfYOTWMS1MW2grWww0aiglSp4pGWvFy6+sQXP2hX9u+ZD2d9daCzTC8idRsPp+Kar Hz2g== X-Gm-Message-State: ALQs6tCYpYerRN1I+WjYE0nQIWVyu0KLQQWfRY6S/Xgr22gBkLCxamz8 9MtB/HuPu6Zs54Rn74Soyzg= X-Received: by 10.28.137.131 with SMTP id l125mr6396775wmd.30.1525076872193; Mon, 30 Apr 2018 01:27:52 -0700 (PDT) Received: from localhost (p200300E41F041C0032947E635CB49D15.dip0.t-ipconnect.de. [2003:e4:1f04:1c00:3294:7e63:5cb4:9d15]) by smtp.gmail.com with ESMTPSA id n23-v6sm7707007wra.39.2018.04.30.01.27.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Apr 2018 01:27:51 -0700 (PDT) Date: Mon, 30 Apr 2018 10:27:50 +0200 From: Thierry Reding To: Wesley Terpstra , Rob Herring Cc: Mark Rutland , Andreas =?utf-8?Q?F=C3=A4rber?= , Noralf =?utf-8?Q?Tr=C3=B8nnes?= , David Lechner , Alexandre Belloni , SZ Lin , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] dt-bindings: added new pwm-sifive driver documentation Message-ID: <20180430082750.GI2484@ulmo> References: <1524869998-2805-1-git-send-email-wesley@sifive.com> <1524869998-2805-2-git-send-email-wesley@sifive.com> <20180429055417.GA10221@mithrandir> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QDIl5R72YNOeCxaP" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --QDIl5R72YNOeCxaP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 29, 2018 at 01:51:34PM -0700, Wesley Terpstra wrote: > On Sat, Apr 28, 2018 at 10:54 PM, Thierry Reding > wrote: > > On Fri, Apr 27, 2018 at 03:59:56PM -0700, Wesley W. Terpstra wrote: > >> +Unlike most other PWM controllers, the SiFive PWM controller currentl= y only > >> +supports one period for all channels in the PWM. This is set globally= in DTS. > >> +The period also has significant restrictions on the values it can ach= ieve, > >> +which the driver rounds to the nearest achievable frequency. > > > > How about you encode this in the driver rather than DT? We have several > > drivers with similar restrictions and they usually allow the first PWM > > channel to choose an arbitrary period and return an error if subsequent > > channels request a period that can't be supported. > > > > I think something similar could work with that second restriction. Why > > not return an error if the exact period can't be set? Or perhaps allow > > some percentage of deviation. >=20 > Interesting. There are two ways to use this PWM. In one mode you use > all channels of the PWM as outputs. This is the mode the driver > supports because the HiFive Unleashed board uses all channels > connected to LEDs. >=20 > In this case, the PWM period must always be a power-of-two reduction > from the core bus clock frequency. The core bus clock frequency can > vary. Therefore, even if the caller's frequency can be achieved at the > time of the method call, it may not remain achievable. You might say > this is a ridiculous PWM design, and I'd agree with you, but sadly > this is what is found in these chips. So effectively, the only thing > we can guarantee is that the period is within a multiple of sqrt(2) > from the requested period, except even that is not true due to > saturation restrictions that could push the period even further from > what you ask. >=20 > In the other mode (where you sacrifice one of the output channels), > you have finer control of the period, but it still affects all > channels. This mode might be a better fit for your proposed API, > except that the driver would still be subject to saturation > restrictions on the period. And those restrictions will change as the > core bus frequency is changed, which means that again, even if your > target period can be achieved (common to all channels) at invocation, > it might not be achievable later. >=20 > IMO the only real control this PWM can offer reliably is the duty > cycle, which is why I've written it how I have. >=20 > If you see a better solution to the above problems, I am open to > suggestions. I don't like the idea of specifying something in DT that is completely approximate because it doesn't give users any kind of control over what is considered acceptable. In some cases an approximation to within 10% might be acceptable, in other cases users may only want to allow 5%. In this case there's even no way to catch or report a deviation from the desired value. How about you allow users to specify a valid frequency range with something like: frequency-range =3D ; or period-range =3D ; That would on one hand give users a way of specifying the valid range of frequencies and give your driver enough data to reject a change if it'd result in a frequency outside of the configured range. You would also have the possibility to react if a change in core bus clock frequency causes the PWM period to go out of range. I wonder if there's a mechanism that allows the clock change to be prevented (via a PRE_CHANGE notifier perhaps?), but if not at least you could disable the PWM if it was fed with an invalid range. Rob, any additional thoughts from you on this matter? Thierry --QDIl5R72YNOeCxaP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlrm04YACgkQ3SOs138+ s6HPNA/9Hck9+p2yppeTRjfr1CJ+Vy9PtFuxpAezhLRtzn0PWS65loEjwkTah9Qe azYrsnHpRUNwr3B/IuxhZ3jqh93wd7wILV9bgLlYYc9iZ/Q1Ki7A/YT+FLvtEyjv hg/aRzefPbjhDPqt3TsBt/by8eu7KNeAHheCd3pFGkZ9Hz0cWN9Z/HimknlvIAKg myES7vJQjYm4g6k/YmKhfxI875HAMAvINaC09obsr3piFRloBb0odJ3YX4Wt913I 0kMn+qwZv2iChvZzVKkcoqSrXoWwyvvuRVEFYw0BrChwjOhyTefvsyD9/rsppTdv mf25wHBSAIMC54Q2FgNBWpCkhFuAw3xMToOUt2rKyD13V6TxSZJe4cLoiQ53kNy/ bQ08alp16PEffHF/68K8slEI47t+dsZFmT2qll+OuAm85ntzNuc5w8y+LuG6hBjb a3HlhkXD1k6WliU0GYb96xdRgwPkbhs9cpyup9SOQFZfjfInDpeRHGG+vwejZOBl PuncyY/asviz2UkK7zS5IIkjAOgkS+TCyw+99/lgS2pECrubQ8TUgoSEg8tkqQDl zFlJAt48BSvPKZHcJYEVNtOGQ5qeIw+Ns0G75OzXX7VO8jGHH5zI3se8fLcNrHWK Irc2FCRc6NEh8AmjY8EL6lOrQ4xHDk3d4p4XvzHH/fxPNZkSUI8= =e6AQ -----END PGP SIGNATURE----- --QDIl5R72YNOeCxaP--