Commit 51699e4c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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

Pull more thermal control changes for 6.4-rc1 from Daniel Lezcano:

"- Do preparating cleaning and DT bindings for RK3588 support
   (Sebastian Reichel)

 - Add driver support for RK3588 (Finley Xiao)

 - Use devm_reset_control_array_get_exclusive() for the Rockchip driver
   (Ye Xingchen)

 - Detect power gated thermal zones and return -EAGAIN when reading the
   temperature (Mikko Perttunen)

 - Remove thermal_bind_params structure as it is unused (Zhang Rui)

 - Drop unneeded quotes in DT bindings allowing to run yamllint (Rob
   Herring)

 - Update the power allocator documentation according to the thermal
   trace relocation (Lukas Bulwahn)

 - Fix sensor 1 interrupt status bitmask for the Mediatek LVTS sensor
   (Chen-Yu Tsai)

 - Use the dev_err_probe() helper in the Amlogic driver (Ye Xingchen)

 - Add AP domain support to LVTS thermal controllers for mt8195
   (Balsam CHIHI)

 - Remove buggy call to thermal_of_zone_unregister() (Daniel Lezcano)

 - Make thermal_of_zone_[un]register() private to the thermal OF code
   (Daniel Lezcano)

 - Create a private copy of the thermal zone device parameters
   structure when registering a thermal zone (Daniel Lezcano)"

* tag 'thermal-v6.4-rc1-2' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/thermal/linux:
  thermal/core: Alloc-copy-free the thermal zone parameters structure
  thermal/of: Unexport unused OF functions
  thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister
  thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195
  dt-bindings: thermal: mediatek: Add AP domain to LVTS thermal controllers for mt8195
  thermal: amlogic: Use dev_err_probe()
  thermal/drivers/mediatek/lvts_thermal: Fix sensor 1 interrupt status bitmask
  MAINTAINERS: adjust entry in THERMAL/POWER_ALLOCATOR after header movement
  dt-bindings: thermal: Drop unneeded quotes
  thermal/core: Remove thermal_bind_params structure
  thermal/drivers/tegra-bpmp: Handle offline zones
  thermal/drivers/rockchip: use devm_reset_control_array_get_exclusive()
  dt-bindings: rockchip-thermal: Support the RK3588 SoC compatible
  thermal/drivers/rockchip: Support RK3588 SoC in the thermal driver
  thermal/drivers/rockchip: Support dynamic sized sensor array
  thermal/drivers/rockchip: Simplify channel id logic
  thermal/drivers/rockchip: Use dev_err_probe
  thermal/drivers/rockchip: Simplify clock logic
  thermal/drivers/rockchip: Simplify getting match data
