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