Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp819522rbd; Fri, 23 Feb 2024 04:46:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgckapSYdOaH5C2AUBNGysNriO4PKaWeX9Cn8OQS0djSM+3aYso2PD6CZLVxqaA3Gsv16CeEnEG70g2GxxKSjmV9HQpKXRa6rt4UpwBQ== X-Google-Smtp-Source: AGHT+IF9EOVnJk+xGTxVT1WLOMzuVMn40OBebVyLp1ryUnLmHpCXrTF/ufo8UaVLf07frBPwTzlD X-Received: by 2002:a25:bcc7:0:b0:dc6:fee4:e889 with SMTP id l7-20020a25bcc7000000b00dc6fee4e889mr1834788ybm.13.1708692400514; Fri, 23 Feb 2024 04:46:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708692400; cv=pass; d=google.com; s=arc-20160816; b=EjO+1exBCcxE//NQAHJvDMpEH0bwhhSPeRKivsznHLqbCVk1Trj3uOyc9WiKTkyqD0 K34JKGXQN0uF4KbIRQBVuoOJ8PO1nEqzE96a6127Xo+izDX4hP+h+GMBDwT1v437/dPA mNLFUFfDBQ8ikJIVioV8g0/0j6iNnoTwQQen1WX896UHEPNo53eynnEKZtoSVa+tJT/U 2ecFcnRK5xECiFiJmZX887bd/5Ty7sOyIzWRxcs9wWuWZa/lQdmXvwyUgd9ehxOCB03V sWTfdP76aQAcEQepeXYPCss2xQDuFSFb4ZDpm97KtSqA842nRMqatBknLZAWybkMufNk jvAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=sxfaU95IOhJe+GArFgDxiQsOo/DyPTq5L26sP2EaD+Y=; fh=4Ejxir7Asd0PGBlxwH+sBJkQn6ICEtx02wHM8aXm5mM=; b=xdzd3aft3smpUiTCYc0cVG2SmR9cgFgLTiboRdsAKNLK1WEt1Y9cNGq6PPB4S2RgOE y/dpfWEOlCYUi37AxL9X1IGebhoPmoOBign5ujGSrBGcfthX2v7CWTByuGofl3SHXb3F J/5IhD/TibEB6hIfqUrm74m9aJQ8hEIdtLwdZbG54YsCkkQEhZooKBihL5iVj1ATAOm7 shJ6mQeJp0dqlaEAkADNkXOvMG10FsGWaI7KCL2+Z/9rkLAZPFEQErkIt/M334Ww1vwf iTKPQ/j8obi/iPJGk9hnbu0OYKXKMYqM6VIwQezJvPD0UOBFe2I+TXWzWluOZoCn9Vya aowg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=0leil.net); spf=pass (google.com: domain of linux-kernel+bounces-78318-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78318-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t21-20020ac865d5000000b0042e56ebe45esi2587002qto.268.2024.02.23.04.46.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 04:46:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78318-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; arc=pass (i=1 spf=pass spfdomain=0leil.net); spf=pass (google.com: domain of linux-kernel+bounces-78318-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78318-linux.lists.archive=gmail.com@vger.kernel.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 3142B1C20D56 for ; Fri, 23 Feb 2024 12:46:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58E1B7E786; Fri, 23 Feb 2024 12:46:13 +0000 (UTC) Received: from smtp-42af.mail.infomaniak.ch (smtp-42af.mail.infomaniak.ch [84.16.66.175]) (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 9E66D5C8E3 for ; Fri, 23 Feb 2024 12:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708692372; cv=none; b=XVDLnphaNFqlTR7o996hxQQ/ffHLMmICLUQHm8HVFLWViruZSwNRCWhEsvOVdd53nmHAd7wlfcUGZyo+sS0h5lgKDFgzCgch9ZmdLARHh9yAOmApGnyUa4cWI9jvUy2NDuJy3tiEdzZdd1sGs5PbL5hpeDnF9GO/UM+Frj90P4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708692372; c=relaxed/simple; bh=K5SKHZ8edZFBOjaMQ5a+FjeaN0WmRn9O5VzcpKzw93w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nPpgp3PBzoQkQGykYlCuyJqTEWysFt77PsJSMtZRIQDTaeHFd2JMH/FGO3Q9dAZy7b683N7Hd4Cgi6D/tqFI4k6UY26RA015Lma1pdaKPVqodSE4GfLb9GFNsPuqWYxuykAUUNECCfXje6y0vmT+kdDF12Frmss8v78uJFFo+nw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net; spf=pass smtp.mailfrom=0leil.net; arc=none smtp.client-ip=84.16.66.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0leil.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Th8rV3Qr6zGMT; Fri, 23 Feb 2024 13:46:02 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4Th8rT5JLQzv7F; Fri, 23 Feb 2024 13:46:01 +0100 (CET) From: Quentin Schulz Date: Fri, 23 Feb 2024 13:45:22 +0100 Subject: [PATCH 2/3] iio: adc: rockchip_saradc: use mask for write_enable bitfield 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240223-saradcv2-chan-mask-v1-2-84b06a0f623a@theobroma-systems.com> References: <20240223-saradcv2-chan-mask-v1-0-84b06a0f623a@theobroma-systems.com> In-Reply-To: <20240223-saradcv2-chan-mask-v1-0-84b06a0f623a@theobroma-systems.com> To: Jonathan Cameron , Lars-Peter Clausen , Heiko Stuebner , AngeloGioacchino Del Regno , Andy Shevchenko , Shreeya Patel , Simon Xue , Philipp Zabel Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Quentin Schulz , Quentin Schulz X-Mailer: b4 0.13.0 X-Infomaniak-Routing: alpha From: Quentin Schulz Some of the registers on the SARADCv2 have bits write protected except if another bit is set. This is usually done by having the lowest 16 bits store the data to write and the highest 16 bits specify which of the 16 lowest bits should have their value written to the hardware block. The write_enable mask for the channel selection was incorrect because it was just the value shifted by 16 bits, which means it would only ever write bits and never clear them. So e.g. if someone starts a conversion on channel 5, the lowest 4 bits would be 0x5, then starts a conversion on channel 0, it would still be 5. Instead of shifting the value by 16 as the mask, let's use the OR'ing of the appropriate masks shifted by 16. Note that this is not an issue currently because the only SARADCv2 currently supported has a reset defined in its Device Tree, that reset resets the SARADC controller before starting a conversion on a channel. However, this reset is handled as optional by the probe function and thus proper masking should be used in the event an SARADCv2 without a reset ever makes it upstream. Fixes: 757953f8ec69 ("iio: adc: rockchip_saradc: Add support for RK3588") Cc: Quentin Schulz Signed-off-by: Quentin Schulz --- drivers/iio/adc/rockchip_saradc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 2da8d6f3241a..1c0042fbbb54 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -102,12 +102,12 @@ static void rockchip_saradc_start_v2(struct rockchip_saradc *info, int chn) writel_relaxed(0xc, info->regs + SARADC_T_DAS_SOC); writel_relaxed(0x20, info->regs + SARADC_T_PD_SOC); val = FIELD_PREP(SARADC2_EN_END_INT, 1); - val |= val << 16; + val |= SARADC2_EN_END_INT << 16; writel_relaxed(val, info->regs + SARADC2_END_INT_EN); val = FIELD_PREP(SARADC2_START, 1) | FIELD_PREP(SARADC2_SINGLE_MODE, 1) | FIELD_PREP(SARADC2_CONV_CHANNELS, chn); - val |= val << 16; + val |= (SARADC2_START | SARADC2_SINGLE_MODE | SARADC2_CONV_CHANNELS) << 16; writel(val, info->regs + SARADC2_CONV_CON); } -- 2.43.2