From patchwork Mon Oct 14 09:40:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 13834564 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 D1E24157A5A; Mon, 14 Oct 2024 09:50:14 +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=1728899416; cv=none; b=auJY+SLTSwoRDozjxx9G6mgA86CW+pq/TmVbHsj2AAf7v1KXOt3vRsdMONWCRQ+fibYGRhA2qOZ48rUGecGEjetI9wFQB7d6y81N4+6fHon4CDDrM89Chs4S3A+xoZ1qsMgpl61+RypL1E7KZ1lqCqpSSvWWkWGaKMOOl/oJThw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728899416; c=relaxed/simple; bh=n4MntVU5vk9nTXVELsmv7GT0JcIYdwIaFIwB6DsxQGc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tfYi37TwdwnEXEjZc2556mq1ul6UnHXC7RFnuIxNXEgweivTAzgmmT1ytfkv0/Lrp6Z91ybZ5A8N7TrGMa5E7rLjp8xuXasy4MY+z2vyNUm7dSu99kvSQKDBgviuFkhwx8j2B21wCFu/7gYDRE6nbY8uwBvFv8KYNckOswN5WPQ= 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=AQ9gA/yA; 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="AQ9gA/yA" 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 49E4XD55006002; Mon, 14 Oct 2024 05:49:19 -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=oJT0q 2J3mQnY+A6GacH6fNH6T6rrobfiFHcupGvV1hM=; b=AQ9gA/yADwgapAerYH6QX mKurqMkUPi0SCIz1Lk1AuSFAjSHkYCwE/dRUtJEebZJ4zP2XtwdK/Fn8NajehzPa IsUKcouiG1Eacti/4HCi/HjinsMJR8UzxJKwpka7FixsZ4MkFxTZ/7F6ya+Zvo+m TgMNZQQZ+GcwCg4lWtLPSMxDvQU9JS9UDVM+C26dALJXELa4WT2tcxYlONf4d/c+ lYFzmPVx7WMCPoCesvHe5iRqBJ9MCoIPeNOmPQOOc346H7p0PnY8rVJGLtrRyPon ZOALyl1ZnaJARyTFWmq59Y9rbgyGhZ8Aw8sC8/+jec+rtt+PlLm6QJ1YRE3DRu0g w== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 427p136e0m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Oct 2024 05:49:18 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 49E9nHVc031612 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 14 Oct 2024 05:49:17 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) 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, 14 Oct 2024 05:49:17 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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, 14 Oct 2024 05:49:17 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Mon, 14 Oct 2024 05:49:17 -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 49E9m0Go024017; Mon, 14 Oct 2024 05:49:07 -0400 From: Antoniu Miclaus To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "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 , "Marius Cristea" , Dumitru Ceclan , Antoniu Miclaus , =?utf-8?q?Jo=C3=A3o_Paulo_Gon?= =?utf-8?q?=C3=A7alves?= , Alisa-Dariana Roman , Ivan Mikhaylov , Sergiu Cuciurean , "Dragos Bogdan" , , , , Subject: [PATCH v3 4/6] iio: adc: adi-axi-adc: set data format Date: Mon, 14 Oct 2024 12:40:38 +0300 Message-ID: <20241014094154.9439-4-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241014094154.9439-1-antoniu.miclaus@analog.com> References: <20241014094154.9439-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: P_pQgTMqzqXUjsfZdfmHLx3U-Q7TjJGq X-Proofpoint-GUID: P_pQgTMqzqXUjsfZdfmHLx3U-Q7TjJGq 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 mlxlogscore=999 mlxscore=0 malwarescore=0 adultscore=0 spamscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410140071 Add support for selecting the data format within the AXI ADC ip. Signed-off-by: Antoniu Miclaus --- no changes in v3. drivers/iio/adc/adi-axi-adc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index ff48f26e02a3..363cc29b4c18 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -45,6 +45,9 @@ #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_CNTRL_3_CUSTOM_CONTROL_MSK GENMASK(7, 0) + #define ADI_AXI_ADC_REG_DRP_STATUS 0x0074 #define ADI_AXI_ADC_DRP_LOCKED BIT(17) @@ -271,6 +274,25 @@ 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_update_bits(st->regmap, ADI_AXI_ADC_REG_CNTRL_3, + ADI_AXI_ADC_CNTRL_3_CUSTOM_CONTROL_MSK, val); +} + static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back, struct iio_dev *indio_dev) { @@ -308,6 +330,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)