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()
196 static int pch_wpt_suspend(struct pch_thermal_device *ptd) in pch_wpt_suspend() argument
203 if (!ptd->bios_enabled) { in pch_wpt_suspend()
204 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
205 writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
222 pch_thr_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TSPM)); in pch_wpt_suspend()
225 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_wpt_suspend()
239 dev_warn(&ptd->pdev->dev, in pch_wpt_suspend()
244 pch_cur_temp = GET_PCH_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); in pch_wpt_suspend()
249 dev_warn(&ptd->pdev->dev, in pch_wpt_suspend()
253 dev_info(&ptd->pdev->dev, in pch_wpt_suspend()
259 static int pch_wpt_resume(struct pch_thermal_device *ptd) in pch_wpt_resume() argument
263 if (ptd->bios_enabled) in pch_wpt_resume()
266 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
268 writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
274 int (*hw_init)(struct pch_thermal_device *ptd, int *nr_trips);
275 int (*get_temp)(struct pch_thermal_device *ptd, int *temp);
276 int (*suspend)(struct pch_thermal_device *ptd);
277 int (*resume)(struct pch_thermal_device *ptd);
291 struct pch_thermal_device *ptd = tzd->devdata; in pch_thermal_get_temp() local
293 return ptd->ops->get_temp(ptd, temp); in pch_thermal_get_temp()
299 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_type() local
301 if (ptd->crt_trip_id == trip) in pch_get_trip_type()
303 else if (ptd->hot_trip_id == trip) in pch_get_trip_type()
305 else if (ptd->psv_trip_id == trip) in pch_get_trip_type()
315 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_temp() local
317 if (ptd->crt_trip_id == trip) in pch_get_trip_temp()
318 *temp = ptd->crt_temp; in pch_get_trip_temp()
319 else if (ptd->hot_trip_id == trip) in pch_get_trip_temp()
320 *temp = ptd->hot_temp; in pch_get_trip_temp()
321 else if (ptd->psv_trip_id == trip) in pch_get_trip_temp()
322 *temp = ptd->psv_temp; in pch_get_trip_temp()
385 struct pch_thermal_device *ptd; in intel_pch_thermal_probe() local
389 ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); in intel_pch_thermal_probe()
390 if (!ptd) in intel_pch_thermal_probe()
393 ptd->ops = bi->ops; in intel_pch_thermal_probe()
395 pci_set_drvdata(pdev, ptd); in intel_pch_thermal_probe()
396 ptd->pdev = pdev; in intel_pch_thermal_probe()
410 ptd->hw_base = pci_ioremap_bar(pdev, 0); in intel_pch_thermal_probe()
411 if (!ptd->hw_base) { in intel_pch_thermal_probe()
417 err = ptd->ops->hw_init(ptd, &nr_trips); in intel_pch_thermal_probe()
421 ptd->tzd = thermal_zone_device_register(bi->name, nr_trips, 0, ptd, in intel_pch_thermal_probe()
423 if (IS_ERR(ptd->tzd)) { in intel_pch_thermal_probe()
426 err = PTR_ERR(ptd->tzd); in intel_pch_thermal_probe()
429 err = thermal_zone_device_enable(ptd->tzd); in intel_pch_thermal_probe()
436 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_probe()
438 iounmap(ptd->hw_base); in intel_pch_thermal_probe()
449 struct pch_thermal_device *ptd = pci_get_drvdata(pdev); in intel_pch_thermal_remove() local
451 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_remove()
452 iounmap(ptd->hw_base); in intel_pch_thermal_remove()
460 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_suspend() local
462 return ptd->ops->suspend(ptd); in intel_pch_thermal_suspend()
467 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_resume() local
469 return ptd->ops->resume(ptd); in intel_pch_thermal_resume()