From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A4F12429838; Tue, 5 May 2026 12:35:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984509; cv=none; b=owQiSu8KH9DWQilTcBqMVQwySBMSDRc1XJB69WYEKgdvPXArHSuN6CTL92gbk5Hoj2S0gWxsX+/HUMDeA7fcqAT/HquF3y1MWV9gmttt3dS3R/hFLGt4TJ5+4tb4cQkYGiZV94rh2GqL0kkSlVTz/IYzs4r9ZII73pciJ+mdCRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777984509; c=relaxed/simple; bh=NV+pb6nkEs/Kb/1eTRMnTHalM7wi/b80qqdCmx/U20E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KYAOH4YMLokpfhM6aQY2Mc8ajOsrnedqFFmcXuAK9jyD9jGFjkgILi54xI1av5GAsy7q9+ZYJtUBmUWul5kkngr7fMy79dIagydDh9ZopcZW0IqJPG8e6gPQcjMbknoXdeMMaWhbXB+WHbHZ5U7ClpN8cwqyFqm4v8v3zpEnDgU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mLDMsUZZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mLDMsUZZ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 59B02C2BCB9; Tue, 5 May 2026 12:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777984509; bh=NV+pb6nkEs/Kb/1eTRMnTHalM7wi/b80qqdCmx/U20E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=mLDMsUZZaGXMwGsKVPCnoX0FlGIEb1em87O94TPamIF6TwPgqSEsJhwm2nLBUf0sS ebdg90rUvzHLLHHWKYWqVrnww95lGtCbLJucY1lt8awD+ryo8eSS0+0bV0YNGdxQpf i7Hd4QsUsxk4M7vw1afF7HBIm0mHp4RPvVH3Euj4L711TeLTmMOF+5WtYSDCVJw3bN vnto4k7bLv9rLrehibijE+vctHL0PBwdRVuJBpCZMi4ZXLl+CzMHRw63zIzVXgnahh zAOyfcTV37tgzoQDy6b9SxVK3xRB2+LboV21GER3b3lS4ZvXQb8f/ruUUUvZHmUmH6 9seMMUnCsfQVQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AC73CD3427; Tue, 5 May 2026 12:35:09 +0000 (UTC) From: Rodrigo Alencar via B4 Relay Date: Tue, 05 May 2026 13:35:02 +0100 Subject: [PATCH v6 01/12] iio: dac: ad5686: fix ref bit initialization for single-channel parts Precedence: bulk X-Mailing-List: linux-iio@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: <20260505-ad5686-fixes-v6-1-c2d5f7be32be@analog.com> References: <20260505-ad5686-fixes-v6-0-c2d5f7be32be@analog.com> In-Reply-To: <20260505-ad5686-fixes-v6-0-c2d5f7be32be@analog.com> To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Stefan Popa , Jonathan Cameron , Greg Kroah-Hartman , Michael Auchter , Jonathan Cameron Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Andy Shevchenko , Rodrigo Alencar , Andy Shevchenko X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777984508; l=1845; i=rodrigo.alencar@analog.com; s=default; h=from:subject:message-id; bh=ACFFNXIkeDLRrCLvd6fNW7RHjZhA5Kd+3kUIKJGbV70=; b=lTc+PRrdexnrVIlOSr0WT/Zwf+J50znwiEsUa1WpEAI5/Ez0edcmrR0wIOIAYsKM3nPEm35hB PNFtzqikA+eCNtegROlYWidCKkLakm1RYhzyuJY3bj0On6NX6WpJEzS X-Developer-Key: i=rodrigo.alencar@analog.com; a=ed25519; pk=ULeHbgU/OYh/PG/4anHDfLgldFItQHAhOktYRVLMFRo= X-Endpoint-Received: by B4 Relay for rodrigo.alencar@analog.com/default with auth_id=561 X-Original-From: Rodrigo Alencar Reply-To: rodrigo.alencar@analog.com From: Rodrigo Alencar The reference bit position was ignored when writing the register at the probe() function (!!val was used). When such bit is 1, internal voltage reference is disabled so that an external one can be used. For multi-channel devices, bit 0 of the Internal Reference Setup command behaves the same way, so AD5686_REF_BIT_MSK is created. The issue exists since support for single-channel devices were first introduced. Fixes: be1b24d24541 ("iio:dac:ad5686: Add AD5691R/AD5692R/AD5693/AD5693R support") Reviewed-by: Andy Shevchenko Signed-off-by: Rodrigo Alencar --- drivers/iio/dac/ad5686.c | 6 +++--- drivers/iio/dac/ad5686.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 9a384c50929b..1fc54c38b629 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -511,7 +511,7 @@ int ad5686_probe(struct device *dev, break; case AD5686_REGMAP: cmd = AD5686_CMD_INTERNAL_REFER_SETUP; - ref_bit_msk = 0; + ref_bit_msk = AD5686_REF_BIT_MSK; break; case AD5693_REGMAP: cmd = AD5686_CMD_CONTROL_REG; @@ -522,9 +522,9 @@ int ad5686_probe(struct device *dev, return -EINVAL; } - val = (has_external_vref | ref_bit_msk); + val = has_external_vref ? ref_bit_msk : 0; - ret = st->write(st, cmd, 0, !!val); + ret = st->write(st, cmd, 0, val); if (ret) return ret; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index e7d36bae3e59..36e16c5c4581 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -46,6 +46,7 @@ #define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) +#define AD5686_REF_BIT_MSK BIT(0) #define AD5693_REF_BIT_MSK BIT(12) /** -- 2.43.0