Lines Matching refs:ptd

101 static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,  in pch_wpt_add_acpi_psv_trip()  argument
106 ptd->psv_trip_id = -1; in pch_wpt_add_acpi_psv_trip()
108 adev = ACPI_COMPANION(&ptd->pdev->dev); in pch_wpt_add_acpi_psv_trip()
120 ptd->psv_temp = trip_temp; in pch_wpt_add_acpi_psv_trip()
121 ptd->psv_trip_id = *nr_trips; in pch_wpt_add_acpi_psv_trip()
128 static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, in pch_wpt_add_acpi_psv_trip() argument
131 ptd->psv_trip_id = -1; in pch_wpt_add_acpi_psv_trip()
136 static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) in pch_wpt_init() argument
144 if (WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL)) { in pch_wpt_init()
145 ptd->bios_enabled = true; in pch_wpt_init()
149 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_init()
155 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
159 writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_init()
160 if (!(WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL))) { in pch_wpt_init()
161 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
166 ptd->crt_trip_id = -1; in pch_wpt_init()
167 trip_temp = readw(ptd->hw_base + WPT_CTT); in pch_wpt_init()
170 ptd->crt_temp = GET_WPT_TEMP(trip_temp); in pch_wpt_init()
171 ptd->crt_trip_id = 0; in pch_wpt_init()
175 ptd->hot_trip_id = -1; in pch_wpt_init()
176 trip_temp = readw(ptd->hw_base + WPT_PHL); in pch_wpt_init()
179 ptd->hot_temp = GET_WPT_TEMP(trip_temp); in pch_wpt_init()
180 ptd->hot_trip_id = *nr_trips; in pch_wpt_init()
184 pch_wpt_add_acpi_psv_trip(ptd, nr_trips); in pch_wpt_init()
189 static int pch_wpt_get_temp(struct pch_thermal_device *ptd, int *temp) in pch_wpt_get_temp() argument
191 *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_wpt_get_temp()
197 static int pch_wpt_suspend(struct pch_thermal_device *ptd) in pch_wpt_suspend() argument
204 if (!ptd->bios_enabled) { in pch_wpt_suspend()
205 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
206 writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
215 pch_thr_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TSPM)); in pch_wpt_suspend()
218 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_wpt_suspend()
233 dev_warn(&ptd->pdev->dev, "Wakeup event detected, abort cooling\n"); in pch_wpt_suspend()
238 dev_dbg(&ptd->pdev->dev, in pch_wpt_suspend()
243 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_wpt_suspend()
247 dev_warn(&ptd->pdev->dev, in pch_wpt_suspend()
252 dev_info(&ptd->pdev->dev, in pch_wpt_suspend()
256 dev_info(&ptd->pdev->dev, in pch_wpt_suspend()
264 static int pch_wpt_resume(struct pch_thermal_device *ptd) in pch_wpt_resume() argument
268 if (ptd->bios_enabled) in pch_wpt_resume()
271 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
273 writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
279 int (*hw_init)(struct pch_thermal_device *ptd, int *nr_trips);
280 int (*get_temp)(struct pch_thermal_device *ptd, int *temp);
281 int (*suspend)(struct pch_thermal_device *ptd);
282 int (*resume)(struct pch_thermal_device *ptd);
296 struct pch_thermal_device *ptd = tzd->devdata; in pch_thermal_get_temp() local
298 return ptd->ops->get_temp(ptd, temp); in pch_thermal_get_temp()
304 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_type() local
306 if (ptd->crt_trip_id == trip) in pch_get_trip_type()
308 else if (ptd->hot_trip_id == trip) in pch_get_trip_type()
310 else if (ptd->psv_trip_id == trip) in pch_get_trip_type()
320 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_temp() local
322 if (ptd->crt_trip_id == trip) in pch_get_trip_temp()
323 *temp = ptd->crt_temp; in pch_get_trip_temp()
324 else if (ptd->hot_trip_id == trip) in pch_get_trip_temp()
325 *temp = ptd->hot_temp; in pch_get_trip_temp()
326 else if (ptd->psv_trip_id == trip) in pch_get_trip_temp()
327 *temp = ptd->psv_temp; in pch_get_trip_temp()
390 struct pch_thermal_device *ptd; in intel_pch_thermal_probe() local
394 ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); in intel_pch_thermal_probe()
395 if (!ptd) in intel_pch_thermal_probe()
398 ptd->ops = bi->ops; in intel_pch_thermal_probe()
400 pci_set_drvdata(pdev, ptd); in intel_pch_thermal_probe()
401 ptd->pdev = pdev; in intel_pch_thermal_probe()
415 ptd->hw_base = pci_ioremap_bar(pdev, 0); in intel_pch_thermal_probe()
416 if (!ptd->hw_base) { in intel_pch_thermal_probe()
422 err = ptd->ops->hw_init(ptd, &nr_trips); in intel_pch_thermal_probe()
426 ptd->tzd = thermal_zone_device_register(bi->name, nr_trips, 0, ptd, in intel_pch_thermal_probe()
428 if (IS_ERR(ptd->tzd)) { in intel_pch_thermal_probe()
431 err = PTR_ERR(ptd->tzd); in intel_pch_thermal_probe()
434 err = thermal_zone_device_enable(ptd->tzd); in intel_pch_thermal_probe()
441 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_probe()
443 iounmap(ptd->hw_base); in intel_pch_thermal_probe()
454 struct pch_thermal_device *ptd = pci_get_drvdata(pdev); in intel_pch_thermal_remove() local
456 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_remove()
457 iounmap(ptd->hw_base); in intel_pch_thermal_remove()
465 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_suspend_noirq() local
467 return ptd->ops->suspend(ptd); in intel_pch_thermal_suspend_noirq()
472 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_resume() local
474 return ptd->ops->resume(ptd); in intel_pch_thermal_resume()