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>
14 #include <linux/thermal.h>
50 struct imx_sc_sensor *sensor = tz->devdata; in imx_sc_thermal_get_temp() local
53 msg.data.req.resource_id = sensor->resource_id; in imx_sc_thermal_get_temp()
56 hdr->ver = IMX_SC_RPC_VERSION; in imx_sc_thermal_get_temp()
57 hdr->svc = IMX_SC_RPC_SVC_MISC; in imx_sc_thermal_get_temp()
58 hdr->func = IMX_SC_MISC_FUNC_GET_TEMP; in imx_sc_thermal_get_temp()
59 hdr->size = 2; in imx_sc_thermal_get_temp()
63 dev_err(&sensor->tzd->device, "read temp sensor %d failed, ret %d\n", in imx_sc_thermal_get_temp()
64 sensor->resource_id, ret); in imx_sc_thermal_get_temp()
79 struct imx_sc_sensor *sensor; in imx_sc_thermal_probe() local
87 resource_id = of_device_get_match_data(&pdev->dev); in imx_sc_thermal_probe()
89 return -EINVAL; in imx_sc_thermal_probe()
93 sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL); in imx_sc_thermal_probe()
94 if (!sensor) in imx_sc_thermal_probe()
95 return -ENOMEM; in imx_sc_thermal_probe()
97 sensor->resource_id = resource_id[i]; in imx_sc_thermal_probe()
99 sensor->tzd = devm_thermal_of_zone_register(&pdev->dev, sensor->resource_id, in imx_sc_thermal_probe()
100 sensor, &imx_sc_thermal_ops); in imx_sc_thermal_probe()
101 if (IS_ERR(sensor->tzd)) { in imx_sc_thermal_probe()
104 * sensor pointer, otherwise we endup with a in imx_sc_thermal_probe()
105 * use-after-free error in imx_sc_thermal_probe()
107 ret = PTR_ERR(sensor->tzd); in imx_sc_thermal_probe()
109 devm_kfree(&pdev->dev, sensor); in imx_sc_thermal_probe()
112 * The thermal framework notifies us there is in imx_sc_thermal_probe()
113 * no thermal zone description for such a in imx_sc_thermal_probe()
114 * sensor id in imx_sc_thermal_probe()
116 if (ret == -ENODEV) in imx_sc_thermal_probe()
119 dev_err(&pdev->dev, "failed to register thermal zone\n"); in imx_sc_thermal_probe()
123 if (devm_thermal_add_hwmon_sysfs(sensor->tzd)) in imx_sc_thermal_probe()
124 dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); in imx_sc_thermal_probe()
135 static int imx_sc_sensors[] = { IMX_SC_R_SYSTEM, IMX_SC_R_PMIC_0, -1 };
138 { .compatible = "fsl,imx-sc-thermal", .data = imx_sc_sensors },
147 .name = "imx-sc-thermal",
154 MODULE_DESCRIPTION("Thermal driver for NXP i.MX SoCs with system controller");