Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Definitions for talking to the PMU. The PMU is a microcontroller |
| 3 | * which controls battery charging and system power on PowerBook 3400 |
| 4 | * and 2400 models as well as the RTC and various other things. |
| 5 | * |
| 6 | * Copyright (C) 1998 Paul Mackerras. |
| 7 | */ |
David Howells | 6c9f2ef | 2011-12-13 09:26:45 +0000 | [diff] [blame] | 8 | #ifndef _LINUX_PMU_H |
| 9 | #define _LINUX_PMU_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 11 | #include <uapi/linux/pmu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | extern int find_via_pmu(void); |
| 15 | |
| 16 | extern int pmu_request(struct adb_request *req, |
| 17 | void (*done)(struct adb_request *), int nbytes, ...); |
Benjamin Herrenschmidt | 730745a | 2006-01-07 11:30:44 +1100 | [diff] [blame] | 18 | extern int pmu_queue_request(struct adb_request *req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | extern void pmu_poll(void); |
| 20 | extern void pmu_poll_adb(void); /* For use by xmon */ |
| 21 | extern void pmu_wait_complete(struct adb_request *req); |
| 22 | |
| 23 | /* For use before switching interrupts off for a long time; |
| 24 | * warning: not stackable |
| 25 | */ |
Tony Breeds | a99d9a6 | 2008-03-12 10:48:48 +1100 | [diff] [blame] | 26 | #if defined(CONFIG_ADB_PMU) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | extern void pmu_suspend(void); |
| 28 | extern void pmu_resume(void); |
Tony Breeds | a99d9a6 | 2008-03-12 10:48:48 +1100 | [diff] [blame] | 29 | #else |
| 30 | static inline void pmu_suspend(void) |
| 31 | {} |
| 32 | static inline void pmu_resume(void) |
| 33 | {} |
| 34 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
| 36 | extern void pmu_enable_irled(int on); |
| 37 | |
| 38 | extern void pmu_restart(void); |
| 39 | extern void pmu_shutdown(void); |
| 40 | extern void pmu_unlock(void); |
| 41 | |
| 42 | extern int pmu_present(void); |
| 43 | extern int pmu_get_model(void); |
| 44 | |
Benjamin Herrenschmidt | 0094f2c | 2007-12-20 15:00:21 +1100 | [diff] [blame] | 45 | extern void pmu_backlight_set_sleep(int sleep); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #define PMU_MAX_BATTERIES 2 |
| 48 | |
| 49 | /* values for pmu_power_flags */ |
| 50 | #define PMU_PWR_AC_PRESENT 0x00000001 |
| 51 | |
| 52 | /* values for pmu_battery_info.flags */ |
| 53 | #define PMU_BATT_PRESENT 0x00000001 |
| 54 | #define PMU_BATT_CHARGING 0x00000002 |
| 55 | #define PMU_BATT_TYPE_MASK 0x000000f0 |
| 56 | #define PMU_BATT_TYPE_SMART 0x00000010 /* Smart battery */ |
| 57 | #define PMU_BATT_TYPE_HOOPER 0x00000020 /* 3400/3500 */ |
| 58 | #define PMU_BATT_TYPE_COMET 0x00000030 /* 2400 */ |
| 59 | |
| 60 | struct pmu_battery_info |
| 61 | { |
| 62 | unsigned int flags; |
| 63 | unsigned int charge; /* current charge */ |
| 64 | unsigned int max_charge; /* maximum charge */ |
| 65 | signed int amperage; /* current, positive if charging */ |
| 66 | unsigned int voltage; /* voltage */ |
| 67 | unsigned int time_remaining; /* remaining time */ |
| 68 | }; |
| 69 | |
| 70 | extern int pmu_battery_count; |
| 71 | extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES]; |
| 72 | extern unsigned int pmu_power_flags; |
| 73 | |
Michael Hanselmann | 5474c12 | 2006-06-25 05:47:08 -0700 | [diff] [blame] | 74 | /* Backlight */ |
Michael Hanselmann | 4b75599 | 2006-07-30 03:04:19 -0700 | [diff] [blame] | 75 | extern void pmu_backlight_init(void); |
Michael Hanselmann | 5474c12 | 2006-06-25 05:47:08 -0700 | [diff] [blame] | 76 | |
Johannes Berg | f596575 | 2007-05-08 01:08:00 +1000 | [diff] [blame] | 77 | /* some code needs to know if the PMU was suspended for hibernation */ |
Tony Breeds | 07c941d | 2008-03-12 10:48:48 +1100 | [diff] [blame] | 78 | #if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32) |
Johannes Berg | f596575 | 2007-05-08 01:08:00 +1000 | [diff] [blame] | 79 | extern int pmu_sys_suspended; |
| 80 | #else |
| 81 | /* if power management is not configured it can't be suspended */ |
| 82 | #define pmu_sys_suspended 0 |
| 83 | #endif |
| 84 | |
David Howells | 6c9f2ef | 2011-12-13 09:26:45 +0000 | [diff] [blame] | 85 | #endif /* _LINUX_PMU_H */ |