From patchwork Sun Jan 28 23:29:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rossak X-Patchwork-Id: 10188609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7824F60383 for ; Sun, 28 Jan 2018 23:33:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FEDF286D2 for ; Sun, 28 Jan 2018 23:33:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60BE8286D1; Sun, 28 Jan 2018 23:33:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 13340286D1 for ; Sun, 28 Jan 2018 23:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LrM3mOp0M+OoB6EDC8QIG/KoZuxwIrHX5FGZ/239lPM=; b=Sa/H8wP6fmzAuaGmkDY4QNkjHZ RCnCRtHRLkD7hTx7qA7TEtucUf7UkosWiPZzjvQvu2crhr1SrlisX4UZwF54/9Ev3bYxuF6ArT8HF I0HxbVGPw8V3koc6DClrsBiLU/o02uGbFEckK62sinmU0/Nx3qzUjmBI054FJ6bivN7yJEmg+GPoL 7ZY5S6Q+ZG4goSyaTqc/c39tBpP8ESiwu4xw0oJhlwQM5gdAdEXvxVoYd/J3bxjkEe6qpInO7lbWe peZ0pNsj6MFGNcmzf7TMNnszSCb15q4GLEl4reG2UMDvRGvXin4jBd0Fm4mCmRaasi9ODimSFNIMw N6ge5wVA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1efwRq-0000MA-FY; Sun, 28 Jan 2018 23:33:18 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1efwOX-0004M5-DB for linux-arm-kernel@lists.infradead.org; Sun, 28 Jan 2018 23:29:56 +0000 Received: by mail-wm0-x243.google.com with SMTP id b21so30444180wme.4 for ; Sun, 28 Jan 2018 15:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CAPy7u17iUOHgD8slI9hKL0MITYV+3t+MDJoEnq2T5o=; b=l3ANpQLfruy/112YVCuwPXSrRqxoGxWtksSBYl1D3oga0xdGdfEk+bdQpCwlkBT4Qj J0ySI26vIZT++Q+B839slKHkLzTqzQJJ6XnmdWzsZ/1GvmHRc1pwelCiKwZrA+SoJVdP sPr8OhVwOqR9Epp0cSXhHwCz4jB6w9NA0/Jv3TzULid5OB9Pzgin8vCjzfkdmx2sWTt8 5QK4BF4/YBlFhVqgHePcp7KnWo19l7apEdk3vc78kACD36GJndsbZu6rV/lXhG1X8KtM l3gK/Y7+dbnYhWbc7pdS3VgoEkdVwSWca3OC8MhMYEsyr7jF71ktj90DP8BQHiKdhTHB x6RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CAPy7u17iUOHgD8slI9hKL0MITYV+3t+MDJoEnq2T5o=; b=O2MY3MuFTSySM2HY5nuWjG25GJthlePdGH6/nnABJbeI/tq+xFhOkzFhkxD/JqOfh/ paGjkl9J0/0c4XLRQGOxw1W2HmrKlUjGTTKAYKXEWOzNc4Byt/oxHF6ExM/mBICV1QR7 fMB99zlPANaAflLIm+e3MaSMhOpE9K6GHMpxTkw8A32yau7Nc1iWzt9cvsjwA4ulNmU5 KWLi5DQL3OQvnf/IYk7FTVv3oiCxpsUTQJ5yM9NMr1I+Zi51HIYfULMMj68WN8fbll/r TVmNVPZuML2hxCxppSMqbEW+W5IJjHPIKZeJeQdMUyH2vcdNWyeA91wgkIgdfx+O0E1I UHag== X-Gm-Message-State: AKwxytenDRZYL8jItH1US1gekoqRSu34IYqXJVB/9XoOmVpVW8AFOVxw 55IT9L43oUyK/KhqzKRxYhg= X-Google-Smtp-Source: AH8x226iDozaWTXGv+xPh4KotNrm8VKVR5aFh61HnpSvZCMlq4RtOdDyoeRBT3lmRkhxw1YsP+q7QQ== X-Received: by 10.28.30.66 with SMTP id e63mr16793353wme.69.1517182180917; Sun, 28 Jan 2018 15:29:40 -0800 (PST) Received: from debian-laptop.fritz.box (p578F04D2.dip0.t-ipconnect.de. [87.143.4.210]) by smtp.gmail.com with ESMTPSA id m86sm11839223wmi.40.2018.01.28.15.29.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jan 2018 15:29:40 -0800 (PST) From: Philipp Rossak To: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@free-electrons.com, wens@csie.org, linux@armlinux.org.uk, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, davem@davemloft.net, hans.verkuil@cisco.com, mchehab@kernel.org, rask@formelder.dk, clabbe.montjoie@gmail.com, sean@mess.org, krzk@kernel.org, quentin.schulz@free-electrons.com, icenowy@aosc.io, edu.molinas@gmail.com, singhalsimran0@gmail.com Subject: [PATCH v2 10/16] iio: adc: sun4i-gpadc-iio: add support for A83T thermal sensor Date: Mon, 29 Jan 2018 00:29:13 +0100 Message-Id: <20180128232919.12639-11-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180128232919.12639-1-embed3d@gmail.com> References: <20180128232919.12639-1-embed3d@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the A83T ths sensor. The A83T supports interrupts. The interrupt is configured to update the the sensor values every second. Signed-off-by: Philipp Rossak --- drivers/iio/adc/sun4i-gpadc-iio.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/sun4i-gpadc.h | 18 ++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 8196203d65fe..9f7895ba1966 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -170,6 +170,40 @@ static const struct gpadc_data sun8i_h3_ths_data = { SUN8I_H3_THS_TEMP_PERIOD(0x7), }; +static const struct gpadc_data sun8i_a83t_ths_data = { + .temp_offset = -2724, + .temp_scale = -70, + .temp_data = {SUN8I_H3_THS_TDATA0, + SUN8I_A83T_THS_TDATA1, + SUN8I_A83T_THS_TDATA2, + 0}, + .sample_start = sunxi_ths_sample_start, + .sample_end = sunxi_ths_sample_end, + .sensor_count = 3, + .supports_nvmem = false, + .support_irq = true, + .ctrl0_map = SUN4I_GPADC_CTRL0_T_ACQ(0x1f3), + .ctrl2_map = SUN8I_H3_THS_ACQ1(0x1f3), + .sensor_en_map = SUN8I_H3_THS_TEMP_SENSE_EN0 | + SUN8I_A83T_THS_TEMP_SENSE_EN1 | + SUN8I_A83T_THS_TEMP_SENSE_EN2, + .filter_map = SUN4I_GPADC_CTRL3_FILTER_EN | + SUN4I_GPADC_CTRL3_FILTER_TYPE(0x2), + .irq_clear_map = SUN8I_H3_THS_INTS_ALARM_INT_0 | + SUN8I_A83T_THS_INTS_ALARM_INT_1 | + SUN8I_A83T_THS_INTS_ALARM_INT_2 | + SUN8I_H3_THS_INTS_SHUT_INT_0 | + SUN8I_A83T_THS_INTS_SHUT_INT_1 | + SUN8I_A83T_THS_INTS_SHUT_INT_2 | + SUN8I_H3_THS_INTS_TDATA_IRQ_0 | + SUN8I_A83T_THS_INTS_TDATA_IRQ_1 | + SUN8I_A83T_THS_INTS_TDATA_IRQ_2, + .irq_control_map = SUN8I_H3_THS_INTC_TDATA_IRQ_EN0 | + SUN8I_A83T_THS_INTC_TDATA_IRQ_EN1 | + SUN8I_A83T_THS_INTC_TDATA_IRQ_EN2 | + SUN8I_H3_THS_TEMP_PERIOD(0x257), +}; + struct sun4i_gpadc_iio { struct iio_dev *indio_dev; struct completion completion; @@ -668,6 +702,10 @@ static const struct of_device_id sun4i_gpadc_of_id[] = { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths_data, }, + { + .compatible = "allwinner,sun8i-a83t-ths", + .data = &sun8i_a83t_ths_data, + }, { /* sentinel */ } }; diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h index 80b79c31cea3..32f15cc03363 100644 --- a/include/linux/mfd/sun4i-gpadc.h +++ b/include/linux/mfd/sun4i-gpadc.h @@ -99,21 +99,39 @@ #define SUNXI_THS_CDATA_0_1 0x74 #define SUNXI_THS_CDATA_2_3 0x78 #define SUN8I_H3_THS_TDATA0 0x80 +#define SUN8I_A83T_THS_TDATA1 0x84 +#define SUN8I_A83T_THS_TDATA2 0x88 #define SUN8I_H3_THS_ACQ1(x) (GENMASK(31, 16) & ((x) << 16)) #define SUN8I_H3_THS_TEMP_SENSE_EN0 BIT(0) +#define SUN8I_A83T_THS_TEMP_SENSE_EN1 BIT(1) +#define SUN8I_A83T_THS_TEMP_SENSE_EN2 BIT(2) #define SUN8I_H3_THS_TEMP_PERIOD(x) (GENMASK(31, 12) & ((x) << 12)) #define SUN8I_H3_THS_INTS_ALARM_INT_0 BIT(0) +#define SUN8I_A83T_THS_INTS_ALARM_INT_1 BIT(1) +#define SUN8I_A83T_THS_INTS_ALARM_INT_2 BIT(2) #define SUN8I_H3_THS_INTS_SHUT_INT_0 BIT(4) +#define SUN8I_A83T_THS_INTS_SHUT_INT_1 BIT(5) +#define SUN8I_A83T_THS_INTS_SHUT_INT_2 BIT(6) #define SUN8I_H3_THS_INTS_TDATA_IRQ_0 BIT(8) +#define SUN8I_A83T_THS_INTS_TDATA_IRQ_1 BIT(9) +#define SUN8I_A83T_THS_INTS_TDATA_IRQ_2 BIT(10) #define SUN8I_H3_THS_INTS_ALARM_OFF_0 BIT(12) +#define SUN8I_A83T_THS_INTS_ALARM_OFF_1 BIT(13) +#define SUN8I_A83T_THS_INTS_ALARM_OFF_2 BIT(14) #define SUN8I_H3_THS_INTC_ALARM_INT_EN0 BIT(0) +#define SUN8I_A83T_THS_INTC_ALARM_INT_EN1 BIT(1) +#define SUN8I_A83T_THS_INTC_ALARM_INT_EN2 BIT(2) #define SUN8I_H3_THS_INTC_SHUT_INT_EN0 BIT(4) +#define SUN8I_A83T_THS_INTC_SHUT_INT_EN1 BIT(5) +#define SUN8I_A83T_THS_INTC_SHUT_INT_EN2 BIT(6) #define SUN8I_H3_THS_INTC_TDATA_IRQ_EN0 BIT(8) +#define SUN8I_A83T_THS_INTC_TDATA_IRQ_EN1 BIT(9) +#define SUN8I_A83T_THS_INTC_TDATA_IRQ_EN2 BIT(10) #define MAX_SENSOR_COUNT 4