Thermal control updates for 6.1-rc1
- Rework the device tree initialization, convert the drivers to the new API and remove the old OF code (Daniel Lezcano). - Fix return value to -ENODEV when searching for a specific thermal zone which does not exist (Daniel Lezcano). - Fix the return value inspection in of_thermal_zone_find() (Dan Carpenter). - Fix kernel panic when KASAN is enabled as it detects use after free when unregistering a thermal zone (Daniel Lezcano). - Move the set_trip ops inside the therma sysfs code (Daniel Lezcano). - Remove unnecessary error message as it is already shown in the underlying function (Jiapeng Chong). - Rework the monitoring path and move the locks upper in the call stack to fix some potentials race windows (Daniel Lezcano). - Fix lockdep_assert() warning introduced by the lock rework (Daniel Lezcano). - Do not lock thermal zone mutex in the user space governor (Rafael Wysocki). - Revert the Mellanox 'hotter thermal zone' feature because it is already handled in the thermal framework core code (Daniel Lezcano). - Increase maximum number of trip points in the thermal core (Sumeet Pawnikar). - Replace strlcpy() with unused retval with strscpy() in the core thermal control code (Wolfram Sang). - Use module_pci_driver() macro in the int340x processor_thermal driver (Shang XiaoJing). - Use get_cpu() instead of smp_processor_id() in the intel_powerclamp thermal driver to prevent it from crashing and remove unused accounting for IRQ wakes from it (Srinivas Pandruvada). - Consolidate priv->data_vault checks in int340x_thermal (Rafael Wysocki). - Check the policy first in cpufreq_cooling_register() (Xuewen Yan). - Drop redundant error message from da9062-thermal (zhaoxiao). - Drop of_match_ptr() from thermal_mmio (Jean Delvare). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmM7OzUSHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRx8CMP/1kNnDUjtCBIvl/OJEM0yVlEGJNppNu9 dCNQwuftAJRt7dBB292clKW15ef1fFAHrW/eOy+z62k6k/tfqnMLEK38hpS4pIaL PZRjRfpp2CDmBBVTJ0I2nNC9h0zZY4tQK+JCII1M2UmgtLaGbp3NuIu2Ga4i5bNR IYE3QvVz/g2/pRNa/BTsJySje/q7wv231Vd5jg4czg58EyntBGO4gmWNuXyZ6OkF ijzcu7K5Tkll6DT+Paw8bGcPCyjBtoBhv2A6HtsC3cYfc2tY9BVf3DG2HlG0qTAU pIZsLOlUozzJScVbu8ScKj1hlP/iCKcPgVjP4l+U57EtcY/ULBqrQtkDVtGedNOZ wa5a1VUsZDrigWRpj1u5SsDWmbAod5uK5X/3naUfH7XtomhqikfaZK7Euek6kfDN SEhZaBycAFWlI/L5cG2sd6BBcmWlBqkaHiQ0zEv2YlALY5SkNOUQrrq2A/1LP1Ae 67xbzbWFXyR8DAq3YyfnLpqgcJcSiyGxmdKZ1u2XHudXeJHKdAB7xlcJz+hfWpYU Rd1ZTB3ATA/IMG1rLO2dKgaMmyQCWPG6oXtJjTH0g3sXm0U6K14dwEU1ey9u/Li6 DmI4cWaXf8WoRvb3rkEcJliayUed4U/ohU+z1bInSE8EuCBuyMLRhoJdi3ZhunOC PAyKcHg8fLy9 =Ufw7 -----END PGP SIGNATURE----- Merge tag 'thermal-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull thermal control updates from Rafael Wysocki: "The most significant part of this update is the thermal control DT initialization rework from Daniel Lezcano and the following conversion of drivers to use the new API introduced by it Apart from that, the maximum number of trip points in a thermal zone is increased and there are some fixes and code cleanups Specifics: - Rework the device tree initialization, convert the drivers to the new API and remove the old OF code (Daniel Lezcano) - Fix return value to -ENODEV when searching for a specific thermal zone which does not exist (Daniel Lezcano) - Fix the return value inspection in of_thermal_zone_find() (Dan Carpenter) - Fix kernel panic when KASAN is enabled as it detects use after free when unregistering a thermal zone (Daniel Lezcano) - Move the set_trip ops inside the therma sysfs code (Daniel Lezcano) - Remove unnecessary error message as it is already shown in the underlying function (Jiapeng Chong) - Rework the monitoring path and move the locks upper in the call stack to fix some potentials race windows (Daniel Lezcano) - Fix lockdep_assert() warning introduced by the lock rework (Daniel Lezcano) - Do not lock thermal zone mutex in the user space governor (Rafael Wysocki) - Revert the Mellanox 'hotter thermal zone' feature because it is already handled in the thermal framework core code (Daniel Lezcano) - Increase maximum number of trip points in the thermal core (Sumeet Pawnikar) - Replace strlcpy() with unused retval with strscpy() in the core thermal control code (Wolfram Sang) - Use module_pci_driver() macro in the int340x processor_thermal driver (Shang XiaoJing) - Use get_cpu() instead of smp_processor_id() in the intel_powerclamp thermal driver to prevent it from crashing and remove unused accounting for IRQ wakes from it (Srinivas Pandruvada) - Consolidate priv->data_vault checks in int340x_thermal (Rafael Wysocki) - Check the policy first in cpufreq_cooling_register() (Xuewen Yan) - Drop redundant error message from da9062-thermal (zhaoxiao) - Drop of_match_ptr() from thermal_mmio (Jean Delvare)" * tag 'thermal-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (55 commits) thermal: core: Increase maximum number of trip points thermal: int340x: processor_thermal: Use module_pci_driver() macro thermal: intel_powerclamp: Remove accounting for IRQ wakes thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash thermal: int340x_thermal: Consolidate priv->data_vault checks thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register() thermal: Drop duplicate words from comments thermal: move from strlcpy() with unused retval to strscpy() thermal: da9062-thermal: Drop redundant error message thermal/drivers/thermal_mmio: Drop of_match_ptr() thermal: gov_user_space: Do not lock thermal zone mutex Revert "mlxsw: core: Add the hottest thermal zone detection" thermal/core: Fix lockdep_assert() warning thermal/core: Move the mutex inside the thermal_zone_device_update() function thermal/core: Move the thermal zone lock out of the governors thermal/governors: Group the thermal zone lock inside the throttle function thermal/core: Rework the monitoring a bit thermal/core: Rearm the monitoring only one time thermal/drivers/qcom/spmi-adc-tm5: Remove unnecessary print function dev_err() thermal/of: Remove old OF code ...
This commit is contained in:
Коммит
a5088ee725
|
@ -327,7 +327,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void __iomem * mmio)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SATA AHCI temperature monitor */
|
/* SATA AHCI temperature monitor */
|
||||||
static int sata_ahci_read_temperature(void *dev, int *temp)
|
static int __sata_ahci_read_temperature(void *dev, int *temp)
|
||||||
{
|
{
|
||||||
u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;
|
u16 mpll_test_reg, rtune_ctl_reg, dac_ctl_reg, read_sum;
|
||||||
u32 str1, str2, str3, str4;
|
u32 str1, str2, str3, str4;
|
||||||
|
@ -416,6 +416,11 @@ static int sata_ahci_read_temperature(void *dev, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sata_ahci_read_temperature(struct thermal_zone_device *tz, int *temp)
|
||||||
|
{
|
||||||
|
return __sata_ahci_read_temperature(tz->devdata, temp);
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t sata_ahci_show_temp(struct device *dev,
|
static ssize_t sata_ahci_show_temp(struct device *dev,
|
||||||
struct device_attribute *da,
|
struct device_attribute *da,
|
||||||
char *buf)
|
char *buf)
|
||||||
|
@ -423,14 +428,14 @@ static ssize_t sata_ahci_show_temp(struct device *dev,
|
||||||
unsigned int temp = 0;
|
unsigned int temp = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = sata_ahci_read_temperature(dev, &temp);
|
err = __sata_ahci_read_temperature(dev, &temp);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
return sprintf(buf, "%u\n", temp);
|
return sprintf(buf, "%u\n", temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops fsl_sata_ahci_of_thermal_ops = {
|
static const struct thermal_zone_device_ops fsl_sata_ahci_of_thermal_ops = {
|
||||||
.get_temp = sata_ahci_read_temperature,
|
.get_temp = sata_ahci_read_temperature,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1131,8 +1136,8 @@ static int imx_ahci_probe(struct platform_device *pdev)
|
||||||
ret = PTR_ERR(hwmon_dev);
|
ret = PTR_ERR(hwmon_dev);
|
||||||
goto disable_clk;
|
goto disable_clk;
|
||||||
}
|
}
|
||||||
devm_thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
|
devm_thermal_of_zone_register(hwmon_dev, 0, hwmon_dev,
|
||||||
&fsl_sata_ahci_of_thermal_ops);
|
&fsl_sata_ahci_of_thermal_ops);
|
||||||
dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev));
|
dev_info(dev, "%s: sensor 'sata_ahci'\n", dev_name(hwmon_dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,9 @@ static DEFINE_IDA(hwmon_ida);
|
||||||
* between hwmon and thermal_sys modules.
|
* between hwmon and thermal_sys modules.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_THERMAL_OF
|
#ifdef CONFIG_THERMAL_OF
|
||||||
static int hwmon_thermal_get_temp(void *data, int *temp)
|
static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct hwmon_thermal_data *tdata = data;
|
struct hwmon_thermal_data *tdata = tz->devdata;
|
||||||
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
|
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
|
||||||
int ret;
|
int ret;
|
||||||
long t;
|
long t;
|
||||||
|
@ -168,9 +168,9 @@ static int hwmon_thermal_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hwmon_thermal_set_trips(void *data, int low, int high)
|
static int hwmon_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct hwmon_thermal_data *tdata = data;
|
struct hwmon_thermal_data *tdata = tz->devdata;
|
||||||
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
|
struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
|
||||||
const struct hwmon_chip_info *chip = hwdev->chip;
|
const struct hwmon_chip_info *chip = hwdev->chip;
|
||||||
const struct hwmon_channel_info **info = chip->info;
|
const struct hwmon_channel_info **info = chip->info;
|
||||||
|
@ -203,7 +203,7 @@ static int hwmon_thermal_set_trips(void *data, int low, int high)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops hwmon_thermal_ops = {
|
static const struct thermal_zone_device_ops hwmon_thermal_ops = {
|
||||||
.get_temp = hwmon_thermal_get_temp,
|
.get_temp = hwmon_thermal_get_temp,
|
||||||
.set_trips = hwmon_thermal_set_trips,
|
.set_trips = hwmon_thermal_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -227,8 +227,8 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index)
|
||||||
tdata->dev = dev;
|
tdata->dev = dev;
|
||||||
tdata->index = index;
|
tdata->index = index;
|
||||||
|
|
||||||
tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata,
|
tzd = devm_thermal_of_zone_register(dev, index, tdata,
|
||||||
&hwmon_thermal_ops);
|
&hwmon_thermal_ops);
|
||||||
if (IS_ERR(tzd)) {
|
if (IS_ERR(tzd)) {
|
||||||
if (PTR_ERR(tzd) != -ENODEV)
|
if (PTR_ERR(tzd) != -ENODEV)
|
||||||
return PTR_ERR(tzd);
|
return PTR_ERR(tzd);
|
||||||
|
|
|
@ -1270,9 +1270,9 @@ struct pmbus_thermal_data {
|
||||||
struct pmbus_sensor *sensor;
|
struct pmbus_sensor *sensor;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pmbus_thermal_get_temp(void *data, int *temp)
|
static int pmbus_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct pmbus_thermal_data *tdata = data;
|
struct pmbus_thermal_data *tdata = tz->devdata;
|
||||||
struct pmbus_sensor *sensor = tdata->sensor;
|
struct pmbus_sensor *sensor = tdata->sensor;
|
||||||
struct pmbus_data *pmbus_data = tdata->pmbus_data;
|
struct pmbus_data *pmbus_data = tdata->pmbus_data;
|
||||||
struct i2c_client *client = to_i2c_client(pmbus_data->dev);
|
struct i2c_client *client = to_i2c_client(pmbus_data->dev);
|
||||||
|
@ -1296,7 +1296,7 @@ static int pmbus_thermal_get_temp(void *data, int *temp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops pmbus_thermal_ops = {
|
static const struct thermal_zone_device_ops pmbus_thermal_ops = {
|
||||||
.get_temp = pmbus_thermal_get_temp,
|
.get_temp = pmbus_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1314,8 +1314,8 @@ static int pmbus_thermal_add_sensor(struct pmbus_data *pmbus_data,
|
||||||
tdata->sensor = sensor;
|
tdata->sensor = sensor;
|
||||||
tdata->pmbus_data = pmbus_data;
|
tdata->pmbus_data = pmbus_data;
|
||||||
|
|
||||||
tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata,
|
tzd = devm_thermal_of_zone_register(dev, index, tdata,
|
||||||
&pmbus_thermal_ops);
|
&pmbus_thermal_ops);
|
||||||
/*
|
/*
|
||||||
* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV,
|
* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV,
|
||||||
* so ignore that error but forward any other error.
|
* so ignore that error but forward any other error.
|
||||||
|
|
|
@ -62,9 +62,9 @@ static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scpi_read_temp(void *dev, int *temp)
|
static int scpi_read_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct scpi_thermal_zone *zone = dev;
|
struct scpi_thermal_zone *zone = tz->devdata;
|
||||||
struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
|
struct scpi_sensors *scpi_sensors = zone->scpi_sensors;
|
||||||
struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
|
struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops;
|
||||||
struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
|
struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id];
|
||||||
|
@ -121,7 +121,7 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
return sprintf(buf, "%s\n", sensor->info.name);
|
return sprintf(buf, "%s\n", sensor->info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops scpi_sensor_ops = {
|
static const struct thermal_zone_device_ops scpi_sensor_ops = {
|
||||||
.get_temp = scpi_read_temp,
|
.get_temp = scpi_read_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -275,10 +275,10 @@ static int scpi_hwmon_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
zone->sensor_id = i;
|
zone->sensor_id = i;
|
||||||
zone->scpi_sensors = scpi_sensors;
|
zone->scpi_sensors = scpi_sensors;
|
||||||
z = devm_thermal_zone_of_sensor_register(dev,
|
z = devm_thermal_of_zone_register(dev,
|
||||||
sensor->info.sensor_id,
|
sensor->info.sensor_id,
|
||||||
zone,
|
zone,
|
||||||
&scpi_sensor_ops);
|
&scpi_sensor_ops);
|
||||||
/*
|
/*
|
||||||
* The call to thermal_zone_of_sensor_register returns
|
* The call to thermal_zone_of_sensor_register returns
|
||||||
* an error for sensors that are not associated with
|
* an error for sensors that are not associated with
|
||||||
|
|
|
@ -412,9 +412,9 @@ static int sun4i_gpadc_runtime_resume(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sun4i_gpadc_get_temp(void *data, int *temp)
|
static int sun4i_gpadc_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct sun4i_gpadc_iio *info = data;
|
struct sun4i_gpadc_iio *info = tz->devdata;
|
||||||
int val, scale, offset;
|
int val, scale, offset;
|
||||||
|
|
||||||
if (sun4i_gpadc_temp_read(info->indio_dev, &val))
|
if (sun4i_gpadc_temp_read(info->indio_dev, &val))
|
||||||
|
@ -428,7 +428,7 @@ static int sun4i_gpadc_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = {
|
static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
|
||||||
.get_temp = &sun4i_gpadc_get_temp,
|
.get_temp = &sun4i_gpadc_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -637,9 +637,9 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
|
||||||
pm_runtime_enable(&pdev->dev);
|
pm_runtime_enable(&pdev->dev);
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_THERMAL_OF)) {
|
if (IS_ENABLED(CONFIG_THERMAL_OF)) {
|
||||||
info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
|
info->tzd = devm_thermal_of_zone_register(info->sensor_device,
|
||||||
0, info,
|
0, info,
|
||||||
&sun4i_ts_tz_ops);
|
&sun4i_ts_tz_ops);
|
||||||
/*
|
/*
|
||||||
* Do not fail driver probing when failing to register in
|
* Do not fail driver probing when failing to register in
|
||||||
* thermal because no thermal DT node is found.
|
* thermal because no thermal DT node is found.
|
||||||
|
@ -681,8 +681,6 @@ static int sun4i_gpadc_remove(struct platform_device *pdev)
|
||||||
if (!IS_ENABLED(CONFIG_THERMAL_OF))
|
if (!IS_ENABLED(CONFIG_THERMAL_OF))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd);
|
|
||||||
|
|
||||||
if (!info->no_irq)
|
if (!info->no_irq)
|
||||||
iio_map_array_unregister(indio_dev);
|
iio_map_array_unregister(indio_dev);
|
||||||
|
|
||||||
|
|
|
@ -192,12 +192,12 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sun4i_get_tz_temp(void *data, int *temp)
|
static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
return sun4i_get_temp(data, temp);
|
return sun4i_get_temp(tz->devdata, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops sun4i_ts_tz_ops = {
|
static const struct thermal_zone_device_ops sun4i_ts_tz_ops = {
|
||||||
.get_temp = sun4i_get_tz_temp,
|
.get_temp = sun4i_get_tz_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -356,8 +356,8 @@ static int sun4i_ts_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(hwmon))
|
if (IS_ERR(hwmon))
|
||||||
return PTR_ERR(hwmon);
|
return PTR_ERR(hwmon);
|
||||||
|
|
||||||
thermal = devm_thermal_zone_of_sensor_register(ts->dev, 0, ts,
|
thermal = devm_thermal_of_zone_register(ts->dev, 0, ts,
|
||||||
&sun4i_ts_tz_ops);
|
&sun4i_ts_tz_ops);
|
||||||
if (IS_ERR(thermal))
|
if (IS_ERR(thermal))
|
||||||
return PTR_ERR(thermal);
|
return PTR_ERR(thermal);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */
|
#define MLXSW_THERMAL_ASIC_TEMP_HOT 105000 /* 105C */
|
||||||
#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */
|
#define MLXSW_THERMAL_HYSTERESIS_TEMP 5000 /* 5C */
|
||||||
#define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2)
|
#define MLXSW_THERMAL_MODULE_TEMP_SHIFT (MLXSW_THERMAL_HYSTERESIS_TEMP * 2)
|
||||||
#define MLXSW_THERMAL_TEMP_SCORE_MAX GENMASK(31, 0)
|
|
||||||
#define MLXSW_THERMAL_MAX_STATE 10
|
#define MLXSW_THERMAL_MAX_STATE 10
|
||||||
#define MLXSW_THERMAL_MIN_STATE 2
|
#define MLXSW_THERMAL_MIN_STATE 2
|
||||||
#define MLXSW_THERMAL_MAX_DUTY 255
|
#define MLXSW_THERMAL_MAX_DUTY 255
|
||||||
|
@ -101,8 +100,6 @@ struct mlxsw_thermal {
|
||||||
struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
|
struct thermal_cooling_device *cdevs[MLXSW_MFCR_PWMS_MAX];
|
||||||
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
|
u8 cooling_levels[MLXSW_THERMAL_MAX_STATE + 1];
|
||||||
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
struct mlxsw_thermal_trip trips[MLXSW_THERMAL_NUM_TRIPS];
|
||||||
unsigned int tz_highest_score;
|
|
||||||
struct thermal_zone_device *tz_highest_dev;
|
|
||||||
struct mlxsw_thermal_area line_cards[];
|
struct mlxsw_thermal_area line_cards[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,34 +190,6 @@ mlxsw_thermal_module_trips_update(struct device *dev, struct mlxsw_core *core,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mlxsw_thermal_tz_score_update(struct mlxsw_thermal *thermal,
|
|
||||||
struct thermal_zone_device *tzdev,
|
|
||||||
struct mlxsw_thermal_trip *trips,
|
|
||||||
int temp)
|
|
||||||
{
|
|
||||||
struct mlxsw_thermal_trip *trip = trips;
|
|
||||||
unsigned int score, delta, i, shift = 1;
|
|
||||||
|
|
||||||
/* Calculate thermal zone score, if temperature is above the hot
|
|
||||||
* threshold score is set to MLXSW_THERMAL_TEMP_SCORE_MAX.
|
|
||||||
*/
|
|
||||||
score = MLXSW_THERMAL_TEMP_SCORE_MAX;
|
|
||||||
for (i = MLXSW_THERMAL_TEMP_TRIP_NORM; i < MLXSW_THERMAL_NUM_TRIPS;
|
|
||||||
i++, trip++) {
|
|
||||||
if (temp < trip->temp) {
|
|
||||||
delta = DIV_ROUND_CLOSEST(temp, trip->temp - temp);
|
|
||||||
score = delta * shift;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
shift *= 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (score > thermal->tz_highest_score) {
|
|
||||||
thermal->tz_highest_score = score;
|
|
||||||
thermal->tz_highest_dev = tzdev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
|
static int mlxsw_thermal_bind(struct thermal_zone_device *tzdev,
|
||||||
struct thermal_cooling_device *cdev)
|
struct thermal_cooling_device *cdev)
|
||||||
{
|
{
|
||||||
|
@ -286,9 +255,6 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
|
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
|
||||||
if (temp > 0)
|
|
||||||
mlxsw_thermal_tz_score_update(thermal, tzdev, thermal->trips,
|
|
||||||
temp);
|
|
||||||
|
|
||||||
*p_temp = temp;
|
*p_temp = temp;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -349,21 +315,6 @@ static int mlxsw_thermal_set_trip_hyst(struct thermal_zone_device *tzdev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_thermal_trend_get(struct thermal_zone_device *tzdev,
|
|
||||||
int trip, enum thermal_trend *trend)
|
|
||||||
{
|
|
||||||
struct mlxsw_thermal *thermal = tzdev->devdata;
|
|
||||||
|
|
||||||
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (tzdev == thermal->tz_highest_dev)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
*trend = THERMAL_TREND_STABLE;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct thermal_zone_params mlxsw_thermal_params = {
|
static struct thermal_zone_params mlxsw_thermal_params = {
|
||||||
.no_hwmon = true,
|
.no_hwmon = true,
|
||||||
};
|
};
|
||||||
|
@ -377,7 +328,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_ops = {
|
||||||
.set_trip_temp = mlxsw_thermal_set_trip_temp,
|
.set_trip_temp = mlxsw_thermal_set_trip_temp,
|
||||||
.get_trip_hyst = mlxsw_thermal_get_trip_hyst,
|
.get_trip_hyst = mlxsw_thermal_get_trip_hyst,
|
||||||
.set_trip_hyst = mlxsw_thermal_set_trip_hyst,
|
.set_trip_hyst = mlxsw_thermal_set_trip_hyst,
|
||||||
.get_trend = mlxsw_thermal_trend_get,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
|
static int mlxsw_thermal_module_bind(struct thermal_zone_device *tzdev,
|
||||||
|
@ -463,7 +413,6 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
|
||||||
int temp, crit_temp, emerg_temp;
|
int temp, crit_temp, emerg_temp;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
u16 sensor_index;
|
u16 sensor_index;
|
||||||
int err;
|
|
||||||
|
|
||||||
dev = thermal->bus_info->dev;
|
dev = thermal->bus_info->dev;
|
||||||
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + tz->module;
|
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + tz->module;
|
||||||
|
@ -479,10 +428,8 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Update trip points. */
|
/* Update trip points. */
|
||||||
err = mlxsw_thermal_module_trips_update(dev, thermal->core, tz,
|
mlxsw_thermal_module_trips_update(dev, thermal->core, tz,
|
||||||
crit_temp, emerg_temp);
|
crit_temp, emerg_temp);
|
||||||
if (!err && temp > 0)
|
|
||||||
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -546,22 +493,6 @@ mlxsw_thermal_module_trip_hyst_set(struct thermal_zone_device *tzdev, int trip,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mlxsw_thermal_module_trend_get(struct thermal_zone_device *tzdev,
|
|
||||||
int trip, enum thermal_trend *trend)
|
|
||||||
{
|
|
||||||
struct mlxsw_thermal_module *tz = tzdev->devdata;
|
|
||||||
struct mlxsw_thermal *thermal = tz->parent;
|
|
||||||
|
|
||||||
if (trip < 0 || trip >= MLXSW_THERMAL_NUM_TRIPS)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (tzdev == thermal->tz_highest_dev)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
*trend = THERMAL_TREND_STABLE;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
|
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
|
||||||
.bind = mlxsw_thermal_module_bind,
|
.bind = mlxsw_thermal_module_bind,
|
||||||
.unbind = mlxsw_thermal_module_unbind,
|
.unbind = mlxsw_thermal_module_unbind,
|
||||||
|
@ -571,7 +502,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
|
||||||
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
|
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
|
||||||
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
|
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
|
||||||
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
|
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
|
||||||
.get_trend = mlxsw_thermal_module_trend_get,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
||||||
|
@ -592,8 +522,6 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
|
mlxsw_reg_mtmp_unpack(mtmp_pl, &temp, NULL, NULL, NULL, NULL);
|
||||||
if (temp > 0)
|
|
||||||
mlxsw_thermal_tz_score_update(thermal, tzdev, tz->trips, temp);
|
|
||||||
|
|
||||||
*p_temp = temp;
|
*p_temp = temp;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -608,7 +536,6 @@ static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
|
||||||
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
|
.set_trip_temp = mlxsw_thermal_module_trip_temp_set,
|
||||||
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
|
.get_trip_hyst = mlxsw_thermal_module_trip_hyst_get,
|
||||||
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
|
.set_trip_hyst = mlxsw_thermal_module_trip_hyst_set,
|
||||||
.get_trend = mlxsw_thermal_module_trend_get,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,
|
static int mlxsw_thermal_get_max_state(struct thermal_cooling_device *cdev,
|
||||||
|
|
|
@ -434,9 +434,9 @@ static int max8973_init_dcdc(struct max8973_chip *max,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int max8973_thermal_read_temp(void *data, int *temp)
|
static int max8973_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct max8973_chip *mchip = data;
|
struct max8973_chip *mchip = tz->devdata;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ static irqreturn_t max8973_thermal_irq(int irq, void *data)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops max77621_tz_ops = {
|
static const struct thermal_zone_device_ops max77621_tz_ops = {
|
||||||
.get_temp = max8973_thermal_read_temp,
|
.get_temp = max8973_thermal_read_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -479,8 +479,8 @@ static int max8973_thermal_init(struct max8973_chip *mchip)
|
||||||
if (mchip->id != MAX77621)
|
if (mchip->id != MAX77621)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tzd = devm_thermal_zone_of_sensor_register(mchip->dev, 0, mchip,
|
tzd = devm_thermal_of_zone_register(mchip->dev, 0, mchip,
|
||||||
&max77621_tz_ops);
|
&max77621_tz_ops);
|
||||||
if (IS_ERR(tzd)) {
|
if (IS_ERR(tzd)) {
|
||||||
ret = PTR_ERR(tzd);
|
ret = PTR_ERR(tzd);
|
||||||
dev_err(mchip->dev, "Failed to register thermal sensor: %d\n",
|
dev_err(mchip->dev, "Failed to register thermal sensor: %d\n",
|
||||||
|
|
|
@ -179,12 +179,12 @@ static int amlogic_thermal_disable(struct amlogic_thermal *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int amlogic_thermal_get_temp(void *data, int *temp)
|
static int amlogic_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
unsigned int tval;
|
unsigned int tval;
|
||||||
struct amlogic_thermal *pdata = data;
|
struct amlogic_thermal *pdata = tz->devdata;
|
||||||
|
|
||||||
if (!data)
|
if (!pdata)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
regmap_read(pdata->regmap, TSENSOR_STAT0, &tval);
|
regmap_read(pdata->regmap, TSENSOR_STAT0, &tval);
|
||||||
|
@ -195,7 +195,7 @@ static int amlogic_thermal_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops amlogic_thermal_ops = {
|
static const struct thermal_zone_device_ops amlogic_thermal_ops = {
|
||||||
.get_temp = amlogic_thermal_get_temp,
|
.get_temp = amlogic_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -276,10 +276,10 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
|
||||||
return PTR_ERR(pdata->sec_ao_map);
|
return PTR_ERR(pdata->sec_ao_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
pdata->tzd = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
0,
|
0,
|
||||||
pdata,
|
pdata,
|
||||||
&amlogic_thermal_ops);
|
&amlogic_thermal_ops);
|
||||||
if (IS_ERR(pdata->tzd)) {
|
if (IS_ERR(pdata->tzd)) {
|
||||||
ret = PTR_ERR(pdata->tzd);
|
ret = PTR_ERR(pdata->tzd);
|
||||||
dev_err(dev, "Failed to register tsensor: %d\n", ret);
|
dev_err(dev, "Failed to register tsensor: %d\n", ret);
|
||||||
|
|
|
@ -420,9 +420,9 @@ static struct thermal_zone_device_ops legacy_ops = {
|
||||||
.get_temp = armada_get_temp_legacy,
|
.get_temp = armada_get_temp_legacy,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int armada_get_temp(void *_sensor, int *temp)
|
static int armada_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct armada_thermal_sensor *sensor = _sensor;
|
struct armada_thermal_sensor *sensor = tz->devdata;
|
||||||
struct armada_thermal_priv *priv = sensor->priv;
|
struct armada_thermal_priv *priv = sensor->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ unlock_mutex:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops of_ops = {
|
static const struct thermal_zone_device_ops of_ops = {
|
||||||
.get_temp = armada_get_temp,
|
.get_temp = armada_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -928,9 +928,9 @@ static int armada_thermal_probe(struct platform_device *pdev)
|
||||||
/* Register the sensor */
|
/* Register the sensor */
|
||||||
sensor->priv = priv;
|
sensor->priv = priv;
|
||||||
sensor->id = sensor_id;
|
sensor->id = sensor_id;
|
||||||
tz = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
tz = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
sensor->id, sensor,
|
sensor->id, sensor,
|
||||||
&of_ops);
|
&of_ops);
|
||||||
if (IS_ERR(tz)) {
|
if (IS_ERR(tz)) {
|
||||||
dev_info(&pdev->dev, "Thermal sensor %d unavailable\n",
|
dev_info(&pdev->dev, "Thermal sensor %d unavailable\n",
|
||||||
sensor_id);
|
sensor_id);
|
||||||
|
|
|
@ -31,11 +31,11 @@ struct bcm2711_thermal_priv {
|
||||||
struct thermal_zone_device *thermal;
|
struct thermal_zone_device *thermal;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bcm2711_get_temp(void *data, int *temp)
|
static int bcm2711_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct bcm2711_thermal_priv *priv = data;
|
struct bcm2711_thermal_priv *priv = tz->devdata;
|
||||||
int slope = thermal_zone_get_slope(priv->thermal);
|
int slope = thermal_zone_get_slope(tz);
|
||||||
int offset = thermal_zone_get_offset(priv->thermal);
|
int offset = thermal_zone_get_offset(tz);
|
||||||
u32 val;
|
u32 val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static int bcm2711_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops bcm2711_thermal_of_ops = {
|
static const struct thermal_zone_device_ops bcm2711_thermal_of_ops = {
|
||||||
.get_temp = bcm2711_get_temp,
|
.get_temp = bcm2711_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ static int bcm2711_thermal_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
priv->regmap = regmap;
|
priv->regmap = regmap;
|
||||||
|
|
||||||
thermal = devm_thermal_zone_of_sensor_register(dev, 0, priv,
|
thermal = devm_thermal_of_zone_register(dev, 0, priv,
|
||||||
&bcm2711_thermal_of_ops);
|
&bcm2711_thermal_of_ops);
|
||||||
if (IS_ERR(thermal)) {
|
if (IS_ERR(thermal)) {
|
||||||
ret = PTR_ERR(thermal);
|
ret = PTR_ERR(thermal);
|
||||||
dev_err(dev, "could not register sensor: %d\n", ret);
|
dev_err(dev, "could not register sensor: %d\n", ret);
|
||||||
|
|
|
@ -88,9 +88,9 @@ static int bcm2835_thermal_temp2adc(int temp, int offset, int slope)
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm2835_thermal_get_temp(void *d, int *temp)
|
static int bcm2835_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct bcm2835_thermal_data *data = d;
|
struct bcm2835_thermal_data *data = tz->devdata;
|
||||||
u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT);
|
u32 val = readl(data->regs + BCM2835_TS_TSENSSTAT);
|
||||||
|
|
||||||
if (!(val & BCM2835_TS_TSENSSTAT_VALID))
|
if (!(val & BCM2835_TS_TSENSSTAT_VALID))
|
||||||
|
@ -135,7 +135,7 @@ static void bcm2835_thermal_debugfs(struct platform_device *pdev)
|
||||||
debugfs_create_regset32("regset", 0444, data->debugfsdir, regset);
|
debugfs_create_regset32("regset", 0444, data->debugfsdir, regset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops bcm2835_thermal_ops = {
|
static const struct thermal_zone_device_ops bcm2835_thermal_ops = {
|
||||||
.get_temp = bcm2835_thermal_get_temp,
|
.get_temp = bcm2835_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -206,8 +206,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
|
||||||
data->clk, rate);
|
data->clk, rate);
|
||||||
|
|
||||||
/* register of thermal sensor and get info from DT */
|
/* register of thermal sensor and get info from DT */
|
||||||
tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
|
tz = devm_thermal_of_zone_register(&pdev->dev, 0, data,
|
||||||
&bcm2835_thermal_ops);
|
&bcm2835_thermal_ops);
|
||||||
if (IS_ERR(tz)) {
|
if (IS_ERR(tz)) {
|
||||||
err = PTR_ERR(tz);
|
err = PTR_ERR(tz);
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
|
@ -277,7 +277,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err_tz:
|
err_tz:
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, tz);
|
thermal_of_zone_unregister(tz);
|
||||||
err_clk:
|
err_clk:
|
||||||
clk_disable_unprepare(data->clk);
|
clk_disable_unprepare(data->clk);
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ static int bcm2835_thermal_remove(struct platform_device *pdev)
|
||||||
struct thermal_zone_device *tz = data->tz;
|
struct thermal_zone_device *tz = data->tz;
|
||||||
|
|
||||||
debugfs_remove_recursive(data->debugfsdir);
|
debugfs_remove_recursive(data->debugfsdir);
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, tz);
|
thermal_of_zone_unregister(tz);
|
||||||
clk_disable_unprepare(data->clk);
|
clk_disable_unprepare(data->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -105,7 +105,7 @@ static struct avs_tmon_trip avs_tmon_trips[] = {
|
||||||
struct brcmstb_thermal_params {
|
struct brcmstb_thermal_params {
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int mult;
|
unsigned int mult;
|
||||||
const struct thermal_zone_of_device_ops *of_ops;
|
const struct thermal_zone_device_ops *of_ops;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct brcmstb_thermal_priv {
|
struct brcmstb_thermal_priv {
|
||||||
|
@ -150,9 +150,9 @@ static inline u32 avs_tmon_temp_to_code(struct brcmstb_thermal_priv *priv,
|
||||||
return (u32)((offset - temp) / mult);
|
return (u32)((offset - temp) / mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int brcmstb_get_temp(void *data, int *temp)
|
static int brcmstb_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct brcmstb_thermal_priv *priv = data;
|
struct brcmstb_thermal_priv *priv = tz->devdata;
|
||||||
u32 val;
|
u32 val;
|
||||||
long t;
|
long t;
|
||||||
|
|
||||||
|
@ -260,9 +260,9 @@ static irqreturn_t brcmstb_tmon_irq_thread(int irq, void *data)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int brcmstb_set_trips(void *data, int low, int high)
|
static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct brcmstb_thermal_priv *priv = data;
|
struct brcmstb_thermal_priv *priv = tz->devdata;
|
||||||
|
|
||||||
dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
|
dev_dbg(priv->dev, "set trips %d <--> %d\n", low, high);
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ static int brcmstb_set_trips(void *data, int low, int high)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops brcmstb_16nm_of_ops = {
|
static const struct thermal_zone_device_ops brcmstb_16nm_of_ops = {
|
||||||
.get_temp = brcmstb_get_temp,
|
.get_temp = brcmstb_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ static const struct brcmstb_thermal_params brcmstb_16nm_params = {
|
||||||
.of_ops = &brcmstb_16nm_of_ops,
|
.of_ops = &brcmstb_16nm_of_ops,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops brcmstb_28nm_of_ops = {
|
static const struct thermal_zone_device_ops brcmstb_28nm_of_ops = {
|
||||||
.get_temp = brcmstb_get_temp,
|
.get_temp = brcmstb_get_temp,
|
||||||
.set_trips = brcmstb_set_trips,
|
.set_trips = brcmstb_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(of, brcmstb_thermal_id_table);
|
||||||
|
|
||||||
static int brcmstb_thermal_probe(struct platform_device *pdev)
|
static int brcmstb_thermal_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct thermal_zone_of_device_ops *of_ops;
|
const struct thermal_zone_device_ops *of_ops;
|
||||||
struct thermal_zone_device *thermal;
|
struct thermal_zone_device *thermal;
|
||||||
struct brcmstb_thermal_priv *priv;
|
struct brcmstb_thermal_priv *priv;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
@ -341,8 +341,8 @@ static int brcmstb_thermal_probe(struct platform_device *pdev)
|
||||||
platform_set_drvdata(pdev, priv);
|
platform_set_drvdata(pdev, priv);
|
||||||
of_ops = priv->temp_params->of_ops;
|
of_ops = priv->temp_params->of_ops;
|
||||||
|
|
||||||
thermal = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, priv,
|
thermal = devm_thermal_of_zone_register(&pdev->dev, 0, priv,
|
||||||
of_ops);
|
of_ops);
|
||||||
if (IS_ERR(thermal)) {
|
if (IS_ERR(thermal)) {
|
||||||
ret = PTR_ERR(thermal);
|
ret = PTR_ERR(thermal);
|
||||||
dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
|
dev_err(&pdev->dev, "could not register sensor: %d\n", ret);
|
||||||
|
|
|
@ -14,19 +14,14 @@
|
||||||
#define PVTMON_CONTROL0_SEL_TEST_MODE 0x0000000e
|
#define PVTMON_CONTROL0_SEL_TEST_MODE 0x0000000e
|
||||||
#define PVTMON_STATUS 0x08
|
#define PVTMON_STATUS 0x08
|
||||||
|
|
||||||
struct ns_thermal {
|
static int ns_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
struct thermal_zone_device *tz;
|
|
||||||
void __iomem *pvtmon;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int ns_thermal_get_temp(void *data, int *temp)
|
|
||||||
{
|
{
|
||||||
struct ns_thermal *ns_thermal = data;
|
void __iomem *pvtmon = tz->devdata;
|
||||||
int offset = thermal_zone_get_offset(ns_thermal->tz);
|
int offset = thermal_zone_get_offset(tz);
|
||||||
int slope = thermal_zone_get_slope(ns_thermal->tz);
|
int slope = thermal_zone_get_slope(tz);
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
val = readl(ns_thermal->pvtmon + PVTMON_CONTROL0);
|
val = readl(pvtmon + PVTMON_CONTROL0);
|
||||||
if ((val & PVTMON_CONTROL0_SEL_MASK) != PVTMON_CONTROL0_SEL_TEMP_MONITOR) {
|
if ((val & PVTMON_CONTROL0_SEL_MASK) != PVTMON_CONTROL0_SEL_TEMP_MONITOR) {
|
||||||
/* Clear current mode selection */
|
/* Clear current mode selection */
|
||||||
val &= ~PVTMON_CONTROL0_SEL_MASK;
|
val &= ~PVTMON_CONTROL0_SEL_MASK;
|
||||||
|
@ -34,50 +29,47 @@ static int ns_thermal_get_temp(void *data, int *temp)
|
||||||
/* Set temp monitor mode (it's the default actually) */
|
/* Set temp monitor mode (it's the default actually) */
|
||||||
val |= PVTMON_CONTROL0_SEL_TEMP_MONITOR;
|
val |= PVTMON_CONTROL0_SEL_TEMP_MONITOR;
|
||||||
|
|
||||||
writel(val, ns_thermal->pvtmon + PVTMON_CONTROL0);
|
writel(val, pvtmon + PVTMON_CONTROL0);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = readl(ns_thermal->pvtmon + PVTMON_STATUS);
|
val = readl(pvtmon + PVTMON_STATUS);
|
||||||
*temp = slope * val + offset;
|
*temp = slope * val + offset;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops ns_thermal_ops = {
|
static const struct thermal_zone_device_ops ns_thermal_ops = {
|
||||||
.get_temp = ns_thermal_get_temp,
|
.get_temp = ns_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ns_thermal_probe(struct platform_device *pdev)
|
static int ns_thermal_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct ns_thermal *ns_thermal;
|
struct thermal_zone_device *tz;
|
||||||
|
void __iomem *pvtmon;
|
||||||
|
|
||||||
ns_thermal = devm_kzalloc(dev, sizeof(*ns_thermal), GFP_KERNEL);
|
pvtmon = of_iomap(dev_of_node(dev), 0);
|
||||||
if (!ns_thermal)
|
if (WARN_ON(!pvtmon))
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
ns_thermal->pvtmon = of_iomap(dev_of_node(dev), 0);
|
|
||||||
if (WARN_ON(!ns_thermal->pvtmon))
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
ns_thermal->tz = devm_thermal_zone_of_sensor_register(dev, 0,
|
tz = devm_thermal_of_zone_register(dev, 0,
|
||||||
ns_thermal,
|
pvtmon,
|
||||||
&ns_thermal_ops);
|
&ns_thermal_ops);
|
||||||
if (IS_ERR(ns_thermal->tz)) {
|
if (IS_ERR(tz)) {
|
||||||
iounmap(ns_thermal->pvtmon);
|
iounmap(pvtmon);
|
||||||
return PTR_ERR(ns_thermal->tz);
|
return PTR_ERR(tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, ns_thermal);
|
platform_set_drvdata(pdev, pvtmon);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ns_thermal_remove(struct platform_device *pdev)
|
static int ns_thermal_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct ns_thermal *ns_thermal = platform_get_drvdata(pdev);
|
void __iomem *pvtmon = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
iounmap(ns_thermal->pvtmon);
|
iounmap(pvtmon);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#define SR_TMON_MAX_LIST 6
|
#define SR_TMON_MAX_LIST 6
|
||||||
|
|
||||||
struct sr_tmon {
|
struct sr_tmon {
|
||||||
struct thermal_zone_device *tz;
|
|
||||||
unsigned int crit_temp;
|
unsigned int crit_temp;
|
||||||
unsigned int tmon_id;
|
unsigned int tmon_id;
|
||||||
struct sr_thermal *priv;
|
struct sr_thermal *priv;
|
||||||
|
@ -31,9 +30,9 @@ struct sr_thermal {
|
||||||
struct sr_tmon tmon[SR_TMON_MAX_LIST];
|
struct sr_tmon tmon[SR_TMON_MAX_LIST];
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sr_get_temp(void *data, int *temp)
|
static int sr_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct sr_tmon *tmon = data;
|
struct sr_tmon *tmon = tz->devdata;
|
||||||
struct sr_thermal *sr_thermal = tmon->priv;
|
struct sr_thermal *sr_thermal = tmon->priv;
|
||||||
|
|
||||||
*temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
|
*temp = readl(sr_thermal->regs + SR_TMON_TEMP_BASE(tmon->tmon_id));
|
||||||
|
@ -41,13 +40,14 @@ static int sr_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops sr_tz_ops = {
|
static const struct thermal_zone_device_ops sr_tz_ops = {
|
||||||
.get_temp = sr_get_temp,
|
.get_temp = sr_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sr_thermal_probe(struct platform_device *pdev)
|
static int sr_thermal_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
struct thermal_zone_device *tz;
|
||||||
struct sr_thermal *sr_thermal;
|
struct sr_thermal *sr_thermal;
|
||||||
struct sr_tmon *tmon;
|
struct sr_tmon *tmon;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
@ -84,10 +84,10 @@ static int sr_thermal_probe(struct platform_device *pdev)
|
||||||
writel(0, sr_thermal->regs + SR_TMON_TEMP_BASE(i));
|
writel(0, sr_thermal->regs + SR_TMON_TEMP_BASE(i));
|
||||||
tmon->tmon_id = i;
|
tmon->tmon_id = i;
|
||||||
tmon->priv = sr_thermal;
|
tmon->priv = sr_thermal;
|
||||||
tmon->tz = devm_thermal_zone_of_sensor_register(dev, i, tmon,
|
tz = devm_thermal_of_zone_register(dev, i, tmon,
|
||||||
&sr_tz_ops);
|
&sr_tz_ops);
|
||||||
if (IS_ERR(tmon->tz))
|
if (IS_ERR(tz))
|
||||||
return PTR_ERR(tmon->tz);
|
return PTR_ERR(tz);
|
||||||
|
|
||||||
dev_dbg(dev, "thermal sensor %d registered\n", i);
|
dev_dbg(dev, "thermal sensor %d registered\n", i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __cpufreq_cooling_register - helper function to create cpufreq cooling device
|
* __cpufreq_cooling_register - helper function to create cpufreq cooling device
|
||||||
* @np: a valid struct device_node to the cooling device device tree node
|
* @np: a valid struct device_node to the cooling device tree node
|
||||||
* @policy: cpufreq policy
|
* @policy: cpufreq policy
|
||||||
* Normally this should be same as cpufreq policy->related_cpus.
|
* Normally this should be same as cpufreq policy->related_cpus.
|
||||||
* @em: Energy Model of the cpufreq policy
|
* @em: Energy Model of the cpufreq policy
|
||||||
|
@ -501,17 +501,17 @@ __cpufreq_cooling_register(struct device_node *np,
|
||||||
struct thermal_cooling_device_ops *cooling_ops;
|
struct thermal_cooling_device_ops *cooling_ops;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
if (IS_ERR_OR_NULL(policy)) {
|
||||||
|
pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
dev = get_cpu_device(policy->cpu);
|
dev = get_cpu_device(policy->cpu);
|
||||||
if (unlikely(!dev)) {
|
if (unlikely(!dev)) {
|
||||||
pr_warn("No cpu device for cpu %d\n", policy->cpu);
|
pr_warn("No cpu device for cpu %d\n", policy->cpu);
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ERR_OR_NULL(policy)) {
|
|
||||||
pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
|
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = cpufreq_table_count_valid_entries(policy);
|
i = cpufreq_table_count_valid_entries(policy);
|
||||||
if (!i) {
|
if (!i) {
|
||||||
pr_debug("%s: CPUFreq table not found or has no valid entries\n",
|
pr_debug("%s: CPUFreq table not found or has no valid entries\n",
|
||||||
|
|
|
@ -248,10 +248,9 @@ static int da9062_thermal_probe(struct platform_device *pdev)
|
||||||
jiffies_to_msecs(thermal->zone->passive_delay_jiffies));
|
jiffies_to_msecs(thermal->zone->passive_delay_jiffies));
|
||||||
|
|
||||||
ret = platform_get_irq_byname(pdev, "THERMAL");
|
ret = platform_get_irq_byname(pdev, "THERMAL");
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(&pdev->dev, "Failed to get platform IRQ.\n");
|
|
||||||
goto err_zone;
|
goto err_zone;
|
||||||
}
|
|
||||||
thermal->irq = ret;
|
thermal->irq = ret;
|
||||||
|
|
||||||
ret = request_threaded_irq(thermal->irq, NULL,
|
ret = request_threaded_irq(thermal->irq, NULL,
|
||||||
|
|
|
@ -58,9 +58,9 @@ struct db8500_thermal_zone {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Callback to get current temperature */
|
/* Callback to get current temperature */
|
||||||
static int db8500_thermal_get_temp(void *data, int *temp)
|
static int db8500_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct db8500_thermal_zone *th = data;
|
struct db8500_thermal_zone *th = tz->devdata;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: There is no PRCMU interface to get temperature data currently,
|
* TODO: There is no PRCMU interface to get temperature data currently,
|
||||||
|
@ -72,7 +72,7 @@ static int db8500_thermal_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thermal_zone_of_device_ops thdev_ops = {
|
static const struct thermal_zone_device_ops thdev_ops = {
|
||||||
.get_temp = db8500_thermal_get_temp,
|
.get_temp = db8500_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ static int db8500_thermal_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register of thermal sensor and get info from DT */
|
/* register of thermal sensor and get info from DT */
|
||||||
th->tz = devm_thermal_zone_of_sensor_register(dev, 0, th, &thdev_ops);
|
th->tz = devm_thermal_of_zone_register(dev, 0, th, &thdev_ops);
|
||||||
if (IS_ERR(th->tz)) {
|
if (IS_ERR(th->tz)) {
|
||||||
dev_err(dev, "register thermal zone sensor failed\n");
|
dev_err(dev, "register thermal zone sensor failed\n");
|
||||||
return PTR_ERR(th->tz);
|
return PTR_ERR(th->tz);
|
||||||
|
|
|
@ -31,8 +31,6 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
|
||||||
trip, trip_temp, tz->temperature,
|
trip, trip_temp, tz->temperature,
|
||||||
trip_hyst);
|
trip_hyst);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
if (instance->trip != trip)
|
if (instance->trip != trip)
|
||||||
continue;
|
continue;
|
||||||
|
@ -65,8 +63,6 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
|
||||||
instance->cdev->updated = false; /* cdev needs update */
|
instance->cdev->updated = false; /* cdev needs update */
|
||||||
mutex_unlock(&instance->cdev->lock);
|
mutex_unlock(&instance->cdev->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,15 +96,13 @@ static int bang_bang_control(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
struct thermal_instance *instance;
|
struct thermal_instance *instance;
|
||||||
|
|
||||||
thermal_zone_trip_update(tz, trip);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
thermal_zone_trip_update(tz, trip);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
||||||
thermal_cdev_update(instance->cdev);
|
thermal_cdev_update(instance->cdev);
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
int total_instance = 0;
|
int total_instance = 0;
|
||||||
int cur_trip_level = get_trip_level(tz);
|
int cur_trip_level = get_trip_level(tz);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
if (instance->trip != trip)
|
if (instance->trip != trip)
|
||||||
|
@ -112,7 +112,6 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
mutex_unlock(&cdev->lock);
|
mutex_unlock(&cdev->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,8 +392,6 @@ static int allocate_power(struct thermal_zone_device *tz,
|
||||||
int i, num_actors, total_weight, ret = 0;
|
int i, num_actors, total_weight, ret = 0;
|
||||||
int trip_max_desired_temperature = params->trip_max_desired_temperature;
|
int trip_max_desired_temperature = params->trip_max_desired_temperature;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
|
|
||||||
num_actors = 0;
|
num_actors = 0;
|
||||||
total_weight = 0;
|
total_weight = 0;
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
|
@ -404,10 +402,8 @@ static int allocate_power(struct thermal_zone_device *tz,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!num_actors) {
|
if (!num_actors)
|
||||||
ret = -ENODEV;
|
return -ENODEV;
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to allocate five arrays of the same size:
|
* We need to allocate five arrays of the same size:
|
||||||
|
@ -421,10 +417,8 @@ static int allocate_power(struct thermal_zone_device *tz,
|
||||||
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power));
|
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power));
|
||||||
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power));
|
BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power));
|
||||||
req_power = kcalloc(num_actors * 5, sizeof(*req_power), GFP_KERNEL);
|
req_power = kcalloc(num_actors * 5, sizeof(*req_power), GFP_KERNEL);
|
||||||
if (!req_power) {
|
if (!req_power)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_power = &req_power[num_actors];
|
max_power = &req_power[num_actors];
|
||||||
granted_power = &req_power[2 * num_actors];
|
granted_power = &req_power[2 * num_actors];
|
||||||
|
@ -496,8 +490,6 @@ static int allocate_power(struct thermal_zone_device *tz,
|
||||||
control_temp - tz->temperature);
|
control_temp - tz->temperature);
|
||||||
|
|
||||||
kfree(req_power);
|
kfree(req_power);
|
||||||
unlock:
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -576,7 +568,6 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
|
||||||
struct power_allocator_params *params = tz->governor_data;
|
struct power_allocator_params *params = tz->governor_data;
|
||||||
u32 req_power;
|
u32 req_power;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
struct thermal_cooling_device *cdev = instance->cdev;
|
struct thermal_cooling_device *cdev = instance->cdev;
|
||||||
|
|
||||||
|
@ -598,7 +589,6 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
|
||||||
|
|
||||||
mutex_unlock(&instance->cdev->lock);
|
mutex_unlock(&instance->cdev->lock);
|
||||||
}
|
}
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -712,6 +702,8 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
struct power_allocator_params *params = tz->governor_data;
|
struct power_allocator_params *params = tz->governor_data;
|
||||||
bool update;
|
bool update;
|
||||||
|
|
||||||
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We get called for every trip point but we only need to do
|
* We get called for every trip point but we only need to do
|
||||||
* our calculations once
|
* our calculations once
|
||||||
|
|
|
@ -117,8 +117,6 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
|
||||||
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
|
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
|
||||||
trip, trip_type, trip_temp, trend, throttle);
|
trip, trip_type, trip_temp, trend, throttle);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
if (instance->trip != trip)
|
if (instance->trip != trip)
|
||||||
continue;
|
continue;
|
||||||
|
@ -145,8 +143,6 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)
|
||||||
instance->cdev->updated = false; /* cdev needs update */
|
instance->cdev->updated = false; /* cdev needs update */
|
||||||
mutex_unlock(&instance->cdev->lock);
|
mutex_unlock(&instance->cdev->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,15 +160,13 @@ static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
struct thermal_instance *instance;
|
struct thermal_instance *instance;
|
||||||
|
|
||||||
thermal_zone_trip_update(tz, trip);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
thermal_zone_trip_update(tz, trip);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
||||||
thermal_cdev_update(instance->cdev);
|
thermal_cdev_update(instance->cdev);
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
|
||||||
char *thermal_prop[5];
|
char *thermal_prop[5];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
|
thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
|
||||||
thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
|
thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
|
||||||
thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
|
thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
|
||||||
|
@ -43,7 +44,7 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
|
||||||
kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
|
kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
kfree(thermal_prop[i]);
|
kfree(thermal_prop[i]);
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,9 +434,9 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hisi_thermal_get_temp(void *__data, int *temp)
|
static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct hisi_thermal_sensor *sensor = __data;
|
struct hisi_thermal_sensor *sensor = tz->devdata;
|
||||||
struct hisi_thermal_data *data = sensor->data;
|
struct hisi_thermal_data *data = sensor->data;
|
||||||
|
|
||||||
*temp = data->ops->get_temp(sensor);
|
*temp = data->ops->get_temp(sensor);
|
||||||
|
@ -447,7 +447,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = {
|
static const struct thermal_zone_device_ops hisi_of_thermal_ops = {
|
||||||
.get_temp = hisi_thermal_get_temp,
|
.get_temp = hisi_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
|
||||||
|
|
||||||
data->ops->irq_handler(sensor);
|
data->ops->irq_handler(sensor);
|
||||||
|
|
||||||
hisi_thermal_get_temp(sensor, &temp);
|
temp = data->ops->get_temp(sensor);
|
||||||
|
|
||||||
if (temp >= sensor->thres_temp) {
|
if (temp >= sensor->thres_temp) {
|
||||||
dev_crit(&data->pdev->dev,
|
dev_crit(&data->pdev->dev,
|
||||||
|
@ -484,9 +484,9 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev,
|
||||||
int ret, i;
|
int ret, i;
|
||||||
const struct thermal_trip *trip;
|
const struct thermal_trip *trip;
|
||||||
|
|
||||||
sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
sensor->tzd = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
sensor->id, sensor,
|
sensor->id, sensor,
|
||||||
&hisi_of_thermal_ops);
|
&hisi_of_thermal_ops);
|
||||||
if (IS_ERR(sensor->tzd)) {
|
if (IS_ERR(sensor->tzd)) {
|
||||||
ret = PTR_ERR(sensor->tzd);
|
ret = PTR_ERR(sensor->tzd);
|
||||||
sensor->tzd = NULL;
|
sensor->tzd = NULL;
|
||||||
|
|
|
@ -96,15 +96,15 @@ static int imx8mp_tmu_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tmu_get_temp(void *data, int *temp)
|
static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct tmu_sensor *sensor = data;
|
struct tmu_sensor *sensor = tz->devdata;
|
||||||
struct imx8mm_tmu *tmu = sensor->priv;
|
struct imx8mm_tmu *tmu = sensor->priv;
|
||||||
|
|
||||||
return tmu->socdata->get_temp(data, temp);
|
return tmu->socdata->get_temp(sensor, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thermal_zone_of_device_ops tmu_tz_ops = {
|
static const struct thermal_zone_device_ops tmu_tz_ops = {
|
||||||
.get_temp = tmu_get_temp,
|
.get_temp = tmu_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,9 +165,9 @@ static int imx8mm_tmu_probe(struct platform_device *pdev)
|
||||||
for (i = 0; i < data->num_sensors; i++) {
|
for (i = 0; i < data->num_sensors; i++) {
|
||||||
tmu->sensors[i].priv = tmu;
|
tmu->sensors[i].priv = tmu;
|
||||||
tmu->sensors[i].tzd =
|
tmu->sensors[i].tzd =
|
||||||
devm_thermal_zone_of_sensor_register(&pdev->dev, i,
|
devm_thermal_of_zone_register(&pdev->dev, i,
|
||||||
&tmu->sensors[i],
|
&tmu->sensors[i],
|
||||||
&tmu_tz_ops);
|
&tmu_tz_ops);
|
||||||
if (IS_ERR(tmu->sensors[i].tzd)) {
|
if (IS_ERR(tmu->sensors[i].tzd)) {
|
||||||
ret = PTR_ERR(tmu->sensors[i].tzd);
|
ret = PTR_ERR(tmu->sensors[i].tzd);
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
|
|
|
@ -43,11 +43,11 @@ struct imx_sc_msg_misc_get_temp {
|
||||||
} data;
|
} data;
|
||||||
} __packed __aligned(4);
|
} __packed __aligned(4);
|
||||||
|
|
||||||
static int imx_sc_thermal_get_temp(void *data, int *temp)
|
static int imx_sc_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct imx_sc_msg_misc_get_temp msg;
|
struct imx_sc_msg_misc_get_temp msg;
|
||||||
struct imx_sc_rpc_msg *hdr = &msg.hdr;
|
struct imx_sc_rpc_msg *hdr = &msg.hdr;
|
||||||
struct imx_sc_sensor *sensor = data;
|
struct imx_sc_sensor *sensor = tz->devdata;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
msg.data.req.resource_id = sensor->resource_id;
|
msg.data.req.resource_id = sensor->resource_id;
|
||||||
|
@ -70,7 +70,7 @@ static int imx_sc_thermal_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops imx_sc_thermal_ops = {
|
static const struct thermal_zone_device_ops imx_sc_thermal_ops = {
|
||||||
.get_temp = imx_sc_thermal_get_temp,
|
.get_temp = imx_sc_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,10 +109,10 @@ static int imx_sc_thermal_probe(struct platform_device *pdev)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
sensor->tzd = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
sensor->resource_id,
|
sensor->resource_id,
|
||||||
sensor,
|
sensor,
|
||||||
&imx_sc_thermal_ops);
|
&imx_sc_thermal_ops);
|
||||||
if (IS_ERR(sensor->tzd)) {
|
if (IS_ERR(sensor->tzd)) {
|
||||||
dev_err(&pdev->dev, "failed to register thermal zone\n");
|
dev_err(&pdev->dev, "failed to register thermal zone\n");
|
||||||
ret = PTR_ERR(sensor->tzd);
|
ret = PTR_ERR(sensor->tzd);
|
||||||
|
|
|
@ -614,9 +614,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
free_sysfs:
|
free_sysfs:
|
||||||
cleanup_odvp(priv);
|
cleanup_odvp(priv);
|
||||||
if (priv->data_vault) {
|
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
|
||||||
if (!ZERO_OR_NULL_PTR(priv->data_vault))
|
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
|
|
||||||
kfree(priv->data_vault);
|
kfree(priv->data_vault);
|
||||||
}
|
}
|
||||||
free_uuid:
|
free_uuid:
|
||||||
|
|
|
@ -373,18 +373,7 @@ static struct pci_driver proc_thermal_pci_driver = {
|
||||||
.driver.pm = &proc_thermal_pci_pm,
|
.driver.pm = &proc_thermal_pci_pm,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init proc_thermal_init(void)
|
module_pci_driver(proc_thermal_pci_driver);
|
||||||
{
|
|
||||||
return pci_register_driver(&proc_thermal_pci_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __exit proc_thermal_exit(void)
|
|
||||||
{
|
|
||||||
pci_unregister_driver(&proc_thermal_pci_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
module_init(proc_thermal_init);
|
|
||||||
module_exit(proc_thermal_exit);
|
|
||||||
|
|
||||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
||||||
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
|
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
|
||||||
|
|
|
@ -151,18 +151,7 @@ static struct pci_driver proc_thermal_pci_driver = {
|
||||||
.driver.pm = &proc_thermal_pci_pm,
|
.driver.pm = &proc_thermal_pci_pm,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init proc_thermal_init(void)
|
module_pci_driver(proc_thermal_pci_driver);
|
||||||
{
|
|
||||||
return pci_register_driver(&proc_thermal_pci_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __exit proc_thermal_exit(void)
|
|
||||||
{
|
|
||||||
pci_unregister_driver(&proc_thermal_pci_driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
module_init(proc_thermal_init);
|
|
||||||
module_exit(proc_thermal_exit);
|
|
||||||
|
|
||||||
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
|
||||||
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
|
MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
|
||||||
|
|
|
@ -62,8 +62,7 @@ static struct dentry *debug_dir;
|
||||||
static unsigned int set_target_ratio;
|
static unsigned int set_target_ratio;
|
||||||
static unsigned int current_ratio;
|
static unsigned int current_ratio;
|
||||||
static bool should_skip;
|
static bool should_skip;
|
||||||
static bool reduce_irq;
|
|
||||||
static atomic_t idle_wakeup_counter;
|
|
||||||
static unsigned int control_cpu; /* The cpu assigned to collect stat and update
|
static unsigned int control_cpu; /* The cpu assigned to collect stat and update
|
||||||
* control parameters. default to BSP but BSP
|
* control parameters. default to BSP but BSP
|
||||||
* can be offlined.
|
* can be offlined.
|
||||||
|
@ -285,9 +284,6 @@ static unsigned int get_compensation(int ratio)
|
||||||
cal_data[ratio + 1].steady_comp) / 3;
|
cal_data[ratio + 1].steady_comp) / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* REVISIT: simple penalty of double idle injection */
|
|
||||||
if (reduce_irq)
|
|
||||||
comp = ratio;
|
|
||||||
/* do not exceed limit */
|
/* do not exceed limit */
|
||||||
if (comp + ratio >= MAX_TARGET_RATIO)
|
if (comp + ratio >= MAX_TARGET_RATIO)
|
||||||
comp = MAX_TARGET_RATIO - ratio - 1;
|
comp = MAX_TARGET_RATIO - ratio - 1;
|
||||||
|
@ -301,13 +297,9 @@ static void adjust_compensation(int target_ratio, unsigned int win)
|
||||||
struct powerclamp_calibration_data *d = &cal_data[target_ratio];
|
struct powerclamp_calibration_data *d = &cal_data[target_ratio];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* adjust compensations if confidence level has not been reached or
|
* adjust compensations if confidence level has not been reached.
|
||||||
* there are too many wakeups during the last idle injection period, we
|
|
||||||
* cannot trust the data for compensation.
|
|
||||||
*/
|
*/
|
||||||
if (d->confidence >= CONFIDENCE_OK ||
|
if (d->confidence >= CONFIDENCE_OK)
|
||||||
atomic_read(&idle_wakeup_counter) >
|
|
||||||
win * num_online_cpus())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delta = set_target_ratio - current_ratio;
|
delta = set_target_ratio - current_ratio;
|
||||||
|
@ -347,14 +339,7 @@ static bool powerclamp_adjust_controls(unsigned int target_ratio,
|
||||||
tsc_last = tsc_now;
|
tsc_last = tsc_now;
|
||||||
|
|
||||||
adjust_compensation(target_ratio, win);
|
adjust_compensation(target_ratio, win);
|
||||||
/*
|
|
||||||
* too many external interrupts, set flag such
|
|
||||||
* that we can take measure later.
|
|
||||||
*/
|
|
||||||
reduce_irq = atomic_read(&idle_wakeup_counter) >=
|
|
||||||
2 * win * num_online_cpus();
|
|
||||||
|
|
||||||
atomic_set(&idle_wakeup_counter, 0);
|
|
||||||
/* if we are above target+guard, skip */
|
/* if we are above target+guard, skip */
|
||||||
return set_target_ratio + guard <= current_ratio;
|
return set_target_ratio + guard <= current_ratio;
|
||||||
}
|
}
|
||||||
|
@ -532,8 +517,10 @@ static int start_power_clamp(void)
|
||||||
|
|
||||||
/* prefer BSP */
|
/* prefer BSP */
|
||||||
control_cpu = 0;
|
control_cpu = 0;
|
||||||
if (!cpu_online(control_cpu))
|
if (!cpu_online(control_cpu)) {
|
||||||
control_cpu = smp_processor_id();
|
control_cpu = get_cpu();
|
||||||
|
put_cpu();
|
||||||
|
}
|
||||||
|
|
||||||
clamping = true;
|
clamping = true;
|
||||||
schedule_delayed_work(&poll_pkg_cstate_work, 0);
|
schedule_delayed_work(&poll_pkg_cstate_work, 0);
|
||||||
|
|
|
@ -139,9 +139,9 @@ static int k3_bgp_read_temp(struct k3_thermal_data *devdata,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int k3_thermal_get_temp(void *devdata, int *temp)
|
static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct k3_thermal_data *data = devdata;
|
struct k3_thermal_data *data = tz->devdata;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
ret = k3_bgp_read_temp(data, temp);
|
ret = k3_bgp_read_temp(data, temp);
|
||||||
|
@ -151,7 +151,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops k3_of_thermal_ops = {
|
static const struct thermal_zone_device_ops k3_of_thermal_ops = {
|
||||||
.get_temp = k3_thermal_get_temp,
|
.get_temp = k3_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,9 +213,9 @@ static int k3_bandgap_probe(struct platform_device *pdev)
|
||||||
writel(val, data[id].bgp->base + data[id].ctrl_offset);
|
writel(val, data[id].bgp->base + data[id].ctrl_offset);
|
||||||
|
|
||||||
data[id].tzd =
|
data[id].tzd =
|
||||||
devm_thermal_zone_of_sensor_register(dev, id,
|
devm_thermal_of_zone_register(dev, id,
|
||||||
&data[id],
|
&data[id],
|
||||||
&k3_of_thermal_ops);
|
&k3_of_thermal_ops);
|
||||||
if (IS_ERR(data[id].tzd)) {
|
if (IS_ERR(data[id].tzd)) {
|
||||||
dev_err(dev, "thermal zone device is NULL\n");
|
dev_err(dev, "thermal zone device is NULL\n");
|
||||||
ret = PTR_ERR(data[id].tzd);
|
ret = PTR_ERR(data[id].tzd);
|
||||||
|
|
|
@ -247,9 +247,9 @@ static inline int k3_bgp_read_temp(struct k3_thermal_data *devdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get temperature callback function for thermal zone */
|
/* Get temperature callback function for thermal zone */
|
||||||
static int k3_thermal_get_temp(void *devdata, int *temp)
|
static int k3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct k3_thermal_data *data = devdata;
|
struct k3_thermal_data *data = tz->devdata;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
ret = k3_bgp_read_temp(data, temp);
|
ret = k3_bgp_read_temp(data, temp);
|
||||||
|
@ -259,7 +259,7 @@ static int k3_thermal_get_temp(void *devdata, int *temp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops k3_of_thermal_ops = {
|
static const struct thermal_zone_device_ops k3_of_thermal_ops = {
|
||||||
.get_temp = k3_thermal_get_temp,
|
.get_temp = k3_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -474,10 +474,8 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
|
||||||
writel(val, data[id].bgp->cfg2_base + data[id].ctrl_offset);
|
writel(val, data[id].bgp->cfg2_base + data[id].ctrl_offset);
|
||||||
|
|
||||||
bgp->ts_data[id] = &data[id];
|
bgp->ts_data[id] = &data[id];
|
||||||
ti_thermal =
|
ti_thermal = devm_thermal_of_zone_register(bgp->dev, id, &data[id],
|
||||||
devm_thermal_zone_of_sensor_register(bgp->dev, id,
|
&k3_of_thermal_ops);
|
||||||
&data[id],
|
|
||||||
&k3_of_thermal_ops);
|
|
||||||
if (IS_ERR(ti_thermal)) {
|
if (IS_ERR(ti_thermal)) {
|
||||||
dev_err(bgp->dev, "thermal zone device is NULL\n");
|
dev_err(bgp->dev, "thermal zone device is NULL\n");
|
||||||
ret = PTR_ERR(ti_thermal);
|
ret = PTR_ERR(ti_thermal);
|
||||||
|
|
|
@ -44,9 +44,9 @@ struct max77620_therm_info {
|
||||||
* Return 0 on success otherwise error number to show reason of failure.
|
* Return 0 on success otherwise error number to show reason of failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int max77620_thermal_read_temp(void *data, int *temp)
|
static int max77620_thermal_read_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct max77620_therm_info *mtherm = data;
|
struct max77620_therm_info *mtherm = tz->devdata;
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ static int max77620_thermal_read_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops max77620_thermal_ops = {
|
static const struct thermal_zone_device_ops max77620_thermal_ops = {
|
||||||
.get_temp = max77620_thermal_read_temp,
|
.get_temp = max77620_thermal_read_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ static int max77620_thermal_probe(struct platform_device *pdev)
|
||||||
*/
|
*/
|
||||||
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
|
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
|
||||||
|
|
||||||
mtherm->tz_device = devm_thermal_zone_of_sensor_register(&pdev->dev, 0,
|
mtherm->tz_device = devm_thermal_of_zone_register(&pdev->dev, 0,
|
||||||
mtherm, &max77620_thermal_ops);
|
mtherm, &max77620_thermal_ops);
|
||||||
if (IS_ERR(mtherm->tz_device)) {
|
if (IS_ERR(mtherm->tz_device)) {
|
||||||
ret = PTR_ERR(mtherm->tz_device);
|
ret = PTR_ERR(mtherm->tz_device);
|
||||||
|
|
|
@ -679,9 +679,9 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mtk_read_temp(void *data, int *temperature)
|
static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature)
|
||||||
{
|
{
|
||||||
struct mtk_thermal *mt = data;
|
struct mtk_thermal *mt = tz->devdata;
|
||||||
int i;
|
int i;
|
||||||
int tempmax = INT_MIN;
|
int tempmax = INT_MIN;
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ static int mtk_read_temp(void *data, int *temperature)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops mtk_thermal_ops = {
|
static const struct thermal_zone_device_ops mtk_thermal_ops = {
|
||||||
.get_temp = mtk_read_temp,
|
.get_temp = mtk_read_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1082,8 +1082,8 @@ static int mtk_thermal_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, mt);
|
platform_set_drvdata(pdev, mt);
|
||||||
|
|
||||||
tzdev = devm_thermal_zone_of_sensor_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)) {
|
||||||
ret = PTR_ERR(tzdev);
|
ret = PTR_ERR(tzdev);
|
||||||
goto err_disable_clk_peri_therm;
|
goto err_disable_clk_peri_therm;
|
||||||
|
|
|
@ -357,9 +357,9 @@ static irqreturn_t adc_tm5_gen2_isr(int irq, void *data)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adc_tm5_get_temp(void *data, int *temp)
|
static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct adc_tm5_channel *channel = data;
|
struct adc_tm5_channel *channel = tz->devdata;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!channel || !channel->iio)
|
if (!channel || !channel->iio)
|
||||||
|
@ -639,9 +639,9 @@ config_fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adc_tm5_set_trips(void *data, int low, int high)
|
static int adc_tm5_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct adc_tm5_channel *channel = data;
|
struct adc_tm5_channel *channel = tz->devdata;
|
||||||
struct adc_tm5_chip *chip;
|
struct adc_tm5_chip *chip;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ static int adc_tm5_set_trips(void *data, int low, int high)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thermal_zone_of_device_ops adc_tm5_thermal_ops = {
|
static const struct thermal_zone_device_ops adc_tm5_thermal_ops = {
|
||||||
.get_temp = adc_tm5_get_temp,
|
.get_temp = adc_tm5_get_temp,
|
||||||
.set_trips = adc_tm5_set_trips,
|
.set_trips = adc_tm5_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -672,11 +672,10 @@ static int adc_tm5_register_tzd(struct adc_tm5_chip *adc_tm)
|
||||||
|
|
||||||
for (i = 0; i < adc_tm->nchannels; i++) {
|
for (i = 0; i < adc_tm->nchannels; i++) {
|
||||||
adc_tm->channels[i].chip = adc_tm;
|
adc_tm->channels[i].chip = adc_tm;
|
||||||
|
tzd = devm_thermal_of_zone_register(adc_tm->dev,
|
||||||
tzd = devm_thermal_zone_of_sensor_register(adc_tm->dev,
|
adc_tm->channels[i].channel,
|
||||||
adc_tm->channels[i].channel,
|
&adc_tm->channels[i],
|
||||||
&adc_tm->channels[i],
|
&adc_tm5_thermal_ops);
|
||||||
&adc_tm5_thermal_ops);
|
|
||||||
if (IS_ERR(tzd)) {
|
if (IS_ERR(tzd)) {
|
||||||
if (PTR_ERR(tzd) == -ENODEV) {
|
if (PTR_ERR(tzd) == -ENODEV) {
|
||||||
dev_warn(adc_tm->dev, "thermal sensor on channel %d is not used\n",
|
dev_warn(adc_tm->dev, "thermal sensor on channel %d is not used\n",
|
||||||
|
@ -1026,10 +1025,8 @@ static int adc_tm5_probe(struct platform_device *pdev)
|
||||||
adc_tm->base = reg;
|
adc_tm->base = reg;
|
||||||
|
|
||||||
irq = platform_get_irq(pdev, 0);
|
irq = platform_get_irq(pdev, 0);
|
||||||
if (irq < 0) {
|
if (irq < 0)
|
||||||
dev_err(dev, "get_irq failed: %d\n", irq);
|
|
||||||
return irq;
|
return irq;
|
||||||
}
|
|
||||||
|
|
||||||
ret = adc_tm5_get_dt_data(adc_tm, node);
|
ret = adc_tm5_get_dt_data(adc_tm, node);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
@ -186,9 +186,9 @@ static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qpnp_tm_get_temp(void *data, int *temp)
|
static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct qpnp_tm_chip *chip = data;
|
struct qpnp_tm_chip *chip = tz->devdata;
|
||||||
int ret, mili_celsius;
|
int ret, mili_celsius;
|
||||||
|
|
||||||
if (!temp)
|
if (!temp)
|
||||||
|
@ -263,9 +263,9 @@ skip:
|
||||||
return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg);
|
return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qpnp_tm_set_trip_temp(void *data, int trip, int temp)
|
static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp)
|
||||||
{
|
{
|
||||||
struct qpnp_tm_chip *chip = data;
|
struct qpnp_tm_chip *chip = tz->devdata;
|
||||||
const struct thermal_trip *trip_points;
|
const struct thermal_trip *trip_points;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ static int qpnp_tm_set_trip_temp(void *data, int trip, int temp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops qpnp_tm_sensor_ops = {
|
static const struct thermal_zone_device_ops qpnp_tm_sensor_ops = {
|
||||||
.get_temp = qpnp_tm_get_temp,
|
.get_temp = qpnp_tm_get_temp,
|
||||||
.set_trip_temp = qpnp_tm_set_trip_temp,
|
.set_trip_temp = qpnp_tm_set_trip_temp,
|
||||||
};
|
};
|
||||||
|
@ -446,7 +446,7 @@ static int qpnp_tm_probe(struct platform_device *pdev)
|
||||||
* read the trip points. get_temp() returns the default temperature
|
* read the trip points. get_temp() returns the default temperature
|
||||||
* before the hardware initialization is completed.
|
* before the hardware initialization is completed.
|
||||||
*/
|
*/
|
||||||
chip->tz_dev = devm_thermal_zone_of_sensor_register(
|
chip->tz_dev = devm_thermal_of_zone_register(
|
||||||
&pdev->dev, 0, chip, &qpnp_tm_sensor_ops);
|
&pdev->dev, 0, chip, &qpnp_tm_sensor_ops);
|
||||||
if (IS_ERR(chip->tz_dev)) {
|
if (IS_ERR(chip->tz_dev)) {
|
||||||
dev_err(&pdev->dev, "failed to register sensor\n");
|
dev_err(&pdev->dev, "failed to register sensor\n");
|
||||||
|
|
|
@ -532,9 +532,9 @@ static irqreturn_t tsens_irq_thread(int irq, void *data)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsens_set_trips(void *_sensor, int low, int high)
|
static int tsens_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct tsens_sensor *s = _sensor;
|
struct tsens_sensor *s = tz->devdata;
|
||||||
struct tsens_priv *priv = s->priv;
|
struct tsens_priv *priv = s->priv;
|
||||||
struct device *dev = priv->dev;
|
struct device *dev = priv->dev;
|
||||||
struct tsens_irq_data d;
|
struct tsens_irq_data d;
|
||||||
|
@ -925,9 +925,9 @@ err_put_device:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsens_get_temp(void *data, int *temp)
|
static int tsens_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct tsens_sensor *s = data;
|
struct tsens_sensor *s = tz->devdata;
|
||||||
struct tsens_priv *priv = s->priv;
|
struct tsens_priv *priv = s->priv;
|
||||||
|
|
||||||
return priv->ops->get_temp(s, temp);
|
return priv->ops->get_temp(s, temp);
|
||||||
|
@ -991,7 +991,7 @@ static const struct of_device_id tsens_table[] = {
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, tsens_table);
|
MODULE_DEVICE_TABLE(of, tsens_table);
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops tsens_of_ops = {
|
static const struct thermal_zone_device_ops tsens_of_ops = {
|
||||||
.get_temp = tsens_get_temp,
|
.get_temp = tsens_get_temp,
|
||||||
.set_trips = tsens_set_trips,
|
.set_trips = tsens_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -1044,9 +1044,9 @@ static int tsens_register(struct tsens_priv *priv)
|
||||||
|
|
||||||
for (i = 0; i < priv->num_sensors; i++) {
|
for (i = 0; i < priv->num_sensors; i++) {
|
||||||
priv->sensor[i].priv = priv;
|
priv->sensor[i].priv = priv;
|
||||||
tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id,
|
tzd = devm_thermal_of_zone_register(priv->dev, priv->sensor[i].hw_id,
|
||||||
&priv->sensor[i],
|
&priv->sensor[i],
|
||||||
&tsens_of_ops);
|
&tsens_of_ops);
|
||||||
if (IS_ERR(tzd))
|
if (IS_ERR(tzd))
|
||||||
continue;
|
continue;
|
||||||
priv->sensor[i].tzd = tzd;
|
priv->sensor[i].tzd = tzd;
|
||||||
|
|
|
@ -82,9 +82,9 @@ static struct qoriq_tmu_data *qoriq_sensor_to_data(struct qoriq_sensor *s)
|
||||||
return container_of(s, struct qoriq_tmu_data, sensor[s->id]);
|
return container_of(s, struct qoriq_tmu_data, sensor[s->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tmu_get_temp(void *p, int *temp)
|
static int tmu_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct qoriq_sensor *qsensor = p;
|
struct qoriq_sensor *qsensor = tz->devdata;
|
||||||
struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
|
struct qoriq_tmu_data *qdata = qoriq_sensor_to_data(qsensor);
|
||||||
u32 val;
|
u32 val;
|
||||||
/*
|
/*
|
||||||
|
@ -122,7 +122,7 @@ static int tmu_get_temp(void *p, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops tmu_tz_ops = {
|
static const struct thermal_zone_device_ops tmu_tz_ops = {
|
||||||
.get_temp = tmu_get_temp,
|
.get_temp = tmu_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev,
|
||||||
|
|
||||||
sensor->id = id;
|
sensor->id = id;
|
||||||
|
|
||||||
tzd = devm_thermal_zone_of_sensor_register(dev, id,
|
tzd = devm_thermal_of_zone_register(dev, id,
|
||||||
sensor,
|
sensor,
|
||||||
&tmu_tz_ops);
|
&tmu_tz_ops);
|
||||||
ret = PTR_ERR_OR_ZERO(tzd);
|
ret = PTR_ERR_OR_ZERO(tzd);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == -ENODEV)
|
if (ret == -ENODEV)
|
||||||
|
|
|
@ -164,9 +164,9 @@ static int rcar_gen3_thermal_round(int temp)
|
||||||
return result * RCAR3_THERMAL_GRAN;
|
return result * RCAR3_THERMAL_GRAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
|
static int rcar_gen3_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct rcar_gen3_thermal_tsc *tsc = devdata;
|
struct rcar_gen3_thermal_tsc *tsc = tz->devdata;
|
||||||
int mcelsius, val;
|
int mcelsius, val;
|
||||||
int reg;
|
int reg;
|
||||||
|
|
||||||
|
@ -203,9 +203,9 @@ static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc,
|
||||||
return INT_FIXPT(val);
|
return INT_FIXPT(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)
|
static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct rcar_gen3_thermal_tsc *tsc = devdata;
|
struct rcar_gen3_thermal_tsc *tsc = tz->devdata;
|
||||||
u32 irqmsk = 0;
|
u32 irqmsk = 0;
|
||||||
|
|
||||||
if (low != -INT_MAX) {
|
if (low != -INT_MAX) {
|
||||||
|
@ -225,7 +225,7 @@ static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = {
|
static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = {
|
||||||
.get_temp = rcar_gen3_thermal_get_temp,
|
.get_temp = rcar_gen3_thermal_get_temp,
|
||||||
.set_trips = rcar_gen3_thermal_set_trips,
|
.set_trips = rcar_gen3_thermal_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -508,8 +508,8 @@ 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];
|
||||||
|
|
||||||
zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
|
zone = devm_thermal_of_zone_register(dev, i, tsc,
|
||||||
&rcar_gen3_tz_of_ops);
|
&rcar_gen3_tz_of_ops);
|
||||||
if (IS_ERR(zone)) {
|
if (IS_ERR(zone)) {
|
||||||
dev_err(dev, "Sensor %u: Can't register thermal zone\n", i);
|
dev_err(dev, "Sensor %u: Can't register thermal zone\n", i);
|
||||||
ret = PTR_ERR(zone);
|
ret = PTR_ERR(zone);
|
||||||
|
@ -560,7 +560,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev)
|
||||||
|
|
||||||
priv->thermal_init(tsc);
|
priv->thermal_init(tsc);
|
||||||
if (zone->ops->set_trips)
|
if (zone->ops->set_trips)
|
||||||
rcar_gen3_thermal_set_trips(tsc, zone->prev_low_trip,
|
rcar_gen3_thermal_set_trips(zone, zone->prev_low_trip,
|
||||||
zone->prev_high_trip);
|
zone->prev_high_trip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,13 +271,6 @@ static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rcar_thermal_of_get_temp(void *data, int *temp)
|
|
||||||
{
|
|
||||||
struct rcar_thermal_priv *priv = data;
|
|
||||||
|
|
||||||
return rcar_thermal_get_current_temp(priv, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
|
static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
|
||||||
{
|
{
|
||||||
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
|
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
|
||||||
|
@ -323,8 +316,8 @@ static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = {
|
static struct thermal_zone_device_ops rcar_thermal_zone_of_ops = {
|
||||||
.get_temp = rcar_thermal_of_get_temp,
|
.get_temp = rcar_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
|
static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
|
||||||
|
@ -534,7 +527,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
|
||||||
goto error_unregister;
|
goto error_unregister;
|
||||||
|
|
||||||
if (chip->use_of_thermal) {
|
if (chip->use_of_thermal) {
|
||||||
priv->zone = devm_thermal_zone_of_sensor_register(
|
priv->zone = devm_thermal_of_zone_register(
|
||||||
dev, i, priv,
|
dev, i, priv,
|
||||||
&rcar_thermal_zone_of_ops);
|
&rcar_thermal_zone_of_ops);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1211,9 +1211,9 @@ static irqreturn_t rockchip_thermal_alarm_irq_thread(int irq, void *dev)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rockchip_thermal_set_trips(void *_sensor, int low, int high)
|
static int rockchip_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct rockchip_thermal_sensor *sensor = _sensor;
|
struct rockchip_thermal_sensor *sensor = tz->devdata;
|
||||||
struct rockchip_thermal_data *thermal = sensor->thermal;
|
struct rockchip_thermal_data *thermal = sensor->thermal;
|
||||||
const struct rockchip_tsadc_chip *tsadc = thermal->chip;
|
const struct rockchip_tsadc_chip *tsadc = thermal->chip;
|
||||||
|
|
||||||
|
@ -1224,9 +1224,9 @@ static int rockchip_thermal_set_trips(void *_sensor, int low, int high)
|
||||||
sensor->id, thermal->regs, high);
|
sensor->id, thermal->regs, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
|
static int rockchip_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)
|
||||||
{
|
{
|
||||||
struct rockchip_thermal_sensor *sensor = _sensor;
|
struct rockchip_thermal_sensor *sensor = tz->devdata;
|
||||||
struct rockchip_thermal_data *thermal = sensor->thermal;
|
struct rockchip_thermal_data *thermal = sensor->thermal;
|
||||||
const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
|
const struct rockchip_tsadc_chip *tsadc = sensor->thermal->chip;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -1239,7 +1239,7 @@ static int rockchip_thermal_get_temp(void *_sensor, int *out_temp)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops rockchip_of_thermal_ops = {
|
static const struct thermal_zone_device_ops rockchip_of_thermal_ops = {
|
||||||
.get_temp = rockchip_thermal_get_temp,
|
.get_temp = rockchip_thermal_get_temp,
|
||||||
.set_trips = rockchip_thermal_set_trips,
|
.set_trips = rockchip_thermal_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -1326,8 +1326,8 @@ rockchip_thermal_register_sensor(struct platform_device *pdev,
|
||||||
|
|
||||||
sensor->thermal = thermal;
|
sensor->thermal = thermal;
|
||||||
sensor->id = id;
|
sensor->id = id;
|
||||||
sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, id,
|
sensor->tzd = devm_thermal_of_zone_register(&pdev->dev, id, sensor,
|
||||||
sensor, &rockchip_of_thermal_ops);
|
&rockchip_of_thermal_ops);
|
||||||
if (IS_ERR(sensor->tzd)) {
|
if (IS_ERR(sensor->tzd)) {
|
||||||
error = PTR_ERR(sensor->tzd);
|
error = PTR_ERR(sensor->tzd);
|
||||||
dev_err(&pdev->dev, "failed to register sensor %d: %d\n",
|
dev_err(&pdev->dev, "failed to register sensor %d: %d\n",
|
||||||
|
|
|
@ -73,9 +73,9 @@ static inline void rzg2l_thermal_write(struct rzg2l_thermal_priv *priv, u32 reg,
|
||||||
iowrite32(data, priv->base + reg);
|
iowrite32(data, priv->base + reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rzg2l_thermal_get_temp(void *devdata, int *temp)
|
static int rzg2l_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct rzg2l_thermal_priv *priv = devdata;
|
struct rzg2l_thermal_priv *priv = tz->devdata;
|
||||||
u32 result = 0, dsensor, ts_code_ave;
|
u32 result = 0, dsensor, ts_code_ave;
|
||||||
int val, i;
|
int val, i;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ static int rzg2l_thermal_get_temp(void *devdata, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops rzg2l_tz_of_ops = {
|
static const struct thermal_zone_device_ops rzg2l_tz_of_ops = {
|
||||||
.get_temp = rzg2l_thermal_get_temp,
|
.get_temp = rzg2l_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,8 +207,8 @@ static int rzg2l_thermal_probe(struct platform_device *pdev)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
zone = devm_thermal_zone_of_sensor_register(dev, 0, priv,
|
zone = devm_thermal_of_zone_register(dev, 0, priv,
|
||||||
&rzg2l_tz_of_ops);
|
&rzg2l_tz_of_ops);
|
||||||
if (IS_ERR(zone)) {
|
if (IS_ERR(zone)) {
|
||||||
dev_err(dev, "Can't register thermal zone");
|
dev_err(dev, "Can't register thermal zone");
|
||||||
ret = PTR_ERR(zone);
|
ret = PTR_ERR(zone);
|
||||||
|
|
|
@ -650,9 +650,9 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
|
||||||
writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
|
writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int exynos_get_temp(void *p, int *temp)
|
static int exynos_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct exynos_tmu_data *data = p;
|
struct exynos_tmu_data *data = tz->devdata;
|
||||||
int value, ret = 0;
|
int value, ret = 0;
|
||||||
|
|
||||||
if (!data || !data->tmu_read)
|
if (!data || !data->tmu_read)
|
||||||
|
@ -728,9 +728,9 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
|
||||||
writel(val, data->base + emul_con);
|
writel(val, data->base + emul_con);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int exynos_tmu_set_emulation(void *drv_data, int temp)
|
static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)
|
||||||
{
|
{
|
||||||
struct exynos_tmu_data *data = drv_data;
|
struct exynos_tmu_data *data = tz->devdata;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
if (data->soc == SOC_ARCH_EXYNOS4210)
|
if (data->soc == SOC_ARCH_EXYNOS4210)
|
||||||
|
@ -750,7 +750,7 @@ out:
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define exynos4412_tmu_set_emulation NULL
|
#define exynos4412_tmu_set_emulation NULL
|
||||||
static int exynos_tmu_set_emulation(void *drv_data, int temp)
|
static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp)
|
||||||
{ return -EINVAL; }
|
{ return -EINVAL; }
|
||||||
#endif /* CONFIG_THERMAL_EMULATION */
|
#endif /* CONFIG_THERMAL_EMULATION */
|
||||||
|
|
||||||
|
@ -997,7 +997,7 @@ static int exynos_map_dt_data(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops exynos_sensor_ops = {
|
static const struct thermal_zone_device_ops exynos_sensor_ops = {
|
||||||
.get_temp = exynos_get_temp,
|
.get_temp = exynos_get_temp,
|
||||||
.set_emul_temp = exynos_tmu_set_emulation,
|
.set_emul_temp = exynos_tmu_set_emulation,
|
||||||
};
|
};
|
||||||
|
@ -1091,8 +1091,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
|
||||||
* data->tzd must be registered before calling exynos_tmu_initialize(),
|
* data->tzd must be registered before calling exynos_tmu_initialize(),
|
||||||
* requesting irq and calling exynos_tmu_control().
|
* requesting irq and calling exynos_tmu_control().
|
||||||
*/
|
*/
|
||||||
data->tzd = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
|
data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data,
|
||||||
&exynos_sensor_ops);
|
&exynos_sensor_ops);
|
||||||
if (IS_ERR(data->tzd)) {
|
if (IS_ERR(data->tzd)) {
|
||||||
ret = PTR_ERR(data->tzd);
|
ret = PTR_ERR(data->tzd);
|
||||||
if (ret != -EPROBE_DEFER)
|
if (ret != -EPROBE_DEFER)
|
||||||
|
@ -1104,21 +1104,19 @@ static int exynos_tmu_probe(struct platform_device *pdev)
|
||||||
ret = exynos_tmu_initialize(pdev);
|
ret = exynos_tmu_initialize(pdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "Failed to initialize TMU\n");
|
dev_err(&pdev->dev, "Failed to initialize TMU\n");
|
||||||
goto err_thermal;
|
goto err_sclk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
|
ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
|
||||||
IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
|
IRQF_TRIGGER_RISING | IRQF_SHARED, dev_name(&pdev->dev), data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
|
dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq);
|
||||||
goto err_thermal;
|
goto err_sclk;
|
||||||
}
|
}
|
||||||
|
|
||||||
exynos_tmu_control(pdev, true);
|
exynos_tmu_control(pdev, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_thermal:
|
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd);
|
|
||||||
err_sclk:
|
err_sclk:
|
||||||
clk_disable_unprepare(data->sclk);
|
clk_disable_unprepare(data->sclk);
|
||||||
err_clk:
|
err_clk:
|
||||||
|
@ -1136,9 +1134,7 @@ err_sensor:
|
||||||
static int exynos_tmu_remove(struct platform_device *pdev)
|
static int exynos_tmu_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
|
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
|
||||||
struct thermal_zone_device *tzd = data->tzd;
|
|
||||||
|
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, tzd);
|
|
||||||
exynos_tmu_control(pdev, false);
|
exynos_tmu_control(pdev, false);
|
||||||
|
|
||||||
clk_disable_unprepare(data->sclk);
|
clk_disable_unprepare(data->sclk);
|
||||||
|
|
|
@ -204,9 +204,9 @@ static int sprd_thm_temp_to_rawdata(int temp, struct sprd_thermal_sensor *sen)
|
||||||
return clamp(val, val, (u32)(SPRD_THM_RAW_DATA_HIGH - 1));
|
return clamp(val, val, (u32)(SPRD_THM_RAW_DATA_HIGH - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sprd_thm_read_temp(void *devdata, int *temp)
|
static int sprd_thm_read_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct sprd_thermal_sensor *sen = devdata;
|
struct sprd_thermal_sensor *sen = tz->devdata;
|
||||||
u32 data;
|
u32 data;
|
||||||
|
|
||||||
data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
|
data = readl(sen->data->base + SPRD_THM_TEMP(sen->id)) &
|
||||||
|
@ -217,7 +217,7 @@ static int sprd_thm_read_temp(void *devdata, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops sprd_thm_ops = {
|
static const struct thermal_zone_device_ops sprd_thm_ops = {
|
||||||
.get_temp = sprd_thm_read_temp,
|
.get_temp = sprd_thm_read_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -408,10 +408,10 @@ static int sprd_thm_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
sprd_thm_sensor_init(thm, sen);
|
sprd_thm_sensor_init(thm, sen);
|
||||||
|
|
||||||
sen->tzd = devm_thermal_zone_of_sensor_register(sen->dev,
|
sen->tzd = devm_thermal_of_zone_register(sen->dev,
|
||||||
sen->id,
|
sen->id,
|
||||||
sen,
|
sen,
|
||||||
&sprd_thm_ops);
|
&sprd_thm_ops);
|
||||||
if (IS_ERR(sen->tzd)) {
|
if (IS_ERR(sen->tzd)) {
|
||||||
dev_err(&pdev->dev, "register thermal zone failed %d\n",
|
dev_err(&pdev->dev, "register thermal zone failed %d\n",
|
||||||
sen->id);
|
sen->id);
|
||||||
|
@ -523,8 +523,8 @@ static int sprd_thm_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
for (i = 0; i < thm->nr_sensors; i++) {
|
for (i = 0; i < thm->nr_sensors; i++) {
|
||||||
sprd_thm_toggle_sensor(thm->sensor[i], false);
|
sprd_thm_toggle_sensor(thm->sensor[i], false);
|
||||||
devm_thermal_zone_of_sensor_unregister(&pdev->dev,
|
devm_thermal_of_zone_unregister(&pdev->dev,
|
||||||
thm->sensor[i]->tzd);
|
thm->sensor[i]->tzd);
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_disable_unprepare(thm->clk);
|
clk_disable_unprepare(thm->clk);
|
||||||
|
|
|
@ -302,9 +302,9 @@ static int stm_disable_irq(struct stm_thermal_sensor *sensor)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm_thermal_set_trips(void *data, int low, int high)
|
static int stm_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
struct stm_thermal_sensor *sensor = data;
|
struct stm_thermal_sensor *sensor = tz->devdata;
|
||||||
u32 itr1, th;
|
u32 itr1, th;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -350,9 +350,9 @@ static int stm_thermal_set_trips(void *data, int low, int high)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback to get temperature from HW */
|
/* Callback to get temperature from HW */
|
||||||
static int stm_thermal_get_temp(void *data, int *temp)
|
static int stm_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct stm_thermal_sensor *sensor = data;
|
struct stm_thermal_sensor *sensor = tz->devdata;
|
||||||
u32 periods;
|
u32 periods;
|
||||||
int freqM, ret;
|
int freqM, ret;
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ static int stm_thermal_resume(struct device *dev)
|
||||||
static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops,
|
static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops,
|
||||||
stm_thermal_suspend, stm_thermal_resume);
|
stm_thermal_suspend, stm_thermal_resume);
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops stm_tz_ops = {
|
static const struct thermal_zone_device_ops stm_tz_ops = {
|
||||||
.get_temp = stm_thermal_get_temp,
|
.get_temp = stm_thermal_get_temp,
|
||||||
.set_trips = stm_thermal_set_trips,
|
.set_trips = stm_thermal_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -539,9 +539,9 @@ static int stm_thermal_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor->th_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0,
|
sensor->th_dev = devm_thermal_of_zone_register(&pdev->dev, 0,
|
||||||
sensor,
|
sensor,
|
||||||
&stm_tz_ops);
|
&stm_tz_ops);
|
||||||
|
|
||||||
if (IS_ERR(sensor->th_dev)) {
|
if (IS_ERR(sensor->th_dev)) {
|
||||||
dev_err(&pdev->dev, "%s: thermal zone sensor registering KO\n",
|
dev_err(&pdev->dev, "%s: thermal zone sensor registering KO\n",
|
||||||
|
@ -572,7 +572,6 @@ static int stm_thermal_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_tz:
|
err_tz:
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, sensor->th_dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +581,6 @@ static int stm_thermal_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
stm_thermal_sensor_off(sensor);
|
stm_thermal_sensor_off(sensor);
|
||||||
thermal_remove_hwmon_sysfs(sensor->th_dev);
|
thermal_remove_hwmon_sysfs(sensor->th_dev);
|
||||||
thermal_zone_of_sensor_unregister(&pdev->dev, sensor->th_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,9 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev,
|
||||||
return -1590 * reg / 10 + 276000;
|
return -1590 * reg / 10 + 276000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sun8i_ths_get_temp(void *data, int *temp)
|
static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct tsensor *s = data;
|
struct tsensor *s = tz->devdata;
|
||||||
struct ths_device *tmdev = s->tmdev;
|
struct ths_device *tmdev = s->tmdev;
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ static int sun8i_ths_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops ths_ops = {
|
static const struct thermal_zone_device_ops ths_ops = {
|
||||||
.get_temp = sun8i_ths_get_temp,
|
.get_temp = sun8i_ths_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -468,10 +468,10 @@ static int sun8i_ths_register(struct ths_device *tmdev)
|
||||||
tmdev->sensor[i].tmdev = tmdev;
|
tmdev->sensor[i].tmdev = tmdev;
|
||||||
tmdev->sensor[i].id = i;
|
tmdev->sensor[i].id = i;
|
||||||
tmdev->sensor[i].tzd =
|
tmdev->sensor[i].tzd =
|
||||||
devm_thermal_zone_of_sensor_register(tmdev->dev,
|
devm_thermal_of_zone_register(tmdev->dev,
|
||||||
i,
|
i,
|
||||||
&tmdev->sensor[i],
|
&tmdev->sensor[i],
|
||||||
&ths_ops);
|
&ths_ops);
|
||||||
if (IS_ERR(tmdev->sensor[i].tzd))
|
if (IS_ERR(tmdev->sensor[i].tzd))
|
||||||
return PTR_ERR(tmdev->sensor[i].tzd);
|
return PTR_ERR(tmdev->sensor[i].tzd);
|
||||||
|
|
||||||
|
|
|
@ -421,9 +421,9 @@ static int translate_temp(u16 val)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_thermctl_get_temp(void *data, int *out_temp)
|
static int tegra_thermctl_get_temp(struct thermal_zone_device *tz, int *out_temp)
|
||||||
{
|
{
|
||||||
struct tegra_thermctl_zone *zone = data;
|
struct tegra_thermctl_zone *zone = tz->devdata;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
val = readl(zone->reg);
|
val = readl(zone->reg);
|
||||||
|
@ -582,10 +582,9 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_thermctl_set_trip_temp(void *data, int trip, int temp)
|
static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp)
|
||||||
{
|
{
|
||||||
struct tegra_thermctl_zone *zone = data;
|
struct tegra_thermctl_zone *zone = tz->devdata;
|
||||||
struct thermal_zone_device *tz = zone->tz;
|
|
||||||
struct tegra_soctherm *ts = zone->ts;
|
struct tegra_soctherm *ts = zone->ts;
|
||||||
const struct tegra_tsensor_group *sg = zone->sg;
|
const struct tegra_tsensor_group *sg = zone->sg;
|
||||||
struct device *dev = zone->dev;
|
struct device *dev = zone->dev;
|
||||||
|
@ -657,9 +656,9 @@ static void thermal_irq_disable(struct tegra_thermctl_zone *zn)
|
||||||
mutex_unlock(&zn->ts->thermctl_lock);
|
mutex_unlock(&zn->ts->thermctl_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_thermctl_set_trips(void *data, int lo, int hi)
|
static int tegra_thermctl_set_trips(struct thermal_zone_device *tz, int lo, int hi)
|
||||||
{
|
{
|
||||||
struct tegra_thermctl_zone *zone = data;
|
struct tegra_thermctl_zone *zone = tz->devdata;
|
||||||
u32 r;
|
u32 r;
|
||||||
|
|
||||||
thermal_irq_disable(zone);
|
thermal_irq_disable(zone);
|
||||||
|
@ -682,7 +681,7 @@ static int tegra_thermctl_set_trips(void *data, int lo, int hi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = {
|
static const struct thermal_zone_device_ops tegra_of_thermal_ops = {
|
||||||
.get_temp = tegra_thermctl_get_temp,
|
.get_temp = tegra_thermctl_get_temp,
|
||||||
.set_trip_temp = tegra_thermctl_set_trip_temp,
|
.set_trip_temp = tegra_thermctl_set_trip_temp,
|
||||||
.set_trips = tegra_thermctl_set_trips,
|
.set_trips = tegra_thermctl_set_trips,
|
||||||
|
@ -2194,9 +2193,9 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
|
||||||
zone->sg = soc->ttgs[i];
|
zone->sg = soc->ttgs[i];
|
||||||
zone->ts = tegra;
|
zone->ts = tegra;
|
||||||
|
|
||||||
z = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
z = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
soc->ttgs[i]->id, zone,
|
soc->ttgs[i]->id, zone,
|
||||||
&tegra_of_thermal_ops);
|
&tegra_of_thermal_ops);
|
||||||
if (IS_ERR(z)) {
|
if (IS_ERR(z)) {
|
||||||
err = PTR_ERR(z);
|
err = PTR_ERR(z);
|
||||||
dev_err(&pdev->dev, "failed to register sensor: %d\n",
|
dev_err(&pdev->dev, "failed to register sensor: %d\n",
|
||||||
|
|
|
@ -30,9 +30,9 @@ struct tegra_bpmp_thermal {
|
||||||
struct tegra_bpmp_thermal_zone **zones;
|
struct tegra_bpmp_thermal_zone **zones;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)
|
static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *zone,
|
||||||
|
int *out_temp)
|
||||||
{
|
{
|
||||||
struct tegra_bpmp_thermal_zone *zone = data;
|
|
||||||
struct mrq_thermal_host_to_bpmp_request req;
|
struct mrq_thermal_host_to_bpmp_request req;
|
||||||
union mrq_thermal_bpmp_to_host_response reply;
|
union mrq_thermal_bpmp_to_host_response reply;
|
||||||
struct tegra_bpmp_message msg;
|
struct tegra_bpmp_message msg;
|
||||||
|
@ -60,9 +60,14 @@ static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_bpmp_thermal_set_trips(void *data, int low, int high)
|
static int tegra_bpmp_thermal_get_temp(struct thermal_zone_device *tz, int *out_temp)
|
||||||
{
|
{
|
||||||
struct tegra_bpmp_thermal_zone *zone = data;
|
return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tegra_bpmp_thermal_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
|
{
|
||||||
|
struct tegra_bpmp_thermal_zone *zone = tz->devdata;
|
||||||
struct mrq_thermal_host_to_bpmp_request req;
|
struct mrq_thermal_host_to_bpmp_request req;
|
||||||
struct tegra_bpmp_message msg;
|
struct tegra_bpmp_message msg;
|
||||||
int err;
|
int err;
|
||||||
|
@ -157,7 +162,7 @@ static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops tegra_bpmp_of_thermal_ops = {
|
static const struct thermal_zone_device_ops tegra_bpmp_of_thermal_ops = {
|
||||||
.get_temp = tegra_bpmp_thermal_get_temp,
|
.get_temp = tegra_bpmp_thermal_get_temp,
|
||||||
.set_trips = tegra_bpmp_thermal_set_trips,
|
.set_trips = tegra_bpmp_thermal_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -200,13 +205,13 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev)
|
||||||
zone->idx = i;
|
zone->idx = i;
|
||||||
zone->tegra = tegra;
|
zone->tegra = tegra;
|
||||||
|
|
||||||
err = tegra_bpmp_thermal_get_temp(zone, &temp);
|
err = __tegra_bpmp_thermal_get_temp(zone, &temp);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
devm_kfree(&pdev->dev, zone);
|
devm_kfree(&pdev->dev, zone);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tzd = devm_thermal_zone_of_sensor_register(
|
tzd = devm_thermal_of_zone_register(
|
||||||
&pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);
|
&pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);
|
||||||
if (IS_ERR(tzd)) {
|
if (IS_ERR(tzd)) {
|
||||||
if (PTR_ERR(tzd) == -EPROBE_DEFER)
|
if (PTR_ERR(tzd) == -EPROBE_DEFER)
|
||||||
|
|
|
@ -159,9 +159,9 @@ static void devm_tegra_tsensor_hw_disable(void *data)
|
||||||
tegra_tsensor_hw_disable(ts);
|
tegra_tsensor_hw_disable(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_tsensor_get_temp(void *data, int *temp)
|
static int tegra_tsensor_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
const struct tegra_tsensor_channel *tsc = data;
|
const struct tegra_tsensor_channel *tsc = tz->devdata;
|
||||||
const struct tegra_tsensor *ts = tsc->ts;
|
const struct tegra_tsensor *ts = tsc->ts;
|
||||||
int err, c1, c2, c3, c4, counter;
|
int err, c1, c2, c3, c4, counter;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
@ -217,9 +217,9 @@ static int tegra_tsensor_temp_to_counter(const struct tegra_tsensor *ts, int tem
|
||||||
return DIV_ROUND_CLOSEST(c2 * 1000000 - ts->calib.b, ts->calib.a);
|
return DIV_ROUND_CLOSEST(c2 * 1000000 - ts->calib.b, ts->calib.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tegra_tsensor_set_trips(void *data, int low, int high)
|
static int tegra_tsensor_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||||
{
|
{
|
||||||
const struct tegra_tsensor_channel *tsc = data;
|
const struct tegra_tsensor_channel *tsc = tz->devdata;
|
||||||
const struct tegra_tsensor *ts = tsc->ts;
|
const struct tegra_tsensor *ts = tsc->ts;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ static int tegra_tsensor_set_trips(void *data, int low, int high)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops ops = {
|
static const struct thermal_zone_device_ops ops = {
|
||||||
.get_temp = tegra_tsensor_get_temp,
|
.get_temp = tegra_tsensor_get_temp,
|
||||||
.set_trips = tegra_tsensor_set_trips,
|
.set_trips = tegra_tsensor_set_trips,
|
||||||
};
|
};
|
||||||
|
@ -516,7 +516,7 @@ static int tegra_tsensor_register_channel(struct tegra_tsensor *ts,
|
||||||
tsc->id = id;
|
tsc->id = id;
|
||||||
tsc->regs = ts->regs + 0x40 * (hw_id + 1);
|
tsc->regs = ts->regs + 0x40 * (hw_id + 1);
|
||||||
|
|
||||||
tsc->tzd = devm_thermal_zone_of_sensor_register(ts->dev, id, tsc, &ops);
|
tsc->tzd = devm_thermal_of_zone_register(ts->dev, id, tsc, &ops);
|
||||||
if (IS_ERR(tsc->tzd)) {
|
if (IS_ERR(tsc->tzd)) {
|
||||||
if (PTR_ERR(tsc->tzd) != -ENODEV)
|
if (PTR_ERR(tsc->tzd) != -ENODEV)
|
||||||
return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd),
|
return dev_err_probe(ts->dev, PTR_ERR(tsc->tzd),
|
||||||
|
|
|
@ -52,9 +52,9 @@ static int gadc_thermal_adc_to_temp(struct gadc_thermal_info *gti, int val)
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gadc_thermal_get_temp(void *data, int *temp)
|
static int gadc_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct gadc_thermal_info *gti = data;
|
struct gadc_thermal_info *gti = tz->devdata;
|
||||||
int val;
|
int val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ static int gadc_thermal_get_temp(void *data, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops gadc_thermal_ops = {
|
static const struct thermal_zone_device_ops gadc_thermal_ops = {
|
||||||
.get_temp = gadc_thermal_get_temp,
|
.get_temp = gadc_thermal_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -143,8 +143,8 @@ static int gadc_thermal_probe(struct platform_device *pdev)
|
||||||
gti->dev = &pdev->dev;
|
gti->dev = &pdev->dev;
|
||||||
platform_set_drvdata(pdev, gti);
|
platform_set_drvdata(pdev, gti);
|
||||||
|
|
||||||
gti->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, gti,
|
gti->tz_dev = devm_thermal_of_zone_register(&pdev->dev, 0, gti,
|
||||||
&gadc_thermal_ops);
|
&gadc_thermal_ops);
|
||||||
if (IS_ERR(gti->tz_dev)) {
|
if (IS_ERR(gti->tz_dev)) {
|
||||||
ret = PTR_ERR(gti->tz_dev);
|
ret = PTR_ERR(gti->tz_dev);
|
||||||
if (ret != -EPROBE_DEFER)
|
if (ret != -EPROBE_DEFER)
|
||||||
|
|
|
@ -295,27 +295,14 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
|
||||||
cancel_delayed_work(&tz->poll_queue);
|
cancel_delayed_work(&tz->poll_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool should_stop_polling(struct thermal_zone_device *tz)
|
|
||||||
{
|
|
||||||
return !thermal_zone_device_is_enabled(tz);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void monitor_thermal_zone(struct thermal_zone_device *tz)
|
static void monitor_thermal_zone(struct thermal_zone_device *tz)
|
||||||
{
|
{
|
||||||
bool stop;
|
if (tz->mode != THERMAL_DEVICE_ENABLED)
|
||||||
|
|
||||||
stop = should_stop_polling(tz);
|
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
|
|
||||||
if (!stop && tz->passive)
|
|
||||||
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
|
|
||||||
else if (!stop && tz->polling_delay_jiffies)
|
|
||||||
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
|
|
||||||
else
|
|
||||||
thermal_zone_device_set_polling(tz, 0);
|
thermal_zone_device_set_polling(tz, 0);
|
||||||
|
else if (tz->passive)
|
||||||
mutex_unlock(&tz->lock);
|
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
|
||||||
|
else if (tz->polling_delay_jiffies)
|
||||||
|
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
|
static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
|
||||||
|
@ -383,18 +370,13 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
|
||||||
handle_critical_trips(tz, trip, trip_temp, type);
|
handle_critical_trips(tz, trip, trip_temp, type);
|
||||||
else
|
else
|
||||||
handle_non_critical_trips(tz, trip);
|
handle_non_critical_trips(tz, trip);
|
||||||
/*
|
|
||||||
* Alright, we handled this trip successfully.
|
|
||||||
* So, start monitoring again.
|
|
||||||
*/
|
|
||||||
monitor_thermal_zone(tz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_temperature(struct thermal_zone_device *tz)
|
static void update_temperature(struct thermal_zone_device *tz)
|
||||||
{
|
{
|
||||||
int temp, ret;
|
int temp, ret;
|
||||||
|
|
||||||
ret = thermal_zone_get_temp(tz, &temp);
|
ret = __thermal_zone_get_temp(tz, &temp);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret != -EAGAIN)
|
if (ret != -EAGAIN)
|
||||||
dev_warn(&tz->device,
|
dev_warn(&tz->device,
|
||||||
|
@ -403,10 +385,8 @@ static void update_temperature(struct thermal_zone_device *tz)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
|
||||||
tz->last_temperature = tz->temperature;
|
tz->last_temperature = tz->temperature;
|
||||||
tz->temperature = temp;
|
tz->temperature = temp;
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
trace_thermal_temperature(tz);
|
trace_thermal_temperature(tz);
|
||||||
|
|
||||||
|
@ -469,15 +449,9 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_disable);
|
||||||
|
|
||||||
int thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
|
int thermal_zone_device_is_enabled(struct thermal_zone_device *tz)
|
||||||
{
|
{
|
||||||
enum thermal_device_mode mode;
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
return tz->mode == THERMAL_DEVICE_ENABLED;
|
||||||
|
|
||||||
mode = tz->mode;
|
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return mode == THERMAL_DEVICE_ENABLED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void thermal_zone_device_update(struct thermal_zone_device *tz,
|
void thermal_zone_device_update(struct thermal_zone_device *tz,
|
||||||
|
@ -485,9 +459,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (should_stop_polling(tz))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (atomic_read(&in_suspend))
|
if (atomic_read(&in_suspend))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -495,14 +466,23 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
|
||||||
"'get_temp' ops set\n", __func__))
|
"'get_temp' ops set\n", __func__))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mutex_lock(&tz->lock);
|
||||||
|
|
||||||
|
if (!thermal_zone_device_is_enabled(tz))
|
||||||
|
goto out;
|
||||||
|
|
||||||
update_temperature(tz);
|
update_temperature(tz);
|
||||||
|
|
||||||
thermal_zone_set_trips(tz);
|
__thermal_zone_set_trips(tz);
|
||||||
|
|
||||||
tz->notify_event = event;
|
tz->notify_event = event;
|
||||||
|
|
||||||
for (count = 0; count < tz->num_trips; count++)
|
for (count = 0; count < tz->num_trips; count++)
|
||||||
handle_thermal_trip(tz, count);
|
handle_thermal_trip(tz, count);
|
||||||
|
|
||||||
|
monitor_thermal_zone(tz);
|
||||||
|
out:
|
||||||
|
mutex_unlock(&tz->lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
|
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
|
||||||
|
|
||||||
|
@ -1212,7 +1192,20 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_trips > THERMAL_MAX_TRIPS || num_trips < 0 || mask >> num_trips) {
|
/*
|
||||||
|
* Max trip count can't exceed 31 as the "mask >> num_trips" condition.
|
||||||
|
* For example, shifting by 32 will result in compiler warning:
|
||||||
|
* warning: right shift count >= width of type [-Wshift-count- overflow]
|
||||||
|
*
|
||||||
|
* Also "mask >> num_trips" will always be true with 32 bit shift.
|
||||||
|
* E.g. mask = 0x80000000 for trip id 31 to be RW. Then
|
||||||
|
* mask >> 32 = 0x80000000
|
||||||
|
* This will result in failure for the below condition.
|
||||||
|
*
|
||||||
|
* Check will be true when the bit 31 of the mask is set.
|
||||||
|
* 32 bit shift will cause overflow of 4 byte integer.
|
||||||
|
*/
|
||||||
|
if (num_trips > (BITS_PER_TYPE(int) - 1) || num_trips < 0 || mask >> num_trips) {
|
||||||
pr_err("Incorrect number of thermal trips\n");
|
pr_err("Incorrect number of thermal trips\n");
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1232,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
|
||||||
}
|
}
|
||||||
|
|
||||||
tz->id = id;
|
tz->id = id;
|
||||||
strlcpy(tz->type, type, sizeof(tz->type));
|
strscpy(tz->type, type, sizeof(tz->type));
|
||||||
|
|
||||||
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
|
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -1458,9 +1451,6 @@ static int thermal_pm_notify(struct notifier_block *nb,
|
||||||
case PM_POST_SUSPEND:
|
case PM_POST_SUSPEND:
|
||||||
atomic_set(&in_suspend, 0);
|
atomic_set(&in_suspend, 0);
|
||||||
list_for_each_entry(tz, &thermal_tz_list, node) {
|
list_for_each_entry(tz, &thermal_tz_list, node) {
|
||||||
if (!thermal_zone_device_is_enabled(tz))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
thermal_zone_device_init(tz);
|
thermal_zone_device_init(tz);
|
||||||
thermal_zone_device_update(tz,
|
thermal_zone_device_update(tz,
|
||||||
THERMAL_EVENT_UNSPECIFIED);
|
THERMAL_EVENT_UNSPECIFIED);
|
||||||
|
@ -1492,10 +1482,6 @@ static int __init thermal_init(void)
|
||||||
if (result)
|
if (result)
|
||||||
goto unregister_governors;
|
goto unregister_governors;
|
||||||
|
|
||||||
result = of_parse_thermal_zones();
|
|
||||||
if (result)
|
|
||||||
goto unregister_class;
|
|
||||||
|
|
||||||
result = register_pm_notifier(&thermal_pm_nb);
|
result = register_pm_notifier(&thermal_pm_nb);
|
||||||
if (result)
|
if (result)
|
||||||
pr_warn("Thermal: Can not register suspend notifier, return %d\n",
|
pr_warn("Thermal: Can not register suspend notifier, return %d\n",
|
||||||
|
@ -1503,8 +1489,6 @@ static int __init thermal_init(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unregister_class:
|
|
||||||
class_unregister(&thermal_class);
|
|
||||||
unregister_governors:
|
unregister_governors:
|
||||||
thermal_unregister_governors();
|
thermal_unregister_governors();
|
||||||
error:
|
error:
|
||||||
|
|
|
@ -112,6 +112,8 @@ int thermal_build_list_of_policies(char *buf);
|
||||||
|
|
||||||
/* Helpers */
|
/* Helpers */
|
||||||
void thermal_zone_set_trips(struct thermal_zone_device *tz);
|
void thermal_zone_set_trips(struct thermal_zone_device *tz);
|
||||||
|
void __thermal_zone_set_trips(struct thermal_zone_device *tz);
|
||||||
|
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
|
||||||
|
|
||||||
/* sysfs I/F */
|
/* sysfs I/F */
|
||||||
int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
|
int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
|
||||||
|
@ -135,13 +137,11 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
|
||||||
|
|
||||||
/* device tree support */
|
/* device tree support */
|
||||||
#ifdef CONFIG_THERMAL_OF
|
#ifdef CONFIG_THERMAL_OF
|
||||||
int of_parse_thermal_zones(void);
|
|
||||||
int of_thermal_get_ntrips(struct thermal_zone_device *);
|
int of_thermal_get_ntrips(struct thermal_zone_device *);
|
||||||
bool of_thermal_is_trip_valid(struct thermal_zone_device *, int);
|
bool of_thermal_is_trip_valid(struct thermal_zone_device *, int);
|
||||||
const struct thermal_trip *
|
const struct thermal_trip *
|
||||||
of_thermal_get_trip_points(struct thermal_zone_device *);
|
of_thermal_get_trip_points(struct thermal_zone_device *);
|
||||||
#else
|
#else
|
||||||
static inline int of_parse_thermal_zones(void) { return 0; }
|
|
||||||
static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
|
static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -64,27 +64,17 @@ get_thermal_instance(struct thermal_zone_device *tz,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(get_thermal_instance);
|
EXPORT_SYMBOL(get_thermal_instance);
|
||||||
|
|
||||||
/**
|
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
* thermal_zone_get_temp() - returns the temperature of a thermal zone
|
|
||||||
* @tz: a valid pointer to a struct thermal_zone_device
|
|
||||||
* @temp: a valid pointer to where to store the resulting temperature.
|
|
||||||
*
|
|
||||||
* When a valid thermal zone reference is passed, it will fetch its
|
|
||||||
* temperature and fill @temp.
|
|
||||||
*
|
|
||||||
* Return: On success returns 0, an error code otherwise
|
|
||||||
*/
|
|
||||||
int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
|
||||||
{
|
{
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
int count;
|
int count;
|
||||||
int crit_temp = INT_MAX;
|
int crit_temp = INT_MAX;
|
||||||
enum thermal_trip_type type;
|
enum thermal_trip_type type;
|
||||||
|
|
||||||
if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
|
lockdep_assert_held(&tz->lock);
|
||||||
goto exit;
|
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
if (!tz || IS_ERR(tz) || !tz->ops->get_temp)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
ret = tz->ops->get_temp(tz, temp);
|
ret = tz->ops->get_temp(tz, temp);
|
||||||
|
|
||||||
|
@ -107,35 +97,42 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
*temp = tz->emul_temperature;
|
*temp = tz->emul_temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* thermal_zone_get_temp() - returns the temperature of a thermal zone
|
||||||
|
* @tz: a valid pointer to a struct thermal_zone_device
|
||||||
|
* @temp: a valid pointer to where to store the resulting temperature.
|
||||||
|
*
|
||||||
|
* When a valid thermal zone reference is passed, it will fetch its
|
||||||
|
* temperature and fill @temp.
|
||||||
|
*
|
||||||
|
* Return: On success returns 0, an error code otherwise
|
||||||
|
*/
|
||||||
|
int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mutex_lock(&tz->lock);
|
||||||
|
ret = __thermal_zone_get_temp(tz, temp);
|
||||||
mutex_unlock(&tz->lock);
|
mutex_unlock(&tz->lock);
|
||||||
exit:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
|
EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
|
||||||
|
|
||||||
/**
|
void __thermal_zone_set_trips(struct thermal_zone_device *tz)
|
||||||
* thermal_zone_set_trips - Computes the next trip points for the driver
|
|
||||||
* @tz: a pointer to a thermal zone device structure
|
|
||||||
*
|
|
||||||
* The function computes the next temperature boundaries by browsing
|
|
||||||
* the trip points. The result is the closer low and high trip points
|
|
||||||
* to the current temperature. These values are passed to the backend
|
|
||||||
* driver to let it set its own notification mechanism (usually an
|
|
||||||
* interrupt).
|
|
||||||
*
|
|
||||||
* It does not return a value
|
|
||||||
*/
|
|
||||||
void thermal_zone_set_trips(struct thermal_zone_device *tz)
|
|
||||||
{
|
{
|
||||||
int low = -INT_MAX;
|
int low = -INT_MAX;
|
||||||
int high = INT_MAX;
|
int high = INT_MAX;
|
||||||
int trip_temp, hysteresis;
|
int trip_temp, hysteresis;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
if (!tz->ops->set_trips || !tz->ops->get_trip_hyst)
|
if (!tz->ops->set_trips || !tz->ops->get_trip_hyst)
|
||||||
goto exit;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < tz->num_trips; i++) {
|
for (i = 0; i < tz->num_trips; i++) {
|
||||||
int trip_low;
|
int trip_low;
|
||||||
|
@ -154,7 +151,7 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
|
||||||
|
|
||||||
/* No need to change trip points */
|
/* No need to change trip points */
|
||||||
if (tz->prev_low_trip == low && tz->prev_high_trip == high)
|
if (tz->prev_low_trip == low && tz->prev_high_trip == high)
|
||||||
goto exit;
|
return;
|
||||||
|
|
||||||
tz->prev_low_trip = low;
|
tz->prev_low_trip = low;
|
||||||
tz->prev_high_trip = high;
|
tz->prev_high_trip = high;
|
||||||
|
@ -169,8 +166,24 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
|
||||||
ret = tz->ops->set_trips(tz, low, high);
|
ret = tz->ops->set_trips(tz, low, high);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(&tz->device, "Failed to set trips: %d\n", ret);
|
dev_err(&tz->device, "Failed to set trips: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
/**
|
||||||
|
* thermal_zone_set_trips - Computes the next trip points for the driver
|
||||||
|
* @tz: a pointer to a thermal zone device structure
|
||||||
|
*
|
||||||
|
* The function computes the next temperature boundaries by browsing
|
||||||
|
* the trip points. The result is the closer low and high trip points
|
||||||
|
* to the current temperature. These values are passed to the backend
|
||||||
|
* driver to let it set its own notification mechanism (usually an
|
||||||
|
* interrupt).
|
||||||
|
*
|
||||||
|
* It does not return a value
|
||||||
|
*/
|
||||||
|
void thermal_zone_set_trips(struct thermal_zone_device *tz)
|
||||||
|
{
|
||||||
|
mutex_lock(&tz->lock);
|
||||||
|
__thermal_zone_set_trips(tz);
|
||||||
mutex_unlock(&tz->lock);
|
mutex_unlock(&tz->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&hwmon->tz_list);
|
INIT_LIST_HEAD(&hwmon->tz_list);
|
||||||
strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
|
strscpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
|
||||||
strreplace(hwmon->type, '-', '_');
|
strreplace(hwmon->type, '-', '_');
|
||||||
hwmon->device = hwmon_device_register_for_thermal(&tz->device,
|
hwmon->device = hwmon_device_register_for_thermal(&tz->device,
|
||||||
hwmon->type, hwmon);
|
hwmon->type, hwmon);
|
||||||
|
|
|
@ -20,11 +20,10 @@ static u32 thermal_mmio_readb(void __iomem *mmio_base)
|
||||||
return readb(mmio_base);
|
return readb(mmio_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int thermal_mmio_get_temperature(void *private, int *temp)
|
static int thermal_mmio_get_temperature(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
struct thermal_mmio *sensor =
|
struct thermal_mmio *sensor = tz->devdata;
|
||||||
(struct thermal_mmio *)private;
|
|
||||||
|
|
||||||
t = sensor->read_mmio(sensor->mmio_base) & sensor->mask;
|
t = sensor->read_mmio(sensor->mmio_base) & sensor->mask;
|
||||||
t *= sensor->factor;
|
t *= sensor->factor;
|
||||||
|
@ -34,7 +33,7 @@ static int thermal_mmio_get_temperature(void *private, int *temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops thermal_mmio_ops = {
|
static const struct thermal_zone_device_ops thermal_mmio_ops = {
|
||||||
.get_temp = thermal_mmio_get_temperature,
|
.get_temp = thermal_mmio_get_temperature,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,10 +67,10 @@ static int thermal_mmio_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thermal_zone = devm_thermal_zone_of_sensor_register(&pdev->dev,
|
thermal_zone = devm_thermal_of_zone_register(&pdev->dev,
|
||||||
0,
|
0,
|
||||||
sensor,
|
sensor,
|
||||||
&thermal_mmio_ops);
|
&thermal_mmio_ops);
|
||||||
if (IS_ERR(thermal_zone)) {
|
if (IS_ERR(thermal_zone)) {
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"failed to register sensor (%ld)\n",
|
"failed to register sensor (%ld)\n",
|
||||||
|
@ -79,7 +78,7 @@ static int thermal_mmio_probe(struct platform_device *pdev)
|
||||||
return PTR_ERR(thermal_zone);
|
return PTR_ERR(thermal_zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
thermal_mmio_get_temperature(sensor, &temperature);
|
thermal_mmio_get_temperature(thermal_zone, &temperature);
|
||||||
dev_info(&pdev->dev,
|
dev_info(&pdev->dev,
|
||||||
"thermal mmio sensor %s registered, current temperature: %d\n",
|
"thermal mmio sensor %s registered, current temperature: %d\n",
|
||||||
pdev->name, temperature);
|
pdev->name, temperature);
|
||||||
|
@ -107,7 +106,7 @@ static struct platform_driver thermal_mmio_driver = {
|
||||||
.probe = thermal_mmio_probe,
|
.probe = thermal_mmio_probe,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "thermal-mmio",
|
.name = "thermal-mmio",
|
||||||
.of_match_table = of_match_ptr(thermal_mmio_id_table),
|
.of_match_table = thermal_mmio_id_table,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -49,7 +49,11 @@ static ssize_t
|
||||||
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
|
mode_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct thermal_zone_device *tz = to_thermal_zone(dev);
|
struct thermal_zone_device *tz = to_thermal_zone(dev);
|
||||||
int enabled = thermal_zone_device_is_enabled(tz);
|
int enabled;
|
||||||
|
|
||||||
|
mutex_lock(&tz->lock);
|
||||||
|
enabled = thermal_zone_device_is_enabled(tz);
|
||||||
|
mutex_unlock(&tz->lock);
|
||||||
|
|
||||||
return sprintf(buf, "%s\n", enabled ? "enabled" : "disabled");
|
return sprintf(buf, "%s\n", enabled ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
@ -115,7 +119,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
|
||||||
int temperature, hyst = 0;
|
int temperature, hyst = 0;
|
||||||
enum thermal_trip_type type;
|
enum thermal_trip_type type;
|
||||||
|
|
||||||
if (!tz->ops->set_trip_temp)
|
if (!tz->ops->set_trip_temp && !tz->trips)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1)
|
if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1)
|
||||||
|
@ -128,6 +132,9 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (tz->trips)
|
||||||
|
tz->trips[trip].temperature = temperature;
|
||||||
|
|
||||||
if (tz->ops->get_trip_hyst) {
|
if (tz->ops->get_trip_hyst) {
|
||||||
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
|
ret = tz->ops->get_trip_hyst(tz, trip, &hyst);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -65,10 +65,10 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
|
||||||
|
|
||||||
/* thermal zone ops */
|
/* thermal zone ops */
|
||||||
/* Get temperature callback function for thermal zone */
|
/* Get temperature callback function for thermal zone */
|
||||||
static inline int __ti_thermal_get_temp(void *devdata, int *temp)
|
static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||||
{
|
{
|
||||||
struct thermal_zone_device *pcb_tz = NULL;
|
struct thermal_zone_device *pcb_tz = NULL;
|
||||||
struct ti_thermal_data *data = devdata;
|
struct ti_thermal_data *data = tz->devdata;
|
||||||
struct ti_bandgap *bgp;
|
struct ti_bandgap *bgp;
|
||||||
const struct ti_temp_sensor *s;
|
const struct ti_temp_sensor *s;
|
||||||
int ret, tmp, slope, constant;
|
int ret, tmp, slope, constant;
|
||||||
|
@ -85,8 +85,8 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Default constants */
|
/* Default constants */
|
||||||
slope = thermal_zone_get_slope(data->ti_thermal);
|
slope = thermal_zone_get_slope(tz);
|
||||||
constant = thermal_zone_get_offset(data->ti_thermal);
|
constant = thermal_zone_get_offset(tz);
|
||||||
|
|
||||||
pcb_tz = data->pcb_tz;
|
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 */
|
||||||
|
@ -107,9 +107,9 @@ static inline int __ti_thermal_get_temp(void *devdata, int *temp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
|
static int __ti_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend)
|
||||||
{
|
{
|
||||||
struct ti_thermal_data *data = p;
|
struct ti_thermal_data *data = tz->devdata;
|
||||||
struct ti_bandgap *bgp;
|
struct ti_bandgap *bgp;
|
||||||
int id, tr, ret = 0;
|
int id, tr, ret = 0;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ static int __ti_thermal_get_trend(void *p, int trip, enum thermal_trend *trend)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops ti_of_thermal_ops = {
|
static const struct thermal_zone_device_ops ti_of_thermal_ops = {
|
||||||
.get_temp = __ti_thermal_get_temp,
|
.get_temp = __ti_thermal_get_temp,
|
||||||
.get_trend = __ti_thermal_get_trend,
|
.get_trend = __ti_thermal_get_trend,
|
||||||
};
|
};
|
||||||
|
@ -170,7 +170,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* in case this is specified by DT */
|
/* in case this is specified by DT */
|
||||||
data->ti_thermal = devm_thermal_zone_of_sensor_register(bgp->dev, id,
|
data->ti_thermal = devm_thermal_of_zone_register(bgp->dev, id,
|
||||||
data, &ti_of_thermal_ops);
|
data, &ti_of_thermal_ops);
|
||||||
if (IS_ERR(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");
|
||||||
|
|
|
@ -187,9 +187,9 @@ static void uniphier_tm_disable_sensor(struct uniphier_tm_dev *tdev)
|
||||||
usleep_range(1000, 2000); /* The spec note says at least 1ms */
|
usleep_range(1000, 2000); /* The spec note says at least 1ms */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uniphier_tm_get_temp(void *data, int *out_temp)
|
static int uniphier_tm_get_temp(struct thermal_zone_device *tz, int *out_temp)
|
||||||
{
|
{
|
||||||
struct uniphier_tm_dev *tdev = data;
|
struct uniphier_tm_dev *tdev = tz->devdata;
|
||||||
struct regmap *map = tdev->regmap;
|
struct regmap *map = tdev->regmap;
|
||||||
int ret;
|
int ret;
|
||||||
u32 temp;
|
u32 temp;
|
||||||
|
@ -204,7 +204,7 @@ static int uniphier_tm_get_temp(void *data, int *out_temp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct thermal_zone_of_device_ops uniphier_of_thermal_ops = {
|
static const struct thermal_zone_device_ops uniphier_of_thermal_ops = {
|
||||||
.get_temp = uniphier_tm_get_temp,
|
.get_temp = uniphier_tm_get_temp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -289,8 +289,8 @@ static int uniphier_tm_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, tdev);
|
platform_set_drvdata(pdev, tdev);
|
||||||
|
|
||||||
tdev->tz_dev = devm_thermal_zone_of_sensor_register(dev, 0, tdev,
|
tdev->tz_dev = devm_thermal_of_zone_register(dev, 0, tdev,
|
||||||
&uniphier_of_thermal_ops);
|
&uniphier_of_thermal_ops);
|
||||||
if (IS_ERR(tdev->tz_dev)) {
|
if (IS_ERR(tdev->tz_dev)) {
|
||||||
dev_err(dev, "failed to register sensor device\n");
|
dev_err(dev, "failed to register sensor device\n");
|
||||||
return PTR_ERR(tdev->tz_dev);
|
return PTR_ERR(tdev->tz_dev);
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <uapi/linux/thermal.h>
|
#include <uapi/linux/thermal.h>
|
||||||
|
|
||||||
#define THERMAL_MAX_TRIPS 12
|
|
||||||
|
|
||||||
/* invalid cooling state */
|
/* invalid cooling state */
|
||||||
#define THERMAL_CSTATE_INVALID -1UL
|
#define THERMAL_CSTATE_INVALID -1UL
|
||||||
|
|
||||||
|
@ -296,82 +294,53 @@ struct thermal_zone_params {
|
||||||
int offset;
|
int offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* struct thermal_zone_of_device_ops - callbacks for handling DT based zones
|
|
||||||
*
|
|
||||||
* Mandatory:
|
|
||||||
* @get_temp: a pointer to a function that reads the sensor temperature.
|
|
||||||
*
|
|
||||||
* Optional:
|
|
||||||
* @get_trend: a pointer to a function that reads the sensor temperature trend.
|
|
||||||
* @set_trips: a pointer to a function that sets a temperature window. When
|
|
||||||
* this window is left the driver must inform the thermal core via
|
|
||||||
* thermal_zone_device_update.
|
|
||||||
* @set_emul_temp: a pointer to a function that sets sensor emulated
|
|
||||||
* temperature.
|
|
||||||
* @set_trip_temp: a pointer to a function that sets the trip temperature on
|
|
||||||
* hardware.
|
|
||||||
* @change_mode: a pointer to a function that notifies the thermal zone
|
|
||||||
* mode change.
|
|
||||||
*/
|
|
||||||
struct thermal_zone_of_device_ops {
|
|
||||||
int (*get_temp)(void *, int *);
|
|
||||||
int (*get_trend)(void *, int, enum thermal_trend *);
|
|
||||||
int (*set_trips)(void *, int, int);
|
|
||||||
int (*set_emul_temp)(void *, int);
|
|
||||||
int (*set_trip_temp)(void *, int, int);
|
|
||||||
int (*change_mode) (void *, enum thermal_device_mode);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Function declarations */
|
/* Function declarations */
|
||||||
#ifdef CONFIG_THERMAL_OF
|
#ifdef CONFIG_THERMAL_OF
|
||||||
|
struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
|
||||||
|
const struct thermal_zone_device_ops *ops);
|
||||||
|
|
||||||
|
struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
|
||||||
|
const struct thermal_zone_device_ops *ops);
|
||||||
|
|
||||||
|
void thermal_of_zone_unregister(struct thermal_zone_device *tz);
|
||||||
|
|
||||||
|
void devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz);
|
||||||
|
|
||||||
|
void thermal_of_zone_unregister(struct thermal_zone_device *tz);
|
||||||
|
|
||||||
int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
|
int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
|
||||||
struct device_node *sensor_np,
|
struct device_node *sensor_np,
|
||||||
u32 *id);
|
u32 *id);
|
||||||
struct thermal_zone_device *
|
|
||||||
thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
|
|
||||||
const struct thermal_zone_of_device_ops *ops);
|
|
||||||
void thermal_zone_of_sensor_unregister(struct device *dev,
|
|
||||||
struct thermal_zone_device *tz);
|
|
||||||
struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
|
|
||||||
struct device *dev, int id, void *data,
|
|
||||||
const struct thermal_zone_of_device_ops *ops);
|
|
||||||
void devm_thermal_zone_of_sensor_unregister(struct device *dev,
|
|
||||||
struct thermal_zone_device *tz);
|
|
||||||
#else
|
#else
|
||||||
|
static inline
|
||||||
|
struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
|
||||||
|
const struct thermal_zone_device_ops *ops)
|
||||||
|
{
|
||||||
|
return ERR_PTR(-ENOTSUPP);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
|
||||||
|
const struct thermal_zone_device_ops *ops)
|
||||||
|
{
|
||||||
|
return ERR_PTR(-ENOTSUPP);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void thermal_of_zone_unregister(struct thermal_zone_device *tz)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void devm_thermal_of_zone_unregister(struct device *dev,
|
||||||
|
struct thermal_zone_device *tz)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
|
static inline int thermal_zone_of_get_sensor_id(struct device_node *tz_np,
|
||||||
struct device_node *sensor_np,
|
struct device_node *sensor_np,
|
||||||
u32 *id)
|
u32 *id)
|
||||||
{
|
{
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
static inline struct thermal_zone_device *
|
|
||||||
thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
|
|
||||||
const struct thermal_zone_of_device_ops *ops)
|
|
||||||
{
|
|
||||||
return ERR_PTR(-ENODEV);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
void thermal_zone_of_sensor_unregister(struct device *dev,
|
|
||||||
struct thermal_zone_device *tz)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct thermal_zone_device *devm_thermal_zone_of_sensor_register(
|
|
||||||
struct device *dev, int id, void *data,
|
|
||||||
const struct thermal_zone_of_device_ops *ops)
|
|
||||||
{
|
|
||||||
return ERR_PTR(-ENODEV);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline
|
|
||||||
void devm_thermal_zone_of_sensor_unregister(struct device *dev,
|
|
||||||
struct thermal_zone_device *tz)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_THERMAL
|
#ifdef CONFIG_THERMAL
|
||||||
|
|
Загрузка…
Ссылка в новой задаче