Lines Matching +full:thermal +full:- +full:zones

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
13 #include <linux/thermal.h>
17 #include <soc/tegra/bpmp-abi.h>
30 struct tegra_bpmp_thermal_zone **zones; member
43 req.get_temp.zone = zone->idx; in __tegra_bpmp_thermal_get_temp()
52 err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); in __tegra_bpmp_thermal_get_temp()
55 if (msg.rx.ret == -BPMP_EFAULT) in __tegra_bpmp_thermal_get_temp()
56 return -EAGAIN; in __tegra_bpmp_thermal_get_temp()
58 return -EINVAL; in __tegra_bpmp_thermal_get_temp()
81 req.set_trip.zone = zone->idx; in tegra_bpmp_thermal_set_trips()
91 err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); in tegra_bpmp_thermal_set_trips()
95 return -EINVAL; in tegra_bpmp_thermal_set_trips()
107 thermal_zone_device_update(zone->tzd, THERMAL_TRIP_VIOLATED); in tz_device_update_work_fn()
119 iosys_map_memcpy_from(&req, &ch->ib, offset, sizeof(req)); in bpmp_mrq_thermal()
122 dev_err(tegra->dev, "%s: invalid request type: %d\n", __func__, req.type); in bpmp_mrq_thermal()
123 tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0); in bpmp_mrq_thermal()
127 for (i = 0; i < tegra->num_zones; ++i) { in bpmp_mrq_thermal()
128 if (tegra->zones[i]->idx != req.host_trip_reached.zone) in bpmp_mrq_thermal()
131 schedule_work(&tegra->zones[i]->tz_device_update_work); in bpmp_mrq_thermal()
136 dev_err(tegra->dev, "%s: invalid thermal zone: %d\n", __func__, in bpmp_mrq_thermal()
138 tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0); in bpmp_mrq_thermal()
163 return -EINVAL; in tegra_bpmp_thermal_get_num_zones()
195 } else if (msg.rx.ret == -BPMP_ENODEV) { in tegra_bpmp_thermal_trips_supported()
199 return -EINVAL; in tegra_bpmp_thermal_trips_supported()
214 struct tegra_bpmp *bpmp = dev_get_drvdata(pdev->dev.parent); in tegra_bpmp_thermal_probe()
224 dev_err(&pdev->dev, "failed to determine if trip points are supported\n"); in tegra_bpmp_thermal_probe()
233 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_bpmp_thermal_probe()
235 return -ENOMEM; in tegra_bpmp_thermal_probe()
237 tegra->dev = &pdev->dev; in tegra_bpmp_thermal_probe()
238 tegra->bpmp = bpmp; in tegra_bpmp_thermal_probe()
242 dev_err(&pdev->dev, "failed to get the number of zones: %d\n", in tegra_bpmp_thermal_probe()
247 tegra->zones = devm_kcalloc(&pdev->dev, max_num_zones, in tegra_bpmp_thermal_probe()
248 sizeof(*tegra->zones), GFP_KERNEL); in tegra_bpmp_thermal_probe()
249 if (!tegra->zones) in tegra_bpmp_thermal_probe()
250 return -ENOMEM; in tegra_bpmp_thermal_probe()
256 zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); in tegra_bpmp_thermal_probe()
258 return -ENOMEM; in tegra_bpmp_thermal_probe()
260 zone->idx = i; in tegra_bpmp_thermal_probe()
261 zone->tegra = tegra; in tegra_bpmp_thermal_probe()
267 * (-EAGAIN), but will become accessible when the domain is powered on. in tegra_bpmp_thermal_probe()
269 if (err < 0 && err != -EAGAIN) { in tegra_bpmp_thermal_probe()
270 devm_kfree(&pdev->dev, zone); in tegra_bpmp_thermal_probe()
275 &pdev->dev, i, zone, thermal_ops); in tegra_bpmp_thermal_probe()
277 if (PTR_ERR(tzd) == -EPROBE_DEFER) in tegra_bpmp_thermal_probe()
278 return -EPROBE_DEFER; in tegra_bpmp_thermal_probe()
279 devm_kfree(&pdev->dev, zone); in tegra_bpmp_thermal_probe()
283 zone->tzd = tzd; in tegra_bpmp_thermal_probe()
284 INIT_WORK(&zone->tz_device_update_work, in tegra_bpmp_thermal_probe()
287 tegra->zones[tegra->num_zones++] = zone; in tegra_bpmp_thermal_probe()
293 dev_err(&pdev->dev, "failed to register mrq handler: %d\n", in tegra_bpmp_thermal_probe()
307 tegra_bpmp_free_mrq(tegra->bpmp, MRQ_THERMAL, tegra); in tegra_bpmp_thermal_remove()
311 { .compatible = "nvidia,tegra186-bpmp-thermal" },
320 .name = "tegra-bpmp-thermal",
327 MODULE_DESCRIPTION("NVIDIA Tegra BPMP thermal sensor driver");