Lines Matching refs:ptd
81 static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, in pch_wpt_add_acpi_psv_trip() argument
86 ptd->psv_trip_id = -1; in pch_wpt_add_acpi_psv_trip()
88 adev = ACPI_COMPANION(&ptd->pdev->dev); in pch_wpt_add_acpi_psv_trip()
100 ptd->psv_temp = trip_temp; in pch_wpt_add_acpi_psv_trip()
101 ptd->psv_trip_id = *nr_trips; in pch_wpt_add_acpi_psv_trip()
108 static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, in pch_wpt_add_acpi_psv_trip() argument
111 ptd->psv_trip_id = -1; in pch_wpt_add_acpi_psv_trip()
116 static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) in pch_wpt_init() argument
124 if (WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL)) { in pch_wpt_init()
125 ptd->bios_enabled = true; in pch_wpt_init()
129 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_init()
135 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
139 writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_init()
140 if (!(WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL))) { in pch_wpt_init()
141 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
146 ptd->crt_trip_id = -1; in pch_wpt_init()
147 trip_temp = readw(ptd->hw_base + WPT_CTT); in pch_wpt_init()
151 ptd->crt_temp = trip_temp * 1000 / 2 - 50000; in pch_wpt_init()
152 ptd->crt_trip_id = 0; in pch_wpt_init()
156 ptd->hot_trip_id = -1; in pch_wpt_init()
157 trip_temp = readw(ptd->hw_base + WPT_PHL); in pch_wpt_init()
161 ptd->hot_temp = trip_temp * 1000 / 2 - 50000; in pch_wpt_init()
162 ptd->hot_trip_id = *nr_trips; in pch_wpt_init()
166 pch_wpt_add_acpi_psv_trip(ptd, nr_trips); in pch_wpt_init()
171 static int pch_wpt_get_temp(struct pch_thermal_device *ptd, int *temp) in pch_wpt_get_temp() argument
175 wpt_temp = WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP); in pch_wpt_get_temp()
183 static int pch_wpt_suspend(struct pch_thermal_device *ptd) in pch_wpt_suspend() argument
187 if (ptd->bios_enabled) in pch_wpt_suspend()
190 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
192 writeb(tsel & 0xFE, ptd->hw_base + WPT_TSEL); in pch_wpt_suspend()
197 static int pch_wpt_resume(struct pch_thermal_device *ptd) in pch_wpt_resume() argument
201 if (ptd->bios_enabled) in pch_wpt_resume()
204 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
206 writeb(tsel | WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_resume()
212 int (*hw_init)(struct pch_thermal_device *ptd, int *nr_trips);
213 int (*get_temp)(struct pch_thermal_device *ptd, int *temp);
214 int (*suspend)(struct pch_thermal_device *ptd);
215 int (*resume)(struct pch_thermal_device *ptd);
229 struct pch_thermal_device *ptd = tzd->devdata; in pch_thermal_get_temp() local
231 return ptd->ops->get_temp(ptd, temp); in pch_thermal_get_temp()
237 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_type() local
239 if (ptd->crt_trip_id == trip) in pch_get_trip_type()
241 else if (ptd->hot_trip_id == trip) in pch_get_trip_type()
243 else if (ptd->psv_trip_id == trip) in pch_get_trip_type()
253 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_temp() local
255 if (ptd->crt_trip_id == trip) in pch_get_trip_temp()
256 *temp = ptd->crt_temp; in pch_get_trip_temp()
257 else if (ptd->hot_trip_id == trip) in pch_get_trip_temp()
258 *temp = ptd->hot_temp; in pch_get_trip_temp()
259 else if (ptd->psv_trip_id == trip) in pch_get_trip_temp()
260 *temp = ptd->psv_temp; in pch_get_trip_temp()
312 struct pch_thermal_device *ptd; in intel_pch_thermal_probe() local
316 ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); in intel_pch_thermal_probe()
317 if (!ptd) in intel_pch_thermal_probe()
320 ptd->ops = bi->ops; in intel_pch_thermal_probe()
322 pci_set_drvdata(pdev, ptd); in intel_pch_thermal_probe()
323 ptd->pdev = pdev; in intel_pch_thermal_probe()
337 ptd->hw_base = pci_ioremap_bar(pdev, 0); in intel_pch_thermal_probe()
338 if (!ptd->hw_base) { in intel_pch_thermal_probe()
344 err = ptd->ops->hw_init(ptd, &nr_trips); in intel_pch_thermal_probe()
348 ptd->tzd = thermal_zone_device_register(bi->name, nr_trips, 0, ptd, in intel_pch_thermal_probe()
350 if (IS_ERR(ptd->tzd)) { in intel_pch_thermal_probe()
353 err = PTR_ERR(ptd->tzd); in intel_pch_thermal_probe()
356 err = thermal_zone_device_enable(ptd->tzd); in intel_pch_thermal_probe()
363 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_probe()
365 iounmap(ptd->hw_base); in intel_pch_thermal_probe()
376 struct pch_thermal_device *ptd = pci_get_drvdata(pdev); in intel_pch_thermal_remove() local
378 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_remove()
379 iounmap(ptd->hw_base); in intel_pch_thermal_remove()
387 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_suspend() local
389 return ptd->ops->suspend(ptd); in intel_pch_thermal_suspend()
394 struct pch_thermal_device *ptd = dev_get_drvdata(device); in intel_pch_thermal_resume() local
396 return ptd->ops->resume(ptd); in intel_pch_thermal_resume()