From nobody Thu Nov 21 21:28:29 2024 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B08A213B2B6; Mon, 18 Nov 2024 18:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731955985; cv=none; b=fI8nUB1Vbp9h0seX6N8Z7V6vIETATFKxFegw8omIp5zL3eyiWK+4XZGWcfXxg9xbyBJjKjVN46YddFJ4/cGGMHc4RWL26NxP9yic8o1Z3z3XYiLaDpFKIa+YghmAVgcKmDffp3sLpzbyY9mSUVrrGnu93TbUC2xi6TfTzyusy0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731955985; c=relaxed/simple; bh=mQPpVX1ii5nEaRzbZho2Fash2vHBJXygqIjjfYsgyb0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eCdrRLod975QFvydCZVh114EUATOUQqZHtBFD1mcF/+wDYF+NVNykuzTRKDKepDoOHEuHodCWr+2VOUEcmVi49Mge4ejpeMyh1yapcY8JcUmq0satUxC94NtKpsBbYJS8fNXp7izeH9VbTHKq7ex+AeKBN4kvmxWvffIvB8Jp/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=Ebg5+ppz; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="Ebg5+ppz" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIH9Df9031074; Mon, 18 Nov 2024 13:52:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=By8v1 wyraTVwOgre8y77EXn983YPMZqSKpChocECxK0=; b=Ebg5+ppzeoZHIatwM6uAx 6mgE96tOzTb9FL2kkzrjbe7LRinNjoap/7qBSQRvS4Orj4sQTYCVo7kflDMUqC6k AU6Jqmam2GSz2Vs008AfotdDV2nT3UZlvsCqLjBZcRp/PdWuAzJYxtxLnt72CYvF QOeHYdHmsUDRvuRuOyMTiJgIQK4yAV08+02EaVgZGeRMM+6HuFXx+bs0CzYQCJGJ bwmqw7mLE1pprU56HpWtMurhaWcrOzFYV+sPMgUOWUr7oFnXtQQiTuSI9a8y/mpY NpmRwJs8bVTdzyuLCebHzMp5FIyIupyxakhEPG3b3stRUUP8XeYPx/c8CiRdbk/2 Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 4309qt0cbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 13:52:49 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 4AIIqmGU063959 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Nov 2024 13:52:48 -0500 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 18 Nov 2024 13:52:48 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 18 Nov 2024 13:52:48 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 18 Nov 2024 13:52:48 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.9]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4AIIqZEJ010373; Mon, 18 Nov 2024 13:52:37 -0500 From: Marcelo Schmitt To: , , , , , , , CC: , , Subject: [PATCH v2 1/4] dt-bindings: iio: adc: adi,ad4000: Add PulSAR Date: Mon, 18 Nov 2024 15:52:33 -0300 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 4veCtguKVdTMikESGIENR0q7VI7mtHqz X-Proofpoint-ORIG-GUID: 4veCtguKVdTMikESGIENR0q7VI7mtHqz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180155 Content-Type: text/plain; charset="utf-8" Extend the AD4000 series device tree documentation to also describe PulSAR devices. Signed-off-by: Marcelo Schmitt --- Changes v1 -> v2 - Made "cs" the default adi,sdi-pin value for PulSAR devices. - Dropped AD7694 and the related vio pin checks. I forgot the ad4000 driver fails if VIO is not provided so I was wrong when= I said AD7694 was software compatible with the other ADCs. I see now AD7694 also doesn't have SDI pin. Aside from the VIO and SDI pins, AD7694 is similar to AD7685 both being 16-= bit precision 250kSPS pseudo-differential ADCs. The AD7683 part mentioned in v1 discussion is similar to AD7988-1, both 16-= bit pseudo-differential 100kSPS. To avoid complicating things, I dropped support for AD7694. AD7685 and AD7988-1 are the parts with features similar to AD7694 and AD768= 3, respectively. .../bindings/iio/adc/adi,ad4000.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad4000.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad4000.yaml index e413a9d8d2a2..4dbb3d2876f9 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad4000.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad4000.yaml @@ -19,6 +19,20 @@ description: | https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 4020-4021-4022.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/ad= aq4001.pdf https://www.analog.com/media/en/technical-documentation/data-sheets/ad= aq4003.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7685.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7686.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7687.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7688.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7690.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7691.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7693.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7942.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7946.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7980.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7982.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7983.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7984.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/ad= 7988-1_7988-5.pdf =20 $ref: /schemas/spi/spi-peripheral-props.yaml# =20 @@ -63,6 +77,37 @@ properties: =20 - const: adi,adaq4003 =20 + - const: adi,ad7946 + - items: + - enum: + - adi,ad7942 + - const: adi,ad7946 + + - const: adi,ad7983 + - items: + - enum: + - adi,ad7980 + - adi,ad7988-5 + - adi,ad7686 + - adi,ad7685 + - adi,ad7988-1 + - const: adi,ad7983 + + - const: adi,ad7688 + - items: + - enum: + - adi,ad7693 + - adi,ad7687 + - const: adi,ad7688 + + - const: adi,ad7984 + - items: + - enum: + - adi,ad7982 + - adi,ad7690 + - adi,ad7691 + - const: adi,ad7984 + reg: maxItems: 1 =20 @@ -133,6 +178,32 @@ required: - ref-supply =20 allOf: + # Single-channel PulSAR devices have SDI either tied to VIO, GND, or hos= t CS. + - if: + properties: + compatible: + contains: + enum: + - adi,ad7685 + - adi,ad7686 + - adi,ad7687 + - adi,ad7688 + - adi,ad7690 + - adi,ad7691 + - adi,ad7693 + - adi,ad7942 + - adi,ad7946 + - adi,ad7980 + - adi,ad7982 + - adi,ad7983 + - adi,ad7984 + - adi,ad7988-1 + - adi,ad7988-5 + then: + properties: + adi,sdi-pin: + enum: [ high, low, cs ] + default: cs # The configuration register can only be accessed if SDI is connected to= MOSI - if: required: --=20 2.45.2 From nobody Thu Nov 21 21:28:29 2024 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7210E1E0DFB; Mon, 18 Nov 2024 18:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956016; cv=none; b=iHrr79yC5kUugHAVkUJ1/W+ViNU0m4fnAx+z4YQFBByNml5NAzGMkFLyZIkH8W8UzriDcc3eJhC/W9fkV98Fyz/kdtLzuoIG2LsFtOj1nVf1yGsIx6eqJjfgsNb/TkSQZ2PuMzSj+ibTiMjvnW5Bm1orpssEQg5vnsliL4kE4y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956016; c=relaxed/simple; bh=LHfl5uf4OUxuRyZMtrgPR7+lm2rc4DSaGKM1rtAFcWE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iJq8coi8t3KecEG8lKN5k3EAwl5yhZxPMOU3Ng02Fgy+uXTE5oFVaKBEvkYfjkDHemkTaq3WDSVhg4fQUnxebKoGYQh5AOmwsFj5QjfcFEQ0zEEQ7faNs2uU+1tF+mnAXi4GTkv2Bmd0S3sKh5CdDgmURS8NPvmasYCC7cMt1w4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=bR6ozC/T; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="bR6ozC/T" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIEnk11020177; Mon, 18 Nov 2024 13:53:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=dWWsa OTW4pk8/fGx3aVmoRzEo9LkdzNQxdEyeNyVyoE=; b=bR6ozC/TCxF67aZjhefYj NckDi2apAmqBF+Z6YbM1X8GTfbxAxBkKjAvaiE3PHSNCXooEbuXV3Vlw7zPpbBe/ 0JALRovjbMY5vLtr/NcmAeuyJyx9exOuKeGzQR3IkevcYXgZV4IbJjNZ+uG2U+Ku PLpvPR9+4HUh5L8MYtBvWz4WKSW3A7UzN9EdEGV4Ok3JrDevwx0UJhRcOJY6vkyi 0B4OcwvcvSze0mAtjFGeoY7qyuPe5Cj4tPs3y9WTFtjnz0LUPi4telCS9yYa2kjr u6guVKLFXhcaLb+/rFyS/PTsNyT1OGGyfPCAQNlZ3lfgjAH3wpH1JsOYPFsWEiTM A== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43025m2fun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 13:53:19 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 4AIIrIh7063995 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Nov 2024 13:53:18 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 18 Nov 2024 13:53:18 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 18 Nov 2024 13:53:18 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.9]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4AIIr5rG010380; Mon, 18 Nov 2024 13:53:07 -0500 From: Marcelo Schmitt To: , , , , , , , CC: , , , David Lechner Subject: [PATCH v2 2/4] iio: adc: ad4000: Add timestamp channel Date: Mon, 18 Nov 2024 15:53:03 -0300 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: d9mPGWUfd-_9s42PAcQ__Blz17yLd5Vd X-Proofpoint-ORIG-GUID: d9mPGWUfd-_9s42PAcQ__Blz17yLd5Vd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180155 Content-Type: text/plain; charset="utf-8" The ADC data is pushed to the IIO buffer along with timestamp but no timestamp channel was provided to retried the time data. Add a timestamp channel to provide sample capture time. Suggested-by: David Lechner Reviewed-by: David Lechner Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad4000.c | 98 +++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c index b3b82535f5c1..21731c4d31ee 100644 --- a/drivers/iio/adc/ad4000.c +++ b/drivers/iio/adc/ad4000.c @@ -49,6 +49,7 @@ .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_SCALE), \ .info_mask_separate_available =3D _reg_access ? BIT(IIO_CHAN_INFO_SCALE) = : 0,\ + .scan_index =3D 0, \ .scan_type =3D { \ .sign =3D _sign, \ .realbits =3D _real_bits, \ @@ -62,6 +63,12 @@ __AD4000_DIFF_CHANNEL((_sign), (_real_bits), \ ((_real_bits) > 16 ? 32 : 16), (_reg_access)) =20 +#define AD4000_DIFF_CHANNELS(_sign, _real_bits, _reg_access) \ +{ \ + AD4000_DIFF_CHANNEL(_sign, _real_bits, _reg_access), \ + IIO_CHAN_SOFT_TIMESTAMP(1) \ +} + #define __AD4000_PSEUDO_DIFF_CHANNEL(_sign, _real_bits, _storage_bits, _re= g_access)\ { \ .type =3D IIO_VOLTAGE, \ @@ -71,6 +78,7 @@ BIT(IIO_CHAN_INFO_SCALE) | \ BIT(IIO_CHAN_INFO_OFFSET), \ .info_mask_separate_available =3D _reg_access ? BIT(IIO_CHAN_INFO_SCALE) = : 0,\ + .scan_index =3D 0, \ .scan_type =3D { \ .sign =3D _sign, \ .realbits =3D _real_bits, \ @@ -84,6 +92,12 @@ __AD4000_PSEUDO_DIFF_CHANNEL((_sign), (_real_bits), \ ((_real_bits) > 16 ? 32 : 16), (_reg_access)) =20 +#define AD4000_PSEUDO_DIFF_CHANNELS(_sign, _real_bits, _reg_access) \ +{ \ + AD4000_PSEUDO_DIFF_CHANNEL(_sign, _real_bits, _reg_access), \ + IIO_CHAN_SOFT_TIMESTAMP(1) \ +} + static const char * const ad4000_power_supplies[] =3D { "vdd", "vio" }; @@ -110,106 +124,106 @@ static const int ad4000_gains[] =3D { =20 struct ad4000_chip_info { const char *dev_name; - struct iio_chan_spec chan_spec; - struct iio_chan_spec reg_access_chan_spec; + struct iio_chan_spec chan_spec[2]; + struct iio_chan_spec reg_access_chan_spec[2]; bool has_hardware_gain; }; =20 static const struct ad4000_chip_info ad4000_chip_info =3D { .dev_name =3D "ad4000", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), }; =20 static const struct ad4000_chip_info ad4001_chip_info =3D { .dev_name =3D "ad4001", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), }; =20 static const struct ad4000_chip_info ad4002_chip_info =3D { .dev_name =3D "ad4002", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), }; =20 static const struct ad4000_chip_info ad4003_chip_info =3D { .dev_name =3D "ad4003", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), }; =20 static const struct ad4000_chip_info ad4004_chip_info =3D { .dev_name =3D "ad4004", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), }; =20 static const struct ad4000_chip_info ad4005_chip_info =3D { .dev_name =3D "ad4005", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), }; =20 static const struct ad4000_chip_info ad4006_chip_info =3D { .dev_name =3D "ad4006", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), }; =20 static const struct ad4000_chip_info ad4007_chip_info =3D { .dev_name =3D "ad4007", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), }; =20 static const struct ad4000_chip_info ad4008_chip_info =3D { .dev_name =3D "ad4008", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 16, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), }; =20 static const struct ad4000_chip_info ad4010_chip_info =3D { .dev_name =3D "ad4010", - .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 0), - .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNEL('u', 18, 1), + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), + .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), }; =20 static const struct ad4000_chip_info ad4011_chip_info =3D { .dev_name =3D "ad4011", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), }; =20 static const struct ad4000_chip_info ad4020_chip_info =3D { .dev_name =3D "ad4020", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), }; =20 static const struct ad4000_chip_info ad4021_chip_info =3D { .dev_name =3D "ad4021", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), }; =20 static const struct ad4000_chip_info ad4022_chip_info =3D { .dev_name =3D "ad4022", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 20, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), }; =20 static const struct ad4000_chip_info adaq4001_chip_info =3D { .dev_name =3D "adaq4001", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 16, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), .has_hardware_gain =3D true, }; =20 static const struct ad4000_chip_info adaq4003_chip_info =3D { .dev_name =3D "adaq4003", - .chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 0), - .reg_access_chan_spec =3D AD4000_DIFF_CHANNEL('s', 18, 1), + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), .has_hardware_gain =3D true, }; =20 @@ -591,7 +605,7 @@ static int ad4000_probe(struct spi_device *spi) switch (st->sdi_pin) { case AD4000_SDI_MOSI: indio_dev->info =3D &ad4000_reg_access_info; - indio_dev->channels =3D &chip->reg_access_chan_spec; + indio_dev->channels =3D chip->reg_access_chan_spec; =20 /* * In "3-wire mode", the ADC SDI line must be kept high when @@ -603,7 +617,7 @@ static int ad4000_probe(struct spi_device *spi) if (ret < 0) return ret; =20 - ret =3D ad4000_prepare_3wire_mode_message(st, indio_dev->channels); + ret =3D ad4000_prepare_3wire_mode_message(st, &indio_dev->channels[0]); if (ret) return ret; =20 @@ -614,16 +628,16 @@ static int ad4000_probe(struct spi_device *spi) break; case AD4000_SDI_VIO: indio_dev->info =3D &ad4000_info; - indio_dev->channels =3D &chip->chan_spec; - ret =3D ad4000_prepare_3wire_mode_message(st, indio_dev->channels); + indio_dev->channels =3D chip->chan_spec; + ret =3D ad4000_prepare_3wire_mode_message(st, &indio_dev->channels[0]); if (ret) return ret; =20 break; case AD4000_SDI_CS: indio_dev->info =3D &ad4000_info; - indio_dev->channels =3D &chip->chan_spec; - ret =3D ad4000_prepare_4wire_mode_message(st, indio_dev->channels); + indio_dev->channels =3D chip->chan_spec; + ret =3D ad4000_prepare_4wire_mode_message(st, &indio_dev->channels[0]); if (ret) return ret; =20 @@ -637,7 +651,7 @@ static int ad4000_probe(struct spi_device *spi) } =20 indio_dev->name =3D chip->dev_name; - indio_dev->num_channels =3D 1; + indio_dev->num_channels =3D 2; =20 ret =3D devm_mutex_init(dev, &st->lock); if (ret) @@ -658,7 +672,7 @@ static int ad4000_probe(struct spi_device *spi) } } =20 - ad4000_fill_scale_tbl(st, indio_dev->channels); + ad4000_fill_scale_tbl(st, &indio_dev->channels[0]); =20 ret =3D devm_iio_triggered_buffer_setup(dev, indio_dev, &iio_pollfunc_store_time, --=20 2.45.2 From nobody Thu Nov 21 21:28:29 2024 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 476E51E1028; Mon, 18 Nov 2024 18:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956041; cv=none; b=mpNSowIskQ4UtMVBEkKZVYXDmg69qW27cF70/1gwHpkAeSBJ2nBcTANWNLEs4rzn3sSb9heeALEm5AreokF+3o/rDICeew6NR5y1+VxPP0gXItheR3jZ+gCgsZIvuj3UD0xLhyqyx69dVTiic+MFIVaJYIhgmY6r+TYUXnb5kd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956041; c=relaxed/simple; bh=j0OO8ijIMhvjvY0T6jXt3cH1FEmyqeRoaaxIojKsTtg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QZEZdQpISFusdWvwPYFgFkb/RfF84MsW6HYCLIrdZXAhXn+x7R8HUfrTsux/oxR+hK+knonrO8DQx2feutncHmGdzW9QCZDpRv1lGvGskW67g9xuxl7If2dZ6z9OTDpSxtys9M3NEjw0gcZs1Ki12XPPwQ+4mUeKehmr6pKfSKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=ESz5y2Bq; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="ESz5y2Bq" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIEnlO2032596; Mon, 18 Nov 2024 13:53:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=WSZ++ ICuuExPa6njMohfctIQ2cE6vPilsywlwCqsKjU=; b=ESz5y2BqGhFs/OwQMm6LR o9OOaBFXfXjPhUvT6Wb34wTDNTaMZ8t3zeahx9CJ+1lVogTxDgrpZWGjUNZiYMtc 9NTuOvRNn0G0EI9js3CTIXulCjcWWacMmHNQhpch0Hwd2VlMhmhhQvv/cgkAxOsT PAbgJLRbcF2f2x8zWrApY7JhA2wG+CHmqch7ZzkFc8/51LP0qZeXU7OMRFajLqCI WfKFHaYgnKXOcbBn0lPTSTb8Y1Cg5u28mui32j7FNnvSoM4YtpE+3/XLOwk+uJWJ Dtr0Gaa3+bzPLymFV8LHHuFjA3A1NXEcEOPAOOlCFqX+zQ12QgBdxp6qHw0BVAbq g== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 42xs65gecr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 13:53:45 -0500 (EST) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 4AIIri9p064028 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Nov 2024 13:53:44 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 18 Nov 2024 13:53:44 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 18 Nov 2024 13:53:44 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.9]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4AIIrUxX010387; Mon, 18 Nov 2024 13:53:33 -0500 From: Marcelo Schmitt To: , , , , , , , CC: , , Subject: [PATCH v2 3/4] iio: adc: ad4000: Use device specific timing for SPI transfers Date: Mon, 18 Nov 2024 15:53:28 -0300 Message-ID: <284478615dd32deff29e4e10815cb49fa7d3b5d0.1731953012.git.marcelo.schmitt@analog.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: v00J4xxzmHN-C-G0hWEz2e1JB3yKJZqX X-Proofpoint-ORIG-GUID: v00J4xxzmHN-C-G0hWEz2e1JB3yKJZqX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180155 Content-Type: text/plain; charset="utf-8" The SPI transfers for AD4020, AD4021, and AD4022 have slightly different timing specifications. Use device specific timing constraints to set SPI transfer parameters. While tweaking time constraints, remove time related defines including unused AD4000_TQUIET1_NS. Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad4000.c | 51 +++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c index 21731c4d31ee..3fa12bcf73aa 100644 --- a/drivers/iio/adc/ad4000.c +++ b/drivers/iio/adc/ad4000.c @@ -35,10 +35,6 @@ =20 #define AD4000_SCALE_OPTIONS 2 =20 -#define AD4000_TQUIET1_NS 190 -#define AD4000_TQUIET2_NS 60 -#define AD4000_TCONV_NS 320 - #define __AD4000_DIFF_CHANNEL(_sign, _real_bits, _storage_bits, _reg_acces= s) \ { \ .type =3D IIO_VOLTAGE, \ @@ -98,6 +94,12 @@ IIO_CHAN_SOFT_TIMESTAMP(1) \ } =20 +#define AD4000_TSPEC(_t_conv, _t_quiet2) \ +{ \ + .t_conv_ns =3D _t_conv, \ + .t_quiet2_ns =3D _t_quiet2, \ +} + static const char * const ad4000_power_supplies[] =3D { "vdd", "vio" }; @@ -122,10 +124,25 @@ static const int ad4000_gains[] =3D { 454, 909, 1000, 1900, }; =20 +struct ad4000_time_spec { + int t_conv_ns; + int t_quiet2_ns; +}; + +/* + * Same timing specifications for all of AD4000, AD4001, ..., AD4008, AD40= 10, + * ADAQ4001, and ADAQ4003. + */ +static const struct ad4000_time_spec ad4000_t_spec =3D AD4000_TSPEC(320, 6= 0); + +/* AD4020, AD4021, AD4022 */ +static const struct ad4000_time_spec ad4020_t_spec =3D AD4000_TSPEC(350, 6= 0); + struct ad4000_chip_info { const char *dev_name; struct iio_chan_spec chan_spec[2]; struct iio_chan_spec reg_access_chan_spec[2]; + const struct ad4000_time_spec *time_spec; bool has_hardware_gain; }; =20 @@ -133,90 +150,105 @@ static const struct ad4000_chip_info ad4000_chip_inf= o =3D { .dev_name =3D "ad4000", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4001_chip_info =3D { .dev_name =3D "ad4001", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4002_chip_info =3D { .dev_name =3D "ad4002", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4003_chip_info =3D { .dev_name =3D "ad4003", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4004_chip_info =3D { .dev_name =3D "ad4004", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4005_chip_info =3D { .dev_name =3D "ad4005", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4006_chip_info =3D { .dev_name =3D "ad4006", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4007_chip_info =3D { .dev_name =3D "ad4007", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4008_chip_info =3D { .dev_name =3D "ad4008", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4010_chip_info =3D { .dev_name =3D "ad4010", .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 0), .reg_access_chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4011_chip_info =3D { .dev_name =3D "ad4011", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), + .time_spec =3D &ad4000_t_spec, }; =20 static const struct ad4000_chip_info ad4020_chip_info =3D { .dev_name =3D "ad4020", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), + .time_spec =3D &ad4020_t_spec, }; =20 static const struct ad4000_chip_info ad4021_chip_info =3D { .dev_name =3D "ad4021", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), + .time_spec =3D &ad4020_t_spec, }; =20 static const struct ad4000_chip_info ad4022_chip_info =3D { .dev_name =3D "ad4022", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 20, 1), + .time_spec =3D &ad4020_t_spec, }; =20 static const struct ad4000_chip_info adaq4001_chip_info =3D { .dev_name =3D "adaq4001", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 1), + .time_spec =3D &ad4000_t_spec, .has_hardware_gain =3D true, }; =20 @@ -224,6 +256,7 @@ static const struct ad4000_chip_info adaq4003_chip_info= =3D { .dev_name =3D "adaq4003", .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), .reg_access_chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 1), + .time_spec =3D &ad4000_t_spec, .has_hardware_gain =3D true, }; =20 @@ -238,6 +271,7 @@ struct ad4000_state { bool span_comp; u16 gain_milli; int scale_tbl[AD4000_SCALE_OPTIONS][2]; + const struct ad4000_time_spec *time_spec; =20 /* * DMA (thus cache coherency maintenance) requires the transfer buffers @@ -502,16 +536,15 @@ static const struct iio_info ad4000_info =3D { static int ad4000_prepare_3wire_mode_message(struct ad4000_state *st, const struct iio_chan_spec *chan) { - unsigned int cnv_pulse_time =3D AD4000_TCONV_NS; struct spi_transfer *xfers =3D st->xfers; =20 xfers[0].cs_change =3D 1; - xfers[0].cs_change_delay.value =3D cnv_pulse_time; + xfers[0].cs_change_delay.value =3D st->time_spec->t_conv_ns; xfers[0].cs_change_delay.unit =3D SPI_DELAY_UNIT_NSECS; =20 xfers[1].rx_buf =3D &st->scan.data; xfers[1].len =3D BITS_TO_BYTES(chan->scan_type.storagebits); - xfers[1].delay.value =3D AD4000_TQUIET2_NS; + xfers[1].delay.value =3D st->time_spec->t_quiet2_ns; xfers[1].delay.unit =3D SPI_DELAY_UNIT_NSECS; =20 spi_message_init_with_transfers(&st->msg, st->xfers, 2); @@ -529,7 +562,6 @@ static int ad4000_prepare_3wire_mode_message(struct ad4= 000_state *st, static int ad4000_prepare_4wire_mode_message(struct ad4000_state *st, const struct iio_chan_spec *chan) { - unsigned int cnv_to_sdi_time =3D AD4000_TCONV_NS; struct spi_transfer *xfers =3D st->xfers; =20 /* @@ -537,7 +569,7 @@ static int ad4000_prepare_4wire_mode_message(struct ad4= 000_state *st, * going low. */ xfers[0].cs_off =3D 1; - xfers[0].delay.value =3D cnv_to_sdi_time; + xfers[0].delay.value =3D st->time_spec->t_conv_ns; xfers[0].delay.unit =3D SPI_DELAY_UNIT_NSECS; =20 xfers[1].rx_buf =3D &st->scan.data; @@ -576,6 +608,7 @@ static int ad4000_probe(struct spi_device *spi) =20 st =3D iio_priv(indio_dev); st->spi =3D spi; + st->time_spec =3D chip->time_spec; =20 ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad4000_power_suppl= ies), ad4000_power_supplies); --=20 2.45.2 From nobody Thu Nov 21 21:28:29 2024 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5411B1494B0; Mon, 18 Nov 2024 18:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956067; cv=none; b=u87Y0KiHGAx4A5oVEXoQR+QirSpKi7IEdlzBcsgYy26soLE5SM1i+C43a7aEPJDyRAJYByIrk/omaQWlSckU/tpODqlBoo4rh4/nJ8Rv0JIES6BWcG6xrH0c8NV5EoeeyExvtSf64apPkj/VI5TZpwlV27S+CGZHQ1yf0Cbty7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731956067; c=relaxed/simple; bh=/H1PV/BMvbHKTb5SX6XHfRjbNzmVKHPWMMhdfwTSBwY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q2BRYGcOp3BjGPyBMcVqpl1/T2dq8plGcYiMrSJvPIDpm3wdRZOcS47ZqenzTT03Mt3j9uT52T/EaL+xzv0ap4N7NyyfdAj9VH5YlDiHeKHg219fIHQQgH5LHGAbKiZsTStMhVEk6W+QOeyQHpspXujdXWii81PX/gmx/ayTpug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=hqc1S3We; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="hqc1S3We" Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIEnlBB020192; Mon, 18 Nov 2024 13:54:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=tOpXV wzlbLBsoHKMz1ze+XGt9cfn8hPt2ymMX5qf7WU=; b=hqc1S3WellmQjnzsF5NSX DA/wqCt2R9+1iUC9encRlYpjBJhddWWYlZEcMTKCw06JzLUaDkm99qrbtnju8Gst 9WgQTFnEEFi+ZMuQqAA8f9jpIyFOIqyzdl0Eaeovick2qPlDF6xMQ5JD5gw2FFXg l6GDhuBAgVtiwlb6zDIJAr1JsO63OT3bdm76hH4rI0YiV5JqGZ2eXWVuQHlzFooD 3EYjkcVOQMjt1ZG99ekgRXPGKezSFyNu6I2YAcFftaCKYAyOqDH2aoWqH0oJ9yyg ALmwFR5vIzs4ARTRNJzISIfY1NblNtVZlM33eSAOYe6giojKHh4nd58HgOFbAg3+ Q== Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 43025m2fxw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Nov 2024 13:54:10 -0500 (EST) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 4AIIs96k064064 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Nov 2024 13:54:09 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 18 Nov 2024 13:54:09 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 18 Nov 2024 13:54:09 -0500 Received: from work.ad.analog.com (HYB-hERzalRezfV.ad.analog.com [10.65.205.9]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 4AIIrsd8010391; Mon, 18 Nov 2024 13:53:56 -0500 From: Marcelo Schmitt To: , , , , , , , CC: , , , David Lechner Subject: [PATCH v2 4/4] iio: adc: ad4000: Add support for PulSAR devices Date: Mon, 18 Nov 2024 15:53:52 -0300 Message-ID: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-GUID: 25OR0Z8ag8UZ-ZvusLGtbjiHPEfKBRTu X-Proofpoint-ORIG-GUID: 25OR0Z8ag8UZ-ZvusLGtbjiHPEfKBRTu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411180155 Content-Type: text/plain; charset="utf-8" The ADI PulSAR series of single-channel devices comprises differential and pseudo-differential ADCs that don't require any input data from the host controller. By not requiring a data input line, PulSAR devices can operate with a 3-wire only data bus in some setups. The AD4000 series and the single-channel PulSAR series of devices have similar SPI transfer specifications and wiring configurations. Single-channel PulSAR devices are slower than AD4000 and don't have a configuration register. That taken into account, single-channel PulSARs can be supported by the ad4000 driver without any increase in code complexity. Extend the AD4000 driver to also support single-channel PulSAR devices. Reviewed-by: David Lechner Signed-off-by: Marcelo Schmitt --- drivers/iio/adc/ad4000.c | 141 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c index 3fa12bcf73aa..38cd98adda8a 100644 --- a/drivers/iio/adc/ad4000.c +++ b/drivers/iio/adc/ad4000.c @@ -138,6 +138,27 @@ static const struct ad4000_time_spec ad4000_t_spec =3D= AD4000_TSPEC(320, 60); /* AD4020, AD4021, AD4022 */ static const struct ad4000_time_spec ad4020_t_spec =3D AD4000_TSPEC(350, 6= 0); =20 +/* AD7983, AD7984 */ +static const struct ad4000_time_spec ad7983_t_spec =3D AD4000_TSPEC(500, 0= ); + +/* AD7980, AD7982 */ +static const struct ad4000_time_spec ad7980_t_spec =3D AD4000_TSPEC(800, 0= ); + +/* AD7946, AD7686, AD7688, AD7988-5, AD7693 */ +static const struct ad4000_time_spec ad7686_t_spec =3D AD4000_TSPEC(1600, = 0); + +/* AD7690 */ +static const struct ad4000_time_spec ad7690_t_spec =3D AD4000_TSPEC(2100, = 0); + +/* AD7942, AD7685, AD7687 */ +static const struct ad4000_time_spec ad7687_t_spec =3D AD4000_TSPEC(3200, = 0); + +/* AD7691 */ +static const struct ad4000_time_spec ad7691_t_spec =3D AD4000_TSPEC(3700, = 0); + +/* AD7988-1 */ +static const struct ad4000_time_spec ad7988_1_t_spec =3D AD4000_TSPEC(9500= , 0); + struct ad4000_chip_info { const char *dev_name; struct iio_chan_spec chan_spec[2]; @@ -260,6 +281,96 @@ static const struct ad4000_chip_info adaq4003_chip_inf= o =3D { .has_hardware_gain =3D true, }; =20 +static const struct ad4000_chip_info ad7685_chip_info =3D { + .dev_name =3D "ad7685", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7687_t_spec, +}; + +static const struct ad4000_chip_info ad7686_chip_info =3D { + .dev_name =3D "ad7686", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7686_t_spec, +}; + +static const struct ad4000_chip_info ad7687_chip_info =3D { + .dev_name =3D "ad7687", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .time_spec =3D &ad7687_t_spec, +}; + +static const struct ad4000_chip_info ad7688_chip_info =3D { + .dev_name =3D "ad7688", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .time_spec =3D &ad7686_t_spec, +}; + +static const struct ad4000_chip_info ad7690_chip_info =3D { + .dev_name =3D "ad7690", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .time_spec =3D &ad7690_t_spec, +}; + +static const struct ad4000_chip_info ad7691_chip_info =3D { + .dev_name =3D "ad7691", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .time_spec =3D &ad7691_t_spec, +}; + +static const struct ad4000_chip_info ad7693_chip_info =3D { + .dev_name =3D "ad7693", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 16, 0), + .time_spec =3D &ad7686_t_spec, +}; + +static const struct ad4000_chip_info ad7942_chip_info =3D { + .dev_name =3D "ad7942", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 14, 0), + .time_spec =3D &ad7687_t_spec, +}; + +static const struct ad4000_chip_info ad7946_chip_info =3D { + .dev_name =3D "ad7946", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 14, 0), + .time_spec =3D &ad7686_t_spec, +}; + +static const struct ad4000_chip_info ad7980_chip_info =3D { + .dev_name =3D "ad7980", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7980_t_spec, +}; + +static const struct ad4000_chip_info ad7982_chip_info =3D { + .dev_name =3D "ad7982", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .time_spec =3D &ad7980_t_spec, +}; + +static const struct ad4000_chip_info ad7983_chip_info =3D { + .dev_name =3D "ad7983", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7983_t_spec, +}; + +static const struct ad4000_chip_info ad7984_chip_info =3D { + .dev_name =3D "ad7984", + .chan_spec =3D AD4000_DIFF_CHANNELS('s', 18, 0), + .time_spec =3D &ad7983_t_spec, +}; + +static const struct ad4000_chip_info ad7988_1_chip_info =3D { + .dev_name =3D "ad7988-1", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7988_1_t_spec, +}; + +static const struct ad4000_chip_info ad7988_5_chip_info =3D { + .dev_name =3D "ad7988-5", + .chan_spec =3D AD4000_PSEUDO_DIFF_CHANNELS('u', 16, 0), + .time_spec =3D &ad7686_t_spec, +}; + struct ad4000_state { struct spi_device *spi; struct gpio_desc *cnv_gpio; @@ -733,6 +844,21 @@ static const struct spi_device_id ad4000_id[] =3D { { "ad4022", (kernel_ulong_t)&ad4022_chip_info }, { "adaq4001", (kernel_ulong_t)&adaq4001_chip_info }, { "adaq4003", (kernel_ulong_t)&adaq4003_chip_info }, + { "ad7685", (kernel_ulong_t)&ad7685_chip_info }, + { "ad7686", (kernel_ulong_t)&ad7686_chip_info }, + { "ad7687", (kernel_ulong_t)&ad7687_chip_info }, + { "ad7688", (kernel_ulong_t)&ad7688_chip_info }, + { "ad7690", (kernel_ulong_t)&ad7690_chip_info }, + { "ad7691", (kernel_ulong_t)&ad7691_chip_info }, + { "ad7693", (kernel_ulong_t)&ad7693_chip_info }, + { "ad7942", (kernel_ulong_t)&ad7942_chip_info }, + { "ad7946", (kernel_ulong_t)&ad7946_chip_info }, + { "ad7980", (kernel_ulong_t)&ad7980_chip_info }, + { "ad7982", (kernel_ulong_t)&ad7982_chip_info }, + { "ad7983", (kernel_ulong_t)&ad7983_chip_info }, + { "ad7984", (kernel_ulong_t)&ad7984_chip_info }, + { "ad7988-1", (kernel_ulong_t)&ad7988_1_chip_info }, + { "ad7988-5", (kernel_ulong_t)&ad7988_5_chip_info }, { } }; MODULE_DEVICE_TABLE(spi, ad4000_id); @@ -754,6 +880,21 @@ static const struct of_device_id ad4000_of_match[] =3D= { { .compatible =3D "adi,ad4022", .data =3D &ad4022_chip_info }, { .compatible =3D "adi,adaq4001", .data =3D &adaq4001_chip_info }, { .compatible =3D "adi,adaq4003", .data =3D &adaq4003_chip_info }, + { .compatible =3D "adi,ad7685", .data =3D &ad7685_chip_info }, + { .compatible =3D "adi,ad7686", .data =3D &ad7686_chip_info }, + { .compatible =3D "adi,ad7687", .data =3D &ad7687_chip_info }, + { .compatible =3D "adi,ad7688", .data =3D &ad7688_chip_info }, + { .compatible =3D "adi,ad7690", .data =3D &ad7690_chip_info }, + { .compatible =3D "adi,ad7691", .data =3D &ad7691_chip_info }, + { .compatible =3D "adi,ad7693", .data =3D &ad7693_chip_info }, + { .compatible =3D "adi,ad7942", .data =3D &ad7942_chip_info }, + { .compatible =3D "adi,ad7946", .data =3D &ad7946_chip_info }, + { .compatible =3D "adi,ad7980", .data =3D &ad7980_chip_info }, + { .compatible =3D "adi,ad7982", .data =3D &ad7982_chip_info }, + { .compatible =3D "adi,ad7983", .data =3D &ad7983_chip_info }, + { .compatible =3D "adi,ad7984", .data =3D &ad7984_chip_info }, + { .compatible =3D "adi,ad7988-1", .data =3D &ad7988_1_chip_info }, + { .compatible =3D "adi,ad7988-5", .data =3D &ad7988_5_chip_info }, { } }; MODULE_DEVICE_TABLE(of, ad4000_of_match); --=20 2.45.2