st_thermal.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * ST Thermal Sensor Driver for STi series of SoCs
  4. * Author: Ajit Pal Singh <[email protected]>
  5. *
  6. * Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited
  7. */
  8. #ifndef __STI_THERMAL_SYSCFG_H
  9. #define __STI_THERMAL_SYSCFG_H
  10. #include <linux/interrupt.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/regmap.h>
  13. #include <linux/thermal.h>
  14. enum st_thermal_regfield_ids {
  15. INT_THRESH_HI = 0, /* Top two regfield IDs are mutually exclusive */
  16. TEMP_PWR = 0,
  17. DCORRECT,
  18. OVERFLOW,
  19. DATA,
  20. INT_ENABLE,
  21. MAX_REGFIELDS
  22. };
  23. /* Thermal sensor power states */
  24. enum st_thermal_power_state {
  25. POWER_OFF = 0,
  26. POWER_ON
  27. };
  28. struct st_thermal_sensor;
  29. /**
  30. * Description of private thermal sensor ops.
  31. *
  32. * @power_ctrl: Function for powering on/off a sensor. Clock to the
  33. * sensor is also controlled from this function.
  34. * @alloc_regfields: Allocate regmap register fields, specific to a sensor.
  35. * @do_memmap_regmap: Memory map the thermal register space and init regmap
  36. * instance or find regmap instance.
  37. * @register_irq: Register an interrupt handler for a sensor.
  38. */
  39. struct st_thermal_sensor_ops {
  40. int (*power_ctrl)(struct st_thermal_sensor *, enum st_thermal_power_state);
  41. int (*alloc_regfields)(struct st_thermal_sensor *);
  42. int (*regmap_init)(struct st_thermal_sensor *);
  43. int (*register_enable_irq)(struct st_thermal_sensor *);
  44. int (*enable_irq)(struct st_thermal_sensor *);
  45. };
  46. /**
  47. * Description of thermal driver compatible data.
  48. *
  49. * @reg_fields: Pointer to the regfields array for a sensor.
  50. * @sys_compat: Pointer to the syscon node compatible string.
  51. * @ops: Pointer to private thermal ops for a sensor.
  52. * @calibration_val: Default calibration value to be written to the DCORRECT
  53. * register field for a sensor.
  54. * @temp_adjust_val: Value to be added/subtracted from the data read from
  55. * the sensor. If value needs to be added please provide a
  56. * positive value and if it is to be subtracted please
  57. * provide a negative value.
  58. * @crit_temp: The temperature beyond which the SoC should be shutdown
  59. * to prevent damage.
  60. */
  61. struct st_thermal_compat_data {
  62. char *sys_compat;
  63. const struct reg_field *reg_fields;
  64. const struct st_thermal_sensor_ops *ops;
  65. unsigned int calibration_val;
  66. int temp_adjust_val;
  67. int crit_temp;
  68. };
  69. struct st_thermal_sensor {
  70. struct device *dev;
  71. struct thermal_zone_device *thermal_dev;
  72. const struct st_thermal_sensor_ops *ops;
  73. const struct st_thermal_compat_data *cdata;
  74. struct clk *clk;
  75. struct regmap *regmap;
  76. struct regmap_field *pwr;
  77. struct regmap_field *dcorrect;
  78. struct regmap_field *overflow;
  79. struct regmap_field *temp_data;
  80. struct regmap_field *int_thresh_hi;
  81. struct regmap_field *int_enable;
  82. int irq;
  83. void __iomem *mmio_base;
  84. };
  85. extern int st_thermal_register(struct platform_device *pdev,
  86. const struct of_device_id *st_thermal_of_match);
  87. extern int st_thermal_unregister(struct platform_device *pdev);
  88. extern const struct dev_pm_ops st_thermal_pm_ops;
  89. #endif /* __STI_RESET_SYSCFG_H */