Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2066808lqp; Tue, 16 Apr 2024 06:36:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDuTCIp5QDflQYROLrOVxm4w/OthVeoNPvOGOTqwLXEaTmn/KJUxWv5QN54R2EevAF6XuIZlG8iU9swDR8xzxp6yUNgmMWwt9uubDndg== X-Google-Smtp-Source: AGHT+IEKWDJ5WIbGgVOcBvFbCrQTPKS1Cbu/5TvsVyvofTfzPDPsYXow9BDlOIKsQ0MXi0841N21 X-Received: by 2002:a05:620a:408f:b0:78e:e2e3:c7c2 with SMTP id f15-20020a05620a408f00b0078ee2e3c7c2mr4146052qko.17.1713274573938; Tue, 16 Apr 2024 06:36:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713274573; cv=pass; d=google.com; s=arc-20160816; b=eYCgV1p6iux8Xsv5w4djFBVn2uAibD4LbJpEl0pRULNqCHVbOi6gSJDlZvx+4ciD/o LKWCzTBP/RtgoLrJQcPCfuJ3zjX0pooNotwcfkSyUxJ6z6uB8N770SGd4vZD94hySCNt 9XZ8ReFCUysSzXvG/v40at7YnjuLk6yW+qsBbvQKw/vwnog56CmtabraBgK9W4HZszgX u8HhoYCa7barvcPHoKMRoZT2rEwsJf+EOUjqyBQnuscjp+HRUhWa5vMJMgN2Gj0PG0E0 vNTqQDjBcuo29e5PmkM6ZnLRcyck+Nb3ktxQ+pI8BAGlZkUHcv/uyhMnTZPcJ00UJfJS V6Vw== ARC-Message-Signature: i=2; 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:dkim-signature:date; bh=Yi0/qfx4nmZfF6fdXRi1R9ZAidfFCHR7CYYCzr1ALiw=; fh=m/c6w5OyUA8vKLnp5ivku7cjSB94tDpuJLAg6VArN3Y=; b=XquGeYVIBZ/CSdeeUIMWnv04NfawaZfe8bM1lfrrApiRgn2HHjs/YnUtyRCmzFsjLR lN9EUNA/N3wjxFc4+6N1KDa4lPDkPjnwzXttUJq42beNufPHo76NrLyxsQwgvlXkWSDd MXRKVaY9AA4F7dnsupzP9CnFoks4kEyxNGaW4sgji4NVNRxiv8xOsZsAUgq1IyWVkAwc DTCri5Jp8MZAsCeDGV5n8wjDSMdGLwOZYwZiPgFAjxuRYD2vTEojFTUDwUoc+vgc1l8G Z9MiL+6wVbPjl1+qjfjgG5JbngsSYC0pECXCC6XMLHtJWh96IjRTP2t9XgYiYVdP2Eoa hT5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=WsN+inhp; arc=pass (i=1 dkim=pass dkdomain=jookia.org dmarc=pass fromdomain=jookia.org); spf=pass (google.com: domain of linux-kernel+bounces-146898-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v10-20020a05620a090a00b0078ec5edb6afsi11368386qkv.17.2024.04.16.06.36.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 06:36:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146898-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@jookia.org header.s=key1 header.b=WsN+inhp; arc=pass (i=1 dkim=pass dkdomain=jookia.org dmarc=pass fromdomain=jookia.org); spf=pass (google.com: domain of linux-kernel+bounces-146898-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146898-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=jookia.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A53CC1C21E7A for ; Tue, 16 Apr 2024 13:36:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8CF712C49E; Tue, 16 Apr 2024 13:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jookia.org header.i=@jookia.org header.b="WsN+inhp" Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 617E512BF29 for ; Tue, 16 Apr 2024 13:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274568; cv=none; b=rFTCrPcU28+dq/Ea6sxdnPW5So9ndFLkqH3XI6/stG6Az+2bM28Ik/0YgWafAGcTBMM7guLZZf2dOqPhfYfdtMZZIJcW4N5/DsgT9H5qVtptkD/lh9OMhFUou5HC0iZ1lOsHtenh3Z6FvjFKYGjHSB2oNPxTVxUGMXjQsqlGP3U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713274568; c=relaxed/simple; bh=ESXTOBerJ11ivDTEUscWQdRvIS+xShE+sRa69XlINm4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ctE/uTWRD9/y2wutMlMH9OTj1NxIRudvVNn0W7xkWYoCmHIAk7ngObk1TcJicXehmbFYDnzRyXioSPQq81PCJAVv8Q7P8WAd8RqSCHibxgpDbXfOqB6M+8YAHJPCx4shWz5n1A5EriJ0JnguSIXsUDup598o10qssPPDMgdzeBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jookia.org; spf=none smtp.mailfrom=jookia.org; dkim=pass (2048-bit key) header.d=jookia.org header.i=@jookia.org header.b=WsN+inhp; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jookia.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=jookia.org Date: Tue, 16 Apr 2024 23:30:43 +1000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1713274563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Yi0/qfx4nmZfF6fdXRi1R9ZAidfFCHR7CYYCzr1ALiw=; b=WsN+inhptWBlLAn4tYfGJsUTwLFrLAQSCnnMGn3U0Hj6QgcJ0wxYAoALpOZh7Oi3b5sI6g ssaUcULn7c0mtcvWJpB5DP8Qxift4AYjIswvzH2NQmGSI++Cs1XukEkGoRC/byHQ7jsOMO CBpOw1a/3pWu8VVA2M41nalYMiRHr3NqB8IzAnPX+iPHISnvSscRdyHTik1VSqmAuFSzAl 0cKjzNVkuR854rG/g0FK6mX9bCOzX9mAyPnrT3MQNEOHRQl4tzDPZwCR4Cld5ESfftonXn sZ5BKACEjTG79h4w+ANMd8FiuEllga+k6ObB5tCsNVvAd/8FjNWdBw5IQmof/g== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: John Watts To: Andre Przywara Cc: Chen-Yu Tsai , Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Jernej Skrabec , Samuel Holland , Ryan Walklin , Chris Morgan Subject: Re: [PATCH 1/4] regulator: axp20x: AXP717: fix LDO supply rails and off-by-ones Message-ID: References: <20240329235033.25309-1-andre.przywara@arm.com> <20240329235033.25309-2-andre.przywara@arm.com> <20240416122305.3ffc2bda@donnerap.manchester.arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240416122305.3ffc2bda@donnerap.manchester.arm.com> X-Migadu-Flow: FLOW_OUT On Tue, Apr 16, 2024 at 12:23:05PM +0100, Andre Przywara wrote: > On Sun, 14 Apr 2024 18:00:09 +1000 > John Watts wrote: > > Hi John, > > many thanks for the detailed review (also on the other two patches), much > appreciated! No problem! > I see what you mean, though I actually looked at the number of steps > mentioned in the first part of the register description. Now > triple-checking this I came up with this table (generated by a spreadsheet > to minimise human error): > voltage decimal binary > 1600 88 1011000 > 1700 89 1011001 > 1800 90 1011010 > 1900 91 1011011 > 2000 92 1011100 > 2100 93 1011101 > 2200 94 1011110 > 2300 95 1011111 > 2400 96 1100000 > 2500 97 1100001 > 2600 98 1100010 > 2700 99 1100011 > 2800 100 1100100 > 2900 101 1100101 > 3000 102 1100110 > 3100 103 1100111 > 3200 104 1101000 > 3300 105 1101001 > 3400 106 1101010 > > Which means the final binary value in the datasheet is wrong, as 1101011 > would mean 3.5V. > Also 1101010 = 106 > -1011000 = 88 > ============= > 0010010 = 18 > and 18 * 100 + 1600 = 3400, right? > > This *is* admittedly quite bonkers, especially since the representations > between the manual and the code are so different, but can you check that > this makes sense? I wrote a program in Python that steps through each range and prints its value, and according to it value 106 is 3.4V. I dumped it at the end of this email for anyone curious. Your math checks out too. So the datasheet must be wrong. Maybe it originally supported up to 3.5V and someone who doesn't know binary updated the sheet. I think you should add a note saying that the datasheet is wrong, to show people this isn't a bug and also save time of others trying to write their own drivers and check their logic. Something like this: Warning, the datasheet specifies that 3.40V is 107, which is incorrect: - There are only 107 steps in total, making the highest step value 106 - 1.60V is listed as 1011000 (88 in decimal), with 18 steps after that - Adding 100mV for each of the 18 steps past 1.60V gives 3.4V I think this logic convinces me at least. :) John. > I discovered some other issue in the original patch (missed declaring the > range of IRQ acknowledge registers in the MFD part), so I will send a v2 of > this series soonish. > > > For DCDC3 after applying this patch we get: > > > > #define AXP717_DCDC3_NUM_VOLTAGES 103 > > static const struct linear_range axp717_dcdc3_ranges[] = { > > REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000), > > REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000), > > }; > > > > The datasheet marks the maximum value as 1100110: 1.84V, which is 102. > > So this patch to correct the AXP717_DCDC3_NUM_VOLTAGES is correct here. > > I agree ;-) thanks for checking! > > Cheers, > Andre --- Python program: reg = 0 value = 500 for x in range(71): print("%i: %imV" % (reg, value)) value += 10 reg += 1 value = 1220 for x in range(17): print("%i: %imV" % (reg, value)) value += 20 reg += 1 value = 1600 for x in range(19): print("%i: %imV" % (reg, value)) value += 100 reg += 1