exynos_tmu.c (8bfc218d0ebbabcba8ed2b8ec1831e0cf1f71629) | exynos_tmu.c (75e0f100774f84db43a1a14a3b6a8d3375bed321) |
---|---|
1/* 2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) 3 * 4 * Copyright (C) 2014 Samsung Electronics 5 * Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> 6 * Lukasz Majewski <l.majewski@samsung.com> 7 * 8 * Copyright (C) 2011 Samsung Electronics --- 295 unchanged lines hidden (view full) --- 304static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling) 305{ 306 struct thermal_zone_device *tz = data->tzd; 307 const struct thermal_trip * const trips = 308 of_thermal_get_trip_points(tz); 309 unsigned long temp; 310 int i; 311 | 1/* 2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit) 3 * 4 * Copyright (C) 2014 Samsung Electronics 5 * Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> 6 * Lukasz Majewski <l.majewski@samsung.com> 7 * 8 * Copyright (C) 2011 Samsung Electronics --- 295 unchanged lines hidden (view full) --- 304static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling) 305{ 306 struct thermal_zone_device *tz = data->tzd; 307 const struct thermal_trip * const trips = 308 of_thermal_get_trip_points(tz); 309 unsigned long temp; 310 int i; 311 |
312 if (!trips) { 313 pr_err("%s: Cannot get trip points from of-thermal.c!\n", 314 __func__); 315 return 0; 316 } 317 | |
318 for (i = 0; i < of_thermal_get_ntrips(tz); i++) { 319 if (trips[i].type == THERMAL_TRIP_CRITICAL) 320 continue; 321 322 temp = trips[i].temperature / MCELSIUS; 323 if (falling) 324 temp -= (trips[i].hysteresis / MCELSIUS); 325 else 326 threshold &= ~(0xff << 8 * i); 327 328 threshold |= temp_to_code(data, temp) << 8 * i; 329 } 330 331 return threshold; 332} 333 334static int exynos_tmu_initialize(struct platform_device *pdev) 335{ 336 struct exynos_tmu_data *data = platform_get_drvdata(pdev); | 312 for (i = 0; i < of_thermal_get_ntrips(tz); i++) { 313 if (trips[i].type == THERMAL_TRIP_CRITICAL) 314 continue; 315 316 temp = trips[i].temperature / MCELSIUS; 317 if (falling) 318 temp -= (trips[i].hysteresis / MCELSIUS); 319 else 320 threshold &= ~(0xff << 8 * i); 321 322 threshold |= temp_to_code(data, temp) << 8 * i; 323 } 324 325 return threshold; 326} 327 328static int exynos_tmu_initialize(struct platform_device *pdev) 329{ 330 struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
331 struct thermal_zone_device *tzd = data->tzd; 332 const struct thermal_trip * const trips = 333 of_thermal_get_trip_points(tzd); |
|
337 int ret; 338 | 334 int ret; 335 |
339 if (of_thermal_get_ntrips(data->tzd) > data->ntrip) { | 336 if (!trips) { 337 dev_err(&pdev->dev, 338 "Cannot get trip points from device tree!\n"); 339 return -ENODEV; 340 } 341 342 if (of_thermal_get_ntrips(tzd) > data->ntrip) { |
340 dev_info(&pdev->dev, 341 "More trip points than supported by this TMU.\n"); 342 dev_info(&pdev->dev, 343 "%d trip points should be configured in polling mode.\n", | 343 dev_info(&pdev->dev, 344 "More trip points than supported by this TMU.\n"); 345 dev_info(&pdev->dev, 346 "%d trip points should be configured in polling mode.\n", |
344 (of_thermal_get_ntrips(data->tzd) - data->ntrip)); | 347 (of_thermal_get_ntrips(tzd) - data->ntrip)); |
345 } 346 347 mutex_lock(&data->lock); 348 clk_enable(data->clk); 349 if (!IS_ERR(data->clk_sec)) 350 clk_enable(data->clk_sec); 351 ret = data->tmu_initialize(pdev); 352 clk_disable(data->clk); --- 39 unchanged lines hidden (view full) --- 392 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 393 struct thermal_zone_device *tz = data->tzd; 394 const struct thermal_trip * const trips = 395 of_thermal_get_trip_points(tz); 396 int ret = 0, threshold_code, i; 397 unsigned long reference, temp; 398 unsigned int status; 399 | 348 } 349 350 mutex_lock(&data->lock); 351 clk_enable(data->clk); 352 if (!IS_ERR(data->clk_sec)) 353 clk_enable(data->clk_sec); 354 ret = data->tmu_initialize(pdev); 355 clk_disable(data->clk); --- 39 unchanged lines hidden (view full) --- 395 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 396 struct thermal_zone_device *tz = data->tzd; 397 const struct thermal_trip * const trips = 398 of_thermal_get_trip_points(tz); 399 int ret = 0, threshold_code, i; 400 unsigned long reference, temp; 401 unsigned int status; 402 |
400 if (!trips) { 401 pr_err("%s: Cannot get trip points from of-thermal.c!\n", 402 __func__); 403 ret = -ENODEV; 404 goto out; 405 } 406 | |
407 status = readb(data->base + EXYNOS_TMU_REG_STATUS); 408 if (!status) { 409 ret = -EBUSY; 410 goto out; 411 } 412 413 sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO)); 414 --- 906 unchanged lines hidden --- | 403 status = readb(data->base + EXYNOS_TMU_REG_STATUS); 404 if (!status) { 405 ret = -EBUSY; 406 goto out; 407 } 408 409 sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO)); 410 --- 906 unchanged lines hidden --- |