From patchwork Tue Jan 14 15:30:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13938879 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 A08D88488 for ; Tue, 14 Jan 2025 15:31:47 +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=1736868711; cv=none; b=FlSuI7VlVk6/gKtCLr1LxWANNl1YYMHgQUsXIZ5v79Vk2DdSzjGuD43CpexikdvJ0F/Oo4ulW3caAzkJ0071EkMzmc7o+gW5x+QL6pQ7cCXysAukNfoZn517bnxztFxlV6dp00tW/EOAZsvyb+GuhWWAp/UVRCT3ntvLl8Q2hXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868711; c=relaxed/simple; bh=pqyr7lB2YlEjhkiVyE7jHiA6cFUHvqgoHwiJXFTx2Ys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=n5faDzp3NaAq6J5Zi6avgOcbN5rls4rphJJtMTIW7PiyfL3UxSpELtILvHNml9XaU6OG0lESKsaDTGbPLHhvfZ0LYml4b+UnGnH3JbFZEfWq4ObVYPEK3hztwDxpdfVtrjLsBn8nNf2KcBMpIMQ9SlO4F8xnqWpGzwJBLHFwXhE= 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=2FComeN8; 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="2FComeN8" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-385e06af753so2871309f8f.2 for ; Tue, 14 Jan 2025 07:31:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868706; x=1737473506; 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=M1ZK1w7swUyQuLFjvZaL7bfwG8xysBkjwjJzs0AMUFQ=; b=2FComeN8pPywh+irUsHDr/YwuN5JgkPNtnzgGY2+i5jmWe+GiL/vuXdquK/h0c5PTi euwPNo5OjfJEQ06MofXOKrxmPif6I6ZN9M060RM3b3y0oNBvhxsiP3JeYKDmovYBCHaC bbmYWvTr2fWaIkrFpdPWvLSNKzGPQMYzWTLzbe9gXGvS2VAeb+7vJh+hqTu9h524X/mv RdXm2wcjAKyFAgc1CZNK7HTyn9hxnXhkSX8g/cqCZb6KtmJ+JvfCBniFfZQ97WCWZSx5 Mlvx3KEo3FhJTuWybdZe9afB4Y9ef8rMfFTIXRqlbzTMiJkx8chDNheMlA2qGsnaZcLU GCYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868706; x=1737473506; 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=M1ZK1w7swUyQuLFjvZaL7bfwG8xysBkjwjJzs0AMUFQ=; b=s3MIisWvspuf3Sp4HXARxgUxCUTF6MWodVODWc7/MlWNCPxT3aM2bjkip5IWPC0aWf ZKhC51mWZgmZZV4ImSZEi++ZKwemojuJJoRNcGTcq5JJ3JKpdM6s3JHMsQwXNS7xJtRy nQ2wqA6b3BF5HaaZxQiCxsALoc8wLUjtcRxb7up2BGMB5+FawTO9erTATmct+R2+XBNh zogJ1HYkP1MM6jNuCnuJ3zGab2JahRj+QsBwS5nM4FhPGl1T7tA0Xt73v5iHh/yobe0+ qKLEkv/0UeB+dJpdQGYLdhqLG8o/3nlziwfgEZW9su2auvXaXRNubLc6iZzplHmnyuL3 4OVw== X-Forwarded-Encrypted: i=1; AJvYcCVLJBrF2qirqBsapJgaVFglWkkywH5PicUpaJDsRYiBI+8LnJAIf6gc7IzbA9Nqjd/HgYPWABpiddI=@vger.kernel.org X-Gm-Message-State: AOJu0YyiHnDZCp2hFChQjYojRVyMU/oBURbPp5AGWMmcjXd8Lzl2yXId 9xFnAOpo7ydBVXwhw/vX3lZ3ZWfdVMnaROBu7zF8gIVoXnjtKSx+eBPxTt9KsbU= X-Gm-Gg: ASbGnctGFdKVC4MkAI0+2I9PuNttKe880FZ5jnmmu2btfAwO4xVzLue20RrLDxvxQEh 1ZJ2MeBd9X/n8o71QVOZCdJNwhLGrOshT0XiKae1EnfqEj4t/F7Lavw22bacoiCUZg8EhSm/CXp +2blfo2nODovTh/Ivv28Gxx8Uwe84OzZGf8+UPUqy8mLA6sdzqgHCgV+MM4NiwoVaR46hDOzJyR e57M+5o005ln4M17uPriazMgi3vcIEuBrR9afAaXbfCCYhf4IyoECds6GI= X-Google-Smtp-Source: AGHT+IGUfVVhHPPVS2cv9/nifIYxojUhr8Wg6b+On+7nFINLHTVHlstooWa0UcWalyJD5136uQ5tlQ== X-Received: by 2002:a5d:6da8:0:b0:38a:5ce8:df51 with SMTP id ffacd0b85a97d-38a872f7ef2mr22563413f8f.2.1736868704441; Tue, 14 Jan 2025 07:31:44 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:43 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:10 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-1-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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") Reviewed-by: Nuno Sa Reviewed-by: David Lechner Signed-off-by: Angelo Dureghello --- 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 Tue Jan 14 15:30:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13938878 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 01BFC15746B for ; Tue, 14 Jan 2025 15:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868710; cv=none; b=T1FZUWhsWeddyBKtHl6jBc7JT6L+dvAucFCMnU8ONYU60RKQ4r3Y1eXjJsqzOeUwEno4FyhA4jZ4keCsN6Gi3EJFl2SrCU6DcUFZcscwK1T3u75IEyBWzzZAucYDltjfrBMNs1RPc7ZcGeeR7rIP8yPKrI2MnxtRYIWdpotDto0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868710; c=relaxed/simple; bh=WwKlVxTv7Oeh09OXx+DvjZEFIeEypUPrgYxitxNiF28=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JxQ43snqW+DlfV1MvyTUCjny5H8br/1DNJvAMQR6vWrp019jmuVwzU9+jGcu53r4JGjEwCJ5YforNY6FsI1pVheU1Szpx9gMuBrbBckcCJ11ZG5dkVfDT5Ti7T+zrEPwxkoxnx85kscH5wPteqxvF0eiha4tmQo5khkOMx/vFTU= 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=Rww4GutW; arc=none smtp.client-ip=209.85.221.43 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="Rww4GutW" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-385f06d0c8eso2952333f8f.0 for ; Tue, 14 Jan 2025 07:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868707; x=1737473507; 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=RmYlx/En2aqqfgAz0OoSAfJ3wizK8wbnQXwhJAWjCCw=; b=Rww4GutWC7vy+903fwKqVbdjh7ptEPyodeJR5ErcStemSSqLhX1SPTCJ9FrsFAXgZ2 HnKPqTawsKKkS9U8f+bZalPWMEIKAvvcjoKx3DCW3ev3UjQZ6IQYWQ3zewrLJ9htH89U 9Kdp/tt73zZn/hHuk3jkghWjMz+ygMu1bUR+93m1cGxnZES6GF/L5gKFCV6SCR2XSK1d ua93ucYSPIWCFbLl/E4Eh5M9f0lGe9o1i51+V2N/Zszcxcq+110hnNyXbfTtcH+jyg7G b+n9j7auq9rX858JGzkeYR4ezqHSxQtTLLahC8Q8/U2GdJa2u4OxGODu2iipikWArtUl 8cFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868707; x=1737473507; 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=RmYlx/En2aqqfgAz0OoSAfJ3wizK8wbnQXwhJAWjCCw=; b=mjYn1U6/5FBGF8EiMeLsti2KxztH9V4gxSpJ7JSDsbQvlb9eRe5p8LeVTkicLEqC/w T0J+a7GenoFUSfMtX9S3vWwPkFob2HZAs9QiV5upaVr3mXO79q9zsnyD6WICEiSNpKUq DnHmN6E0KX3ytyWnHXCyaypsYQ+uKmEDChEvCH7W0Wjs1USIp884CBEhPC+aiyFrm12s 4aPQHaUmMFO5ehz0ccbMCzjuDfe1b6Be/xEtMj3RPihLw0mh0F753EpZ3R1AWqTCAXS4 WMI+lSlH7RgjOmniC2YgRQSQawPHH7xG2xaTz2I18M1ZQEyPXjMxQLhwTkwNj5JqE9k6 GsyA== X-Forwarded-Encrypted: i=1; AJvYcCUSQIUt5aqZjsFEyoPdL8n9auaLVKdC+wew2QuF0TBJwnhnDqacYkhfj3Ht+XZ+16qSBjLCL2xIcwM=@vger.kernel.org X-Gm-Message-State: AOJu0YzfMDy6y1mT+iRDkVg+G+5oaKbPqAkaWSq/yNziZbsFZJKDLhki JD60Eo6BQ7WDpl1Kap+FNkUM+427nwKDNxTooNSye25IgGLaoaZP+2vF/AoJ9Gg= X-Gm-Gg: ASbGncs4Vr/TpoAhmqMf3867Rdzuktfr0XVMsPp3alTYM9eLxmDfqxRQxQxUKlon9L2 gTL+Wlr9c+YkgQTDI4ApaZVKlx0t1ERQYhsa58z5DcyRNWwGikT8C2aUnd6rE670jTMpVODESZ2 6ITe0pI9T1fQL8dQOJxU04LpDTo3kz+oFugbmouAfXJTsim03cNWRyx9pQZTeiq7HUz+Po0cXwl yzF6yH9I6GAN8qjRcO0Oz/NtRkxG+05PWF/dpDEscLrLp1lWmk/L5f0wyc= X-Google-Smtp-Source: AGHT+IGTfu68TjbqpJhz91FbPuANOfke+PQV/4PPq6Ra3BMMNeQguSEVyw6KgI7jOnEtN3nP89YzHg== X-Received: by 2002:a5d:6d0e:0:b0:38a:a117:3da1 with SMTP id ffacd0b85a97d-38aa1173f70mr10969153f8f.5.1736868705806; Tue, 14 Jan 2025 07:31:45 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:45 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:11 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-2-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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") Reviewed-by: Nuno Sa Reviewed-by: David Lechner Signed-off-by: Angelo Dureghello --- 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 Tue Jan 14 15:30:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13938880 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 3273218EFCC for ; Tue, 14 Jan 2025 15:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868712; cv=none; b=Rxgc+Rs2MMU+7QKUxnS6adpzPCTF1hAeNsuCRZSQsBX+o/kSBj5KSgMGETqBXmuBgwYV3IDpnCj+ZwANucnJnMToHqQVJ1d7FLKzqBr23t/I8olckNg19zSpWxeSJ4juFJt6Nz0FN7DWoCd8wUFJZi36RJNqCxPLOicvdiyVItU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868712; c=relaxed/simple; bh=pSP5O2KpDcWDn/YPvUVk/p3yqEOsgwFMEHN2oKWfl2Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sq+WXB9tWtJ+KHe4V8U8rtjHWcleRmPSxqSR+vrS0qoCvCgnwWOO9S2hhQn9ZwMlEhPC740V59xjdEWzAbzbU6h6MX8JfmyzvPcWv3PCXPDdPfQl9RtvB12cMMxVw3IbMq51gaN/QG6xYbYMxB2aR+yzY9jREZ0nJbMqXjAc7aA= 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=oQTAmP0V; arc=none smtp.client-ip=209.85.221.41 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="oQTAmP0V" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-38a88ba968aso4664219f8f.3 for ; Tue, 14 Jan 2025 07:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868708; x=1737473508; 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=79ELYnS/0cFQomhFXegbEFpd0OUlcm/1XJ4h0p0TxPA=; b=oQTAmP0VN/7YrYU0b6McFPgPIdRbtBGuuj+QZs7zFWMpc4Ys4B7A8DNhTO8k5qNSjE Tcov0GwTlyF1O3zTegRwtabcUiflWHbRUoG2/SzC78tRM4R211tRDCa+PudXefg4VALW VB++8ghIMHRVIma6U/wURV2BWFahXvuW1S23nyN0M5Uvs3jQIO+xDragxvQYE0RKkalD 2OiqSM0U/nFNlDP4NNLc0VdZnu7Bto776vSc7om4bKqyf6Kdbl9UcKMNo0bayrD1AF0m iIIJcccdjzNa19ATmduCyDqw0VQ0IbpxlyyIN+6iPdzaBUqn1dRwJlQCWRoamSSQPzem 28fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868708; x=1737473508; 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=79ELYnS/0cFQomhFXegbEFpd0OUlcm/1XJ4h0p0TxPA=; b=FWJo1TASfyWNc3ZtwJlOEZY3N8V3dsgqIuEFXMuooXAtY8ayogFrFarMrymlxF0JS9 JztUReuJNzbwqKOFNsErh2dv9klP0HzYpXDUrbs4ZGCLBQ6E1318jbAXMWJd+k32ud8x kEIYlEcqSUrU1R0dV7Nb2FzFlQ4Cc+ApjlqiO1nK/qvihJpTbE6lsxaJo2ckN8cOOScM ebxQhw5fKLkM1HKroSJ/WtSRpPWGFECRJ+vV0yTRSRKQSDUn6X1SqrfulId/QpzwDa0Y GlbbpxgWkunsHRiWpanD7MMudmTdbgRkwGUNX9o5iwtGCKqCmUVZ+NZlJ38IeBExMq+t ClLw== X-Forwarded-Encrypted: i=1; AJvYcCXOzFo5qu/TEaybYfI8fwEhIPCYQyJHc03y0f8r6LMMRVek8uHkLsGCqyZg8UGham9BDL9JtbYTTww=@vger.kernel.org X-Gm-Message-State: AOJu0YxgUrxmgCHYL1gDoyuo+RpXu7axWBUpaN/6CrzTuJ2GfqqaTba4 8Cf7jaA3LI5HbZ0gKJDUVaX/6rgxJOUgc8GoPCHfLFdFLaE4yOqZ6vrTyB3LwaA= X-Gm-Gg: ASbGncuEGDZ3MlmX157o6WtH1/WyI1WJSw5dH79ryu2CIsTMp5cGD9A9BdMFW3Glzmx F+GqKtjzsFMDlS+waAQcG7eKYWbunadQwOQ9ftYHaeCCTD+f3JSBjVi3DfrkM3okYDlPUjIP6Rq zNIwivDdbYn3LOhvw/CIQaTjZIguUiFMh1S7PqE8AnSqsnGdZlYELMGSVwt21xQitFSBsm0IaGX jA8AfiYTvgVJy1h5Orz2kVt08HGf8qvU3v7A1x4pdy9IpOLuXoRM/5fwAs= X-Google-Smtp-Source: AGHT+IEQwIlC+JLtLtee+bYn5GDdoWVZ3hShcRyhT/V0Hier8yuFXFLUZ2GFZ3aUCqKCEmcFYWLBlw== X-Received: by 2002:a05:6000:184e:b0:382:46ea:113f with SMTP id ffacd0b85a97d-38a872fc1b3mr23588975f8f.10.1736868707122; Tue, 14 Jan 2025 07:31:47 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:46 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:12 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-3-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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") Reviewed-by: Nuno Sa Signed-off-by: Angelo Dureghello --- drivers/iio/dac/adi-axi-dac.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c index b143f7ed6847..ac871deb8063 100644 --- a/drivers/iio/dac/adi-axi-dac.c +++ b/drivers/iio/dac/adi-axi-dac.c @@ -585,6 +585,14 @@ 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) + return ret; return regmap_set_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG, AXI_DAC_CUSTOM_CTRL_STREAM_ENABLE); From patchwork Tue Jan 14 15:30:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13938881 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 4C43519066D for ; Tue, 14 Jan 2025 15:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868712; cv=none; b=GJ0V3FGDsuD93F7GdScJtoaZo3xXY7IZWLK+3Uefc4oAgZMKmatdWk98r1TpzejWMAenzEavTYPkvVaOJlKHKz+oMSDFhg6/kubQMELevCQwGV6V4xeSdFx5h6jlwK+/f7zV8dkwpMFCf4Q9xgGpu+j5t41ga9cgWtHeseIGVHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868712; c=relaxed/simple; bh=M6naqnLCM4ZXUGO/uUploLBwKizmZEKciSJDiKFWV0I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=llzBulPA4ksWuPEQ6NsGzEabTQRwoKT19zJxSE4xCJ61fnm9KP7RANNbORKDlpDVggCp1MrKIj9tEiJGaF/S1UqqJRoDTwcqYJVUEXQaOzKdMnFexaEmgtF0KQ33Mljh3B7+bjustJ41fv1WsOMYjN25PGs+SPrp9NfVXfR5EV0= 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=h/w/dpAF; arc=none smtp.client-ip=209.85.128.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="h/w/dpAF" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so40519895e9.1 for ; Tue, 14 Jan 2025 07:31:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868709; x=1737473509; 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=/d4iBZJ3r931DOCGukuu/0h9Or44VrIVD3hzoFAX6nY=; b=h/w/dpAF6EFGk6sg9pebrS2lLNC+55gD4hcy2KPfr96LptWOY0KyiRk+FOdz7FkwAu NfKn0I09y0StokeTwGy4WC7TLcptwmaj15QPdZKRQsUfSzDxMtcm/+T+tvt8/ZzN88j5 gNYc0YMD4upkNBluiPYrIpq69wtvgDRQlm/Pe26FFH2ZTd/xJ60kT4JV07Gcw+aJQsWd cDphIHPApaToUHkr52YFCvHWA1n8gZRQu1HLaFo9AKcncJlHvp4geLJvNIUPzADSTj9L BRWcAevPsiuweor2Zc3yK4T1T53XQ3Hve83fUYiJcYmvjOLA/9XQPQCgASbMPji8kLNL ceYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868709; x=1737473509; 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=/d4iBZJ3r931DOCGukuu/0h9Or44VrIVD3hzoFAX6nY=; b=sGMN1h+eex/aCdq9w6QJ1s8d00eLBS1xJ1ttO4c9JXk6EWX/Y2c886Q+NKk+ccW/Uo j7+QzJGlXL8DucppAD3W9abFXug0oeXTMQZSY18xYmQWHhyISIw5g5UNLDhnF1BKLMVD OcZdW+ZLOkI6XbgXlzC6clLVPJSc3R3l5M3BoSkozF05Cc+336hsO6o5JyNTP61a23Ai JBoFpAn70Oqpbe8TECsw2iSoiQXeHq9Cen0Y4xA8GPJL/pN3yXBlUqupKWILxCoRnToc +pU2OuyGpwhnbi/ZIAUu/sQpRbSE8bgZa1MAHHvk4aSfw+SPuZmgn5FnssS42TQfYe/F OVNA== X-Forwarded-Encrypted: i=1; AJvYcCXrEGw90k42gFhY5dgUxXHihammX2bBOE7nR4TYBEXM1Ft1+vXL8UcEaZysNvy4XBJFcpZ8AOM93rM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8LyYgdNdlNWJvnyyqlYkkKEfxograkwFFTcVY4VwuBevVf7m7 7piMBK9jfZ4tdn7SGhy5uYBTecAyZhhJpjgCl8u0+iahdsKmwrwXJkymqnEAAPg= X-Gm-Gg: ASbGncsTrI9iMi4TPN6UVyHzaayxXxrj/Tk2mVHgWTk+PnVAZiyQIIuFnQq6GCmSEjx uak2E9yzR3YINRaoozY4T3Vx0d0qC06aY7hYvayimiRpRjl50TA2u8DAeqzmDd0PnhlyQVnoX+s vrN7iofgI1hwybgyWFJjummBYSqvLTz6HqOq2W8QB3tu6NiH4GoyKkoPS2Os4W5skwWENnvoMN8 /EoKhqtjaTR+FEUG54SyQYkHgeMybJ1crhX7npflZhViLbGftM+fA4apBw= X-Google-Smtp-Source: AGHT+IFms9UiV+PF4o0FViAbBpzFXZQSmkQPq9Fro0GWF4ObbRaN0Lk34b6EYD+QAzvkkhtkVZRtzw== X-Received: by 2002:a5d:6484:0:b0:385:f092:e00 with SMTP id ffacd0b85a97d-38a87355760mr21235499f8f.50.1736868708533; Tue, 14 Jan 2025 07:31:48 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:47 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:13 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-4-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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, depending on the DAC type, target TRANSFER_REGISTER "MULTI_IO_MODE" bitfield can be set between: SPI (configuration, entire ad35xxr family), DSPI (ad354xr), QSPI (ad355xr). Also bus IO_MODE must be set accordingly. About removal of AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER, according to the HDL history the flag has never been used. So looks like the driver was including it by mistake or in anticipation for something that was never implemented on HDL side. Current HDL updated documentation confirm it is actually not in use anymore and replaced by the IO_MODE bits. Reviewed-by: Nuno Sa Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.h | 8 ++++++++ drivers/iio/dac/adi-axi-dac.c | 25 ++++++++++++++++++++++++- 2 files changed, 32 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 ac871deb8063..ac4c96c4ccf3 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) @@ -722,6 +722,28 @@ 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; + + if (!(mode >= AD3552R_IO_MODE_SPI && mode <= AD3552R_IO_MODE_QSPI)) + return -EINVAL; + + guard(mutex)(&st->lock); + + 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; + + return 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); +} + static void axi_dac_child_remove(void *data) { platform_device_unregister(data); @@ -733,6 +755,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 Tue Jan 14 15:30:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Dureghello X-Patchwork-Id: 13938882 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 119A31B6556 for ; Tue, 14 Jan 2025 15:31:51 +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=1736868713; cv=none; b=eik2ivkW54r6jeBgKIYukNj5Q54F8uDK3Jq3eU8QDb33MqAEvmt1wB0Ms7AR2e1uiIl4dPp5gRG802pKjFuYzP5508vP03Xq9gj22BL038NrzAhgDFQcNZHLoAL0QxDUkZYreMRR4fjjM2hCIVXWDkihokU8bxGe2t4MYtDre2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868713; c=relaxed/simple; bh=FGkqYiXXh/+bxSWU1J+RITwSb7AerkurSv9AeODl+PE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=abCugnRKU5ePqZh27BYulB0qnaZP2/31Xc8x0LHjYcpE79yHw2I3y2UROOpW3Z8qduh30kwBY1qsuyMBIaH5PChSaoRwG3tIqANHQmp8eSq1dB/pbC1puzeNMiT334nuGmsRP76QX3J/wE33sOCNDa2ayyZOZyCWXTrCiXEqX+s= 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=EghShoJj; 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="EghShoJj" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-385de59c1a0so2792465f8f.2 for ; Tue, 14 Jan 2025 07:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868710; x=1737473510; 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=Y9+dDQA2ZUdP/rTzes45J+HZpWx/w4e6GLVk9fKNwPA=; b=EghShoJjZC7n83byKz4XC64Hw+55eaDPWS7WLznth07smLO993wqkD1BymhlnNPf47 ZXPsKdcF5TUIge0xRwITHGashAAM9fiM3+A/p6K1JzN76xBSD9lyzCQetYAfaBQh7Aiv fO2OEICszkf5SRzr/0X6N8odUxId2sv5sVi6jhOYRvuK6Xc5SD4l/t/+QxMUeTM9157K hI0/Q+xBVo0t6iHtqvM9aAHHgs3VOi/ty814uwj/pYiyKcI+o8kqui1VmfdLoy0UoC88 AS2u29O3SPK9NAHEsN2Tib8K3glq5EFetRpqEVRgnA3Lqcj5WQAlKR0IQtt7MW/qYNEI /GaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868710; x=1737473510; 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=Y9+dDQA2ZUdP/rTzes45J+HZpWx/w4e6GLVk9fKNwPA=; b=aXHH39ZnPzbgtqViXlHexBlERRzdip6RaQqXFmi+4mBQncGOTW0G/jLn8WsNdSBXRi D1lljBXuFZen4rMRwbzYegaYMBTOjia0zXma7n5C8P6yykLVfA2pVfv/IXNBcElAgoj5 LIBi9emjRgCqGafVYx+crPljxc6MCfVIbT/U0ah6HwyVv+qFgm8QhXIoe/4nk2dA46W+ wo2C1CVczvy7gA+YmmgPCw6eVhYfqXyCEoh3t1feSLp6NW/4cAQbbqSOZbR82mBKB1HB KDoMXxm11N8rolG+nCRja/ND7gBKna3B/vDnn7MVcEYIKAa5fbgFSnSQsVLyfcdRF9Ty 3KGg== X-Forwarded-Encrypted: i=1; AJvYcCXigwS0fplQIgE90ob0/ttQpYd0PmK+plK+obmNsfjPv9R53CrYGq/K52+rLgE/hRS+ASSIz7vDVEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YynkgQbs9vajjCB+BQr7vNMdBVYnIIxN4sFxtd5GL+OBagRc/ET F6HtxhRmeouztNNBSbVP4c283zTOnoIHLH6dBm/7cYDPRRI6oiBoA2qQRpZpBNc= X-Gm-Gg: ASbGncv6VsLHvFZPkOtihGlB3UoVW5sMTOkI5ghRMg7wx2sVYFyPLutxmtVHdPPkOZW pHG+JPOOaqwXLUSzut9er4itKa4sdaVPIFUmItG30JRtTy2M+KPcmpTGrqhGaGghfQzAiuCdNx0 smna3YO7QbENJsj40o8GwrT1CSTNNCCYebQddjYt/E0Bn5u3MaUyKWS0gqYUQN6K+xn8zhFAMoX JiSxe3/LYOIQkwLMc+5YM/aHlZXaRJtn0UWlj2pcsq/jVlStIiZ5OTLD+c= X-Google-Smtp-Source: AGHT+IH7AnS8Xy0AvaKh32AoS3bdK4ykrox2/qO5FDmQaEgt2abKbZj4t9TCxwZlk0zyzle/K0RGGA== X-Received: by 2002:a5d:6d83:0:b0:386:3864:5cf2 with SMTP id ffacd0b85a97d-38a8730497dmr19668664f8f.19.1736868710473; Tue, 14 Jan 2025 07:31:50 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:49 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:14 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-5-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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..6bf995b50395 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_warn(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 Tue Jan 14 15:30: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: 13938883 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 685B41C54B3 for ; Tue, 14 Jan 2025 15:31:53 +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=1736868715; cv=none; b=guhrGCnXdKriZ80JF1B9+xiM1B9fKpKIvR1oEMY2m6r7E/XEOlKfyYTuLE8IAFE+qaWB7IO38yTYxYg5cd2oIB/qjkeNhd9+9swcAjMMxwnyRH9ylhzIpdHUSE7dYgzqR299AMD6wDlnUuIcL49ZyU823IX31dnAxyZeeuBZSXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868715; c=relaxed/simple; bh=UItI2hZUiFhSBtbcXWs4AMta6KQvhi9R1iJhmuA9Jg8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hmf4TyU5xScTUDJPoE/mTl7ZF7JKBK5JLIHbx4+EhNu2cGwY8cVYgZ09sdnyLdfF+4s537V4RqOZ/WRLd2ZWFQGJ5epPKt2ApPPaDEKtzQLgcEht5babJwuP2liegowhjCNOLuxGUANECaVQdBaDeWdQN76FfdTeh4PF1IR/9G8= 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=C+CZ7QIk; 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="C+CZ7QIk" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-38a34e8410bso2781558f8f.2 for ; Tue, 14 Jan 2025 07:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868712; x=1737473512; 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=b7AD+wJ8IOjuFx6p9gLrTL8TthqHXj7sqaFRN+y4/jo=; b=C+CZ7QIkRs+xH/tlLX7fq2E+5f532SpB2pl9myceRlKJESfMHIRCuRmnRkbl8WT/Is kw5EF+hKWuys/xsZCDe/pMsZ1wjR7ykSXZSwJMq72ECs+vO6XdDXhJZJwgi1ItcW2vfj /AKw0VWrNSafO9dtHsx+lDuluyyjWmdi5VSzHbbfLDd3214AzN/G6oVY4nF0cYuu3Q6j hwig2zQyb/JrOh4t+hxoZ30Auz38MroSJfG2EH0Zbk+yW+w86fsT1aa0wxZaLmd/loPM D5LN/DcNPzX79fS1vqGSipHxn5gYELJBy4b/UUPot7LJ/oOdEsNoUXBIvtF2+4vo0zux Jk7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868712; x=1737473512; 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=b7AD+wJ8IOjuFx6p9gLrTL8TthqHXj7sqaFRN+y4/jo=; b=V3sidu/JJ+sqhiezP5NzARRevoM/VEfPUBL3Q9LCYrRWWnAtJlMi0AIdRUltdMFQcO /I0ZU/y527X+0S8g7d1Anwl1kurmkjVfibN7TntbtxgGNtAQSvkPb0M0I0XfvieoUZv2 C702cGVOm/Fgc58GAiKTDTG8RaYiCbVZ//KCTxo8/d4f20mlSXBiu3lwLDbLLv35ZcsV cV+YVk++M3DGeA9O6ytxVikDasqc/B7vVDRWaNYTkzG/105nMN9sVqdjtuzyi81nHIzM 7JUaxiJ2CSZGkzyz99pS6vlYpwELPdA19BSUvgsTmyKUCPvF1rT8xoU3NQiZH9sHyhHd hk6g== X-Forwarded-Encrypted: i=1; AJvYcCXhys7lkNqIBpef/z+lvujgOMthgtNFI90OaqVlzuzCpTtfeejwroq2RXPSfGd3/vpCMtZvP8PPC2Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwltXZ82EsGH6kFTzpaVH0OLhII3G6vOnf1Bg/vP8V8rmEEXkA/ vL7rkJ8fWY7naUUxGkdgMN8l9r4KMe3CkhiJqqonc8wmnF3+20cfCy+Aedmcres= X-Gm-Gg: ASbGncuurXhfi5Rw26i1Y+1mEjUnFw12isz/0F0M3J+fVFZv6IxdRzDnxkRV6zx4frA 0lrrzVTMkYmVrArChHG0jXh1bUOdRaiMOuOxk7KklM5733G5XFBpH3K/W2vrfNOyOYQFTDNntEi 0vY659rwRqtVDshnH+fntxnTjZd9HEfLISKtLIL5ElYCFrxlDvYF+nhZ3s2BpwmUmcvPv7VEspx Tace6fOFNytEN0HsWN6oplyTafInjIiXV9TvxxIXTpb/+RAQsdhSZf5alY= X-Google-Smtp-Source: AGHT+IEBdBTstRr21+IGJ+9lga2m4RjpAaan3Vw+TrGj1moJe+FA7MQSsGPvn31Jx0HzgkVxxzHBZA== X-Received: by 2002:a5d:584d:0:b0:386:4a16:dad7 with SMTP id ffacd0b85a97d-38a872d2a33mr24271920f8f.10.1736868711783; Tue, 14 Jan 2025 07:31:51 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:51 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:15 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-6-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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 because 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 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index 6bf995b50395..25ee716b57cd 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -137,13 +137,20 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) if (ret) return ret; + /* 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; + /* 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); if (ret) - return ret; + goto exit_err_ddr; /* Inform DAC IP to go for DDR mode from now on */ ret = iio_backend_ddr_enable(st->back); @@ -174,6 +181,11 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) iio_backend_ddr_disable(st->back); +exit_err_ddr: + ad3552r_qspi_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, + AD3552R_MASK_SINGLE_INST, 1); + return ret; } @@ -198,6 +210,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 +328,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 Tue Jan 14 15:30: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: 13938884 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 B25511CCED2 for ; Tue, 14 Jan 2025 15:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868716; cv=none; b=W0YivMhAjRuwFHisO7pMRCuBW3cFNxs+pgYl3aivcd6ix1XNLyOhbwK+SXi2NQoENEz9zjdoPvwMX4o0EjWU5jrE0+sqI8j0p+UBvBrUvjEbj1T2QXG77EkQ9SsJcfQoB0ZSfgd5HHFspuQiitiLKw0iz/zN/exCzH6QDwarVLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868716; c=relaxed/simple; bh=v1+O4noY3O0s65OrfzA8R59Ys8F2s28DZZGvtlbpJsg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cpUwct/FyoUepiCnVqzUYr2kLDF4FVTNzwSQ6u60OJ3YagfYBMO+qe8+oL72mNuYXld1YX3liZwx58vNVfK8TFxSdqKRgY1IsPyeUocEita15Ll9BCIg0Y5opoFjx18/pALZMa/N7EY7ijYjH3yXPABd/ZWpnzw37wfoyP+Qh2A= 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=b+fxTTb1; arc=none smtp.client-ip=209.85.128.41 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="b+fxTTb1" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-43690d4605dso39431985e9.0 for ; Tue, 14 Jan 2025 07:31:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868713; x=1737473513; 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=ZuhTyNXJGoJmvY2b3b+eX+Gs7fiX+q1of8RI8yzzWR0=; b=b+fxTTb1TzxwAAIi9ec7h9eiNoFnlC30+kRP+rLVD2pV7wjZDmAaH6RCROwcrffXqt IJb4d9FVY+gqixbwGmPk9Bmhoj9Qie0LrtFJbbdLpkt3xcWEZDS5UpqAAyo2eZJSrIZG x1uUbY4MIZxp6MhTbpMkYM9u9t4NgpvNTb855y9BzmT0DKOpDqQVdyBNv5jW+NC5BpDi oM3BH+94p2pQBT9m3S7b5Z+E7FsGwCEMKtbhlZRq9JYO/vbGJZkLJKZBB9B4F2xERUQt ajw/+F8bbVj2pguKLU1XgH5n5G0kg9i63kxaHVhhU35nAnMpBz9XL/mXkPMN3QbzTsnP T/ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868713; x=1737473513; 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=ZuhTyNXJGoJmvY2b3b+eX+Gs7fiX+q1of8RI8yzzWR0=; b=er8fkC/KuGX4jPq3Ack6ZBDPua7QttQPT5krvVSu5GqqjubuiR2QVC84xWK9w1jFN4 izzsSv9HfylUELa9MoygzUXQ7822dVuOtgUHkDIEPRvGqe/i2Yql3k/CS/Pj+WltA2ew lkmRBQ3T+NLieFfX74CzZ5pLMkPy8zZ5mbHGXw1x1wmgg/WmCMIcDs+ZF1RTaKgciUtm kTebif1puoxNS9mhIBUnUHGx+lgMC3K8IQ0IodSBXE5SzkMsaN87cJJHZggpVkgVPJ/+ MOyNIGhEgGbAnJTXwFXUlmgArH37BMn/d9dKhm5cfz99iYJR+jlfMyqpoywQrrAWMVzG jVRQ== X-Forwarded-Encrypted: i=1; AJvYcCWMMij6k/5lwp3JUGcxf2s5ZOZkUfwh1CIeMwuzC7jdemFG+kvOoh3ID8zlJBIk2YpvQKTS0hnUiRQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyHRosgM2awP9fdeANO5+/bPCkyLVOX7N2F1KcKdVN/bjN2Sa+e /prGqaoh24lD4ZG0W7tkIg49rsGOCs5J/bEdXWEM4OvoAf8NDj5HpPxH6/21Z9o= X-Gm-Gg: ASbGncv3SzIZ2NOwGesdOvlDGMgLXVFbs1P9yZzEQSK/Ba4f6gANQO+YWTKno9KnUms Y1mpFCoEYbGxo4oogCIiVPJjcgL25wAygHrI1qfpKYHs4uGAoyEQ5/1988WccdSDgYA+rMrv5wd 26Q/54Gkjy8AMhXQYvutNQDUmhwH9wS1C4BnIfp+J0uAHPYya65HmdA9s3j361xzSqCXjisHIJD 2Mk+tra1ylBA1WxDDVtwZHyWYJJ4+Fdz75wt1c9A4aE6kXYnjEsFG0nIZ4= X-Google-Smtp-Source: AGHT+IE4URCzRCcKwzMMg5I6jlVUcPCNFuZwZxe/rvVw9KP+ZpeRnhfpFCTY29EMVrFPBsE7qLoIQg== X-Received: by 2002:a05:6000:1564:b0:38a:8d32:274e with SMTP id ffacd0b85a97d-38a8d322b18mr18955634f8f.5.1736868713121; Tue, 14 Jan 2025 07:31:53 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:52 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:16 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-7-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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. Reviewed-by: David Lechner Reviewed-by: Nuno Sa Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-common.c | 46 ++++++++++++++++++++++++++++++++++++---- drivers/iio/dac/ad3552r-hs.c | 8 ------- drivers/iio/dac/ad3552r.c | 36 ------------------------------- drivers/iio/dac/ad3552r.h | 6 ++++-- 4 files changed, 46 insertions(+), 50 deletions(-) diff --git a/drivers/iio/dac/ad3552r-common.c b/drivers/iio/dac/ad3552r-common.c index 03e0864f5084..ded90bf57baf 100644 --- a/drivers/iio/dac/ad3552r-common.c +++ b/drivers/iio/dac/ad3552r-common.c @@ -11,23 +11,21 @@ #include "ad3552r.h" -const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2] = { +static const s32 ad3552r_ch_ranges[AD3552R_MAX_RANGES][2] = { [AD3552R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 }, [AD3552R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 }, [AD3552R_CH_OUTPUT_RANGE_0__10V] = { 0, 10000 }, [AD3552R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 }, [AD3552R_CH_OUTPUT_RANGE_NEG_10__10V] = { -10000, 10000 } }; -EXPORT_SYMBOL_NS_GPL(ad3552r_ch_ranges, "IIO_AD3552R"); -const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = { +static const s32 ad3542r_ch_ranges[AD3542R_MAX_RANGES][2] = { [AD3542R_CH_OUTPUT_RANGE_0__2P5V] = { 0, 2500 }, [AD3542R_CH_OUTPUT_RANGE_0__5V] = { 0, 5000 }, [AD3542R_CH_OUTPUT_RANGE_0__10V] = { 0, 10000 }, [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"); /* Gain * AD3552R_GAIN_SCALE */ static const s32 gains_scaling_table[] = { @@ -37,6 +35,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 25ee716b57cd..98711f742c70 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -532,14 +532,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..3dc8d1d9c0f9 100644 --- a/drivers/iio/dac/ad3552r.h +++ b/drivers/iio/dac/ad3552r.h @@ -134,8 +134,10 @@ #define AD3542R_MAX_RANGES 5 #define AD3552R_QUAD_SPI 2 -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, From patchwork Tue Jan 14 15:30: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: 13938885 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 757EB1D54CF for ; Tue, 14 Jan 2025 15:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868718; cv=none; b=oss9b2cw/WBPoMOdXuTHQ5/q88DAWAj3bUZz2znICm6g2MbNdRZvxo1waUBEmMff1Jm9HzqQjkaMX6uNPpksjGnognJuZaPs3/6p014OG5VLhnxSb9R4gjEG1oiCrNgLfU+2TeuD5/tDgFxfG95t5npB9Eez0ISBUHOIMsLK+SM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868718; c=relaxed/simple; bh=3NLonDaZXZHxQwUe77tNiYWg1OYTBJ3xp2Pe4pve3KU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mgLIXS6XrR2kUSV4c930pdJmyRZevvL3ya0PZMN5NpAsujHbJgLe5kt0U8p8AJYSO3ZfYWBcoc4YxD6jzVXDyTmj1v83RiP42gY//PJYWzqUqYas/U11JKCdP8odZ1QCb/qjo5S3xdoMLu09I5i2eNS9aoSgIfFhkp25YViovGI= 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=R90AKZTV; arc=none smtp.client-ip=209.85.128.49 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="R90AKZTV" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4361815b96cso39998955e9.1 for ; Tue, 14 Jan 2025 07:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868715; x=1737473515; 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=dl1oUp9XUDJT3tl0OP8G5+aUHgYGYfeR2svkPzgkqwc=; b=R90AKZTVv61ku/u7zZDoYYkNvk+cBeesJVTA1j9xm4S8fljwmcventdWuM65LHAkP8 sve6ZmXwSjo4dqJ3HyM3VkNwBO9cAJJnwYjqlPgA9N2UUW/LCtdkBSuaevRf788aGqFJ PlwI8FHrcGK0c6LVcaolVcICppwx9ERECJncNvAsMddsfqhIrnOE6YHWFBypZWH166Ip FRTvL6n/2U9caqXN1UAxtCfdDcoSdh4FiZoGpezwWNxr5bf2LnXrA5GXpJJwXHLYfig8 vlw4XO08aV1nixToGiEKIH9G0Fa/uQye3faxvCePcjrWq35bh9K89YLTC1hJfTkr1C4e fvMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868715; x=1737473515; 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=dl1oUp9XUDJT3tl0OP8G5+aUHgYGYfeR2svkPzgkqwc=; b=M9jughRucZU/tk7CQBmOW8IhXCtxlRL8vKbnRId1QtIo7hWJk4itUps00gL2PtIvas oXWLMVv7aaypmbydfHPzR5c3ooO7QsdQnEf4/A3v2fT5Xbox0bq31Gk5QZ6ZZpxNPEqJ 7e6CxgHY55psFRLOl/ycDWrXSwkE7mx6abRpZ9wbHsQf10tjGsq0gJXRrowexu4t9gBE uQnfaoBD5fFn5rmflzMBbmZVrtSPq5dgSQgu7RFy/bGba9ytlI7wXua0OBHOE3+CxK8s mUTpow3p9k3dwyfV8zodJFR5rBsoT5b5PgFwe395mIZGjY8MH8Cawk+3zxdpZzuiHJps mWTg== X-Forwarded-Encrypted: i=1; AJvYcCUo3D5QXShPnNaau4bSxbiWZybG6upwAi8URmj2rZGcYdB1OLRGGzc0KVAivUITKFtgwexpU2fX8ak=@vger.kernel.org X-Gm-Message-State: AOJu0YxEOorZVK2wnC8Xk6sd4ickHfdDn2Cm+rq3cvx3gYlx3uHwRLuQ jcySulaHAbD/oJzYEmfFSXdgrNEiwREaf8tB8WYdevGSdLqu/t5fexX2Q3H3uzU= X-Gm-Gg: ASbGncsHqud3AESKPhOkHuKDvWO/PhAeqwyV497+y2eZr9wZDMFfbiv4znV6DKc8lVs sFq1HvTmVX509eFJfzbr5KspZfihuYQPfs1SvhFX5RJzR+jt+29s+8AGCYqR2EFaElx3eDKGqVU LbLw9EHfPcVLoc9HY0TOma4Q9+28nC+HZhEqEgYmu7pSz7kWYdqYPOmXxGiSSivtF9BPZ2wqRn9 q75X+XATvZVl1eoOxSoM0PfVHs1NNf0H0bnC+MMuunzVs8+KYUnnVbbAkU= X-Google-Smtp-Source: AGHT+IEfWZ2AzTIekjMqWBTl6vtRsgu2N7dbvBTSOolVxS/YcloLUk61fkXYN/4GB0Xa3Ov03DzHjg== X-Received: by 2002:a05:6000:490e:b0:386:32cb:4aa with SMTP id ffacd0b85a97d-38a8730ef59mr23946987f8f.45.1736868714557; Tue, 14 Jan 2025 07:31:54 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:53 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:17 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-8-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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 sample rate to respect number of lanes. Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-common.c | 4 + drivers/iio/dac/ad3552r-hs.c | 260 +++++++++++++++++++++++++++++++-------- drivers/iio/dac/ad3552r.h | 3 + 3 files changed, 216 insertions(+), 51 deletions(-) diff --git a/drivers/iio/dac/ad3552r-common.c b/drivers/iio/dac/ad3552r-common.c index ded90bf57baf..b8807e54fa05 100644 --- a/drivers/iio/dac/ad3552r-common.c +++ b/drivers/iio/dac/ad3552r-common.c @@ -42,6 +42,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"); @@ -52,6 +53,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"); @@ -62,6 +64,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"); @@ -72,6 +75,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 98711f742c70..e8e309046f11 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,8 +52,19 @@ 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_hs_reg_read(struct ad3552r_hs_state *st, u32 reg, u32 *val, + size_t xfer_size) +{ + /* No chip in the family supports DDR read. Informing of this. */ + WARN_ON_ONCE(st->config_d & AD3552R_MASK_SPI_CONFIG_DDR); + + return st->data->bus_reg_read(st->back, reg, val, xfer_size); +} + static int ad3552r_qspi_update_reg_bits(struct ad3552r_hs_state *st, u32 reg, u32 mask, u32 val, size_t xfer_size) @@ -36,7 +72,7 @@ static int ad3552r_qspi_update_reg_bits(struct ad3552r_hs_state *st, u32 rval; int ret; - ret = st->data->bus_reg_read(st->back, reg, &rval, xfer_size); + ret = ad3552r_hs_reg_read(st, reg, &rval, xfer_size); if (ret) return ret; @@ -56,16 +92,20 @@ 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: - ret = st->data->bus_reg_read(st->back, + /* For RAW accesses, stay always in simple-spi. */ + ret = ad3552r_hs_reg_read(st, AD3552R_REG_ADDR_CH_DAC_16B(chan->channel), val, 2); if (ret) @@ -93,6 +133,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 +145,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) +{ + u32 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,10 +209,10 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) return -EINVAL; } - ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_STREAM_MODE, - loop_len, 1); - if (ret) - return ret; + /* + * With ad3541/2r support, 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, @@ -144,47 +221,98 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) if (ret) return ret; - /* Inform DAC chip to switch into DDR mode */ + /* + * Set target loop len, keeping the value: streaming writes at address + * 0x2c or 0x2a, in descending loop (2 or 4 bytes), keeping loop len + * value so that it's not cleared hereafter when _CS is deasserted. + */ ret = ad3552r_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SPI_CONFIG_DDR, - AD3552R_MASK_SPI_CONFIG_DDR, 1); + AD3552R_REG_ADDR_TRANSFER_REGISTER, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, + AD3552R_MASK_STREAM_LENGTH_KEEP_VALUE, 1); if (ret) - goto exit_err_ddr; + goto exit_err_streaming; + + ret = st->data->bus_reg_write(st->back, + AD3552R_REG_ADDR_STREAM_MODE, + loop_len, 1); + if (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: - ad3552r_qspi_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, - AD3552R_MASK_SINGLE_INST, - AD3552R_MASK_SINGLE_INST, 1); +exit_err_ddr_mode_target: + /* + * Back to SDR. In DDR we cannot read, whatever the mode is, so not + * using update. + */ + st->config_d &= ~AD3552R_MASK_SPI_CONFIG_DDR; + st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + st->config_d, 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; } @@ -198,11 +326,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; @@ -210,6 +349,17 @@ static int ad3552r_hs_buffer_predisable(struct iio_dev *indio_dev) if (ret) return ret; + /* + * 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); + if (ret) + return ret; + /* Back to single instruction mode, disabling loop. */ ret = ad3552r_qspi_update_reg_bits(st, AD3552R_REG_ADDR_INTERFACE_CONFIG_B, @@ -324,6 +474,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; @@ -339,15 +490,23 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) if (ret) return ret; - ret = st->data->bus_reg_read(st->back, AD3552R_REG_ADDR_PRODUCT_ID_L, - &val, 1); + /* + * Caching config_d, needed to restore it after streaming, + * and also, to detect possible DDR read, that's not allowed. + */ + ret = st->data->bus_reg_read(st->back, + AD3552R_REG_ADDR_INTERFACE_CONFIG_D, + &st->config_d, 1); + if (ret) + return ret; + + ret = ad3552r_hs_reg_read(st, AD3552R_REG_ADDR_PRODUCT_ID_L, &val, 1); if (ret) return ret; id = val; - ret = st->data->bus_reg_read(st->back, AD3552R_REG_ADDR_PRODUCT_ID_H, - &val, 1); + ret = ad3552r_hs_reg_read(st, AD3552R_REG_ADDR_PRODUCT_ID_H, &val, 1); if (ret) return ret; @@ -357,6 +516,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_dbg(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); @@ -369,14 +530,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; @@ -400,10 +553,12 @@ static int ad3552r_hs_setup(struct ad3552r_hs_state *st) ret = ad3552r_get_drive_strength(st->dev, &val); if (!ret) { - ret = ad3552r_qspi_update_reg_bits(st, + st->config_d |= + FIELD_PREP(AD3552R_MASK_SDO_DRIVE_STRENGTH, val); + + ret = st->data->bus_reg_write(st->back, AD3552R_REG_ADDR_INTERFACE_CONFIG_D, - AD3552R_MASK_SDO_DRIVE_STRENGTH, - val, 1); + st->config_d, 1); if (ret) return ret; } @@ -533,6 +688,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 3dc8d1d9c0f9..768fa264d39e 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 struct ad3552r_model_data ad3541r_model_data; @@ -153,6 +155,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 Tue Jan 14 15:30: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: 13938886 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 8EE9B1B86D5 for ; Tue, 14 Jan 2025 15:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868719; cv=none; b=ZhqGXm9UegxAG56BIXpOp/8SIImEqXheJJIp3KWkibAgOmS+ylqB2UfL5O84+S4OtWH2AtKaGgiGvtEdeM8OevSiEnip2S6Nk8Tl+Qmvxw5hOYlBqCCFv7Dm4Q6gVXO2GDPVDQo2nJ4T8pXEySoXckj3FX78m5geEtP1Qd3ijz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736868719; c=relaxed/simple; bh=qYyzsrOrzx5St4FThuHvNxAMEp85//w2zLTC8Y3IIIY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ffZ31a1fg1/GbCk4IcL6yOhmcR1H4aCxsPbZPNDb4P5mtpf2DniDc1Cj3SZEtxnKrju2C9hhJDk/nyJh3G/YVEsHHzb0BLFSQl7UyjqxCEgOSCac7rInpB2tquSZ3QwXUmFjQddafnJtj0x6q/5nRn0cxqyZTIfIBcET3pu+noQ= 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=BiL9ZafD; arc=none smtp.client-ip=209.85.128.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="BiL9ZafD" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so40521315e9.1 for ; Tue, 14 Jan 2025 07:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736868716; x=1737473516; 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=ylCBASlMPJkZHv6GhjEiCkHB/0+Vz29gsqJdZKd5MdM=; b=BiL9ZafD5bf+6j7JrIAiCjJcNrdDSrm0Xul3MKobnYOc6qu2HsAkTQWcFHfIa/Q0Nz LDLxLRlh4p3hrwU8FOm+u/EZfH1ZGKnlFq2yTK+dW7tXpK8B3b/QUpEKyWUJMIoI10F1 sYWcG3F3g+sUCEhLKMO4QC/Hg9IJv8A7WJt1V5gjzLElnT6LKTW9a/mf1AL6sXh0qoHx GxaCoepbuiVyz+w7/p/fzD6A8mv14GjwAVm6qCG8dLzVlvuDgMexFinU2Cfc/uWiHktD Ho7/K+RId2mZ1v+zZaw/ctOHhKkw7L1zZzQZ5XaeiiE3pCebdfI2viyZaFdCNOks2SKT kU9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736868716; x=1737473516; 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=ylCBASlMPJkZHv6GhjEiCkHB/0+Vz29gsqJdZKd5MdM=; b=ZYaPGwjK6/5wUpK7nBIgqNHj7roUvV7oGK6tDaxZhl1QE887+0+9s8GyqkXbTJezbJ SB1RakmroQ4BD3K9Yy1cWbhLOyEdhMbxjUeHK2fCVceWYDkZgI853jznuP6uS5FgOnjq Rbu7wjiB7PVgBza2ZYDbHSgQVsByoGTVLmbeYwRK1Xvg3iRI1Kz5C/qb07370eOT1ZDz MeA5SCdW+DATcPx96JVyV1OHHkbYuMKefiQJzoHinJGAbyJEFlGZ4DRvC1Gu13/nrscz 1TxQtv/WKtKira+ECdHjfhLRJIfr+h3GshA87UEdWCcMsRYakPqIF8qWYzCQFO9dZMho kffQ== X-Forwarded-Encrypted: i=1; AJvYcCUkKPfUa2taqinuHHzwKtBSaRicAsy75Am1TypRrcmk4K4scFlpl5SFv509sSUL604D2YSprdpX9Vk=@vger.kernel.org X-Gm-Message-State: AOJu0YxwUbd8Qwa8DfQ5EMJlzDDYlUMDgu8gfAwghMLAgkfCtcXwl2B/ zR84yroZ0wjCobw1Tu/dXrnLU8zPjyn0VNM7K4QpO9/vfsi3zqMda1bedWrWTz8= X-Gm-Gg: ASbGncuQtST6cbREEbm3OgGtq0V37vXGOo+7Bdljsq1BFxVePKsK30jsf1x2Ou3e0Ax AR9LU+fNumV6+Onf8RZ3nvnM6frtNC50nM99ZZvWj9s6UkgfsYPAFMogt9jK2+ECIhzQdir4+5b oKjsxNRi756kNqe+SHJ9/N+AVVzlsfZ+mb9nplzKeVZBsZuLFcq9pSLzaoLj+KL6hvVrn0jU94E HKDcpcQ9w5Wh9AGqnUGnJKFLaiOoC4n+SAMEyFiCCDO3+yp3HO9PuXoPN8= X-Google-Smtp-Source: AGHT+IHGq0wfH03pxXCXZ0hcHDHI669Hj0ZbP8/2Zn0o0ALPUihu4LyMgScyCO3Pg4kIgBtCvARAqw== X-Received: by 2002:a05:6000:1787:b0:38a:41b6:d685 with SMTP id ffacd0b85a97d-38a872f6f17mr23199035f8f.3.1736868715927; Tue, 14 Jan 2025 07:31:55 -0800 (PST) Received: from [127.0.1.1] ([87.13.70.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b8116sm15049907f8f.79.2025.01.14.07.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 07:31:55 -0800 (PST) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Tue, 14 Jan 2025 16:30:18 +0100 Subject: [PATCH v4 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: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-9-979402e33545@baylibre.com> References: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> In-Reply-To: <20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-0-979402e33545@baylibre.com> To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , David Lechner , Nuno Sa 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. Reviewed-by: David Lechner Signed-off-by: Angelo Dureghello --- drivers/iio/dac/ad3552r-hs.c | 60 +++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c index e8e309046f11..c1dae58c1975 100644 --- a/drivers/iio/dac/ad3552r-hs.c +++ b/drivers/iio/dac/ad3552r-hs.c @@ -65,9 +65,8 @@ static int ad3552r_hs_reg_read(struct ad3552r_hs_state *st, u32 reg, u32 *val, return st->data->bus_reg_read(st->back, reg, val, xfer_size); } -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_hs_update_reg_bits(struct ad3552r_hs_state *st, u32 reg, + u32 mask, u32 val, size_t xfer_size) { u32 rval; int ret; @@ -215,9 +214,9 @@ 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_hs_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, 0, 1); if (ret) return ret; @@ -226,10 +225,10 @@ static int ad3552r_hs_buffer_postenable(struct iio_dev *indio_dev) * 0x2c or 0x2a, in descending loop (2 or 4 bytes), keeping loop len * value so that it's not cleared hereafter when _CS is deasserted. */ - 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_hs_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; @@ -252,7 +251,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" function. + * anymore, including calling "ad3552r_hs_update_reg_bits" function. */ /* Set target to best high speed mode (D or QSPI). */ @@ -353,18 +352,17 @@ 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_hs_update_reg_bits(st, 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_qspi_update_reg_bits(st, - AD3552R_REG_ADDR_INTERFACE_CONFIG_B, - AD3552R_MASK_SINGLE_INST, - AD3552R_MASK_SINGLE_INST, 1); + ret = ad3552r_hs_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_B, + AD3552R_MASK_SINGLE_INST, + AD3552R_MASK_SINGLE_INST, 1); if (ret) return ret; @@ -381,10 +379,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_hs_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) @@ -400,10 +398,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_hs_update_reg_bits(st, + AD3552R_REG_ADDR_INTERFACE_CONFIG_A, + AD3552R_MASK_SOFTWARE_RESET, + AD3552R_MASK_SOFTWARE_RESET, 1); if (ret) return ret; } @@ -544,10 +542,10 @@ 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_hs_update_reg_bits(st, + AD3552R_REG_ADDR_SH_REFERENCE_CONFIG, + AD3552R_MASK_REFERENCE_VOLTAGE_SEL, + val, 1); if (ret) return ret;