sharpsl_pm.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #ifndef _MACH_SHARPSL_PM
  12. #define _MACH_SHARPSL_PM
  13. struct sharpsl_charger_machinfo {
  14. void (*init)(void);
  15. void (*exit)(void);
  16. int gpio_acin;
  17. int gpio_batfull;
  18. int batfull_irq;
  19. int gpio_batlock;
  20. int gpio_fatal;
  21. void (*discharge)(int);
  22. void (*discharge1)(int);
  23. void (*charge)(int);
  24. void (*measure_temp)(int);
  25. void (*presuspend)(void);
  26. void (*postsuspend)(void);
  27. void (*earlyresume)(void);
  28. unsigned long (*read_devdata)(int);
  29. #define SHARPSL_BATT_VOLT 1
  30. #define SHARPSL_BATT_TEMP 2
  31. #define SHARPSL_ACIN_VOLT 3
  32. #define SHARPSL_STATUS_ACIN 4
  33. #define SHARPSL_STATUS_LOCK 5
  34. #define SHARPSL_STATUS_CHRGFULL 6
  35. #define SHARPSL_STATUS_FATAL 7
  36. bool (*charger_wakeup)(void);
  37. int (*should_wakeup)(unsigned int resume_on_alarm);
  38. void (*backlight_limit)(int);
  39. int (*backlight_get_status) (void);
  40. int charge_on_volt;
  41. int charge_on_temp;
  42. int charge_acin_high;
  43. int charge_acin_low;
  44. int fatal_acin_volt;
  45. int fatal_noacin_volt;
  46. int bat_levels;
  47. struct battery_thresh *bat_levels_noac;
  48. struct battery_thresh *bat_levels_acin;
  49. struct battery_thresh *bat_levels_noac_bl;
  50. struct battery_thresh *bat_levels_acin_bl;
  51. int status_high_acin;
  52. int status_low_acin;
  53. int status_high_noac;
  54. int status_low_noac;
  55. };
  56. struct battery_thresh {
  57. int voltage;
  58. int percentage;
  59. };
  60. struct battery_stat {
  61. int ac_status; /* APM AC Present/Not Present */
  62. int mainbat_status; /* APM Main Battery Status */
  63. int mainbat_percent; /* Main Battery Percentage Charge */
  64. int mainbat_voltage; /* Main Battery Voltage */
  65. };
  66. struct sharpsl_pm_status {
  67. struct device *dev;
  68. struct timer_list ac_timer;
  69. struct timer_list chrg_full_timer;
  70. int charge_mode;
  71. #define CHRG_ERROR (-1)
  72. #define CHRG_OFF (0)
  73. #define CHRG_ON (1)
  74. #define CHRG_DONE (2)
  75. unsigned int flags;
  76. #define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */
  77. #define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */
  78. #define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */
  79. #define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */
  80. #define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */
  81. int full_count;
  82. unsigned long charge_start_time;
  83. struct sharpsl_charger_machinfo *machinfo;
  84. struct battery_stat battstat;
  85. };
  86. extern struct sharpsl_pm_status sharpsl_pm;
  87. extern struct battery_thresh sharpsl_battery_levels_acin[];
  88. extern struct battery_thresh sharpsl_battery_levels_noac[];
  89. #define SHARPSL_LED_ERROR 2
  90. #define SHARPSL_LED_ON 1
  91. #define SHARPSL_LED_OFF 0
  92. void sharpsl_battery_kick(void);
  93. void sharpsl_pm_led(int val);
  94. /* MAX1111 Channel Definitions */
  95. #define MAX1111_BATT_VOLT 4u
  96. #define MAX1111_BATT_TEMP 2u
  97. #define MAX1111_ACIN_VOLT 6u
  98. int sharpsl_pm_pxa_read_max1111(int channel);
  99. void corgi_lcd_limit_intensity(int limit);
  100. #endif