Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp823284rbd; Fri, 23 Feb 2024 04:54:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHZcWfADW/CDMn9pzdrIKk/NAu5A9EMRux9bQIuzpLHXOGLsyae+pjdip1bYB/bsFkGQOcC1P5jqrcL59tHKGBJorJ1eEBGJDObgy3xw== X-Google-Smtp-Source: AGHT+IEcDYmINBDd+PoiaEcVYFRpdLqUn7fsGarl+YnSWqkZ6ycKTKSGGw4VE8UwGeyZTb3jZO0U X-Received: by 2002:a17:906:7f94:b0:a3e:e83b:10a4 with SMTP id f20-20020a1709067f9400b00a3ee83b10a4mr1219666ejr.44.1708692866165; Fri, 23 Feb 2024 04:54:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708692866; cv=pass; d=google.com; s=arc-20160816; b=AlHVA8bc32NnbRj75XXRdCMYtQG2M43vTBLf7kf52pzKzldAA0Vr0z2QYFaSprRFZk Fzz0xHbwOXyp1uC4jeVaE8V5ok3+6S610am0/jRbk+hNv21VFrwhg9Koin0DAWgIGvqI c/Rx6R7OtN06GqqMUWfhjS+fUodDYKeRLHvewpkqlZLJZYTHuFT0y/VP/t9K5uPyb8G1 2vtjYWjndcodAy+5A9UW0RoWa1/qZd53zVqDxXRAsz0ARnRsKyU8nrkUYhdEvOe4epA8 jfJgEYKoPkxmO+RR7SAh+ktNp+7T34AudFa1pJ9MQjOKGthCyqi3kXfFLonNwHTXuIH5 tNYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from; bh=IlAbL3M7In57VWeJo7qdj1nSBuK3AiK3k5dyDpHP+qk=; fh=4Ejxir7Asd0PGBlxwH+sBJkQn6ICEtx02wHM8aXm5mM=; b=eAN4le1aagAeb73jzQpN6ONUEec7RwgnBICMCmfB2CuF7oV/CF/pXLUuGH+AUdzPOj ulUZLGq3Rcnmj7UWObZCxSKDbCchFJsW6NvV1q2hG9hIFViBSi43dyaHF0W0FuM2+fSh QGMVB+tNWVvm/i7E2D05ekAGlMUHvmopnLt5MVdsXqugeJssm9Ky+fKbdDKgcuiPh/Hy YbpA7b4BkQLoRegKSgd4vXiC/51RnHK1F9ReK4sta5C8wL5/fO+cPWpCYUPofO6zuSmx YTN2wtxw3vXftIBK1trySHcQJMSUYzjnsMOYKolyMsrtich/wBqBRjiDg3gxT9YF1IuK YcRw==; 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-78331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78331-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gs17-20020a1709072d1100b00a3f59fc4c32si1968149ejc.973.2024.02.23.04.54.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 04:54:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=0leil.net); spf=pass (google.com: domain of linux-kernel+bounces-78331-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78331-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E8A581F21BB0 for ; Fri, 23 Feb 2024 12:54:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 270087CF2D; Fri, 23 Feb 2024 12:54:19 +0000 (UTC) Received: from smtp-8fab.mail.infomaniak.ch (smtp-8fab.mail.infomaniak.ch [83.166.143.171]) (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 BC13063104 for ; Fri, 23 Feb 2024 12:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708692858; cv=none; b=g3yD7FdnfGMzjdiiJgmPkty9dfGcY/ZgYJqGadyey57GGUo4cYCw8uHOLupOju6sHoT6XfGPBLN4bNd4Dexl77jwt1azjuzg/TxxR0bvkhTTbLUBvj5ctsYRvataqj1mpGJIbbNQ1Ax66K3jdGX8Vdq7G4193xGFuxnZIWPV9JQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708692858; c=relaxed/simple; bh=G7JhRkmmJzhTv/nbROWOJ+QozMPIQrIGjBMDxlq8nVw=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=atxcb1tSY5SkkGvZuCHU5F2qVRso89kV8k1WZzkEkCJXnfyorGDZy+fHuenDgc46SAvaZfX6FHOhuAda3SQS3d7MkIed77p7vDZSKtgfoGVtfICz41bPzj5HUT5Ma/skJC3puh0MugYgggRowV3Zq68ZSUgyWtRlZZvRwOwu2E8= 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=83.166.143.171 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 4Th8rS6rJ3z5mK; Fri, 23 Feb 2024 13:46:00 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4Th8rR5kDjzyKs; Fri, 23 Feb 2024 13:45:59 +0100 (CET) From: Quentin Schulz Subject: [PATCH 0/3] iio: adc: rockchip_saradc: fix bitmasking and remove custom logic for getting reset Date: Fri, 23 Feb 2024 13:45:20 +0100 Message-Id: <20240223-saradcv2-chan-mask-v1-0-84b06a0f623a@theobroma-systems.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="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAGGT2GUC/x2M2wpAUBAAf0X7bItlhV+RhxOLTS6drZOSf3d4n KaZG0y8ikGb3OAlqOmxR8jTBIbF7bOgjpGBMiozIkJz3o1DIPw0bs5W5KbgmuuKiSuI4ell0uu fdv3zvF0lV5dkAAAA 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 The mask for the channel selection is incorrect as it's specified to be 16b wide by is actually only 4. Also, the 16 lower bits in the SARADC_CONV_CON register are write protected. Whatever their value is can only be written to the hardware block if their associated bit in the higher 16 bits is set. Considering that the channel bitmask is 4b wide but that we can write e.g. 0 in there, we shouldn't use the value shifted by 16 as a mask but rather the bitmask for that value shifted by 16. This is currently NOT an issue because the only SoC with SARADCv2 IP is the RK3588 which has a reset defined in the SoC DTSI. When that is the case, the reset is asserted before every channel conversion is started. This means the registers are reset so effectively, we do not need to write zeros so the wrong mask still works because where we should be writing zeroes, there are already zeroes. However, let's fix this in case there comes a day there's an SoC which doesn't require to reset the controller before every channel conversion is started. Lastly, let's use the appropriate function from the reset subsystem for getting an optional exclusive reset instead of rolling out our own logic. Those three patches should not be changing any behavior. Signed-off-by: Quentin Schulz --- Quentin Schulz (3): iio: adc: rockchip_saradc: fix bitmask for channels on SARADCv2 iio: adc: rockchip_saradc: use mask for write_enable bitfield iio: adc: rockchip_saradc: replace custom logic with devm_reset_control_get_optional_exclusive drivers/iio/adc/rockchip_saradc.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) --- base-commit: 39133352cbed6626956d38ed72012f49b0421e7b change-id: 20240222-saradcv2-chan-mask-593585865256 Best regards, -- Quentin Schulz