^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Author:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Mikko Perttunen <mperttunen@nvidia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Aapo Vienamo <avienamo@nvidia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/thermal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <soc/tegra/bpmp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <soc/tegra/bpmp-abi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct tegra_bpmp_thermal_zone {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct tegra_bpmp_thermal *tegra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct thermal_zone_device *tzd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct work_struct tz_device_update_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct tegra_bpmp_thermal {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct tegra_bpmp *bpmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int num_zones;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct tegra_bpmp_thermal_zone **zones;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static int tegra_bpmp_thermal_get_temp(void *data, int *out_temp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct tegra_bpmp_thermal_zone *zone = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct mrq_thermal_host_to_bpmp_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) union mrq_thermal_bpmp_to_host_response reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct tegra_bpmp_message msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) memset(&req, 0, sizeof(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) req.type = CMD_THERMAL_GET_TEMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) req.get_temp.zone = zone->idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) memset(&msg, 0, sizeof(msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) msg.mrq = MRQ_THERMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) msg.tx.data = &req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) msg.tx.size = sizeof(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) msg.rx.data = &reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) msg.rx.size = sizeof(reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) err = tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *out_temp = reply.get_temp.temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static int tegra_bpmp_thermal_set_trips(void *data, int low, int high)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct tegra_bpmp_thermal_zone *zone = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct mrq_thermal_host_to_bpmp_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct tegra_bpmp_message msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) memset(&req, 0, sizeof(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) req.type = CMD_THERMAL_SET_TRIP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) req.set_trip.zone = zone->idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) req.set_trip.enabled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) req.set_trip.low = low;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) req.set_trip.high = high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) memset(&msg, 0, sizeof(msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) msg.mrq = MRQ_THERMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) msg.tx.data = &req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) msg.tx.size = sizeof(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return tegra_bpmp_transfer(zone->tegra->bpmp, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) static void tz_device_update_work_fn(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct tegra_bpmp_thermal_zone *zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) zone = container_of(work, struct tegra_bpmp_thermal_zone,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) tz_device_update_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) thermal_zone_device_update(zone->tzd, THERMAL_TRIP_VIOLATED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static void bpmp_mrq_thermal(unsigned int mrq, struct tegra_bpmp_channel *ch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct mrq_thermal_bpmp_to_host_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct tegra_bpmp_thermal *tegra = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) req = (struct mrq_thermal_bpmp_to_host_request *)ch->ib->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (req->type != CMD_THERMAL_HOST_TRIP_REACHED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) dev_err(tegra->dev, "%s: invalid request type: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) __func__, req->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) for (i = 0; i < tegra->num_zones; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (tegra->zones[i]->idx != req->host_trip_reached.zone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) schedule_work(&tegra->zones[i]->tz_device_update_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) tegra_bpmp_mrq_return(ch, 0, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) dev_err(tegra->dev, "%s: invalid thermal zone: %d\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) req->host_trip_reached.zone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) tegra_bpmp_mrq_return(ch, -EINVAL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static int tegra_bpmp_thermal_get_num_zones(struct tegra_bpmp *bpmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int *num_zones)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct mrq_thermal_host_to_bpmp_request req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) union mrq_thermal_bpmp_to_host_response reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct tegra_bpmp_message msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) memset(&req, 0, sizeof(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) req.type = CMD_THERMAL_GET_NUM_ZONES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) memset(&msg, 0, sizeof(msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) msg.mrq = MRQ_THERMAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) msg.tx.data = &req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) msg.tx.size = sizeof(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) msg.rx.data = &reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) msg.rx.size = sizeof(reply);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) err = tegra_bpmp_transfer(bpmp, &msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *num_zones = reply.get_num_zones.num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static const struct thermal_zone_of_device_ops tegra_bpmp_of_thermal_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) .get_temp = tegra_bpmp_thermal_get_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) .set_trips = tegra_bpmp_thermal_set_trips,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static int tegra_bpmp_thermal_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct tegra_bpmp *bpmp = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct tegra_bpmp_thermal *tegra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) struct thermal_zone_device *tzd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) unsigned int i, max_num_zones;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (!tegra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) tegra->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) tegra->bpmp = bpmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) err = tegra_bpmp_thermal_get_num_zones(bpmp, &max_num_zones);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) dev_err(&pdev->dev, "failed to get the number of zones: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) tegra->zones = devm_kcalloc(&pdev->dev, max_num_zones,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) sizeof(*tegra->zones), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!tegra->zones)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) for (i = 0; i < max_num_zones; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct tegra_bpmp_thermal_zone *zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) zone = devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (!zone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) zone->idx = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) zone->tegra = tegra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) err = tegra_bpmp_thermal_get_temp(zone, &temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) devm_kfree(&pdev->dev, zone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) tzd = devm_thermal_zone_of_sensor_register(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) &pdev->dev, i, zone, &tegra_bpmp_of_thermal_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (IS_ERR(tzd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (PTR_ERR(tzd) == -EPROBE_DEFER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return -EPROBE_DEFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) devm_kfree(&pdev->dev, zone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) zone->tzd = tzd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) INIT_WORK(&zone->tz_device_update_work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) tz_device_update_work_fn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) tegra->zones[tegra->num_zones++] = zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) err = tegra_bpmp_request_mrq(bpmp, MRQ_THERMAL, bpmp_mrq_thermal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) tegra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) dev_err(&pdev->dev, "failed to register mrq handler: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) platform_set_drvdata(pdev, tegra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static int tegra_bpmp_thermal_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct tegra_bpmp_thermal *tegra = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) tegra_bpmp_free_mrq(tegra->bpmp, MRQ_THERMAL, tegra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static const struct of_device_id tegra_bpmp_thermal_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) { .compatible = "nvidia,tegra186-bpmp-thermal" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) { },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) MODULE_DEVICE_TABLE(of, tegra_bpmp_thermal_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static struct platform_driver tegra_bpmp_thermal_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) .probe = tegra_bpmp_thermal_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) .remove = tegra_bpmp_thermal_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) .name = "tegra-bpmp-thermal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) .of_match_table = tegra_bpmp_thermal_of_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) module_platform_driver(tegra_bpmp_thermal_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MODULE_AUTHOR("Mikko Perttunen <mperttunen@nvidia.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MODULE_DESCRIPTION("NVIDIA Tegra BPMP thermal sensor driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MODULE_LICENSE("GPL v2");