Commit 30072fb9 authored by Zhang Rui's avatar Zhang Rui

Merge branches 'for-rc' and 'ti-soc' of .git into next

......@@ -57,4 +57,17 @@ bandgap {
0x4a002380 0x2c
0x4a0023C0 0x3c>;
compatible = "ti,omap5430-bandgap";
interrupts = <0 126 4>; /* talert */
};
DRA752:
bandgap {
reg = <0x4a0021e0 0xc
0x4a00232c 0xc
0x4a002380 0x2c
0x4a0023C0 0x3c
0x4a002564 0x8
0x4a002574 0x50>;
compatible = "ti,dra752-bandgap";
interrupts = <0 126 4>; /* talert */
};
......@@ -167,7 +167,7 @@ static int get_property(unsigned int cpu, unsigned long input,
continue;
/* get the frequency order */
if (freq != CPUFREQ_ENTRY_INVALID && descend != -1)
if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
descend = !!(freq > table[i].frequency);
freq = table[i].frequency;
......
......@@ -156,7 +156,8 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip)
{
enum thermal_trend trend;
if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend)) {
if (tz->emul_temperature || !tz->ops->get_trend ||
tz->ops->get_trend(tz, trip, &trend)) {
if (tz->temperature > tz->last_temperature)
trend = THERMAL_TREND_RAISING;
else if (tz->temperature < tz->last_temperature)
......
......@@ -46,3 +46,15 @@ config OMAP5_THERMAL
This includes alert interrupts generation and also the TSHUT
support.
config DRA752_THERMAL
bool "Texas Instruments DRA752 thermal support"
depends on TI_SOC_THERMAL
depends on SOC_DRA7XX
help
If you say yes here you get thermal support for the Texas Instruments
DRA752 SoC family. The current chip supported are:
- DRA752
This includes alert interrupts generation and also the TSHUT
support.
obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal.o
ti-soc-thermal-y := ti-bandgap.o
ti-soc-thermal-$(CONFIG_TI_THERMAL) += ti-thermal-common.o
ti-soc-thermal-$(CONFIG_DRA752_THERMAL) += dra752-thermal-data.o
ti-soc-thermal-$(CONFIG_OMAP4_THERMAL) += omap4-thermal-data.o
ti-soc-thermal-$(CONFIG_OMAP5_THERMAL) += omap5-thermal-data.o
This diff is collapsed.
This diff is collapsed.
......@@ -469,7 +469,7 @@ static inline int ti_bandgap_validate(struct ti_bandgap *bgp, int id)
{
int ret = 0;
if (IS_ERR_OR_NULL(bgp)) {
if (!bgp || IS_ERR(bgp)) {
pr_err("%s: invalid bandgap pointer\n", __func__);
ret = -EINVAL;
goto exit;
......@@ -992,9 +992,12 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend)
goto exit;
}
spin_lock(&bgp->lock);
tsr = bgp->conf->sensors[id].registers;
/* Freeze and read the last 2 valid readings */
RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 1);
reg1 = tsr->ctrl_dtemp_1;
reg2 = tsr->ctrl_dtemp_2;
......@@ -1008,22 +1011,25 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend)
/* Convert from adc values to mCelsius temperature */
ret = ti_bandgap_adc_to_mcelsius(bgp, temp1, &t1);
if (ret)
goto exit;
goto unfreeze;
ret = ti_bandgap_adc_to_mcelsius(bgp, temp2, &t2);
if (ret)
goto exit;
goto unfreeze;
/* Fetch the update interval */
ret = ti_bandgap_read_update_interval(bgp, id, &interval);
if (ret || !interval)
goto exit;
goto unfreeze;
*trend = (t1 - t2) / interval;
dev_dbg(bgp->dev, "The temperatures are t1 = %d and t2 = %d and trend =%d\n",
t1, t2, *trend);
unfreeze:
RMW_BITS(bgp, id, bgap_mask_ctrl, mask_freeze_mask, 0);
spin_unlock(&bgp->lock);
exit:
return ret;
}
......@@ -1191,7 +1197,7 @@ int ti_bandgap_probe(struct platform_device *pdev)
int clk_rate, ret = 0, i;
bgp = ti_bandgap_build(pdev);
if (IS_ERR_OR_NULL(bgp)) {
if (IS_ERR(bgp)) {
dev_err(&pdev->dev, "failed to fetch platform data\n");
return PTR_ERR(bgp);
}
......@@ -1207,17 +1213,19 @@ int ti_bandgap_probe(struct platform_device *pdev)
}
bgp->fclock = clk_get(NULL, bgp->conf->fclock_name);
ret = IS_ERR_OR_NULL(bgp->fclock);
ret = IS_ERR(bgp->fclock);
if (ret) {
dev_err(&pdev->dev, "failed to request fclock reference\n");
ret = PTR_ERR(bgp->fclock);
goto free_irqs;
}
bgp->div_clk = clk_get(NULL, bgp->conf->div_ck_name);
ret = IS_ERR_OR_NULL(bgp->div_clk);
ret = IS_ERR(bgp->div_clk);
if (ret) {
dev_err(&pdev->dev,
"failed to request div_ts_ck clock ref\n");
ret = PTR_ERR(bgp->div_clk);
goto free_irqs;
}
......@@ -1522,6 +1530,12 @@ static const struct of_device_id of_ti_bandgap_match[] = {
.compatible = "ti,omap5430-bandgap",
.data = (void *)&omap5430_data,
},
#endif
#ifdef CONFIG_DRA752_THERMAL
{
.compatible = "ti,dra752-bandgap",
.data = (void *)&dra752_data,
},
#endif
/* Sentinel */
{ },
......
......@@ -400,4 +400,9 @@ extern const struct ti_bandgap_data omap5430_data;
#define omap5430_data NULL
#endif
#ifdef CONFIG_DRA752_THERMAL
extern const struct ti_bandgap_data dra752_data;
#else
#define dra752_data NULL
#endif
#endif
......@@ -38,6 +38,7 @@
/* common data structures */
struct ti_thermal_data {
struct thermal_zone_device *ti_thermal;
struct thermal_zone_device *pcb_tz;
struct thermal_cooling_device *cool_dev;
struct ti_bandgap *bgp;
enum thermal_device_mode mode;
......@@ -77,10 +78,12 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
{
struct thermal_zone_device *pcb_tz = NULL;
struct ti_thermal_data *data = thermal->devdata;
struct ti_bandgap *bgp;
const struct ti_temp_sensor *s;
int ret, tmp, pcb_temp, slope, constant;
int ret, tmp, slope, constant;
unsigned long pcb_temp;
if (!data)
return 0;
......@@ -92,16 +95,22 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
if (ret)
return ret;
pcb_temp = 0;
/* TODO: Introduce pcb temperature lookup */
/* Default constants */
slope = s->slope;
constant = s->constant;
pcb_tz = data->pcb_tz;
/* In case pcb zone is available, use the extrapolation rule with it */
if (pcb_temp) {
tmp -= pcb_temp;
if (!IS_ERR(pcb_tz)) {
ret = thermal_zone_get_temp(pcb_tz, &pcb_temp);
if (!ret) {
tmp -= pcb_temp; /* got a valid PCB temp */
slope = s->slope_pcb;
constant = s->constant_pcb;
} else {
slope = s->slope;
constant = s->constant;
dev_err(bgp->dev,
"Failed to read PCB state. Using defaults\n");
}
}
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);
......@@ -115,7 +124,7 @@ static int ti_thermal_bind(struct thermal_zone_device *thermal,
struct ti_thermal_data *data = thermal->devdata;
int id;
if (IS_ERR_OR_NULL(data))
if (!data || IS_ERR(data))
return -ENODEV;
/* check if this is the cooling device we registered */
......@@ -137,7 +146,7 @@ static int ti_thermal_unbind(struct thermal_zone_device *thermal,
{
struct ti_thermal_data *data = thermal->devdata;
if (IS_ERR_OR_NULL(data))
if (!data || IS_ERR(data))
return -ENODEV;
/* check if this is the cooling device we registered */
......@@ -273,6 +282,8 @@ static struct ti_thermal_data
data->sensor_id = id;
data->bgp = bgp;
data->mode = THERMAL_DEVICE_ENABLED;
/* pcb_tz will be either valid or PTR_ERR() */
data->pcb_tz = thermal_zone_get_zone_by_name("pcb");
INIT_WORK(&data->thermal_wq, ti_thermal_work);
return data;
......@@ -285,7 +296,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
data = ti_bandgap_get_sensor_data(bgp, id);
if (IS_ERR_OR_NULL(data))
if (!data || IS_ERR(data))
data = ti_thermal_build_data(bgp, id);
if (!data)
......@@ -296,7 +307,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
OMAP_TRIP_NUMBER, 0, data, &ti_thermal_ops,
NULL, FAST_TEMP_MONITORING_RATE,
FAST_TEMP_MONITORING_RATE);
if (IS_ERR_OR_NULL(data->ti_thermal)) {
if (IS_ERR(data->ti_thermal)) {
dev_err(bgp->dev, "thermal zone device is NULL\n");
return PTR_ERR(data->ti_thermal);
}
......@@ -333,7 +344,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
struct ti_thermal_data *data;
data = ti_bandgap_get_sensor_data(bgp, id);
if (IS_ERR_OR_NULL(data))
if (!data || IS_ERR(data))
data = ti_thermal_build_data(bgp, id);
if (!data)
......@@ -346,7 +357,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
/* Register cooling device */
data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
if (IS_ERR_OR_NULL(data->cool_dev)) {
if (IS_ERR(data->cool_dev)) {
dev_err(bgp->dev,
"Failed to register cpufreq cooling device\n");
return PTR_ERR(data->cool_dev);
......
......@@ -38,6 +38,9 @@
#define OMAP_GRADIENT_SLOPE_5430_GPU 117
#define OMAP_GRADIENT_CONST_5430_GPU -2992
#define DRA752_GRADIENT_SLOPE 0
#define DRA752_GRADIENT_CONST 2000
/* PCB sensor calculation constants */
#define OMAP_GRADIENT_SLOPE_W_PCB_4430 0
#define OMAP_GRADIENT_CONST_W_PCB_4430 20000
......@@ -51,6 +54,9 @@
#define OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU 464
#define OMAP_GRADIENT_CONST_W_PCB_5430_GPU -5102
#define DRA752_GRADIENT_SLOPE_W_PCB 0
#define DRA752_GRADIENT_CONST_W_PCB 2000
/* trip points of interest in milicelsius (at hotspot level) */
#define OMAP_TRIP_COLD 100000
#define OMAP_TRIP_HOT 110000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment