Received: by 10.223.176.5 with SMTP id f5csp2364811wra; Sun, 28 Jan 2018 18:58:12 -0800 (PST) X-Google-Smtp-Source: AH8x224V9yazknBkb1d9kIXOiGWUPP/RXzc8d2bYUlDIuF7yfjypWusBtxwlI9hkG5GvKJ++9Gxc X-Received: by 2002:a17:902:c81:: with SMTP id 1-v6mr20588267plt.281.1517194691945; Sun, 28 Jan 2018 18:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517194691; cv=none; d=google.com; s=arc-20160816; b=RlfE+53m6aKssGmGCWi2l3ZwmuzeK+uDCGs70RtSBqPQj37uM7sf/3+7vT8Rjz/zar ADNewUUJLnstIpmi/chy0cjdlomsx5eX7W9u70YoqQI4SXnfWc2hsKQOufrLTXoqc361 zHLtD+cHfONZidpZpfw65nMMLPhuBm3lvhUsPZqHKSxT81swNYBrshbyjfAfd8nCouNG MnzT55AexlaxSzk2N3WAskVP66JvGAP2xY16viNz1a2YmyH0yj3BuY07czWiNzWhvWtY MPRHPgnzivga4R7uwYWsHdN3YQ72lFcOQSkAOg7HVPBwjOFhy5pXnyHVZA+CdcEiC6Xt no6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CAPy7u17iUOHgD8slI9hKL0MITYV+3t+MDJoEnq2T5o=; b=dhw63ZjnwoAw8b2eZ0AeFrPxCRs0CgfjkwGuP/Uka/0O7l71OPTvdXa2t8d2wDYeMl 4Adfq4YLpurb6V6ltNMEUyKttMmjqAbZvsLfk4ZEVWKRgNWp3O6VmXV1WNFBcgcmNx6n mgRfzurP+kX3W0WgX88n/UpQ7EZ0qku+NFauATeZho3STSLDsi8lGlq29+74rZvEzfQb 7/NiSRShGmqNaFC5Tz/U8BlUZ9hxj6Ur9bH7YGbmURT5foQYBkYfGzzt1ZfYzbQ9l1hk rnvQd6vfVUAXSN3ZlNJpiQcgtaNeYj2VKS3SarxXb/+HGnMdotZNnxpccVQexoNBLRWX AVlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l3ANpQLf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c41-v6si8177321plj.258.2018.01.28.18.57.57; Sun, 28 Jan 2018 18:58:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l3ANpQLf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435AbeA1Xbf (ORCPT + 99 others); Sun, 28 Jan 2018 18:31:35 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37150 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753351AbeA1X3m (ORCPT ); Sun, 28 Jan 2018 18:29:42 -0500 Received: by mail-wm0-f67.google.com with SMTP id v71so30464180wmv.2; Sun, 28 Jan 2018 15:29:41 -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=cmY9LqMQRK0cChsyHSv/iFTsmSWtoUiZBt4mAWlK2pc98XA+aJ4yATw7dvLUu0JGAh +GLHF6iSvxdPIjKpIp3Cb7EA2qriIh9mrwK3AzZ7IlYKynWH5JVdAGbNqbt4jOvtrr77 5q/6ZMm0IO+RjmOlyRuvjskTxddr3v1JkOtsDJEZWje4Zs6BW0n4nIHELr0fDZg3tdB+ iLDhW+0Ehfh5vcI4HzPSssWDen1kVLS4+TU6CVNSW80NyT+jnHkYbIP9sJYwF6CxZIJo Bg4l8PzLmEluTXsHU6opfGJmsOsUHwibjclQewfW2t6dFRIzc5eDhEQt64arGIrjwBAt HbeQ== X-Gm-Message-State: AKwxytdNDWb4aby8oAH6mkbcuoYawV8Y5iXA+dhk0qpWnAMHG2e2FnR8 BuH2jA3ocllE9SeczawFDys= 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.11.0