From patchwork Wed Jun 14 13:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13280058 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 2C794EB64D8 for ; Wed, 14 Jun 2023 13:28:29 +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=W29JW3QaV7LCE0bXwb6A/BCT4Lfh8JxW110SX4oh/p0=; b=pCMCOZoxUWJK4G VeKwy7nKkP+EKj2cauJt+xtrMVii1h/eZEbpcfy03VExLbvDivgIrP+b3DJZMc1ohSu1OUD+ZiVMV Lgn7pDLhzLop8UTqP3KIzhvxE+Rzxu0Eb/Y4EEKP9Wj96mCTNnDxyRUpWEOf+1G45tLAW4fgN1W0o FdBUscN7T62mrm4qIag+hpMVZMGZssyRYH8Y0irdETLVBUJXn2/8HbjLqboCKU6P02M7QkuNnDU/S BsFw7HD90+XUAlsj43n/3zrjTsDYeu8LhfYFt/shYlPrbwLxHUywn5qLyrXTC5FHrD+lo3Nycw93f 6eFsamtdBsC1gcjq4JRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9QXg-00BkM8-0y; Wed, 14 Jun 2023 13:28:08 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9QXc-00BkKn-2L; Wed, 14 Jun 2023 13:28:06 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-30c4c1fd511so6284710f8f.1; Wed, 14 Jun 2023 06:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686749282; x=1689341282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=COISb8jR0JndjG+qNPVWLMqbsub3XBTxNgpOM9JICRM=; b=EBmFB3AN9UPhZq2XSVcDdtVtua9evum1N4+mFaYdD4R48RoyJ1B3JBFLNPBssIEBwr K4ztndE0fr313AN2C/epxClHKZmltHF0beSlK0qGxWSXadrL7T69A/1Lxmm3Lqu9hkDz qYTVnMdIYerIhlTtWWWtaU8lBku3fCsHsDfxRdZLZfA/ZW/YQ+4RT2RQt7MmbyZMLTed JaHqm3dcxpnwnOIU+z8ztYlC2Crj3yo4+9yK/GznJmNI7HDHmyoiMQReppK/h9aRDysD bDz3qiKSdY0Pd40k5azy1gRN6iH9y6F1ncPaZ4i9b+GYA6wBazFHH9T/uwZUQySVhMDi ZaAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686749282; x=1689341282; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=COISb8jR0JndjG+qNPVWLMqbsub3XBTxNgpOM9JICRM=; b=ZcHRykCSlNfAgmC84940aoEC6ogE4Jodvz6Jbxf4qoo0/9XnHv9Awg9W0ZAMtuXcBR SORBKg6crfE9YizmcxiZppAalHWgMXrcIxgmPZxnkeGFEsGGh7/pytJF9a9ZbQdSZdUz Ira6zTmfmTVr6wOPKXDaDVZkVusHP1PKygUY4fAZPDF/XyB0ovm8PKZtTD9F4191ZTsp CuQup0yWjaC+02+CRGeX0hF/edmWwHi7NDVxthDXsjFVQ9XNpTrdSldBR0qsSULraSXt 9tAr0GtBWB/TVhp+rMKcTjayNizIGj+D19SK0NtizSCPJ1NoPnySlRY6Hd8EgNOIcqNx AUSQ== X-Gm-Message-State: AC+VfDxJQgb9MymS6NtINsXuneAnkSbCdzwX6WtsvY8+WWvA4TPuXYMO M58cmCtsNXtojDJsX0d81YY= X-Google-Smtp-Source: ACHHUZ4ROdPprYFl2yAJNqLxHRSMEAuYKRDXn4JUWJCH7yKox4P/cPmR3Re2bPgJ3+3bkEyM/M97yA== X-Received: by 2002:adf:ef52:0:b0:306:2e04:5925 with SMTP id c18-20020adfef52000000b003062e045925mr10681194wrp.17.1686749281713; Wed, 14 Jun 2023 06:28:01 -0700 (PDT) Received: from user-PC.. ([92.51.95.194]) by smtp.gmail.com with ESMTPSA id l6-20020a5d4bc6000000b003047ae72b14sm18295017wrt.82.2023.06.14.06.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 06:28:01 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maksim Kiselev , Andy Shevchenko , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Cristian Ciocaltea , Cosmin Tanislav , Miquel Raynal , William Breathitt Gray , Ramona Bolboaca , Arnd Bergmann , Haibo Chen , Ibrahim Tilki , ChiYuan Huang , ChiaEn Wu , =?utf-8?q?Leonard_G=C3=B6hrs?= , Caleb Connolly , Mike Looijmans , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v6 1/3] iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC Date: Wed, 14 Jun 2023 16:26:25 +0300 Message-Id: <20230614132644.699425-2-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614132644.699425-1-bigunclemax@gmail.com> References: <20230614132644.699425-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_062804_767237_90102009 X-CRM114-Status: GOOD ( 30.32 ) 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 The General Purpose ADC (GPADC) can convert the external signal into a certain proportion of digital value, to realize the measurement of analog signal, which can be applied to power detection and key detection. Theoretically, this ADC can support up to 16 channels. All SoCs below contain this GPADC IP. The only difference between them is the number of available channels: T113 - 1 channel D1 - 2 channels R329 - 4 channels T507 - 4 channels Signed-off-by: Maksim Kiselev Reviewed-by: Andy Shevchenko --- drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sun20i-gpadc-iio.c | 276 +++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 drivers/iio/adc/sun20i-gpadc-iio.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index eb2b09ef5d5b..deff7ae704ce 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1123,6 +1123,16 @@ config SUN4I_GPADC To compile this driver as a module, choose M here: the module will be called sun4i-gpadc-iio. +config SUN20I_GPADC + tristate "Support for the Allwinner SoCs GPADC" + depends on ARCH_SUNXI || COMPILE_TEST + help + Say yes here to build support for Allwinner (D1, T113, T507 and R329) + SoCs GPADC. This ADC provides up to 16 channels. + + To compile this driver as a module, choose M here: the module will be + called sun20i-gpadc-iio. + config TI_ADC081C tristate "Texas Instruments ADC081C/ADC101C/ADC121C family" depends on I2C diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index e07e4a3e6237..fc4ef71d5f8f 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -95,6 +95,7 @@ obj-$(CONFIG_RZG2L_ADC) += rzg2l_adc.o obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o obj-$(CONFIG_SUN4I_GPADC) += sun4i-gpadc-iio.o +obj-$(CONFIG_SUN20I_GPADC) += sun20i-gpadc-iio.o obj-$(CONFIG_STM32_ADC_CORE) += stm32-adc-core.o obj-$(CONFIG_STM32_ADC) += stm32-adc.o obj-$(CONFIG_STM32_DFSDM_CORE) += stm32-dfsdm-core.o diff --git a/drivers/iio/adc/sun20i-gpadc-iio.c b/drivers/iio/adc/sun20i-gpadc-iio.c new file mode 100644 index 000000000000..6a893d484cf7 --- /dev/null +++ b/drivers/iio/adc/sun20i-gpadc-iio.c @@ -0,0 +1,276 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * GPADC driver for sunxi platforms (D1, T113-S3 and R329) + * Copyright (c) 2023 Maksim Kiselev + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define SUN20I_GPADC_DRIVER_NAME "sun20i-gpadc" + +/* Register map definition */ +#define SUN20I_GPADC_SR 0x00 +#define SUN20I_GPADC_CTRL 0x04 +#define SUN20I_GPADC_CS_EN 0x08 +#define SUN20I_GPADC_FIFO_INTC 0x0c +#define SUN20I_GPADC_FIFO_INTS 0x10 +#define SUN20I_GPADC_FIFO_DATA 0X14 +#define SUN20I_GPADC_CB_DATA 0X18 +#define SUN20I_GPADC_DATAL_INTC 0x20 +#define SUN20I_GPADC_DATAH_INTC 0x24 +#define SUN20I_GPADC_DATA_INTC 0x28 +#define SUN20I_GPADC_DATAL_INTS 0x30 +#define SUN20I_GPADC_DATAH_INTS 0x34 +#define SUN20I_GPADC_DATA_INTS 0x38 +#define SUN20I_GPADC_CH_CMP_DATA(x) (0x40 + (x) * 4) +#define SUN20I_GPADC_CH_DATA(x) (0x80 + (x) * 4) + +#define SUN20I_GPADC_CTRL_ADC_AUTOCALI_EN_MASK BIT(23) +#define SUN20I_GPADC_CTRL_WORK_MODE_MASK GENMASK(19, 18) +#define SUN20I_GPADC_CTRL_ADC_EN_MASK BIT(16) +#define SUN20I_GPADC_CS_EN_ADC_CH(x) BIT(x) +#define SUN20I_GPADC_DATA_INTC_CH_DATA_IRQ_EN(x) BIT(x) + +#define SUN20I_GPADC_WORK_MODE_SINGLE 0 + +struct sun20i_gpadc_iio { + void __iomem *regs; + struct completion completion; + int last_channel; + /* + * Lock to protect the device state during a potential concurrent + * read access from userspace. Reading a raw value requires a sequence + * of register writes, then a wait for a completion callback, + * and finally a register read, during which userspace could issue + * another read request. This lock protects a read access from + * ocurring before another one has finished. + */ + struct mutex lock; +}; + +static int sun20i_gpadc_adc_read(struct sun20i_gpadc_iio *info, + struct iio_chan_spec const *chan, int *val) +{ + u32 ctrl; + int ret = IIO_VAL_INT; + + mutex_lock(&info->lock); + + reinit_completion(&info->completion); + + if (info->last_channel != chan->channel) { + info->last_channel = chan->channel; + + /* enable the analog input channel */ + writel(SUN20I_GPADC_CS_EN_ADC_CH(chan->channel), + info->regs + SUN20I_GPADC_CS_EN); + + /* enable the data irq for input channel */ + writel(SUN20I_GPADC_DATA_INTC_CH_DATA_IRQ_EN(chan->channel), + info->regs + SUN20I_GPADC_DATA_INTC); + } + + /* enable the ADC function */ + ctrl = readl(info->regs + SUN20I_GPADC_CTRL); + ctrl |= FIELD_PREP(SUN20I_GPADC_CTRL_ADC_EN_MASK, 1); + writel(ctrl, info->regs + SUN20I_GPADC_CTRL); + + /* + * According to the datasheet Maksimum acquire time(TACQ) can be + * (65535+1)/24Mhz and conversion time(CONV_TIME) is always constant + * and equal to 14/24Mhz, so (TACQ+CONV_TIME) <= 2.73125ms. + * A 10ms delay should be enough to make sure an interrupt occurs in + * normal conditions. If it doesn't occur, then there is a timeout. + */ + if (!wait_for_completion_timeout(&info->completion, msecs_to_jiffies(10))) { + ret = -ETIMEDOUT; + goto err_unlock; + } + + /* read the ADC data */ + *val = readl(info->regs + SUN20I_GPADC_CH_DATA(chan->channel)); + +err_unlock: + mutex_unlock(&info->lock); + + return ret; +} + +static int sun20i_gpadc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct sun20i_gpadc_iio *info = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return sun20i_gpadc_adc_read(info, chan, val); + case IIO_CHAN_INFO_SCALE: + /* value in mv = 1800mV / 4096 raw */ + *val = 1800; + *val2 = 12; + return IIO_VAL_FRACTIONAL_LOG2; + default: + return -EINVAL; + } +} + +static irqreturn_t sun20i_gpadc_irq_handler(int irq, void *data) +{ + struct sun20i_gpadc_iio *info = data; + + /* clear data interrupt status register */ + writel(GENMASK(31, 0), info->regs + SUN20I_GPADC_DATA_INTS); + + complete(&info->completion); + + return IRQ_HANDLED; +} + +static const struct iio_info sun20i_gpadc_iio_info = { + .read_raw = sun20i_gpadc_read_raw, +}; + +static void sun20i_gpadc_reset_assert(void *data) +{ + struct reset_control *rst = data; + + reset_control_assert(rst); +} + +static int sun20i_gpadc_alloc_channels(struct iio_dev *indio_dev, + struct device *dev) +{ + unsigned int channel; + int num_channels, i, ret; + struct iio_chan_spec *channels; + struct fwnode_handle *node; + + num_channels = device_get_child_node_count(dev); + if (num_channels == 0) + return dev_err_probe(dev, -ENODEV, "no channel children\n"); + + channels = devm_kcalloc(dev, num_channels, sizeof(*channels), + GFP_KERNEL); + if (!channels) + return -ENOMEM; + + i = 0; + device_for_each_child_node(dev, node) { + ret = fwnode_property_read_u32(node, "reg", &channel); + if (ret) { + fwnode_handle_put(node); + return dev_err_probe(dev, ret, "invalid channel number\n"); + } + + channels[i].type = IIO_VOLTAGE; + channels[i].indexed = 1; + channels[i].channel = channel; + channels[i].info_mask_separate = BIT(IIO_CHAN_INFO_RAW); + channels[i].info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE); + + i++; + } + + indio_dev->channels = channels; + indio_dev->num_channels = num_channels; + + return 0; +} + +static int sun20i_gpadc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct iio_dev *indio_dev; + struct sun20i_gpadc_iio *info; + struct reset_control *rst; + struct clk *clk; + int irq; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*info)); + if (!indio_dev) + return -ENOMEM; + + info = iio_priv(indio_dev); + info->last_channel = -1; + + mutex_init(&info->lock); + init_completion(&info->completion); + + ret = sun20i_gpadc_alloc_channels(indio_dev, dev); + if (ret) + return ret; + + indio_dev->info = &sun20i_gpadc_iio_info; + indio_dev->name = SUN20I_GPADC_DRIVER_NAME; + + info->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(info->regs)) + return PTR_ERR(info->regs); + + clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), "failed to enable bus clock\n"); + + rst = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(rst)) + return dev_err_probe(dev, PTR_ERR(rst), "failed to get reset control\n"); + + ret = reset_control_deassert(rst); + if (ret) + return dev_err_probe(dev, ret, "failed to deassert reset\n"); + + ret = devm_add_action_or_reset(dev, sun20i_gpadc_reset_assert, rst); + if (ret) + return ret; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + ret = devm_request_irq(dev, irq, sun20i_gpadc_irq_handler, 0, + dev_name(dev), info); + if (ret) + return dev_err_probe(dev, ret, "failed requesting irq %d\n", irq); + + writel(FIELD_PREP(SUN20I_GPADC_CTRL_ADC_AUTOCALI_EN_MASK, 1) | + FIELD_PREP(SUN20I_GPADC_CTRL_WORK_MODE_MASK, SUN20I_GPADC_WORK_MODE_SINGLE), + info->regs + SUN20I_GPADC_CTRL); + + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return dev_err_probe(dev, ret, "could not register the device\n"); + + return 0; +} + +static const struct of_device_id sun20i_gpadc_of_id[] = { + { .compatible = "allwinner,sun20i-d1-gpadc" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sun20i_gpadc_of_id); + +static struct platform_driver sun20i_gpadc_driver = { + .driver = { + .name = SUN20I_GPADC_DRIVER_NAME, + .of_match_table = sun20i_gpadc_of_id, + }, + .probe = sun20i_gpadc_probe, +}; +module_platform_driver(sun20i_gpadc_driver); + +MODULE_DESCRIPTION("ADC driver for sunxi platforms"); +MODULE_AUTHOR("Maksim Kiselev "); +MODULE_LICENSE("GPL"); From patchwork Wed Jun 14 13:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13280059 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 E1B5BEB64D8 for ; Wed, 14 Jun 2023 13:28: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=lCOpJSyORq8rL15WVX3gLtStpCAyvhH/0vi81xlSv34=; b=2q3wWCiRDcTc9K AvetTEbr8Y10243D6Bnu49FwHMZp5KgFFkwMxCSRy+UlO3lR4Ev0ToutXayGRsOSdnVulJBMTdsw4 C7cHpfZf9kmkXmxsO3fffdYGJVGdrA1ncQR4iXWEfs/VWRe+idjv5+thh5TxirWa1h4//f3GkXPu3 kwyMYuWc8bekfD7hIX5sAJGfrtXwDEQ6OEuPGeYZEVXEpX2TGAZI9OFNJT69IWUkbs7/CobT/G+6n rKdBGDMNpCPDhZ2OeAztlzRZWvt8zCujSYUWIBrEz3zE/hIYYYW1RAV7bJsUmAQXpo1vbSqJ+9uKn JOqKtPBOZimq5rwpadTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9QXy-00BkSz-2Z; Wed, 14 Jun 2023 13:28:26 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9QXv-00BkQT-1j; Wed, 14 Jun 2023 13:28:25 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f7fcdc7f7fso5125505e9.0; Wed, 14 Jun 2023 06:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686749301; x=1689341301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b77Gx0dzvWdL2Ewt5vOqBtzy67fgg8OX+nEzj3LcNxc=; b=eGI3aVXPIExyJXocmigotKZcTTF+2K07Awv16Ea4pLVi1nZXq3IWbUSc62UAcRGWDf wfo3D/BRmZwfbThLYbHFSQ8fj3Rko+ILaamZ0O76grO8EiOqCv/Ri0gH6k496St542WU 4DWeldP131+b7A7JWV6BEPATdcdBDMlHM1kNDo+/kxMUSFS8nIWI7REwDHf0xxTkp5Kr 2RmPCacCTF7E4OQ3FD5LcdSnGXFUvi/IKHPbdJzmtM4VV2B+i6bqfKgDqBPVMu5vozfX T0RFmq5PoZuxJTPrbZWYm+YpNbHLjeSxBLA8mUbTUjQuB8Ye8ObY2v0IFYLOgUnO4S5H GDTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686749301; x=1689341301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b77Gx0dzvWdL2Ewt5vOqBtzy67fgg8OX+nEzj3LcNxc=; b=hw/YNyOb5gZrtCxmfuPjGCC5yqAlwa7EfEWRrlF6sEB0SZqzRqOIJT22EB5E+kQfNW nI1rkkLTiCCsU/1DD/3spUbqQpss7o5ovSW4CN8iPTjPgaMaWg33JtEek3Vh36VFyX5A cwzAOI6v3c5SJbULn/7ieFlGDdMMy6joeWE3CSCZ5Vf6e5XXyuxJWDqpmC0ysQpHxRPp c8sqKq/3ilv7eCmiCC2xWJ8P62vScFsfQ+B5TpanJnAROKzt/3spPFl1dtEMyHF1MEyi /rAdeu0W2QqP/T4uU2t9qayYiXrIO90cHwM71ZjnhsevWAwr8MSe6OjLaLlCEpevjywi IY/A== X-Gm-Message-State: AC+VfDz4+lORENT8T1IO/6aWfajV4zPgA7tlwwCicphPt3610H4D9Xje bXuLcGI7ikwf73pUPXyC55Q= X-Google-Smtp-Source: ACHHUZ4PW5hwIltSw2AlRcUvhdSuuPFBq2RV2rxrZZ8MBHLc3PORtG+ybj3h2gADj3GHmqAWVGc4SA== X-Received: by 2002:a05:600c:2281:b0:3f7:a20a:561d with SMTP id 1-20020a05600c228100b003f7a20a561dmr1619452wmf.8.1686749301236; Wed, 14 Jun 2023 06:28:21 -0700 (PDT) Received: from user-PC.. ([92.51.95.194]) by smtp.gmail.com with ESMTPSA id l6-20020a5d4bc6000000b003047ae72b14sm18295017wrt.82.2023.06.14.06.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 06:28:20 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maksim Kiselev , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Cristian Ciocaltea , Andre Przywara , Andy Shevchenko , Cosmin Tanislav , Miquel Raynal , Mike Looijmans , Ramona Bolboaca , Caleb Connolly , ChiYuan Huang , Ibrahim Tilki , ChiaEn Wu , William Breathitt Gray , Arnd Bergmann , Haibo Chen , =?utf-8?q?L?= =?utf-8?q?eonard_G=C3=B6hrs?= , Hugo Villeneuve , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v6 2/3] dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC Date: Wed, 14 Jun 2023 16:26:26 +0300 Message-Id: <20230614132644.699425-3-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614132644.699425-1-bigunclemax@gmail.com> References: <20230614132644.699425-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_062823_575756_6A470AEC X-CRM114-Status: GOOD ( 13.13 ) 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 Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC. This ADC is the same for all of this SoCs. The only difference is the number of available channels. Signed-off-by: Maksim Kiselev Reviewed-by: Conor Dooley --- .../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml new file mode 100644 index 000000000000..23c584f5a6e6 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/allwinner,sun20i-d1-gpadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Allwinner D1 General Purpose ADC + +maintainers: + - Maksim Kiselev + +properties: + compatible: + enum: + - allwinner,sun20i-d1-gpadc + + "#io-channel-cells": + const: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + clocks: + maxItems: 1 + + interrupts: + maxItems: 1 + + reg: + maxItems: 1 + + resets: + maxItems: 1 + +patternProperties: + "^channel@[0-9a-f]+$": + $ref: adc.yaml + type: object + description: + Represents the internal channels of the ADC. + + properties: + reg: + items: + minimum: 0 + Maksimum: 15 + + required: + - reg + + unevaluatedProperties: false + +required: + - "#io-channel-cells" + - clocks + - compatible + - interrupts + - reg + - resets + +additionalProperties: false + +examples: + - | + #include + #include + #include + + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x1000>; + clocks = <&ccu CLK_BUS_GPADC>; + resets = <&ccu RST_BUS_GPADC>; + interrupts = <73 IRQ_TYPE_LEVEL_HIGH>; + #io-channel-cells = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + }; + + channel@1 { + reg = <1>; + }; + }; +... From patchwork Wed Jun 14 13:26:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13280060 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 ABAE7EB64D8 for ; Wed, 14 Jun 2023 13:29:03 +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=DdReMgvPFdE/vDgai32Ln3UoTdrA7/7X8bIP+E5pi/4=; b=kLslZYSztlmNUq IGKjCaQ8PlSR+OPo2L6JfDYLKGGCh5SKO5KKJ4fU7jgQR69+g2gO+WIUIHYINKoYIaWmZLE2Pm6J9 68taNzkAAg7b8vASGoz+5ZwboKcMjf/A+J9n0yb+jac41sz7EOj5PKGCktfQRyaoZSnjAAIrxQtik 6nyN/M/Ohuvkd9yaGe51+25gNs/TjcTrWLoFEO9G4zNbw4cme8PbjvrOBegWDoGSRxrPIhtod5Nci dITyZM2dQQxO5PdmGCYpH4fOszTvlfq3UOlwwPa4sPjo7XaXinjdQHL2NQbem7CqtL2vt79r+m2PW fT8TD3oYJvci0JlppINg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9QYI-00BkZh-0X; Wed, 14 Jun 2023 13:28:46 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9QYF-00BkY6-07; Wed, 14 Jun 2023 13:28:44 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f8cec6641bso8103575e9.1; Wed, 14 Jun 2023 06:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686749321; x=1689341321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dPsNG/FZ1k4UaDSBhJRqncRzudNFaZG2hOicOFjuDg0=; b=AsIeycw7JKSVlX3rZAXj0VwdwEpUA2cD5kZgqIEd1XvHiu3ykvduo88KsTKzKKG3EK SWDNmkagjHwGdbFJQq6vXAtCthe/rufzfteujq9byzWzQ5TviAGm9c4cwtSHU/ZJlg8e yossznwjncroo/0G2M4iKun5LidbAiOGOHK32rSnH6Gpr3cZgGKimytAH1H8i5wk5o7G go0PvSQ2v5/yxUeA3E0MIB01DEJwOQYj2xuStS5IVs7/ierzqgHe4jjWqApZdNMS8lb/ EB//F+xYOiwfy9AYguYRf3LUuJwzU3457PdpZ95KTPsAPFwUdJDhcNcu56qmKs5zd1Z+ wb0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686749321; x=1689341321; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dPsNG/FZ1k4UaDSBhJRqncRzudNFaZG2hOicOFjuDg0=; b=AgdJaIWklnICnXg/duY8dk4HBqnOsWRkMFCACkzFY2MlSKEH4Z60uiHMdYyidwqbfZ TZa21Wf2RVz3iNHV6oBLLz0HKudpnTpLywDSJPytdKy79m2jGZlqjH7hLJ4oNegXfwH1 ifFbofLxMUXm+2zXgK+BO6+A03k4hWb+zTnBOxuE/zU0mgBhpQ5M3Djhhm0KXNVULLMR g9uUd7zWSaTi173D6uJkbvGaNtASWj//tewkDHdlvymMHRoWWKCJ15+yYPv8k8WlUT6q jQ8dE1v4rcXUj/bqUnrA5ezWxjTLWlH67M1eFj4bv6Yiu86Ri/zqfnqzIzufw2oomq00 3Maw== X-Gm-Message-State: AC+VfDzh5QIRSsqbQmakyPZ23+0m7Cc5TlIuCk7wrZa8J7myRO5yKOlt Qn5pewRRy0VFOEAQSB2+MDI= X-Google-Smtp-Source: ACHHUZ6OldjWB/O5w6++CoG5CqyBVydA97jdA46Qv0Hn+Fg2Ncy5riE3GkkDaTbuni9DWvVm/W2tqg== X-Received: by 2002:adf:f810:0:b0:30f:d32c:ed8e with SMTP id s16-20020adff810000000b0030fd32ced8emr2357358wrp.45.1686749320597; Wed, 14 Jun 2023 06:28:40 -0700 (PDT) Received: from user-PC.. ([92.51.95.194]) by smtp.gmail.com with ESMTPSA id l6-20020a5d4bc6000000b003047ae72b14sm18295017wrt.82.2023.06.14.06.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 06:28:40 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maksim Kiselev , Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Cristian Ciocaltea , Heiko Stuebner , Andy Shevchenko , Cosmin Tanislav , Ulf Hansson , Arnd Bergmann , Haibo Chen , Hugo Villeneuve , ChiYuan Huang , Ramona Bolboaca , Ibrahim Tilki , ChiaEn Wu , William Breathitt Gray , Caleb Connolly , =?utf-8?q?Leonard_G=C3=B6hrs?= , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v6 3/3] riscv: dts: allwinner: d1: Add GPADC node Date: Wed, 14 Jun 2023 16:26:27 +0300 Message-Id: <20230614132644.699425-4-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614132644.699425-1-bigunclemax@gmail.com> References: <20230614132644.699425-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_062843_075472_44CA0BAD X-CRM114-Status: GOOD ( 10.09 ) 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 This patch adds declaration of the general purpose ADC for D1 and T113s SoCs. Signed-off-by: Maksim Kiselev --- arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi index 922e8e0e2c09..90c79041cfba 100644 --- a/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +++ b/arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi @@ -138,6 +138,16 @@ ccu: clock-controller@2001000 { #reset-cells = <1>; }; + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x1000>; + clocks = <&ccu CLK_BUS_GPADC>; + resets = <&ccu RST_BUS_GPADC>; + interrupts = ; + status = "disabled"; + #io-channel-cells = <1>; + }; + dmic: dmic@2031000 { compatible = "allwinner,sun20i-d1-dmic", "allwinner,sun50i-h6-dmic";