From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Philipp Rossak <embed3d@gmail.com>
Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.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,
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: Re: [PATCH v2 09/16] iio: adc: sun4i-gpadc-iio: add support for H3 thermal sensor
Date: Mon, 29 Jan 2018 10:46:50 +0100 [thread overview]
Message-ID: <20180129094650.kpbhtbcpo42huadl@flea.lan> (raw)
In-Reply-To: <20180128232919.12639-10-embed3d@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4176 bytes --]
On Mon, Jan 29, 2018 at 12:29:12AM +0100, Philipp Rossak wrote:
> 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 <embed3d@gmail.com>
> ---
> drivers/iio/adc/sun4i-gpadc-iio.c | 86 +++++++++++++++++++++++++++++++++++++++
> include/linux/mfd/sun4i-gpadc.h | 22 ++++++++++
> 2 files changed, 108 insertions(+)
>
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index b7b5451226b0..8196203d65fe 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -61,6 +61,9 @@ struct sun4i_gpadc_iio;
> static int sun4i_gpadc_sample_start(struct sun4i_gpadc_iio *info);
> static int sun4i_gpadc_sample_end(struct sun4i_gpadc_iio *info);
>
> +static int sunxi_ths_sample_start(struct sun4i_gpadc_iio *info);
> +static int sunxi_ths_sample_end(struct sun4i_gpadc_iio *info);
> +
> struct gpadc_data {
> int temp_offset;
> int temp_scale;
> @@ -71,6 +74,10 @@ struct gpadc_data {
> unsigned int temp_data[MAX_SENSOR_COUNT];
> int (*sample_start)(struct sun4i_gpadc_iio *info);
> int (*sample_end)(struct sun4i_gpadc_iio *info);
> + u32 ctrl0_map;
> + u32 ctrl2_map;
> + u32 sensor_en_map;
> + u32 filter_map;
You can use a regmap_field for that.
> u32 irq_clear_map;
> u32 irq_control_map;
> bool has_bus_clk;
> @@ -138,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 = {SUN8I_H3_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 = SUN4I_GPADC_CTRL0_T_ACQ(0xff),
> + .ctrl2_map = SUN8I_H3_THS_ACQ1(0x3f),
> + .sensor_en_map = SUN8I_H3_THS_TEMP_SENSE_EN0,
> + .filter_map = SUN4I_GPADC_CTRL3_FILTER_EN |
> + SUN4I_GPADC_CTRL3_FILTER_TYPE(0x2),
> + .irq_clear_map = SUN8I_H3_THS_INTS_ALARM_INT_0 |
> + SUN8I_H3_THS_INTS_SHUT_INT_0 |
> + SUN8I_H3_THS_INTS_TDATA_IRQ_0 |
> + SUN8I_H3_THS_INTS_ALARM_OFF_0,
> + .irq_control_map = SUN8I_H3_THS_INTC_TDATA_IRQ_EN0 |
> + SUN8I_H3_THS_TEMP_PERIOD(0x7),
> +};
> +
> struct sun4i_gpadc_iio {
> struct iio_dev *indio_dev;
> struct completion completion;
> @@ -462,6 +494,16 @@ static int sun4i_gpadc_sample_end(struct sun4i_gpadc_iio *info)
> return 0;
> }
>
> +static int sunxi_ths_sample_end(struct sun4i_gpadc_iio *info)
> +{
> + /* Disable ths interrupt */
> + regmap_write(info->regmap, SUN8I_H3_THS_INTC, 0x0);
> + /* Disable temperature sensor */
> + regmap_write(info->regmap, SUN8I_H3_THS_CTRL2, 0x0);
> +
> + return 0;
> +}
> +
> static int sun4i_gpadc_runtime_suspend(struct device *dev)
> {
> struct sun4i_gpadc_iio *info = iio_priv(dev_get_drvdata(dev));
> @@ -473,6 +515,17 @@ static int sun4i_gpadc_runtime_suspend(struct device *dev)
> return info->data->sample_end(info);
> }
>
> +static void sunxi_calibrate(struct sun4i_gpadc_iio *info)
> +{
> + if (info->has_calibration_data[0])
> + regmap_write(info->regmap, SUNXI_THS_CDATA_0_1,
> + info->calibration_data[0]);
> +
> + if (info->has_calibration_data[1])
> + regmap_write(info->regmap, SUNXI_THS_CDATA_2_3,
> + info->calibration_data[1]);
> +}
> +
> static int sun4i_gpadc_sample_start(struct sun4i_gpadc_iio *info)
> {
> /* clkin = 6MHz */
> @@ -492,6 +545,35 @@ static int sun4i_gpadc_sample_start(struct sun4i_gpadc_iio *info)
> return 0;
> }
>
> +static int sunxi_ths_sample_start(struct sun4i_gpadc_iio *info)
Please remain consistent with the prefixes used in the driver
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2018-01-29 9:47 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-28 23:29 [PATCH v2 00/16] IIO-based thermal sensor driver for Allwinner H3 and A83T SoC Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 01/16] dt-bindings: update the Allwinner GPADC device tree binding for H3 & A83T Philipp Rossak
2018-01-29 9:19 ` Maxime Ripard
2018-01-29 12:30 ` Philipp Rossak
2018-01-31 17:40 ` Quentin Schulz
2018-01-31 18:14 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 02/16] arm: config: sunxi_defconfig: enable SUN4I_GPADC Philipp Rossak
2018-01-29 9:21 ` Maxime Ripard
2018-01-28 23:29 ` [PATCH v2 03/16] iio: adc: sun4i-gpadc-iio: rename A33-specified registers to contain A33 Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 04/16] iio: adc: sun4i-gpadc-iio: rework: sampling start/end code readout reg Philipp Rossak
2018-01-29 9:27 ` Maxime Ripard
2018-01-31 17:51 ` Quentin Schulz
2018-01-31 18:35 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 05/16] iio: adc: sun4i-gpadc-iio: rework: support clocks and reset Philipp Rossak
2018-01-29 9:31 ` Maxime Ripard
2018-01-28 23:29 ` [PATCH v2 06/16] iio: adc: sun4i-gpadc-iio: rework: support multiple sensors Philipp Rossak
2018-01-29 9:37 ` Maxime Ripard
2018-01-31 18:42 ` Quentin Schulz
2018-02-02 14:13 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 07/16] iio: adc: sun4i-gpadc-iio: rework: support nvmem calibration data Philipp Rossak
2018-01-29 9:40 ` Maxime Ripard
2018-01-29 12:33 ` Philipp Rossak
2018-01-30 8:36 ` Maxime Ripard
2018-02-02 15:24 ` Philipp Rossak
2018-01-31 22:49 ` kbuild test robot
2018-01-28 23:29 ` [PATCH v2 08/16] iio: adc: sun4i-gpadc-iio: rework: add interrupt support Philipp Rossak
2018-01-31 19:07 ` Quentin Schulz
2018-02-02 14:30 ` Philipp Rossak
2018-01-31 21:47 ` kbuild test robot
2018-01-28 23:29 ` [PATCH v2 09/16] iio: adc: sun4i-gpadc-iio: add support for H3 thermal sensor Philipp Rossak
2018-01-29 9:46 ` Maxime Ripard [this message]
2018-01-31 19:23 ` Quentin Schulz
2018-02-02 14:42 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 10/16] iio: adc: sun4i-gpadc-iio: add support for A83T " Philipp Rossak
2018-01-29 9:48 ` Maxime Ripard
2018-01-29 11:53 ` Philipp Rossak
2018-01-30 8:32 ` Maxime Ripard
2018-01-28 23:29 ` [PATCH v2 11/16] arm: dts: sunxi-h3-h5: add support for the thermal sensor in H3 and H5 Philipp Rossak
2018-01-29 9:49 ` Maxime Ripard
2018-01-29 11:54 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 12/16] arm: dts: sun8i: h3: add support for the thermal sensor in H3 Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 13/16] arm: dts: sun8i: h3: add thermal zone to H3 Philipp Rossak
2018-01-29 9:50 ` Maxime Ripard
2018-01-29 11:56 ` Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 14/16] arm: dts: sun8i: h3: enable H3 sid controller Philipp Rossak
2018-01-29 9:52 ` Maxime Ripard
2018-01-29 12:03 ` Philipp Rossak
2018-04-19 15:11 ` [linux-sunxi] " Kyle Evans
2018-04-19 15:13 ` Icenowy Zheng
2018-04-19 15:19 ` Kyle Evans
2018-04-20 9:35 ` Philipp Rossak
2018-07-24 17:19 ` Paul Kocialkowski
2018-07-25 9:05 ` Emmanuel Vadot
2018-07-25 9:12 ` Paul Kocialkowski
2018-01-28 23:29 ` [PATCH v2 15/16] arm: dts: sun8i: a83t: add support for the thermal sensor in A83T Philipp Rossak
2018-01-28 23:29 ` [PATCH v2 16/16] arm: dts: sun8i: a83t: add thermal zone to A83T Philipp Rossak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180129094650.kpbhtbcpo42huadl@flea.lan \
--to=maxime.ripard@free-electrons.com \
--cc=clabbe.montjoie@gmail.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edu.molinas@gmail.com \
--cc=embed3d@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=icenowy@aosc.io \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=krzk@kernel.org \
--cc=lars@metafoo.de \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mchehab@kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=quentin.schulz@free-electrons.com \
--cc=rask@formelder.dk \
--cc=robh+dt@kernel.org \
--cc=sean@mess.org \
--cc=singhalsimran0@gmail.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®