st_thermal.h 3.2 KB

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