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>,
	Amit Daniel Kachhap <amit.daniel@samsung.com>,
	Lukasz Majewski <l.majewski@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com
Subject: [PATCH v2 21/33] thermal: exynos: add ->tmu_read method
Date: Thu, 13 Nov 2014 16:01:16 +0100	[thread overview]
Message-ID: <1415890888-8881-22-git-send-email-b.zolnierkie@samsung.com> (raw)
In-Reply-To: <1415890888-8881-1-git-send-email-b.zolnierkie@samsung.com>

Add ->tmu_read method to struct exynos_tmu_data and use it
in exynos_tmu_control().  Then add ->tmu_read implementations
for Exynos4210, Exynos4412+ and Exynos5440.  Finally remove
no longer needed reg->tmu_cur_temp abstractions.

There should be no functional changes caused by this patch.

Cc: Amit Daniel Kachhap <amit.daniel@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c      | 45 +++++++++++++++++++------------
 drivers/thermal/samsung/exynos_tmu.h      |  2 --
 drivers/thermal/samsung/exynos_tmu_data.c |  6 -----
 3 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 938e8e63..b209593 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -54,6 +54,7 @@
  * @reg_conf: pointer to structure to register with core thermal.
  * @tmu_initialize: SoC specific TMU initialization method
  * @tmu_control: SoC specific TMU control method
