Adding .24 support for olpc
[openwrt.git] / target / linux / olpc / files-2.6.23 / include / linux / battery.h
1 /*
2  * Driver model for batteries
3  *
4  *      © 2006 David Woodhouse <dwmw2@infradead.org>
5  *
6  * Based on LED Class support, by John Lenz and Richard Purdie:
7  *
8  *      © 2005 John Lenz <lenz@cs.wisc.edu>
9  *      © 2005-2006 Richard Purdie <rpurdie@openedhand.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  *
15  */
16 #ifndef __LINUX_BATTERY_H__
17 #define __LINUX_BATTERY_H__
18
19 struct device;
20 struct class_device;
21
22 /*
23  * Battery Core
24  */
25 #define PWRDEV_TYPE_BATTERY     0
26 #define PWRDEV_TYPE_AC          1
27
28 #define BAT_STAT_PRESENT        (1<<0)
29 #define BAT_STAT_LOW            (1<<1)
30 #define BAT_STAT_FULL           (1<<2)
31 #define BAT_STAT_CHARGING       (1<<3)
32 #define BAT_STAT_DISCHARGING    (1<<4)
33 #define BAT_STAT_OVERTEMP       (1<<5)
34 #define BAT_STAT_CRITICAL       (1<<6)
35 #define BAT_STAT_FIRE           (1<<7)
36 #define BAT_STAT_CHARGE_DONE    (1<<8)
37
38 /* Thou shalt not export any attributes in sysfs except these, and
39    with these units: */
40 #define BAT_INFO_STATUS         "status"                /* Not free-form. Use
41                                                            provided function */
42 #define BAT_INFO_TEMP1          "temp1"                 /* °C/1000 */
43 #define BAT_INFO_TEMP1_NAME     "temp1_name"            /* string */
44
45 #define BAT_INFO_TEMP2          "temp2"                 /* °C/1000 */
46 #define BAT_INFO_TEMP2_NAME     "temp2_name"            /* string */
47
48 #define BAT_INFO_VOLTAGE        "voltage"               /* mV */
49 #define BAT_INFO_VOLTAGE_DESIGN "voltage_design"        /* mV */
50
51 #define BAT_INFO_CURRENT        "current"               /* mA */
52 #define BAT_INFO_CURRENT_NOW    "current_now"           /* mA */
53
54 #define BAT_INFO_POWER          "power"                 /* mW */
55 #define BAT_INFO_POWER_NOW      "power_now"             /* mW */
56
57 /* The following capacity/charge properties are represented in either
58    mA or mW. The CAP_UNITS property MUST be provided if any of these are. */
59 #define BAT_INFO_RATE           "rate"                  /* CAP_UNITS */
60 #define BAT_INFO_CAP_LEFT       "capacity_left"         /* CAP_UNITS*h */
61 #define BAT_INFO_CAP_DESIGN     "capacity_design"       /* CAP_UNITS*h */
62 #define BAT_INFO_CAP_LAST_FULL  "capacity_last_full"    /* CAP_UNITS*h */
63 #define BAT_INFO_CAP_LOW        "capacity_low_thresh"   /* CAP_UNITS*h */
64 #define BAT_INFO_CAP_WARN       "capacity_warn_thresh"  /* CAP_UNITS*h */
65 #define BAT_INFO_CAP_UNITS      "capacity_units"        /* string: must be
66                                                            either mA or mW */
67         
68 #define BAT_INFO_CAP_PCT        "capacity_percentage"   /* integer */
69
70 #define BAT_INFO_TIME_EMPTY     "time_to_empty"         /* seconds */
71 #define BAT_INFO_TIME_EMPTY_NOW "time_to_empty_now"     /* seconds */
72 #define BAT_INFO_TIME_FULL      "time_to_full"          /* seconds */
73 #define BAT_INFO_TIME_FULL_NOW  "time_to_full_now"      /* seconds */
74
75 #define BAT_INFO_MANUFACTURER   "manufacturer"          /* string */
76 #define BAT_INFO_TECHNOLOGY     "technology"            /* string */
77 #define BAT_INFO_MODEL          "model"                 /* string */
78 #define BAT_INFO_SERIAL         "serial"                /* string */
79 #define BAT_INFO_OEM_INFO       "oem_info"              /* string */
80
81 #define BAT_INFO_CYCLE_COUNT    "cycle_count"           /* integer */
82 #define BAT_INFO_DATE_MFR       "date_manufactured"     /* YYYY[-MM[-DD]] */
83 #define BAT_INFO_DATE_FIRST_USE "date_first_use"        /* YYYY[-MM[-DD]] */
84
85 struct battery_dev {
86         int                     status_cap;
87         int                     id;
88         int                     type;
89         const char              *name;
90
91         struct device           *dev;
92 };
93
94 int battery_device_register(struct device *parent,
95                             struct battery_dev *battery_cdev);
96 void battery_device_unregister(struct battery_dev *battery_cdev);
97
98
99 ssize_t battery_attribute_show_status(char *buf, unsigned long status);
100 ssize_t battery_attribute_show_ac_status(char *buf, unsigned long status);
101 #endif /* __LINUX_BATTERY_H__ */