From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Eduardo Valentin <edubezval@gmail.com>,
Zhang Rui <rui.zhang@intel.com>,
linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 16/18] thermal: exynos: cleanup code for enabling threshold interrupts
Date: Wed, 02 May 2018 13:04:16 +0200 [thread overview]
Message-ID: <3056898.TmvD5ep5ug@amdc3058> (raw)
In-Reply-To: <17338828.V5XOYeIB5l@amdc3058>
On Wednesday, May 02, 2018 12:03:44 PM Bartlomiej Zolnierkiewicz wrote:
> On Tuesday, May 01, 2018 01:02:39 PM Daniel Lezcano wrote:
> > On Thu, Apr 26, 2018 at 01:51:31PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > Cleanup code for enabling threshold interrupts in ->tmu_control
> > > method implementations.
> > >
> > > There should be no functional changes caused by this patch.
> > >
> > > Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > ---
> > > drivers/thermal/samsung/exynos_tmu.c | 101 ++++++++++++-----------------------
> > > 1 file changed, 34 insertions(+), 67 deletions(-)
> > >
> > > diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> > > index abe0737..9639acf 100644
> > > --- a/drivers/thermal/samsung/exynos_tmu.c
> > > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > > @@ -76,9 +76,6 @@
> > > #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
> > >
> > > #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
> > > -#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
> > > -#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8
> > > -#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12
> > > #define EXYNOS_TMU_INTEN_FALL0_SHIFT 16
> > >
> > > #define EXYNOS_EMUL_TIME 0x57F0
> > > @@ -136,13 +133,6 @@
> > > #define EXYNOS7_TMU_TEMP_MASK 0x1ff
> > > #define EXYNOS7_PD_DET_EN_SHIFT 23
> > > #define EXYNOS7_TMU_INTEN_RISE0_SHIFT 0
> > > -#define EXYNOS7_TMU_INTEN_RISE1_SHIFT 1
> > > -#define EXYNOS7_TMU_INTEN_RISE2_SHIFT 2
> > > -#define EXYNOS7_TMU_INTEN_RISE3_SHIFT 3
> > > -#define EXYNOS7_TMU_INTEN_RISE4_SHIFT 4
> > > -#define EXYNOS7_TMU_INTEN_RISE5_SHIFT 5
> > > -#define EXYNOS7_TMU_INTEN_RISE6_SHIFT 6
> > > -#define EXYNOS7_TMU_INTEN_RISE7_SHIFT 7
> > > #define EXYNOS7_EMUL_DATA_SHIFT 7
> > > #define EXYNOS7_EMUL_DATA_MASK 0x1ff
> > >
> > > @@ -615,29 +605,27 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
> > > {
> > > struct exynos_tmu_data *data = platform_get_drvdata(pdev);
> > > struct thermal_zone_device *tz = data->tzd;
> > > - unsigned int con, interrupt_en;
> > > + unsigned int con, interrupt_en = 0, i;
> > >
> > > con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
> > >
> > > if (on) {
> > > - con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
> > > - interrupt_en =
> > > - (of_thermal_is_trip_valid(tz, 3)
> > > - << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
> > > - (of_thermal_is_trip_valid(tz, 2)
> > > - << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
> > > - (of_thermal_is_trip_valid(tz, 1)
> > > - << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
> > > - (of_thermal_is_trip_valid(tz, 0)
> > > - << EXYNOS_TMU_INTEN_RISE0_SHIFT);
> > > + for (i = 0; i < data->ntrip; i++) {
> > > + if (!of_thermal_is_trip_valid(tz, i))
> > > + continue;
> > > +
> > > + interrupt_en |=
> > > + (1 << (EXYNOS_TMU_INTEN_RISE0_SHIFT + i * 4));
> > > + }
> >
> > As EXYNOS_TMU_INTEN_RISE0_SHIFT is equal to zero, may be you can replace this
> > by BITS(i * 4) ?
> >
> > Same comments for exynos5433 and exynos7 below.
>
> Good point, I will replace it by using BIT() macro.
From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: [PATCH] thermal: exynos: cleanup code for enabling threshold interrupts
Cleanup code for enabling threshold interrupts in ->tmu_control
method implementations.
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
drivers/thermal/samsung/exynos_tmu.c | 100 ++++++++++-------------------------
1 file changed, 31 insertions(+), 69 deletions(-)
Index: b/drivers/thermal/samsung/exynos_tmu.c
===================================================================
--- a/drivers/thermal/samsung/exynos_tmu.c 2018-05-02 12:25:14.393266604 +0200
+++ b/drivers/thermal/samsung/exynos_tmu.c 2018-05-02 12:28:23.545271367 +0200
@@ -75,10 +75,6 @@
#define EXYNOS_TMU_TRIP_MODE_MASK 0x7
#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
-#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
-#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
-#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8
-#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12
#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16
#define EXYNOS_EMUL_TIME 0x57F0
@@ -135,14 +131,6 @@
#define EXYNOS7_TMU_TEMP_MASK 0x1ff
#define EXYNOS7_PD_DET_EN_SHIFT 23
-#define EXYNOS7_TMU_INTEN_RISE0_SHIFT 0
-#define EXYNOS7_TMU_INTEN_RISE1_SHIFT 1
-#define EXYNOS7_TMU_INTEN_RISE2_SHIFT 2
-#define EXYNOS7_TMU_INTEN_RISE3_SHIFT 3
-#define EXYNOS7_TMU_INTEN_RISE4_SHIFT 4
-#define EXYNOS7_TMU_INTEN_RISE5_SHIFT 5
-#define EXYNOS7_TMU_INTEN_RISE6_SHIFT 6
-#define EXYNOS7_TMU_INTEN_RISE7_SHIFT 7
#define EXYNOS7_EMUL_DATA_SHIFT 7
#define EXYNOS7_EMUL_DATA_MASK 0x1ff
@@ -615,29 +603,26 @@ static void exynos4210_tmu_control(struc
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
- unsigned int con, interrupt_en;
+ unsigned int con, interrupt_en = 0, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
- con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
- interrupt_en =
- (of_thermal_is_trip_valid(tz, 3)
- << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
- (of_thermal_is_trip_valid(tz, 2)
- << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
- (of_thermal_is_trip_valid(tz, 1)
- << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
- (of_thermal_is_trip_valid(tz, 0)
- << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+ for (i = 0; i < data->ntrip; i++) {
+ if (!of_thermal_is_trip_valid(tz, i))
+ continue;
+
+ interrupt_en |= BIT(i * 4);
+ }
if (data->soc != SOC_ARCH_EXYNOS4210)
interrupt_en |=
interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
- } else {
+
+ con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+ } else
con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
- interrupt_en = 0; /* Disable all interrupts */
- }
+
writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN);
writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
}
@@ -646,36 +631,24 @@ static void exynos5433_tmu_control(struc
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
- unsigned int con, interrupt_en, pd_det_en;
+ unsigned int con, interrupt_en = 0, pd_det_en, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
- con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
- interrupt_en =
- (of_thermal_is_trip_valid(tz, 7)
- << EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
- (of_thermal_is_trip_valid(tz, 6)
- << EXYNOS7_TMU_INTEN_RISE6_SHIFT) |
- (of_thermal_is_trip_valid(tz, 5)
- << EXYNOS7_TMU_INTEN_RISE5_SHIFT) |
- (of_thermal_is_trip_valid(tz, 4)
- << EXYNOS7_TMU_INTEN_RISE4_SHIFT) |
- (of_thermal_is_trip_valid(tz, 3)
- << EXYNOS7_TMU_INTEN_RISE3_SHIFT) |
- (of_thermal_is_trip_valid(tz, 2)
- << EXYNOS7_TMU_INTEN_RISE2_SHIFT) |
- (of_thermal_is_trip_valid(tz, 1)
- << EXYNOS7_TMU_INTEN_RISE1_SHIFT) |
- (of_thermal_is_trip_valid(tz, 0)
- << EXYNOS7_TMU_INTEN_RISE0_SHIFT);
+ for (i = 0; i < data->ntrip; i++) {
+ if (!of_thermal_is_trip_valid(tz, i))
+ continue;
+
+ interrupt_en |= BIT(i);
+ }
interrupt_en |=
interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
- } else {
+
+ con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+ } else
con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
- interrupt_en = 0; /* Disable all interrupts */
- }
pd_det_en = on ? EXYNOS5433_PD_DET_EN : 0;
@@ -688,37 +661,26 @@ static void exynos7_tmu_control(struct p
{
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tzd;
- unsigned int con, interrupt_en;
+ unsigned int con, interrupt_en = 0, i;
con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
if (on) {
- con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
- con |= (1 << EXYNOS7_PD_DET_EN_SHIFT);
- interrupt_en =
- (of_thermal_is_trip_valid(tz, 7)
- << EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
- (of_thermal_is_trip_valid(tz, 6)
- << EXYNOS7_TMU_INTEN_RISE6_SHIFT) |
- (of_thermal_is_trip_valid(tz, 5)
- << EXYNOS7_TMU_INTEN_RISE5_SHIFT) |
- (of_thermal_is_trip_valid(tz, 4)
- << EXYNOS7_TMU_INTEN_RISE4_SHIFT) |
- (of_thermal_is_trip_valid(tz, 3)
- << EXYNOS7_TMU_INTEN_RISE3_SHIFT) |
- (of_thermal_is_trip_valid(tz, 2)
- << EXYNOS7_TMU_INTEN_RISE2_SHIFT) |
- (of_thermal_is_trip_valid(tz, 1)
- << EXYNOS7_TMU_INTEN_RISE1_SHIFT) |
- (of_thermal_is_trip_valid(tz, 0)
- << EXYNOS7_TMU_INTEN_RISE0_SHIFT);
+ for (i = 0; i < data->ntrip; i++) {
+ if (!of_thermal_is_trip_valid(tz, i))
+ continue;
+
+ interrupt_en |= BIT(i);
+ }
interrupt_en |=
interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
+
+ con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+ con |= (1 << EXYNOS7_PD_DET_EN_SHIFT);
} else {
con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
con &= ~(1 << EXYNOS7_PD_DET_EN_SHIFT);
- interrupt_en = 0; /* Disable all interrupts */
}
writel(interrupt_en, data->base + EXYNOS7_TMU_REG_INTEN);
next prev parent reply other threads:[~2018-05-02 11:04 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180426115159epcas2p3b8d995ba552b403b5052f74970fdef0f@epcas2p3.samsung.com>
2018-04-26 11:51 ` [PATCH 00/18] thermal: exynos: further fixes and cleanups Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 01/18] thermal: exynos: fix setting rising_threshold for Exynos5433 Bartlomiej Zolnierkiewicz
2018-04-30 14:36 ` Daniel Lezcano
2018-04-30 15:21 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 02/18] thermal: exynos: always check for trips points existence Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 03/18] thermal: exynos: always check for critical trip " Bartlomiej Zolnierkiewicz
2018-04-30 14:44 ` Daniel Lezcano
2018-04-30 15:24 ` Bartlomiej Zolnierkiewicz
2018-05-01 9:00 ` Daniel Lezcano
2018-05-02 9:16 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 04/18] thermal: exynos: check STATUS register in exynos_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-04-30 15:23 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 05/18] thermal: exynos: use sanitize_temp_error() in exynos7_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-04-30 15:30 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 06/18] thermal: exynos: fix trips limit checking in get_th_reg() Bartlomiej Zolnierkiewicz
2018-04-30 15:34 ` Daniel Lezcano
2018-04-30 15:48 ` Bartlomiej Zolnierkiewicz
2018-05-01 9:39 ` Daniel Lezcano
2018-05-02 9:19 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 07/18] thermal: exynos: remove threshold_code checking from exynos4210_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-04-30 15:37 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 08/18] thermal: exynos: make ->tmu_initialize method void Bartlomiej Zolnierkiewicz
2018-04-30 15:40 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 09/18] thermal: exynos: clear IRQs later in exynos4412_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-04-30 14:47 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 10/18] thermal: exynos: move IRQs clearing to exynos_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-04-30 14:47 ` Daniel Lezcano
2018-05-06 23:27 ` Eduardo Valentin
2018-04-26 11:51 ` [PATCH 11/18] thermal: exynos: add exynos*_tmu_set_[trip,hyst]() helpers Bartlomiej Zolnierkiewicz
2018-05-01 9:55 ` Daniel Lezcano
2018-05-02 9:33 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 12/18] thermal: exynos: do not use trips structure directly in ->tmu_initialize Bartlomiej Zolnierkiewicz
2018-05-01 9:59 ` Daniel Lezcano
2018-04-26 11:51 ` [PATCH 13/18] thermal: exynos: set trips in ascending order in exynos7_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-05-01 10:02 ` Daniel Lezcano
2018-05-02 9:37 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 14/18] thermal: exynos: move trips setting to exynos_tmu_initialize() Bartlomiej Zolnierkiewicz
2018-05-01 10:31 ` Daniel Lezcano
2018-05-02 9:39 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 15/18] thermal: exynos: check return values of ->get_trip_[temp,hyst] methods Bartlomiej Zolnierkiewicz
2018-05-01 10:43 ` Daniel Lezcano
2018-05-02 9:41 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 16/18] thermal: exynos: cleanup code for enabling threshold interrupts Bartlomiej Zolnierkiewicz
2018-05-01 11:02 ` Daniel Lezcano
2018-05-02 10:03 ` Bartlomiej Zolnierkiewicz
2018-05-02 11:04 ` Bartlomiej Zolnierkiewicz [this message]
2018-04-26 11:51 ` [PATCH 17/18] thermal: exynos: remove unused defines for Exynos5433 Bartlomiej Zolnierkiewicz
2018-05-01 11:11 ` Daniel Lezcano
2018-05-02 10:05 ` Bartlomiej Zolnierkiewicz
2018-04-26 11:51 ` [PATCH 18/18] thermal: exynos: remove trip reporting to user-space Bartlomiej Zolnierkiewicz
2018-05-01 11:12 ` Daniel Lezcano
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=3056898.TmvD5ep5ug@amdc3058 \
--to=b.zolnierkie@samsung.com \
--cc=daniel.lezcano@linaro.org \
--cc=edubezval@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=rui.zhang@intel.com \
/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