sharpsl_pm.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * SharpSL Battery/PM Driver
  3. *
  4. * Copyright (c) 2004-2005 Richard Purdie
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/interrupt.h>
  12. struct sharpsl_charger_machinfo {
  13. void (*init)(void);
  14. void (*exit)(void);
  15. int gpio_acin;
  16. int gpio_batfull;
  17. int batfull_irq;
  18. int gpio_batlock;
  19. int gpio_fatal;
  20. void (*discharge)(int);
  21. void (*discharge1)(int);
  22. void (*charge)(int);
  23. void (*measure_temp)(int);
  24. void (*presuspend)(void);
  25. void (*postsuspend)(void);
  26. unsigned long (*read_devdata)(int);
  27. #define SHARPSL_BATT_VOLT 1
  28. #define SHARPSL_BATT_TEMP 2
  29. #define SHARPSL_ACIN_VOLT 3
  30. #define SHARPSL_STATUS_ACIN 4
  31. #define SHARPSL_STATUS_LOCK 5
  32. #define SHARPSL_STATUS_CHRGFULL 6
  33. #define SHARPSL_STATUS_FATAL 7
  34. unsigned long (*charger_wakeup)(void);
  35. int (*should_wakeup)(unsigned int resume_on_alarm);
  36. void (*backlight_limit)(int);
  37. int (*backlight_get_status) (void);
  38. int charge_on_volt;
  39. int charge_on_temp;
  40. int charge_acin_high;
  41. int charge_acin_low;
  42. int fatal_acin_volt;
  43. int fatal_noacin_volt;
  44. int bat_levels;
  45. struct battery_thresh *bat_levels_noac;
  46. struct battery_thresh *bat_levels_acin;
  47. struct battery_thresh *bat_levels_noac_bl;
  48. struct battery_thresh *bat_levels_acin_bl;
  49. int status_high_acin;
  50. int status_low_acin;
  51. int status_high_noac;
  52. int status_low_noac;
  53. };
  54. struct battery_thresh {
  55. int voltage;
  56. int percentage;
  57. };
  58. struct battery_stat {
  59. int ac_status; /* APM AC Present/Not Present */
  60. int mainbat_status; /* APM Main Battery Status */
  61. int mainbat_percent; /* Main Battery Percentage Charge */
  62. int mainbat_voltage; /* Main Battery Voltage */
  63. };
  64. struct sharpsl_pm_status {
  65. struct device *dev;
  66. struct timer_list ac_timer;
  67. struct timer_list chrg_full_timer;
  68. int charge_mode;
  69. #define CHRG_ERROR (-1)
  70. #define CHRG_OFF (0)
  71. #define CHRG_ON (1)
  72. #define CHRG_DONE (2)
  73. unsigned int flags;
  74. #define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */
  75. #define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */
  76. #define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */
  77. #define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */
  78. #define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */
  79. int full_count;
  80. unsigned long charge_start_time;
  81. struct sharpsl_charger_machinfo *machinfo;
  82. struct battery_stat battstat;
  83. };
  84. extern struct sharpsl_pm_status sharpsl_pm;
  85. #define SHARPSL_LED_ERROR 2
  86. #define SHARPSL_LED_ON 1
  87. #define SHARPSL_LED_OFF 0
  88. void sharpsl_battery_kick(void);
  89. void sharpsl_pm_led(int val);
  90. irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp);
  91. irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp);
  92. irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp);