From: Jonathan Cameron <jic23@kernel.org> To: Yangtao Li <tiny.windzz@gmail.com> Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH 6/7] iio: adc: sun4i-gpadc-iio: add support for H6 thermal sensor Date: Sun, 5 May 2019 16:25:46 +0100 [thread overview] Message-ID: <20190505162546.634bae93@archlinux> (raw) In-Reply-To: <20190503072813.2719-7-tiny.windzz@gmail.com> On Fri, 3 May 2019 03:28:12 -0400 Yangtao Li <tiny.windzz@gmail.com> wrote: > This patch adds support for the H6 ths sensor. > > TODO: calibrate thermal sensor by using information from sid. > > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> This and the patches before it that I haven't comment on look fine to me. thanks, Jonathan > --- > drivers/iio/adc/sun4i-gpadc-iio.c | 65 +++++++++++++++++++++++++++++++ > include/linux/mfd/sun4i-gpadc.h | 9 +++++ > 2 files changed, 74 insertions(+) > > diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c > index f24eb76d65c0..9b6fc592f54c 100644 > --- a/drivers/iio/adc/sun4i-gpadc-iio.c > +++ b/drivers/iio/adc/sun4i-gpadc-iio.c > @@ -120,6 +120,20 @@ static const struct gpadc_data sun8i_a33_gpadc_data = { > .temp_data_base = SUN4I_GPADC_TEMP_DATA, > }; > > +static int sun50i_gpadc_disable(struct sun4i_gpadc_iio *info); > +static int sun50i_gpadc_enable(struct sun4i_gpadc_iio *info); > + > +static const struct gpadc_data sun50i_h6_gpadc_data = { > + .temp_offset = -2809, > + .temp_scale = -67, > + .has_bus_clk = true, > + .has_bus_rst = true, > + .gpadc_enable = sun50i_gpadc_enable, > + .gpadc_disable = sun50i_gpadc_disable, > + .sensor_count = 2, > + .temp_data_base = SUN50I_H6_GPADC_TEMP_DATA, > +}; > + > struct sun4i_sensor_tzd { > struct sun4i_gpadc_iio *info; > struct thermal_zone_device *tzd; > @@ -452,6 +466,53 @@ static int sun4i_gpadc_enable(struct sun4i_gpadc_iio *info) > return 0; > } > > +static int sun50i_gpadc_enable(struct sun4i_gpadc_iio *info) > +{ > + int ret, val; > + > + ret = reset_control_deassert(info->reset); > + if (ret) > + return ret; > + > + ret = clk_prepare_enable(info->bus_clk); > + if (ret) > + goto assert_reset; > + > + /* > + * clkin = 24MHz > + * T acquire = clkin / (SUN50I_GPADC_CTRL0_T_ACQ + 1) > + * = 20us > + */ > + regmap_write(info->regmap, SUN4I_GPADC_CTRL0, > + SUN50I_GPADC_CTRL0_T_ACQ(479)); > + /* average over 4 samples */ > + regmap_write(info->regmap, SUN50I_H6_GPADC_CTRL3, > + SUN4I_GPADC_CTRL3_FILTER_EN | > + SUN4I_GPADC_CTRL3_FILTER_TYPE(1)); > + /* period = (SUN50I_GPADC_TPR_TEMP_PERIOD + 1) * 4096 / clkin; ~10ms */ > + regmap_write(info->regmap, SUN50I_GPADC_TPR, > + SUN50I_GPADC_TPR_TEMP_PERIOD(58)); > + /* TODO: calibrate ths */ > + /* enable sensor */ > + val = GENMASK(info->data->sensor_count - 1, 0); > + regmap_write(info->regmap, SUN4I_GPADC_CTRL1, val); > + > + return 0; > + > +assert_reset: > + reset_control_assert(info->reset); > + > + return ret; > +} > + > +static int sun50i_gpadc_disable(struct sun4i_gpadc_iio *info) > +{ > + clk_disable_unprepare(info->bus_clk); > + reset_control_assert(info->reset); > + > + return 0; > +} > + > static int sun4i_gpadc_runtime_suspend(struct device *dev) > { > struct sun4i_gpadc_iio *info = iio_priv(dev_get_drvdata(dev)); > @@ -546,6 +607,10 @@ static const struct of_device_id sun4i_gpadc_of_id[] = { > .compatible = "allwinner,sun8i-a33-ths", > .data = &sun8i_a33_gpadc_data, > }, > + { > + .compatible = "allwinner,sun50i-h6-ths", > + .data = &sun50i_h6_gpadc_data, > + }, > { /* sentinel */ } > }; > > diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h > index 139872c2e0fe..f505013e9c0d 100644 > --- a/include/linux/mfd/sun4i-gpadc.h > +++ b/include/linux/mfd/sun4i-gpadc.h > @@ -19,6 +19,9 @@ > #define SUN4I_GPADC_CTRL0_FS_DIV(x) ((GENMASK(3, 0) & (x)) << 16) > #define SUN4I_GPADC_CTRL0_T_ACQ(x) (GENMASK(15, 0) & (x)) > > +/* TP_CTRL0 bits for sun50i SOCs */ > +#define SUN50I_GPADC_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16) > + > #define SUN4I_GPADC_CTRL1 0x04 > > #define SUN4I_GPADC_CTRL1_STYLUS_UP_DEBOUNCE(x) ((GENMASK(7, 0) & (x)) << 12) > @@ -49,6 +52,9 @@ > #define SUN4I_GPADC_CTRL2_PRE_MEA_EN BIT(24) > #define SUN4I_GPADC_CTRL2_PRE_MEA_THRE_CNT(x) (GENMASK(23, 0) & (x)) > > +#define SUN50I_GPADC_TPR 0x08 > +#define SUN50I_GPADC_TPR_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) > + > #define SUN4I_GPADC_CTRL3 0x0c > > #define SUN4I_GPADC_CTRL3_FILTER_EN BIT(2) > @@ -84,6 +90,9 @@ > #define SUN4I_GPADC_TEMP_DATA 0x20 > #define SUN4I_GPADC_DATA 0x24 > > +#define SUN50I_H6_GPADC_CTRL3 0x30 > +#define SUN50I_H6_GPADC_TEMP_DATA 0xc0 > + > #define SUN4I_GPADC_IRQ_FIFO_DATA 0 > #define SUN4I_GPADC_IRQ_TEMP_DATA 1 >
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org> To: Yangtao Li <tiny.windzz@gmail.com> Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, lars@metafoo.de, maxime.ripard@bootlin.com, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, wens@csie.org, robh+dt@kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/7] iio: adc: sun4i-gpadc-iio: add support for H6 thermal sensor Date: Sun, 5 May 2019 16:25:46 +0100 [thread overview] Message-ID: <20190505162546.634bae93@archlinux> (raw) In-Reply-To: <20190503072813.2719-7-tiny.windzz@gmail.com> On Fri, 3 May 2019 03:28:12 -0400 Yangtao Li <tiny.windzz@gmail.com> wrote: > This patch adds support for the H6 ths sensor. > > TODO: calibrate thermal sensor by using information from sid. > > Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> This and the patches before it that I haven't comment on look fine to me. thanks, Jonathan > --- > drivers/iio/adc/sun4i-gpadc-iio.c | 65 +++++++++++++++++++++++++++++++ > include/linux/mfd/sun4i-gpadc.h | 9 +++++ > 2 files changed, 74 insertions(+) > > diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c > index f24eb76d65c0..9b6fc592f54c 100644 > --- a/drivers/iio/adc/sun4i-gpadc-iio.c > +++ b/drivers/iio/adc/sun4i-gpadc-iio.c > @@ -120,6 +120,20 @@ static const struct gpadc_data sun8i_a33_gpadc_data = { > .temp_data_base = SUN4I_GPADC_TEMP_DATA, > }; > > +static int sun50i_gpadc_disable(struct sun4i_gpadc_iio *info); > +static int sun50i_gpadc_enable(struct sun4i_gpadc_iio *info); > + > +static const struct gpadc_data sun50i_h6_gpadc_data = { > + .temp_offset = -2809, > + .temp_scale = -67, > + .has_bus_clk = true, > + .has_bus_rst = true, > + .gpadc_enable = sun50i_gpadc_enable, > + .gpadc_disable = sun50i_gpadc_disable, > + .sensor_count = 2, > + .temp_data_base = SUN50I_H6_GPADC_TEMP_DATA, > +}; > + > struct sun4i_sensor_tzd { > struct sun4i_gpadc_iio *info; > struct thermal_zone_device *tzd; > @@ -452,6 +466,53 @@ static int sun4i_gpadc_enable(struct sun4i_gpadc_iio *info) > return 0; > } > > +static int sun50i_gpadc_enable(struct sun4i_gpadc_iio *info) > +{ > + int ret, val; > + > + ret = reset_control_deassert(info->reset); > + if (ret) > + return ret; > + > + ret = clk_prepare_enable(info->bus_clk); > + if (ret) > + goto assert_reset; > + > + /* > + * clkin = 24MHz > + * T acquire = clkin / (SUN50I_GPADC_CTRL0_T_ACQ + 1) > + * = 20us > + */ > + regmap_write(info->regmap, SUN4I_GPADC_CTRL0, > + SUN50I_GPADC_CTRL0_T_ACQ(479)); > + /* average over 4 samples */ > + regmap_write(info->regmap, SUN50I_H6_GPADC_CTRL3, > + SUN4I_GPADC_CTRL3_FILTER_EN | > + SUN4I_GPADC_CTRL3_FILTER_TYPE(1)); > + /* period = (SUN50I_GPADC_TPR_TEMP_PERIOD + 1) * 4096 / clkin; ~10ms */ > + regmap_write(info->regmap, SUN50I_GPADC_TPR, > + SUN50I_GPADC_TPR_TEMP_PERIOD(58)); > + /* TODO: calibrate ths */ > + /* enable sensor */ > + val = GENMASK(info->data->sensor_count - 1, 0); > + regmap_write(info->regmap, SUN4I_GPADC_CTRL1, val); > + > + return 0; > + > +assert_reset: > + reset_control_assert(info->reset); > + > + return ret; > +} > + > +static int sun50i_gpadc_disable(struct sun4i_gpadc_iio *info) > +{ > + clk_disable_unprepare(info->bus_clk); > + reset_control_assert(info->reset); > + > + return 0; > +} > + > static int sun4i_gpadc_runtime_suspend(struct device *dev) > { > struct sun4i_gpadc_iio *info = iio_priv(dev_get_drvdata(dev)); > @@ -546,6 +607,10 @@ static const struct of_device_id sun4i_gpadc_of_id[] = { > .compatible = "allwinner,sun8i-a33-ths", > .data = &sun8i_a33_gpadc_data, > }, > + { > + .compatible = "allwinner,sun50i-h6-ths", > + .data = &sun50i_h6_gpadc_data, > + }, > { /* sentinel */ } > }; > > diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h > index 139872c2e0fe..f505013e9c0d 100644 > --- a/include/linux/mfd/sun4i-gpadc.h > +++ b/include/linux/mfd/sun4i-gpadc.h > @@ -19,6 +19,9 @@ > #define SUN4I_GPADC_CTRL0_FS_DIV(x) ((GENMASK(3, 0) & (x)) << 16) > #define SUN4I_GPADC_CTRL0_T_ACQ(x) (GENMASK(15, 0) & (x)) > > +/* TP_CTRL0 bits for sun50i SOCs */ > +#define SUN50I_GPADC_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16) > + > #define SUN4I_GPADC_CTRL1 0x04 > > #define SUN4I_GPADC_CTRL1_STYLUS_UP_DEBOUNCE(x) ((GENMASK(7, 0) & (x)) << 12) > @@ -49,6 +52,9 @@ > #define SUN4I_GPADC_CTRL2_PRE_MEA_EN BIT(24) > #define SUN4I_GPADC_CTRL2_PRE_MEA_THRE_CNT(x) (GENMASK(23, 0) & (x)) > > +#define SUN50I_GPADC_TPR 0x08 > +#define SUN50I_GPADC_TPR_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) > + > #define SUN4I_GPADC_CTRL3 0x0c > > #define SUN4I_GPADC_CTRL3_FILTER_EN BIT(2) > @@ -84,6 +90,9 @@ > #define SUN4I_GPADC_TEMP_DATA 0x20 > #define SUN4I_GPADC_DATA 0x24 > > +#define SUN50I_H6_GPADC_CTRL3 0x30 > +#define SUN50I_H6_GPADC_TEMP_DATA 0xc0 > + > #define SUN4I_GPADC_IRQ_FIFO_DATA 0 > #define SUN4I_GPADC_IRQ_TEMP_DATA 1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-05-05 15:25 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-03 7:28 [PATCH 0/7] Add support for H6 thermal sensor Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-03 7:28 ` [PATCH 1/7] iio: adc: sun4i-gpadc: rework for support multiple " Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-05 15:22 ` Jonathan Cameron 2019-05-05 15:22 ` Jonathan Cameron 2019-05-05 15:22 ` Jonathan Cameron 2019-05-06 12:28 ` Maxime Ripard 2019-05-06 12:28 ` Maxime Ripard 2019-05-06 16:52 ` Icenowy Zheng 2019-05-06 16:52 ` Icenowy Zheng 2019-05-06 17:08 ` Frank Lee 2019-05-06 17:08 ` Frank Lee 2019-05-06 17:55 ` Ondřej Jirman 2019-05-06 17:55 ` Ondřej Jirman 2019-05-07 13:59 ` Maxime Ripard 2019-05-07 13:59 ` Maxime Ripard 2019-05-03 7:28 ` [PATCH 2/7] iio: adc: sun4i-gpadc: introduce temp_data in gpadc_data Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-03 7:28 ` [PATCH 3/7] iio: adc: sun4i-gpadc: introduce gpadc_enable and gpadc_disable " Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-03 7:28 ` [PATCH 4/7] iio: adc: sun4i-gpadc-iio: support clocks and reset Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-03 7:28 ` [PATCH 5/7] dt-bindings: mfd: Add H6 GPADC binding Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-08 11:44 ` Lee Jones 2019-05-08 11:44 ` Lee Jones 2019-05-03 7:28 ` [PATCH 6/7] iio: adc: sun4i-gpadc-iio: add support for H6 thermal sensor Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-05 15:25 ` Jonathan Cameron [this message] 2019-05-05 15:25 ` Jonathan Cameron 2019-05-08 11:45 ` Lee Jones 2019-05-08 11:45 ` Lee Jones 2019-05-03 7:28 ` [PATCH 7/7] iio: adc: sun4i-gpadc-iio convert to SPDX license tags Yangtao Li 2019-05-03 7:28 ` Yangtao Li 2019-05-03 9:18 ` Maxime Ripard 2019-05-03 9:18 ` Maxime Ripard
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=20190505162546.634bae93@archlinux \ --to=jic23@kernel.org \ --cc=devicetree@vger.kernel.org \ --cc=knaack.h@gmx.de \ --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=mark.rutland@arm.com \ --cc=maxime.ripard@bootlin.com \ --cc=pmeerw@pmeerw.net \ --cc=robh+dt@kernel.org \ --cc=tiny.windzz@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.