Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * SharpSL Battery/PM Driver |
| 4 | * |
| 5 | * Copyright (c) 2004-2005 Richard Purdie |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 6 | */ |
Dmitry Eremin-Solenikov | d48898a | 2009-03-28 18:18:52 +0300 | [diff] [blame] | 7 | #ifndef _MACH_SHARPSL_PM |
| 8 | #define _MACH_SHARPSL_PM |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 9 | |
| 10 | struct sharpsl_charger_machinfo { |
| 11 | void (*init)(void); |
| 12 | void (*exit)(void); |
| 13 | int gpio_acin; |
| 14 | int gpio_batfull; |
Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 15 | int batfull_irq; |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 16 | int gpio_batlock; |
| 17 | int gpio_fatal; |
| 18 | void (*discharge)(int); |
| 19 | void (*discharge1)(int); |
| 20 | void (*charge)(int); |
| 21 | void (*measure_temp)(int); |
| 22 | void (*presuspend)(void); |
| 23 | void (*postsuspend)(void); |
Dirk Opfer | 576b3ef | 2006-09-25 22:51:02 +0100 | [diff] [blame] | 24 | void (*earlyresume)(void); |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 25 | unsigned long (*read_devdata)(int); |
| 26 | #define SHARPSL_BATT_VOLT 1 |
| 27 | #define SHARPSL_BATT_TEMP 2 |
| 28 | #define SHARPSL_ACIN_VOLT 3 |
| 29 | #define SHARPSL_STATUS_ACIN 4 |
| 30 | #define SHARPSL_STATUS_LOCK 5 |
| 31 | #define SHARPSL_STATUS_CHRGFULL 6 |
| 32 | #define SHARPSL_STATUS_FATAL 7 |
Robert Jarzmik | ca26475 | 2016-08-02 00:01:32 +0200 | [diff] [blame] | 33 | bool (*charger_wakeup)(void); |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 34 | int (*should_wakeup)(unsigned int resume_on_alarm); |
Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 35 | void (*backlight_limit)(int); |
| 36 | int (*backlight_get_status) (void); |
| 37 | int charge_on_volt; |
| 38 | int charge_on_temp; |
| 39 | int charge_acin_high; |
| 40 | int charge_acin_low; |
| 41 | int fatal_acin_volt; |
| 42 | int fatal_noacin_volt; |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 43 | int bat_levels; |
| 44 | struct battery_thresh *bat_levels_noac; |
| 45 | struct battery_thresh *bat_levels_acin; |
Richard Purdie | f8703dc | 2006-06-19 19:58:52 +0100 | [diff] [blame] | 46 | struct battery_thresh *bat_levels_noac_bl; |
| 47 | struct battery_thresh *bat_levels_acin_bl; |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 48 | int status_high_acin; |
| 49 | int status_low_acin; |
| 50 | int status_high_noac; |
| 51 | int status_low_noac; |
| 52 | }; |
| 53 | |
| 54 | struct battery_thresh { |
| 55 | int voltage; |
| 56 | int percentage; |
| 57 | }; |
| 58 | |
| 59 | struct battery_stat { |
| 60 | int ac_status; /* APM AC Present/Not Present */ |
| 61 | int mainbat_status; /* APM Main Battery Status */ |
| 62 | int mainbat_percent; /* Main Battery Percentage Charge */ |
| 63 | int mainbat_voltage; /* Main Battery Voltage */ |
| 64 | }; |
| 65 | |
| 66 | struct sharpsl_pm_status { |
| 67 | struct device *dev; |
| 68 | struct timer_list ac_timer; |
| 69 | struct timer_list chrg_full_timer; |
| 70 | |
| 71 | int charge_mode; |
| 72 | #define CHRG_ERROR (-1) |
| 73 | #define CHRG_OFF (0) |
| 74 | #define CHRG_ON (1) |
| 75 | #define CHRG_DONE (2) |
| 76 | |
| 77 | unsigned int flags; |
| 78 | #define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */ |
| 79 | #define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */ |
| 80 | #define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */ |
| 81 | #define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */ |
| 82 | #define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */ |
| 83 | |
| 84 | int full_count; |
| 85 | unsigned long charge_start_time; |
| 86 | struct sharpsl_charger_machinfo *machinfo; |
| 87 | struct battery_stat battstat; |
| 88 | }; |
| 89 | |
| 90 | extern struct sharpsl_pm_status sharpsl_pm; |
| 91 | |
Eric Miao | 04e4ad2 | 2010-07-05 00:03:34 +0800 | [diff] [blame] | 92 | extern struct battery_thresh sharpsl_battery_levels_acin[]; |
| 93 | extern struct battery_thresh sharpsl_battery_levels_noac[]; |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 94 | |
| 95 | #define SHARPSL_LED_ERROR 2 |
| 96 | #define SHARPSL_LED_ON 1 |
| 97 | #define SHARPSL_LED_OFF 0 |
| 98 | |
| 99 | void sharpsl_battery_kick(void); |
| 100 | void sharpsl_pm_led(int val); |
Richard Purdie | b7557de | 2006-01-05 20:44:55 +0000 | [diff] [blame] | 101 | |
Eric Miao | 04e4ad2 | 2010-07-05 00:03:34 +0800 | [diff] [blame] | 102 | /* MAX1111 Channel Definitions */ |
| 103 | #define MAX1111_BATT_VOLT 4u |
| 104 | #define MAX1111_BATT_TEMP 2u |
| 105 | #define MAX1111_ACIN_VOLT 6u |
| 106 | int sharpsl_pm_pxa_read_max1111(int channel); |
| 107 | |
| 108 | void corgi_lcd_limit_intensity(int limit); |
Dmitry Eremin-Solenikov | d48898a | 2009-03-28 18:18:52 +0300 | [diff] [blame] | 109 | #endif |