^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * db8500_thermal.c - DB8500 Thermal Management Implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2012 ST-Ericsson
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2012-2019 Linaro Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Authors: Hongbo Zhang, Linus Walleij
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/cpu_cooling.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mfd/dbx500-prcmu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/thermal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define PRCMU_DEFAULT_MEASURE_TIME 0xFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define PRCMU_DEFAULT_LOW_TEMP 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * db8500_thermal_points - the interpolation points that trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static const unsigned long db8500_thermal_points[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 15000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 20000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 25000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 30000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 35000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 40000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 45000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 50000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 55000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 60000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 65000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 70000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 75000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 80000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * This is where things start to get really bad for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * SoC and the thermal zones should be set up to trigger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * critical temperature at 85000 mC so we don't get above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * this point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 85000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 90000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 95000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 100000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct db8500_thermal_zone {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct thermal_zone_device *tz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) enum thermal_trend trend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned long interpolated_temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) unsigned int cur_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Callback to get current temperature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static int db8500_thermal_get_temp(void *data, int *temp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct db8500_thermal_zone *th = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * TODO: There is no PRCMU interface to get temperature data currently,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * so a pseudo temperature is returned , it works for thermal framework
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * and this will be fixed when the PRCMU interface is available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) *temp = th->interpolated_temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* Callback to get temperature changing trend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static int db8500_thermal_get_trend(void *data, int trip, enum thermal_trend *trend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct db8500_thermal_zone *th = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) *trend = th->trend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) static struct thermal_zone_of_device_ops thdev_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .get_temp = db8500_thermal_get_temp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .get_trend = db8500_thermal_get_trend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static void db8500_thermal_update_config(struct db8500_thermal_zone *th,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned int idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) enum thermal_trend trend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) unsigned long next_low,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned long next_high)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) prcmu_stop_temp_sense();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) th->cur_index = idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) th->interpolated_temp = (next_low + next_high)/2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) th->trend = trend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * The PRCMU accept absolute temperatures in celsius so divide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * down the millicelsius with 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) prcmu_config_hotmon((u8)(next_low/1000), (u8)(next_high/1000));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) prcmu_start_temp_sense(PRCMU_DEFAULT_MEASURE_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static irqreturn_t prcmu_low_irq_handler(int irq, void *irq_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct db8500_thermal_zone *th = irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) unsigned int idx = th->cur_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned long next_low, next_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (idx == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* Meaningless for thermal management, ignoring it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (idx == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) next_high = db8500_thermal_points[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) next_low = PRCMU_DEFAULT_LOW_TEMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) next_high = db8500_thermal_points[idx - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) next_low = db8500_thermal_points[idx - 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) idx -= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) db8500_thermal_update_config(th, idx, THERMAL_TREND_DROPPING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) next_low, next_high);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) dev_dbg(&th->tz->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) "PRCMU set max %ld, min %ld\n", next_high, next_low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static irqreturn_t prcmu_high_irq_handler(int irq, void *irq_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct db8500_thermal_zone *th = irq_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) unsigned int idx = th->cur_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) unsigned long next_low, next_high;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int num_points = ARRAY_SIZE(db8500_thermal_points);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (idx < num_points - 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) next_high = db8500_thermal_points[idx+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) next_low = db8500_thermal_points[idx];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) idx += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) db8500_thermal_update_config(th, idx, THERMAL_TREND_RAISING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) next_low, next_high);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) dev_dbg(&th->tz->device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) "PRCMU set max %ld, min %ld\n", next_high, next_low);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) } else if (idx == num_points - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /* So we roof out 1 degree over the max point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) th->interpolated_temp = db8500_thermal_points[idx] + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) thermal_zone_device_update(th->tz, THERMAL_EVENT_UNSPECIFIED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static int db8500_thermal_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct db8500_thermal_zone *th = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int low_irq, high_irq, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) th = devm_kzalloc(dev, sizeof(*th), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (!th)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (low_irq < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) dev_err(dev, "Get IRQ_HOTMON_LOW failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return low_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) ret = devm_request_threaded_irq(dev, low_irq, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) "dbx500_temp_low", th);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) dev_err(dev, "failed to allocate temp low irq\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (high_irq < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) dev_err(dev, "Get IRQ_HOTMON_HIGH failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return high_irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ret = devm_request_threaded_irq(dev, high_irq, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "dbx500_temp_high", th);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) dev_err(dev, "failed to allocate temp high irq\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /* register of thermal sensor and get info from DT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) th->tz = devm_thermal_zone_of_sensor_register(dev, 0, th, &thdev_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (IS_ERR(th->tz)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) dev_err(dev, "register thermal zone sensor failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return PTR_ERR(th->tz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) dev_info(dev, "thermal zone sensor registered\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* Start measuring at the lowest point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) db8500_thermal_update_config(th, 0, THERMAL_TREND_STABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) PRCMU_DEFAULT_LOW_TEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) db8500_thermal_points[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) platform_set_drvdata(pdev, th);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static int db8500_thermal_suspend(struct platform_device *pdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) pm_message_t state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) prcmu_stop_temp_sense();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static int db8500_thermal_resume(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct db8500_thermal_zone *th = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* Resume and start measuring at the lowest point */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) db8500_thermal_update_config(th, 0, THERMAL_TREND_STABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) PRCMU_DEFAULT_LOW_TEMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) db8500_thermal_points[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static const struct of_device_id db8500_thermal_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) { .compatible = "stericsson,db8500-thermal" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) MODULE_DEVICE_TABLE(of, db8500_thermal_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static struct platform_driver db8500_thermal_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .name = "db8500-thermal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .of_match_table = of_match_ptr(db8500_thermal_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .probe = db8500_thermal_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .suspend = db8500_thermal_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .resume = db8500_thermal_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) module_platform_driver(db8500_thermal_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MODULE_DESCRIPTION("DB8500 thermal driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MODULE_LICENSE("GPL");