Received: by 10.223.176.5 with SMTP id f5csp2661312wra; Mon, 29 Jan 2018 01:48:02 -0800 (PST) X-Google-Smtp-Source: AH8x224R+EMWC5eaRsbyY3U/0wkaXfy4e8eHaUpROs8TVIvctSmq7SfjPjME6T7i7hyw/k3t1kYJ X-Received: by 10.99.142.76 with SMTP id k73mr20986234pge.89.1517219282034; Mon, 29 Jan 2018 01:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517219282; cv=none; d=google.com; s=arc-20160816; b=t/kiFDYnrkXhilwWmzdrQiPeRu5F0bBfahmN+kgSmYyGDXjXyZpKA+ygOdstHGt5XL kIMwF77WeRkIDluXePAeYiTdcfzAoRW06LrdZBKspZj0WE4BVmo83YMkwGxZlGbnwyQ2 Akm+/tPTrap9ECAGizUSP2hTpm++Wcw7izTbkoHk06jjQ24gtGHlc0Hn290fHs2p8htc TTbCa+KikI8Ix7h/ngm4EbaPFWcrkYgie7TwwvlsEXbff0Zs/vtTOtuqPcyL+wHrlmBn NVxzKqwyI3tjgYvPpob90/NWci+ojJNWCYceJbqYiXxG5oCwuF5GkCE/1ojMFsKT2b86 3kLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=b3ih2CjTa5fKg/RYQCPx37ADj7jje3TXPtohgeb4xCA=; b=F0GetztOWhMoiv2X8vYnmOxyaA47sCIO1xZS8y0LZvkmY1FfmdYkaiVkiu3KZ/Sn6g nbtuswPZsplQp/yTRoZiAvpKDkU1/2Kvk7NZ0RS5JYh7FffkMkTw0lxSRD9MsB3uefjG Ywbw2o2pDRRcgNzCxXYOf2K2w/xBK52TIARZPvcM4MbAUqy7XrWX9Hf9Y0o4N6ZRR5m9 LozRaKGQ8evIShaoBHG1pYPK8Hk7d54ikso02yAwNeIlyL4fEpCFjaJ1MDnvk9w/3Cht 9H/QjmMVeZdFDRrplqipOQLKBItMyVrxBZ8sizZ8/HpUH+DVgR6IHKajxYtx+V8ic8Uk AhgQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si8883164plb.740.2018.01.29.01.47.47; Mon, 29 Jan 2018 01:48:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbeA2JrD (ORCPT + 99 others); Mon, 29 Jan 2018 04:47:03 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:58761 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbeA2JrC (ORCPT ); Mon, 29 Jan 2018 04:47:02 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5678421995; Mon, 29 Jan 2018 10:47:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 185A621992; Mon, 29 Jan 2018 10:46:50 +0100 (CET) Date: Mon, 29 Jan 2018 10:46:50 +0100 From: Maxime Ripard To: Philipp Rossak 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 Message-ID: <20180129094650.kpbhtbcpo42huadl@flea.lan> References: <20180128232919.12639-1-embed3d@gmail.com> <20180128232919.12639-10-embed3d@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gd24cx5qwqzi4jit" Content-Disposition: inline In-Reply-To: <20180128232919.12639-10-embed3d@gmail.com> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --gd24cx5qwqzi4jit Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 29, 2018 at 12:29:12AM +0100, Philipp Rossak wrote: > This patch adds support for the H3 ths sensor. >=20 > 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. >=20 > Signed-off-by: Philipp Rossak > --- > drivers/iio/adc/sun4i-gpadc-iio.c | 86 +++++++++++++++++++++++++++++++++= ++++++ > include/linux/mfd/sun4i-gpadc.h | 22 ++++++++++ > 2 files changed, 108 insertions(+) >=20 > diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gp= adc-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); > =20 > +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 = =3D { > .support_irq =3D false, > }; > =20 > +static const struct gpadc_data sun8i_h3_ths_data =3D { > + .temp_offset =3D -1791, > + .temp_scale =3D -121, > + .temp_data =3D {SUN8I_H3_THS_TDATA0, 0, 0, 0}, > + .sample_start =3D sunxi_ths_sample_start, > + .sample_end =3D sunxi_ths_sample_end, > + .has_bus_clk =3D true, > + .has_bus_rst =3D true, > + .has_mod_clk =3D true, > + .sensor_count =3D 1, > + .supports_nvmem =3D true, > + .support_irq =3D true, > + .ctrl0_map =3D SUN4I_GPADC_CTRL0_T_ACQ(0xff), > + .ctrl2_map =3D SUN8I_H3_THS_ACQ1(0x3f), > + .sensor_en_map =3D SUN8I_H3_THS_TEMP_SENSE_EN0, > + .filter_map =3D SUN4I_GPADC_CTRL3_FILTER_EN | > + SUN4I_GPADC_CTRL3_FILTER_TYPE(0x2), > + .irq_clear_map =3D 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 =3D 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; > } > =20 > +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 =3D 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); > } > =20 > +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 =3D 6MHz */ > @@ -492,6 +545,35 @@ static int sun4i_gpadc_sample_start(struct sun4i_gpa= dc_iio *info) > return 0; > } > =20 > +static int sunxi_ths_sample_start(struct sun4i_gpadc_iio *info) Please remain consistent with the prefixes used in the driver Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --gd24cx5qwqzi4jit Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE0VqZU19dR2zEVaqr0rTAlCFNr3QFAlpu7YkACgkQ0rTAlCFN r3TTZQ/9E9HtoW3omwSUySaUVMtzKl9cy+xoWn6jUQBjnbewDgs180WLnCm+sk+z iN0UPMxTJ8T02KF8p7cq9JdWqYZHWdE1L8IBFLdrG3OJGVLnhbO+lubQ/e0wj0Oa LuDoIqnu11rvVwS4yzpDHwwmkgAJfql7fgTweK3DYYKXAjaz6aLiBRXWMEJXvnHz 17yqtsydbdc++vu6PkcjHu6p3jK3HpKJtRShsNMomi+CCQ441/zMnEk1EuYJZ1XY 8ggQp5B5l33E5IpPdjQc3uGFUajVpAzO/k5ocWE/RZptMO5CfUXdG2EZxOSOHSv+ XRzc0NeWo8w0Tn1jU+vkhvsqMU6rdbFqqA7buhcwx1R0cog5wLVKf0kW/wNJ6vBT QYUvGuNn5HIjg6ZkyKfMxJ9Fkwkj54Fnr6VJDcwGTZoqLsWJnJKzdaiIyxJj7cA4 KpczFC99CFzsy5X0f2F/ppFQTRG79V1uJrfgZ1XwjoUOMs0OUJBGEMQ6z6ixMZLy GQQH7nlhRtKV9RNa1I/oIM4UGTxWRtvTT3N3cGJdAyNXsVkfSknJvfHwz6hk5Pxz rr6mJw2eFcB4i16bb5hxj7wO4bPdq3YGqoIfjQzBA6M+hFNfgAa2jmavy/LLyYMH U5tRZg7gipgEQ3hzi6Ybh6dTqwWqFuJ42m3vfbcKVFPzBaP3SKM= =JOI2 -----END PGP SIGNATURE----- --gd24cx5qwqzi4jit--