Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp697713rdb; Fri, 22 Dec 2023 02:12:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+69/BYMuercvVtle1aHJfdcxlPUbW4/vL6+/JTzwOjTkk8fAurLCdoJiWqNUeG6Z//XjQ X-Received: by 2002:a05:6358:71cd:b0:170:e30c:476f with SMTP id u13-20020a05635871cd00b00170e30c476fmr1347866rwu.21.1703239976248; Fri, 22 Dec 2023 02:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703239976; cv=none; d=google.com; s=arc-20160816; b=MqElMgvNfhokIJA4gF7bMIgx8rwCKytFD0e7Z9RARbggv7HGiF+aXIbz/qrowqIpNX nxxJEXOrIpCMKZhHFF63VH7iOJ07QXLYFdgyU/CVc6suT5AGF8wBpxuJYyXHneJ5lE6p Qh7kfKe0/oQuD5wrgTAEeplJBWQXi4XLgpE0ikcfOlV0PY6bklIWVy1PSGv/17ULuGdK yxGYnwIUw4jhHa1MbZSOgrmtcH+kGYyN1Oq/Ri0L7i2Zv0GIJeq1Z1apYVpoeE/DNNfz OlrXEH6Rdxi90uFIDWfBfITt67QF4AIREE1RFBPeh4UiwJcl+Rg68R1XVocFXhMPyUjy XT0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=vdoNGX1KxNkpP3oAqLoaAe4EdC/4AxyKYEpoYHOwAEQ=; fh=XTm/1as0rNNLI6X6shnl7vsHS0yM8bFYpq0tRVKnqgE=; b=s+qAggDa8uI1yoVrzzK+sGip9hDJGW7ShJlMwuWngDY4jPNoB/oNgkVwZROEMbQnpd xeNrvBuf3OsH6TaT4x0SP/muvWgNcSkAFZxPiB/YdP6F1xOAKFL6MsfPMr2ZOMh2fn3r 597xNTqQCuf2m7ELykIjC5a2AQYuGCI1OgjNsip1HM2bjFf+A6PiXa993lJv+NEejnDT tFEe78gCwTg52EFA5bBg4/FHfan2kbYZounOMn4FHGxXCmniZhVuXAcJwtYrRhUwMWoh nkd8H0FxQ1OlKWFc5R1cIP9+AygHjw4Dfr8KZG6OCxIOv7xKcyEI22ckivw26kwIV+A4 r1Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=OnBvpJr+; spf=pass (google.com: domain of linux-kernel+bounces-9586-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w22-20020a63f516000000b005cd813c23besi744083pgh.415.2023.12.22.02.12.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 02:12:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9586-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=OnBvpJr+; spf=pass (google.com: domain of linux-kernel+bounces-9586-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9586-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 235AD287DBE for ; Fri, 22 Dec 2023 10:12:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82A7A156C3; Fri, 22 Dec 2023 10:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="OnBvpJr+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75D0714F97; Fri, 22 Dec 2023 10:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-28b06be7cf6so1075101a91.2; Fri, 22 Dec 2023 02:12:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1703239962; x=1703844762; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vdoNGX1KxNkpP3oAqLoaAe4EdC/4AxyKYEpoYHOwAEQ=; b=OnBvpJr+++JUFVyPtvv/1c9aaXXrIcnn494KCgFV2Wd8d3YOs2efxMAVzEcqnfKBYC GF5M0uS598uJROAHeHM4pa26U6kYd0RBqBEDmmmFbY9yzHIQZNx1RfTU5Ee6cKYaSt70 NfCXJVna+t9TM02C6gZPfMMwlaOnkmT+8iW8/yjFlVZgh1lbZoUyC6G/yamjgOdreStt qSP3LPuIIJnMo6Wpx7/DxhfdEAiTmPfc/xgvm630dQIuwRBgcPrtsOdFy3LHW6TQMQcz lfePF4xdP3ukXoz/d0wLO/TH6oCe9L9nNNvumlUA/ZlBosp9tRspnS9SeqQozdJoxjz/ qMMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703239962; x=1703844762; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vdoNGX1KxNkpP3oAqLoaAe4EdC/4AxyKYEpoYHOwAEQ=; b=CpI13Xa7gTkxpRJOitykZENcHgTo79D4/9WIlrLY5QM8gaXADKOxE9srMOl0TuQYxW TnXZpKk741Dd4Sp4cYw6bRobAmOeI0X1SYjGGPbLgTxDneqR7UteWayPq1vnH1SJneNe IENQMCMinLKe+l6xlp7E9qd+ZtZ+OZbFCeLOj/CuYAGZyJl8IsblWSVYTWyAQdt4L/zc MBkUCSLfrXAJBvbZIJZpdLSCR46Lrn/a6AHl3xTlitfLFF2E7YpB+1O9uAdqsyEBvjie zN5LljU3X+Nyz0IRfOmPBwQ6k1jDi/0sJ0JRF1JRPIRCXIZqdac0Dh3VUZtlRv51hxSX azjQ== X-Gm-Message-State: AOJu0YwT5Shq6ijCnbkbVyNo3AM6EpsnoTzHOICFqo9i0yqVdOpT/rXj QJRtrWAhhyAiJRaxvk+rb/zyrlg/ZTtnXyCZXOcGVw3qPX0= X-Received: by 2002:a17:90b:19d2:b0:28b:cf7d:bc72 with SMTP id nm18-20020a17090b19d200b0028bcf7dbc72mr695938pjb.56.1703239961483; Fri, 22 Dec 2023 02:12:41 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221211222.1380658-1-martin.blumenstingl@googlemail.com> <2f2bc3xvemk2x3sno65so6vglmpavjtyeiqzy6yyzwvx5hqtmi@tsfx2hr7rmqp> In-Reply-To: <2f2bc3xvemk2x3sno65so6vglmpavjtyeiqzy6yyzwvx5hqtmi@tsfx2hr7rmqp> From: Martin Blumenstingl Date: Fri, 22 Dec 2023 11:12:30 +0100 Message-ID: Subject: Re: [RFC PATCH v1] regulator: pwm-regulator: Fix continuous get_voltage for disabled PWM To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Uwe, 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! > (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). 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" [...] > > - if (pstate.enabled) > > - voltage =3D pwm_get_relative_duty_cycle(&pstate, duty_uni= t); > > - 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. Best regards, Martin