| Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 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 |  | 
 | 12 | #include <linux/interrupt.h> | 
 | 13 |  | 
 | 14 | struct sharpsl_charger_machinfo { | 
 | 15 | 	void (*init)(void); | 
 | 16 | 	void (*exit)(void); | 
 | 17 | 	int gpio_acin; | 
 | 18 | 	int gpio_batfull; | 
| Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 19 | 	int batfull_irq; | 
| Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 20 | 	int gpio_batlock; | 
 | 21 | 	int gpio_fatal; | 
 | 22 | 	void (*discharge)(int); | 
 | 23 | 	void (*discharge1)(int); | 
 | 24 | 	void (*charge)(int); | 
 | 25 | 	void (*measure_temp)(int); | 
 | 26 | 	void (*presuspend)(void); | 
 | 27 | 	void (*postsuspend)(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 | 	unsigned long (*charger_wakeup)(void); | 
 | 37 | 	int (*should_wakeup)(unsigned int resume_on_alarm); | 
| Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 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; | 
| Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 46 | 	int bat_levels; | 
 | 47 | 	struct battery_thresh *bat_levels_noac; | 
 | 48 | 	struct battery_thresh *bat_levels_acin; | 
| Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 49 | 	struct battery_thresh *bat_levels_noac_bl; | 
 | 50 | 	struct battery_thresh *bat_levels_acin_bl; | 
| Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 51 | 	int status_high_acin; | 
 | 52 | 	int status_low_acin; | 
 | 53 | 	int status_high_noac; | 
 | 54 | 	int status_low_noac; | 
 | 55 | }; | 
 | 56 |  | 
 | 57 | struct battery_thresh { | 
 | 58 | 	int voltage; | 
 | 59 | 	int percentage; | 
 | 60 | }; | 
 | 61 |  | 
 | 62 | struct battery_stat { | 
 | 63 | 	int ac_status;         /* APM AC Present/Not Present */ | 
 | 64 | 	int mainbat_status;    /* APM Main Battery Status */ | 
 | 65 | 	int mainbat_percent;   /* Main Battery Percentage Charge */ | 
 | 66 | 	int mainbat_voltage;   /* Main Battery Voltage */ | 
 | 67 | }; | 
 | 68 |  | 
 | 69 | struct sharpsl_pm_status { | 
 | 70 | 	struct device *dev; | 
 | 71 | 	struct timer_list ac_timer; | 
 | 72 | 	struct timer_list chrg_full_timer; | 
 | 73 |  | 
 | 74 | 	int charge_mode; | 
 | 75 | #define CHRG_ERROR    (-1) | 
 | 76 | #define CHRG_OFF      (0) | 
 | 77 | #define CHRG_ON       (1) | 
 | 78 | #define CHRG_DONE     (2) | 
 | 79 |  | 
 | 80 | 	unsigned int flags; | 
 | 81 | #define SHARPSL_SUSPENDED       (1 << 0)  /* Device is Suspended */ | 
 | 82 | #define SHARPSL_ALARM_ACTIVE    (1 << 1)  /* Alarm is for charging event (not user) */ | 
 | 83 | #define SHARPSL_BL_LIMIT        (1 << 2)  /* Backlight Intensity Limited */ | 
 | 84 | #define SHARPSL_APM_QUEUED      (1 << 3)  /* APM Event Queued */ | 
 | 85 | #define SHARPSL_DO_OFFLINE_CHRG (1 << 4)  /* Trigger the offline charger */ | 
 | 86 |  | 
 | 87 | 	int full_count; | 
 | 88 | 	unsigned long charge_start_time; | 
 | 89 | 	struct sharpsl_charger_machinfo *machinfo; | 
 | 90 | 	struct battery_stat battstat; | 
 | 91 | }; | 
 | 92 |  | 
 | 93 | extern struct sharpsl_pm_status sharpsl_pm; | 
 | 94 |  | 
 | 95 |  | 
 | 96 | #define SHARPSL_LED_ERROR  2 | 
 | 97 | #define SHARPSL_LED_ON     1 | 
 | 98 | #define SHARPSL_LED_OFF    0 | 
 | 99 |  | 
 | 100 | void sharpsl_battery_kick(void); | 
 | 101 | void sharpsl_pm_led(int val); | 
 | 102 | irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp); | 
 | 103 | irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp); | 
 | 104 | irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp); | 
 | 105 |  |