Lines Matching +full:tegra186 +full:- +full:bpmp
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
16 #include <soc/tegra/bpmp.h>
17 #include <soc/tegra/bpmp-abi.h>
28 struct tegra_bpmp *bpmp; 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()
56 return -EINVAL; in __tegra_bpmp_thermal_get_temp()
65 return __tegra_bpmp_thermal_get_temp(tz->devdata, out_temp); in tegra_bpmp_thermal_get_temp()
70 struct tegra_bpmp_thermal_zone *zone = tz->devdata; in tegra_bpmp_thermal_set_trips()
77 req.set_trip.zone = zone->idx; in tegra_bpmp_thermal_set_trips()
87 err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg); in tegra_bpmp_thermal_set_trips()
91 return -EINVAL; in tegra_bpmp_thermal_set_trips()
103 thermal_zone_device_update(zone->tzd, THERMAL_TRIP_VIOLATED); in tz_device_update_work_fn()
113 req = (struct mrq_thermal_bpmp_to_host_request *)ch->ib->data; in bpmp_mrq_thermal()
115 if (req->type != CMD_THERMAL_HOST_TRIP_REACHED) { in bpmp_mrq_thermal()
116 dev_err(tegra->dev, "%s: invalid request type: %d\n", in bpmp_mrq_thermal()
117 __func__, req->type); in bpmp_mrq_thermal()
118 tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0); in bpmp_mrq_thermal()
122 for (i = 0; i < tegra->num_zones; ++i) { in bpmp_mrq_thermal()
123 if (tegra->zones[i]->idx != req->host_trip_reached.zone) in bpmp_mrq_thermal()
126 schedule_work(&tegra->zones[i]->tz_device_update_work); in bpmp_mrq_thermal()
131 dev_err(tegra->dev, "%s: invalid thermal zone: %d\n", __func__, in bpmp_mrq_thermal()
132 req->host_trip_reached.zone); in bpmp_mrq_thermal()
133 tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0); in bpmp_mrq_thermal()
136 static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp, in tegra_bpmp_thermal_get_num_zones() argument
154 err = tegra_bpmp_transfer(bpmp, &msg); in tegra_bpmp_thermal_get_num_zones()
158 return -EINVAL; in tegra_bpmp_thermal_get_num_zones()
172 struct tegra_bpmp *bpmp = dev_get_drvdata(pdev->dev.parent); in tegra_bpmp_thermal_probe() local
178 tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); in tegra_bpmp_thermal_probe()
180 return -ENOMEM; in tegra_bpmp_thermal_probe()
182 tegra->dev = &pdev->dev; in tegra_bpmp_thermal_probe()
183 tegra->bpmp = bpmp; in tegra_bpmp_thermal_probe()
185 err = tegra_bpmp_thermal_get_num_zones(bpmp, &max_num_zones); in tegra_bpmp_thermal_probe()
187 dev_err(&pdev->dev, "failed to get the number of zones: %d\n", in tegra_bpmp_thermal_probe()
192 tegra->zones = devm_kcalloc(&pdev->dev, max_num_zones, in tegra_bpmp_thermal_probe()
193 sizeof(*tegra->zones), GFP_KERNEL); in tegra_bpmp_thermal_probe()
194 if (!tegra->zones) in tegra_bpmp_thermal_probe()
195 return -ENOMEM; in tegra_bpmp_thermal_probe()
201 zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL); in tegra_bpmp_thermal_probe()
203 return -ENOMEM; in tegra_bpmp_thermal_probe()
205 zone->idx = i; in tegra_bpmp_thermal_probe()
206 zone->tegra = tegra; in tegra_bpmp_thermal_probe()
210 devm_kfree(&pdev->dev, zone); in tegra_bpmp_thermal_probe()
215 &pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops); in tegra_bpmp_thermal_probe()
217 if (PTR_ERR(tzd) == -EPROBE_DEFER) in tegra_bpmp_thermal_probe()
218 return -EPROBE_DEFER; in tegra_bpmp_thermal_probe()
219 devm_kfree(&pdev->dev, zone); in tegra_bpmp_thermal_probe()
223 zone->tzd = tzd; in tegra_bpmp_thermal_probe()
224 INIT_WORK(&zone->tz_device_update_work, in tegra_bpmp_thermal_probe()
227 tegra->zones[tegra->num_zones++] = zone; in tegra_bpmp_thermal_probe()
230 err = tegra_bpmp_request_mrq(bpmp, MRQ_THERMAL, bpmp_mrq_thermal, in tegra_bpmp_thermal_probe()
233 dev_err(&pdev->dev, "failed to register mrq handler: %d\n", in tegra_bpmp_thermal_probe()
247 tegra_bpmp_free_mrq(tegra->bpmp, MRQ_THERMAL, tegra); in tegra_bpmp_thermal_remove()
253 { .compatible = "nvidia,tegra186-bpmp-thermal" },
262 .name = "tegra-bpmp-thermal",
269 MODULE_DESCRIPTION("NVIDIA Tegra BPMP thermal sensor driver");