exynos_tmu.c (1928457ea6337043a06ca2acd9b4d01e75810a3f) exynos_tmu.c (498d22f616f6880531b6d75630a9cc0ecd1f7865)
1/*
2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
3 *
4 * Copyright (C) 2011 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com>
6 * Amit Daniel Kachhap <amit.kachhap@linaro.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 15 unchanged lines hidden (view full) ---

24#include <linux/clk.h>
25#include <linux/io.h>
26#include <linux/interrupt.h>
27#include <linux/module.h>
28#include <linux/of.h>
29#include <linux/of_address.h>
30#include <linux/of_irq.h>
31#include <linux/platform_device.h>
1/*
2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
3 *
4 * Copyright (C) 2011 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com>
6 * Amit Daniel Kachhap <amit.kachhap@linaro.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 15 unchanged lines hidden (view full) ---

24#include <linux/clk.h>
25#include <linux/io.h>
26#include <linux/interrupt.h>
27#include <linux/module.h>
28#include <linux/of.h>
29#include <linux/of_address.h>
30#include <linux/of_irq.h>
31#include <linux/platform_device.h>
32#include <linux/regulator/consumer.h>
32
33#include "exynos_thermal_common.h"
34#include "exynos_tmu.h"
35#include "exynos_tmu_data.h"
36
37/**
38 * struct exynos_tmu_data : A structure to hold the private data of the TMU
39 driver
40 * @id: identifier of the one instance of the TMU controller.
41 * @pdata: pointer to the tmu platform/configuration data
42 * @base: base address of the single instance of the TMU controller.
43 * @base_common: base address of the common registers of the TMU controller.
44 * @irq: irq number of the TMU controller.
45 * @soc: id of the SOC type.
46 * @irq_work: pointer to the irq work structure.
47 * @lock: lock to implement synchronization.
48 * @clk: pointer to the clock structure.
49 * @temp_error1: fused value of the first point trim.
50 * @temp_error2: fused value of the second point trim.
33
34#include "exynos_thermal_common.h"
35#include "exynos_tmu.h"
36#include "exynos_tmu_data.h"
37
38/**
39 * struct exynos_tmu_data : A structure to hold the private data of the TMU
40 driver
41 * @id: identifier of the one instance of the TMU controller.
42 * @pdata: pointer to the tmu platform/configuration data
43 * @base: base address of the single instance of the TMU controller.
44 * @base_common: base address of the common registers of the TMU controller.
45 * @irq: irq number of the TMU controller.
46 * @soc: id of the SOC type.
47 * @irq_work: pointer to the irq work structure.
48 * @lock: lock to implement synchronization.
49 * @clk: pointer to the clock structure.
50 * @temp_error1: fused value of the first point trim.
51 * @temp_error2: fused value of the second point trim.
52 * @regulator: pointer to the TMU regulator structure.
51 * @reg_conf: pointer to structure to register with core thermal.
52 */
53struct exynos_tmu_data {
54 int id;
55 struct exynos_tmu_platform_data *pdata;
56 void __iomem *base;
57 void __iomem *base_common;
58 int irq;
59 enum soc_type soc;
60 struct work_struct irq_work;
61 struct mutex lock;
62 struct clk *clk;
63 u8 temp_error1, temp_error2;
53 * @reg_conf: pointer to structure to register with core thermal.
54 */
55struct exynos_tmu_data {
56 int id;
57 struct exynos_tmu_platform_data *pdata;
58 void __iomem *base;
59 void __iomem *base_common;
60 int irq;
61 enum soc_type soc;
62 struct work_struct irq_work;
63 struct mutex lock;
64 struct clk *clk;
65 u8 temp_error1, temp_error2;
66 struct regulator *regulator;
64 struct thermal_sensor_conf *reg_conf;
65};
66
67/*
68 * TMU treats temperature as a mapped temperature code.
69 * The temperature is converted differently depending on the calibration type.
70 */
71static int temp_to_code(struct exynos_tmu_data *data, u8 temp)

--- 450 unchanged lines hidden (view full) ---

522 return NULL;
523}
524
525static int exynos_map_dt_data(struct platform_device *pdev)
526{
527 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
528 struct exynos_tmu_platform_data *pdata;
529 struct resource res;
67 struct thermal_sensor_conf *reg_conf;
68};
69
70/*
71 * TMU treats temperature as a mapped temperature code.
72 * The temperature is converted differently depending on the calibration type.
73 */
74static int temp_to_code(struct exynos_tmu_data *data, u8 temp)

--- 450 unchanged lines hidden (view full) ---

525 return NULL;
526}
527
528static int exynos_map_dt_data(struct platform_device *pdev)
529{
530 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
531 struct exynos_tmu_platform_data *pdata;
532 struct resource res;
533 int ret;
530
531 if (!data)
532 return -ENODEV;
533
534
535 if (!data)
536 return -ENODEV;
537
538 /*
539 * Try enabling the regulator if found
540 * TODO: Add regulator as an SOC feature, so that regulator enable
541 * is a compulsory call.
542 */
543 data->regulator = devm_regulator_get(&pdev->dev, "vtmu");
544 if (!IS_ERR(data->regulator)) {
545 ret = regulator_enable(data->regulator);
546 if (ret) {
547 dev_err(&pdev->dev, "failed to enable vtmu\n");
548 return ret;
549 }
550 } else {
551 dev_info(&pdev->dev, "Regulator node (vtmu) not found\n");
552 }
553
534 data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
535 if (data->id < 0)
536 data->id = 0;
537
538 data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
539 if (data->irq <= 0) {
540 dev_err(&pdev->dev, "failed to get IRQ\n");
541 return -ENODEV;

--- 151 unchanged lines hidden (view full) ---

693 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
694
695 exynos_tmu_control(pdev, false);
696
697 exynos_unregister_thermal(data->reg_conf);
698
699 clk_unprepare(data->clk);
700
554 data->id = of_alias_get_id(pdev->dev.of_node, "tmuctrl");
555 if (data->id < 0)
556 data->id = 0;
557
558 data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
559 if (data->irq <= 0) {
560 dev_err(&pdev->dev, "failed to get IRQ\n");
561 return -ENODEV;

--- 151 unchanged lines hidden (view full) ---

713 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
714
715 exynos_tmu_control(pdev, false);
716
717 exynos_unregister_thermal(data->reg_conf);
718
719 clk_unprepare(data->clk);
720
721 if (!IS_ERR(data->regulator))
722 regulator_disable(data->regulator);
723
701 return 0;
702}
703
704#ifdef CONFIG_PM_SLEEP
705static int exynos_tmu_suspend(struct device *dev)
706{
707 exynos_tmu_control(to_platform_device(dev), false);
708

--- 37 unchanged lines hidden ---
724 return 0;
725}
726
727#ifdef CONFIG_PM_SLEEP
728static int exynos_tmu_suspend(struct device *dev)
729{
730 exynos_tmu_control(to_platform_device(dev), false);
731

--- 37 unchanged lines hidden ---