exynos_tmu.c (ca38255e92112c4204dbd551934505baf25849f4) exynos_tmu.c (a3b3dd381a0806cf19dab07a16f066e64d70a32d)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * exynos_tmu.c - Samsung Exynos TMU (Thermal Management Unit)
4 *
5 * Copyright (C) 2014 Samsung Electronics
6 * Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
7 * Lukasz Majewski <l.majewski@samsung.com>
8 *

--- 246 unchanged lines hidden (view full) ---

255 (data->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
256 EXYNOS_TMU_TEMP_MASK;
257}
258
259static int exynos_tmu_initialize(struct platform_device *pdev)
260{
261 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
262 struct thermal_zone_device *tzd = data->tzd;
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * exynos_tmu.c - Samsung Exynos TMU (Thermal Management Unit)
4 *
5 * Copyright (C) 2014 Samsung Electronics
6 * Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
7 * Lukasz Majewski <l.majewski@samsung.com>
8 *

--- 246 unchanged lines hidden (view full) ---

255 (data->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
256 EXYNOS_TMU_TEMP_MASK;
257}
258
259static int exynos_tmu_initialize(struct platform_device *pdev)
260{
261 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
262 struct thermal_zone_device *tzd = data->tzd;
263 int num_trips = thermal_zone_get_num_trips(tzd);
263 unsigned int status;
264 int ret = 0, temp;
265
266 if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
267 ret = tzd->ops->get_crit_temp(tzd, &temp);
268 if (ret) {
269 dev_err(&pdev->dev,
270 "No CRITICAL trip point defined in device tree!\n");
271 goto out;
272 }
273
264 unsigned int status;
265 int ret = 0, temp;
266
267 if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
268 ret = tzd->ops->get_crit_temp(tzd, &temp);
269 if (ret) {
270 dev_err(&pdev->dev,
271 "No CRITICAL trip point defined in device tree!\n");
272 goto out;
273 }
274
274 if (of_thermal_get_ntrips(tzd) > data->ntrip) {
275 if (num_trips > data->ntrip) {
275 dev_info(&pdev->dev,
276 "More trip points than supported by this TMU.\n");
277 dev_info(&pdev->dev,
278 "%d trip points should be configured in polling mode.\n",
276 dev_info(&pdev->dev,
277 "More trip points than supported by this TMU.\n");
278 dev_info(&pdev->dev,
279 "%d trip points should be configured in polling mode.\n",
279 (of_thermal_get_ntrips(tzd) - data->ntrip));
280 num_trips - data->ntrip);
280 }
281
282 mutex_lock(&data->lock);
283 clk_enable(data->clk);
284 if (!IS_ERR(data->clk_sec))
285 clk_enable(data->clk_sec);
286
287 status = readb(data->base + EXYNOS_TMU_REG_STATUS);
288 if (!status) {
289 ret = -EBUSY;
290 } else {
291 int i, ntrips =
281 }
282
283 mutex_lock(&data->lock);
284 clk_enable(data->clk);
285 if (!IS_ERR(data->clk_sec))
286 clk_enable(data->clk_sec);
287
288 status = readb(data->base + EXYNOS_TMU_REG_STATUS);
289 if (!status) {
290 ret = -EBUSY;
291 } else {
292 int i, ntrips =
292 min_t(int, of_thermal_get_ntrips(tzd), data->ntrip);
293 min_t(int, num_trips, data->ntrip);
293
294 data->tmu_initialize(pdev);
295
296 /* Write temperature code for rising and falling threshold */
297 for (i = 0; i < ntrips; i++) {
298
299 struct thermal_trip trip;
300

--- 882 unchanged lines hidden ---
294
295 data->tmu_initialize(pdev);
296
297 /* Write temperature code for rising and falling threshold */
298 for (i = 0; i < ntrips; i++) {
299
300 struct thermal_trip trip;
301

--- 882 unchanged lines hidden ---