From patchwork Mon Sep 23 10:10:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13809483 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 D2C61194147; Mon, 23 Sep 2024 10:17:20 +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=1727086642; cv=none; b=LtRKNtk/7uPLSlynO4QpQBcyWFUa7kJIeo64EuLnBrl04gE1ZRtGJHJmzfroOsOiXGpvQ4PecEzkaYD2Bj810cFC+96RzeFTQLhdUouOpMGvCDInwZxf7DiAFra/mTmo5c9/iy3dUIqpGOXKIHcxxE73tVIUBITfT0DCDHMry0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727086642; c=relaxed/simple; bh=Y7m3FbrcMIX8doj0UqQkjmF6tyyznbiYc8hoMXhKBuI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q0N45P4V/fVkuuggyshu8UtcAeE3xT454fvU5LD8e7AYqlznuGUlTV5Zhow1lzuta1xnI7LDQ0eO4BdAP25qt7PqMte5ukXUpzH69dM+W/D8TN116w3cKBOzZjN3dQcUUVP5xR+uz6j/Q3OEcVLTJaeA+a2v11R/tqtKLr3tkcA= 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=RCuscZWf; 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="RCuscZWf" 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 48N74q7s015348; Mon, 23 Sep 2024 06:16:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=6hGCi Gz5VriW3UyHaFx5OSWQaXNxI85/MwJeVfPVkmc=; b=RCuscZWfCZfNn/9QH8zOu 8Rb1BLSlqpjW03LRqhWGLbRJS7qRvHGz1DMhuNWa3GSbSd+G4dWr6cSA7VPdYqhg 5notPTtIzJWmTUzsGt4nSBOfz9nO/AS3AGLuUB8mGNOPASjcCf/FQPcvhbiZJchx n+NnNqUtNLVqVfwdXtTAAK0QcpruDTdlzBfcLtBcJlM5ofOFTWR+e8z3yZ2GAigp nWns+/0M+SyDfRkoRXUgZYGEJaqCHU15EoJUpV6ma4sKrhEA7Dkb0noGv9IMrT0X zJfpL8LDhuvgpnlABWFNUFG4CuLC0Oc9JSZI+AAYY2LTVCOsRv67JAdGGlxGJlFY A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 41u3frrqrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2024 06:16:47 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 48NAGj9I026069 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 23 Sep 2024 06:16:46 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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, 23 Sep 2024 06:16:45 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Mon, 23 Sep 2024 06:16:45 -0400 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, 23 Sep 2024 06:16:45 -0400 Received: from amiclaus-VirtualBox.ad.analog.com ([10.65.36.213]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 48NAFIQU001918; Mon, 23 Sep 2024 06:16:33 -0400 From: Antoniu Miclaus To: Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nuno Sa , Olivier Moysan , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= =?utf-8?q?g?= , Andy Shevchenko , David Lechner , Marcelo Schmitt , Dumitru Ceclan , =?utf-8?q?Jo=C3=A3o_Paulo_Gon?= =?utf-8?q?=C3=A7alves?= , AngeloGioacchino Del Regno , Alisa-Dariana Roman , Antoniu Miclaus , Marius Cristea , Mike Looijmans , Sergiu Cuciurean , Dragos Bogdan , , , , Subject: [PATCH 4/7] iio: adc: adi-axi-adc: set data format Date: Mon, 23 Sep 2024 13:10:21 +0300 Message-ID: <20240923101206.3753-5-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240923101206.3753-1-antoniu.miclaus@analog.com> References: <20240923101206.3753-1-antoniu.miclaus@analog.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: zmxL_KVjNgdyUydpxfcQEWmrcGS8aX53 X-Proofpoint-GUID: zmxL_KVjNgdyUydpxfcQEWmrcGS8aX53 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 mlxlogscore=999 suspectscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 clxscore=1011 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409230075 Add support for selecting the data format within the AXI ADC ip. Signed-off-by: Antoniu Miclaus --- drivers/iio/adc/adi-axi-adc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index ff48f26e02a3..926a8902c621 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -45,6 +45,8 @@ #define ADI_AXI_ADC_REG_CTRL 0x0044 #define ADI_AXI_ADC_CTRL_DDR_EDGESEL_MASK BIT(1) +#define ADI_AXI_ADC_REG_CNTRL_3 0x004c + #define ADI_AXI_ADC_REG_DRP_STATUS 0x0074 #define ADI_AXI_ADC_DRP_LOCKED BIT(17) @@ -271,6 +273,24 @@ static int axi_adc_interface_type_get(struct iio_backend *back, return 0; } +static int axi_adc_data_size_set(struct iio_backend *back, + ssize_t size) +{ + struct adi_axi_adc_state *st = iio_backend_get_priv(back); + unsigned int val; + + if (size <= 20) + val = 0; + else if (size <= 24) + val = 1; + else if (size <= 32) + val = 3; + else + return -EINVAL; + + return regmap_write(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, val); +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -308,6 +328,7 @@ static const struct iio_backend_ops adi_axi_adc_generic = { .test_pattern_set = axi_adc_test_pattern_set, .chan_status = axi_adc_chan_status, .interface_type_get = axi_adc_interface_type_get, + .data_size_set = axi_adc_data_size_set, }; static int adi_axi_adc_probe(struct platform_device *pdev)