blob: 774a0baa006006760875a3629c4268d3294a3de0 [file] [log] [blame]
/*
* exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit)
*
* Copyright (C) 2011 Samsung Electronics
* Donggeun Kim <dg77.kim@samsung.com>
* Amit Daniel Kachhap <amit.daniel@samsung.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _EXYNOS_TMU_H
#define _EXYNOS_TMU_H
#include <linux/cpu_cooling.h>
#include <linux/gpu_cooling.h>
#include <linux/isp_cooling.h>
#include <dt-bindings/thermal/thermal_exynos.h>
#define NR_HOTPLUG_CPUS 4
#define MCELSIUS 1000
enum soc_type {
SOC_ARCH_EXYNOS8890 = 1,
SOC_ARCH_EXYNOS8895 = 2,
SOC_ARCH_EXYNOS7872,
SOC_ARCH_EXYNOS9810,
SOC_ARCH_EXYNOS9610,
};
/**
* struct exynos_tmu_platform_data
* @gain: gain of amplifier in the positive-TC generator block
* 0 < gain <= 15
* @reference_voltage: reference voltage of amplifier
* in the positive-TC generator block
* 0 < reference_voltage <= 31
* @noise_cancel_mode: noise cancellation mode
* 000, 100, 101, 110 and 111 can be different modes
* @type: determines the type of SOC
* @efuse_value: platform defined fuse value
* @default_temp_offset: default temperature offset in case of no trimming
* @cal_type: calibration type for temperature
*
* This structure is required for configuration of exynos_tmu driver.
*/
struct exynos_tmu_platform_data {
u8 gain;
u8 reference_voltage;
u8 noise_cancel_mode;
u32 efuse_value;
u8 first_point_trim;
u8 second_point_trim;
u8 default_temp_offset;
u32 trip_temp;
enum soc_type type;
u32 sensor_type;
u32 cal_type;
};
enum sensing_type {
AVG = 0,
MAX,
MIN,
BALANCE,
END_OF_TYPE,
};
static const char * const sensing_method[] = {
[AVG] = "avg",
[MAX] = "max",
[MIN] = "min",
[BALANCE] = "balance",
};
struct sensor_info {
u16 sensor_num;
u16 cal_type;
u16 temp_error1;
u16 temp_error2;
};
/**
* struct exynos_tmu_data : A structure to hold the private data of the TMU
driver
* @id: identifier of the one instance of the TMU controller.
* @pdata: pointer to the tmu platform/configuration data
* @base: base address of the single instance of the TMU controller.
* @base_second: base address of the common registers of the TMU controller.
* @irq: irq number of the TMU controller.
* @soc: id of the SOC type.
* @irq_work: pointer to the irq work structure.
* @lock: lock to implement synchronization.
* @temp_error1: fused value of the first point trim.
* @temp_error2: fused value of the second point trim.
* @num_probe: number of probe for TMU_CONTROL1 SFR setting.
* @regulator: pointer to the TMU regulator structure.
* @reg_conf: pointer to structure to register with core thermal.
* @ntrip: number of supported trip points.
* @tmu_initialize: SoC specific TMU initialization method
* @tmu_control: SoC specific TMU control method
* @tmu_read: SoC specific TMU temperature read method
* @tmu_set_emulation: SoC specific TMU emulation setting method
* @tmu_clear_irqs: SoC specific TMU interrupts clearing method
*/
struct exynos_tmu_data {
int id;
/* Throttle hotplug related variables */
bool hotplug_enable;
int hotplug_in_threshold;
int hotplug_out_threshold;
int limited_frequency;
int limited_threshold;
int limited_threshold_release;
struct exynos_tmu_platform_data *pdata;
void __iomem *base;
int irq;
enum soc_type soc;
struct work_struct irq_work;
struct mutex lock;
u16 temp_error1, temp_error2;
struct thermal_zone_device *tzd;
unsigned int ntrip;
bool enabled;
struct thermal_cooling_device *cool_dev;
struct list_head node;
u32 sensors;
int num_probe;
int num_of_sensors;
struct sensor_info *sensor_info;
int sensing_mode;
char tmu_name[THERMAL_NAME_LENGTH + 1];
struct device_node *np;
int balance_offset;
struct mutex hotplug_lock;
ktime_t last_thermal_status_updated;
ktime_t thermal_status[3];
int (*tmu_initialize)(struct platform_device *pdev);
void (*tmu_control)(struct platform_device *pdev, bool on);
int (*tmu_read)(struct exynos_tmu_data *data);
void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp);
void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
};
#endif /* _EXYNOS_TMU_H */