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