From patchwork Wed Jul 26 14:33:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 126441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp477053vqo; Wed, 26 Jul 2023 08:23:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvA/WVmv2ZjXTzLRsXPm2lM8csS18Tjw7gPbPxn8UmYx+jGuwMZ3gJItRpBJ5o+EwOTPU1 X-Received: by 2002:a05:6a20:197:b0:137:2460:d3b5 with SMTP id 23-20020a056a20019700b001372460d3b5mr1723473pzy.62.1690384981683; Wed, 26 Jul 2023 08:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690384981; cv=none; d=google.com; s=arc-20160816; b=ie9ibXp44nbqUnNTu4AoLn7wowmyJT2WdgzvuWVmSeBUK3aLmSmekMzDzy5S8MUSdY kEjL+XVPBa092xaJbHC2H7M6BnvA0K5iMF6caRH4gws+dtcbZNtKEs0rneowj5zSM+pC BLl2kKQqgv2Beamlz2XY8t+a7r700JhT1rgK1wZuWTeG0oILdJFZFefJ3aMgeLKKMXLv b8s9mBQKUvJgZCKd0tfzqfA9AvwB2vugB5KPHMOynb9jaocT6xM/Q8YOeHq4mc66cFeA pG73tSLklTMyRhC9zSgYsxyy4hgaPZ/I5V9qKTw+WlTrvxT3bd7keCT3XiD8j8FU0jjQ Nc2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vihggvmBGOF5ZW6coA+lNZNQKs1tB9OC20X+Iw3gKZg=; fh=HabWJFzVcNYyYtiXZVpYupAsiak3SIjkcQ0UETgCRVQ=; b=bNAb94XoiipTqPOow0VQpwMqU0W009qdQSL11RmkWCR4QpzlhUw3Ef/V9aFXnowKK/ bMQm+I+fsAy36ZmproD6eHSiWTQ8eusiKZiiDJadUURbsSnEQ/kfInM6GxyKz83bxPeh rxGg/I303RtETOvUVH5VkPFKMf0oiLgpG9k0xuntUHz+n/jt5UDUyNDG3nOQRqn8GOCa SCEfadd9q2m3D0ep4mTyPwXYyia3Ckz8otBGKjj81e577OplepOmf6XwpIo1C95tFKOO x6mS+utI47EOotuERsYrvabVpudTp9G2AF7jJQCSq8LY6B3nP4z0mimcgmh9iYeXek+d RToA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b0056336fb99aasi13364709pgh.850.2023.07.26.08.22.48; Wed, 26 Jul 2023 08:23:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233085AbjGZOgS (ORCPT + 99 others); Wed, 26 Jul 2023 10:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbjGZOgQ (ORCPT ); Wed, 26 Jul 2023 10:36:16 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29707E7E; Wed, 26 Jul 2023 07:36:12 -0700 (PDT) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36QDQaOW025947; Wed, 26 Jul 2023 10:36:09 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3s34cj8eje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 10:36:09 -0400 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 36QEa7vY040781 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 26 Jul 2023 10:36:07 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) 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; Wed, 26 Jul 2023 10:36:06 -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; Wed, 26 Jul 2023 10:36:06 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.194]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 36QEZwi8029912; Wed, 26 Jul 2023 10:36:00 -0400 From: Antoniu Miclaus To: , , CC: Antoniu Miclaus Subject: [PATCH 1/2] drivers: iio: filter: admv8818: add bypass mode Date: Wed, 26 Jul 2023 17:33:30 +0300 Message-ID: <20230726143331.66456-1-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: JWWiTUniWTiPK0zaYZK1EZmIuJd5EFUw X-Proofpoint-GUID: JWWiTUniWTiPK0zaYZK1EZmIuJd5EFUw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-26_06,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 bulkscore=0 clxscore=1011 phishscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307260129 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772497122846226808 X-GMAIL-MSGID: 1772497122846226808 Add filter bypass mode, which bypasses the low pass filter, high pass filter and disables/unregister the clock rate notifier. The patch contains minimal changes in order to add the functionality. It was requested by users of the driver to ease the interaction with different configuration modes of the device. Signed-off-by: Antoniu Miclaus --- drivers/iio/filter/admv8818.c | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c index fe8d46cb7f1d..f0d6bb606507 100644 --- a/drivers/iio/filter/admv8818.c +++ b/drivers/iio/filter/admv8818.c @@ -78,6 +78,7 @@ enum { enum { ADMV8818_AUTO_MODE, ADMV8818_MANUAL_MODE, + ADMV8818_BYPASS_MODE, }; struct admv8818_state { @@ -114,7 +115,8 @@ static const struct regmap_config admv8818_regmap_config = { static const char * const admv8818_modes[] = { [0] = "auto", - [1] = "manual" + [1] = "manual", + [2] = "bypass" }; static int __admv8818_hpf_select(struct admv8818_state *st, u64 freq) @@ -394,6 +396,36 @@ static int admv8818_reg_access(struct iio_dev *indio_dev, return regmap_write(st->regmap, reg, write_val); } +static int admv8818_filter_bypass(struct admv8818_state *st) +{ + int ret; + + mutex_lock(&st->lock); + + ret = regmap_update_bits(st->regmap, ADMV8818_REG_WR0_SW, + ADMV8818_SW_IN_SET_WR0_MSK | + ADMV8818_SW_IN_WR0_MSK | + ADMV8818_SW_OUT_SET_WR0_MSK | + ADMV8818_SW_OUT_WR0_MSK, + FIELD_PREP(ADMV8818_SW_IN_SET_WR0_MSK, 1) | + FIELD_PREP(ADMV8818_SW_IN_WR0_MSK, 0) | + FIELD_PREP(ADMV8818_SW_OUT_SET_WR0_MSK, 1) | + FIELD_PREP(ADMV8818_SW_OUT_WR0_MSK, 0)); + if (ret) + goto exit; + + ret = regmap_update_bits(st->regmap, ADMV8818_REG_WR0_FILTER, + ADMV8818_HPF_WR0_MSK | + ADMV8818_LPF_WR0_MSK, + FIELD_PREP(ADMV8818_HPF_WR0_MSK, 0) | + FIELD_PREP(ADMV8818_LPF_WR0_MSK, 0)); + +exit: + mutex_unlock(&st->lock); + + return ret; +} + static int admv8818_get_mode(struct iio_dev *indio_dev, const struct iio_chan_spec *chan) { @@ -411,7 +443,10 @@ static int admv8818_set_mode(struct iio_dev *indio_dev, if (!st->clkin) { if (mode == ADMV8818_MANUAL_MODE) - return 0; + goto set_mode; + + if (mode == ADMV8818_BYPASS_MODE) + goto bypass_filter; return -EINVAL; } @@ -434,8 +469,9 @@ static int admv8818_set_mode(struct iio_dev *indio_dev, break; case ADMV8818_MANUAL_MODE: + case ADMV8818_BYPASS_MODE: if (st->filter_mode) - return 0; + break; clk_disable_unprepare(st->clkin); @@ -448,6 +484,15 @@ static int admv8818_set_mode(struct iio_dev *indio_dev, return -EINVAL; } +bypass_filter: + if (st->filter_mode != ADMV8818_BYPASS_MODE && + mode == ADMV8818_BYPASS_MODE) { + ret = admv8818_filter_bypass(st); + if (ret) + return ret; + } + +set_mode: st->filter_mode = mode; return ret; From patchwork Wed Jul 26 14:33:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 126453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp483362vqo; Wed, 26 Jul 2023 08:33:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBOzFAt2GJh5+mg9TbqPm2DevldoSP5hJP4DBSwOfoTttYo7EQghDF4vokN/UzWPq15CW8 X-Received: by 2002:a05:6a20:7489:b0:132:d029:e2d7 with SMTP id p9-20020a056a20748900b00132d029e2d7mr2055491pzd.55.1690385600902; Wed, 26 Jul 2023 08:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690385600; cv=none; d=google.com; s=arc-20160816; b=gmNqci+WJp5c0kC6AyYgieZKCkgqRbdvCkJsTbkgNniM/MmT+vZhJTvdR9gavQd3bF ZtAN17JdjIVzoyyDPfPgc4ef1cVBggrWKoeuhV7kvcxHaQkcUj1qE3Vt+51cJs3Yr48l axBilN8VSSGkNhdNwUZY2xxBoqcPUstsPG+AIux/ns9V7Sbbjy1PBlt7XWAOWF0tCYWF trfctaNo9HAY86cfGjH4fjWhq+wJ2DnTcmRLf3uWyqgsO4He26ymuD1nWbNMCLvFY1Ts WAzv6iGzRmZ1YuFBwOmbHP+jUERUzAZNTo6bB5hYelnbygXw5QKW+adG5b8HAL9P5TPv bhGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9AfEi+2be8p9QJsFTLGQFdmMfnGToUfQj4hxd7o87PQ=; fh=HabWJFzVcNYyYtiXZVpYupAsiak3SIjkcQ0UETgCRVQ=; b=lKVYck5uy5hUEZbJEZh8rIOJV7vKvPtby6tgXkjEvl73MFAHdCniYyxyLc4V6bn2Zq WNGdI9hWZjR2Bj6nj9hNEyvK105QtUbj24v8knefx9Bc+IkUZjujq9ZORovbAKs8c+7i 0nAis+wDb//45b0VCsNFLFYWytHmiZuZQHBpdDNSx6Aou9ltEExJ7AB4Dbo/260KJZO/ 3fe4bxKC1rz1BeunCn/wJR1ramKOiTxuCoTvIaTuiPxS9SQcDh/XutzzduBkwjIq6V5M otDv8B0S+ed0CpVMlXqrmz6Kk+WwgtVuT8mkNggbAy8fbPlLf2yZzUmMLIueVsI98Z8E kokA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r144-20020a632b96000000b00563e70c270bsi1118670pgr.781.2023.07.26.08.33.07; Wed, 26 Jul 2023 08:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbjGZOgW (ORCPT + 99 others); Wed, 26 Jul 2023 10:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234277AbjGZOgQ (ORCPT ); Wed, 26 Jul 2023 10:36:16 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB49B4; Wed, 26 Jul 2023 07:36:13 -0700 (PDT) Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36QEYmOb013739; Wed, 26 Jul 2023 10:36:11 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3s0c15k37k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Jul 2023 10:36:10 -0400 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 36QEa9NB032588 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 26 Jul 2023 10:36:09 -0400 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; Wed, 26 Jul 2023 10:36:08 -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; Wed, 26 Jul 2023 10:36:08 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.194]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 36QEZwi9029912; Wed, 26 Jul 2023 10:36:03 -0400 From: Antoniu Miclaus To: , , CC: Antoniu Miclaus Subject: [PATCH 2/2] Documentation: ABI: testing: admv8818: add bypass Date: Wed, 26 Jul 2023 17:33:31 +0300 Message-ID: <20230726143331.66456-2-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726143331.66456-1-antoniu.miclaus@analog.com> References: <20230726143331.66456-1-antoniu.miclaus@analog.com> MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: E9DuXrzDbYXiAqB6kXYtqSq1800wEtYF X-Proofpoint-GUID: E9DuXrzDbYXiAqB6kXYtqSq1800wEtYF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-26_06,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxlogscore=882 impostorscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307260129 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772497771791224810 X-GMAIL-MSGID: 1772497771791224810 Add documentation for the use of the bypass filter mode. Signed-off-by: Antoniu Miclaus --- Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 b/Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 index f6c035752639..31dbb390573f 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 +++ b/Documentation/ABI/testing/sysfs-bus-iio-filter-admv8818 @@ -7,6 +7,8 @@ Description: - auto -> Adjust bandpass filter to track changes in input clock rate. - manual -> disable/unregister the clock rate notifier / input clock tracking. + - bypass -> bypass low pass filter, high pass filter and disable/unregister + the clock rate notifier What: /sys/bus/iio/devices/iio:deviceX/filter_mode KernelVersion: