Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp704015rdb; Fri, 22 Dec 2023 02:27:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtMSzS0e/kYMEkYEYsfUCMnzooFjkm1+e8T76wouRwtrHs16LLAiJS9m2fVrhPiEZkTqYb X-Received: by 2002:a9d:6a4e:0:b0:6d9:d99c:55f0 with SMTP id h14-20020a9d6a4e000000b006d9d99c55f0mr1144527otn.23.1703240874004; Fri, 22 Dec 2023 02:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703240873; cv=none; d=google.com; s=arc-20160816; b=bfxNVf8TDPQA66Zp+UvvPRZWkQ+4tkiOxCGrnFnIMJCJBpeh8DtYafLRVGOEW+7c4/ 6tM6DF4WjNEDzfWiBFPk3KHC3wQyGfhQHSr+pThdGiLb6R30E+0cAzArBgujyZnRpB6H /DbSHPnIHXBecEUS9QcExz2WCViK7XauI+24VZyYOi6oP7FB6fmid/mjA16w1buGvZ2i fsmpAmGhqn+M7r4VQndWvOwPt+Ygnz5qmxnb76zBEOY8CCphz9geBCr6aXlmZBJaVqJZ y27im333oZrPaxrYhE4SbOlomScpgtTaoZddw6xQ3aM4mtk6HVM9aXcTzfr97glLC3ie EtCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=8QYfP84CdJ7pDzaQxrwvSzRrEoNzxIR0VpG76Bpjfws=; fh=k0tcPuoslLFiFHV4ycXsBSMAa9AkIpD+V2iPdyRLkg8=; b=RPsc1Yjb9UOTP5rZmEnJ7ebh6JDBNhxqF5rsmFSoPjUChwd4dg9Sfwb87AIY9b6DZH CgLx4gJ9FXRNRfpcXRxSnECyCQuYpyWvvPPicFkyIeWbkdOsbRWLdy65p7VAoXjgLz5Y N96o6GZfPZLdFJpIzdYZbZF24N/4IpqkBXLjJE7jb1yNeNMWk3ixqJJS1e+VseYsfoRW NH/xdpHupHReNZRz/O51v4L/W3Rm0ULmjylW3FyqsflIZWYRcLZyMfoOlXkNuEwCVPiv r2uLCPVuL4A1yJwafXSIQClIiNgEjBC0417wkylbNFTQvFA9m/xtCoBp7CVwSEEHjQ4k E6JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9593-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s10-20020a65644a000000b005aa7d3730dfsi74427pgv.114.2023.12.22.02.27.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 02:27:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9593-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 92491B22D16 for ; Fri, 22 Dec 2023 10:27:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C9A212B65; Fri, 22 Dec 2023 10:27:45 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8935011718 for ; Fri, 22 Dec 2023 10:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rGckX-0008A3-Ce; Fri, 22 Dec 2023 11:27:25 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGckV-000jXS-3D; Fri, 22 Dec 2023 11:27:24 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1rGckV-001cdB-T5; Fri, 22 Dec 2023 11:27:23 +0100 Date: Fri, 22 Dec 2023 11:27:23 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Martin Blumenstingl Cc: lgirdwood@gmail.com, broonie@kernel.org, linux-pwm@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Thierry Reding , Heiner Kallweit , Dmitry Rokosov Subject: Re: [RFC PATCH v1] regulator: pwm-regulator: Fix continuous get_voltage for disabled PWM Message-ID: References: <20231221211222.1380658-1-martin.blumenstingl@googlemail.com> <2f2bc3xvemk2x3sno65so6vglmpavjtyeiqzy6yyzwvx5hqtmi@tsfx2hr7rmqp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ofg2g3grsnoftz76" Content-Disposition: inline In-Reply-To: X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --ofg2g3grsnoftz76 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 22, 2023 at 11:12:30AM +0100, Martin Blumenstingl wrote: > Hello Uwe, >=20 > On Fri, Dec 22, 2023 at 8:10=E2=80=AFAM Uwe Kleine-K=C3=B6nig > wrote: > [...] > > Also the calculation is wrong: If a relative duty-cyle in the interval > > [91%; 0%] maps lineary to [860 mV; 1140 mV] you get 1100 mV at > > > > 1100 mV - 860 mV > > 91 + ---------------- * (0 - 91) =3D 13 > > 1140 mV - 860 mV > > > > (If the calculations in the driver used signed multiplication and > > division, all the checks for max_uV_duty < min_uV_duty could just go > > away.) > > > > So you want > > > > + pwm-dutycycle-range =3D <13 0>; > Thank you! >=20 > > (if this restriction is really necessary). > I could not find a way around this. > Without this change pwm_regulator_set_voltage() is called with req_min > 860mV and req_max 1140mV. > pwm_regulator_set_voltage() will then pick the lowest possible > voltage, which then results in 860mV (exactly what I get without any > patches). >=20 > To be able to keep the original minimum voltage in .dts would be to > work on what Mark suggested where he said: > "I'd expect a change in the init_state() function, possibly one that > programs the PWM to reflect the actual hardware state" >=20 > [...] > > > - if (pstate.enabled) > > > - voltage =3D pwm_get_relative_duty_cycle(&pstate, duty_u= nit); > > > - else if (max_uV_duty < min_uV_duty) > > > - voltage =3D max_uV_duty; > > > - else > > > - voltage =3D min_uV_duty; > > > + voltage =3D pwm_get_relative_duty_cycle(&pstate, duty_unit); > > > > I'd add here: > > > > if (voltage < min(max_uV_duty, min_uV_duty) || > > voltage > max(max_uV_duty, min_uV_duty)) > > return -ENOTRECOVERABLE; > I can do that - although I think it should be a separate change. That can go in together with the if (pstate.enabled) return -ENOTRECOVERABLE; Otherwise +1 to not mix that with the machine specfic stuff. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=C3=B6nig = | Industrial Linux Solutions | https://www.pengutronix.de/ | --ofg2g3grsnoftz76 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmWFZIoACgkQj4D7WH0S /k7wLQgAgB0mlw3wy3ju4Du6LWIxSgraCzeRpxj6i4nzctEXRDsG7vLq9hKVW9Uf GAFpXYSwxcG3rUS9CMj3YY7NPeo7ZZ1U6EvHNyQOk/DEbWKIw/Y1eZi2QGaWjUqa T0x1En4EaSUKC4ZdDGy+5DgGsC0rlfMyE7YQHkurbuAjb5fvCbfL9XTW/GqnRUuJ Ptd+EyNbQfpzwyKA99G9WEy3eWM5ou5n0mTXGRtSpYlEPa7evYWF8+U65dcd/o9Y d7mETR2MMvUfIJmbxp1Ob/zj+tjI0Jes6ahX2Jc9ev9BTjmFchcMB4MTE5xY3MRn +T9SqS89y1Ku9rTXDCpbDx0uZKAwvA== =bR5z -----END PGP SIGNATURE----- --ofg2g3grsnoftz76--