From patchwork Fri Jan 26 15:19:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rossak X-Patchwork-Id: 10186333 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 AB31260383 for ; Fri, 26 Jan 2018 15:22:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A91D29C19 for ; Fri, 26 Jan 2018 15:22:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F29C29C2E; Fri, 26 Jan 2018 15:22:30 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D08429C19 for ; Fri, 26 Jan 2018 15:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652AbeAZPWO (ORCPT ); Fri, 26 Jan 2018 10:22:14 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:43538 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751973AbeAZPUD (ORCPT ); Fri, 26 Jan 2018 10:20:03 -0500 Received: by mail-wr0-f194.google.com with SMTP id t16so821773wrc.10; Fri, 26 Jan 2018 07:20:02 -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=Mcd5C6tnxoFMS+Vhq9KA90lnvQHuRUYvvt3saAoocUQ=; b=iIACbIMn0tKmIBru4ndKd+Gw9/hYmfcRIBGe+QkR6LncWVQoD8RZBFJ72VL3zVhr8T yLw4cRenodkyFI40hkr55gx0TLLkl7OWWEXU1jyNQQaWIJGdFXuHIKuRwAUhMrlc08AS NfKoTatHfFPGZavSZZCjhMouGTbhZR/ydHR+zQmADynpAuqWZc0/6uowOv9a4J4ag0cZ exVwP01AI31W0OCIQ/MFgtObMI1aWfxFYm0DWDJ7xWQ5M4+BIgiFL9QGNHBH2o7n84a8 fkqGCr6wad7xooUy+lgmPgc1gdPekmhhUS3AKbbotBbKoPB3hi93q94oaq2IpLoo5ubz +SVQ== 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=Mcd5C6tnxoFMS+Vhq9KA90lnvQHuRUYvvt3saAoocUQ=; b=FdZ9TUVsDntIOOrbjkQ//6wdFHPO7u9cAlNgjZkbJrJsjwnK1U+GAGboip/TzKaceM AFFDJhhhCsQXekAUwc4SJk7/syOCytFmHu8EOSBGJPZSjzf7TgozevLVQWgLB10WiI5D BIU3Not3kh/w6GXDjAcQZgO7OIUMaTbB723NCI0V6TS+anej3xpAu5C0ZMk2MBkloHLp WnI6gDfkv1magGOPeA2tg8drLcq+CSMTWBtUGKO5CtaSgrsqLm5wruazmCJt7vYqmOY9 5G3bBC8TEGlzLxKUuiwSte8izn9Da9TbIg4ISfx28CI06qzkgoDj/rpgC1I6G4+F3lj2 cvkQ== X-Gm-Message-State: AKwxytfUl75JQi66PKNoxjR7BcBd/37aRcAm/qgro02Jy2jJHWY59jMo xxcK8Etguq/lCHLT/Cej5uo= X-Google-Smtp-Source: AH8x226OHxnjPDukjUiEUjnoOaYqDvk1Oi1Ly4ZMDxw9GRlsENJ9w9bRVj3yh1ZeQ1cVQOFsXZWEEQ== X-Received: by 10.223.164.146 with SMTP id g18mr11376801wrb.241.1516980001599; Fri, 26 Jan 2018 07:20:01 -0800 (PST) Received: from debian-laptop.fritz.box (p578F04D2.dip0.t-ipconnect.de. [87.143.4.210]) by smtp.gmail.com with ESMTPSA id e15sm4586130wmd.26.2018.01.26.07.19.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 07:20:01 -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 Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH 09/16] iio: adc: sun4i-gpadc-iio: add support for H3 thermal sensor Date: Fri, 26 Jan 2018 16:19:34 +0100 Message-Id: <20180126151941.12183-10-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180126151941.12183-1-embed3d@gmail.com> References: <20180126151941.12183-1-embed3d@gmail.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the H3 ths sensor. The H3 supports interrupts. The interrupt is configured to update the the sensor values every second. The calibration data is writen at the begin of the init process. Signed-off-by: Philipp Rossak --- drivers/iio/adc/sun4i-gpadc-iio.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 77e07f042730..f2e0ec65c53e 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -145,6 +145,31 @@ static const struct gpadc_data sun8i_a33_gpadc_data = { .support_irq = false, }; +static const struct gpadc_data sun8i_h3_ths_data = { + .temp_offset = -1791, + .temp_scale = -121, + .temp_data = {SUNXI_THS_TDATA0, 0, 0, 0}, + .sample_start = sunxi_ths_sample_start, + .sample_end = sunxi_ths_sample_end, + .has_bus_clk = true, + .has_bus_rst = true, + .has_mod_clk = true, + .sensor_count = 1, + .supports_nvmem = true, + .support_irq = true, + .ctrl0_map = SUNXI_THS_ACQ0(0xff), + .ctrl2_map = SUNXI_THS_ACQ1(0x3f), + .sensor_en_map = SUNXI_THS_TEMP_SENSE_EN0, + .filter_map = SUNXI_THS_FILTER_EN | + SUNXI_THS_FILTER_TYPE(0x2), + .irq_clear_map = SUNXI_THS_INTS_ALARM_INT_0 | + SUNXI_THS_INTS_SHUT_INT_0 | + SUNXI_THS_INTS_TDATA_IRQ_0 | + SUNXI_THS_INTS_ALARM_OFF_0, + .irq_control_map = SUNXI_THS_INTC_TDATA_IRQ_EN0 | + SUNXI_THS_TEMP_PERIOD(0x7), +}; + struct sun4i_gpadc_iio { struct iio_dev *indio_dev; struct completion completion; @@ -643,6 +668,10 @@ static const struct of_device_id sun4i_gpadc_of_id[] = { .compatible = "allwinner,sun8i-a33-ths", .data = &sun8i_a33_gpadc_data, }, + { + .compatible = "allwinner,sun8i-h3-ths", + .data = &sun8i_h3_ths_data, + }, { /* sentinel */ } };