From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 25E3A35838E for ; Wed, 22 Apr 2026 10:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776855282; cv=none; b=pUUaBo+JnUAgY/nerRSJsnDCM5g5ulMotj+e8OtG1Ocbvlx6Bti37NLTLUK209RbY9AN38ojjVDyAXB7Pd9BHERg+H9ThwuDgn4Vujs2acNWq+hwICo5pXlEAPwbhGnzXLy2Wluv9Qf6j4295NK2D32j5reJMbZz3ygXllVwqW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776855282; c=relaxed/simple; bh=s7qqKXP5rsxtgWlSlo0b3SQeHvEWj675RuctlxGMm/s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hB3sWKi88eketjhVFkKNmY/LCuLbnxZgAZjHgmX0y29lV6Y6zjFYp53nqrpJQG/XcNyamIsBSrxtZeAxiajIsSQnzrShNlUNXufuZyP8Ra705PNahwrsiTZ+q5IXJzypTXLwMfTZSCRlyhUQqXCHqSg8G309J8lI7+0oPHR7QRo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=f25Tlirp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Qf18nqWl; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="f25Tlirp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Qf18nqWl" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63MAfTdM3083125 for ; Wed, 22 Apr 2026 10:54:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= TPrSphMryBJEES6iy3//yAergccADe6wIWq8Ir+NbZ4=; b=f25TlirpVj0F7dHd o3nSXN6GNLK6tUshzRYVbhR+nLs+sIdz+3f5XgEDNLWEpCUF8VR44Nck6DHm1P7a QL209UdT6kc8fgjegBbBgCycMjdsTpPdeGtRw8vbVJ8ofKRrXDlNbVLGAI124x+Y H504AdzNnQqReHDhwnm5S01ER+WL47umiOTBAl71X+R1B8+9aR4fBhFzWgG1J8Dg SpfJihxQJt2mar0qK9EUEiSItl7YzwIxYmFDU66cCkIvdUucViSTRHvLN6cU4rXI B0FzmgD/iORmbVw1uGPuNPZP/v0Vr4M6fbPLAh6Gnjq24yXdm3QVva3n1sK1hfSd ayJ5UA== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dpenmk5bp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 22 Apr 2026 10:54:40 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8eec753a7bdso54405885a.3 for ; Wed, 22 Apr 2026 03:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776855279; x=1777460079; 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=TPrSphMryBJEES6iy3//yAergccADe6wIWq8Ir+NbZ4=; b=Qf18nqWlMysX0O0sbaFyymQuCm0DaDFkH3U+6XKX+BTd8Fos0qQbNVHiOOluy5mZKj Qg+nVNvhQ64ZrDZErP2yrahHYM6er8XQoD/qb4rsoXMvSe7ldiWwizpULiFinOSxEAXR 0Q8Y3Yizs8OHV+IB+ieop2aT0xVZo8JzrfUHRw6fqBDs2ogPBYf57qAmygbYRfTU/orZ SGevn/+tsFzychCozuzf1YnVpl1wLS4pdBg3xcNrPsY61qSN8VbJ/LuTQD0qwqClcyTd GWMb6B2j+e/v6hECxNUE0UzrOWyl+V51GksQ6pR7NF7z0uspadmZn+p+bHotpHfYtmai e79w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776855279; x=1777460079; 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=TPrSphMryBJEES6iy3//yAergccADe6wIWq8Ir+NbZ4=; b=GEgGOjeIjNp6oIEbPEMfkqIUk4dxnhikytqnP4daCPJ08K9HnzMOyVsvm4dUu6LctX U4KMVuGXHGfyTl9HIuB/cjRNQH3vrttpkZ9y7z5BBSmVE63fdlAJXjD47a0NAEZtmPj5 wIbpl1xaSE8+mDRt24yylZIGjNpYx+aFU8XqhlhFCppxDKWNloll0F9aqxRTWo2BLyXT qyN13vDIxo0YTArNZM7IwxJFqbZts1CrfpMlOCfZopMgkllHUSXOJJol+R+Lw1SOStj4 l4LscsYIstNzMntkYEkYB5sMJ/6V6qVm+f7bElejBmwZrJggYqnBguIJO3NDRiR9T8VK sX2Q== X-Forwarded-Encrypted: i=1; AFNElJ+NCb7zTWA7US1B2DEqxSUg6lRESRbjN7Hv2AKExcCxV76+/n4JfHV/jL5MUKJKtodbvFJDsuLprADA5vw=@vger.kernel.org X-Gm-Message-State: AOJu0YwnRGX0HrI1lYDUMleB8pYRDd2z33tkQcInHErqMsW7dFItr//s MQLHgYILh5YlMq0J+1lM/s8YaKRSwzlOTyVDKkogq0cCv+cfdCp1Ls0XLSquf+E9KULpQis9Y1Q wCndiiAah7cif4EZXp4bXNU9A8qIkTbSExwkc97BNHYa70Mykwt9S/uKjOng+uD7+pnkFoKsS4J s= X-Gm-Gg: AeBDievX6voD6yGvYWGtwfmhPG63A/22pLjcy1C1ckpJL7RA1Mqc47EVIv2ozh/W4QO qOqyfKEAy9OZIPRub+cDCs9lZrf3A8Ee2w4qc8D1iUl2SyJjQBjelH2irVZqGEmiqbWDiYKuHz5 UU4IBazJL42ebxJcOdujp4d7hqGFggvMWPCGI+r9n/i9ua8OGf1KjdWcZI0FhV2NE6gIzr/R0EB UeR8NwUtIzk3mTuOubWIc2pC0O+XBDECewUNiggrwkp1SCiMIEo3/+ejuVLzFWb07pMlbEanFCz 8ajUiklO/oKQcmzj4YXl2QPBNqrTFl70Jg9flolLlWl3N53hp8XdwrVVtlZjGUrXafExdRaJYeM 1Zg/vUTdmphtfHtGRMEyYDsWReN4fDePAAGhBuNBcMCkEi9qrPdmGEqgnAutsmwmHNC3wo1pj7a p8q1yrxU+Rqp02vQ== X-Received: by 2002:a05:620a:2a13:b0:8ee:7878:af34 with SMTP id af79cd13be357-8ee7878b19bmr574680785a.1.1776855278899; Wed, 22 Apr 2026 03:54:38 -0700 (PDT) X-Received: by 2002:a05:620a:2a13:b0:8ee:7878:af34 with SMTP id af79cd13be357-8ee7878b19bmr574679285a.1.1776855278461; Wed, 22 Apr 2026 03:54:38 -0700 (PDT) Received: from [192.168.119.254] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-672c4d4561fsm3301028a12.16.2026.04.22.03.54.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Apr 2026 03:54:36 -0700 (PDT) Message-ID: Date: Wed, 22 Apr 2026 12:54:33 +0200 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 v4 3/4] regulator: qcom-rpmh: readback voltage/bypass/mode/status set during bootup To: Kamal Wadhwa , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Vinod Koul Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260420-read-rpmh-v3-v4-0-70c152e6c958@oss.qualcomm.com> <20260420-read-rpmh-v3-v4-3-70c152e6c958@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260420-read-rpmh-v3-v4-3-70c152e6c958@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: V2QuOSIiHBMfD4s_RsR-szpM9jOWIbvo X-Proofpoint-ORIG-GUID: V2QuOSIiHBMfD4s_RsR-szpM9jOWIbvo X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIyMDEwNCBTYWx0ZWRfX7hP4Y14Ov7AS wAug7crnYfgOCCofbuVCV/GAPtwjrPq2kaxDB6WI1KXaAe+w0L71mxqrAWmPs22V29qg4eQqccj 8cBfYAglW069I0MBr8DpXRZrYBDbxnbwMrRbrdhZ6QHBUR7ZM3JloasDVBYk++sS87UTk1fueL8 wXMR3lIqHoeAc8mW0yeBFua/WYjQN9R+3DZPIaCPiA7RC4q+dyoUzHY1NtSHT6mucQNgLoPfEyW Yqkm1M9siMcg1CgVnKenrEG309R19cruOZubHl9UZIvjhm5sJOmoYofs42eBLEHRCL29mmhQ75u VqYS5aAnxGg+CSzXQCMbc6/VlEohlQ5G12SPyQtcfElX5pdHsayKc403V1F6VdzAYL+9ehdrmyP EBl9GTWXs8xD2PQIKGnpuAzFsa4klMC/sMN1WhZa/9+6/4SILeT+wltMtipwPDHXPRi2blk4fob TxBgbmVqv9qB/lQSdhg== X-Authority-Analysis: v=2.4 cv=Xd65Co55 c=1 sm=1 tr=0 ts=69e8a8f0 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=FpWmc02/iXfjRdCD7H54yg==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=ZIThRnkgJp5XSj0HyFcA:9 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-22_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604220104 On 4/20/26 5:43 PM, Kamal Wadhwa wrote: > Currently, during regulator registration, regulator framework sends an > unnecessary `min-microvolts` request for the rpmh-regulator device. This > happens because in current design, we do not have a way to readback the > voltage settings that was set during the bootloader stage. > > Fix this by using the rpmh_read() API to read the regulator voltage > settings done during boot and make it available to regulator framework > from the very first read after the bootup. > > Also use this API to read the status/mode/bypass settings as well. This > will provide the regulator framework a sense of the initial settings > done by bootloader and thus preventing any redundents writes for any > setting post bootup incase the same setting was already applied during > bootup. > > Signed-off-by: Kamal Wadhwa > --- > drivers/regulator/qcom-rpmh-regulator.c | 179 ++++++++++++++++++++++++++++++++ > 1 file changed, 179 insertions(+) > > diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c > index 85fbf10f74bb3393071bc65681356312f27b7527..1add15d73cac67ad8c0b45aaad6fb2ae9b388180 100644 > --- a/drivers/regulator/qcom-rpmh-regulator.c > +++ b/drivers/regulator/qcom-rpmh-regulator.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include Please sort the includes [...] > +/** > + * rpmh_regulator_read_data() - read data from RPMh > + * @vreg: Pointer to the RPMh regulator > + * @cmd: Pointer to the RPMh command struct to readback data > + * > + * Return: 0 on success, or a negative error number on failure > + */ > +static int rpmh_regulator_read_data(struct rpmh_vreg *vreg, struct tcs_cmd *cmd) > +{ > + return rpmh_read(vreg->dev, cmd); > +} Since this is a wrapper of a oneliner, perhaps let's just ctrl-x + ctrl-v it into the usage [...] > +static int rpmh_regulator_determine_initial_status(struct rpmh_vreg *vreg) > +{ > + struct tcs_cmd cmd = { > + .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE, > + }; > + int ret, pmic_mode, mode; > + int sts = 0; Drop the initialization, it's always initialized before usage [...] > + /* > + * NOTE: Since BOB4 BYPASS_MODE value = 0 we cannot confirm if that BOB > + * regulator has been sent into bypass mode by bootloader or if bootloader > + * just has not requested for any mode voting. Due this limitation, we > + * must check if the read pmic_mode value is non-zero before comparing it > + * to bypass mode value. This also is needed to avoid setting BYPASS status > + * for LDOs which dont support bypass mode, and have the pmic_bypass_mode > + * uninitialized value as zero in the vreg hw data. For such cases assume > + * lowest mode/status, if pmic_mode is zero, to allow for mode voting. > + */ > + if (!pmic_mode) { > + for (mode = REGULATOR_MODE_STANDBY; mode > REGULATOR_MODE_INVALID; mode >>= 1) { > + if (vreg->hw_data->pmic_mode_map[mode] >= 0) { > + vreg->mode = mode; > + break; > + } > + } > + > + vreg->status = regulator_mode_to_status(vreg->mode); > + return 0; nit: since you did so above, please keep a \n above the return statements Konrad