1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
4 */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <thermal.h>
9 #include <power/pmic.h>
10 #include <power/sy7636a.h>
11
12 DECLARE_GLOBAL_DATA_PTR;
13
sy7636a_get_temp(struct udevice * dev,int * temp)14 static int sy7636a_get_temp(struct udevice *dev, int *temp)
15 {
16 struct udevice *pmic = dev_get_parent(dev);
17 int ret;
18
19 ret = pmic_reg_read(pmic, SY7636A_REG_TERMISTOR_READOUT);
20 if (ret < 0)
21 return ret;
22
23 *temp = *((signed char *)&ret);
24
25 return 0;
26 }
27
28 static const struct dm_thermal_ops sy7636a_thermal_ops = {
29 .get_temp = sy7636a_get_temp,
30 };
31
32 static const struct udevice_id sy7636a_thermal_of_match[] = {
33 { .compatible = SY7636A_THERMAL_COMTATIBLE_NAME },
34 { }
35 };
36
37 U_BOOT_DRIVER(sy7636a_thermal) = {
38 .name = SY7636A_THERMAL_COMTATIBLE_NAME,
39 .id = UCLASS_THERMAL,
40 .of_match = sy7636a_thermal_of_match,
41 .ops = &sy7636a_thermal_ops,
42 };
43