Commit 75f74a90 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge tag 'thermal-v6.4-rc1-1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux

Pull thermal control material for 6.4-rc1 from Daniel Lezcano:

"- Add more thermal zone device encapsulation: prevent setting
   structure field directly, access the sensor device instead the
   thermal zone's device for trace, relocate the traces in
   drivers/thermal (Daniel Lezcano)

 - Use the generic trip point for the i.MX and remove the get_trip_temp
   ops (Daniel Lezcano)

 - Use the devm_platform_ioremap_resource() in the Hisilicon driver
   (Yang Li)

 - Remove R-Car H3 ES1.* handling as public has only access to the ES2
   version and the upstream support for the ES1 has been shutdown (Wolfram
   Sang)

 - Add a delay after initializing the bank in order to let the time to
   the hardware to initialze itself before reading the temperature
   (Amjad Ouled-Ameur)

 - Add MT8365 support (Amjad Ouled-Ameur)"

* tag 'thermal-v6.4-rc1-1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal/drivers/ti: Use fixed update interval
  thermal/drivers/stm: Don't set no_hwmon to false
  thermal/drivers/db8500: Use driver dev instead of tz->device
  thermal/core: Relocate the traces definition in thermal directory
  thermal/drivers/hisi: Use devm_platform_ioremap_resource()
  thermal/drivers/imx: Use the thermal framework for the trip point
  thermal/drivers/imx: Remove get_trip_temp ops
  thermal/drivers/rcar_gen3_thermal: Remove R-Car H3 ES1.* handling
  thermal/drivers/mediatek: Add delay after thermal banks initialization
  thermal/drivers/mediatek: Add support for MT8365 SoC
  thermal/drivers/mediatek: Control buffer enablement tweaks
  dt-bindings: thermal: mediatek: Add binding documentation for MT8365 SoC
