Lines Matching full:sensor
3 * HiSilicon thermal sensor driver
68 int (*get_temp)(struct hisi_thermal_sensor *sensor);
69 int (*enable_sensor)(struct hisi_thermal_sensor *sensor);
70 int (*disable_sensor)(struct hisi_thermal_sensor *sensor);
71 int (*irq_handler)(struct hisi_thermal_sensor *sensor);
77 struct hisi_thermal_sensor *sensor; member
243 * Temperature configuration register - Sensor selection
247 * 0x0: local sensor (default)
248 * 0x1: remote sensor 1 (ACPU cluster 1)
249 * 0x2: remote sensor 2 (ACPU cluster 0)
250 * 0x3: remote sensor 3 (G3D)
252 static inline void hi6220_thermal_sensor_select(void __iomem *addr, int sensor) in hi6220_thermal_sensor_select() argument
255 (sensor << 12), addr + HI6220_TEMP0_CFG); in hi6220_thermal_sensor_select()
274 static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor) in hi6220_thermal_irq_handler() argument
276 struct hisi_thermal_data *data = sensor->data; in hi6220_thermal_irq_handler()
282 static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor) in hi3660_thermal_irq_handler() argument
284 struct hisi_thermal_data *data = sensor->data; in hi3660_thermal_irq_handler()
286 hi3660_thermal_alarm_clear(data->regs, sensor->id, 1); in hi3660_thermal_irq_handler()
290 static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor) in hi6220_thermal_get_temp() argument
292 struct hisi_thermal_data *data = sensor->data; in hi6220_thermal_get_temp()
297 static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor) in hi3660_thermal_get_temp() argument
299 struct hisi_thermal_data *data = sensor->data; in hi3660_thermal_get_temp()
301 return hi3660_thermal_get_temperature(data->regs, sensor->id); in hi3660_thermal_get_temp()
304 static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) in hi6220_thermal_disable_sensor() argument
306 struct hisi_thermal_data *data = sensor->data; in hi6220_thermal_disable_sensor()
308 /* disable sensor module */ in hi6220_thermal_disable_sensor()
318 static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) in hi3660_thermal_disable_sensor() argument
320 struct hisi_thermal_data *data = sensor->data; in hi3660_thermal_disable_sensor()
322 /* disable sensor module */ in hi3660_thermal_disable_sensor()
323 hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); in hi3660_thermal_disable_sensor()
327 static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) in hi6220_thermal_enable_sensor() argument
329 struct hisi_thermal_data *data = sensor->data; in hi6220_thermal_enable_sensor()
341 /* select sensor id */ in hi6220_thermal_enable_sensor()
342 hi6220_thermal_sensor_select(data->regs, sensor->id); in hi6220_thermal_enable_sensor()
351 hi6220_thermal_alarm_set(data->regs, sensor->thres_temp); in hi6220_thermal_enable_sensor()
365 static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) in hi3660_thermal_enable_sensor() argument
368 struct hisi_thermal_data *data = sensor->data; in hi3660_thermal_enable_sensor()
371 hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); in hi3660_thermal_enable_sensor()
374 hi3660_thermal_set_lag(data->regs, sensor->id, HI3660_TEMP_LAG); in hi3660_thermal_enable_sensor()
377 value = hi3660_thermal_temp_to_step(sensor->thres_temp); in hi3660_thermal_enable_sensor()
378 hi3660_thermal_alarm_set(data->regs, sensor->id, value); in hi3660_thermal_enable_sensor()
381 hi3660_thermal_alarm_clear(data->regs, sensor->id, 1); in hi3660_thermal_enable_sensor()
382 hi3660_thermal_alarm_enable(data->regs, sensor->id, 1); in hi3660_thermal_enable_sensor()
396 data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); in hi6220_thermal_probe()
397 if (!data->sensor) in hi6220_thermal_probe()
400 data->sensor[0].id = HI6220_CLUSTER0_SENSOR; in hi6220_thermal_probe()
401 data->sensor[0].irq_name = "tsensor_intr"; in hi6220_thermal_probe()
402 data->sensor[0].data = data; in hi6220_thermal_probe()
415 data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) * in hi3660_thermal_probe()
417 if (!data->sensor) in hi3660_thermal_probe()
420 data->sensor[0].id = HI3660_BIG_SENSOR; in hi3660_thermal_probe()
421 data->sensor[0].irq_name = "tsensor_a73"; in hi3660_thermal_probe()
422 data->sensor[0].data = data; in hi3660_thermal_probe()
429 struct hisi_thermal_sensor *sensor = thermal_zone_device_priv(tz); in hisi_thermal_get_temp() local
430 struct hisi_thermal_data *data = sensor->data; in hisi_thermal_get_temp()
432 *temp = data->ops->get_temp(sensor); in hisi_thermal_get_temp()
443 struct hisi_thermal_sensor *sensor = dev; in hisi_thermal_alarm_irq_thread() local
444 struct hisi_thermal_data *data = sensor->data; in hisi_thermal_alarm_irq_thread()
447 data->ops->irq_handler(sensor); in hisi_thermal_alarm_irq_thread()
449 temp = data->ops->get_temp(sensor); in hisi_thermal_alarm_irq_thread()
451 if (temp >= sensor->thres_temp) { in hisi_thermal_alarm_irq_thread()
453 "sensor <%d> THERMAL ALARM: %d > %d\n", in hisi_thermal_alarm_irq_thread()
454 sensor->id, temp, sensor->thres_temp); in hisi_thermal_alarm_irq_thread()
456 thermal_zone_device_update(sensor->tzd, in hisi_thermal_alarm_irq_thread()
461 "sensor <%d> THERMAL ALARM stopped: %d < %d\n", in hisi_thermal_alarm_irq_thread()
462 sensor->id, temp, sensor->thres_temp); in hisi_thermal_alarm_irq_thread()
470 struct hisi_thermal_sensor *sensor = arg; in hisi_trip_walk_cb() local
475 sensor->thres_temp = trip->temperature; in hisi_trip_walk_cb()
481 struct hisi_thermal_sensor *sensor) in hisi_thermal_register_sensor() argument
485 sensor->tzd = devm_thermal_of_zone_register(&pdev->dev, in hisi_thermal_register_sensor()
486 sensor->id, sensor, in hisi_thermal_register_sensor()
488 if (IS_ERR(sensor->tzd)) { in hisi_thermal_register_sensor()
489 ret = PTR_ERR(sensor->tzd); in hisi_thermal_register_sensor()
490 sensor->tzd = NULL; in hisi_thermal_register_sensor()
491 dev_err(&pdev->dev, "failed to register sensor id %d: %d\n", in hisi_thermal_register_sensor()
492 sensor->id, ret); in hisi_thermal_register_sensor()
496 thermal_zone_for_each_trip(sensor->tzd, hisi_trip_walk_cb, sensor); in hisi_thermal_register_sensor()
530 static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, in hisi_thermal_toggle_sensor() argument
533 struct thermal_zone_device *tzd = sensor->tzd; in hisi_thermal_toggle_sensor()
564 struct hisi_thermal_sensor *sensor = &data->sensor[i]; in hisi_thermal_probe() local
566 ret = hisi_thermal_register_sensor(pdev, sensor); in hisi_thermal_probe()
568 dev_err(dev, "failed to register thermal sensor: %d\n", in hisi_thermal_probe()
579 IRQF_ONESHOT, sensor->irq_name, in hisi_thermal_probe()
580 sensor); in hisi_thermal_probe()
586 ret = data->ops->enable_sensor(sensor); in hisi_thermal_probe()
588 dev_err(dev, "Failed to setup the sensor: %d\n", ret); in hisi_thermal_probe()
592 hisi_thermal_toggle_sensor(sensor, true); in hisi_thermal_probe()
604 struct hisi_thermal_sensor *sensor = &data->sensor[i]; in hisi_thermal_remove() local
606 hisi_thermal_toggle_sensor(sensor, false); in hisi_thermal_remove()
607 data->ops->disable_sensor(sensor); in hisi_thermal_remove()
617 data->ops->disable_sensor(&data->sensor[i]); in hisi_thermal_suspend()
628 ret |= data->ops->enable_sensor(&data->sensor[i]); in hisi_thermal_resume()