Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp497774rdb; Thu, 21 Dec 2023 16:18:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHh8UlHJNIpC338JAfs0LecPm/ZN4kLabXsQQ2NtKvtW3UvsAjpE7Tr+Gja4COeFRKBCT4g X-Received: by 2002:a05:620a:4104:b0:781:2acb:1d3 with SMTP id j4-20020a05620a410400b007812acb01d3mr524202qko.0.1703204285672; Thu, 21 Dec 2023 16:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703204285; cv=none; d=google.com; s=arc-20160816; b=FI5ua3E64McuvtCh55RqWHF1eKaJvueYH6J1p5ELdM/O7yEgllp95gn69RYrUNKlAu yuzvMyPI0OTs1H76sroaxAjPc9RiiXeDu9kAlg2+csoJuyQLAHc5R+i4+OqVTN/05qJ0 iip3sIsr/Pu9sQ4dKgcHNK5H6L897mBNcUMYxOvAacAt7ySBKFrUMOQdbWPT/5gz9/rq vwyCzZQp+jpLDRbH6KTg9cDkcgT8fy2NPG32N/ldEg/BgyNQc5nZyi6Db2LYL1MiFOea 2xoQ0KU6Yl43yrTXJug8cfSQ7EQ/vApPtB/pamHzEeOUIWCJJgyp/OXVr5UyHZV5OyAS QOXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=K4eLtecU1AzkZ6v0yoRfkSekFdqon4FA+IB17UNyBZc=; fh=XTm/1as0rNNLI6X6shnl7vsHS0yM8bFYpq0tRVKnqgE=; b=w5KKJA23lch3oooqy6C7brMTdAz8IGcYLxBNI5gv2QkWB0ePKImmQbhD/QjoC4YIH+ NkLSwcls+Q6ZHzXYTr4/trcp50XNLP3ZdZSKIV8/d5g9BI20hO1LT0aJ2A6MDr6vbCeS QmG32qaAU1cBIaSLKbNKNk4+MSU1PX2k0P69Zm1/WoPRqdR3asjrVDy59FeedJieStd3 YlzLAYCyyIL7x+bnygvRo5f/YEe0GHI5JoODVyF3Li/zgToLadQDS/ReVtyzvgIfBJqT PGC1axyzIhV5T/ClAyKCTB/CAq6laWvTLYurVVbodeWaaSkHgvDQH0Dl2oMpaPnNWU1I WYyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=UqPZ2ZQm; spf=pass (google.com: domain of linux-kernel+bounces-9201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q11-20020a05620a024b00b0077d7db54d82si3095990qkn.427.2023.12.21.16.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 16:18:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@googlemail.com header.s=20230601 header.b=UqPZ2ZQm; spf=pass (google.com: domain of linux-kernel+bounces-9201-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9201-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5E9B31C239AB for ; Fri, 22 Dec 2023 00:18:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77956394; Fri, 22 Dec 2023 00:17:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="UqPZ2ZQm" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 6149B630; Fri, 22 Dec 2023 00:17:56 +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-pl1-f181.google.com with SMTP id d9443c01a7336-1d4006b2566so9857475ad.0; Thu, 21 Dec 2023 16:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1703204276; x=1703809076; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K4eLtecU1AzkZ6v0yoRfkSekFdqon4FA+IB17UNyBZc=; b=UqPZ2ZQmNCL7ZS4xZgP5L7goYg9YUKeaTcxo+tCmo7AcIDPR7iFrcMkBHu9Gnf+4JW Qi9lQmCQgwMMl1l7m3LSVSuFT2i+wf9oIVgMFtib6JgjE0jcVCFOLd9dxEZOVnUvsRfV OdZjC2n77x5AlfGAhi95Vr9nBfwjCBbrV4DxbxbHKfZRK445ZJ5NiYf0LTtQXc7E5z4Z APplq4oF0mx762eB4uBQ007BZXJxgVCtZ0UCxmZ0yZr3XOq0MTsOJme3fSTJKEg/xlwE 1vPUnK3TS5caV1CR5XBd/9euT6R4UQzQCZ7S44clYewLxPIyvNYS9ZUZ7tpgtyXlAVGN JGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703204276; x=1703809076; h=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=K4eLtecU1AzkZ6v0yoRfkSekFdqon4FA+IB17UNyBZc=; b=OKHo2cXPKBUGRxd5fLC2d2Flf4oA0VB5aRYABGyX3IQ7rC1sb+KXSETQD1zVa4WrL7 RVCQrdlK2MUdjTULsvnvbLHmjcczQPmRxyHJSWDonsfa603gLVuraX/0LVPqt44BNr+s zIppS4wEJW/cJfzjYF7Nv3zcRVeGfWBkcB9UVZdfnC1DxfjCEPxYB+9Maduti2Yc4v5h D/FGAuoz5sG/U3Glu6LY3RRKM1ugi9gcAV2t+TrxL4f/5n4hSYxZ0gXlomKcDOqv+zot YkGCBzpBphBNthFC3zMABYlf90hJTHPiT807GCXzoByHSXF1Iaru3Msp9gaSh7O+4/Pe /nUA== X-Gm-Message-State: AOJu0YxZKn2Qy0ubalJJwuZEzuhCzGkjk3/Nfkik5vBZvBBgj3sPej5F ZITb1Uv3kkLnT/Lq+/hKuuPrlI8mMoieK5EyuNCnSr2XYlQ= X-Received: by 2002:a17:902:7c95:b0:1d0:9609:382e with SMTP id y21-20020a1709027c9500b001d09609382emr300415pll.21.1703204275514; Thu, 21 Dec 2023 16:17:55 -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> In-Reply-To: From: Martin Blumenstingl Date: Fri, 22 Dec 2023 01:17:44 +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: multipart/mixed; boundary="000000000000d28aac060d0e2533" --000000000000d28aac060d0e2533 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Uwe, On Thu, Dec 21, 2023 at 11:03=E2=80=AFPM Uwe Kleine-K=C3=B6nig wrote: [...] > Note this isn't save in general. You're implicitly assuming that a > disabled PWM runs with the minimal supported duty_cycle. Most disabled > PWMs yield the inactive level (which corresponds to a 0% relative duty > cycle). But there are exceptions. Good catch - thank you! [...] > Without claiming to understand all implications, I'd say > pwm_regulator_get_voltage should signal to the caller when the > duty_cycle isn't contained in [min(max_uV_duty, min_uV_duty), > max(max_uV_duty, min_uV_duty)]. It seems like there's -ENOTRECOVERABLE that we can signal to the caller. This makes the following message appear in my kernel log: VDDEE: Setting 1100000-1140000uV Which means that pwm_regulator_set_voltage() is called which will then pick the minimum voltage. To make this work I will need to update meson8b-odroidc1.dts (which isn't a problem, I just want to point it out as it's mandatory for that solution. also I will send that in a separate patch). See my attached patch (which replaces the initial patch I sent, it's not meant to be applied on top). One question that I still have is whether we are allowed to just enable the PWM output within pwm_regulator_set_voltage(). Doing so is actually mandatory, otherwise we end up in an infinite loop of not being able to read the voltage, then sets the minimum voltage (but leaves the PWM output disabled) which then means that it can't read back the voltage which means it tries to set the minimum voltage .... Best regards, Martin --000000000000d28aac060d0e2533 Content-Type: text/x-patch; charset="US-ASCII"; name="odroidc1-vddee-fix-to-discuss.diff" Content-Disposition: attachment; filename="odroidc1-vddee-fix-to-discuss.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lqfvouez0 ZGlmZiAtLWdpdCBhL2FyY2gvYXJtL2Jvb3QvZHRzL2FtbG9naWMvbWVzb244Yi1vZHJvaWRjMS5k dHMgYi9hcmNoL2FybS9ib290L2R0cy9hbWxvZ2ljL21lc29uOGItb2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