Lines Matching refs:ptd

69 static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips)  in pch_wpt_init()  argument
77 if (WPT_TSS_TSDSS & readb(ptd->hw_base + WPT_TSS)) in pch_wpt_init()
80 tsel = readb(ptd->hw_base + WPT_TSEL); in pch_wpt_init()
86 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
90 writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL); in pch_wpt_init()
91 if (!(WPT_TSS_TSDSS & readb(ptd->hw_base + WPT_TSS))) { in pch_wpt_init()
92 dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n"); in pch_wpt_init()
97 ptd->crt_trip_id = -1; in pch_wpt_init()
98 trip_temp = readw(ptd->hw_base + WPT_CTT); in pch_wpt_init()
102 ptd->crt_temp = trip_temp * 1000 / 2 - 50000; in pch_wpt_init()
103 ptd->crt_trip_id = 0; in pch_wpt_init()
107 ptd->hot_trip_id = -1; in pch_wpt_init()
108 trip_temp = readw(ptd->hw_base + WPT_PHL); in pch_wpt_init()
112 ptd->hot_temp = trip_temp * 1000 / 2 - 50000; in pch_wpt_init()
113 ptd->hot_trip_id = *nr_trips; in pch_wpt_init()
120 static int pch_wpt_get_temp(struct pch_thermal_device *ptd, int *temp) in pch_wpt_get_temp() argument
124 wpt_temp = WPT_TEMP_TSR & readl(ptd->hw_base + WPT_TEMP); in pch_wpt_get_temp()
133 int (*hw_init)(struct pch_thermal_device *ptd, int *nr_trips);
134 int (*get_temp)(struct pch_thermal_device *ptd, int *temp);
146 struct pch_thermal_device *ptd = tzd->devdata; in pch_thermal_get_temp() local
148 return ptd->ops->get_temp(ptd, temp); in pch_thermal_get_temp()
154 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_type() local
156 if (ptd->crt_trip_id == trip) in pch_get_trip_type()
158 else if (ptd->hot_trip_id == trip) in pch_get_trip_type()
168 struct pch_thermal_device *ptd = tzd->devdata; in pch_get_trip_temp() local
170 if (ptd->crt_trip_id == trip) in pch_get_trip_temp()
171 *temp = ptd->crt_temp; in pch_get_trip_temp()
172 else if (ptd->hot_trip_id == trip) in pch_get_trip_temp()
173 *temp = ptd->hot_temp; in pch_get_trip_temp()
190 struct pch_thermal_device *ptd; in intel_pch_thermal_probe() local
195 ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL); in intel_pch_thermal_probe()
196 if (!ptd) in intel_pch_thermal_probe()
201 ptd->ops = &pch_dev_ops_wpt; in intel_pch_thermal_probe()
209 pci_set_drvdata(pdev, ptd); in intel_pch_thermal_probe()
210 ptd->pdev = pdev; in intel_pch_thermal_probe()
224 ptd->hw_base = pci_ioremap_bar(pdev, 0); in intel_pch_thermal_probe()
225 if (!ptd->hw_base) { in intel_pch_thermal_probe()
231 err = ptd->ops->hw_init(ptd, &nr_trips); in intel_pch_thermal_probe()
235 ptd->tzd = thermal_zone_device_register(dev_name, nr_trips, 0, ptd, in intel_pch_thermal_probe()
237 if (IS_ERR(ptd->tzd)) { in intel_pch_thermal_probe()
240 err = PTR_ERR(ptd->tzd); in intel_pch_thermal_probe()
247 iounmap(ptd->hw_base); in intel_pch_thermal_probe()
258 struct pch_thermal_device *ptd = pci_get_drvdata(pdev); in intel_pch_thermal_remove() local
260 thermal_zone_device_unregister(ptd->tzd); in intel_pch_thermal_remove()
261 iounmap(ptd->hw_base); in intel_pch_thermal_remove()