blob: 9ac8fc60ad492716231b872b01ac7ba3a13f787a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Definitions for talking to the PMU. The PMU is a microcontroller
4 * which controls battery charging and system power on PowerBook 3400
5 * and 2400 models as well as the RTC and various other things.
6 *
7 * Copyright (C) 1998 Paul Mackerras.
8 */
David Howells6c9f2ef2011-12-13 09:26:45 +00009#ifndef _LINUX_PMU_H
10#define _LINUX_PMU_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
David Howells607ca462012-10-13 10:46:48 +010012#include <uapi/linux/pmu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15extern int find_via_pmu(void);
16
17extern int pmu_request(struct adb_request *req,
18 void (*done)(struct adb_request *), int nbytes, ...);
Benjamin Herrenschmidt730745a2006-01-07 11:30:44 +110019extern int pmu_queue_request(struct adb_request *req);
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern void pmu_poll(void);
21extern void pmu_poll_adb(void); /* For use by xmon */
22extern void pmu_wait_complete(struct adb_request *req);
23
24/* For use before switching interrupts off for a long time;
25 * warning: not stackable
26 */
Tony Breedsa99d9a62008-03-12 10:48:48 +110027#if defined(CONFIG_ADB_PMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028extern void pmu_suspend(void);
29extern void pmu_resume(void);
Tony Breedsa99d9a62008-03-12 10:48:48 +110030#else
31static inline void pmu_suspend(void)
32{}
33static inline void pmu_resume(void)
34{}
35#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37extern void pmu_enable_irled(int on);
38
39extern void pmu_restart(void);
40extern void pmu_shutdown(void);
41extern void pmu_unlock(void);
42
43extern int pmu_present(void);
44extern int pmu_get_model(void);
45
Benjamin Herrenschmidt0094f2c2007-12-20 15:00:21 +110046extern void pmu_backlight_set_sleep(int sleep);
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define PMU_MAX_BATTERIES 2
49
50/* values for pmu_power_flags */
51#define PMU_PWR_AC_PRESENT 0x00000001
52
53/* values for pmu_battery_info.flags */
54#define PMU_BATT_PRESENT 0x00000001
55#define PMU_BATT_CHARGING 0x00000002
56#define PMU_BATT_TYPE_MASK 0x000000f0
57#define PMU_BATT_TYPE_SMART 0x00000010 /* Smart battery */
58#define PMU_BATT_TYPE_HOOPER 0x00000020 /* 3400/3500 */
59#define PMU_BATT_TYPE_COMET 0x00000030 /* 2400 */
60
61struct pmu_battery_info
62{
63 unsigned int flags;
64 unsigned int charge; /* current charge */
65 unsigned int max_charge; /* maximum charge */
66 signed int amperage; /* current, positive if charging */
67 unsigned int voltage; /* voltage */
68 unsigned int time_remaining; /* remaining time */
69};
70
71extern int pmu_battery_count;
72extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
73extern unsigned int pmu_power_flags;
74
Michael Hanselmann5474c122006-06-25 05:47:08 -070075/* Backlight */
Michael Hanselmann4b755992006-07-30 03:04:19 -070076extern void pmu_backlight_init(void);
Michael Hanselmann5474c122006-06-25 05:47:08 -070077
Johannes Bergf5965752007-05-08 01:08:00 +100078/* some code needs to know if the PMU was suspended for hibernation */
Tony Breeds07c941d2008-03-12 10:48:48 +110079#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
Johannes Bergf5965752007-05-08 01:08:00 +100080extern int pmu_sys_suspended;
81#else
82/* if power management is not configured it can't be suspended */
83#define pmu_sys_suspended 0
84#endif
85
David Howells6c9f2ef2011-12-13 09:26:45 +000086#endif /* _LINUX_PMU_H */