parents cfeeb7d3 3d439b1a
...@@ -30,7 +30,7 @@ properties: ...@@ -30,7 +30,7 @@ properties:
amlogic,ao-secure: amlogic,ao-secure:
description: phandle to the ao-secure syscon description: phandle to the ao-secure syscon
$ref: '/schemas/types.yaml#/definitions/phandle' $ref: /schemas/types.yaml#/definitions/phandle
'#thermal-sensor-cells': '#thermal-sensor-cells':
const: 0 const: 0
......
...@@ -40,11 +40,11 @@ properties: ...@@ -40,11 +40,11 @@ properties:
- const: temp_grade - const: temp_grade
fsl,tempmon: fsl,tempmon:
$ref: '/schemas/types.yaml#/definitions/phandle' $ref: /schemas/types.yaml#/definitions/phandle
description: Phandle to anatop system controller node. description: Phandle to anatop system controller node.
fsl,tempmon-data: fsl,tempmon-data:
$ref: '/schemas/types.yaml#/definitions/phandle' $ref: /schemas/types.yaml#/definitions/phandle
description: | description: |
Deprecated property, phandle pointer to fuse controller that contains Deprecated property, phandle pointer to fuse controller that contains
TEMPMON calibration data, e.g. OCOTP on imx6q. The details about TEMPMON calibration data, e.g. OCOTP on imx6q. The details about
......
...@@ -29,14 +29,14 @@ properties: ...@@ -29,14 +29,14 @@ properties:
maxItems: 1 maxItems: 1
fsl,tmu-range: fsl,tmu-range:
$ref: '/schemas/types.yaml#/definitions/uint32-array' $ref: /schemas/types.yaml#/definitions/uint32-array
description: | description: |
The values to be programmed into TTRnCR, as specified by the SoC The values to be programmed into TTRnCR, as specified by the SoC
reference manual. The first cell is TTR0CR, the second is TTR1CR, etc. reference manual. The first cell is TTR0CR, the second is TTR1CR, etc.
maxItems: 4 maxItems: 4
fsl,tmu-calibration: fsl,tmu-calibration:
$ref: '/schemas/types.yaml#/definitions/uint32-matrix' $ref: /schemas/types.yaml#/definitions/uint32-matrix
description: | description: |
A list of cell pairs containing temperature calibration data, as A list of cell pairs containing temperature calibration data, as
specified by the SoC reference manual. The first cell of each pair specified by the SoC reference manual. The first cell of each pair
......
...@@ -19,6 +19,7 @@ properties: ...@@ -19,6 +19,7 @@ properties:
- rockchip,rk3368-tsadc - rockchip,rk3368-tsadc
- rockchip,rk3399-tsadc - rockchip,rk3399-tsadc
- rockchip,rk3568-tsadc - rockchip,rk3568-tsadc
- rockchip,rk3588-tsadc
- rockchip,rv1108-tsadc - rockchip,rv1108-tsadc
reg: reg:
......
...@@ -304,42 +304,6 @@ temperature) and throttle appropriate devices. ...@@ -304,42 +304,6 @@ temperature) and throttle appropriate devices.
1.4 Thermal Zone Parameters 1.4 Thermal Zone Parameters
--------------------------- ---------------------------
::
struct thermal_bind_params
This structure defines the following parameters that are used to bind
a zone with a cooling device for a particular trip point.
.cdev:
The cooling device pointer
.weight:
The 'influence' of a particular cooling device on this
zone. This is relative to the rest of the cooling
devices. For example, if all cooling devices have a
weight of 1, then they all contribute the same. You can
use percentages if you want, but it's not mandatory. A
weight of 0 means that this cooling device doesn't
contribute to the cooling of this zone unless all cooling
devices have a weight of 0. If all weights are 0, then
they all contribute the same.
.trip_mask:
This is a bit mask that gives the binding relation between
this thermal zone and cdev, for a particular trip point.
If nth bit is set, then the cdev and thermal zone are bound
for trip point n.
.binding_limits:
This is an array of cooling state limits. Must have
exactly 2 * thermal_zone.number_of_trip_points. It is an
array consisting of tuples <lower-state upper-state> of
state limits. Each trip will be associated with one state
limit tuple when binding. A NULL pointer means
<THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips.
These limits are used when binding a cdev to a trip point.
.match:
This call back returns success(0) if the 'tz and cdev' need to
be bound, as per platform data.
:: ::
struct thermal_zone_params struct thermal_zone_params
...@@ -357,10 +321,6 @@ temperature) and throttle appropriate devices. ...@@ -357,10 +321,6 @@ temperature) and throttle appropriate devices.
will be created. when no_hwmon == true, nothing will be done. will be created. when no_hwmon == true, nothing will be done.
In case the thermal_zone_params is NULL, the hwmon interface In case the thermal_zone_params is NULL, the hwmon interface
will be created (for backward compatibility). will be created (for backward compatibility).
.num_tbps:
Number of thermal_bind_params entries for this zone
.tbp:
thermal_bind_params entries
2. sysfs attributes structure 2. sysfs attributes structure
============================= =============================
......
...@@ -20771,7 +20771,7 @@ L: linux-pm@vger.kernel.org ...@@ -20771,7 +20771,7 @@ L: linux-pm@vger.kernel.org
S: Maintained S: Maintained
F: Documentation/driver-api/thermal/power_allocator.rst F: Documentation/driver-api/thermal/power_allocator.rst
F: drivers/thermal/gov_power_allocator.c F: drivers/thermal/gov_power_allocator.c
F: include/trace/events/thermal_power_allocator.h F: drivers/thermal/thermal_trace_ipa.h
THINKPAD ACPI EXTRAS DRIVER THINKPAD ACPI EXTRAS DRIVER
M: Henrique de Moraes Holschuh <hmh@hmh.eng.br> M: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
......
...@@ -262,11 +262,8 @@ static int amlogic_thermal_probe(struct platform_device *pdev) ...@@ -262,11 +262,8 @@ static int amlogic_thermal_probe(struct platform_device *pdev)
return PTR_ERR(pdata->regmap); return PTR_ERR(pdata->regmap);
pdata->clk = devm_clk_get(dev, NULL); pdata->clk = devm_clk_get(dev, NULL);
if (IS_ERR(pdata->clk)) { if (IS_ERR(pdata->clk))
if (PTR_ERR(pdata->clk) != -EPROBE_DEFER) return dev_err_probe(dev, PTR_ERR(pdata->clk), "failed to get clock\n");
dev_err(dev, "failed to get clock\n");
return PTR_ERR(pdata->clk);
}
pdata->sec_ao_map = syscon_regmap_lookup_by_phandle pdata->sec_ao_map = syscon_regmap_lookup_by_phandle
(pdev->dev.of_node, "amlogic,ao-secure"); (pdev->dev.of_node, "amlogic,ao-secure");
......
...@@ -275,7 +275,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) ...@@ -275,7 +275,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
return 0; return 0;
err_tz: err_tz:
thermal_of_zone_unregister(tz); devm_thermal_of_zone_unregister(&pdev->dev, tz);
err_clk: err_clk:
clk_disable_unprepare(data->clk); clk_disable_unprepare(data->clk);
...@@ -285,10 +285,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) ...@@ -285,10 +285,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
static int bcm2835_thermal_remove(struct platform_device *pdev) static int bcm2835_thermal_remove(struct platform_device *pdev)
{ {
struct bcm2835_thermal_data *data = platform_get_drvdata(pdev); struct bcm2835_thermal_data *data = platform_get_drvdata(pdev);
struct thermal_zone_device *tz = data->tz;
debugfs_remove_recursive(data->debugfsdir); debugfs_remove_recursive(data->debugfsdir);
thermal_of_zone_unregister(tz);
clk_disable_unprepare(data->clk); clk_disable_unprepare(data->clk);
return 0; return 0;
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
#define LVTS_MONINT_CONF 0x9FBF7BDE #define LVTS_MONINT_CONF 0x9FBF7BDE
#define LVTS_INT_SENSOR0 0x0009001F #define LVTS_INT_SENSOR0 0x0009001F
#define LVTS_INT_SENSOR1 0X000881F0 #define LVTS_INT_SENSOR1 0x001203E0
#define LVTS_INT_SENSOR2 0x00247C00 #define LVTS_INT_SENSOR2 0x00247C00
#define LVTS_INT_SENSOR3 0x1FC00000 #define LVTS_INT_SENSOR3 0x1FC00000
...@@ -395,8 +395,8 @@ static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl) ...@@ -395,8 +395,8 @@ static irqreturn_t lvts_ctrl_irq_handler(struct lvts_ctrl *lvts_ctrl)
* => 0x1FC00000 * => 0x1FC00000
* sensor 2 interrupt: 0000 0000 0010 0100 0111 1100 0000 0000 * sensor 2 interrupt: 0000 0000 0010 0100 0111 1100 0000 0000
* => 0x00247C00 * => 0x00247C00
* sensor 1 interrupt: 0000 0000 0001 0001 0000 0011 1110 0000 * sensor 1 interrupt: 0000 0000 0001 0010 0000 0011 1110 0000
* => 0X000881F0 * => 0X001203E0
* sensor 0 interrupt: 0000 0000 0000 1001 0000 0000 0001 1111 * sensor 0 interrupt: 0000 0000 0000 1001 0000 0000 0001 1111
* => 0x0009001F * => 0x0009001F
*/ */
...@@ -530,29 +530,33 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, ...@@ -530,29 +530,33 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
* The efuse blob values follows the sensor enumeration per thermal * The efuse blob values follows the sensor enumeration per thermal
* controller. The decoding of the stream is as follow: * controller. The decoding of the stream is as follow:
* *
* <--?-> <----big0 ???---> <-sensor0-> <-0-> * stream index map for MCU Domain :
* ------------------------------------------
* index in the stream: : | 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 |
* ------------------------------------------
* *
* <--sensor1--><-0-> <----big1 ???---> <-sen * <-----mcu-tc#0-----> <-----sensor#0-----> <-----sensor#1----->
* ------------------------------------------ * 0x01 | 0x02 | 0x03 | 0x04 | 0x05 | 0x06 | 0x07 | 0x08 | 0x09
* | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD |
* ------------------------------------------
* *
* sor0-> <-0-> <-sensor1-> <-0-> .......... * <-----mcu-tc#1-----> <-----sensor#2-----> <-----sensor#3----->
* ------------------------------------------ * 0x0A | 0x0B | 0x0C | 0x0D | 0x0E | 0x0F | 0x10 | 0x11 | 0x12
* | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD |
* ------------------------------------------
* *
* And so on ... * <-----mcu-tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6-----> <-----sensor#7----->
* 0x13 | 0x14 | 0x15 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1A | 0x1B | 0x1C | 0x1D | 0x1E | 0x1F | 0x20 | 0x21
*
* stream index map for AP Domain :
*
* <-----ap--tc#0-----> <-----sensor#0-----> <-----sensor#1----->
* 0x22 | 0x23 | 0x24 | 0x25 | 0x26 | 0x27 | 0x28 | 0x29 | 0x2A
*
* <-----ap--tc#1-----> <-----sensor#2-----> <-----sensor#3----->
* 0x2B | 0x2C | 0x2D | 0x2E | 0x2F | 0x30 | 0x31 | 0x32 | 0x33
*
* <-----ap--tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6----->
* 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39 | 0x3A | 0x3B | 0x3C | 0x3D | 0x3E | 0x3F
*
* <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
* 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
* *
* The data description gives the offset of the calibration data in * The data description gives the offset of the calibration data in
* this bytes stream for each sensor. * this bytes stream for each sensor.
*
* Each thermal controller can handle up to 4 sensors max, we don't
* care if there are less as the array of calibration is sized to 4
* anyway. The unused sensor slot will be zeroed.
*/ */
static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl, static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
const struct lvts_ctrl_data *lvts_ctrl_data, const struct lvts_ctrl_data *lvts_ctrl_data,
...@@ -1165,7 +1169,7 @@ static int lvts_remove(struct platform_device *pdev) ...@@ -1165,7 +1169,7 @@ static int lvts_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = { static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
{ {
.cal_offset = { 0x04, 0x07 }, .cal_offset = { 0x04, 0x07 },
.lvts_sensor = { .lvts_sensor = {
...@@ -1200,13 +1204,63 @@ static const struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = { ...@@ -1200,13 +1204,63 @@ static const struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = {
} }
}; };
static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
{
.cal_offset = { 0x25, 0x28 },
.lvts_sensor = {
{ .dt_id = MT8195_AP_VPU0 },
{ .dt_id = MT8195_AP_VPU1 }
},
.num_lvts_sensor = 2,
.offset = 0x0,
.hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x2e, 0x31 },
.lvts_sensor = {
{ .dt_id = MT8195_AP_GPU0 },
{ .dt_id = MT8195_AP_GPU1 }
},
.num_lvts_sensor = 2,
.offset = 0x100,
.hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x37, 0x3a, 0x3d },
.lvts_sensor = {
{ .dt_id = MT8195_AP_VDEC },
{ .dt_id = MT8195_AP_IMG },
{ .dt_id = MT8195_AP_INFRA },
},
.num_lvts_sensor = 3,
.offset = 0x200,
.hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x43, 0x46 },
.lvts_sensor = {
{ .dt_id = MT8195_AP_CAM0 },
{ .dt_id = MT8195_AP_CAM1 }
},
.num_lvts_sensor = 2,
.offset = 0x300,
.hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
}
};
static const struct lvts_data mt8195_lvts_mcu_data = { static const struct lvts_data mt8195_lvts_mcu_data = {
.lvts_ctrl = mt8195_lvts_data_ctrl, .lvts_ctrl = mt8195_lvts_mcu_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_data_ctrl), .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_mcu_data_ctrl),
};
static const struct lvts_data mt8195_lvts_ap_data = {
.lvts_ctrl = mt8195_lvts_ap_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_ap_data_ctrl),
}; };
static const struct of_device_id lvts_of_match[] = { static const struct of_device_id lvts_of_match[] = {
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data }, { .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
{ .compatible = "mediatek,mt8195-lvts-ap", .data = &mt8195_lvts_ap_data },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, lvts_of_match); MODULE_DEVICE_TABLE(of, lvts_of_match);
......
This diff is collapsed.
...@@ -52,6 +52,8 @@ static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *zone, ...@@ -52,6 +52,8 @@ static int __tegra_bpmp_thermal_get_temp(struct tegra_bpmp_thermal_zone *zone,
err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
if (err) if (err)
return err; return err;
if (msg.rx.ret == -BPMP_EFAULT)
return -EAGAIN;
if (msg.rx.ret) if (msg.rx.ret)
return -EINVAL; return -EINVAL;
...@@ -209,7 +211,12 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev) ...@@ -209,7 +211,12 @@ static int tegra_bpmp_thermal_probe(struct platform_device *pdev)
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) {
/*
* Sensors in powergated domains may temporarily fail to be read
* (-EAGAIN), but will become accessible when the domain is powered on.
*/
if (err < 0 && err != -EAGAIN) {
devm_kfree(&pdev->dev, zone); devm_kfree(&pdev->dev, zone);
continue; continue;
} }
......
...@@ -794,62 +794,16 @@ void print_bind_err_msg(struct thermal_zone_device *tz, ...@@ -794,62 +794,16 @@ void print_bind_err_msg(struct thermal_zone_device *tz,
tz->type, cdev->type, ret); tz->type, cdev->type, ret);
} }
static void __bind(struct thermal_zone_device *tz, int mask,
struct thermal_cooling_device *cdev,
unsigned long *limits,
unsigned int weight)
{
int i, ret;
for (i = 0; i < tz->num_trips; i++) {
if (mask & (1 << i)) {
unsigned long upper, lower;
upper = THERMAL_NO_LIMIT;
lower = THERMAL_NO_LIMIT;
if (limits) {
lower = limits[i * 2];
upper = limits[i * 2 + 1];
}
ret = thermal_zone_bind_cooling_device(tz, i, cdev,
upper, lower,
weight);
if (ret)
print_bind_err_msg(tz, cdev, ret);
}
}
}
static void bind_cdev(struct thermal_cooling_device *cdev) static void bind_cdev(struct thermal_cooling_device *cdev)
{ {
int i, ret; int ret;
const struct thermal_zone_params *tzp;
struct thermal_zone_device *pos = NULL; struct thermal_zone_device *pos = NULL;
list_for_each_entry(pos, &thermal_tz_list, node) { list_for_each_entry(pos, &thermal_tz_list, node) {
if (!pos->tzp && !pos->ops->bind)
continue;
if (pos->ops->bind) { if (pos->ops->bind) {
ret = pos->ops->bind(pos, cdev); ret = pos->ops->bind(pos, cdev);
if (ret) if (ret)
print_bind_err_msg(pos, cdev, ret); print_bind_err_msg(pos, cdev, ret);
continue;
}
tzp = pos->tzp;
if (!tzp || !tzp->tbp)
continue;
for (i = 0; i < tzp->num_tbps; i++) {
if (tzp->tbp[i].cdev || !tzp->tbp[i].match)
continue;
if (tzp->tbp[i].match(pos, cdev))
continue;
tzp->tbp[i].cdev = cdev;
__bind(pos, tzp->tbp[i].trip_mask, cdev,
tzp->tbp[i].binding_limits,
tzp->tbp[i].weight);
} }
} }
} }
...@@ -1134,16 +1088,6 @@ void thermal_cooling_device_update(struct thermal_cooling_device *cdev) ...@@ -1134,16 +1088,6 @@ void thermal_cooling_device_update(struct thermal_cooling_device *cdev)
} }
EXPORT_SYMBOL_GPL(thermal_cooling_device_update); EXPORT_SYMBOL_GPL(thermal_cooling_device_update);
static void __unbind(struct thermal_zone_device *tz, int mask,
struct thermal_cooling_device *cdev)
{
int i;
for (i = 0; i < tz->num_trips; i++)
if (mask & (1 << i))
thermal_zone_unbind_cooling_device(tz, i, cdev);
}
/** /**
* thermal_cooling_device_unregister - removes a thermal cooling device * thermal_cooling_device_unregister - removes a thermal cooling device
* @cdev: the thermal cooling device to remove. * @cdev: the thermal cooling device to remove.
...@@ -1153,8 +1097,6 @@ static void __unbind(struct thermal_zone_device *tz, int mask, ...@@ -1153,8 +1097,6 @@ static void __unbind(struct thermal_zone_device *tz, int mask,
*/ */
void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
{ {
int i;
const struct thermal_zone_params *tzp;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
if (!cdev) if (!cdev)
...@@ -1171,21 +1113,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ...@@ -1171,21 +1113,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
/* Unbind all thermal zones associated with 'this' cdev */ /* Unbind all thermal zones associated with 'this' cdev */
list_for_each_entry(tz, &thermal_tz_list, node) { list_for_each_entry(tz, &thermal_tz_list, node) {
if (tz->ops->unbind) { if (tz->ops->unbind)
tz->ops->unbind(tz, cdev); tz->ops->unbind(tz, cdev);
continue;
}
if (!tz->tzp || !tz->tzp->tbp)
continue;
tzp = tz->tzp;
for (i = 0; i < tzp->num_tbps; i++) {
if (tzp->tbp[i].cdev == cdev) {
__unbind(tz, tzp->tbp[i].trip_mask, cdev);
tzp->tbp[i].cdev = NULL;
}
}
} }
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
...@@ -1196,41 +1125,20 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); ...@@ -1196,41 +1125,20 @@ EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
static void bind_tz(struct thermal_zone_device *tz) static void bind_tz(struct thermal_zone_device *tz)
{ {
int i, ret; int ret;
struct thermal_cooling_device *pos = NULL; struct thermal_cooling_device *pos = NULL;
const struct thermal_zone_params *tzp = tz->tzp;
if (!tzp && !tz->ops->bind) if (!tz->ops->bind)
return; return;
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
/* If there is ops->bind, try to use ops->bind */
if (tz->ops->bind) {
list_for_each_entry(pos, &thermal_cdev_list, node) {
ret = tz->ops->bind(tz, pos);
if (ret)
print_bind_err_msg(tz, pos, ret);
}
goto exit;
}
if (!tzp || !tzp->tbp)
goto exit;
list_for_each_entry(pos, &thermal_cdev_list, node) { list_for_each_entry(pos, &thermal_cdev_list, node) {
for (i = 0; i < tzp->num_tbps; i++) { ret = tz->ops->bind(tz, pos);
if (tzp->tbp[i].cdev || !tzp->tbp[i].match) if (ret)
continue; print_bind_err_msg(tz, pos, ret);
if (tzp->tbp[i].match(tz, pos))
continue;
tzp->tbp[i].cdev = pos;
__bind(tz, tzp->tbp[i].trip_mask, pos,
tzp->tbp[i].binding_limits,
tzp->tbp[i].weight);
}
} }
exit:
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
} }
...@@ -1348,13 +1256,21 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1348,13 +1256,21 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
if (!tz) if (!tz)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (tzp) {
tz->tzp = kmemdup(tzp, sizeof(*tzp), GFP_KERNEL);
if (!tz->tzp) {
result = -ENOMEM;
goto free_tz;
}
}
INIT_LIST_HEAD(&tz->thermal_instances); INIT_LIST_HEAD(&tz->thermal_instances);
ida_init(&tz->ida); ida_init(&tz->ida);
mutex_init(&tz->lock); mutex_init(&tz->lock);
id = ida_alloc(&thermal_tz_ida, GFP_KERNEL); id = ida_alloc(&thermal_tz_ida, GFP_KERNEL);
if (id < 0) { if (id < 0) {
result = id; result = id;
goto free_tz; goto free_tzp;
} }
tz->id = id; tz->id = id;
...@@ -1364,7 +1280,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1364,7 +1280,6 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
ops->critical = thermal_zone_device_critical; ops->critical = thermal_zone_device_critical;
tz->ops = ops; tz->ops = ops;
tz->tzp = tzp;
tz->device.class = thermal_class; tz->device.class = thermal_class;
tz->devdata = devdata; tz->devdata = devdata;
tz->trips = trips; tz->trips = trips;
...@@ -1446,6 +1361,8 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1446,6 +1361,8 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
tz = NULL; tz = NULL;
remove_id: remove_id:
ida_free(&thermal_tz_ida, id); ida_free(&thermal_tz_ida, id);
free_tzp:
kfree(tz->tzp);
free_tz: free_tz:
kfree(tz); kfree(tz);
return ERR_PTR(result); return ERR_PTR(result);
...@@ -1487,15 +1404,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_id); ...@@ -1487,15 +1404,13 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_id);
*/ */
void thermal_zone_device_unregister(struct thermal_zone_device *tz) void thermal_zone_device_unregister(struct thermal_zone_device *tz)
{ {
int i, tz_id; int tz_id;
const struct thermal_zone_params *tzp;
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
struct thermal_zone_device *pos = NULL; struct thermal_zone_device *pos = NULL;
if (!tz) if (!tz)
return; return;
tzp = tz->tzp;
tz_id = tz->id; tz_id = tz->id;
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
...@@ -1510,22 +1425,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) ...@@ -1510,22 +1425,9 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
list_del(&tz->node); list_del(&tz->node);
/* Unbind all cdevs associated with 'this' thermal zone */ /* Unbind all cdevs associated with 'this' thermal zone */
list_for_each_entry(cdev, &thermal_cdev_list, node) { list_for_each_entry(cdev, &thermal_cdev_list, node)
if (tz->ops->unbind) { if (tz->ops->unbind)
tz->ops->unbind(tz, cdev); tz->ops->unbind(tz, cdev);
continue;
}
if (!tzp || !tzp->tbp)
break;
for (i = 0; i < tzp->num_tbps; i++) {
if (tzp->tbp[i].cdev == cdev) {
__unbind(tz, tzp->tbp[i].trip_mask, cdev);
tzp->tbp[i].cdev = NULL;
}
}
}
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
...@@ -1541,6 +1443,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) ...@@ -1541,6 +1443,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
device_del(&tz->device); device_del(&tz->device);
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
kfree(tz->tzp);
put_device(&tz->device); put_device(&tz->device);
thermal_notify_tz_delete(tz_id); thermal_notify_tz_delete(tz_id);
......
...@@ -439,7 +439,7 @@ static int thermal_of_unbind(struct thermal_zone_device *tz, ...@@ -439,7 +439,7 @@ static int thermal_of_unbind(struct thermal_zone_device *tz,
* *
* @tz: a pointer to the thermal zone structure * @tz: a pointer to the thermal zone structure
*/ */
void thermal_of_zone_unregister(struct thermal_zone_device *tz) static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
{ {
struct thermal_trip *trips = tz->trips; struct thermal_trip *trips = tz->trips;
struct thermal_zone_params *tzp = tz->tzp; struct thermal_zone_params *tzp = tz->tzp;
...@@ -451,7 +451,6 @@ void thermal_of_zone_unregister(struct thermal_zone_device *tz) ...@@ -451,7 +451,6 @@ void thermal_of_zone_unregister(struct thermal_zone_device *tz)
kfree(tzp); kfree(tzp);
kfree(ops); kfree(ops);
} }
EXPORT_SYMBOL_GPL(thermal_of_zone_unregister);
/** /**
* thermal_of_zone_register - Register a thermal zone with device node * thermal_of_zone_register - Register a thermal zone with device node
...@@ -473,8 +472,8 @@ EXPORT_SYMBOL_GPL(thermal_of_zone_unregister); ...@@ -473,8 +472,8 @@ EXPORT_SYMBOL_GPL(thermal_of_zone_unregister);
* - ENOMEM: if one structure can not be allocated * - ENOMEM: if one structure can not be allocated
* - Other negative errors are returned by the underlying called functions * - Other negative errors are returned by the underlying called functions
*/ */
struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
const struct thermal_zone_device_ops *ops) const struct thermal_zone_device_ops *ops)
{ {
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct thermal_trip *trips; struct thermal_trip *trips;
...@@ -550,7 +549,6 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, ...@@ -550,7 +549,6 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(thermal_of_zone_register);
static void devm_thermal_of_zone_release(struct device *dev, void *res) static void devm_thermal_of_zone_release(struct device *dev, void *res)
{ {
......
...@@ -16,4 +16,14 @@ ...@@ -16,4 +16,14 @@
#define MT8195_MCU_LITTLE_CPU2 6 #define MT8195_MCU_LITTLE_CPU2 6
#define MT8195_MCU_LITTLE_CPU3 7 #define MT8195_MCU_LITTLE_CPU3 7
#define MT8195_AP_VPU0 8
#define MT8195_AP_VPU1 9
#define MT8195_AP_GPU0 10
#define MT8195_AP_GPU1 11
#define MT8195_AP_VDEC 12
#define MT8195_AP_IMG 13
#define MT8195_AP_INFRA 14
#define MT8195_AP_CAM0 15
#define MT8195_AP_CAM1 16
#endif /* __MEDIATEK_LVTS_DT_H */ #endif /* __MEDIATEK_LVTS_DT_H */
...@@ -207,41 +207,6 @@ struct thermal_governor { ...@@ -207,41 +207,6 @@ struct thermal_governor {
struct list_head governor_list; struct list_head governor_list;
}; };
/* Structure that holds binding parameters for a zone */
struct thermal_bind_params {
struct thermal_cooling_device *cdev;
/*
* This is a measure of 'how effectively these devices can
* cool 'this' thermal zone. It shall be determined by
* platform characterization. This value is relative to the
* rest of the weights so a cooling device whose weight is
* double that of another cooling device is twice as
* effective. See Documentation/driver-api/thermal/sysfs-api.rst for more
* information.
*/
int weight;
/*
* This is a bit mask that gives the binding relation between this
* thermal zone and cdev, for a particular trip point.
* See Documentation/driver-api/thermal/sysfs-api.rst for more information.
*/
int trip_mask;
/*
* This is an array of cooling state limits. Must have exactly
* 2 * thermal_zone.number_of_trip_points. It is an array consisting
* of tuples <lower-state upper-state> of state limits. Each trip
* will be associated with one state limit tuple when binding.
* A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS>
* on all trips.
*/
unsigned long *binding_limits;
int (*match) (struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev);
};
/* Structure to define Thermal Zone parameters */ /* Structure to define Thermal Zone parameters */
struct thermal_zone_params { struct thermal_zone_params {
char governor_name[THERMAL_NAME_LENGTH]; char governor_name[THERMAL_NAME_LENGTH];
...@@ -253,9 +218,6 @@ struct thermal_zone_params { ...@@ -253,9 +218,6 @@ struct thermal_zone_params {
*/ */
bool no_hwmon; bool no_hwmon;
int num_tbps; /* Number of tbp entries */
struct thermal_bind_params *tbp;
/* /*
* Sustainable power (heat) that this thermal zone can dissipate in * Sustainable power (heat) that this thermal zone can dissipate in
* mW * mW
...@@ -297,25 +259,12 @@ struct thermal_zone_params { ...@@ -297,25 +259,12 @@ struct thermal_zone_params {
/* 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, struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
const struct thermal_zone_device_ops *ops); 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 devm_thermal_of_zone_unregister(struct device *dev, struct thermal_zone_device *tz);
void thermal_of_zone_unregister(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 static inline
struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data, struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, int id, void *data,
...@@ -324,10 +273,6 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in ...@@ -324,10 +273,6 @@ struct thermal_zone_device *devm_thermal_of_zone_register(struct device *dev, in
return ERR_PTR(-ENOTSUPP); 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, static inline void devm_thermal_of_zone_unregister(struct device *dev,
struct thermal_zone_device *tz) struct thermal_zone_device *tz)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment