summaryrefslogtreecommitdiff
path: root/drivers/soc
diff options
context:
space:
mode:
authorFinley Xiao <finley.xiao@rock-chips.com>2018-03-07 19:51:12 +0800
committerTao Huang <huangtao@rock-chips.com>2018-07-19 09:14:52 +0800
commit0658b847023f2b01f32f2bd2017f033e04b67918 (patch)
tree65a49e53b17934071650055593c2bc8c9144538a /drivers/soc
parentd20c5570788e8d370faa5092ae34a14d3a9333a0 (diff)
soc: rockchip: pvtm: Add support to show temperature
Change-Id: Ibdf09a5a043e7f1a6d203513a6f22172e9e24c09 Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Diffstat (limited to 'drivers/soc')
-rw-r--r--drivers/soc/rockchip/rockchip_pvtm.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/soc/rockchip/rockchip_pvtm.c b/drivers/soc/rockchip/rockchip_pvtm.c
index 2442baf885f5..cb24b96cf501 100644
--- a/drivers/soc/rockchip/rockchip_pvtm.c
+++ b/drivers/soc/rockchip/rockchip_pvtm.c
@@ -28,6 +28,7 @@
#include <linux/reset.h>
#include <linux/slab.h>
#include <linux/soc/rockchip/pvtm.h>
+#include <linux/thermal.h>
#define PX30_PVTM_CORE 0
#define PX30_PVTM_PMU 1
@@ -93,6 +94,7 @@ struct rockchip_pvtm {
struct clk *clk;
struct reset_control *rst;
const struct rockchip_pvtm_channel *channel;
+ struct thermal_zone_device *tz;
u32 (*get_value)(struct rockchip_pvtm *pvtm, unsigned int sub_ch,
unsigned int time_us);
void (*set_ring_sel)(struct rockchip_pvtm *pvtm, unsigned int sub_ch);
@@ -108,13 +110,21 @@ static int pvtm_value_show(struct seq_file *s, void *data)
{
struct rockchip_pvtm *pvtm = (struct rockchip_pvtm *)s->private;
u32 value;
- int i;
+ int i, ret, cur_temp;
if (!pvtm) {
pr_err("pvtm struct NULL\n");
return -EINVAL;
}
+ if (pvtm->tz && pvtm->tz->ops && pvtm->tz->ops->get_temp) {
+ ret = pvtm->tz->ops->get_temp(pvtm->tz, &cur_temp);
+ if (ret)
+ dev_err(pvtm->dev, "debug failed to get temp\n");
+ else
+ seq_printf(s, "temp: %d ", cur_temp);
+ }
+ seq_puts(s, "pvtm: ");
for (i = 0; i < pvtm->channel->num_sub; i++) {
value = pvtm->get_value(pvtm, i, 1000);
seq_printf(s, "%d ", value);
@@ -477,10 +487,13 @@ MODULE_DEVICE_TABLE(of, rockchip_pvtm_match);
static int rockchip_pvtm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ struct device_node *np = pdev->dev.of_node;
const struct of_device_id *match;
const struct rockchip_pvtm_info *info;
struct rockchip_pvtm *pvtm;
struct regmap *grf;
+ struct thermal_zone_device *pvtm_tz = NULL;
+ const char *tz_name;
int i;
match = of_match_device(dev->driver->of_match_table, dev);
@@ -503,6 +516,14 @@ static int rockchip_pvtm_probe(struct platform_device *pdev)
if (!pvtm)
return -ENOMEM;
+ if (!of_property_read_string(np, "thermal-zone", &tz_name)) {
+ pvtm_tz = thermal_zone_get_zone_by_name(tz_name);
+ if (IS_ERR(pvtm_tz)) {
+ dev_err(dev, "debug failed to get pvtm_tz\n");
+ pvtm_tz = NULL;
+ }
+ }
+
for (i = 0; i < info->num_channels; i++) {
pvtm[i].dev = &pdev->dev;
pvtm[i].grf = grf;
@@ -510,6 +531,7 @@ static int rockchip_pvtm_probe(struct platform_device *pdev)
pvtm[i].sta = info->sta;
pvtm[i].get_value = info->get_value;
pvtm[i].channel = &info->channels[i];
+ pvtm[i].tz = pvtm_tz;
if (info->set_ring_sel)
pvtm[i].set_ring_sel = info->set_ring_sel;