From patchwork Wed Jan 8 17:29:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931406 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DA301F2C5D for ; Wed, 8 Jan 2025 17:30:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357435; cv=none; b=D4Gw+t91FpQQDlIB3h/XAgYg0kuukpMY7OGS64pGRQzU8nlNsyA6SywbT95V/7ZqUFKmSEbJPWmzf+jxdiw65Prw9hcPbfE3ks9eF8RYBddgTr3/jWT6K4USltuenTbEvksSVUWyXBqHxESkGVALSV06nRjiOgAI6XzXXLP9tcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357435; c=relaxed/simple; bh=Evy5a08Q4IXyCPvxw1bhzoqYCioL8eNF759RXajKvAk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EDbOddVo18LSdja9p+l8iFVPVa0GhKKh3Z1lGhI15jKJR6iqg+vMDkcgDnnAp1ACWbw/9R7BkwWsnuF/6ccbXWRQlt+Xokzo+BG692DxTOWzN44uCHV+mCpQuVTh8Bl1Tn08gda4Cz/j0MMxo+KprJVUdD3bvqx6U37edB6Hfa8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=H4nT60Fc; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="H4nT60Fc" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-385dece873cso27261f8f.0 for ; Wed, 08 Jan 2025 09:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357432; x=1736962232; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=MISweJ7mhpf3vsy2x6Aiv1b3ZxOcL3WBro7kZl0BFxk=; b=H4nT60FcxFbPJ+o2W2BZbnCUbmDX0a9vZNUxrguCctO1zNjrGnkIDoqNP9ptUs9Zke gUNwSLmgjpFijmyCFZhkCdeGnveaArZR/hXHr6BqC8hSlNqlBzNcis9Mk8vDPBMWIBkK RjAwZ5KR3zSU/kyNNbrJETcWfs/nKCt+bKVu30J3sgO8vrSq7ZB6MCaP/X5G0DlihBIS CLJ4MWqcFIa6h/7eazvJ9veoD8r3akP38r/+kuEXI0v276+aqjCjGm28b9/4L7KidHa0 rOBBewmuB+cAAYbcxZQuFFpyQDkGO19w1Xzh0xjNTGHkjt/h2ZK3KjLwECWJKYkfAPi1 H1Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357432; x=1736962232; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MISweJ7mhpf3vsy2x6Aiv1b3ZxOcL3WBro7kZl0BFxk=; b=t9TfI21b/8quggnAbagdAfriWqFOVu4hfTFueGmBMdMIsPpiHPB33czpnhYqscCNIu liuoA07Ohc9+mZ+eQmuHtKoCNWQ3yc9mJih1PJTSfEtLq/dlnzPYHclGz3x3G8L0OODp 3y9PURxT/+eNM0c6rOFUMVYwvw0vzfXr730hjO3y9OhI6snSUE38a20sTVocLncrkYDR PUdYHR9+69tnl+JShYSWE59MkQfWuoi9eseJC7Q3is024bhv9ubeE1PV+uGDzJ5dJ33Y McHCXzp06KZSdb79jyQd3ejq9mRnpRb0tuUR5O4imqdQP6cmamMUnJYJ/R86lGoA+r4b ocwg== X-Forwarded-Encrypted: i=1; AJvYcCUGuTvsqIeEjxdcA77C8iTIrZXB7TlNJKwmzlsf/9K1Bqm5k4ari6awMv2oz+FbjOEn7VSX4UhDmeU=@vger.kernel.org X-Gm-Message-State: AOJu0Yxq7d/NOazFPdbswIP035aKei9RYmnXDdYz3r8mH9BQIO89GPS3 YQmE0GISG3Xrx0Ws5iVWiG6ekE5foA0g0+6IlvjMHuD1O7XCIbsyu92oKoOidkg= X-Gm-Gg: ASbGncvPIZGXUybZ/Y4xErdbUHI4m2Ai11u2oRT2Gztvnwx0uHTF26ehbW/88F7+uUl 0lno1wKt9K1rRiTqrf+ErC2pE+Q3v6oqeAlx90UE1zfOgIv56V/+/22tRlt/m3Npnh63EISvB0D lhm63fKx7GkqcG5g/ia4rTXea1pSE6HrH0DkbtmBu/NWzSJsCYeRDHlGY2+5Rf1amRQUEpqcmHP ZyVirYqy5xQWWcOC4xUJqQqp5J9BqbryWbBUfSjaMKDdXCoeGCbVOIEplk= X-Google-Smtp-Source: AGHT+IHDamTzJpW3qPznX5EYK5GRfDPlH2hpAKWLJ73AVRWe7y5yhqi8Rjxz3mXkBuFV8JrxR91qGw== X-Received: by 2002:a5d:648a:0:b0:38a:4b8a:e47d with SMTP id ffacd0b85a97d-38a8730ac0emr2930329f8f.26.1736357431699; Wed, 08 Jan 2025 09:30:31 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:31 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:15 +0100 Subject: [PATCH v2 1/9] iio: dac: ad3552r-common: fix ad3541/2r ranges Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-1-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Fix ad3541/2r voltage ranges to be as per ad3542r datasheet, rev. C, table 38 (page 57). The wrong ad354xr ranges was generating erroneous Vpp output. In more details: - fix wrong number of ranges, they are 5 ranges, not 6, - remove non-existent 0-3V range, - adjust order, since ad3552r_find_range() get a wrong index, producing a wrong Vpp as output. Retested all the ranges on real hardware, EVALAD3542RFMCZ: adi,output-range-microvolt (fdt): <(000000) (2500000)>; ok (Rfbx1, switch 10) <(000000) (5000000)>; ok (Rfbx1, switch 10) <(000000) (10000000)>; ok (Rfbx1, switch 10) <(-5000000) (5000000)>; ok (Rfbx2, switch +/- 5) <(-2500000) (7500000)>; ok (Rfbx2, switch -2.5/7.5) Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support") Signed-off-by: Angelo Dureghello Reviewed-by: David Lechner --- drivers/iio/dac/ad3552r-common.c | 5 ++--- drivers/iio/dac/ad3552r.h | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/dac/ad3552r-common.c b/drivers/iio/dac/ad3552r-common.c index 0f495df2e5ce..03e0864f5084 100644 --- a/drivers/iio/dac/ad3552r-common.c +++ b/drivers/iio/dac/ad3552r-common.c @@ -22,11 +22,10 @@ EXPORT_SYMBOL_NS_GPL(ad3552r_ch_ranges, "IIO_AD3552R"); const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = { [AD3542R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 }, - [AD3542R_CH_OUTPUT_RANGE_0__3V] = { 0, 3000 }, [AD3542R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 }, [AD3542R_CH_OUTPUT_RANGE_0__10V] = { 0, 10000 }, - [AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 }, - [AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 } + [AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 }, + [AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 } }; EXPORT_SYMBOL_NS_GPL(ad3542r_ch_ranges, "IIO_AD3552R"); diff --git a/drivers/iio/dac/ad3552r.h b/drivers/iio/dac/ad3552r.h index fd5a3dfd1d1c..4b5581039ae9 100644 --- a/drivers/iio/dac/ad3552r.h +++ b/drivers/iio/dac/ad3552r.h @@ -131,7 +131,7 @@ #define AD3552R_CH1_ACTIVE BIT(1) #define AD3552R_MAX_RANGES 5 -#define AD3542R_MAX_RANGES 6 +#define AD3542R_MAX_RANGES 5 #define AD3552R_QUAD_SPI 2 extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2]; @@ -189,16 +189,14 @@ enum ad3552r_ch_vref_select { enum ad3542r_ch_output_range { /* Range from 0 V to 2.5 V. Requires Rfb1x connection */ AD3542R_CH_OUTPUT_RANGE_0__2P5V, - /* Range from 0 V to 3 V. Requires Rfb1x connection */ - AD3542R_CH_OUTPUT_RANGE_0__3V, /* Range from 0 V to 5 V. Requires Rfb1x connection */ AD3542R_CH_OUTPUT_RANGE_0__5V, /* Range from 0 V to 10 V. Requires Rfb2x connection */ AD3542R_CH_OUTPUT_RANGE_0__10V, - /* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */ - AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V, /* Range from -5 V to 5 V. Requires Rfb2x connection */ AD3542R_CH_OUTPUT_RANGE_NEG_5__5V, + /* Range from -2.5 V to 7.5 V. Requires Rfb2x connection */ + AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V, }; enum ad3552r_ch_output_range { From patchwork Wed Jan 8 17:29:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931407 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E618B1FF7D5 for ; Wed, 8 Jan 2025 17:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357436; cv=none; b=mabdElCrdKMLmTx/RoGeha7LIfqRj2MLYxGzl15dKne/6YLYz5UpYA/8c8j2Nk4YvRYuzRDEUECKhOxLdaAwWMwxUryC+5NX1Nk0uB/OjtUSTJwYA6ptHkhFtoYUpn3y21zFANAb6TclwdQelCzH2iazuocqqfoLnmm60cp/UHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357436; c=relaxed/simple; bh=nZkRgILfPdhIXSsrXa+Y4ye1ieetO/26xbBu55cEnj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VQnnKdL6mCdRd/zdv6+KWx65C1KItJR6YQugSDx8ldG1F6Bd2EhkYxJuV9z8xT3tOOILXhz73jQwqMyMSrYq1StdYkgOurdAAkmQSctYZSsRgCpxW+3htKhEgpnj6hfCSKyclRf0RI/HmwgchrZw1X/GFhZU/s3mJs6SU0y1JQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cOfhaBSy; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cOfhaBSy" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385d7f19f20so18767f8f.1 for ; Wed, 08 Jan 2025 09:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357433; x=1736962233; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ogqDcmpodmDQ/q56quzP/HOrrjeT0i3lFvLbU+LwsSM=; b=cOfhaBSyz2NE6KVX8ISHqWIz1OSfK9bg0x9FBQBk4Rs6xIASP7Map9QimXBni+uw3W EEIOgyoecLpRonqxNXqw3gWoN+jqKhVIJ9sKqyYLuFw3+FYXyPw6U+59SxzenlA80hqZ 45blMQPrt1W29yy51P2gAL0nipMSN46occH/0c7bID7EQeiyDoOnJYfr57koguzoxl1S iefSqScbxOyA81St+0hQ6UAQmwJ6bN3pfU8pJ5+Ud3B3fRncI1keDwI9mHl+3tipPBnN kzwnUtGdaTNRZuMDpVuMedXqblAEMSMnZU49sfXb9eP45ffAgghbbxglXxxeF7lEuXbX U8tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357433; x=1736962233; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ogqDcmpodmDQ/q56quzP/HOrrjeT0i3lFvLbU+LwsSM=; b=s4X/Of+GagzozefTUVZ/8pHVKBeIUT4SKCCMIxD+wze8khYff8BK2TsVMiz797ZyTe cX34/UaIlr+YmQhy4LsMhmimNwbwWk7u28ARtEayymT/NTOYtOB2DCzduAr7fDJbVitu IUmRbogODrvdOhXKfeDvAb6SYFG6k3kyvBz3AagwNMtiZnbECXtvSK0Q87UBt/7Davez ntb1tDvYQ4vZwG6idDtLDGkKvA3+sjYVD/eySjUKN1ahnl1Hqx990AvbG8ZYamtDRfVM A1jOhTC+kaSJclpAi1x0HuKmSqWQl0F6XM5BaWuZ+fzqUxVQxqxrXVt3ijbVyZEjkfJA 2IYQ== X-Forwarded-Encrypted: i=1; AJvYcCUF8FN8+hlIsyD9/3LfbQb9nAjAmgFr1njViqGQIRAKFTCcTOysV3ILrlljVwgzGy1cUFXMD5eNePw=@vger.kernel.org X-Gm-Message-State: AOJu0Yzt85VkQ7CMJ0pjj1hRALSqzHoz00vENwY9E79R9LxhNw80yGaP ibsBL9paTkg3LE9rYKxHYJ5IDp7rOfiwEPtfJ2s/3B1IIWtm82KPsqbYz3lw2Nw= X-Gm-Gg: ASbGncsxmQJp1FUOhlmO/aRoD+BupMNN5cMezidi8QOAq9UGJel3qdGvv/MrfENApqn OzKX7Y3hE9c6imxDXIia9tZkBFjLIO9Y6bSFrMLa8RFENynLWUG0t7JMcDUB001yR5b381cCPsi LhIL0TX2VDeCnNaLUr3lEYNwjj9JA9ZAHmHwsUkW3Q+KTBiEgZK5N3gr+dfhru7ImOVZKrZSCL8 czVgAeVCUDqrnOYeKGY+ARoO3lfQawvNPZqoPDteeSMFbxOzzBQsnWE1oE= X-Google-Smtp-Source: AGHT+IHcmhJGXkysxn7bW+xCJxZmZYHBYQ+uQ9YZk1VUxnFMsUr5DpBd/e0GMjIuxB1CvtGZSm6LXw== X-Received: by 2002:a05:6000:144a:b0:385:fc70:832 with SMTP id ffacd0b85a97d-38a87303cacmr3138373f8f.16.1736357433088; Wed, 08 Jan 2025 09:30:33 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:32 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:16 +0100 Subject: [PATCH v2 2/9] iio: dac: ad3552r-hs: clear reset status flag Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-2-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Clear reset status flag, to keep error status register clean after reset (ad3552r manual, rev B table 38). Reset error flag was left to 1, so debugging registers, the "Error Status Register" was dirty (0x01). It is important to clear this bit, so if there is any reset event over normal working mode, it is possible to detect it. Fixes: 0b4d9fe58be8 ("iio: dac: ad3552r: add high-speed platform driver") Signed-off-by: Angelo Dureghello Reviewed-by: David Lechner --- drivers/iio/dac/ad3552r-hs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 216c634f3eaf..8974df625670 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -329,6 +329,12 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) dev_info(st->dev, "Chip ID error. Expected 0x%x, Read 0x%x\n", AD3552R_ID, id); + /* Clear reset error flag, see ad3552r manual, rev B table 38. */ + ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS, + AD3552R_MASK_RESET_STATUS, 1); + if (ret) + return ret; + ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_SH_REFERENCE_CONFIG, 0, 1); From patchwork Wed Jan 8 17:29:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931408 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6759B201015 for ; Wed, 8 Jan 2025 17:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357438; cv=none; b=MlG/xYFT2yxNVQKV5japYMSQOlpKYYpJ+dzoO8xkqBqs/z4z+9/FeZjLltDuz4uMzbS41PBlRCqO8DhRbDYgxDITrabHu3Up0Sit8WnIjUXCka1JK9NsICPsMgQtoKp/nJBXCDlniedqxiIXcEF1ZQmSf3hTE0Pvw1YlRLl8TiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357438; c=relaxed/simple; bh=+lZHZ4OM8rTY/dhezSlahZGVnk6ol0FvguLhf0YmUqs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bn/u48SfzYccrYE6GhB2lZKTjYl9QjdBCIwpRH3YwWLJIycOUUBdLEq5nVAzs7a0ZloIsW60dSNPTV3IgdSbrJgbfXzS0n4wVFR3c1ppY0xIWwJq/LiiVvdir6QUBH7AhSjJSzBIB6ohZW23ROHpyn+ntWCmWUT2eubrouPWcd8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=QB8ttpc9; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="QB8ttpc9" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-385eed29d17so25111f8f.0 for ; Wed, 08 Jan 2025 09:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357435; x=1736962235; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xfrMkIY9tbM1sPwHCNYu/jKLHOMpHgwU9OMNQ7g5My0=; b=QB8ttpc9lu5kIPW9y5IGzWfWIaxC4JQzHb63R6JpfCAEKIGO6c4DvBWKYnY5biJ+aq NSlFi54pPO6YZg7HqLGrHTASLkab6A/hW+YgCGX8MpGr2jk42nKwdFbDpUhughsl2pfT yAOdypOo2JPocecoo9FhJWUU+2sDvEKfAUCZLKYZa1NjaFPRItvRouJhuzS12s06jQpq +WyUAfWzFKhLGTdw3+TFKIWlGmVLe+wn0VxIIILYjopzaswt1SGUpRl6hhGAq0jBuIso 97hSfVc75ensKGDGJoP4lROmgaC4Tuv5rGhjZOUkCTZXHfCwSz61Xx8/3qX1zGilPQK7 E1/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357435; x=1736962235; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xfrMkIY9tbM1sPwHCNYu/jKLHOMpHgwU9OMNQ7g5My0=; b=aY6ykoUxD43USLxu3M/57F0PRe+SYDhc7CW/EJVpd9RR4JG10Th2maQCrWMaI6rW2k UUmzzJyIZlWp2dvZ6GzMQy4aUgbEDaoSzeqUVRWI5JHtjRMAOEHfVDoweC0jRbPfDYZJ 80gLhNf2r9jggyAG1BpOpLSiXPnXBQrwPOxokYa5DrjDGGXEU5VyudGQjFZxafexdMKM KzmMP/XBIiUTW4Aeo9sSQJMXPbDE9Tm/F4u0swjAHKM0/eubcOYNXQSZg8UU3YNAZJ84 NnyTdKfEJpSqnW5Jg/7dw+I3uj+ePP+yvGI8K+/LkHTyrFgDgVHBvOoQW5U5B9jl2bEv sEOw== X-Forwarded-Encrypted: i=1; AJvYcCX64ALuhxdpSfKXOD8MHXOzZNqiCvKLH6/gYowqktROSidfuY+xJshejRREQS9tv+fC6R5WBgk1B5A=@vger.kernel.org X-Gm-Message-State: AOJu0YwwfoJVLyPuWiK8cvYPgjMaXKuqnWnn/QjHHpcSz09DjbQt/1ZV An2ES/SwGfwkiexNhD1Fv/PKbbOCDB0SMVcLraKkfOnqNKVYquimkrq/uw3U8Rg= X-Gm-Gg: ASbGncu0ulrODr1cmddkkSoqtCmig2p7cQzYvlRdwr7ImC2VHohBmfjZ7e/i82S5XWA FIlldgYMGlzBn7MSamBP0Ip4b2J75TB28XyyMP0g3J6lFhYV2oKmC5owKDvmC52VR4U3fJ7MFLj v7f5dU5fCTfK2ZxBuW57XrMDygbI8yuFl4bEZ6z+xH9wDLxSZyVLZv7JHLVG3H5XW79xv8RBSs7 7LFoE9VS2fuzZ2vNwWuC5ZRRlpB5qnRqiW4LZAwpnHSu0dMtQFa/8gjkwg= X-Google-Smtp-Source: AGHT+IH4qbFI51oPuAFstB6iigZ7tk+yDzWm7fy62GK+mJysZx+iajrKN/1HnJeyNn4/bidfamGMWw== X-Received: by 2002:a05:6000:1f8d:b0:385:f6c7:90c6 with SMTP id ffacd0b85a97d-38a8730687emr3515425f8f.20.1736357434494; Wed, 08 Jan 2025 09:30:34 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:33 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:17 +0100 Subject: [PATCH v2 3/9] iio: dac: adi-axi-dac: modify stream enable Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-3-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Change suggested from the AXI HDL team, modify the function axi_dac_data_stream_enable() to check for interface busy, to avoid possible issues when starting the stream. Fixes: e61d7178429a ("iio: dac: adi-axi-dac: extend features") Signed-off-by: Angelo Dureghello --- drivers/iio/dac/adi-axi-dac.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index b143f7ed6847..d02eb535b648 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -585,6 +585,17 @@ static int axi_dac_ddr_disable(struct iio_backend *back) static int axi_dac_data_stream_enable(struct iio_backend *back) { struct axi_dac_state *st = iio_backend_get_priv(back); + int ret, val; + + ret = regmap_read_poll_timeout(st->regmap, + AXI_DAC_UI_STATUS_REG, val, + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, val) == 0, + 10, 100 * KILO); + if (ret) { + if (ret == -ETIMEDOUT) + dev_err(st->dev, "AXI read timeout\n"); + return ret; + } return regmap_set_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG, AXI_DAC_CUSTOM_CTRL_STREAM_ENABLE); From patchwork Wed Jan 8 17:29:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931409 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F6452010E5 for ; Wed, 8 Jan 2025 17:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357439; cv=none; b=jxIrAXdcGT29OQH/A6oujhZRGRW/Qt8Ma4h47/z5UEs6GJPdVvRPZIMCqIYUVJyp6KTDHANLxKsre3Y1svEVrz7h3mkzoZrSynJn2JA6Q6DtO3006EYJrtN/gdaFPWzO2weh55ZUi6sQHhvJJg4jZkP4yRWD59X8GnvJ/4aTbpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357439; c=relaxed/simple; bh=XfnaLwPbwvEvqLzRap/jhDwdzzaCiSDrFwR+woVVJDc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G1IWXm8yYNI2aa/SsAWTknbcdUYlZhyJvt8ju3wcKWcYB76oRoDeg2DUay9CFzQndrQrYBdX9nTBo0c5Kd1MvZD1hIhLHwXKkocNtwRaVHkWch5HvNBfPqZxf3kbnKz5lr7MxqXPUxuCJ/MmbhPsUiB7UstDg/4sVBgC7BRVuwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=e0A3ZUXs; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="e0A3ZUXs" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3862d161947so8220f8f.3 for ; Wed, 08 Jan 2025 09:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357436; x=1736962236; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4FQcFBx5V6lkdkVoqAqgUJ0fqMpy++8oGzKM6couGQY=; b=e0A3ZUXsdRCigPCDpEehbVPj2edMD7Lj0pw4dVJXADJ9JCXSMSLQXZBbdVSZgFA4Kk OuEEHaNm7Ls1xsUDgIWoUOH/CyLRQLXK/7NxQpMc9rbj0NMvuCTqwgmFJTp+fYt8ayQp OoKE3Los04hj1sbyd6MWXILVh51bXz5g3+TIo6y3Cf/7SZfLaTTM7HWC3lEDiO8GShLk 5j+RJvBEachfHrrYDsYUIfQ6QxRsQR6EeGt8oJxgHVCa2a/ysGbDRqBEVpKpbE44Xdlv jVEvjvyc92DLHM4kufqAEJK+e3XNoD6uasVx4TkhCBSDfBGuHxfzhSqr7Rhkf/fcwQSN zagg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357436; x=1736962236; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4FQcFBx5V6lkdkVoqAqgUJ0fqMpy++8oGzKM6couGQY=; b=OjzUEgCeqt2dxiXb7YFAJ7cWjMPFOFx2omRzFPRdBcFeqp2yHAgOv+xzui9YpERvLe qvcMvgwPYFGz1B4bF9Fs/gq4PMLSMCZvONZ5X1nutyqHanV+LRFdt8zHjlhe6J6t+rRo +JWmI/fFphKZWx8hILLCuj44UqeRbGiSwjtraZqWG4+IyPzK1PUBRYD93EYkdnoRfbC2 VUHdKZYxThODpKRVRW7RaluOKzFEbzNcLDjZP9/k/f3OwpyeV0JAkYLYN3episH0BD4V OyIhDaI6tDWcZe7Xnru3yhl3fhUMTC/4b/H5Mjt49EG7gGeKMNqN08JJiP/Vq6cugpFh 6RMg== X-Forwarded-Encrypted: i=1; AJvYcCWPrKQMMaTrcjTqzEn2QFovms/OjqnSC5QIoj+gJWRM/Q2U1hqCiulduqzu8Yf2k/2VSxEaL83EjuU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzcfr71FXZn8H//p5IXEzJ9LogRwr+cxKqhJVMoWIigu+MNmxSY Y4ItrrTKu8Ncy6m91UeKY7k19FIp7DnneLWBL0JS8Z1qmeAF/LTHTdNsFQ7C0+E= X-Gm-Gg: ASbGncsRT0ci0Znv8kJrGp64WosNoDniZZHiq6Ay61mbxR+WoQE9L4qMdpEN9RYT6SF MoQW+117XYsfiCGXD/0fz57AGFj8Bf2ccFhKpQVuxH/fXiZQQILcJUdP1eWnnO4nElRO3EWb5Vi afsbo+QNha1YRqi7LM0TQyyyzdmVlKKMwYZKTuJh/II0YNpM0eHA0WUZsVeqPdCHut3HREh0s13 eb/hkc5tJri217eT5z8yF/febiS9kbUCR/953kPoK5/y9I39DEPVk8+CN0= X-Google-Smtp-Source: AGHT+IGgfxt16ev6MsDtJ/+I4o/+V+kvxrkDi2iioXLqcSIuCoTFprBTGUC4euEkcvZinBrYpakpsg== X-Received: by 2002:a05:6000:4102:b0:38a:8afe:9530 with SMTP id ffacd0b85a97d-38a8afe9557mr194371f8f.33.1736357436006; Wed, 08 Jan 2025 09:30:36 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:35 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:18 +0100 Subject: [PATCH v2 4/9] iio: dac: adi-axi-dac: add bus mode setup Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-4-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello The ad354xr requires DSPI mode (2 data lanes) to work in buffering mode, so backend needs to allow a mode selection between: SPI (entire ad35xxr family), DSPI (ad354xr), QSPI (ad355xr). Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.h | 8 ++++++++ drivers/iio/dac/adi-axi-dac.c | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad3552r-hs.h b/drivers/iio/dac/ad3552r-hs.h index 724261d38dea..4a9e35234124 100644 --- a/drivers/iio/dac/ad3552r-hs.h +++ b/drivers/iio/dac/ad3552r-hs.h @@ -8,11 +8,19 @@ struct iio_backend; +enum ad3552r_io_mode { + AD3552R_IO_MODE_SPI, + AD3552R_IO_MODE_DSPI, + AD3552R_IO_MODE_QSPI, +}; + struct ad3552r_hs_platform_data { int (*bus_reg_read)(struct iio_backend *back, u32 reg, u32 *val, size_t data_size); int (*bus_reg_write)(struct iio_backend *back, u32 reg, u32 val, size_t data_size); + int (*bus_set_io_mode)(struct iio_backend *back, + enum ad3552r_io_mode mode); u32 bus_sample_data_clock_hz; }; diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index d02eb535b648..79ca158c1ad9 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -64,7 +64,7 @@ #define AXI_DAC_UI_STATUS_IF_BUSY BIT(4) #define AXI_DAC_CUSTOM_CTRL_REG 0x008C #define AXI_DAC_CUSTOM_CTRL_ADDRESS GENMASK(31, 24) -#define AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER BIT(2) +#define AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE GENMASK(3, 2) #define AXI_DAC_CUSTOM_CTRL_STREAM BIT(1) #define AXI_DAC_CUSTOM_CTRL_TRANSFER_DATA BIT(0) @@ -725,6 +725,29 @@ static int axi_dac_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val, return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val); } +static int axi_dac_bus_set_io_mode(struct iio_backend *back, + enum ad3552r_io_mode mode) +{ + struct axi_dac_state *st = iio_backend_get_priv(back); + int ival, ret; + + ret = regmap_update_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG, + AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE, + FIELD_PREP(AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE, mode)); + if (ret) + return ret; + + ret = regmap_read_poll_timeout(st->regmap, + AXI_DAC_UI_STATUS_REG, ival, + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, + 10, 100 * KILO); + + if (ret == -ETIMEDOUT) + dev_err(st->dev, "AXI read timeout\n"); + + return ret; +} + static void axi_dac_child_remove(void *data) { platform_device_unregister(data); @@ -736,6 +759,7 @@ static int axi_dac_create_platform_device(struct axi_dac_state *st, struct ad3552r_hs_platform_data pdata = { .bus_reg_read = axi_dac_bus_reg_read, .bus_reg_write = axi_dac_bus_reg_write, + .bus_set_io_mode = axi_dac_bus_set_io_mode, .bus_sample_data_clock_hz = st->dac_clk_rate, }; struct platform_device_info pi = { From patchwork Wed Jan 8 17:29:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931410 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2666201278 for ; Wed, 8 Jan 2025 17:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357441; cv=none; b=E0GvqW+TXxAmuDXZPtn55Oeg4ckjIp2s4tH4iKBqS5O+H5YoGbd8CTM8RZISwyccec119XDTmI83bSV72oYybriV4GS4LFhnCmUfBxRsSA1ciNYl9AcKTvZAr2FgH9mhWZXQJd2VfIBuw2X+B6P9Ph92OkyfQFLkKjScowKaj6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357441; c=relaxed/simple; bh=IuHaI/semL+Hv8JNr40Pmjd0RO8u7Ce4lu8w8B537I0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H4rsIWHHlvTl8f/eDefiJZ2COBhn6dW5vfI5Wz+6GjVqDVBg/9gnaqshZFxhItiladH3w2pLRdp6rf8/FIVXShlBBWnt+CWMRrPJWBjQBqbC9YZ3NgoYeP9unZUecRWvtfzrtHnHISQCJDHNvvMxpYHw1aXnRdKQ2o4skb3IBv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=fl+bbM8v; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="fl+bbM8v" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43623f0c574so657585e9.2 for ; Wed, 08 Jan 2025 09:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357437; x=1736962237; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=szKwztPhzV6CVF/0X9HGbGEX7Uh9TD9UOgptum5XTx8=; b=fl+bbM8vy1Ovyuhzmdz+qTWRxaNY/cD8dPmdfWFomZMLhk/jwr8EsYHhqsJJmEddGg +pKkrqoNcCMbQ7TPMIYnL/vSFIc26aRIIIeCe/Dgk7T+D5/l0vbtGINObG4T+8kqIak0 fhmVedw6qeay4xb5L6LLn90vLHBMdkAeuL80eGXbhq3U89HWoQ9d23vgZLnvrrhc2JaF xforg/F03QKxJzgTYwr+ztEQ5JV4xTNy/lajN6uWhlupF4nXmXgqRAhM3dWQnaWPQrkl NAxff8wINBgrUouEmlP1nZvCwhYwhPvC07oLWM+fBb3Upd7eOYLCTCR3V2e5XM9EyJrE 53iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357437; x=1736962237; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=szKwztPhzV6CVF/0X9HGbGEX7Uh9TD9UOgptum5XTx8=; b=lUED+CGsuamzNDst0/4gbtu2o4KIJgLQCXnVSSQ0ReNdWrdVOR868zarssNaWOFE4J ED9eT0tqge3gSgKPpClIgES/7DSeSj3NpjdBo+0TEcbQuKd4vdvHVzZ7fEYgqf7XaMnJ zbcqO8yIVlGbuvURAWx+1ppPiEQyjaVsuPNU3A+ivMpavOnB5zzQbFqzt94aUmYRQycJ QCKgMm7XuAtAEBjqEbKd6zr6LGx8BJZQx1kETFegmpm3p78kq5/8qM4TOMKVKuyISrFZ /aw1FNMgpHwUqnjRoaRLKjCgtnkYkcm14gLr/4YKZAr2BoWiTm8BsXozz6fvIAEs0yK3 XqqQ== X-Forwarded-Encrypted: i=1; AJvYcCWD9hu20avoQ4Eaacbq5/befH0bQ4fzI43ugeL9d2fvMCLD0h8JSunHfsshhVeKjSR8Gyi0qqEYBaQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwPaj1Tn1lu2984Tnded4kM2hRbPuCmwVO4V8TXVTi+mrfSqr/w ePKrxhVHvYdJ3MIvDOTMvg3xUbbyYDt6+IRLyzdkFZEgM5j4AdBkG8ZCieHb5QQ= X-Gm-Gg: ASbGnctOfiL/FElsZsTf9u0JkGJP5ICa32ZziYOz2l2ZSY7vIVhzn0GGM4E7D15Gv1a l8tygE6PHWhwiSR/XjUwl7TBh5wWEWfDsflfY98AR0nloptKR0lzAIPJNgm7qf7Aogy4sCDfhET CqeyGssAjnOHUJ/ZnkxDBQJoV+GTPiA6FMxktwTJWAzZzgR0+uzwhfHGXsqZvQLgTRKB99lflwX JmoMyXpmmB8FgkCpU6BUR1Db3/4OzVQVuaSpi3JMXIKXWJoFCKx+wxoSYo= X-Google-Smtp-Source: AGHT+IHZQe7bqAuDCWH482pq2vJ7oArvpn5JDt8LHHWBYu8pE/3pqQpPt6ie/yD+qulq+Fw1RO94Lg== X-Received: by 2002:a5d:64eb:0:b0:38a:50fa:d582 with SMTP id ffacd0b85a97d-38a87363364mr2332501f8f.59.1736357437339; Wed, 08 Jan 2025 09:30:37 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:36 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:19 +0100 Subject: [PATCH v2 5/9] iio: dac: ad3552r-hs: fix message on wrong chip id Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-5-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Set a better info message on wrong chip id, fixing the expected value as read from the info struct. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 8974df625670..27949f207d42 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -326,8 +326,9 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) id |= val << 8; if (id != st->model_data->chip_id) - dev_info(st->dev, "Chip ID error. Expected 0x%x, Read 0x%x\n", - AD3552R_ID, id); + dev_info(st->dev, + "Chip ID mismatch, detected 0x%x but expected 0x%x\n", + id, st->model_data->chip_id); /* Clear reset error flag, see ad3552r manual, rev B table 38. */ ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS, From patchwork Wed Jan 8 17:29:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931411 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5DD4202F6D for ; Wed, 8 Jan 2025 17:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357443; cv=none; b=p7ySxjhQbVExWui2f76l59sIM+GtUPCewbQ9cfmevFBfbKnodHvABnIK6ScXi5fO8Dpe2G72noyj6DXQA4MDM7hW1P+C9djQ2ZQLHzIvkT7JzHYvFx0DM83SXVlXQhPAY9aiEHVbluK0WxXDAcL23y9DbOw/+vK3+w5sNZOmdhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357443; c=relaxed/simple; bh=DnAjjx0PkSOieNJ5OJb2nk2Cce0Mvn+naUnXYCUW1PM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=inyVwfR7cY8vWOHmgdjjeJHYkoVcPqLNJoj6vBLqoQ7jQiQM20vAScOXbWdJnyCM/kBqgr7XzBCYqHq1IgeB0zcwfmMd/Z0H8DMecvTv2PIzG6VtuTE6oIFlt6LCuSquf+zSHsz3kI8iO66hjs2h79dRaRg9ieA/mp41m+hK1po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Gp5+FlpH; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Gp5+FlpH" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4361fe642ddso758565e9.2 for ; Wed, 08 Jan 2025 09:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357440; x=1736962240; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qABqYAhj0TrQzJxH7XVarpnbO7+OveXqYM2s3icznC4=; b=Gp5+FlpHJFNF4Iv1xZSRQrMCGxxP96zqrOhsI2nCDVQV/F2fhUcjpqib8XK0zowHCv jnfVioIcJ3MwAb5+dpn2F64Wj++/TmguihzKtLDRrrrgXGK1NT0kd7ad8gC2CRwEBkvK 91rSF/Ur53zPbINWSTxJhRi7CFc/qzsVE21DAllAbn+CZpPkhGdhohnG1EkcWzCUJ9m1 3rSXqdG3+6csNurp9ONIVEGPNiiC7EZJQd60qgA+wxzUEQMOReA2sbW8VUOgTzHzsuGI XuFNUXokkf2xrln0OzfMbzR55Awtcc7tvn/MmRd/+9DHyio+aqpIdX7aAUgurcKKeo2p 1tTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357440; x=1736962240; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qABqYAhj0TrQzJxH7XVarpnbO7+OveXqYM2s3icznC4=; b=mwECWmDZRzBBkE4LSGPIwy0noneV5oONnejc7OZma8c9gRadafoGZn03dASsfNR++q WlLSv09Nrwc1x99u6isEyHsvm31FUdlTliD7l5EUK3XXZP1FiK+OIjboFnnqZWpjGAcM ijBWhVKm3MzndnV+s8yznQqxScMyCV02AzRgKqU7gD+v3t/Nhkavq6rfSJHbairn+m9k PD/GXbN+vpZd7QxuG/Db4orEtBBXwWF1TQExz23TChUaeixOH7yuYLCMfb4O0Bb0DuY9 d/zamUEyqYADnrwFH6Grgi30cEYkP3Nd/Y0l+ZCTMtzDkGHIm9EGD6/xVhzt/6pCHwYQ IQzA== X-Forwarded-Encrypted: i=1; AJvYcCXDPbJiQDyaOCKiUprxf5JfFg+c1400k4inaw+LSLYap66mlnBMaJitAiQFiK5QI5FLxadi8MPbnLo=@vger.kernel.org X-Gm-Message-State: AOJu0YzA5H2/CZqZH2RZEtW4C9bM8+WWTd0h9oiSirsRMFedVmqrpDKE jDH9VZmur3idFYNy6HCFSi5zSSgztHNFi2hIDVFcFjyi3QHRxIPWtujsusb1GCU= X-Gm-Gg: ASbGnct8QugdXw9tHaTbqMv4VCTon8WYC58jgF5s/71Bt/CY2hPuMgGDbfDUR6iKwnl MO3Qjno/PNHzzkgg8ITdzVRtM21QD7yaG5gINRp5e4yJVCcOHEE7duPSbjumQPpneuHCrj/8PU1 7kprcb6HGg2K5vOrbrc2uxPsdUfafK8vOcdgrS0+1pQkI9+qRzuJJs0fwCkvihXo0kZNspmtQls Wwwh9dkz0k8vJvy6ke5YO961i/FZYY2nHdewEg4akkQT15TuvAY6TjeVzE= X-Google-Smtp-Source: AGHT+IF3nilwMU43g5/fpaBvcw4VZUw4Fkdm9sOic07GjpPunCK+W3hkn/+CE4mn9czZhiryv71U9w== X-Received: by 2002:a05:600c:1e09:b0:436:e751:e445 with SMTP id 5b1f17b1804b1-436e751e61fmr16540885e9.5.1736357438725; Wed, 08 Jan 2025 09:30:38 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:38 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:20 +0100 Subject: [PATCH v2 6/9] iio: dac: ad3552r-hs: use instruction mode for configuration Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-6-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Use "instruction" mode over initial configuration and all other non-streaming operations. DAC boots in streaming mode as default, and the driver is not changing this mode. Instruction r/w is still working becouse instruction is processed from the DAC after chip select is deasserted, this works until loop mode is 0 or greater than the instruction size. All initial operations should be more safely done in instruction mode, a mode provided for this. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 27949f207d42..991b11702273 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -132,6 +132,13 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) return -EINVAL; } + /* Primary region access, set streaming mode (now in SPI + SDR). */ + ret = ad3552r_qspi_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, 0, 1); + if (ret) + return ret; + ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_STREAM_MODE, loop_len, 1); if (ret) @@ -198,6 +205,14 @@ static int ad3552r_hs_buffer_predisable(struct iio_dev *indio_dev) if (ret) return ret; + /* Back to single instruction mode, disabling loop. */ + ret = ad3552r_qspi_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, + AD3552R_MASK_SINGLE_INST, 1); + if (ret) + return ret; + return 0; } @@ -308,6 +323,13 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) if (ret) return ret; + ret = st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST | + AD3552R_MASK_SHORT_INSTRUCTION, 1); + if (ret) + return ret; + ret = ad3552r_hs_scratch_pad_test(st); if (ret) return ret; From patchwork Wed Jan 8 17:29:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931412 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDDAB202C45 for ; Wed, 8 Jan 2025 17:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357443; cv=none; b=m/AEkI1IfeITT18Djp+YSxyMcVB+uiiNSbwleHUczJj37ZPrH27Nxz+Dn/cVPQLuBdhdTpYk2f/6v8DWnmFuZDv82uWZCZ0q4XJalTwC522uHqCdi0DAgFGg+yb7+BCgI3GjBJnS6aFiA8JK+h3g0yzpZ/7LzrAmJByxDioCbT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357443; c=relaxed/simple; bh=yPBj8+317vNPAuFqO9cv8l0b9AdvZ+jKb3gEbQivFoE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V93+3mWMYXvOZ3njdwBboNqHcDSvFTWUIqdPVLBEg+4se8QthjMJac6Fruc1D+lrJAa+kT84NoaOdQpMZEv7lxvlaYgczBdIgsNCvbFVLGeG3UZqI9olUZ20IGsXiKBXMpLelry8AkXTQy3SUiJq8b42HQiM8TnPN6K9Vj6lh+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=IcjGHFO4; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="IcjGHFO4" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-385deda28b3so20413f8f.0 for ; Wed, 08 Jan 2025 09:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357440; x=1736962240; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CNTleVNIiTU9nZ6xRJX/KSmh/FQGS6/eS5WcZiPevhQ=; b=IcjGHFO4bUZsVypNlpe5bFcQ8+unHA6rXaGqZFeicw6Tx+WJbM2tg0k9+fF5HsBfvS 1mT1qc3o8Dy+djD4mwNv8ucKrpOJyudWA+aTFmeRHD7qAo7RL2r9fOlVn5HAz9CZs4u/ ORVKvogTJLm23HIdibsLiPFYaLKdbgILNr8YddALiKLr2h0HTy6oFVFHO7NQNrVEWJg6 DLumMkxhe0EBmw0g4qw/Z1hVnosqpkK8VNQPn6kUI2kDNuhlWV73QT2csA/VFAhnfLh5 U0PMJYqzmDUxMxtqlxYcFU0fWW3BnFyIqAzwnj+wRaBf30gNBeSwUH5pQOEL078pBrbo H/RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357440; x=1736962240; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CNTleVNIiTU9nZ6xRJX/KSmh/FQGS6/eS5WcZiPevhQ=; b=Wr37sq2pGzt8A/U4M6Dqhcs+JZVXJZUVLYzzDcpNogv3HyGRB4ILYP0vivCF2Y7DZa 88dufjlwuE2m6s3qzNlJZdCVDyAURCmT3AWp+GDYV7kSsKRui1nkdQxJ5ZbGzSbMIFnM ShNaloE5CzT3iqFW4GSoLN/AcZUZbIAJ6YSEVJ0XgSWYUL656uzT/ztIrs5AeLq3LeUB D8MH+VMPGOFXfD/e8q5we3muv+K5LvX36gUvo0n0JMygr8b4IvNNfI2Wg0PhRagTXiKo X4ZzfmYc6GHKTXMSzhUrGnwm+lKw5w+sLekrBECrSGwT68m0h6A3AW6HoYpMzuN9YGcw 67XA== X-Forwarded-Encrypted: i=1; AJvYcCXwtdxurRqHXFU/VXAh4NwFbc0npaO8KOeLvt2ZbeqVuZDNQldVPZ7fFLPBIZ1jo6p0CEGr4k1Ctio=@vger.kernel.org X-Gm-Message-State: AOJu0YwCdK2DCkoTD7/ZI17/UIAMl1ZnPsy7yBuNz5I4/NgZOYZoK5aC Gmd3TN/9UQYXZKm0i7AA/T895nR+rGWmDCasut29b34Lo9rBwzKROxP/wrqKCXY= X-Gm-Gg: ASbGnct7+gjeDNXPcUkiMjDMquEg1W0Q4jerH3TEXn3+hoiJTDFuun93WfpqZ0D5sfi B4Xr7M9vcN+yNXsajJ3Zj4MLtUX1ip7DAjjlWOAZN062FZmF65O2ci6Df3aUTWWX0wE1BA4ChWA akIx0ooNH6gWCliIyKuZS4DCFmGPIM/UeqqHLrJ90cmYaGwsvjUWaXpqtAMHJVs7ZDSPG8okY/m pejmMVI44KLcQYwafeEtys9U6Iequqb/vMtbDSxyOkHsVNlB0o87xV18UY= X-Google-Smtp-Source: AGHT+IHtHhpOxNudv3flMNURgU+J5Uz+IMqJA+3tUtgmXAU844RXw/Uo6ltVqTOhohjFukKWhgwc6A== X-Received: by 2002:a05:6000:4714:b0:386:3752:b28c with SMTP id ffacd0b85a97d-38a8732bb23mr2741757f8f.41.1736357440075; Wed, 08 Jan 2025 09:30:40 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:39 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:21 +0100 Subject: [PATCH v2 7/9] iio: dac: ad3552r: share model data structures Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-7-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Preparing for new parts to be added also in the hs driver, set model data structures in ad3552r-common.c, to be accessible from both -hs and non hs driver. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-common.c | 40 ++++++++++++++++++++++++++++++++++++++++ drivers/iio/dac/ad3552r-hs.c | 8 -------- drivers/iio/dac/ad3552r.c | 36 ------------------------------------ drivers/iio/dac/ad3552r.h | 5 +++++ 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/drivers/iio/dac/ad3552r-common.c b/drivers/iio/dac/ad3552r-common.c index 03e0864f5084..36920ec95836 100644 --- a/drivers/iio/dac/ad3552r-common.c +++ b/drivers/iio/dac/ad3552r-common.c @@ -37,6 +37,46 @@ static const s32 gains_scaling_table[] = { [AD3552R_CH_GAIN_SCALING_0_125] = 125 }; +const struct ad3552r_model_data ad3541r_model_data = { + .model_name = "ad3541r", + .chip_id = AD3541R_ID, + .num_hw_channels = 1, + .ranges_table = ad3542r_ch_ranges, + .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), + .requires_output_range = true, +}; +EXPORT_SYMBOL_NS_GPL(ad3541r_model_data, "IIO_AD3552R"); + +const struct ad3552r_model_data ad3542r_model_data = { + .model_name = "ad3542r", + .chip_id = AD3542R_ID, + .num_hw_channels = 2, + .ranges_table = ad3542r_ch_ranges, + .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), + .requires_output_range = true, +}; +EXPORT_SYMBOL_NS_GPL(ad3542r_model_data, "IIO_AD3552R"); + +const struct ad3552r_model_data ad3551r_model_data = { + .model_name = "ad3551r", + .chip_id = AD3551R_ID, + .num_hw_channels = 1, + .ranges_table = ad3552r_ch_ranges, + .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), + .requires_output_range = false, +}; +EXPORT_SYMBOL_NS_GPL(ad3551r_model_data, "IIO_AD3552R"); + +const struct ad3552r_model_data ad3552r_model_data = { + .model_name = "ad3552r", + .chip_id = AD3552R_ID, + .num_hw_channels = 2, + .ranges_table = ad3552r_ch_ranges, + .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), + .requires_output_range = false, +}; +EXPORT_SYMBOL_NS_GPL(ad3552r_model_data, "IIO_AD3552R"); + u16 ad3552r_calc_custom_gain(u8 p, u8 n, s16 goffs) { return FIELD_PREP(AD3552R_MASK_CH_RANGE_OVERRIDE, 1) | diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 991b11702273..bfb6228c9b9b 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -527,14 +527,6 @@ static int ad3552r_hs_probe(struct platform_device *pdev) return devm_iio_device_register(&pdev->dev, indio_dev); } -static const struct ad3552r_model_data ad3552r_model_data = { - .model_name = "ad3552r", - .chip_id = AD3552R_ID, - .num_hw_channels = 2, - .ranges_table = ad3552r_ch_ranges, - .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), -}; - static const struct of_device_id ad3552r_hs_of_id[] = { { .compatible = "adi,ad3552r", .data = &ad3552r_model_data }, { } diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c index e7206af53af6..9d28e06b80c0 100644 --- a/drivers/iio/dac/ad3552r.c +++ b/drivers/iio/dac/ad3552r.c @@ -649,42 +649,6 @@ static int ad3552r_probe(struct spi_device *spi) return devm_iio_device_register(&spi->dev, indio_dev); } -static const struct ad3552r_model_data ad3541r_model_data = { - .model_name = "ad3541r", - .chip_id = AD3541R_ID, - .num_hw_channels = 1, - .ranges_table = ad3542r_ch_ranges, - .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), - .requires_output_range = true, -}; - -static const struct ad3552r_model_data ad3542r_model_data = { - .model_name = "ad3542r", - .chip_id = AD3542R_ID, - .num_hw_channels = 2, - .ranges_table = ad3542r_ch_ranges, - .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), - .requires_output_range = true, -}; - -static const struct ad3552r_model_data ad3551r_model_data = { - .model_name = "ad3551r", - .chip_id = AD3551R_ID, - .num_hw_channels = 1, - .ranges_table = ad3552r_ch_ranges, - .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), - .requires_output_range = false, -}; - -static const struct ad3552r_model_data ad3552r_model_data = { - .model_name = "ad3552r", - .chip_id = AD3552R_ID, - .num_hw_channels = 2, - .ranges_table = ad3552r_ch_ranges, - .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), - .requires_output_range = false, -}; - static const struct spi_device_id ad3552r_id[] = { { .name = "ad3541r", diff --git a/drivers/iio/dac/ad3552r.h b/drivers/iio/dac/ad3552r.h index 4b5581039ae9..23f038464a0c 100644 --- a/drivers/iio/dac/ad3552r.h +++ b/drivers/iio/dac/ad3552r.h @@ -137,6 +137,11 @@ extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2]; extern const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2]; +extern const struct ad3552r_model_data ad3541r_model_data; +extern const struct ad3552r_model_data ad3542r_model_data; +extern const struct ad3552r_model_data ad3551r_model_data; +extern const struct ad3552r_model_data ad3552r_model_data; + enum ad3552r_id { AD3541R_ID = 0x400b, AD3542R_ID = 0x4009, From patchwork Wed Jan 8 17:29:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931413 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73CAF202F97 for ; Wed, 8 Jan 2025 17:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357445; cv=none; b=HUhQgcNEn+DgDTwwFJ/iiR9blEDoAM0NRHEwW6LdJ9VbRMw/+Ty7nTBmZOg3j0XREMB8RELLuCyR5AiyQwopbSZATsxCwwxZccq6a0bbHdgajceXnFYSDopi4kAnAsN2qmv8yWru9uvhSKCcgZGmhLHxToANyvk44p5dI7x1zoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357445; c=relaxed/simple; bh=AhVYyfcJyUQuknu+k6SdzE03Oz9o2XZyVIS6TgjYN9k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lu4+Kp4Ht7tX6F0VZGMtAuJn/KO4gkWK57flMwqp29RVqpwCSTlpb1L/PjUoUBX7GwHt15C0UTkjdqIcZEb3sgWOiIHMWehfuM63wSmNyWNd6RPbfdHBi5hddM/SboU/sapkYZdNtGEmIb+AZQQeAR2cZu16Hj+UsesSaYIjOrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=yls+ca7I; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="yls+ca7I" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so42568f8f.0 for ; Wed, 08 Jan 2025 09:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357442; x=1736962242; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yW2QdAEBTAIXZ0FwhrlcyQ2UztjJ2op9sufvOiml2fo=; b=yls+ca7IH+kAgA1RZj9pj4FKS3rOktfhWqa+iCwQfZo3d7mOkYAOS8aDi397ceBCTS 4H/iwHpgcNo14MSE0djxbMWt01Gevd04Qg/owcM1t6BlQyPQi1lE7KhNw2jmN1V2oYuw CQqqs7upNth528bte3MbE8cP1wCM0AYIUOTu5bp+EZEW6nbMO2MRVbjmEVHiHSLKlZbr 6eBnd+Vy8yWNkeRObu5ekjUZKbF6y4ozxNe21ahTw+JsU0NxuYVQk1c3IYRwHMwKITCK th5nYMB8cSkSt09i6VircdoOPPgVZTNGWrYKx/RpWAOEfq1ObZkh/YGTKzrYX7bVjTBf gxag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357442; x=1736962242; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yW2QdAEBTAIXZ0FwhrlcyQ2UztjJ2op9sufvOiml2fo=; b=hTGuJcpoF+VKb7ZXMiizVqgn6UeOjj+F/6ZKinRXxDn40AzsQFGx5Omnm7mG50tX6x YEgSJoKHsMLf8884V2UBRUxq12Z2c0uTM+/oGY2umjKIHGBfHzpL9Nmid7hNGCIV+KjH xvsq1heeDUXDYdxf8Ahbr3pX/HvrJ9mvA7MpsmamTuG5xi1CzEPLt/TZRTeYEYqqjA/w bZ50JNeqK8U1CB9Glio2JIclIln35m3oHZlv3G4p7lY2HtuoEnGxfKTq/l2eKl5B/f9+ WFR5asylK5RYJeDVotw6ltN0hOWqAZyPdxSObspuD4yhFvcvI4anm2P1TdBo8TZS6lMY VnIQ== X-Forwarded-Encrypted: i=1; AJvYcCX90cU4hvWRntLzvtelEl3Mwen5O7RuoWXm6hKM+MGDIWDO32MHHWW7jVwXKsTr9i8SBBr9gqYgC0g=@vger.kernel.org X-Gm-Message-State: AOJu0YwQDk1FW70FtF1DwDbNvmn9PdTU9noGt3QC58PQrXqrKpyUYhhj vnUzrw9hSyAjhbZkaUqgebt9IxOs1po7wDH1Eyj0iBt2JYD5PuQH+zQec5Um0/8= X-Gm-Gg: ASbGncvoUMcHap5Q3X6TKkAO+8T4lfwaKuxSanu8tB5rQCuPOWk/GerCx5CWwC326Br UbVxXbMQ+g0dRr0PxNZQ+/DAtq2sx3BAieYe32+Xwyw3suAH1jqa2faqNE6h9UMJqbvHP90j4AB XZRhUFMmPVIQB+CMLYXUWN4ckfisL+KWE2yEw1RT8apWohGLP/dMKBhdy3PmSQ7c5NXfr7y2f0g hyVek+kiTeYDHA09m0s1+flliDS8nLpJ2b3NMgDu6sNAyGGvDt5idaYqyw= X-Google-Smtp-Source: AGHT+IELdA96ehkDADF185V5g/Df7b6lGEqYEK4L8hpBP5+JsHgb8jVH/uZYHGv/eMK8ObED+oHDSw== X-Received: by 2002:a5d:64ce:0:b0:385:f6de:6266 with SMTP id ffacd0b85a97d-38a872eacdemr2600226f8f.24.1736357441570; Wed, 08 Jan 2025 09:30:41 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:40 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:22 +0100 Subject: [PATCH v2 8/9] iio: dac: ad3552r-hs: add ad3541/2r support Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-8-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello A new fpga HDL has been developed from ADI to support ad354xr devices. Add support for ad3541r and ad3542r with following additions: - use common device_info structures for hs and non hs drivers, - DMA buffering, use DSPI mode for ad354xr and QSPI for ad355xr, - change samplerate to respect number of lanes. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-common.c | 4 + drivers/iio/dac/ad3552r-hs.c | 240 ++++++++++++++++++++++++++++++++------- drivers/iio/dac/ad3552r.h | 3 + 3 files changed, 206 insertions(+), 41 deletions(-) diff --git a/drivers/iio/dac/ad3552r-common.c b/drivers/iio/dac/ad3552r-common.c index 36920ec95836..fa3050dc2efa 100644 --- a/drivers/iio/dac/ad3552r-common.c +++ b/drivers/iio/dac/ad3552r-common.c @@ -44,6 +44,7 @@ const struct ad3552r_model_data ad3541r_model_data = { .ranges_table = ad3542r_ch_ranges, .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), .requires_output_range = true, + .num_spi_data_lanes = 2, }; EXPORT_SYMBOL_NS_GPL(ad3541r_model_data, "IIO_AD3552R"); @@ -54,6 +55,7 @@ const struct ad3552r_model_data ad3542r_model_data = { .ranges_table = ad3542r_ch_ranges, .num_ranges = ARRAY_SIZE(ad3542r_ch_ranges), .requires_output_range = true, + .num_spi_data_lanes = 2, }; EXPORT_SYMBOL_NS_GPL(ad3542r_model_data, "IIO_AD3552R"); @@ -64,6 +66,7 @@ const struct ad3552r_model_data ad3551r_model_data = { .ranges_table = ad3552r_ch_ranges, .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), .requires_output_range = false, + .num_spi_data_lanes = 4, }; EXPORT_SYMBOL_NS_GPL(ad3551r_model_data, "IIO_AD3552R"); @@ -74,6 +77,7 @@ const struct ad3552r_model_data ad3552r_model_data = { .ranges_table = ad3552r_ch_ranges, .num_ranges = ARRAY_SIZE(ad3552r_ch_ranges), .requires_output_range = false, + .num_spi_data_lanes = 4, }; EXPORT_SYMBOL_NS_GPL(ad3552r_model_data, "IIO_AD3552R"); diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index bfb6228c9b9b..5995bab6a9b1 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -19,6 +19,31 @@ #include "ad3552r.h" #include "ad3552r-hs.h" +/* + * Important notes for register map access: + * ======================================== + * + * Register address space is divided in 2 regions, primary (config) and + * secondary (DAC). Primary region can only be accessed in simple SPI mode, + * with exception for ad355x models where setting QSPI pin high allows QSPI + * access to both the regions. + * + * Due to the fact that ad3541/2r do not implement QSPI, for proper device + * detection, HDL keeps "QSPI" pin level low at boot (see ad3552r manual, rev B + * table 7, pin 31, digital input). For this reason, actually the working mode + * between SPI, DSPI and QSPI must be set via software, configuring the target + * DAC appropriately, together with the backend api to configure the bus mode + * accordingly. + * + * Also, important to note that none of the three modes allow to read in DDR. + * + * In non-buffering operations, mode is set to simple SPI SDR for all primary + * and secondary region r/w accesses, to avoid to switch the mode each time DAC + * register is accessed (raw accesses, r/w), and to be able to dump registers + * content (possible as non DDR only). + * In buffering mode, driver sets best possible mode, D/QSPI and DDR. + */ + struct ad3552r_hs_state { const struct ad3552r_model_data *model_data; struct gpio_desc *reset_gpio; @@ -27,6 +52,8 @@ struct ad3552r_hs_state { bool single_channel; struct ad3552r_ch_data ch_data[AD3552R_MAX_CH]; struct ad3552r_hs_platform_data *data; + /* INTERFACE_CONFIG_D register cache, in DDR we cannot read values. */ + u32 config_d; }; static int ad3552r_qspi_update_reg_bits(struct ad3552r_hs_state *st, @@ -56,15 +83,19 @@ static int ad3552r_hs_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: /* - * Using 4 lanes (QSPI), then using 2 as DDR mode is - * considered always on (considering buffering mode always). + * Using a "num_spi_data_lanes" variable since ad3541/2 have + * only DSPI interface, while ad355x is QSPI. Then using 2 as + * DDR mode is considered always on (considering buffering + * mode always). */ *val = DIV_ROUND_CLOSEST(st->data->bus_sample_data_clock_hz * - 4 * 2, chan->scan_type.realbits); + st->model_data->num_spi_data_lanes * 2, + chan->scan_type.realbits); return IIO_VAL_INT; case IIO_CHAN_INFO_RAW: + /* For RAW accesses, stay always in simple-spi. */ ret = st->data->bus_reg_read(st->back, AD3552R_REG_ADDR_CH_DAC_16B(chan->channel), val, 2); @@ -93,6 +124,7 @@ static int ad3552r_hs_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: + /* For RAW accesses, stay always in simple-spi. */ iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { return st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_CH_DAC_16B(chan->channel), @@ -104,6 +136,42 @@ static int ad3552r_hs_write_raw(struct iio_dev *indio_dev, } } +static int ad3552r_hs_set_bus_io_mode_hs(struct ad3552r_hs_state *st) +{ + int bus_mode; + + if (st->model_data->num_spi_data_lanes == 4) + bus_mode = AD3552R_IO_MODE_QSPI; + else + bus_mode = AD3552R_IO_MODE_DSPI; + + return st->data->bus_set_io_mode(st->back, bus_mode); +} + +static int ad3552r_hs_set_target_io_mode_hs(struct ad3552r_hs_state *st) +{ + int mode_target; + + /* + * Best access for secondary reg area, QSPI where possible, + * else as DSPI. + */ + if (st->model_data->num_spi_data_lanes == 4) + mode_target = AD3552R_QUAD_SPI; + else + mode_target = AD3552R_DUAL_SPI; + + /* + * Better to not use update here, since generally it is already + * set as DDR mode, and it's not possible to read in DDR mode. + */ + return st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_TRANSFER_REGISTER, + FIELD_PREP(AD3552R_MASK_MULTI_IO_MODE, + mode_target) | + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); +} + static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) { struct ad3552r_hs_state *st = iio_priv(indio_dev); @@ -132,6 +200,11 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) return -EINVAL; } + /* + * With ad3541/2r supoport, QSPI pin is held low at reset from HDL, + * streaming start sequence must respect strictly the order below. + */ + /* Primary region access, set streaming mode (now in SPI + SDR). */ ret = ad3552r_qspi_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, @@ -139,48 +212,114 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) if (ret) return ret; - ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_STREAM_MODE, + /* + * Set target loop len, 0x2c 0r 0x2a, descending loop, + * and keeping loop len value so it's not cleared hereafter when + * enabling streaming mode (cleared by CS_ up). + */ + ret = ad3552r_qspi_update_reg_bits(st, + AD3552R_REG_ADDR_TRANSFER_REGISTER, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); + if (ret) + goto exit_err_streaming; + + ret = st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_STREAM_MODE, loop_len, 1); if (ret) - return ret; + goto exit_err_streaming; - /* Inform DAC chip to switch into DDR mode */ - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SPI_CONFIG_DDR, - AD3552R_MASK_SPI_CONFIG_DDR, 1); + /* + * Registers dump for debug purposes is only possible until here, + * read in primary region must be SPI SDR (DDR read is never possible, + * D/QSPI SDR read in primary region is also not possible). + */ + + /* Setting DDR now, caching current config_d. */ + ret = st->data->bus_reg_read(st->back, + AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + &st->config_d, 1); if (ret) - return ret; + goto exit_err_streaming; + + st->config_d |= AD3552R_MASK_SPI_CONFIG_DDR; + ret = st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + st->config_d, 1); + + if (ret) + goto exit_err_streaming; - /* Inform DAC IP to go for DDR mode from now on */ ret = iio_backend_ddr_enable(st->back); - if (ret) { - dev_err(st->dev, "could not set DDR mode, not streaming"); - goto exit_err; - } + if (ret) + goto exit_err_ddr_mode_target; + /* + * From here onward mode is DDR, so reading any register is not + * possible anymore, including calling "ad3552r_qspi_update_reg_bits" + * function. + */ + + /* Set target to best high speed mode (D or QSPI). */ + ret = ad3552r_hs_set_target_io_mode_hs(st); + if (ret) + goto exit_err_ddr_mode; + + /* Set bus to best high speed mode (D or QSPI). */ + ret = ad3552r_hs_set_bus_io_mode_hs(st); + if (ret) + goto exit_err_bus_mode_target; + + /* + * Backend setup must be done now only, or related register values + * will be disrupted by previous bus accesses. + */ ret = iio_backend_data_transfer_addr(st->back, val); if (ret) - goto exit_err; + goto exit_err_bus_mode_target; ret = iio_backend_data_format_set(st->back, 0, &fmt); if (ret) - goto exit_err; + goto exit_err_bus_mode_target; ret = iio_backend_data_stream_enable(st->back); if (ret) - goto exit_err; + goto exit_err_bus_mode_target; return 0; -exit_err: - ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SPI_CONFIG_DDR, - 0, 1); +exit_err_bus_mode_target: + /* Back to simple SPI, not using update to avoid read. */ + st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_TRANSFER_REGISTER, + FIELD_PREP(AD3552R_MASK_MULTI_IO_MODE, + AD3552R_SPI) | + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); + /* + * Back bus to simple SPI, this must be executed together with above + * target mode unwind, and can be done only after it. + */ + st->data->bus_set_io_mode(st->back, AD3552R_IO_MODE_SPI); + +exit_err_ddr_mode: iio_backend_ddr_disable(st->back); +exit_err_ddr_mode_target: + /* + * Back to SDR. + * In DDR we cannot read, whatever the mode is, so not using update. + */ + st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + FIELD_PREP(AD3552R_MASK_SDO_DRIVE_STRENGTH, 1), + 1); + +exit_err_streaming: + /* Back to single instruction mode, disabling loop. */ + st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST | + AD3552R_MASK_SHORT_INSTRUCTION, 1); + return ret; } @@ -193,11 +332,22 @@ static int ad3552r_hs_buffer_predisable(struct iio_dev *indio_dev) if (ret) return ret; - /* Inform DAC to set in SDR mode */ - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SPI_CONFIG_DDR, - 0, 1); + /* + * Set us to simple SPI, even if still in ddr, so to be able + * to write in primary region. + */ + ret = st->data->bus_set_io_mode(st->back, AD3552R_IO_MODE_SPI); + if (ret) + return ret; + + /* + * Back to SDR + * (in DDR we cannot read, whatever the mode is, so not using update). + */ + st->config_d &= ~AD3552R_MASK_SPI_CONFIG_DDR; + ret = st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + st->config_d, 1); if (ret) return ret; @@ -205,11 +355,21 @@ static int ad3552r_hs_buffer_predisable(struct iio_dev *indio_dev) if (ret) return ret; - /* Back to single instruction mode, disabling loop. */ + /* + * Back to simple SPI for secondary region too now, + * so to be able to dump/read registers there too if needed. + */ ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_B, - AD3552R_MASK_SINGLE_INST, - AD3552R_MASK_SINGLE_INST, 1); + AD3552R_REG_ADDR_TRANSFER_REGISTER, + AD3552R_MASK_MULTI_IO_MODE, + AD3552R_SPI, 1); + if (ret) + return ret; + + /* Back to single instruction mode, disabling loop. */ + ret = ad3552r_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, + AD3552R_MASK_SINGLE_INST, 1); if (ret) return ret; @@ -319,6 +479,7 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) if (ret) return ret; + /* HDL starts with DDR enabled, disabling it. */ ret = iio_backend_ddr_disable(st->back); if (ret) return ret; @@ -352,6 +513,8 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) "Chip ID mismatch, detected 0x%x but expected 0x%x\n", id, st->model_data->chip_id); + dev_info(st->dev, "chip id %s detected", st->model_data->model_name); + /* Clear reset error flag, see ad3552r manual, rev B table 38. */ ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_ERR_STATUS, AD3552R_MASK_RESET_STATUS, 1); @@ -364,14 +527,6 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) if (ret) return ret; - ret = st->data->bus_reg_write(st->back, - AD3552R_REG_ADDR_TRANSFER_REGISTER, - FIELD_PREP(AD3552R_MASK_MULTI_IO_MODE, - AD3552R_QUAD_SPI) | - AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); - if (ret) - return ret; - ret = iio_backend_data_source_set(st->back, 0, IIO_BACKEND_EXTERNAL); if (ret) return ret; @@ -528,6 +683,9 @@ static int ad3552r_hs_probe(struct platform_device *pdev) } static const struct of_device_id ad3552r_hs_of_id[] = { + { .compatible = "adi,ad3541r", .data = &ad3541r_model_data }, + { .compatible = "adi,ad3542r", .data = &ad3542r_model_data }, + { .compatible = "adi,ad3551r", .data = &ad3551r_model_data }, { .compatible = "adi,ad3552r", .data = &ad3552r_model_data }, { } }; diff --git a/drivers/iio/dac/ad3552r.h b/drivers/iio/dac/ad3552r.h index 23f038464a0c..9d450019ece9 100644 --- a/drivers/iio/dac/ad3552r.h +++ b/drivers/iio/dac/ad3552r.h @@ -132,6 +132,8 @@ #define AD3552R_MAX_RANGES 5 #define AD3542R_MAX_RANGES 5 +#define AD3552R_SPI 0 +#define AD3552R_DUAL_SPI 1 #define AD3552R_QUAD_SPI 2 extern const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2]; @@ -156,6 +158,7 @@ struct ad3552r_model_data { const s32 (*ranges_table)[2]; int num_ranges; bool requires_output_range; + int num_spi_data_lanes; }; struct ad3552r_ch_data { From patchwork Wed Jan 8 17:29:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13931414 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEE34202F7E for ; Wed, 8 Jan 2025 17:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357446; cv=none; b=ayWRL/7O0w9f/8mAYOw/hnJUBuf//r09ZrI1VxCWSQtCxDCPxkFYG37B7xkGn/BeC7LrBXey0e9L/jdPBIUFFhewLM4r5yvq6QCGEeQyZisZ3i03LVFb0T8WtNPCpZZF6NIb4mUeZZ/NbGXB8x5VsHmz/2CdthGdUXn7VFwswQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736357446; c=relaxed/simple; bh=T6i3t0gkmspAQpLvDBy59RH0XXVU3fyslIP9/NkPmzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SW80mizFQOIT/X1b7p9HK2l9O9Yis/kCOrfXUG8VcjJmme4dHfYXsUHywlSpF7DHuhssW6hPyEy0pkVAigfVE4JEkxO/C0UFbeajkbuzFyXAGU+nKhmzkEdDow1MNgOPFsKymTxKe/7u8n5mpXUKpOz1eFs/rOPo0Y8oag2t9zU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=sOxSlhA0; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="sOxSlhA0" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3862b40a6e0so24861f8f.0 for ; Wed, 08 Jan 2025 09:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736357443; x=1736962243; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=63sUA66Ctgyf7KL2tc561CUvyyC0coEhZW4ecsp3aQg=; b=sOxSlhA0/tlGSO/VGi0tk0PoX0Q1AgFDEfob5mDHa5U80tTu7IU4VR2HAymsknT/n0 ooKuzUzXeo+rNjWrHw4aVIZmNevFUj2uvO88/ng66rxd2T+5XXokuid0Awd5iP+ko8Ms wFo1NDHIHTUE2bexUlDNGF6qdeushdSnpxTrXNEObgqrAnFVVbfTK3tl4owwrenEOCcO wvfjndSgdb2hkBiPrbWqYlOp2Yi5f/kzLGl31D/xbsPGA6cb4NowCzOONMHrc/ngjiyS 1EqIaxg5ARHHktmWJowZxY0F572yHrgEmhMQGj51lxiN4pXAIgUQi6Tft1TkSQgLelJQ PI2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736357443; x=1736962243; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=63sUA66Ctgyf7KL2tc561CUvyyC0coEhZW4ecsp3aQg=; b=cC204aNe4p0fs7LRNa827u5N0RJNLghCgTOPFbJERDmcSYbSz/HVukYWfUg6iHtdNq 0MH07I6Ln6BXDFmsCfCjQzk3Vz14+XSKvHQXTjkaOt6vdlbEjnZlC1LzWT8Hno0yRicz j+Khd81ET73P/PASl5HoQQVKN90rltsJ+ghtWmXxS63k+aaCYGiansFH9eTcKaWK/AeR GkOK2EEbUHL07T9soiM25AlL4nDKeX7s5zQ0Q/bPoMgKSg+l8S7ahHhMntIDpaeI3Z1J /AhInSbB/8HCHSR+62DxYL6XCxudrdmXU2FVOjjlYiw3YOM1xilGCq8Z0aRMyOtgeWEM 186A== X-Forwarded-Encrypted: i=1; AJvYcCWDwA3D/SqGBTk+FXCjc4B7GyAn4YObcHBPFxrcVAw8AQfYCoZtQObVe9bd+DpLnXwVkS8Xmohe6X0=@vger.kernel.org X-Gm-Message-State: AOJu0YzH7XPHPBRqpBRWuPTi3QbnQEDroF1ZBgIiiDcq3h8glLkF2jPJ bONhd1xScdwisQC86erR510M4m/jrkDawt1ZS8ZbaXLmGBEiBFeSNOHDxDhzYaY= X-Gm-Gg: ASbGncv/k8UuDrmyPF3w7INg+/tJfA/usbsPHE54qnnvsSP+WRiTuGchl7UJyKeywfm 61ESeuB5oJ3k7/jVpAllQkQOuXhlH2AesKnDRkKjnD+iv+cwqhuRyuk824P42hph5m2k7iCpq7T mT7NfsGk6/mhyN/uWoiapgZN6utn0KjB7Zmwb9twRiEkmzblDNQDOUXjEDjNX+oxnyV20Z0Yjb/ e1hXQ96/ue0TVoqWp0KghzP0W1RJjghBM7LH+OKlwad/MQlzMboYuxr+lw= X-Google-Smtp-Source: AGHT+IGzdj5Cb9f/UsfLaSyFl+zkmljSKvG6y4+kUJdZtYo99f9dUTCsFvgvvixfxjqKsbmZuOxeYw== X-Received: by 2002:a5d:64eb:0:b0:38a:50fa:d582 with SMTP id ffacd0b85a97d-38a87363364mr2332840f8f.59.1736357443074; Wed, 08 Jan 2025 09:30:43 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8330d4sm52782599f8f.29.2025.01.08.09.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 09:30:42 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Wed, 08 Jan 2025 18:29:23 +0100 Subject: [PATCH v2 9/9] iio: dac: ad3552r-hs: update function name (non functional) Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-9-2dac02f04638@baylibre.com> References: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> In-Reply-To: <20250108-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v2-0-2dac02f04638@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Mihail Chindris , Nuno Sa , David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.1 From: Angelo Dureghello Update ad3552r_qspi_update_reg_bits function name to a more generic name, since used mode can be SIMPLE/DUAL/QUAD SPI. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.c | 58 ++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 5995bab6a9b1..53ab912eea11 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -56,9 +56,9 @@ struct ad3552r_hs_state { u32 config_d; }; -static int ad3552r_qspi_update_reg_bits(struct ad3552r_hs_state *st, - u32 reg, u32 mask, u32 val, - size_t xfer_size) +static int ad3552r_update_reg_bits(struct ad3552r_hs_state *st, + u32 reg, u32 mask, u32 val, + size_t xfer_size) { u32 rval; int ret; @@ -206,9 +206,8 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) */ /* Primary region access, set streaming mode (now in SPI + SDR). */ - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_B, - AD3552R_MASK_SINGLE_INST, 0, 1); + ret = ad3552r_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, 0, 1); if (ret) return ret; @@ -217,10 +216,9 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) * and keeping loop len value so it's not cleared hereafter when * enabling streaming mode (cleared by CS_ up). */ - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_TRANSFER_REGISTER, - AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, - AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); + ret = ad3552r_update_reg_bits(st, AD3552R_REG_ADDR_TRANSFER_REGISTER, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); if (ret) goto exit_err_streaming; @@ -247,7 +245,6 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_INTERFACE_CONFIG_D, st->config_d, 1); - if (ret) goto exit_err_streaming; @@ -257,7 +254,7 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) /* * From here onward mode is DDR, so reading any register is not - * possible anymore, including calling "ad3552r_qspi_update_reg_bits" + * possible anymore, including calling "ad3552r_update_reg_bits" * function. */ @@ -359,10 +356,9 @@ static int ad3552r_hs_buffer_predisable(struct iio_dev *indio_dev) * Back to simple SPI for secondary region too now, * so to be able to dump/read registers there too if needed. */ - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_TRANSFER_REGISTER, - AD3552R_MASK_MULTI_IO_MODE, - AD3552R_SPI, 1); + ret = ad3552r_update_reg_bits(st, AD3552R_REG_ADDR_TRANSFER_REGISTER, + AD3552R_MASK_MULTI_IO_MODE, + AD3552R_SPI, 1); if (ret) return ret; @@ -386,10 +382,10 @@ static inline int ad3552r_hs_set_output_range(struct ad3552r_hs_state *st, else val = FIELD_PREP(AD3552R_MASK_CH1_RANGE, mode); - return ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_CH0_CH1_OUTPUT_RANGE, - AD3552R_MASK_CH_OUTPUT_RANGE_SEL(ch), - val, 1); + return ad3552r_update_reg_bits(st, + AD3552R_REG_ADDR_CH0_CH1_OUTPUT_RANGE, + AD3552R_MASK_CH_OUTPUT_RANGE_SEL(ch), + val, 1); } static int ad3552r_hs_reset(struct ad3552r_hs_state *st) @@ -405,10 +401,10 @@ static int ad3552r_hs_reset(struct ad3552r_hs_state *st) fsleep(10); gpiod_set_value_cansleep(st->reset_gpio, 0); } else { - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_A, - AD3552R_MASK_SOFTWARE_RESET, - AD3552R_MASK_SOFTWARE_RESET, 1); + ret = ad3552r_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_A, + AD3552R_MASK_SOFTWARE_RESET, + AD3552R_MASK_SOFTWARE_RESET, 1); if (ret) return ret; } @@ -541,19 +537,17 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) val = ret; - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_SH_REFERENCE_CONFIG, - AD3552R_MASK_REFERENCE_VOLTAGE_SEL, - val, 1); + ret = ad3552r_update_reg_bits(st, AD3552R_REG_ADDR_SH_REFERENCE_CONFIG, + AD3552R_MASK_REFERENCE_VOLTAGE_SEL, + val, 1); if (ret) return ret; ret = ad3552r_get_drive_strength(st->dev, &val); if (!ret) { - ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SDO_DRIVE_STRENGTH, - val, 1); + ret = ad3552r_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + AD3552R_MASK_SDO_DRIVE_STRENGTH, val, 1); if (ret) return ret; }