From patchwork Fri Jun 23 02:20:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 890E2EB64DA for ; Fri, 23 Jun 2023 02:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IbVmDBjESamghyN9uaibOqqsuf8JGKJqTLGqlhVs9g8=; b=FXS7FaxjHNVZ7u hUO6VsFPgpkqp5eVIGNgELbnN4OgBn4aECHphZCc9H+coB7mWJvZiTWQ3pO04SGOkhLDqgKAIe5L5 bO9vqtYuc/rqxFXnDomYH9SQ5AGBdpULmfJ8hSpXr38v2PTju1ceZTNQo2tU2VJQ0gf2npXjdCb2l ooO4jQTag/WR9WRu2Y1FlxJY8fVM9xPBcdZZXEB6y58sb09SFEvKHoN5OnuantV2reJYs/cJAnx4b x0bBuSvaWfaH0GNS3qQlI3dc/Cn/9gQsV+WG7hKQH4pPcvidOpeukSWFMpZth6bYkaB1kiRYfV0cW 8aBsbAeB6X2I+lMrNPxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWTC-002K2G-3D; Fri, 23 Jun 2023 02:24:18 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSr-002JqD-03; Fri, 23 Jun 2023 02:24:02 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id D6FCE5FD25; Fri, 23 Jun 2023 05:23:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487029; bh=LSrYU9Za3aez8EGwCKmAePmxhFcW4UYhK9sMcYhgfkg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=EQi9Aw6+t23MHwjeQar8O0FWuOMHEnCzaUQidDb9YTt3HUkgFfZnb6hxTtWmPBZeX sGkFA1+t5fIr9CnVj9GdZTTREtt64oCsLUfurdf4yY+zg2oXfYVdg2068VpBbjQZEX Ph74+kLp3IBFYLDh1HjwQzBG6dolzuu7s1+ZibVPczRS92u6frNvx+bXNI1I8i4L7Z isbuhPBikYFJ21rbl41Ebprxlwiz0Kti/j0diu52gN0mdDXoHPNFFVZXJAZ0AArlOE 6HmUYvgMhfRBkPCTE3oMwBkjeVIbamFnLXaEHm6Yq1TqXDHv8wDRM1xoJT0Hecy9CY iqoinOYJPYwgw== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:49 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 1/6] meson saradc: move enums declaration before variables declaration Date: Fri, 23 Jun 2023 05:20:09 +0300 Message-ID: <20230623022334.791026-2-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192357_656007_8C84B331 X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move enums declaration before variables declaration. Signed-off-by: George Stark --- drivers/iio/adc/meson_saradc.c | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 18937a262af6..af38d95bd504 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -202,6 +202,28 @@ .datasheet_name = "TEMP_SENSOR", \ } +enum meson_sar_adc_avg_mode { + NO_AVERAGING = 0x0, + MEAN_AVERAGING = 0x1, + MEDIAN_AVERAGING = 0x2, +}; + +enum meson_sar_adc_num_samples { + ONE_SAMPLE = 0x0, + TWO_SAMPLES = 0x1, + FOUR_SAMPLES = 0x2, + EIGHT_SAMPLES = 0x3, +}; + +enum meson_sar_adc_chan7_mux_sel { + CHAN7_MUX_VSS = 0x0, + CHAN7_MUX_VDD_DIV4 = 0x1, + CHAN7_MUX_VDD_DIV2 = 0x2, + CHAN7_MUX_VDD_MUL3_DIV4 = 0x3, + CHAN7_MUX_VDD = 0x4, + CHAN7_MUX_CH7_INPUT = 0x7, +}; + static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { MESON_SAR_ADC_CHAN(0), MESON_SAR_ADC_CHAN(1), @@ -227,28 +249,6 @@ static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(9), }; -enum meson_sar_adc_avg_mode { - NO_AVERAGING = 0x0, - MEAN_AVERAGING = 0x1, - MEDIAN_AVERAGING = 0x2, -}; - -enum meson_sar_adc_num_samples { - ONE_SAMPLE = 0x0, - TWO_SAMPLES = 0x1, - FOUR_SAMPLES = 0x2, - EIGHT_SAMPLES = 0x3, -}; - -enum meson_sar_adc_chan7_mux_sel { - CHAN7_MUX_VSS = 0x0, - CHAN7_MUX_VDD_DIV4 = 0x1, - CHAN7_MUX_VDD_DIV2 = 0x2, - CHAN7_MUX_VDD_MUL3_DIV4 = 0x3, - CHAN7_MUX_VDD = 0x4, - CHAN7_MUX_CH7_INPUT = 0x7, -}; - struct meson_sar_adc_param { bool has_bl30_integration; unsigned long clock_rate; From patchwork Fri Jun 23 02:20:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF919EB64DA for ; Fri, 23 Jun 2023 02:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UXlGAFdt74XfeXEnozJ+eFrcrIPLqYGhF4j6UtfPIDI=; b=Z7is/qT0QRv/O1 ASbv+de7u+rpjT8qfWJoEjEqar4qQ51MuN1aSkYL4ZJCiuw69nKX4dtl5Sz0G5MSHK7lEnDLT0f76 UUnMk38jXWUspapHzhjnQWyEfzLmkmwO0gXHCb89lRKn3YVJQgLZanj0b/Xb8UGIg/NY1Hh0IdWH9 u+o7nwEBG9htQKTcR7jFbGrjnZgIgNxqmqTgq72h+tjT5DGUNXm94wU0vjTRNS6IwjouC3iP6Bjh1 rdtGEsdn7JYkOLwrD8Kl5ZKZ3AkYZiKuDvc+mqkPOYUdu0r6zaXMN7aAMSU1LNmqOOAFwtaMeOkTK SOlbGMVWO+wmtGe9BEbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSx-002JuV-1p; Fri, 23 Jun 2023 02:24:03 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSr-002Jqh-0A; Fri, 23 Jun 2023 02:24:00 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id D03AE5FD26; Fri, 23 Jun 2023 05:23:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487033; bh=rc3qX8KRQTMzSGALx1FQDUphrLTDt4aHKYVi/7eAovo=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=qKuCdlW3r6B6aRyuTHJYiu/Xm+Sn9B+bM/zMkqA9X1KQcfG1oawH6mWNcJNTYJqOZ tLVZJqoYy7eznJkWaHbBc2yqVKoaBS5eXB2RII+Cnb8/I71IFf0/+VBbsXxGwgXJEt OzVBoYJfqFc9rZYAGYcMwxCnnN9wZVbmtNYhrDDynx8DZMAnTc7dceiHyV5BNs8VS6 fT4yaD+E5VqJEjnby3f535trLC6AhfGYFZuky/3qkCD+0sQDXV8e7j0JOb08cbdfBc Z7ZyEy6qQxot1b47qOiuynxfy61G5dNNFrdKyRAWf1Ad8Gt0d+YMDIktlm6DtZcdL4 tjo2rkzp+BUFQ== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:53 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 2/6] meson saradc: move meson_sar_adc_set_chan7_mux routine upper Date: Fri, 23 Jun 2023 05:20:10 +0300 Message-ID: <20230623022334.791026-3-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192357_656007_C97E6C7B X-CRM114-Status: UNSURE ( 8.43 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move meson_sar_adc_set_chan7_mux routine upper. Signed-off-by: George Stark --- drivers/iio/adc/meson_saradc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index af38d95bd504..6e69b40b3309 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -338,6 +338,19 @@ static int meson_sar_adc_wait_busy_clear(struct iio_dev *indio_dev) 1, 10000); } +static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev, + enum meson_sar_adc_chan7_mux_sel sel) +{ + struct meson_sar_adc_priv *priv = iio_priv(indio_dev); + u32 regval; + + regval = FIELD_PREP(MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, sel); + regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, + MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, regval); + + usleep_range(10, 20); +} + static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, int *val) @@ -434,19 +447,6 @@ static void meson_sar_adc_enable_channel(struct iio_dev *indio_dev, } } -static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev, - enum meson_sar_adc_chan7_mux_sel sel) -{ - struct meson_sar_adc_priv *priv = iio_priv(indio_dev); - u32 regval; - - regval = FIELD_PREP(MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, sel); - regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, - MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, regval); - - usleep_range(10, 20); -} - static void meson_sar_adc_start_sample_engine(struct iio_dev *indio_dev) { struct meson_sar_adc_priv *priv = iio_priv(indio_dev); From patchwork Fri Jun 23 02:20:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C782BC001B3 for ; Fri, 23 Jun 2023 02:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zf+u9iAMyr0lGVQNhq6jQBdND2hZ1VUli5gQOgpLwTw=; b=tY6jWGAQIG79Ii G0bjFcmhvvD3pSXf5vZkBUXYR24kLLtv9xkt6NJbxKB4/urjNJqu/iRkogTTuDWyXkSl/XdT7jdD3 rF75sHQQf3At99EcX3nfGYwhjPf4k4isWGtqVy78W2Ip+76nLawiGa0dFa41X9jyesLWpz2MKt366 lPuFfF5EjChU/cTOkrrag57SNbHT1m116y82CPdHpCPFHZSLqiBLpmBi83fPgiYLo+wZDoabv+2QE 2CAFK1SKAeQgLzrpIxB2m9Y5Z8OnKV7lYjJe6XTulvKh0DQY0CUbPSa7mrIbCJvwX8wfM/KyF+bWh GJRxWIxFS5dCMzKzOQow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWTE-002K3d-1W; Fri, 23 Jun 2023 02:24:20 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSr-002Jqp-1I; Fri, 23 Jun 2023 02:24:02 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 5F7A65FD27; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487034; bh=xNSHkYYB8/LbeA0+r7XGd/32WotV9MdYNPXVJkH92yU=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=lfi4idW2RP2iu9BEegqhGovm8etD0Wx6LaaRwxwsBbi63WHmdk/Hx21WZRpymJg/D sFtp/N1nu5ICdl/vMcPJcvYZwYMM7Z7oPwOp6IQcro2xUB0GioQNbTarpIUrViOsAa KFsLw2A2DxWadmVEPCaQbjDaNpUEUrmmF5LMsoDl6cyT6dZ+HazCUauzyGQ88XEFHD Q7GIzC/Z7Tjua3hPpoPMjv3LwPKm9sj3iEWI739VfIzBhPvFrH7OMRKo+yoVizZh98 o9RwRPNr11i2iX0xxscxtCySVkj8eNhGE6cUtm9vVS+hpvITEKRKXO7v7jUsEpstLv u7Z6pqVSnB8UQ== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 3/6] meson saradc: unite iio channel array definitions Date: Fri, 23 Jun 2023 05:20:11 +0300 Message-ID: <20230623022334.791026-4-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192357_809159_271AF3C8 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of having several similar channel arrays which are different only by one item unite the arrays and put the unique item in the end. Signed-off-by: George Stark --- drivers/iio/adc/meson_saradc.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 6e69b40b3309..ffd4de950a63 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -189,9 +189,8 @@ .datasheet_name = "SAR_ADC_CH"#_chan, \ } -#define MESON_SAR_ADC_TEMP_CHAN(_chan) { \ +#define MESON_SAR_ADC_TEMP_CHAN() { \ .type = IIO_TEMP, \ - .channel = _chan, \ .address = MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ @@ -234,19 +233,7 @@ static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { MESON_SAR_ADC_CHAN(6), MESON_SAR_ADC_CHAN(7), IIO_CHAN_SOFT_TIMESTAMP(8), -}; - -static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = { - MESON_SAR_ADC_CHAN(0), - MESON_SAR_ADC_CHAN(1), - MESON_SAR_ADC_CHAN(2), - MESON_SAR_ADC_CHAN(3), - MESON_SAR_ADC_CHAN(4), - MESON_SAR_ADC_CHAN(5), - MESON_SAR_ADC_CHAN(6), - MESON_SAR_ADC_CHAN(7), - MESON_SAR_ADC_TEMP_CHAN(8), - IIO_CHAN_SOFT_TIMESTAMP(9), + MESON_SAR_ADC_TEMP_CHAN(), /* must be the last item */ }; struct meson_sar_adc_param { @@ -1242,15 +1229,11 @@ static int meson_sar_adc_probe(struct platform_device *pdev) return ret; } - if (priv->temperature_sensor_calibrated) { - indio_dev->channels = meson_sar_adc_and_temp_iio_channels; - indio_dev->num_channels = - ARRAY_SIZE(meson_sar_adc_and_temp_iio_channels); - } else { - indio_dev->channels = meson_sar_adc_iio_channels; - indio_dev->num_channels = - ARRAY_SIZE(meson_sar_adc_iio_channels); - } + indio_dev->channels = meson_sar_adc_iio_channels; + indio_dev->num_channels = ARRAY_SIZE(meson_sar_adc_iio_channels); + /* last item is temp channel */ + if (!priv->temperature_sensor_calibrated) + indio_dev->num_channels--; ret = meson_sar_adc_init(indio_dev); if (ret) From patchwork Fri Jun 23 02:20:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0061C0015E for ; Fri, 23 Jun 2023 02:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PLvOdoBzi/kCA05bT8GzxH3h24fK/zUVxZjwRZXQnu8=; b=lb5alHGOi/gosS rczAZs3suMKY1+EfQS22dCCFNlmRp4eTmAIOmC1NQfLoo6J2AC8iPBDpLlR+j9ZKBXc8WPn4SXg78 06xu+GbISLGNeWX/naU4e20PC6Z3vX5tvd+y9YxZ9KCwbkt6/3dalReDvEDpbNnExmfK87iN/f3VK f1Y22cw3e2OsRMiuSYVf/NXACxmUpTLndPCoxb3vrBn4PJ1saEBDeY6ScKh58oVYMe/P3XZL0bWnL HTNkjrcfYTIS5AzBgzMsXsoiqVKvbUwvaUAuSh9X8nkqUy1iXeLK724V6exnMvsfRej0m55W1mbVI 5DdTI9YLKcKUhIPkiuRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWTD-002K2k-1f; Fri, 23 Jun 2023 02:24:19 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSr-002Jqu-1o; Fri, 23 Jun 2023 02:24:02 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 81B195FD28; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487034; bh=xJtb2PxI0po9bYawG64NHJS7+zf3ZJH0TBfB5YdKzHY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bRX+++1zU1HV0IKkDfv0xOuRU+k1BLIBZe+MGgmJ+N/JDnCju1VqjIBgTMULDJmFU 8mBlLVrl8ZaOMIgDjBT0LX1YyFPllOqcIch3Ms5MqCVTWAVquKk1HeTFMpj8/dRPBS JH23tbqSBVSBWsu+39m404IllChX1E8fnfmDwqPq8e2t8pK4Frf9c46XVHC0zUPNrs ZnUed4CBwvaKITRjhjA2RwOLWqxmksCf2CuBLa+uNFRYN5rqGQJaVli2gOzWSbFtMN 5kku/rKn/WTzGBq5wa6XC3LP4USU/wfR/7wiRu+AkUXo+UBEniQg021JYTIKgVmPo9 2TTDL0Ln/wCPA== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 4/6] meson saradc: add enum for iio channel array indexes Date: Fri, 23 Jun 2023 05:20:12 +0300 Message-ID: <20230623022334.791026-5-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192357_958102_515CEAA6 X-CRM114-Status: UNSURE ( 9.66 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add enum for iio channel array indexes. Signed-off-by: George Stark --- drivers/iio/adc/meson_saradc.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index ffd4de950a63..7ef006650982 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -223,16 +223,28 @@ enum meson_sar_adc_chan7_mux_sel { CHAN7_MUX_CH7_INPUT = 0x7, }; +enum meson_sar_adc_channel_index { + INDEX_CHAN_0, + INDEX_CHAN_1, + INDEX_CHAN_2, + INDEX_CHAN_3, + INDEX_CHAN_4, + INDEX_CHAN_5, + INDEX_CHAN_6, + INDEX_CHAN_7, + INDEX_CHAN_SOFT_TIMESTAMP, +}; + static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { - MESON_SAR_ADC_CHAN(0), - MESON_SAR_ADC_CHAN(1), - MESON_SAR_ADC_CHAN(2), - MESON_SAR_ADC_CHAN(3), - MESON_SAR_ADC_CHAN(4), - MESON_SAR_ADC_CHAN(5), - MESON_SAR_ADC_CHAN(6), - MESON_SAR_ADC_CHAN(7), - IIO_CHAN_SOFT_TIMESTAMP(8), + MESON_SAR_ADC_CHAN(INDEX_CHAN_0), + MESON_SAR_ADC_CHAN(INDEX_CHAN_1), + MESON_SAR_ADC_CHAN(INDEX_CHAN_2), + MESON_SAR_ADC_CHAN(INDEX_CHAN_3), + MESON_SAR_ADC_CHAN(INDEX_CHAN_4), + MESON_SAR_ADC_CHAN(INDEX_CHAN_5), + MESON_SAR_ADC_CHAN(INDEX_CHAN_6), + MESON_SAR_ADC_CHAN(INDEX_CHAN_7), + IIO_CHAN_SOFT_TIMESTAMP(INDEX_CHAN_SOFT_TIMESTAMP), MESON_SAR_ADC_TEMP_CHAN(), /* must be the last item */ }; @@ -1003,7 +1015,7 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_DIV4); usleep_range(10, 20); ret = meson_sar_adc_get_sample(indio_dev, - &indio_dev->channels[7], + &indio_dev->channels[INDEX_CHAN_7], MEAN_AVERAGING, EIGHT_SAMPLES, &value0); if (ret < 0) goto out; @@ -1011,7 +1023,7 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_MUL3_DIV4); usleep_range(10, 20); ret = meson_sar_adc_get_sample(indio_dev, - &indio_dev->channels[7], + &indio_dev->channels[INDEX_CHAN_7], MEAN_AVERAGING, EIGHT_SAMPLES, &value1); if (ret < 0) goto out; From patchwork Fri Jun 23 02:20:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FAD7C0015E for ; Fri, 23 Jun 2023 02:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=74HefqhXuuuQj3cRR3VV+Ab3oFUogWQuUA8lMAk5N54=; b=2BqVbtpp9ej6Hf tk0BDz8qWV/8RyYgK1YzOVpyFzK2nEMV3NGooskA9hOguT6HEfjjXFDn9/ieQ9+IRqJs/WdiMuP+8 6Qu7n3QhNbuN7ZypNUWBLGaH3mPLhc6DvBaZRFZz5sqKGTQgI3vm+7PMkuOPQfoG6PH944tQ0lXqs Di3kPjZm2kmIs3ZhTQ1RqqQ7cCxdzxUxoB0HwG6J7PYj2Y/hbj3E1iO8WpIgUxhyD5fvoy+GC3nYh IKDaHvkWNn9QS4zeygUoK0hYPhQdeLqES94HxvS7pGQ7fuRtmVObc+7m+Y+8AMtxijOmwP6icuSx8 kWHSMg8KZ1JK2RJQV+Fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWTF-002K4n-29; Fri, 23 Jun 2023 02:24:21 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSw-002Jt2-1p; Fri, 23 Jun 2023 02:24:04 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id A65DB5FD66; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487034; bh=yGw6bp8rvMgtKlw7MfG3NQJsW3rgZ+48z4t6tgdQl5A=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=SQfezWoQUw91CXnAJuGgsda09wgT4veJgufAKFqHIVzEWuGMW9zal7vDWqaRDhaRL lt9ZGqr/oqWg1CZ9khRL8kgyWLc6Sqv0GI6hBnjK91uwLxeE+FoeFgB40Z33ZbA3Js vY3fVKzvmPCb9+S/tcniHM3OE3XrP6C233+tZ45foRlT/5uCtbmkyFmjXeythZi7lg StvbLYLOw6qGXpnFYj4PDRPs1yrBJ0NijYiMglo6K/UecY5DLchEMsD3zo2AB4O8Ni 1/5LX0iCC0k7VZOcu412pn3Mo8MD0VZdsAW8qy+GkK10oIcpNufSiLdgtlO94Mto3C 8eziUJpe906tw== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 5/6] meson saradc: add channel labels Date: Fri, 23 Jun 2023 05:20:13 +0300 Message-ID: <20230623022334.791026-6-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192402_793757_3A7BB4C6 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add attribute 'label' to all iio channles Signed-off-by: George Stark --- Changelog: v1->v2: update commit message from [1] [1] https://lore.kernel.org/lkml/20230621062715.455652-3-gnstark@sberdevices.ru/ --- drivers/iio/adc/meson_saradc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 7ef006650982..e7eb154b151f 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -1044,8 +1044,20 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) return ret; } +static int read_label(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + char *label) +{ + if (chan->type == IIO_TEMP) + return sprintf(label, "%s\n", "temp-sensor"); + if (chan->type == IIO_VOLTAGE) + return sprintf(label, "channel-%d\n", chan->channel); + return 0; +} + static const struct iio_info meson_sar_adc_iio_info = { .read_raw = meson_sar_adc_iio_info_read_raw, + .read_label = read_label, }; static const struct meson_sar_adc_param meson_sar_adc_meson8_param = { From patchwork Fri Jun 23 02:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 13289950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95955EB64DA for ; Fri, 23 Jun 2023 02:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LzcDjj23yngxqxihwoRdnps5EQ8rl8w8LrtVZtNvSkw=; b=3oXdhZv+cG6QU2 9lvRWx0XCjB1cV3fRBXoMGlnQVhJnecnpKSO8pkAOeorqEMez6IuWnhWk8Jd0IGxmAHmprX+fVZZD 5ohPz5dkEk6ok8cBSE93XGADSwfy8JidbcILXts5KFj1+QXAx0y0AKEFxlgoeeI0h0DtIi4jYRnIq X0ArFenndMycEcMbCbJwCfSWQ6E0rSp365jJpijSiVSgcHmRVihwX1+wK23Q979uthV9/dBrU9gx6 xWupOChjuajMreSM9TBYYEhIn0DTpQYaA7maySBw/+Zlw0dC4DgHfVvUSGdP45TvHkAU7fn1NePUX Ie2hl1krB/roDAxRO3fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qCWTG-002K5m-2V; Fri, 23 Jun 2023 02:24:22 +0000 Received: from mx.sberdevices.ru ([45.89.227.171]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qCWSw-002Jt3-1q; Fri, 23 Jun 2023 02:24:04 +0000 Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id CC5655FD8F; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1687487034; bh=kqNz9q85odOrDuiiTt1JEkfAd/EMGs7Y5SX22XNQeEE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=T39Jxks6azD91PZBhbkGc1NRepOEgTuS1Elqw6BHEExneu+lrGYZsXG2KIhgrdR1s qJU2/0uKFkHnCXw6cTC4aH7MzCltyBbjhl48/FJ0+SihFJlq1rMvuBu//8pzZjpUVe nvK7nQDr7ySW1ao5hJe8JkL0bW7cA3Wum7ENfunSXuL1fMJiEE5jEtS/5JEP6rvSPg fkCeOQ0htuogBhUDJZ5OhevrKV2zBmAUwc34R8DuNKDKPiTvyyWO9mrF5JBe+m3BBJ 3q5NNsGZuOxmKlp4xX8jSHwcZPD1z8WMLE28i1oDMZbF3N9bYDZTajVxzkofbdmQZs dcc9GUDkPiYTw== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) by mx.sberdevices.ru (Postfix) with ESMTP; Fri, 23 Jun 2023 05:23:54 +0300 (MSK) From: George Stark To: , , , , , , , , CC: , , , , , George Stark Subject: [PATCH v2 6/6] meson saradc: support reading from channel7 mux inputs Date: Fri, 23 Jun 2023 05:20:14 +0300 Message-ID: <20230623022334.791026-7-gnstark@sberdevices.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru> References: <20230623022334.791026-1-gnstark@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/22 21:10:00 #21557945 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230622_192402_978245_3516BCC0 X-CRM114-Status: GOOD ( 14.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add iio channel for every channel 7 muxer input. Meson saradc channel 7 is connected to muxer that can switch channel input to well-known sources like Vdd, GND and several Vdd dividers. Signed-off-by: George Stark --- Changelog: v1->v2: update commit message from [1] [1] https://lore.kernel.org/lkml/20230621062715.455652-4-gnstark@sberdevices.ru/ --- drivers/iio/adc/meson_saradc.c | 65 +++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index e7eb154b151f..ecaebb569e8e 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -163,6 +163,7 @@ #define MESON_SAR_ADC_MAX_FIFO_SIZE 32 #define MESON_SAR_ADC_TIMEOUT 100 /* ms */ #define MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL 6 +#define MESON_SAR_ADC_VOLTAGE_AND_MUX_CHANNEL 7 #define MESON_SAR_ADC_TEMP_OFFSET 27 /* temperature sensor calibration information in eFuse */ @@ -201,6 +202,19 @@ .datasheet_name = "TEMP_SENSOR", \ } +#define MESON_SAR_ADC_MUX(_chan, _sel) { \ + .type = IIO_VOLTAGE, \ + .channel = _chan, \ + .indexed = 1, \ + .address = MESON_SAR_ADC_VOLTAGE_AND_MUX_CHANNEL, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_CALIBBIAS) | \ + BIT(IIO_CHAN_INFO_CALIBSCALE), \ + .datasheet_name = "SAR_ADC_MUX_"#_sel, \ +} + enum meson_sar_adc_avg_mode { NO_AVERAGING = 0x0, MEAN_AVERAGING = 0x1, @@ -233,6 +247,27 @@ enum meson_sar_adc_channel_index { INDEX_CHAN_6, INDEX_CHAN_7, INDEX_CHAN_SOFT_TIMESTAMP, + INDEX_MUX_0_VSS, + INDEX_MUX_1_VDD_DIV4, + INDEX_MUX_2_VDD_DIV2, + INDEX_MUX_3_VDD_MUL3_DIV4, + INDEX_MUX_4_VDD, +}; + +static enum meson_sar_adc_chan7_mux_sel chan7_mux_values[] = { + CHAN7_MUX_VSS, + CHAN7_MUX_VDD_DIV4, + CHAN7_MUX_VDD_DIV2, + CHAN7_MUX_VDD_MUL3_DIV4, + CHAN7_MUX_VDD, +}; + +static const char * const chan7_mux_names[] = { + "gnd", + "0.25vdd", + "0.5vdd", + "0.75vdd", + "vdd", }; static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { @@ -245,6 +280,11 @@ static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { MESON_SAR_ADC_CHAN(INDEX_CHAN_6), MESON_SAR_ADC_CHAN(INDEX_CHAN_7), IIO_CHAN_SOFT_TIMESTAMP(INDEX_CHAN_SOFT_TIMESTAMP), + MESON_SAR_ADC_MUX(INDEX_MUX_0_VSS, 0), + MESON_SAR_ADC_MUX(INDEX_MUX_1_VDD_DIV4, 1), + MESON_SAR_ADC_MUX(INDEX_MUX_2_VDD_DIV2, 2), + MESON_SAR_ADC_MUX(INDEX_MUX_3_VDD_MUL3_DIV4, 3), + MESON_SAR_ADC_MUX(INDEX_MUX_4_VDD, 4), MESON_SAR_ADC_TEMP_CHAN(), /* must be the last item */ }; @@ -284,6 +324,7 @@ struct meson_sar_adc_priv { bool temperature_sensor_calibrated; u8 temperature_sensor_coefficient; u16 temperature_sensor_adc_val; + enum meson_sar_adc_chan7_mux_sel chan7_mux_sel; }; static const struct regmap_config meson_sar_adc_regmap_config_gxbb = { @@ -348,6 +389,8 @@ static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev, MESON_SAR_ADC_REG3_CTRL_CHAN7_MUX_SEL_MASK, regval); usleep_range(10, 20); + + priv->chan7_mux_sel = sel; } static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev, @@ -443,6 +486,15 @@ static void meson_sar_adc_enable_channel(struct iio_dev *indio_dev, regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, MESON_SAR_ADC_DELTA_10_TEMP_SEL, regval); + } else if (chan->address == MESON_SAR_ADC_VOLTAGE_AND_MUX_CHANNEL) { + enum meson_sar_adc_chan7_mux_sel sel; + + if (chan->channel == INDEX_CHAN_7) + sel = CHAN7_MUX_CH7_INPUT; + else + sel = chan7_mux_values[chan->channel - INDEX_MUX_0_VSS]; + if (sel != priv->chan7_mux_sel) + meson_sar_adc_set_chan7_mux(indio_dev, sel); } } @@ -1015,7 +1067,7 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_DIV4); usleep_range(10, 20); ret = meson_sar_adc_get_sample(indio_dev, - &indio_dev->channels[INDEX_CHAN_7], + &indio_dev->channels[INDEX_MUX_1_VDD_DIV4], MEAN_AVERAGING, EIGHT_SAMPLES, &value0); if (ret < 0) goto out; @@ -1023,7 +1075,7 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_MUL3_DIV4); usleep_range(10, 20); ret = meson_sar_adc_get_sample(indio_dev, - &indio_dev->channels[INDEX_CHAN_7], + &indio_dev->channels[INDEX_MUX_3_VDD_MUL3_DIV4], MEAN_AVERAGING, EIGHT_SAMPLES, &value1); if (ret < 0) goto out; @@ -1050,8 +1102,13 @@ static int read_label(struct iio_dev *indio_dev, { if (chan->type == IIO_TEMP) return sprintf(label, "%s\n", "temp-sensor"); - if (chan->type == IIO_VOLTAGE) - return sprintf(label, "channel-%d\n", chan->channel); + if (chan->type == IIO_VOLTAGE) { + if (chan->channel <= INDEX_CHAN_7) + return sprintf(label, "channel-%d\n", chan->channel); + if (chan->channel >= INDEX_MUX_0_VSS) + return sprintf(label, "%s\n", + chan7_mux_names[chan->channel - INDEX_MUX_0_VSS]); + } return 0; }