From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 4BF21352FA6 for ; Wed, 28 Jan 2026 13:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769606932; cv=none; b=FhPpP85YmBgqJxnWBZ1g933fOJzMjM2l1KhKf9E1I45eG9vwaFv3WQeMbXyO6oRdYsKMCd7aUrt9SZJNZIpi9e78KaZ0rl/nvG39hKAOSUSOg9vTnv3duKs6KB9o8666H9Hy2X2qj3zRTt41pyPN4Oo+5ySP+Vm0HZpD22GHvOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769606932; c=relaxed/simple; bh=7ljei3xi3U8OfQYlSxjCCViYlQqU96DBeVgUd1EakdY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T3aVUycYm1O7pLGaWbIOMikstgHqUfXg8+s9jZsBZLPtHCVbpomFNVRVt/rPwEx75hJMNhXlEl7JTUSBsD77XAeNJKanESca2EMM+z0lghhdc6eYf9h6pC/vcOi4MVdWeOLtoYIpnaGg0QiZ+b/4RutRvfoZJ1kBYfd2l6xWl4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com; spf=pass smtp.mailfrom=riscstar.com; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b=ukPg+oU+; arc=none smtp.client-ip=209.85.161.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riscstar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riscstar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=riscstar-com.20230601.gappssmtp.com header.i=@riscstar-com.20230601.gappssmtp.com header.b="ukPg+oU+" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-65f59501dacso4538866eaf.0 for ; Wed, 28 Jan 2026 05:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=riscstar-com.20230601.gappssmtp.com; s=20230601; t=1769606930; x=1770211730; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CR+ZvBkGA0rmoAszJtyMWrCYonp7pdFBqImvRwPUKjc=; b=ukPg+oU+ilBy6pTQ9tjwjwpQRW4+EURIRLwR5xF1LsFB20+Skq0mbnxUr/pT8s4ICd MFPb50R9hmfUIvVADAS+M3TSXjRsQ91qMNWLAGoSRm6u30aSu6Kg0HUw6Ldtd2QNai88 pH8IG3Dgazcc3ZsFk9opbTXDKNqCcdt2ra1o9u7nn9Kn39uu0/x7TgOmqbOinjJkMJp+ zABhbozDB5vTzax58TI9eaef7OPFzpLJfXLfzZpWPSr04hJvarMDoOKLYoqKztKQr2jt A9YIyjMadwaO5HaDwb4NkD1HUZO6itRxZjWnmQl4btUa0/wN3uvu52M3j4w3L5rnyhaC h4Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769606930; x=1770211730; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CR+ZvBkGA0rmoAszJtyMWrCYonp7pdFBqImvRwPUKjc=; b=n5sWyRTGfsZw+TFGaMlGyO9O3QKg3um15hy/qFaIHH1F0kRaCylpdyWEOn1e3c7zZ9 KyU2orSGejXsa9DmhhA9DduHtyixJUZsrnTpAyQPXId0Ig+Eqs5PPbkMKQ644VvUbVh6 0Omovr3p1HnDkNEFWKkvAQj3lC7Si1rWFtaoqzo02hAw1trvi5HJhtKmtbuaiB+VpQX/ itJ7ud/V4ZF/KiYNrDYdQ4bVDAYejQmhqNQUMlAADOX1RmgsbjVpNcag3FPyPZmyeTnx zminGNAQBok7BoeGd9KFOhQ0H9CXctxx8/px6f+iY5lxSMwTKqFynxGDt+Cfqc38DnYI ueGA== X-Gm-Message-State: AOJu0YytH/+azT5/goYgP9VYbYbzh50qBh1jKFdlncFW5u+Dfn6G2lL7 t0Z+ePjA83YGA+5+UmTyHTo7u7NwurnWSD/eRfDXyfnnmyIklxv1FMluhGSZ95fFBOg+PGfuSq3 bS4W0nLs= X-Gm-Gg: AZuq6aKrWvNIyR1jq35vFQFCjy9bgKpcRb3B1XDUaRoe0Qe0UWZK1RJGxVVX95eXM59 7SvTloYWrQgrZ1UTSrvQ2GB2TwVzQnJE7LrcXeHG3JlhWbKbC93g7OQtXh0BUqXMrV/+oHrRxqc xBPIobTxVYCfN25UWhX3hQQUFPBASl/rSHVtl3ztD5qUQTLKc6VoArJfEDDWBPgwS/7LXnf/2T0 s6DzsQ0O+rbi/x6hsCTwHcYUBcuvleQciMSTbg9aHX9iDtoJ7Jl2H0MlE7Efk8vL4yDKOpkyzEC IQ1Dwih0kd5bejBT1I0dFvEij2rmVNvVUfmIlKfrMlMPMqyiHuUn1lSUYHnuI4LTOg4/4XwiuL5 bzwBENzvDvxqzkTCpGw6nSwUT6JS70MNmPGp9kef2pAQE6Tk2wPqwrQ18a2030gHmOHDPSBBJM+ UAB7/Xb70btEbgTnbQyqBV1hfMBNY7mCcr/AVyOU+Jzt4NdG2iisg= X-Received: by 2002:a05:6820:f061:b0:662:f493:181 with SMTP id 006d021491bc7-662f49306cbmr2051118eaf.76.1769606930064; Wed, 28 Jan 2026 05:28:50 -0800 (PST) Received: from [172.22.22.28] (c-75-72-117-212.hsd1.mn.comcast.net. [75.72.117.212]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-662f994388fsm1374132eaf.4.2026.01.28.05.28.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jan 2026 05:28:49 -0800 (PST) Message-ID: <501849d1-2158-471a-af25-da3dbb070422@riscstar.com> Date: Wed, 28 Jan 2026 07:28:48 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] regulator: spacemit-p1: Fix n_voltages for BUCK and LDO regulators To: Guodong Xu , Liam Girdwood , Mark Brown , Yixun Lan , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Troy Mitchell , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, devicetree@vger.kernel.org References: <20260124-spacemit-p1-v2-0-2c86b06694ba@riscstar.com> <20260124-spacemit-p1-v2-1-2c86b06694ba@riscstar.com> Content-Language: en-US From: Alex Elder In-Reply-To: <20260124-spacemit-p1-v2-1-2c86b06694ba@riscstar.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/23/26 6:20 PM, Guodong Xu wrote: > Higher voltage settings were unusable due to incorrect n_voltages values > causing registration failures. For example, setting aldo4 to 3.3V failed > with -EINVAL because the required selector (123) exceeded the allowed > range (n_voltages=117). > > Fix by aligning n_voltages with the hardware register widths per the P1 > datasheet [1]: > - BUCK: 255 (was 254), allows selectors 0-254, selector 255 is reserved > - LDO: 128 (was 117), allows selectors 0-127, selectors 0-10 are for > suspend mode, valid operational range is 11-127 > > This enables the full voltage range supported by the hardware. > > Fixes: 8b84d712ad84 ("regulator: spacemit: support SpacemiT P1 regulators") > Link: https://developer.spacemit.com/documentation [1] > Signed-off-by: Guodong Xu > --- > v2: No change. > --- > drivers/regulator/spacemit-p1.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/regulator/spacemit-p1.c b/drivers/regulator/spacemit-p1.c > index 2bf9137e12b1..2b585ba01a93 100644 > --- a/drivers/regulator/spacemit-p1.c > +++ b/drivers/regulator/spacemit-p1.c > @@ -87,13 +87,13 @@ static const struct linear_range p1_ldo_ranges[] = { > } > > #define P1_BUCK_DESC(_n) \ > - P1_REG_DESC(BUCK, buck, _n, "vin", 0x47, BUCK_MASK, 254, p1_buck_ranges) > + P1_REG_DESC(BUCK, buck, _n, "vin", 0x47, BUCK_MASK, 255, p1_buck_ranges) This is correct. There are 255 possible ranges, 0..254, and 255 is an illegal value. I think this bug is an artifact of a change I made while chasing an issue during development, and I neglected to change it back. Technically this is a bug fix but it doesn't matter because this voltage value (255 represents 3.450 volts) was not required. > #define P1_ALDO_DESC(_n) \ > - P1_REG_DESC(ALDO, aldo, _n, "vin", 0x5b, LDO_MASK, 117, p1_ldo_ranges) > + P1_REG_DESC(ALDO, aldo, _n, "vin", 0x5b, LDO_MASK, 128, p1_ldo_ranges) I would say this is not correct. The valid range of values in this register is 0xd-0x1f (11-127), which is 117 values; 0xd represents 0.500V and 0x1f represents 3.400V. Technically, all other values represent 0.5v (and could therefore be considered valid), but I believe those should never be used and intentionally considered them invalid. If 0.5V is desired, 0xd should be used. Do you disagree with this? > #define P1_DLDO_DESC(_n) \ > - P1_REG_DESC(DLDO, dldo, _n, "buck5", 0x67, LDO_MASK, 117, p1_ldo_ranges) > + P1_REG_DESC(DLDO, dldo, _n, "buck5", 0x67, LDO_MASK, 128, p1_ldo_ranges) > > static const struct regulator_desc p1_regulator_desc[] = { > P1_BUCK_DESC(1), > I have exactly the same comment about this change to the number of supported values. -Alex