From patchwork Tue Feb 18 06:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 11387863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22BF21395 for ; Tue, 18 Feb 2020 06:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 042F524655 for ; Tue, 18 Feb 2020 06:20:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="SnE4vO4q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726295AbgBRGUv (ORCPT ); Tue, 18 Feb 2020 01:20:51 -0500 Received: from mail.andi.de1.cc ([85.214.55.253]:58066 "EHLO mail.andi.de1.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbgBRGUu (ORCPT ); Tue, 18 Feb 2020 01:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xduJTT0bviGOj9/DUGQKc14Tgq0pDPhC7FFhfYWsClo=; b=SnE4vO4qfHeYd9wmOOuIUpQoeI dE5YxQWvYdxymjF7f/UNAhx1ih6cyQ7ry5X0WA3J4/aseHAVbjcNiFvy4zoQmDnMXQcxW73BEDMBQ BikK+9Aqh0Moda7+LznojPOpWwcp9IUOLf7Jy2pf/IbwgbWkn0E6EWhAwW7K+mkzprKc=; Received: from [77.247.85.102] (helo=localhost) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1j3wFM-0000ok-CE; Tue, 18 Feb 2020 07:20:40 +0100 Received: from andi by localhost with local (Exim 4.92) (envelope-from ) id 1j3wEv-0005rG-Iu; Tue, 18 Feb 2020 07:20:13 +0100 From: Andreas Kemnade To: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, lee.jones@linaro.org, b.galvani@gmail.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, phh@phh.me, stefan@agner.ch, letux-kernel@openphoenux.org, martin.blumenstingl@googlemail.com, jic23@kernel.org Cc: Andreas Kemnade Subject: [PATCH v3 1/4] mfd: rn5t618: add ADC subdevice for RC5T619 Date: Tue, 18 Feb 2020 07:17:22 +0100 Message-Id: <20200218061725.22420-2-andreas@kemnade.info> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218061725.22420-1-andreas@kemnade.info> References: <20200218061725.22420-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -1.0 (-) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org This adds a subdevice for tde ADC in the RC5T619 Signed-off-by: Andreas Kemnade --- depends on: https://lore.kernel.org/lkml/20191220122416.31881-1-andreas@kemnade.info/ Changes in v3: re-added it to the series (including an Ack) because of "Oh, it looks like there was a conflict. Could you collect any Acks (including mine) rebase and resend please?" drivers/mfd/rn5t618.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 073de8e0e78b..321836f78120 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -24,6 +24,7 @@ static const struct mfd_cell rn5t618_cells[] = { }; static const struct mfd_cell rc5t619_cells[] = { + { .name = "rn5t618-adc" }, { .name = "rn5t618-regulator" }, { .name = "rc5t619-rtc" }, { .name = "rn5t618-wdt" }, From patchwork Tue Feb 18 06:17:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 11387867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03354159A for ; Tue, 18 Feb 2020 06:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6ED721D7D for ; Tue, 18 Feb 2020 06:21:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="Gm9eS/Xo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbgBRGVA (ORCPT ); Tue, 18 Feb 2020 01:21:00 -0500 Received: from mail.andi.de1.cc ([85.214.55.253]:58024 "EHLO mail.andi.de1.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgBRGUu (ORCPT ); Tue, 18 Feb 2020 01:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5hmvZ4s2ZfotLVfVE2HDn0S2IYvgOP6OBTCMpuoAPUA=; b=Gm9eS/XoK3ZRKIneTCtWOmCT+P IfqWKcnSixaIG9z4E4N/0fxQM73Z94tX/zGjQ063zdTpqL23VidaOmr6RwTtpziCf6U/AWsihj9nj TKu93CcYsw34tMDaPeNFvbt+1A2GpALrgkBgDLIqdcTe9IulrJLSWsIzK7V4/gCYDl1E=; Received: from [77.247.85.102] (helo=localhost) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1j3wFM-0000oj-Bs; Tue, 18 Feb 2020 07:20:40 +0100 Received: from andi by localhost with local (Exim 4.92) (envelope-from ) id 1j3wF3-0005rI-Uf; Tue, 18 Feb 2020 07:20:21 +0100 From: Andreas Kemnade To: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, lee.jones@linaro.org, b.galvani@gmail.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, phh@phh.me, stefan@agner.ch, letux-kernel@openphoenux.org, martin.blumenstingl@googlemail.com, jic23@kernel.org Cc: Andreas Kemnade Subject: [PATCH v3 2/4] iio: adc: rn5t618: Add ADC driver for RN5T618/RC5T619 Date: Tue, 18 Feb 2020 07:17:23 +0100 Message-Id: <20200218061725.22420-3-andreas@kemnade.info> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218061725.22420-1-andreas@kemnade.info> References: <20200218061725.22420-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -1.0 (-) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Both chips have an A/D converter capable of measuring things like VBAT, VUSB and analog inputs. Signed-off-by: Andreas Kemnade Reviewed-by: Jonathan Cameron --- depends on (build and runtime): https://lore.kernel.org/lkml/20191220122416.31881-1-andreas@kemnade.info/ Changes in v3: - output scale instead of processed - prefixed symbols with RN5T618 Changes in v2: - enum for channels - bulk read instead of single byte read for conversion result - fix get_virq error handling - use devm for registering device and requesting IRQ drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/rn5t618-adc.c | 258 ++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+) create mode 100644 drivers/iio/adc/rn5t618-adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 5d8540b7b427..e7e74e775336 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -766,6 +766,16 @@ config RCAR_GYRO_ADC To compile this driver as a module, choose M here: the module will be called rcar-gyroadc. +config RN5T618_ADC + tristate "ADC for the RN5T618/RC5T619 family of chips" + depends on MFD_RN5T618 + help + Say yes here to build support for the integrated ADC inside the + RN5T618/619 series PMICs: + + This driver can also be built as a module. If so, the module + will be called rn5t618-adc. + config ROCKCHIP_SARADC tristate "Rockchip SARADC driver" depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index a1f1fbec0f87..ea95f89c91cd 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -72,6 +72,7 @@ obj-$(CONFIG_QCOM_VADC_COMMON) += qcom-vadc-common.o obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o obj-$(CONFIG_RCAR_GYRO_ADC) += rcar-gyroadc.o +obj-$(CONFIG_RN5T618_ADC) += rn5t618-adc.o obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o obj-$(CONFIG_SC27XX_ADC) += sc27xx_adc.o obj-$(CONFIG_SPEAR_ADC) += spear_adc.o diff --git a/drivers/iio/adc/rn5t618-adc.c b/drivers/iio/adc/rn5t618-adc.c new file mode 100644 index 000000000000..8396eba0fcb5 --- /dev/null +++ b/drivers/iio/adc/rn5t618-adc.c @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * ADC driver for the RICOH RN5T618 power management chip family + * + * Copyright (C) 2019 Andreas Kemnade + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RN5T618_ADC_CONVERSION_TIMEOUT (msecs_to_jiffies(500)) +#define RN5T618_REFERENCE_VOLT 2500 + +/* mask for selecting channels for single conversion */ +#define RN5T618_ADCCNT3_CHANNEL_MASK 0x7 +/* average 4-time conversion mode */ +#define RN5T618_ADCCNT3_AVG BIT(3) +/* set for starting a single conversion, gets cleared by hw when done */ +#define RN5T618_ADCCNT3_GODONE BIT(4) +/* automatic conversion, period is in ADCCNT2, selected channels are + * in ADCCNT1 + */ +#define RN5T618_ADCCNT3_AUTO BIT(5) +#define RN5T618_ADCEND_IRQ BIT(0) + +struct rn5t618_adc_data { + struct device *dev; + struct rn5t618 *rn5t618; + struct completion conv_completion; + int irq; +}; + +struct rn5t618_channel_ratios { + u16 numerator; + u16 denominator; +}; + +enum rn5t618_channels { + LIMMON = 0, + VBAT, + VADP, + VUSB, + VSYS, + VTHM, + AIN1, + AIN0 +}; + +static const struct rn5t618_channel_ratios rn5t618_ratios[8] = { + [LIMMON] = {50, 32}, /* measured across 20mOhm, amplified by 32 */ + [VBAT] = {2, 1}, + [VADP] = {3, 1}, + [VUSB] = {3, 1}, + [VSYS] = {3, 1}, + [VTHM] = {1, 1}, + [AIN1] = {1, 1}, + [AIN0] = {1, 1}, +}; + +static int rn5t618_read_adc_reg(struct rn5t618 *rn5t618, int reg, u16 *val) +{ + u8 data[2]; + int ret; + + ret = regmap_bulk_read(rn5t618->regmap, reg, data, sizeof(data)); + if (ret < 0) + return ret; + + *val = (data[0] << 4) | (data[1] & 0xF); + + return 0; +} + +static irqreturn_t rn5t618_adc_irq(int irq, void *data) +{ + struct rn5t618_adc_data *adc = data; + unsigned int r = 0; + int ret; + + /* clear low & high threshold irqs */ + regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC1, 0); + regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC2, 0); + + ret = regmap_read(adc->rn5t618->regmap, RN5T618_IR_ADC3, &r); + if (ret < 0) + dev_err(adc->dev, "failed to read IRQ status: %d\n", ret); + + regmap_write(adc->rn5t618->regmap, RN5T618_IR_ADC3, 0); + + if (r & RN5T618_ADCEND_IRQ) + complete(&adc->conv_completion); + + return IRQ_HANDLED; +} + +static int rn5t618_adc_read(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, + int *val, int *val2, long mask) +{ + struct rn5t618_adc_data *adc = iio_priv(iio_dev); + u16 raw; + int ret; + + if (mask == IIO_CHAN_INFO_SCALE) { + *val = RN5T618_REFERENCE_VOLT * + rn5t618_ratios[chan->channel].numerator; + *val2 = rn5t618_ratios[chan->channel].denominator * 4095; + + return IIO_VAL_FRACTIONAL; + } + + /* select channel */ + ret = regmap_update_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, + RN5T618_ADCCNT3_CHANNEL_MASK, + chan->channel); + if (ret < 0) + return ret; + + ret = regmap_write(adc->rn5t618->regmap, RN5T618_EN_ADCIR3, + RN5T618_ADCEND_IRQ); + if (ret < 0) + return ret; + + ret = regmap_update_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, + RN5T618_ADCCNT3_AVG, + mask == IIO_CHAN_INFO_AVERAGE_RAW ? + RN5T618_ADCCNT3_AVG : 0); + if (ret < 0) + return ret; + + init_completion(&adc->conv_completion); + /* single conversion */ + ret = regmap_update_bits(adc->rn5t618->regmap, RN5T618_ADCCNT3, + RN5T618_ADCCNT3_GODONE, + RN5T618_ADCCNT3_GODONE); + if (ret < 0) + return ret; + + ret = wait_for_completion_timeout(&adc->conv_completion, + RN5T618_ADC_CONVERSION_TIMEOUT); + if (ret == 0) { + dev_warn(adc->dev, "timeout waiting for adc result\n"); + return -ETIMEDOUT; + } + + ret = rn5t618_read_adc_reg(adc->rn5t618, + RN5T618_ILIMDATAH + 2 * chan->channel, + &raw); + if (ret < 0) + return ret; + + *val = raw; + + return IIO_VAL_INT; +} + +static const struct iio_info rn5t618_adc_iio_info = { + .read_raw = &rn5t618_adc_read, +}; + +#define RN5T618_ADC_CHANNEL(_channel, _type, _name) { \ + .type = _type, \ + .channel = _channel, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_AVERAGE_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .datasheet_name = _name, \ + .indexed = 1. \ +} + +static const struct iio_chan_spec rn5t618_adc_iio_channels[] = { + RN5T618_ADC_CHANNEL(LIMMON, IIO_CURRENT, "LIMMON"), + RN5T618_ADC_CHANNEL(VBAT, IIO_VOLTAGE, "VBAT"), + RN5T618_ADC_CHANNEL(VADP, IIO_VOLTAGE, "VADP"), + RN5T618_ADC_CHANNEL(VUSB, IIO_VOLTAGE, "VUSB"), + RN5T618_ADC_CHANNEL(VSYS, IIO_VOLTAGE, "VSYS"), + RN5T618_ADC_CHANNEL(VTHM, IIO_VOLTAGE, "VTHM"), + RN5T618_ADC_CHANNEL(AIN1, IIO_VOLTAGE, "AIN1"), + RN5T618_ADC_CHANNEL(AIN0, IIO_VOLTAGE, "AIN0") +}; + +static int rn5t618_adc_probe(struct platform_device *pdev) +{ + int ret; + struct iio_dev *iio_dev; + struct rn5t618_adc_data *adc; + struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); + + iio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); + if (!iio_dev) { + dev_err(&pdev->dev, "failed allocating iio device\n"); + return -ENOMEM; + } + + adc = iio_priv(iio_dev); + adc->dev = &pdev->dev; + adc->rn5t618 = rn5t618; + + if (rn5t618->irq_data) + adc->irq = regmap_irq_get_virq(rn5t618->irq_data, + RN5T618_IRQ_ADC); + + if (adc->irq <= 0) { + dev_err(&pdev->dev, "get virq failed\n"); + return -EINVAL; + } + + init_completion(&adc->conv_completion); + + iio_dev->name = dev_name(&pdev->dev); + iio_dev->dev.parent = &pdev->dev; + iio_dev->info = &rn5t618_adc_iio_info; + iio_dev->modes = INDIO_DIRECT_MODE; + iio_dev->channels = rn5t618_adc_iio_channels; + iio_dev->num_channels = ARRAY_SIZE(rn5t618_adc_iio_channels); + + /* stop any auto-conversion */ + ret = regmap_write(rn5t618->regmap, RN5T618_ADCCNT3, 0); + if (ret < 0) + return ret; + + platform_set_drvdata(pdev, iio_dev); + + ret = devm_request_threaded_irq(adc->dev, adc->irq, NULL, + rn5t618_adc_irq, + IRQF_ONESHOT, dev_name(adc->dev), + adc); + if (ret < 0) { + dev_err(adc->dev, "request irq %d failed: %d\n", adc->irq, ret); + return ret; + } + + ret = devm_iio_device_register(adc->dev, iio_dev); + + return ret; +} + +static struct platform_driver rn5t618_adc_driver = { + .driver = { + .name = "rn5t618-adc", + }, + .probe = rn5t618_adc_probe, +}; + +module_platform_driver(rn5t618_adc_driver); +MODULE_ALIAS("platform:rn5t618-adc"); +MODULE_DESCRIPTION("RICOH RN5T618 ADC driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Feb 18 06:17:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 11387869 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AEBE17EF for ; Tue, 18 Feb 2020 06:21:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C4FA21D7D for ; Tue, 18 Feb 2020 06:21:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="Ua4SnNym" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbgBRGVA (ORCPT ); Tue, 18 Feb 2020 01:21:00 -0500 Received: from mail.andi.de1.cc ([85.214.55.253]:58054 "EHLO mail.andi.de1.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgBRGUu (ORCPT ); Tue, 18 Feb 2020 01:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bDxLdFftj2IWWC8iJ/gD6olwrFTBIbD4WB3uu4ao4RY=; b=Ua4SnNymDOW+CeAghFqEEFozG/ Tj5c3e6dpeLvF3Oe1pDNqKEhaPCpjj/c1aBF4FEK5Hz9T/ZKpVav3IPAH54Fir05T56hUmoDtdJee 4LiRplNUeRlufno8ua2NmI/6Q2Ep5veFFTjJRHtU400eyGOEzllogeua/SeC4mEn8V+M=; Received: from [77.247.85.102] (helo=localhost) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1j3wFO-0000oy-1L; Tue, 18 Feb 2020 07:20:42 +0100 Received: from andi by localhost with local (Exim 4.92) (envelope-from ) id 1j3wF4-0005rK-VX; Tue, 18 Feb 2020 07:20:22 +0100 From: Andreas Kemnade To: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, lee.jones@linaro.org, b.galvani@gmail.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, phh@phh.me, stefan@agner.ch, letux-kernel@openphoenux.org, martin.blumenstingl@googlemail.com, jic23@kernel.org Cc: Andreas Kemnade Subject: [PATCH RFC v3 3/4] mfd: rn5t618: add IRQ definitions for RN5T618 Date: Tue, 18 Feb 2020 07:17:24 +0100 Message-Id: <20200218061725.22420-4-andreas@kemnade.info> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218061725.22420-1-andreas@kemnade.info> References: <20200218061725.22420-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -1.0 (-) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Previously, only the definitions for the RC5T619 were available. Signed-off-by: Andreas Kemnade --- depends on: https://lore.kernel.org/lkml/20191220122416.31881-1-andreas@kemnade.info/ Untested, IMHO only acceptable with a Tested-By. Not needed for the RC5T619, feel free to ignore them if the whole series would be delayed just because of missing Tested-By for this. drivers/mfd/rn5t618.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 321836f78120..6828fd40b0a1 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -58,6 +58,24 @@ static const struct regmap_config rn5t618_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const struct regmap_irq rn5t618_irqs[] = { + REGMAP_IRQ_REG(RN5T618_IRQ_SYS, 0, BIT(0)), + REGMAP_IRQ_REG(RN5T618_IRQ_DCDC, 0, BIT(1)), + REGMAP_IRQ_REG(RN5T618_IRQ_ADC, 0, BIT(3)), + REGMAP_IRQ_REG(RN5T618_IRQ_GPIO, 0, BIT(4)), + REGMAP_IRQ_REG(RN5T618_IRQ_CHG, 0, BIT(6)), +}; + +static const struct regmap_irq_chip rn5t618_irq_chip = { + .name = "rn5t618", + .irqs = rn5t618_irqs, + .num_irqs = ARRAY_SIZE(rn5t618_irqs), + .num_regs = 1, + .status_base = RN5T618_INTMON, + .mask_base = RN5T618_INTEN, + .mask_invert = true, +}; + static const struct regmap_irq rc5t619_irqs[] = { REGMAP_IRQ_REG(RN5T618_IRQ_SYS, 0, BIT(0)), REGMAP_IRQ_REG(RN5T618_IRQ_DCDC, 0, BIT(1)), @@ -92,6 +110,9 @@ static int rn5t618_irq_init(struct rn5t618 *rn5t618) case RC5T619: irq_chip = &rc5t619_irq_chip; break; + case RN5T618: + irq_chip = &rn5t618_irq_chip; + break; default: irq_chip = NULL; break; From patchwork Tue Feb 18 06:17:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 11387861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC03C1395 for ; Tue, 18 Feb 2020 06:20:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CDB021D7D for ; Tue, 18 Feb 2020 06:20:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="RHBmr/rj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbgBRGUu (ORCPT ); Tue, 18 Feb 2020 01:20:50 -0500 Received: from mail.andi.de1.cc ([85.214.55.253]:58022 "EHLO mail.andi.de1.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgBRGUu (ORCPT ); Tue, 18 Feb 2020 01:20:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nmY2tjaMWRwVLTyGzwjeXNSRFboYF38fEHLRyvhHHzA=; b=RHBmr/rjCFx1xxay/NykFECKA7 GOquwGZj8aEAYoe6td91EuHQYFzOyq/E4/+zDlm0ewsYmbYXC9G/tHKDvdfZUd478prGNDL0WoJS5 rqEUTniMFtU5GNB20FRZN0FDMzF6BSau5o2Mu+Tbegt3aCB6oZJvgCWVIpL07+9lU8JU=; Received: from [77.247.85.102] (helo=localhost) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1j3wFM-0000on-I9; Tue, 18 Feb 2020 07:20:41 +0100 Received: from andi by localhost with local (Exim 4.92) (envelope-from ) id 1j3wF5-0005rM-OK; Tue, 18 Feb 2020 07:20:23 +0100 From: Andreas Kemnade To: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, lee.jones@linaro.org, b.galvani@gmail.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, phh@phh.me, stefan@agner.ch, letux-kernel@openphoenux.org, martin.blumenstingl@googlemail.com, jic23@kernel.org Cc: Andreas Kemnade Subject: [PATCH RFC v3 4/4] mfd: rn5t618: add ADC subdevice for RN5T618 Date: Tue, 18 Feb 2020 07:17:25 +0100 Message-Id: <20200218061725.22420-5-andreas@kemnade.info> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200218061725.22420-1-andreas@kemnade.info> References: <20200218061725.22420-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -1.0 (-) Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org RN5T618 has an ADC but RN5T567 has not, so we need separate subdevice lists for both. Signed-off-by: Andreas Kemnade --- Untested, IMHO only acceptable with a Tested-By. Not needed for the RC5T619, feel free to ignore them if the whole series would be delayed just because of missing Tested-By for this. drivers/mfd/rn5t618.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 6828fd40b0a1..d37d7a31cf26 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -21,6 +21,7 @@ static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-regulator" }, { .name = "rn5t618-wdt" }, + { .name = "rn5t618-adc" }, }; static const struct mfd_cell rc5t619_cells[] = { @@ -30,6 +31,11 @@ static const struct mfd_cell rc5t619_cells[] = { { .name = "rn5t618-wdt" }, }; +static const struct mfd_cell rn5t567_cells[] = { + { .name = "rn5t618-regulator" }, + { .name = "rn5t618-wdt" }, +}; + static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -203,16 +209,32 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c, return ret; } - if (priv->variant == RC5T619) + switch (priv->variant) { + case RC5T619: ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE, rc5t619_cells, ARRAY_SIZE(rc5t619_cells), NULL, 0, NULL); - else + break; + case RN5T618: ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE, rn5t618_cells, ARRAY_SIZE(rn5t618_cells), NULL, 0, NULL); + break; + case RN5T567: + ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE, + rn5t567_cells, + ARRAY_SIZE(rn5t567_cells), + NULL, 0, NULL); + break; + /* + * Should not happen because we come here only with a valid device + * tree match, so variant contains any of the above. + */ + default: + return -ENOENT; + } if (ret) { dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); return ret;