Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp372330pxj; Fri, 7 May 2021 10:25:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7YbdK5htZTl9BYhJrjFeSYd+Fe1eur3yysVFdPsOPNKeD4CTC71bVy0gA8PErj0GcII/N X-Received: by 2002:a65:530c:: with SMTP id m12mr11043662pgq.425.1620408312916; Fri, 07 May 2021 10:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620408312; cv=none; d=google.com; s=arc-20160816; b=Ro4QSARvVFQk1VsL3l49/kNhgH6WxFLEW1FmR/9ZkmYtkXB+PhnF5a2MXJSZNTbwOz DwDZW6hMAqF+NBXP7OgoUTCwtcXnxxMgQg0wqxJxZ7k3spp6HNRrv7sFq8jbwo8rnFcT wgeTp4EC+/fteZIAph0y0k0tftIwv70P3O5bkvW7p4SWt1zAVqjI5yC59chhvoLTGlFN kH6QvAsyDIEEnwkd438cSb3U98Grn/ANfNZmbqDB9Y/yn+pgerdyUZ34Tq52RKW7c2ZU SBo9ft5UyYhwtSe+u4f71L7WYUJ+pai12IE1fIfbdCkXbn3nUcsTiOiOfLP8l5GtUjf3 hA4g== 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; bh=TVWpsG3eV/oo9lcoI5bEku7yCaWYnngVXvDKCOAIwnw=; b=XCW8tsKpSOzX8cX+WzV1Rtcj99XsVWtxACyI6Tw3X/6ISTqCL9CBOXWXc8iRsMZtmf YE2daqEo35TpSTzI8Ee62oh+EqTFkRi5Rr1J/cbLZo+ffjPRGM/3qDTnD1/clKHSUS7B 7N7YNqsySKGn8XeAdCFZ7nk4d4VkkvPWEXr7y9V7wDwbpi/o9Ki3BoK9HwCUhT8928Y5 aqRgjAyUobwNr+uhlNIpDsXTV5ahHMYltKY6ipNl0z3vIsxElGPvRneJBXBWOIInPbd9 R6+gj/ga+uoRrwf44s8DFRoAp/TMdfdXIOdyHj/t3cSejkhnbde9GQxHQnKqSS6GBBwK CHkg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r64si8029262pfc.234.2021.05.07.10.25.00; Fri, 07 May 2021 10:25:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237745AbhEGPEf (ORCPT + 99 others); Fri, 7 May 2021 11:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237744AbhEGPEY (ORCPT ); Fri, 7 May 2021 11:04:24 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFB7C061574 for ; Fri, 7 May 2021 08:03:23 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lf20c-0000O7-MC; Fri, 07 May 2021 17:03:18 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1lf20b-0002zp-Vp; Fri, 07 May 2021 17:03:17 +0200 Date: Fri, 7 May 2021 17:03:17 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Clemens Gruber Cc: linux-pwm@vger.kernel.org, Thierry Reding , Sven Van Asbroeck , linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 1/4] pwm: core: Support new usage_power setting in PWM state Message-ID: <20210507150317.bnluhqrqepde4xjm@pengutronix.de> References: <20210507131845.37605-1-clemens.gruber@pqgruber.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="r5l7l24l74cfsloy" Content-Disposition: inline In-Reply-To: <20210507131845.37605-1-clemens.gruber@pqgruber.com> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --r5l7l24l74cfsloy Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Fri, May 07, 2021 at 03:18:42PM +0200, Clemens Gruber wrote: > diff --git a/include/linux/pwm.h b/include/linux/pwm.h > index 5bb90af4997e..5a73251d28e3 100644 > --- a/include/linux/pwm.h > +++ b/include/linux/pwm.h > @@ -54,12 +54,17 @@ enum { > * @duty_cycle: PWM duty cycle (in nanoseconds) > * @polarity: PWM polarity > * @enabled: PWM enabled status > + * @usage_power: If set, the PWM driver is only required to maintain the= power > + * output but has more freedom regarding signal form. > + * If supported, the signal can be optimized, for example = to > + * improve EMI by phase shifting individual channels. > */ > struct pwm_state { > u64 period; > u64 duty_cycle; > enum pwm_polarity polarity; > bool enabled; > + bool usage_power; > }; > =20 > /** If we really want to support this usecase, I would prefer to not have it in pwm_state because this concept is not a property of the wave form. So for a driver it doesn't really make sense to set this flag in =2Eget_state(). Maybe it makes more sense to put this in a separate argument for a variant of pwm_apply_state? something like: int pwm_apply_state_transition(struct pwm_device *pwm, const struct pwm_st= ate *state, const struct pwm_state_transition *transition); and pwm_state_transition can then contain something like this usage power concept and maybe also a sync flag that requests that the call should only return when the new setting is active and maybe also a complete_period flag that requests that the currently running period must be completed before the requested setting is implemented. OTOH the information "I only care about the relative duty cycle" is relevant longer than during the transition to a new setting. (So if there are two consumers and one specified to be only interested in the relative duty cycle, the other might be allowed to change the common period.) Having said that, I don't like the proposed names. Neither "usage_power" nor "pwm_apply_state_transition". In a non-representative survey among two hardware engineers and one software engineer who already contributed to PWM (!=3D me) I found out that these three have an intuitive right understanding of "allow-phase-shift" but have no idea what "usage-power" could mean. On a side note: The hardware guys noted that it might make sense to align the shifted phases. i.e. instead of shifting channel i by i * period/16, it might be better to let the 2nd channel get active when the first gets inactive. (i.e. try to keep the count of active channels constant). And as already mentioned earlier I still think we should define the concept of "usage power" better. It should be clearly defined for a driver author which setting they should pick for a given request. This removes surprises for consumers and guessing for lowlevel driver authors. Also a uniform policy brings conflicts better to light. (Something like driver A does the right thing for consumer C and driver B makes it right for D. But once D tries to use A things break. (And then maybe A is changed to fit D, and C doesn't object because they don't read the pwm list resulting in a breakage for C later.)) So in sum: I think this concept is too inchoate and we shouldn't apply these patches. I would prefer to go for allow-phase-shift (if at all) for now. There the concept is clear what is allowed (for a lowlevel driver) resp. can be expected (for a consumer). Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --r5l7l24l74cfsloy Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmCVVq0ACgkQwfwUeK3K 7AnTuwgAhP667IaX+Z5p2hqnp++5ZCSeUJr7CCWWn4FPrv/YvY+6Hmb124IHkyN4 7ve3JPC3uk+3b79IlihpbTQsv1X1oUw3ZtdaD2wHoBrzBkloTBk2bP8X4+AXNg1i XgrQmcJ2j10RI8m9KFXvsnjEcGxL15Lcondxt/iJkhISpW9Adz1fcg8bsaFPySww C/6UUpB8wet/hHeCFSqgOepoYmibkgYbr7HIHNO2aSnNJuTu1z9wS5WfqoSFARw9 1f4P0JP+Ouz1OV6nwgAP0HfpKSmoc4nCdeKOtlxLEBpQX6pEVABSXtqIvF7v2N2l +bG+a2Sk1XpAGdkuLhGmo9NHF+NrWg== =Y7ZD -----END PGP SIGNATURE----- --r5l7l24l74cfsloy--