Lines Matching refs:thm

149 				       struct sprd_thermal_data *thm,  in sprd_thm_sensor_calibration()  argument
163 ratio += thm->ratio_sign * thm->ratio_off; in sprd_thm_sensor_calibration()
172 sen->cal_slope = (thm->var_data->ideal_k * ratio) / 1000; in sprd_thm_sensor_calibration()
173 sen->cal_offset = thm->var_data->ideal_b + (dt_offset - 128) * 250; in sprd_thm_sensor_calibration()
224 static int sprd_thm_poll_ready_status(struct sprd_thermal_data *thm) in sprd_thm_poll_ready_status() argument
232 ret = readl_poll_timeout(thm->base + SPRD_THM_CTL, val, in sprd_thm_poll_ready_status()
239 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, SPRD_THM_MON_EN, in sprd_thm_poll_ready_status()
241 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, SPRD_THM_SET_RDY, in sprd_thm_poll_ready_status()
246 static int sprd_thm_wait_temp_ready(struct sprd_thermal_data *thm) in sprd_thm_wait_temp_ready() argument
251 return readl_poll_timeout(thm->base + SPRD_THM_INTERNAL_STS1, val, in sprd_thm_wait_temp_ready()
257 static int sprd_thm_set_ready(struct sprd_thermal_data *thm) in sprd_thm_set_ready() argument
261 ret = sprd_thm_poll_ready_status(thm); in sprd_thm_set_ready()
274 writel(SPRD_THM_INT_CLR_MASK, thm->base + SPRD_THM_INT_CLR); in sprd_thm_set_ready()
275 sprd_thm_update_bits(thm->base + SPRD_THM_INT_EN, in sprd_thm_set_ready()
277 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, in sprd_thm_set_ready()
282 static void sprd_thm_sensor_init(struct sprd_thermal_data *thm, in sprd_thm_sensor_init() argument
291 sprd_thm_update_bits(thm->base + SPRD_THM_INT_EN, in sprd_thm_sensor_init()
296 sprd_thm_update_bits(thm->base + SPRD_THM_THRES(sen->id), in sprd_thm_sensor_init()
302 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, SPRD_THM_SEN(sen->id), in sprd_thm_sensor_init()
306 static void sprd_thm_para_config(struct sprd_thermal_data *thm) in sprd_thm_para_config() argument
309 sprd_thm_update_bits(thm->base + SPRD_THM_DET_PERIOD, in sprd_thm_para_config()
313 sprd_thm_update_bits(thm->base + SPRD_THM_MON_CTL, in sprd_thm_para_config()
317 sprd_thm_update_bits(thm->base + SPRD_THM_MON_PERIOD, in sprd_thm_para_config()
335 struct sprd_thermal_data *thm; in sprd_thm_probe() local
347 thm = devm_kzalloc(&pdev->dev, sizeof(*thm), GFP_KERNEL); in sprd_thm_probe()
348 if (!thm) in sprd_thm_probe()
351 thm->var_data = pdata; in sprd_thm_probe()
352 thm->base = devm_platform_ioremap_resource(pdev, 0); in sprd_thm_probe()
353 if (IS_ERR(thm->base)) in sprd_thm_probe()
354 return PTR_ERR(thm->base); in sprd_thm_probe()
356 thm->nr_sensors = of_get_child_count(np); in sprd_thm_probe()
357 if (thm->nr_sensors == 0 || thm->nr_sensors > SPRD_THM_MAX_SENSOR) { in sprd_thm_probe()
362 thm->clk = devm_clk_get(&pdev->dev, "enable"); in sprd_thm_probe()
363 if (IS_ERR(thm->clk)) { in sprd_thm_probe()
365 return PTR_ERR(thm->clk); in sprd_thm_probe()
368 ret = clk_prepare_enable(thm->clk); in sprd_thm_probe()
372 sprd_thm_para_config(thm); in sprd_thm_probe()
379 thm->ratio_sign = -1; in sprd_thm_probe()
381 thm->ratio_sign = 1; in sprd_thm_probe()
383 ret = sprd_thm_cal_read(np, "thm_ratio_cal", &thm->ratio_off); in sprd_thm_probe()
394 sen->data = thm; in sprd_thm_probe()
403 ret = sprd_thm_sensor_calibration(sen_child, thm, sen); in sprd_thm_probe()
409 sprd_thm_sensor_init(thm, sen); in sprd_thm_probe()
422 thm->sensor[sen->id] = sen; in sprd_thm_probe()
426 ret = sprd_thm_set_ready(thm); in sprd_thm_probe()
430 ret = sprd_thm_wait_temp_ready(thm); in sprd_thm_probe()
434 for (i = 0; i < thm->nr_sensors; i++) in sprd_thm_probe()
435 sprd_thm_toggle_sensor(thm->sensor[i], true); in sprd_thm_probe()
437 platform_set_drvdata(pdev, thm); in sprd_thm_probe()
443 clk_disable_unprepare(thm->clk); in sprd_thm_probe()
448 static void sprd_thm_hw_suspend(struct sprd_thermal_data *thm) in sprd_thm_hw_suspend() argument
452 for (i = 0; i < thm->nr_sensors; i++) { in sprd_thm_hw_suspend()
453 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, in sprd_thm_hw_suspend()
454 SPRD_THM_SEN(thm->sensor[i]->id), 0); in sprd_thm_hw_suspend()
457 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, in sprd_thm_hw_suspend()
463 struct sprd_thermal_data *thm = dev_get_drvdata(dev); in sprd_thm_suspend() local
466 for (i = 0; i < thm->nr_sensors; i++) in sprd_thm_suspend()
467 sprd_thm_toggle_sensor(thm->sensor[i], false); in sprd_thm_suspend()
469 sprd_thm_hw_suspend(thm); in sprd_thm_suspend()
470 clk_disable_unprepare(thm->clk); in sprd_thm_suspend()
475 static int sprd_thm_hw_resume(struct sprd_thermal_data *thm) in sprd_thm_hw_resume() argument
479 for (i = 0; i < thm->nr_sensors; i++) { in sprd_thm_hw_resume()
480 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, in sprd_thm_hw_resume()
481 SPRD_THM_SEN(thm->sensor[i]->id), in sprd_thm_hw_resume()
482 SPRD_THM_SEN(thm->sensor[i]->id)); in sprd_thm_hw_resume()
485 ret = sprd_thm_poll_ready_status(thm); in sprd_thm_hw_resume()
489 writel(SPRD_THM_INT_CLR_MASK, thm->base + SPRD_THM_INT_CLR); in sprd_thm_hw_resume()
490 sprd_thm_update_bits(thm->base + SPRD_THM_CTL, in sprd_thm_hw_resume()
492 return sprd_thm_wait_temp_ready(thm); in sprd_thm_hw_resume()
497 struct sprd_thermal_data *thm = dev_get_drvdata(dev); in sprd_thm_resume() local
500 ret = clk_prepare_enable(thm->clk); in sprd_thm_resume()
504 ret = sprd_thm_hw_resume(thm); in sprd_thm_resume()
508 for (i = 0; i < thm->nr_sensors; i++) in sprd_thm_resume()
509 sprd_thm_toggle_sensor(thm->sensor[i], true); in sprd_thm_resume()
514 clk_disable_unprepare(thm->clk); in sprd_thm_resume()
521 struct sprd_thermal_data *thm = platform_get_drvdata(pdev); in sprd_thm_remove() local
524 for (i = 0; i < thm->nr_sensors; i++) { in sprd_thm_remove()
525 sprd_thm_toggle_sensor(thm->sensor[i], false); in sprd_thm_remove()
527 thm->sensor[i]->tzd); in sprd_thm_remove()
530 clk_disable_unprepare(thm->clk); in sprd_thm_remove()