From patchwork Thu Jun 1 22:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13264540 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 5451DC77B7A for ; Thu, 1 Jun 2023 22:32:04 +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=uQLbKNnF769Ey7g7n7FRpSIq9fUndhcrTZM+dWj5Jes=; b=cWSnwabC9fzRg+ BlwyYE5wFi9/cfh4UqSAHyj9UnDwOKrHChqQoN2GCcbpfMUh6cqJZafcrtKQ+vFxLsdlumtvwQZj6 +Iwh8mvAc6QNqey5gkgYjxJTlMWgGfBH4PT7/8U+fqShfJTco3L2UwWrayZ1OuZNkG7ZadghQkpeS BkqtSjgkF4TNcKkrqkm4dm3PgQYbHq2kU6aSxa7It8ohAccasFQhXuNZ2WsjhEOQqV6zfQaWiXVmG VrgVWAuqa72VXUA04lwryXsUc2P5DhGXWpOfH/wTbLxHErfBggQOgKTN7em593Cl0ZZ3IMoNOiVr0 Yfxmr/fmPSpX+VV0WNKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4qpq-0058RM-0w; Thu, 01 Jun 2023 22:31:58 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4qpm-0058Q4-0q; Thu, 01 Jun 2023 22:31:56 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f6dfc4e01fso14482045e9.0; Thu, 01 Jun 2023 15:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685658711; x=1688250711; 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=bLSVIxme6KJ3aqYjv0nrqVRHuMFGNioy207Dudv9OR0=; b=c4NYkGxHaV+1Rmcr/YJKpOu/KuPdhp9VRHQOCQRlMgCGGLqugamLA6OhO74qFY3NlZ AGBfnXPLbt515It/PVeNaA7QAY/Aw8lM9ePtRVKL4utjZQOQfA7f8MFSqAC3lJRHPQ7o LHIuUqSeW61lpv96Yn20fu1dHvCo4Ce28xXczeteecPnfb0u/MjvJFmj/ByDOFt69WH9 Ephy4LwzeEAF7fz09E+Z3czOsfFU2O4Qt3yy68iQ/jhgyv4d8ulJzzOYsl344p+IbO+x /ZslZGoihyTJctaxje7ZkCg3a1BjYv0avTVj5HOcGdv0M9N21Xvsv28vPkwB3rPnZENb V2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685658711; x=1688250711; 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=bLSVIxme6KJ3aqYjv0nrqVRHuMFGNioy207Dudv9OR0=; b=SM/B/nVmVh1v4vHN3K+RoiM6mizx35FnR4cQGivndikwOsEvgRg0Qj0WRgIX5loArm KaoHlDjQ0K36/n5SchWKVXQO121Xh75D/nh2vJPc7iF2U1/+VPI+pxDMmoaiQrRBHUV5 3qiu9Z8ivgPYha5gUX5RFjviS5EsV9+bGUshjH8HmH7Sw1IwYzSZxMsrjdxzzTDRJ+aZ mBVSGPYqoJjNjy2eHKQAz+Sp9l88J7ID4eYDy9tXKH3jUFP1jT1kddSoi5NAtEAD+pXU 78w50+mdEPnovfyeIePcgQpR0V3S4kXaV50QWSXfSF2jerbsbO3W9HGrTbiH9v3QJuGQ YJMA== X-Gm-Message-State: AC+VfDztwpZNLLBPdjaHNV2PxKeYFI3YQDpDs/lcJknue+JRXfbhHe0Y 0dbTsNfUeCsQdKA8kQAMd0Q= X-Google-Smtp-Source: ACHHUZ4TuZuQNCsW4w/zHvMEZSqRsU0gVAkPEtBY+dXcj95iKDAXJE4TJb+Dsm7n22DdTW/wQtJhww== X-Received: by 2002:a7b:c40a:0:b0:3f5:ce4:6c3f with SMTP id k10-20020a7bc40a000000b003f50ce46c3fmr608558wmi.7.1685658711260; Thu, 01 Jun 2023 15:31:51 -0700 (PDT) Received: from user-PC.. ([178.134.198.138]) by smtp.gmail.com with ESMTPSA id b7-20020a5d4d87000000b0030af8da022dsm8619149wru.44.2023.06.01.15.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 15:31:50 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maxim 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 , Andy Shevchenko , Cosmin Tanislav , Miquel Raynal , ChiaEn Wu , Arnd Bergmann , Ramona Bolboaca , Caleb Connolly , ChiYuan Huang , Ibrahim Tilki , William Breathitt Gray , =?utf-8?q?Leonard_G=C3=B6?= =?utf-8?q?hrs?= , Haibo Chen , Hugo Villeneuve , 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 v2 1/3] iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC Date: Fri, 2 Jun 2023 01:30:39 +0300 Message-Id: <20230601223104.1243871-2-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601223104.1243871-1-bigunclemax@gmail.com> References: <20230601223104.1243871-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_153154_302826_4A683E99 X-CRM114-Status: GOOD ( 29.11 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Maxim Kiselev 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: Maxim Kiselev --- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/sun20i-gpadc-iio.c | 296 +++++++++++++++++++++++++++++ 3 files changed, 307 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..f4f1dcb06ea5 --- /dev/null +++ b/drivers/iio/adc/sun20i-gpadc-iio.c @@ -0,0 +1,296 @@ +// 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 + +#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) + +/* ADC bit shift */ +#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) + +/* ADC parameters */ +#define SUN20I_GPADC_WORK_MODE_SINGLE 0 + +#define SUN20I_GPADC_MAX_CHANNELS 16 + +struct sun20i_gpadc_iio { + struct regmap *regmap; + struct completion completion; + struct mutex lock; + int lastch; +}; + +static const struct regmap_config sun20i_gpadc_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .fast_io = true, +}; + +static int sun20i_gpadc_adc_read(struct sun20i_gpadc_iio *info, + struct iio_chan_spec const *chan, int *val) +{ + int ret = IIO_VAL_INT; + + mutex_lock(&info->lock); + + reinit_completion(&info->completion); + + if (info->lastch != chan->channel) { + info->lastch = chan->channel; + + /* enable the analog input channel */ + regmap_write(info->regmap, SUN20I_GPADC_CS_EN, + SUN20I_GPADC_CS_EN_ADC_CH(chan->channel)); + + /* enable the data irq for input channel */ + regmap_write(info->regmap, SUN20I_GPADC_DATA_INTC, + SUN20I_GPADC_DATA_INTC_CH_DATA_IRQ_EN(chan->channel)); + } + + /* enable the ADC function */ + regmap_update_bits(info->regmap, SUN20I_GPADC_CTRL, + SUN20I_GPADC_CTRL_ADC_EN_MASK, SUN20I_GPADC_CTRL_ADC_EN_MASK); + + if (!wait_for_completion_timeout(&info->completion, + msecs_to_jiffies(100))) { + ret = -ETIMEDOUT; + goto err; + } + + /* read the ADC data */ + regmap_read(info->regmap, SUN20I_GPADC_CH_DATA(chan->channel), val); + +err: + 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); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = sun20i_gpadc_adc_read(info, chan, val); + return ret; + 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 */ + regmap_write(info->regmap, SUN20I_GPADC_DATA_INTS, ~0); + + 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) { + dev_err(dev, "no channel children"); + return -ENODEV; + } + + if (num_channels > SUN20I_GPADC_MAX_CHANNELS) { + dev_err(dev, "num of channel children out of range"); + return -EINVAL; + } + + 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) + goto err_child_out; + + 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; + +err_child_out: + fwnode_handle_put(node); + + return ret; +} + +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; + void __iomem *base; + 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->lastch = -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; + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + info->regmap = devm_regmap_init_mmio(dev, base, + &sun20i_gpadc_regmap_config); + if (IS_ERR(info->regmap)) + return dev_err_probe(dev, PTR_ERR(info->regmap), + "failed to init regmap\n"); + + 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 < 0) + return dev_err_probe(dev, ret, + "failed requesting irq %d\n", irq); + + regmap_write(info->regmap, SUN20I_GPADC_CTRL, + FIELD_PREP(SUN20I_GPADC_CTRL_ADC_AUTOCALI_EN_MASK, 1) | + FIELD_PREP(SUN20I_GPADC_CTRL_WORK_MODE_MASK, SUN20I_GPADC_WORK_MODE_SINGLE)); + + ret = devm_iio_device_register(dev, indio_dev); + if (ret < 0) + 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 Thu Jun 1 22:30:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13264541 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 4451AC77B7E for ; Thu, 1 Jun 2023 22:32: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=gQx2lguBOYDfK+b123XYytzo16Hz7cssuFy3iKExHGg=; b=2F31h1VidOzk+/ mYRuho/Uq22USbdCnw3nKVn1sLuHuARPB6IJKmfuGoMo6GbYJl7Eltx8cu8UnkgEJ7FgQTuqK2dXE GyUlQ/ywEWqOe8kUXvEQ55qDLns5nSiGoFdCDZ+s30iGJll2pTg5pH2pAaFpu1DRMH66lG7UtoNQr kBOxIvi+gp9+iysg4WRX4T0UFuj1FHzQmErrshFmU4VwPNkRAmvlc5pyn5GfF7EpS2afhMeA2J5ki dxLT1y0a5ocMNF9iAdvf/rQMIopXkE1FAMZeJiIImRea8hnDBTjvBED6PaBad+M6gZgZsKCC/rnCg r57Wgy0BViUATpj54Awg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4qqG-0058Yr-0C; Thu, 01 Jun 2023 22:32:24 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4qqC-0058V6-10; Thu, 01 Jun 2023 22:32:21 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-30a1fdde3d6so1402116f8f.0; Thu, 01 Jun 2023 15:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685658731; x=1688250731; 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=RDQovBoms3FLau58BysfqmyJWkZDGP+mDWm5zuqZL/Y=; b=nJ5nrB/K65xBQKeS4GK49exb8oASXvkB07wZO02wNCVCzxUG+fXPDtEcDX1berfUJd +Dnim0ocLAx6/xp4BqZHLDSdO5QS9me/pYMaRIrhky0TGnpJbxDqO7aDu8BcOELRIMIV T1FMGnigqZwePfryfBXqE8S6Um91z4H7ji7M6+YlBlSeaJxylPSlgpsSFbnmXAeNQ/H+ WzpMtM1IbWpS4PUsNYMkWRN6+G7FtIdvkbA4F1Fd2UWBP8woALbMjNjERKg2hovSBsH3 0y0YkI4wO8qI2MI3pKH5oA+nA+L6qGqsRXDsSiH58FHQshYUIdHAxwdUS2TU9nh2dsMa exYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685658731; x=1688250731; 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=RDQovBoms3FLau58BysfqmyJWkZDGP+mDWm5zuqZL/Y=; b=Ela7uBV//k6gjciqqGUbaTCjBmM+XchxcPxSQCrA1vWl9cnzdmzyspgBPHzcoIyCCt AaCyzn465TcXH3YkqyDp6PRK0MTp8wMtz2A7jmufvjWNsCDMzxlH1eJsO9rmJFDC/iW9 wXDYbeMsj0h47d+jDtNsbVjDmWEzd03/x4pzSX6lRjQGh5hXJn+mKLBdQsAZ8D5M1i2/ 4CvjzWMmVBNt4Ix9SXvljzhX9I3a2RyfuRpXWTmQDUFg7FQCVnU5nyy0xzVRxJ4KF68c WoCa7CEsGYykAqdNQeukmNDfLe5UMCPwk7L7vXEJ0kqBguv5S60wLLmstUZ3QXtgXxC2 /IvA== X-Gm-Message-State: AC+VfDyE+Wy4Do+1XjXuqNkwdcJEMb0p6+bCNMtefwucOZS67jQq/G7W 6yMI3/ZkewS6+jYiF/0J9ts= X-Google-Smtp-Source: ACHHUZ4UrAst4qPVDvoXKTVPsJrseXBlcZmYfr9vB25sGSdLTIpkgvX8Re139ignQ4DE5Du+R0qDmw== X-Received: by 2002:a05:6000:1191:b0:300:cb8c:fd8f with SMTP id g17-20020a056000119100b00300cb8cfd8fmr2588538wrx.54.1685658731484; Thu, 01 Jun 2023 15:32:11 -0700 (PDT) Received: from user-PC.. ([178.134.198.138]) by smtp.gmail.com with ESMTPSA id b7-20020a5d4d87000000b0030af8da022dsm8619149wru.44.2023.06.01.15.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 15:32:11 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maxim 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 , Stephen Boyd , Arnd Bergmann , William Breathitt Gray , Hugo Villeneuve , Mike Looijmans , ChiYuan Huang , Ramona Bolboaca , Ibrahim Tilki , Caleb Connolly , AngeloGioacchino Del Regno , ChiaEn Wu , 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 v2 2/3] dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC Date: Fri, 2 Jun 2023 01:30:40 +0300 Message-Id: <20230601223104.1243871-3-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601223104.1243871-1-bigunclemax@gmail.com> References: <20230601223104.1243871-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_153220_347539_C3D374FE X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Maxim Kiselev 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: Maxim Kiselev --- .../iio/adc/allwinner,sun20i-d1-gpadc.yaml | 79 +++++++++++++++++++ 1 file changed, 79 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..94f15bb48231 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: GPL-2.0 +%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 + +properties: + "#io-channel-cells": + const: 1 + + clocks: + maxItems: 1 + + compatible: + enum: + - allwinner,sun20i-d1-gpadc + + interrupts: + maxItems: 1 + + reg: + maxItems: 1 + + resets: + maxItems: 1 + +required: + - "#io-channel-cells" + - clocks + - compatible + - interrupts + - reg + - resets + +patternProperties: + "^channel@([0-15])$": + $ref: adc.yaml + type: object + description: | + Represents the internal channels of the ADC. + + properties: + reg: + description: | + The channel number. + Up to 16 channels, numbered from 0 to 15. + items: + minimum: 0 + maximum: 15 + + required: + - reg + + additionalProperties: false + +additionalProperties: false + +examples: + - | + gpadc: adc@2009000 { + compatible = "allwinner,sun20i-d1-gpadc"; + reg = <0x2009000 0x1000>; + clocks = <&ccu 80>; + resets = <&ccu 32>; + interrupts = <0 57 4>; + #io-channel-cells = <1>; + + channel@0 { + reg = <0>; + }; + + channel@1 { + reg = <1>; + }; + }; + +... From patchwork Thu Jun 1 22:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Kiselev X-Patchwork-Id: 13264542 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 B8B17C77B7A for ; Thu, 1 Jun 2023 22:32:42 +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=ykkXplSPzTWz12JdxRq5t//LP3nCPq8Jin5M9FRThJc=; b=SfmzhoB4sUaMvO x3KF0aQxzGx64+zBVgMKaFBsGNaiuw9hCuz6xGcKemBT13U4pVDGDZItuzCY5PmJOJW4hWdHQ96qb hqWWdWgt4Kzs3RAalNbdQt2wlb0Ke3DS4B28uhyKKMr8RmywCaWhTqRNo5gP0jwZJNIi3sb8fx4Pd nvCB24sZqo8ZMTL9rKyiMnMHBxaUSatSTuUlwg0Li4EqMd8blRmkjVdTzGKw7UlwVgWC4sTYW5ZTl pY+S2a1VrDIOWoYImJzFgIFs64SZ+Wa/msyP9UIMwFtA/kMJPiVGSrhJnRk+Qk6rH5cjZCk19uOO6 UTwYwsxwaD8hdY0J1nEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4qqU-0058db-1t; Thu, 01 Jun 2023 22:32:38 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4qqR-0058bU-28; Thu, 01 Jun 2023 22:32:36 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-30ae5f2ac94so1393578f8f.1; Thu, 01 Jun 2023 15:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685658752; x=1688250752; 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=9/TmEA+PoC7xu6/KU/ll32pvJQ2ck1CrGNuRyF6FIV0=; b=PONnEob4cS799koyjCLxAEsadb0C5Fdkmzoc9mRcit0XlOSYJQv+wlsMZI1/KUhrq0 EmiI5N6UUlzX07g4bppV5fM/ERH0Kc1q6C1Ecwo+XK/lBO+kqZhSWdHRQTJn/r+xHJ3Q /RBLLfLxgIVRLbYYoZgGQ+EM/XZH2dpFGccTFJrYUZ3AkWEYYPMaVSTUYmlnEKCu306P mM31tPQ8fqWiFZRgKAMLFy8HVh/vqXa11YJMlUmyGKmSiVSSfBBkOZuln7xeu0urBO3P kdwBI+K529QyXPDED8jvlTPhU96rtmoSs6MoFIw1vWgaQmEoeT+EXp2xw9pGcPw+t1ZH J4Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685658752; x=1688250752; 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=9/TmEA+PoC7xu6/KU/ll32pvJQ2ck1CrGNuRyF6FIV0=; b=YDWuGQ+CRGlre/F1yaFT3qFgB81u3PV4Kc54lFTIEiN38f5QGWlp86y+E8QSCCgpD4 0taQJf77nuop/aQll82dbX6DrGL4wqR4qnfSy3NJXWQ3YoHF0SWqYK+/TL9MQ//GFMDu jxujI5oL+/uAYy2F16cqwzIPgIJmFFYnaa6p04Dg8fmrDs5WaJcnUZl6mrTdimsy73cD iahaX2cyUdK1Ksz/5bj+inOnpY2QGWuk8irj4hpu7jnAYjSjWNvjcM9TRiOB7pJ8yUL0 kkPJMQ+tSaj+3OxID69FvnKFoYk0p8Xk8zJ3uP/msXrW2w6OqjpchgNpCTHCnwioVzxc flpw== X-Gm-Message-State: AC+VfDy8d1+yi8dZQxPn2xtLOyw2lwJQWlZAIctBCSwscVnRzd2G9PqB k0z/t+l7euRJDpKAX6J6uRI= X-Google-Smtp-Source: ACHHUZ7+6YZkcaeG6CeOS2iTlIxdCLfJll9IA+N/ujkTvPbYMeBBBBx/fSq02syrGNxPfUZeojqXWg== X-Received: by 2002:a5d:6709:0:b0:30a:eac8:e5c1 with SMTP id o9-20020a5d6709000000b0030aeac8e5c1mr3088955wru.6.1685658751871; Thu, 01 Jun 2023 15:32:31 -0700 (PDT) Received: from user-PC.. ([178.134.198.138]) by smtp.gmail.com with ESMTPSA id b7-20020a5d4d87000000b0030af8da022dsm8619149wru.44.2023.06.01.15.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 15:32:31 -0700 (PDT) From: Maksim Kiselev To: linux-iio@vger.kernel.org Cc: Maxim 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 , Andre Przywara , Andy Shevchenko , Cosmin Tanislav , Alexander Sverdlin , =?utf-8?q?Leonard_G?= =?utf-8?q?=C3=B6hrs?= , ChiaEn Wu , Marcus Folkesson , Ibrahim Tilki , ChiYuan Huang , Ramona Bolboaca , Caleb Connolly , William Breathitt Gray , Arnd Bergmann , Mike Looijmans , 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 v2 3/3] riscv: dts: allwinner: d1: Add GPADC node Date: Fri, 2 Jun 2023 01:30:41 +0300 Message-Id: <20230601223104.1243871-4-bigunclemax@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601223104.1243871-1-bigunclemax@gmail.com> References: <20230601223104.1243871-1-bigunclemax@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_153235_697922_47761E5B X-CRM114-Status: GOOD ( 10.41 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Maxim Kiselev This patch adds declaration of the general purpose ADC for D1 and T113s SoCs. Signed-off-by: Maxim 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";