blob: 52453a24a24f9b04c0c97335c0d38d0c75a43649 [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
Finn Thain0792a2c2018-09-11 20:18:44 -040012#include <linux/rtc.h>
David Howells607ca462012-10-13 10:46:48 +010013#include <uapi/linux/pmu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16extern int find_via_pmu(void);
17
18extern int pmu_request(struct adb_request *req,
19 void (*done)(struct adb_request *), int nbytes, ...);
Benjamin Herrenschmidt730745a2006-01-07 11:30:44 +110020extern int pmu_queue_request(struct adb_request *req);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021extern void pmu_poll(void);
22extern void pmu_poll_adb(void); /* For use by xmon */
23extern void pmu_wait_complete(struct adb_request *req);
24
25/* For use before switching interrupts off for a long time;
26 * warning: not stackable
27 */
Tony Breedsa99d9a62008-03-12 10:48:48 +110028#if defined(CONFIG_ADB_PMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029extern void pmu_suspend(void);
30extern void pmu_resume(void);
Tony Breedsa99d9a62008-03-12 10:48:48 +110031#else
32static inline void pmu_suspend(void)
33{}
34static inline void pmu_resume(void)
35{}
36#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38extern void pmu_enable_irled(int on);
39
Finn Thain0792a2c2018-09-11 20:18:44 -040040extern time64_t pmu_get_time(void);
41extern int pmu_set_rtc_time(struct rtc_time *tm);
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043extern void pmu_restart(void);
44extern void pmu_shutdown(void);
45extern void pmu_unlock(void);
46
47extern int pmu_present(void);
48extern int pmu_get_model(void);
49
Benjamin Herrenschmidt0094f2c2007-12-20 15:00:21 +110050extern void pmu_backlight_set_sleep(int sleep);
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#define PMU_MAX_BATTERIES 2
53
54/* values for pmu_power_flags */
55#define PMU_PWR_AC_PRESENT 0x00000001
56
57/* values for pmu_battery_info.flags */
58#define PMU_BATT_PRESENT 0x00000001
59#define PMU_BATT_CHARGING 0x00000002
60#define PMU_BATT_TYPE_MASK 0x000000f0
61#define PMU_BATT_TYPE_SMART 0x00000010 /* Smart battery */
62#define PMU_BATT_TYPE_HOOPER 0x00000020 /* 3400/3500 */
63#define PMU_BATT_TYPE_COMET 0x00000030 /* 2400 */
64
65struct pmu_battery_info
66{
67 unsigned int flags;
68 unsigned int charge; /* current charge */
69 unsigned int max_charge; /* maximum charge */
70 signed int amperage; /* current, positive if charging */
71 unsigned int voltage; /* voltage */
72 unsigned int time_remaining; /* remaining time */
73};
74
75extern int pmu_battery_count;
76extern struct pmu_battery_info pmu_batteries[PMU_MAX_BATTERIES];
77extern unsigned int pmu_power_flags;
78
Michael Hanselmann5474c122006-06-25 05:47:08 -070079/* Backlight */
Michael Hanselmann4b755992006-07-30 03:04:19 -070080extern void pmu_backlight_init(void);
Michael Hanselmann5474c122006-06-25 05:47:08 -070081
Johannes Bergf5965752007-05-08 01:08:00 +100082/* some code needs to know if the PMU was suspended for hibernation */
Tony Breeds07c941d2008-03-12 10:48:48 +110083#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
Johannes Bergf5965752007-05-08 01:08:00 +100084extern int pmu_sys_suspended;
85#else
86/* if power management is not configured it can't be suspended */
87#define pmu_sys_suspended 0
88#endif
89
David Howells6c9f2ef2011-12-13 09:26:45 +000090#endif /* _LINUX_PMU_H */