parents cd246fa9 0c492be4
...@@ -16,6 +16,7 @@ Required properties: ...@@ -16,6 +16,7 @@ Required properties:
- "mediatek,mt7981-thermal", "mediatek,mt7986-thermal" : For MT7981 SoC - "mediatek,mt7981-thermal", "mediatek,mt7986-thermal" : For MT7981 SoC
- "mediatek,mt7986-thermal" : For MT7986 SoC - "mediatek,mt7986-thermal" : For MT7986 SoC
- "mediatek,mt8183-thermal" : For MT8183 family of SoCs - "mediatek,mt8183-thermal" : For MT8183 family of SoCs
- "mediatek,mt8365-thermal" : For MT8365 family of SoCs
- "mediatek,mt8516-thermal", "mediatek,mt2701-thermal : For MT8516 family of SoCs - "mediatek,mt8516-thermal", "mediatek,mt2701-thermal : For MT8516 family of SoCs
- reg: Address range of the thermal controller - reg: Address range of the thermal controller
- interrupts: IRQ for the thermal controller - interrupts: IRQ for the thermal controller
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for sensor chip drivers. # Makefile for sensor chip drivers.
# #
CFLAGS_thermal_core.o := -I$(src)
obj-$(CONFIG_THERMAL) += thermal_sys.o obj-$(CONFIG_THERMAL) += thermal_sys.o
thermal_sys-y += thermal_core.o thermal_sysfs.o thermal_sys-y += thermal_core.o thermal_sysfs.o
thermal_sys-y += thermal_trip.o thermal_helpers.o thermal_sys-y += thermal_trip.o thermal_helpers.o
...@@ -16,6 +16,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o ...@@ -16,6 +16,7 @@ thermal_sys-$(CONFIG_THERMAL_OF) += thermal_of.o
thermal_sys-$(CONFIG_THERMAL_ACPI) += thermal_acpi.o thermal_sys-$(CONFIG_THERMAL_ACPI) += thermal_acpi.o
# governors # governors
CFLAGS_gov_power_allocator.o := -I$(src)
thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += gov_fair_share.o thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += gov_fair_share.o
thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o thermal_sys-$(CONFIG_THERMAL_GOV_BANG_BANG) += gov_bang_bang.o
thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += gov_step_wise.o thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += gov_step_wise.o
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#include <linux/units.h> #include <linux/units.h>
#include <trace/events/thermal.h> #include "thermal_trace.h"
/* /*
* Cooling state <-> CPUFreq frequency * Cooling state <-> CPUFreq frequency
......
...@@ -53,6 +53,7 @@ static const unsigned long db8500_thermal_points[] = { ...@@ -53,6 +53,7 @@ static const unsigned long db8500_thermal_points[] = {
struct db8500_thermal_zone { struct db8500_thermal_zone {
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct device *dev;
unsigned long interpolated_temp; unsigned long interpolated_temp;
unsigned int cur_index; unsigned int cur_index;
}; };
...@@ -114,7 +115,7 @@ static irqreturn_t prcmu_low_irq_handler(int irq, void *irq_data) ...@@ -114,7 +115,7 @@ static irqreturn_t prcmu_low_irq_handler(int irq, void *irq_data)
idx -= 1; idx -= 1;
db8500_thermal_update_config(th, idx, next_low, next_high); db8500_thermal_update_config(th, idx, next_low, next_high);
dev_dbg(&th->tz->device, dev_dbg(th->dev,
"PRCMU set max %ld, min %ld\n", next_high, next_low); "PRCMU set max %ld, min %ld\n", next_high, next_low);
thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED); thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED);
...@@ -136,7 +137,7 @@ static irqreturn_t prcmu_high_irq_handler(int irq, void *irq_data) ...@@ -136,7 +137,7 @@ static irqreturn_t prcmu_high_irq_handler(int irq, void *irq_data)
db8500_thermal_update_config(th, idx, next_low, next_high); db8500_thermal_update_config(th, idx, next_low, next_high);
dev_dbg(&th->tz->device, dev_dbg(th->dev,
"PRCMU set max %ld, min %ld\n", next_high, next_low); "PRCMU set max %ld, min %ld\n", next_high, next_low);
} else if (idx == num_points - 1) } else if (idx == num_points - 1)
/* So we roof out 1 degree over the max point */ /* So we roof out 1 degree over the max point */
...@@ -157,6 +158,8 @@ static int db8500_thermal_probe(struct platform_device *pdev) ...@@ -157,6 +158,8 @@ static int db8500_thermal_probe(struct platform_device *pdev)
if (!th) if (!th)
return -ENOMEM; return -ENOMEM;
th->dev = dev;
low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW"); low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW");
if (low_irq < 0) if (low_irq < 0)
return low_irq; return low_irq;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#include <linux/units.h> #include <linux/units.h>
#include <trace/events/thermal.h> #include "thermal_trace.h"
#define SCALE_ERROR_MITIGATION 100 #define SCALE_ERROR_MITIGATION 100
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
#include <linux/thermal.h> #include <linux/thermal.h>
#include <trace/events/thermal.h> #include "thermal_trace.h"
#include "thermal_core.h" #include "thermal_core.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/thermal_power_allocator.h> #include "thermal_trace_ipa.h"
#include "thermal_core.h" #include "thermal_core.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/thermal.h> #include <linux/thermal.h>
#include <linux/minmax.h> #include <linux/minmax.h>
#include <trace/events/thermal.h> #include "thermal_trace.h"
#include "thermal_core.h" #include "thermal_core.h"
......
...@@ -544,7 +544,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) ...@@ -544,7 +544,6 @@ static int hisi_thermal_probe(struct platform_device *pdev)
{ {
struct hisi_thermal_data *data; struct hisi_thermal_data *data;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res;
int i, ret; int i, ret;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
...@@ -555,8 +554,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) ...@@ -555,8 +554,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
data->ops = of_device_get_match_data(dev); data->ops = of_device_get_match_data(dev);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_platform_ioremap_resource(pdev, 0);
data->regs = devm_ioremap_resource(dev, res);
if (IS_ERR(data->regs)) if (IS_ERR(data->regs))
return PTR_ERR(data->regs); return PTR_ERR(data->regs);
......
...@@ -330,33 +330,29 @@ static int imx_change_mode(struct thermal_zone_device *tz, ...@@ -330,33 +330,29 @@ static int imx_change_mode(struct thermal_zone_device *tz,
return 0; return 0;
} }
static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
{
*temp = trips[IMX_TRIP_CRITICAL].temperature;
return 0;
}
static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip,
int temp) int temp)
{ {
struct imx_thermal_data *data = thermal_zone_device_priv(tz); struct imx_thermal_data *data = thermal_zone_device_priv(tz);
struct thermal_trip trip;
int ret; int ret;
ret = pm_runtime_resume_and_get(data->dev); ret = pm_runtime_resume_and_get(data->dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = __thermal_zone_get_trip(tz, trip_id, &trip);
if (ret)
return ret;
/* do not allow changing critical threshold */ /* do not allow changing critical threshold */
if (trip == IMX_TRIP_CRITICAL) if (trip.type == THERMAL_TRIP_CRITICAL)
return -EPERM; return -EPERM;
/* do not allow passive to be set higher than critical */ /* do not allow passive to be set higher than critical */
if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature)
return -EINVAL; return -EINVAL;
trips[IMX_TRIP_PASSIVE].temperature = temp;
imx_set_alarm_temp(data, temp); imx_set_alarm_temp(data, temp);
pm_runtime_put(data->dev); pm_runtime_put(data->dev);
...@@ -384,7 +380,6 @@ static struct thermal_zone_device_ops imx_tz_ops = { ...@@ -384,7 +380,6 @@ static struct thermal_zone_device_ops imx_tz_ops = {
.unbind = imx_unbind, .unbind = imx_unbind,
.get_temp = imx_get_temp, .get_temp = imx_get_temp,
.change_mode = imx_change_mode, .change_mode = imx_change_mode,
.get_crit_temp = imx_get_crit_temp,
.set_trip_temp = imx_set_trip_temp, .set_trip_temp = imx_set_trip_temp,
}; };
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define AUXADC_CON2_V 0x010 #define AUXADC_CON2_V 0x010
#define AUXADC_DATA(channel) (0x14 + (channel) * 4) #define AUXADC_DATA(channel) (0x14 + (channel) * 4)
#define APMIXED_SYS_TS_CON0 0x600
#define APMIXED_SYS_TS_CON1 0x604 #define APMIXED_SYS_TS_CON1 0x604
/* Thermal Controller Registers */ /* Thermal Controller Registers */
...@@ -281,6 +282,17 @@ enum mtk_thermal_version { ...@@ -281,6 +282,17 @@ enum mtk_thermal_version {
/* The calibration coefficient of sensor */ /* The calibration coefficient of sensor */
#define MT7986_CALIBRATION 165 #define MT7986_CALIBRATION 165
/* MT8365 */
#define MT8365_TEMP_AUXADC_CHANNEL 11
#define MT8365_CALIBRATION 164
#define MT8365_NUM_CONTROLLER 1
#define MT8365_NUM_BANKS 1
#define MT8365_NUM_SENSORS 3
#define MT8365_NUM_SENSORS_PER_ZONE 3
#define MT8365_TS1 0
#define MT8365_TS2 1
#define MT8365_TS3 2
struct mtk_thermal; struct mtk_thermal;
struct thermal_bank_cfg { struct thermal_bank_cfg {
...@@ -307,6 +319,9 @@ struct mtk_thermal_data { ...@@ -307,6 +319,9 @@ struct mtk_thermal_data {
bool need_switch_bank; bool need_switch_bank;
struct thermal_bank_cfg bank_data[MAX_NUM_ZONES]; struct thermal_bank_cfg bank_data[MAX_NUM_ZONES];
enum mtk_thermal_version version; enum mtk_thermal_version version;
u32 apmixed_buffer_ctl_reg;
u32 apmixed_buffer_ctl_mask;
u32 apmixed_buffer_ctl_set;
}; };
struct mtk_thermal { struct mtk_thermal {
...@@ -432,6 +447,24 @@ static const int mt7986_mux_values[MT7986_NUM_SENSORS] = { 0, }; ...@@ -432,6 +447,24 @@ static const int mt7986_mux_values[MT7986_NUM_SENSORS] = { 0, };
static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 }; static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 };
static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, }; static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, };
/* MT8365 thermal sensor data */
static const int mt8365_bank_data[MT8365_NUM_SENSORS] = {
MT8365_TS1, MT8365_TS2, MT8365_TS3
};
static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = {
TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
};
static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = {
TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
};
static const int mt8365_mux_values[MT8365_NUM_SENSORS] = { 0, 1, 2 };
static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = { 0 };
static const int mt8365_vts_index[MT8365_NUM_SENSORS] = { VTS1, VTS2, VTS3 };
/* /*
* The MT8173 thermal controller has four banks. Each bank can read up to * The MT8173 thermal controller has four banks. Each bank can read up to
* four temperature sensors simultaneously. The MT8173 has a total of 5 * four temperature sensors simultaneously. The MT8173 has a total of 5
...@@ -506,6 +539,40 @@ static const struct mtk_thermal_data mt2701_thermal_data = { ...@@ -506,6 +539,40 @@ static const struct mtk_thermal_data mt2701_thermal_data = {
.version = MTK_THERMAL_V1, .version = MTK_THERMAL_V1,
}; };
/*
* The MT8365 thermal controller has one bank, which can read up to
* four temperature sensors simultaneously. The MT8365 has a total of 3
* temperature sensors.
*
* The thermal core only gets the maximum temperature of this one bank,
* so the bank concept wouldn't be necessary here. However, the SVS (Smart
* Voltage Scaling) unit makes its decisions based on the same bank
* data.
*/
static const struct mtk_thermal_data mt8365_thermal_data = {
.auxadc_channel = MT8365_TEMP_AUXADC_CHANNEL,
.num_banks = MT8365_NUM_BANKS,
.num_sensors = MT8365_NUM_SENSORS,
.vts_index = mt8365_vts_index,
.cali_val = MT8365_CALIBRATION,
.num_controller = MT8365_NUM_CONTROLLER,
.controller_offset = mt8365_tc_offset,
.need_switch_bank = false,
.bank_data = {
{
.num_sensors = MT8365_NUM_SENSORS,
.sensors = mt8365_bank_data
},
},
.msr = mt8365_msr,
.adcpnp = mt8365_adcpnp,
.sensor_mux_values = mt8365_mux_values,
.version = MTK_THERMAL_V1,
.apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON0,
.apmixed_buffer_ctl_mask = (u32) ~GENMASK(29, 28),
.apmixed_buffer_ctl_set = 0,
};
/* /*
* The MT2712 thermal controller has one bank, which can read up to * The MT2712 thermal controller has one bank, which can read up to
* four temperature sensors simultaneously. The MT2712 has a total of 4 * four temperature sensors simultaneously. The MT2712 has a total of 4
...@@ -560,6 +627,9 @@ static const struct mtk_thermal_data mt7622_thermal_data = { ...@@ -560,6 +627,9 @@ static const struct mtk_thermal_data mt7622_thermal_data = {
.adcpnp = mt7622_adcpnp, .adcpnp = mt7622_adcpnp,
.sensor_mux_values = mt7622_mux_values, .sensor_mux_values = mt7622_mux_values,
.version = MTK_THERMAL_V2, .version = MTK_THERMAL_V2,
.apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1,
.apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3),
.apmixed_buffer_ctl_set = BIT(0),
}; };
/* /*
...@@ -746,14 +816,6 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank) ...@@ -746,14 +816,6 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
mt, conf->bank_data[bank->id].sensors[i], raw); mt, conf->bank_data[bank->id].sensors[i], raw);
/*
* The first read of a sensor often contains very high bogus
* temperature value. Filter these out so that the system does
* not immediately shut down.
*/
if (temp > 200000)
temp = 0;
if (temp > max) if (temp > max)
max = temp; max = temp;
} }
...@@ -1074,19 +1136,27 @@ static const struct of_device_id mtk_thermal_of_match[] = { ...@@ -1074,19 +1136,27 @@ static const struct of_device_id mtk_thermal_of_match[] = {
{ {
.compatible = "mediatek,mt8183-thermal", .compatible = "mediatek,mt8183-thermal",
.data = (void *)&mt8183_thermal_data, .data = (void *)&mt8183_thermal_data,
},
{
.compatible = "mediatek,mt8365-thermal",
.data = (void *)&mt8365_thermal_data,
}, { }, {
}, },
}; };
MODULE_DEVICE_TABLE(of, mtk_thermal_of_match); MODULE_DEVICE_TABLE(of, mtk_thermal_of_match);
static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base) static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt,
void __iomem *apmixed_base)
{ {
int tmp; u32 tmp;
tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1); if (!mt->conf->apmixed_buffer_ctl_reg)
tmp &= ~(0x37); return;
tmp |= 0x1;
writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
tmp &= mt->conf->apmixed_buffer_ctl_mask;
tmp |= mt->conf->apmixed_buffer_ctl_set;
writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
udelay(200); udelay(200);
} }
...@@ -1184,10 +1254,10 @@ static int mtk_thermal_probe(struct platform_device *pdev) ...@@ -1184,10 +1254,10 @@ static int mtk_thermal_probe(struct platform_device *pdev)
goto err_disable_clk_auxadc; goto err_disable_clk_auxadc;
} }
if (mt->conf->version != MTK_THERMAL_V1) { mtk_thermal_turn_on_buffer(mt, apmixed_base);
mtk_thermal_turn_on_buffer(apmixed_base);
if (mt->conf->version != MTK_THERMAL_V2)
mtk_thermal_release_periodic_ts(mt, auxadc_base); mtk_thermal_release_periodic_ts(mt, auxadc_base);
}
if (mt->conf->version == MTK_THERMAL_V1) if (mt->conf->version == MTK_THERMAL_V1)
mt->raw_to_mcelsius = raw_to_mcelsius_v1; mt->raw_to_mcelsius = raw_to_mcelsius_v1;
...@@ -1203,6 +1273,9 @@ static int mtk_thermal_probe(struct platform_device *pdev) ...@@ -1203,6 +1273,9 @@ static int mtk_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mt); platform_set_drvdata(pdev, mt);
/* Delay for thermal banks to be ready */
msleep(30);
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt, tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
&mtk_thermal_ops); &mtk_thermal_ops);
if (IS_ERR(tzdev)) { if (IS_ERR(tzdev)) {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/sys_soc.h>
#include <linux/thermal.h> #include <linux/thermal.h>
#include "thermal_hwmon.h" #include "thermal_hwmon.h"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
#define REG_GEN3_IRQTEMP1 0x14 #define REG_GEN3_IRQTEMP1 0x14
#define REG_GEN3_IRQTEMP2 0x18 #define REG_GEN3_IRQTEMP2 0x18
#define REG_GEN3_IRQTEMP3 0x1C #define REG_GEN3_IRQTEMP3 0x1C
#define REG_GEN3_CTSR 0x20
#define REG_GEN3_THCTR 0x20 #define REG_GEN3_THCTR 0x20
#define REG_GEN3_TEMP 0x28 #define REG_GEN3_TEMP 0x28
#define REG_GEN3_THCODE1 0x50 #define REG_GEN3_THCODE1 0x50
...@@ -46,14 +44,6 @@ ...@@ -46,14 +44,6 @@
#define IRQ_TEMPD2 BIT(4) #define IRQ_TEMPD2 BIT(4)
#define IRQ_TEMPD3 BIT(5) #define IRQ_TEMPD3 BIT(5)
/* CTSR bits */
#define CTSR_PONM BIT(8)
#define CTSR_AOUT BIT(7)
#define CTSR_THBGR BIT(5)
#define CTSR_VMEN BIT(4)
#define CTSR_VMST BIT(1)
#define CTSR_THSST BIT(0)
/* THCTR bits */ /* THCTR bits */
#define THCTR_PONM BIT(6) #define THCTR_PONM BIT(6)
#define THCTR_THSST BIT(0) #define THCTR_THSST BIT(0)
...@@ -88,8 +78,6 @@ struct rcar_gen3_thermal_priv { ...@@ -88,8 +78,6 @@ struct rcar_gen3_thermal_priv {
struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
struct thermal_zone_device_ops ops; struct thermal_zone_device_ops ops;
unsigned int num_tscs; unsigned int num_tscs;
void (*thermal_init)(struct rcar_gen3_thermal_priv *priv,
struct rcar_gen3_thermal_tsc *tsc);
int ptat[3]; int ptat[3];
}; };
...@@ -248,11 +236,6 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) ...@@ -248,11 +236,6 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static const struct soc_device_attribute r8a7795es1[] = {
{ .soc_id = "r8a7795", .revision = "ES1.*" },
{ /* sentinel */ }
};
static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv)
{ {
unsigned int i; unsigned int i;
...@@ -311,34 +294,6 @@ static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) ...@@ -311,34 +294,6 @@ static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv)
return true; return true;
} }
static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_priv *priv,
struct rcar_gen3_thermal_tsc *tsc)
{
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0);
usleep_range(1000, 2000);
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM);
rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F);
rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0);
if (priv->ops.set_trips)
rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN,
IRQ_TEMPD1 | IRQ_TEMP2);
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN);
usleep_range(100, 200);
rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN |
CTSR_VMST | CTSR_THSST);
usleep_range(1000, 2000);
}
static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv,
struct rcar_gen3_thermal_tsc *tsc) struct rcar_gen3_thermal_tsc *tsc)
{ {
...@@ -474,9 +429,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) ...@@ -474,9 +429,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
priv->ops = rcar_gen3_tz_of_ops; priv->ops = rcar_gen3_tz_of_ops;
priv->thermal_init = rcar_gen3_thermal_init;
if (soc_device_match(r8a7795es1))
priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
...@@ -516,7 +468,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) ...@@ -516,7 +468,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
for (i = 0; i < priv->num_tscs; i++) { for (i = 0; i < priv->num_tscs; i++) {
struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
priv->thermal_init(priv, tsc); rcar_gen3_thermal_init(priv, tsc);
rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1);
zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops);
...@@ -563,7 +515,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) ...@@ -563,7 +515,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev)
for (i = 0; i < priv->num_tscs; i++) { for (i = 0; i < priv->num_tscs; i++) {
struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i];
priv->thermal_init(priv, tsc); rcar_gen3_thermal_init(priv, tsc);
} }
return 0; return 0;
......
...@@ -558,7 +558,6 @@ static int stm_thermal_probe(struct platform_device *pdev) ...@@ -558,7 +558,6 @@ static int stm_thermal_probe(struct platform_device *pdev)
* Thermal_zone doesn't enable hwmon as default, * Thermal_zone doesn't enable hwmon as default,
* enable it here * enable it here
*/ */
sensor->th_dev->tzp->no_hwmon = false;
ret = thermal_add_hwmon_sysfs(sensor->th_dev); ret = thermal_add_hwmon_sysfs(sensor->th_dev);
if (ret) if (ret)
goto err_tz; goto err_tz;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/suspend.h> #include <linux/suspend.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/thermal.h> #include "thermal_trace.h"
#include "thermal_core.h" #include "thermal_core.h"
#include "thermal_hwmon.h" #include "thermal_hwmon.h"
......
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <trace/events/thermal.h>
#include "thermal_core.h" #include "thermal_core.h"
#include "thermal_trace.h"
int get_tz_trend(struct thermal_zone_device *tz, int trip) int get_tz_trend(struct thermal_zone_device *tz, int trip)
{ {
......
...@@ -195,5 +195,11 @@ TRACE_EVENT(thermal_power_devfreq_limit, ...@@ -195,5 +195,11 @@ TRACE_EVENT(thermal_power_devfreq_limit,
#endif /* CONFIG_DEVFREQ_THERMAL */ #endif /* CONFIG_DEVFREQ_THERMAL */
#endif /* _TRACE_THERMAL_H */ #endif /* _TRACE_THERMAL_H */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE thermal_trace
/* This part must be outside protection */ /* This part must be outside protection */
#include <trace/define_trace.h> #include <trace/define_trace.h>
...@@ -84,5 +84,11 @@ TRACE_EVENT(thermal_power_allocator_pid, ...@@ -84,5 +84,11 @@ TRACE_EVENT(thermal_power_allocator_pid,
); );
#endif /* _TRACE_THERMAL_POWER_ALLOCATOR_H */ #endif /* _TRACE_THERMAL_POWER_ALLOCATOR_H */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE thermal_trace_ipa
/* This part must be outside protection */ /* This part must be outside protection */
#include <trace/define_trace.h> #include <trace/define_trace.h>
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "ti-bandgap.h" #include "ti-bandgap.h"
#include "../thermal_hwmon.h" #include "../thermal_hwmon.h"
#define TI_BANDGAP_UPDATE_INTERVAL_MS 250
/* common data structures */ /* common data structures */
struct ti_thermal_data { struct ti_thermal_data {
struct cpufreq_policy *policy; struct cpufreq_policy *policy;
...@@ -159,7 +161,6 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, ...@@ -159,7 +161,6 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
char *domain) char *domain)
{ {
struct ti_thermal_data *data; struct ti_thermal_data *data;
int interval;
data = ti_bandgap_get_sensor_data(bgp, id); data = ti_bandgap_get_sensor_data(bgp, id);
...@@ -177,10 +178,9 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, ...@@ -177,10 +178,9 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
return PTR_ERR(data->ti_thermal); return PTR_ERR(data->ti_thermal);
} }
interval = jiffies_to_msecs(data->ti_thermal->polling_delay_jiffies);
ti_bandgap_set_sensor_data(bgp, id, data); ti_bandgap_set_sensor_data(bgp, id, data);
ti_bandgap_write_update_interval(bgp, data->sensor_id, interval); ti_bandgap_write_update_interval(bgp, data->sensor_id,
TI_BANDGAP_UPDATE_INTERVAL_MS);
if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal)) if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal))
dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n"); dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n");
......
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