+ * @tmu_read: SoC specific TMU temperature read method
  */
 struct exynos_tmu_data {
 	int id;
@@ -70,6 +71,7 @@ struct exynos_tmu_data {
 	struct thermal_sensor_conf *reg_conf;
 	int (*tmu_initialize)(struct platform_device *pdev);
 	void (*tmu_control)(struct platform_device *pdev, bool on);
+	int (*tmu_read)(struct exynos_tmu_data *data);
 };
 
 /*
@@ -422,29 +424,17 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
 
 static int exynos_tmu_read(struct exynos_tmu_data *data)
 {
-	struct exynos_tmu_platform_data *pdata = data->pdata;
-	const struct exynos_tmu_registers *reg = pdata->registers;
-	u8 temp_code;
-	int temp;
+	int ret;
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
-
-	temp_code = readb(data->base + reg->tmu_cur_temp);
-
-	if (data->soc == SOC_ARCH_EXYNOS4210)
-		/* temp_code should range between 75 and 175 */
-		if (temp_code < 75 || temp_code > 175) {
-			temp = -ENODATA;
-			goto out;
-		}
-
-	temp = code_to_temp(data, temp_code);
-out:
+	ret = data->tmu_read(data);
+	if (ret >= 0)
+		ret = code_to_temp(data, ret);
 	clk_disable(data->clk);
 	mutex_unlock(&data->lock);
 
-	return temp;
+	return ret;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -494,6 +484,24 @@ static int exynos_tmu_set_emulation(void *drv_data,	unsigned long temp)
 	{ return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
+static int exynos4210_tmu_read(struct exynos_tmu_data *data)
+{
+	int ret = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP);
+
+	/* "temp_code" should range between 75 and 175 */
+	return (ret < 75 || ret > 175) ? -ENODATA : ret;
+}
+
+static int exynos4412_tmu_read(struct exynos_tmu_data *data)
+{
+	return readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP);
+}
+
+static int exynos5440_tmu_read(struct exynos_tmu_data *data)
+{
+	return readb(data->base + EXYNOS5440_TMU_S0_7_TEMP);
+}
+
 static void exynos_tmu_work(struct work_struct *work)
 {
 	struct exynos_tmu_data *data = container_of(work,
@@ -718,6 +726,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	case SOC_ARCH_EXYNOS4210:
 		data->tmu_initialize = exynos4210_tmu_initialize;
 		data->tmu_control = exynos4210_tmu_control;
+		data->tmu_read = exynos4210_tmu_read;
 		break;
 	case SOC_ARCH_EXYNOS3250:
 	case SOC_ARCH_EXYNOS4412:
@@ -727,10 +736,12 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 	case SOC_ARCH_EXYNOS5420_TRIMINFO:
 		data->tmu_initialize = exynos4412_tmu_initialize;
 		data->tmu_control = exynos4210_tmu_control;
+		data->tmu_read = exynos4412_tmu_read;
 		break;
 	case SOC_ARCH_EXYNOS5440:
 		data->tmu_initialize = exynos5440_tmu_initialize;
 		data->tmu_control = exynos5440_tmu_control;
+		data->tmu_read = exynos5440_tmu_read;
 		break;
 	default:
 		ret = -EINVAL;
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 7496b54..9460e6e 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -70,13 +70,11 @@ enum soc_type {
 /**
  * struct exynos_tmu_register - register descriptors to access registers.
  * The register validity may vary slightly across different exynos SOC's.
- * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @tmu_intstat: Register containing the interrupt status values.
  * @tmu_intclear: Register for clearing the raised interrupt status.
  * @emul_con: TMU emulation controller register.
  */
 struct exynos_tmu_registers {
-	u32	tmu_cur_temp;
 	u32	tmu_intstat;
 	u32	tmu_intclear;
 	u32	emul_con;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 2bfd469..769b89d 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -26,7 +26,6 @@
 
 #if defined(CONFIG_CPU_EXYNOS4210)
 static const struct exynos_tmu_registers exynos4210_tmu_registers = {
-	.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
 	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 };
@@ -74,7 +73,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS3250)
 static const struct exynos_tmu_registers exynos3250_tmu_registers = {
-	.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
 	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 	.emul_con = EXYNOS_EMUL_CON,
@@ -135,7 +133,6 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 static const struct exynos_tmu_registers exynos4412_tmu_registers = {
-	.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
 	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 	.emul_con = EXYNOS_EMUL_CON,
@@ -208,7 +205,6 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS5260)
 static const struct exynos_tmu_registers exynos5260_tmu_registers = {
-	.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
 	.tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR,
 	.emul_con = EXYNOS5260_EMUL_CON,
@@ -271,7 +267,6 @@ struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS5420)
 static const struct exynos_tmu_registers exynos5420_tmu_registers = {
-	.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
 	.tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
 	.tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
 	.emul_con = EXYNOS_EMUL_CON,
@@ -340,7 +335,6 @@ struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS5440)
 static const struct exynos_tmu_registers exynos5440_tmu_registers = {
-	.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
 	.tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
 	.tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
 	.emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
-- 
1.8.2.3


  parent reply	other threads:[~2014-11-13 15:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-13 15:00 [PATCH v2 00/33] thermal: exynos: convert the driver to use per-SoC type operations Bartlomiej Zolnierkiewicz
2014-11-13 15:00 ` [PATCH v2 01/33] thermal: exynos: remove needless triminfo_data abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:00 ` [PATCH v2 02/33] thermal: exynos: remove needless tmu_status abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:00 ` [PATCH v2 03/33] thermal: exynos: remove needless threshold_temp abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:00 ` [PATCH v2 04/33] thermal: exynos: remove needless triminfo_ctrl abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 05/33] thermal: exynos: remove needless test_mux_addr_shift abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 06/33] thermal: exynos: remove needless therm_trip_[mode,mask]_shift abstractions Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 07/33] thermal: exynos: remove needless therm_trip_en_shift abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 08/33] thermal: exynos: remove needless emul_temp_shift abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 09/33] thermal: exynos: remove needless emul_time_shift abstraction Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 10/33] thermal: exynos: replace tmu_irqstatus check by Exynos5440 one Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 11/33] thermal: exynos: replace tmu_pmin " Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 12/33] thermal: exynos: simplify HW_TRIP level setting Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 13/33] thermal: exynos: replace threshold_falling check by Exynos SoC type one Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 14/33] thermal: exynos: remove TMU_SUPPORT_READY_STATUS flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 15/33] thermal: exynos: remove TMU_SUPPORT_TRIM_RELOAD flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 16/33] thermal: exynos: add sanitize_temp_error() helper Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 17/33] thermal: exynos: add get_th_reg() helper Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 18/33] thermal: exynos: add ->tmu_initialize method Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 19/33] thermal: exynos: add get_con_reg() helper Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 20/33] thermal: exynos: add ->tmu_control method Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` Bartlomiej Zolnierkiewicz [this message]
2014-11-13 15:01 ` [PATCH v2 22/33] thermal: exynos: add get_emul_con_reg() helper Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 23/33] thermal: exynos: add ->tmu_set_emulation method Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 24/33] thermal: exynos: add ->tmu_clear_irqs method Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 25/33] thermal: exynos: remove TMU_SUPPORT_FALLING_TRIP flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 26/33] thermal: exynos: remove TMU_SUPPORT_EMUL_TIME flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 27/33] thermal: exynos: remove TMU_SUPPORT_EMULATION flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 28/33] thermal: exynos: remove TMU_SUPPORT_ADDRESS_MULTIPLE flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 29/33] thermal: exynos: remove TMU_SUPPORT_MULTI_INST flag Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 30/33] thermal: exynos: remove test_mux pdata field Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 31/33] thermal: exynos: remove SoC type ifdefs Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 32/33] thermal: exynos: remove __EXYNOS5420_TMU_DATA macro Bartlomiej Zolnierkiewicz
2014-11-13 15:01 ` [PATCH v2 33/33] thermal: exynos: remove exynos_tmu_data.h include Bartlomiej Zolnierkiewicz
2014-11-15 18:47 ` [PATCH v2 00/33] thermal: exynos: convert the driver to use per-SoC type operations Eduardo Valentin
2014-11-20 11:58 ` Lukasz Majewski

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=1415890888-8881-22-git-send-email-b.zolnierkie@samsung.com \
    --to=b.zolnierkie@samsung.com \
    --cc=amit.daniel@samsung.com \
    --cc=edubezval@gmail.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.majewski@samsung.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.