All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Eduardo Valentin <edubezval@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>,
	linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com
Subject: [PATCH 14/18] thermal: exynos: move trips setting to exynos_tmu_initialize()
Date: Thu, 26 Apr 2018 13:51:29 +0200	[thread overview]
Message-ID: <1524743493-28113-15-git-send-email-b.zolnierkie@samsung.com> (raw)
In-Reply-To: <1524743493-28113-1-git-send-email-b.zolnierkie@samsung.com>

* Add dummy exynos4210_tmu_set_trip_hyst() helper.

* Add ->tmu_set_trip_temp and ->tmu_set_trip_hyst methods to struct
  exynos_tmu_data and set them in exynos_map_dt_data().

* Move trips setting to exynos_tmu_initialize().

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 | 88 +++++++++++++++---------------------
 1 file changed, 37 insertions(+), 51 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 571511f..244aaf6 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -220,6 +220,10 @@ struct exynos_tmu_data {
 	unsigned int ntrip;
 	bool enabled;
 
+	void (*tmu_set_trip_temp)(struct exynos_tmu_data *data, int trip,
+				 u8 temp);
+	void (*tmu_set_trip_hyst)(struct exynos_tmu_data *data, int trip,
+				 u8 temp, u8 hyst);
 	void (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
 	int (*tmu_read)(struct exynos_tmu_data *data);
@@ -312,7 +316,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	const struct thermal_trip * const trips =
 		of_thermal_get_trip_points(tzd);
 	unsigned int status;
-	int ret = 0, temp;
+	int ret = 0, temp, hyst;
 
 	if (!trips) {
 		dev_err(&pdev->dev,
@@ -345,7 +349,24 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 	if (!status)
 		ret = -EBUSY;
 	else {
+		int i, ntrips =
+			min_t(int, of_thermal_get_ntrips(tzd), data->ntrip);
+
 		data->tmu_initialize(pdev);
+
+		/* Write temperature code for rising and falling threshold */
+		for (i = 0; i < ntrips; i++) {
+			/* Write temperature code for rising threshold */
+			tzd->ops->get_trip_temp(tzd, i, &temp);
+			temp /= MCELSIUS;
+			data->tmu_set_trip_temp(data, i, temp);
+
+			/* Write temperature code for falling threshold */
+			tzd->ops->get_trip_hyst(tzd, i, &hyst);
+			hyst /= MCELSIUS;
+			data->tmu_set_trip_hyst(data, i, temp, hyst);
+		}
+
 		data->tmu_clear_irqs(data);
 	}
 
@@ -405,19 +426,17 @@ static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data,
 	writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4);
 }
 
+/* failing thresholds are not supported on Exynos4210 */
+static void exynos4210_tmu_set_trip_hyst(struct exynos_tmu_data *data,
+					 int trip, u8 temp, u8 hyst)
+{
+}
+
 static void exynos4210_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct thermal_zone_device *tz = data->tzd;
-	int i, temp;
 
 	sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
-
-	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-		tz->ops->get_trip_temp(tz, i, &temp);
-		temp /= MCELSIUS;
-		exynos4210_tmu_set_trip_temp(data, i, temp);
-	}
 }
 
 static void exynos4412_tmu_set_trip_temp(struct exynos_tmu_data *data,
@@ -452,10 +471,7 @@ static void exynos4412_tmu_set_trip_hyst(struct exynos_tmu_data *data,
 static void exynos4412_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct thermal_zone_device *tz = data->tzd;
 	unsigned int trim_info, ctrl;
-	int i, ntrips = min_t(int, of_thermal_get_ntrips(tz), data->ntrip);
-	int temp, hyst;
 
 	if (data->soc == SOC_ARCH_EXYNOS3250 ||
 	    data->soc == SOC_ARCH_EXYNOS4412 ||
@@ -477,17 +493,6 @@ static void exynos4412_tmu_initialize(struct platform_device *pdev)
 		trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
 
 	sanitize_temp_error(data, trim_info);
-
-	/* Write temperature code for rising and falling threshold */
-	for (i = 0; i < ntrips; i++) {
-		tz->ops->get_trip_temp(tz, i, &temp);
-		temp /= MCELSIUS;
-		exynos4412_tmu_set_trip_temp(data, i, temp);
-
-		tz->ops->get_trip_hyst(tz, i, &hyst);
-		hyst /= MCELSIUS;
-		exynos4412_tmu_set_trip_hyst(data, i, temp, hyst);
-	}
 }
 
 static void exynos5433_tmu_set_trip_temp(struct exynos_tmu_data *data,
@@ -533,9 +538,8 @@ static void exynos5433_tmu_set_trip_hyst(struct exynos_tmu_data *data,
 static void exynos5433_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct thermal_zone_device *tz = data->tzd;
 	unsigned int trim_info;
-	int sensor_id, cal_type, i, temp, hyst;
+	int sensor_id, cal_type;
 
 	trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
 	sanitize_temp_error(data, trim_info);
@@ -562,19 +566,6 @@ static void exynos5433_tmu_initialize(struct platform_device *pdev)
 
 	dev_info(&pdev->dev, "Calibration type is %d-point calibration\n",
 			cal_type ?  2 : 1);
-
-	/* Write temperature code for rising and falling threshold */
-	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-		/* Write temperature code for rising threshold */
-		tz->ops->get_trip_temp(tz, i, &temp);
-		temp /= MCELSIUS;
-		exynos5433_tmu_set_trip_temp(data, i, temp);
-
-		/* Write temperature code for falling threshold */
-		tz->ops->get_trip_hyst(tz, i, &hyst);
-		hyst /= MCELSIUS;
-		exynos5433_tmu_set_trip_hyst(data, i, temp, hyst);
-	}
 }
 
 static void exynos7_tmu_set_trip_temp(struct exynos_tmu_data *data,
@@ -610,23 +601,10 @@ static void exynos7_tmu_set_trip_hyst(struct exynos_tmu_data *data,
 static void exynos7_tmu_initialize(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct thermal_zone_device *tz = data->tzd;
 	unsigned int trim_info;
-	int i, temp, hyst;
 
 	trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
 	sanitize_temp_error(data, trim_info);
-
-	/* Write temperature code for rising and falling threshold */
-	for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-		tz->ops->get_trip_temp(tz, i, &temp);
-		temp /= MCELSIUS;
-		exynos7_tmu_set_trip_temp(data, i, temp);
-
-		tz->ops->get_trip_hyst(tz, i, &hyst);
-		hyst /= MCELSIUS;
-		exynos7_tmu_set_trip_hyst(data, i, temp, hyst);
-	}
 }
 
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
@@ -989,6 +967,8 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
+		data->tmu_set_trip_temp = exynos4210_tmu_set_trip_temp;
+		data->tmu_set_trip_hyst = exynos4210_tmu_set_trip_hyst;
 		data->tmu_initialize = exynos4210_tmu_initialize;
 		data->tmu_control = exynos4210_tmu_control;
 		data->tmu_read = exynos4210_tmu_read;
@@ -1006,6 +986,8 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 	case SOC_ARCH_EXYNOS5260:
 	case SOC_ARCH_EXYNOS5420:
 	case SOC_ARCH_EXYNOS5420_TRIMINFO:
+		data->tmu_set_trip_temp = exynos4412_tmu_set_trip_temp;
+		data->tmu_set_trip_hyst = exynos4412_tmu_set_trip_hyst;
 		data->tmu_initialize = exynos4412_tmu_initialize;
 		data->tmu_control = exynos4210_tmu_control;
 		data->tmu_read = exynos4412_tmu_read;
@@ -1023,6 +1005,8 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		data->max_efuse_value = 100;
 		break;
 	case SOC_ARCH_EXYNOS5433:
+		data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp;
+		data->tmu_set_trip_hyst = exynos5433_tmu_set_trip_hyst;
 		data->tmu_initialize = exynos5433_tmu_initialize;
 		data->tmu_control = exynos5433_tmu_control;
 		data->tmu_read = exynos4412_tmu_read;
@@ -1039,6 +1023,8 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		data->max_efuse_value = 150;
 		break;
 	case SOC_ARCH_EXYNOS7:
+		data->tmu_set_trip_temp = exynos7_tmu_set_trip_temp;
+		data->tmu_set_trip_hyst = exynos7_tmu_set_trip_hyst;
 		data->tmu_initialize = exynos7_tmu_initialize;
 		data->tmu_control = exynos7_tmu_control;
 		data->tmu_read = exynos7_tmu_read;
-- 
1.9.1

  parent reply	other threads:[~2018-04-26 11:55 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
     [not found]   ` <CGME20180426115201epcas2p17e5cdb0f79927903880e58c290b663e6@epcas2p1.samsung.com>
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
     [not found]         ` <CGME20180430152141eucas1p2f39d7e8ee83a1fa66ccd19f74442357f@eucas1p2.samsung.com>
2018-04-30 15:21           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115204epcas2p3a0b53d8b2bdd687b1acc19db98f30227@epcas2p3.samsung.com>
2018-04-26 11:51     ` [PATCH 02/18] thermal: exynos: always check for trips points existence Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115206epcas1p2da6ae1d85708907dc99a97baf0791b4d@epcas1p2.samsung.com>
2018-04-26 11:51     ` [PATCH 03/18] thermal: exynos: always check for critical trip " Bartlomiej Zolnierkiewicz
2018-04-30 14:44       ` Daniel Lezcano
     [not found]         ` <CGME20180430152416eucas1p10bde2c1501e7f5f4b284caca3b630ea3@eucas1p1.samsung.com>
2018-04-30 15:24           ` Bartlomiej Zolnierkiewicz
2018-05-01  9:00             ` Daniel Lezcano
     [not found]               ` <CGME20180502091631eucas1p1e310f34a39383e01cfbf9eef992db260@eucas1p1.samsung.com>
2018-05-02  9:16                 ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115209epcas2p1af89ecf3180a396261af3b18f952877a@epcas2p1.samsung.com>
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
     [not found]   ` <CGME20180426115211epcas1p3db7cbe215a3dfb49567a771931574a2f@epcas1p3.samsung.com>
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
     [not found]   ` <CGME20180426115214epcas2p33003bbbe84310405c6871853f0df40e3@epcas2p3.samsung.com>
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
     [not found]         ` <CGME20180430154830eucas1p20a5d8e1d4d50c60f8072ce022b6afb1d@eucas1p2.samsung.com>
2018-04-30 15:48           ` Bartlomiej Zolnierkiewicz
2018-05-01  9:39             ` Daniel Lezcano
     [not found]               ` <CGME20180502091907eucas1p17017c6793fb49f0c90660b3042b803bb@eucas1p1.samsung.com>
2018-05-02  9:19                 ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115216epcas1p3ed61f0fd8563e7ea72f3d7d17c9c039f@epcas1p3.samsung.com>
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
     [not found]   ` <CGME20180426115219epcas2p48747814c37573e56473fe246955656fd@epcas2p4.samsung.com>
2018-04-26 11:51     ` [PATCH 08/18] thermal: exynos: make ->tmu_initialize method void Bartlomiej Zolnierkiewicz
2018-04-30 15:40       ` Daniel Lezcano
     [not found]   ` <CGME20180426115221epcas2p29faeae4b9bd5eb023e9696e2c33c01e9@epcas2p2.samsung.com>
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
     [not found]   ` <CGME20180426115224epcas1p3dde7044de7d11c7ec7a7411df1123552@epcas1p3.samsung.com>
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
     [not found]   ` <CGME20180426115226epcas1p2e902011524b5ef6e0b53c314b72f35e0@epcas1p2.samsung.com>
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
     [not found]         ` <CGME20180502093316eucas1p1e7e7b2f27eae677dde9882a4aedd2ed7@eucas1p1.samsung.com>
2018-05-02  9:33           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115229epcas1p42ebcc547531485a4f30284dd3be7e43a@epcas1p4.samsung.com>
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
     [not found]   ` <CGME20180426115231epcas2p3727de5409903e05811c2b5ed10ee0a51@epcas2p3.samsung.com>
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
     [not found]         ` <CGME20180502093709eucas1p177dd30efffed16e763fcad10686af159@eucas1p1.samsung.com>
2018-05-02  9:37           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115234epcas1p47cf54556fd061e8f90a4df4a2c62f7ce@epcas1p4.samsung.com>
2018-04-26 11:51     ` Bartlomiej Zolnierkiewicz [this message]
2018-05-01 10:31       ` [PATCH 14/18] thermal: exynos: move trips setting to exynos_tmu_initialize() Daniel Lezcano
     [not found]         ` <CGME20180502093921eucas1p1c1da14cc87d3e2c7f5550b961004521d@eucas1p1.samsung.com>
2018-05-02  9:39           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115236epcas2p3764927b3c23113fb4c3771b753a51199@epcas2p3.samsung.com>
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
     [not found]         ` <CGME20180502094143eucas1p282ea9e6519120d8eff473a7b3e1830ac@eucas1p2.samsung.com>
2018-05-02  9:41           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115239epcas2p2dc72353efa8375b7f70a41c570fba789@epcas2p2.samsung.com>
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
     [not found]         ` <CGME20180502100345eucas1p27280d10571f3e9d7c5b5a62a364dd439@eucas1p2.samsung.com>
2018-05-02 10:03           ` Bartlomiej Zolnierkiewicz
     [not found]             ` <CGME20180502110417eucas1p172aa0b68b5719dbebd2ed02baaf6a10a@eucas1p1.samsung.com>
2018-05-02 11:04               ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115241epcas1p4472048bd1647d9151718f573e6f1025a@epcas1p4.samsung.com>
2018-04-26 11:51     ` [PATCH 17/18] thermal: exynos: remove unused defines for Exynos5433 Bartlomiej Zolnierkiewicz
2018-05-01 11:11       ` Daniel Lezcano
     [not found]         ` <CGME20180502100530eucas1p180d0b51059ca8002ffe9440810391e9a@eucas1p1.samsung.com>
2018-05-02 10:05           ` Bartlomiej Zolnierkiewicz
     [not found]   ` <CGME20180426115244epcas2p36d0d44d1a0b2c3c4edff33187046caac@epcas2p3.samsung.com>
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=1524743493-28113-15-git-send-email-b.zolnierkie@samsung.com \
    --to=b.zolnierkie@samsung.com \
    --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 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.