Lines Matching +full:thermal +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2018-2020 NXP.
6 #include <dt-bindings/firmware/imx/rsrc.h>
13 #include <linux/thermal.h>
48 struct imx_sc_sensor *sensor = thermal_zone_device_priv(tz); in imx_sc_thermal_get_temp() local
51 msg.data.req.resource_id = sensor->resource_id; in imx_sc_thermal_get_temp()
54 hdr->ver = IMX_SC_RPC_VERSION; in imx_sc_thermal_get_temp()
55 hdr->svc = IMX_SC_RPC_SVC_MISC; in imx_sc_thermal_get_temp()
56 hdr->func = IMX_SC_MISC_FUNC_GET_TEMP; in imx_sc_thermal_get_temp()
57 hdr->size = 2; in imx_sc_thermal_get_temp()
74 struct imx_sc_sensor *sensor; in imx_sc_thermal_probe() local
82 resource_id = of_device_get_match_data(&pdev->dev); in imx_sc_thermal_probe()
84 return -EINVAL; in imx_sc_thermal_probe()
88 sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL); in imx_sc_thermal_probe()
89 if (!sensor) in imx_sc_thermal_probe()
90 return -ENOMEM; in imx_sc_thermal_probe()
92 sensor->resource_id = resource_id[i]; in imx_sc_thermal_probe()
94 sensor->tzd = devm_thermal_of_zone_register(&pdev->dev, sensor->resource_id, in imx_sc_thermal_probe()
95 sensor, &imx_sc_thermal_ops); in imx_sc_thermal_probe()
96 if (IS_ERR(sensor->tzd)) { in imx_sc_thermal_probe()
99 * sensor pointer, otherwise we endup with a in imx_sc_thermal_probe()
100 * use-after-free error in imx_sc_thermal_probe()
102 ret = PTR_ERR(sensor->tzd); in imx_sc_thermal_probe()
104 devm_kfree(&pdev->dev, sensor); in imx_sc_thermal_probe()
107 * The thermal framework notifies us there is in imx_sc_thermal_probe()
108 * no thermal zone description for such a in imx_sc_thermal_probe()
109 * sensor id in imx_sc_thermal_probe()
111 if (ret == -ENODEV) in imx_sc_thermal_probe()
114 dev_err(&pdev->dev, "failed to register thermal zone\n"); in imx_sc_thermal_probe()
118 devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd); in imx_sc_thermal_probe()
128 IMX_SC_R_DRC_0, -1 };
131 { .compatible = "fsl,imx-sc-thermal", .data = imx_sc_sensors },
139 .name = "imx-sc-thermal",
146 MODULE_DESCRIPTION("Thermal driver for NXP i.MX SoCs with system controller");