abx500.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) ST-Ericsson 2010 - 2013
  3. * License terms: GNU General Public License v2
  4. * Author: Martin Persson <martin.persson@stericsson.com>
  5. * Hongbo Zhang <hongbo.zhang@linaro.com>
  6. */
  7. #ifndef _ABX500_H
  8. #define _ABX500_H
  9. #define NUM_SENSORS 5
  10. struct abx500_temp;
  11. /*
  12. * struct abx500_temp_ops - abx500 chip specific ops
  13. * @read_sensor: reads gpadc output
  14. * @irq_handler: irq handler
  15. * @show_name: hwmon device name
  16. * @show_label: hwmon attribute label
  17. * @is_visible: is attribute visible
  18. */
  19. struct abx500_temp_ops {
  20. int (*read_sensor)(struct abx500_temp *, u8, int *);
  21. int (*irq_handler)(int, struct abx500_temp *);
  22. ssize_t (*show_name)(struct device *,
  23. struct device_attribute *, char *);
  24. ssize_t (*show_label) (struct device *,
  25. struct device_attribute *, char *);
  26. int (*is_visible)(struct attribute *, int);
  27. };
  28. /*
  29. * struct abx500_temp - representation of temp mon device
  30. * @pdev: platform device
  31. * @hwmon_dev: hwmon device
  32. * @ops: abx500 chip specific ops
  33. * @gpadc_addr: gpadc channel address
  34. * @min: sensor temperature min value
  35. * @max: sensor temperature max value
  36. * @max_hyst: sensor temperature hysteresis value for max limit
  37. * @min_alarm: sensor temperature min alarm
  38. * @max_alarm: sensor temperature max alarm
  39. * @work: delayed work scheduled to monitor temperature periodically
  40. * @work_active: True if work is active
  41. * @lock: mutex
  42. * @monitored_sensors: number of monitored sensors
  43. * @plat_data: private usage, usually points to platform specific data
  44. */
  45. struct abx500_temp {
  46. struct platform_device *pdev;
  47. struct device *hwmon_dev;
  48. struct abx500_temp_ops ops;
  49. u8 gpadc_addr[NUM_SENSORS];
  50. unsigned long min[NUM_SENSORS];
  51. unsigned long max[NUM_SENSORS];
  52. unsigned long max_hyst[NUM_SENSORS];
  53. bool min_alarm[NUM_SENSORS];
  54. bool max_alarm[NUM_SENSORS];
  55. struct delayed_work work;
  56. bool work_active;
  57. struct mutex lock;
  58. int monitored_sensors;
  59. void *plat_data;
  60. };
  61. int abx500_hwmon_init(struct abx500_temp *data);
  62. #endif /* _ABX500_H */