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