exynos_tmu.c (75e0f100774f84db43a1a14a3b6a8d3375bed321) | exynos_tmu.c (8f1c404b212baec2f7cb46182a45067066aed131) |
---|---|
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 --- 317 unchanged lines hidden (view full) --- 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); | 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 --- 317 unchanged lines hidden (view full) --- 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); |
334 int ret; | 334 int ret = 0, temp; |
335 336 if (!trips) { 337 dev_err(&pdev->dev, 338 "Cannot get trip points from device tree!\n"); 339 return -ENODEV; 340 } 341 | 335 336 if (!trips) { 337 dev_err(&pdev->dev, 338 "Cannot get trip points from device tree!\n"); 339 return -ENODEV; 340 } 341 |
342 if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ 343 ret = tzd->ops->get_crit_temp(tzd, &temp); 344 if (ret) { 345 dev_err(&pdev->dev, 346 "No CRITICAL trip point defined in device tree!\n"); 347 goto out; 348 } 349 |
|
342 if (of_thermal_get_ntrips(tzd) > data->ntrip) { 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", 347 (of_thermal_get_ntrips(tzd) - data->ntrip)); 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); 356 mutex_unlock(&data->lock); 357 if (!IS_ERR(data->clk_sec)) 358 clk_disable(data->clk_sec); | 350 if (of_thermal_get_ntrips(tzd) > data->ntrip) { 351 dev_info(&pdev->dev, 352 "More trip points than supported by this TMU.\n"); 353 dev_info(&pdev->dev, 354 "%d trip points should be configured in polling mode.\n", 355 (of_thermal_get_ntrips(tzd) - data->ntrip)); 356 } 357 358 mutex_lock(&data->lock); 359 clk_enable(data->clk); 360 if (!IS_ERR(data->clk_sec)) 361 clk_enable(data->clk_sec); 362 ret = data->tmu_initialize(pdev); 363 clk_disable(data->clk); 364 mutex_unlock(&data->lock); 365 if (!IS_ERR(data->clk_sec)) 366 clk_disable(data->clk_sec); |
359 | 367out: |
360 return ret; 361} 362 363static u32 get_con_reg(struct exynos_tmu_data *data, u32 con) 364{ 365 if (data->soc == SOC_ARCH_EXYNOS4412 || 366 data->soc == SOC_ARCH_EXYNOS3250) 367 con |= (EXYNOS4412_MUX_ADDR_VALUE << EXYNOS4412_MUX_ADDR_SHIFT); --- 107 unchanged lines hidden (view full) --- 475 /* if last threshold limit is also present */ 476 for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) { 477 if (trips[i].type == THERMAL_TRIP_CRITICAL) { 478 crit_temp = trips[i].temperature; 479 break; 480 } 481 } 482 | 368 return ret; 369} 370 371static u32 get_con_reg(struct exynos_tmu_data *data, u32 con) 372{ 373 if (data->soc == SOC_ARCH_EXYNOS4412 || 374 data->soc == SOC_ARCH_EXYNOS3250) 375 con |= (EXYNOS4412_MUX_ADDR_VALUE << EXYNOS4412_MUX_ADDR_SHIFT); --- 107 unchanged lines hidden (view full) --- 483 /* if last threshold limit is also present */ 484 for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) { 485 if (trips[i].type == THERMAL_TRIP_CRITICAL) { 486 crit_temp = trips[i].temperature; 487 break; 488 } 489 } 490 |
483 if (i == of_thermal_get_ntrips(data->tzd)) { 484 pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n", 485 __func__); 486 ret = -EINVAL; 487 goto out; 488 } 489 | |
490 threshold_code = temp_to_code(data, crit_temp / MCELSIUS); 491 /* 1-4 level to be assigned in th0 reg */ 492 rising_threshold &= ~(0xff << 8 * i); 493 rising_threshold |= threshold_code << 8 * i; 494 writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE); 495 con = readl(data->base + EXYNOS_TMU_REG_CONTROL); 496 con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT); 497 writel(con, data->base + EXYNOS_TMU_REG_CONTROL); --- 819 unchanged lines hidden --- | 491 threshold_code = temp_to_code(data, crit_temp / MCELSIUS); 492 /* 1-4 level to be assigned in th0 reg */ 493 rising_threshold &= ~(0xff << 8 * i); 494 rising_threshold |= threshold_code << 8 * i; 495 writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE); 496 con = readl(data->base + EXYNOS_TMU_REG_CONTROL); 497 con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT); 498 writel(con, data->base + EXYNOS_TMU_REG_CONTROL); --- 819 unchanged lines hidden --- |