From patchwork Mon Aug 7 14:38:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 132128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1510361vqr; Mon, 7 Aug 2023 08:01:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsQKDXOJ1Q/RCpDx6fujuoxArsxX6WLAAXBlndOnv0LUCCJNnq8tR4FWNbDMyjYOhvHn5r X-Received: by 2002:a17:902:8c88:b0:1b8:a31b:ac85 with SMTP id t8-20020a1709028c8800b001b8a31bac85mr9084210plo.41.1691420506180; Mon, 07 Aug 2023 08:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691420506; cv=none; d=google.com; s=arc-20160816; b=hEv1PvoruTsiPklhGQiJGZPwZv6MUbxIYmbmvw1Mr+zDS/c3c8DgY69wVhdO7A41Gy U6ij2c2c8MI+QEPfl/Ukys4RAvv8lkj1OQIBdSiGJu5BLoSxow99rWzcklEmqKMRS1D8 EfbbPM5w6SrL2z3gpx4VsCaqeVZJVKndFELBtDYBcXpY11X6BXSYPqT188PyJp/jGy4R uA8yLDrYkt4wDlIbltmtcsxg1DfJfPpkNiJPZbmpxMqlJuu8+sJYamhiuSzHptumK228 JqS11l3hGVNh47yVq4jdZa2YbTvipKldr82NI3aE46SMf8YyaZZ4S7vKfFNH1lIQkyxw AUjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=6y/uMbhakWSS8oAqg45H0ccmFpSOu2nRFKRQ6r7ECl0=; fh=qPturt8a7BGl9xh2ra5lDlKzzRIIUrPRbXZ4OcdfHWw=; b=OfmwLGjx1QjE6/yF6xpmT8KUdMJVd1JzIlbldFdivLyVR4qIjB5S19hEYk4dsGy446 QGGctO4J/mQI4w8XXk+KD6vTtBdHAcY4QIpka/yxk94sYXArSVKFhe0vxBRvIIWoFJBO Z9iP/x70cmf67TDp+EBsbK9LRJrOupQrBZ/beQW84sSd4HcRxLF4XGaAhZNBHYLeeHPh O2UcLI4rVt5qGtKsqN7zpqS6w/dPLJJ/eXPhXyzzruXw4iULxmDMQiDlZZ3xhzMFYrZQ q7UMgc4Czt9kMtXvwj9J+kscuAhTL30gnvGgcaoaECoIzs1btSQS1grG38sLpb0J3wmi 7UVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a17090276c200b001b9e39f8e21si5703462plt.127.2023.08.07.08.01.29; Mon, 07 Aug 2023 08:01:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbjHGOil (ORCPT + 99 others); Mon, 7 Aug 2023 10:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbjHGOii (ORCPT ); Mon, 7 Aug 2023 10:38:38 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D97510DD; Mon, 7 Aug 2023 07:38:37 -0700 (PDT) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 377EAbHa025188; Mon, 7 Aug 2023 10:38:25 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3s9kb1ty85-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Aug 2023 10:38:25 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 377EcNkZ056328 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Aug 2023 10:38:23 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 7 Aug 2023 10:38:23 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 7 Aug 2023 10:38:22 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 7 Aug 2023 10:38:22 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.194]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 377EcAFV022976; Mon, 7 Aug 2023 10:38:15 -0400 From: Antoniu Miclaus To: , , , CC: Antoniu Miclaus Subject: [PATCH] iio: admv1013: add mixer_vgate corner cases Date: Mon, 7 Aug 2023 17:38:05 +0300 Message-ID: <20230807143806.6954-1-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 8O4WMoDGPjjBTTYZ8mooRsYqTmoqwkrM X-Proofpoint-ORIG-GUID: 8O4WMoDGPjjBTTYZ8mooRsYqTmoqwkrM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-07_15,2023-08-03_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2306200000 definitions=main-2308070135 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773582949060417436 X-GMAIL-MSGID: 1773582949060417436 Include the corner cases in the computation of the MIXER_VGATE register value. According to the datasheet: The MIXER_VGATE values follows the VCM such as, that for a 0V to 1.8V VCM, MIXER_VGATE = 23.89 VCM + 81, and for a > 1.8V to 2.6V VCM, MIXER_VGATE = 23.75 VCM + 1.25. Fixes: da35a7b526d9 ("iio: frequency: admv1013: add support for ADMV1013") Signed-off-by: Antoniu Miclaus Reviewed-by: Nuno Sa --- drivers/iio/frequency/admv1013.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/frequency/admv1013.c b/drivers/iio/frequency/admv1013.c index 9bf8337806fc..df29f1216b9a 100644 --- a/drivers/iio/frequency/admv1013.c +++ b/drivers/iio/frequency/admv1013.c @@ -348,9 +348,9 @@ static int admv1013_update_mixer_vgate(struct admv1013_state *st) vcm = regulator_get_voltage(st->reg); - if (vcm < 1800000) + if (vcm <= 1800000) mixer_vgate = (2389 * vcm / 1000000 + 8100) / 100; - else if (vcm > 1800000 && vcm < 2600000) + else if (vcm > 1800000 && vcm <= 2600000) mixer_vgate = (2375 * vcm / 1000000 + 125) / 100; else return -EINVAL;