diff options
author | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2018-04-26 07:51:19 -0400 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2018-05-06 19:15:30 -0400 |
commit | 97b3881b8bc5f49a276b5265539f244bf507f42d (patch) | |
tree | c18593835e2ade419e4cac8a9ac09aa5a3a835b9 | |
parent | 8f1c404b212baec2f7cb46182a45067066aed131 (diff) |
thermal: exynos: check STATUS register in exynos_tmu_initialize()
STATUS register is present on all SoCs so move its checking into
exynos_tmu_initialize().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index a0c16044d20a..3b41666b2f13 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -331,6 +331,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) | |||
331 | struct thermal_zone_device *tzd = data->tzd; | 331 | struct thermal_zone_device *tzd = data->tzd; |
332 | const struct thermal_trip * const trips = | 332 | const struct thermal_trip * const trips = |
333 | of_thermal_get_trip_points(tzd); | 333 | of_thermal_get_trip_points(tzd); |
334 | unsigned int status; | ||
334 | int ret = 0, temp; | 335 | int ret = 0, temp; |
335 | 336 | ||
336 | if (!trips) { | 337 | if (!trips) { |
@@ -359,7 +360,13 @@ static int exynos_tmu_initialize(struct platform_device *pdev) | |||
359 | clk_enable(data->clk); | 360 | clk_enable(data->clk); |
360 | if (!IS_ERR(data->clk_sec)) | 361 | if (!IS_ERR(data->clk_sec)) |
361 | clk_enable(data->clk_sec); | 362 | clk_enable(data->clk_sec); |
362 | ret = data->tmu_initialize(pdev); | 363 | |
364 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); | ||
365 | if (!status) | ||
366 | ret = -EBUSY; | ||
367 | else | ||
368 | ret = data->tmu_initialize(pdev); | ||
369 | |||
363 | clk_disable(data->clk); | 370 | clk_disable(data->clk); |
364 | mutex_unlock(&data->lock); | 371 | mutex_unlock(&data->lock); |
365 | if (!IS_ERR(data->clk_sec)) | 372 | if (!IS_ERR(data->clk_sec)) |
@@ -406,13 +413,6 @@ static int exynos4210_tmu_initialize(struct platform_device *pdev) | |||
406 | of_thermal_get_trip_points(tz); | 413 | of_thermal_get_trip_points(tz); |
407 | int ret = 0, threshold_code, i; | 414 | int ret = 0, threshold_code, i; |
408 | unsigned long reference, temp; | 415 | unsigned long reference, temp; |
409 | unsigned int status; | ||
410 | |||
411 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); | ||
412 | if (!status) { | ||
413 | ret = -EBUSY; | ||
414 | goto out; | ||
415 | } | ||
416 | 416 | ||
417 | sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO)); | 417 | sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO)); |
418 | 418 | ||
@@ -441,16 +441,10 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev) | |||
441 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); | 441 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
442 | const struct thermal_trip * const trips = | 442 | const struct thermal_trip * const trips = |
443 | of_thermal_get_trip_points(data->tzd); | 443 | of_thermal_get_trip_points(data->tzd); |
444 | unsigned int status, trim_info, con, ctrl, rising_threshold; | 444 | unsigned int trim_info, con, ctrl, rising_threshold; |
445 | int ret = 0, threshold_code, i; | 445 | int ret = 0, threshold_code, i; |
446 | unsigned long crit_temp = 0; | 446 | unsigned long crit_temp = 0; |
447 | 447 | ||
448 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); | ||
449 | if (!status) { | ||
450 | ret = -EBUSY; | ||
451 | goto out; | ||
452 | } | ||
453 | |||
454 | if (data->soc == SOC_ARCH_EXYNOS3250 || | 448 | if (data->soc == SOC_ARCH_EXYNOS3250 || |
455 | data->soc == SOC_ARCH_EXYNOS4412 || | 449 | data->soc == SOC_ARCH_EXYNOS4412 || |
456 | data->soc == SOC_ARCH_EXYNOS5250) { | 450 | data->soc == SOC_ARCH_EXYNOS5250) { |
@@ -497,7 +491,6 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev) | |||
497 | con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT); | 491 | con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT); |
498 | writel(con, data->base + EXYNOS_TMU_REG_CONTROL); | 492 | writel(con, data->base + EXYNOS_TMU_REG_CONTROL); |
499 | 493 | ||
500 | out: | ||
501 | return ret; | 494 | return ret; |
502 | } | 495 | } |
503 | 496 | ||
@@ -505,17 +498,11 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev) | |||
505 | { | 498 | { |
506 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); | 499 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
507 | struct thermal_zone_device *tz = data->tzd; | 500 | struct thermal_zone_device *tz = data->tzd; |
508 | unsigned int status, trim_info; | 501 | unsigned int trim_info; |
509 | unsigned int rising_threshold = 0, falling_threshold = 0; | 502 | unsigned int rising_threshold = 0, falling_threshold = 0; |
510 | int temp, temp_hist; | 503 | int temp, temp_hist; |
511 | int ret = 0, threshold_code, i, sensor_id, cal_type; | 504 | int ret = 0, threshold_code, i, sensor_id, cal_type; |
512 | 505 | ||
513 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); | ||
514 | if (!status) { | ||
515 | ret = -EBUSY; | ||
516 | goto out; | ||
517 | } | ||
518 | |||
519 | trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); | 506 | trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); |
520 | sanitize_temp_error(data, trim_info); | 507 | sanitize_temp_error(data, trim_info); |
521 | 508 | ||
@@ -590,7 +577,7 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev) | |||
590 | } | 577 | } |
591 | 578 | ||
592 | data->tmu_clear_irqs(data); | 579 | data->tmu_clear_irqs(data); |
593 | out: | 580 | |
594 | return ret; | 581 | return ret; |
595 | } | 582 | } |
596 | 583 | ||
@@ -598,18 +585,12 @@ static int exynos7_tmu_initialize(struct platform_device *pdev) | |||
598 | { | 585 | { |
599 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); | 586 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
600 | struct thermal_zone_device *tz = data->tzd; | 587 | struct thermal_zone_device *tz = data->tzd; |
601 | unsigned int status, trim_info; | 588 | unsigned int trim_info; |
602 | unsigned int rising_threshold = 0, falling_threshold = 0; | 589 | unsigned int rising_threshold = 0, falling_threshold = 0; |
603 | int ret = 0, threshold_code, i; | 590 | int ret = 0, threshold_code, i; |
604 | int temp, temp_hist; | 591 | int temp, temp_hist; |
605 | unsigned int reg_off, bit_off; | 592 | unsigned int reg_off, bit_off; |
606 | 593 | ||
607 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); | ||
608 | if (!status) { | ||
609 | ret = -EBUSY; | ||
610 | goto out; | ||
611 | } | ||
612 | |||
613 | trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); | 594 | trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); |
614 | 595 | ||
615 | data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK; | 596 | data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK; |
@@ -667,7 +648,7 @@ static int exynos7_tmu_initialize(struct platform_device *pdev) | |||
667 | } | 648 | } |
668 | 649 | ||
669 | data->tmu_clear_irqs(data); | 650 | data->tmu_clear_irqs(data); |
670 | out: | 651 | |
671 | return ret; | 652 | return ret; |
672 | } | 653 | } |
673 | 654 | ||