1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _BATTERY_H 28 #define _BATTERY_H 29 30 #pragma ident "@(#)battery.h 1.5 07/04/14 SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/param.h> 37 38 #define _BATT_DRV (('B' << 24) + ('A' << 16) + ('T' << 8)) 39 40 #define BATT_IOC_BAY (_BATT_DRV | 0) 41 #define BATT_IOC_INFO (_BATT_DRV | 1) 42 #define BATT_IOC_STATUS (_BATT_DRV | 2) 43 #define BATT_IOC_AC_COUNT (_BATT_DRV | 3) 44 #define BATT_IOC_POWER_STATUS (_BATT_DRV | 4) 45 #define BATT_IOC_SET_WARNING (_BATT_DRV | 5) 46 #define BATT_IOC_GET_WARNING (_BATT_DRV | 6) 47 48 #define BATT_BST_CHARGING 2 49 #define BATT_BST_DISCHARGING 1 50 51 typedef struct batt_bay { 52 /* Total number of bays in the system */ 53 int bay_number; 54 55 /* 56 * Bitmap for each bay and its battery. 57 * battery_map bit i: 58 * 1 -- battery inserted to bay i 59 * 0 -- bay i empty 60 */ 61 uint64_t battery_map; 62 } batt_bay_t; 63 64 typedef struct acpi_bif { 65 uint32_t bif_unit; 66 67 /* 68 * 0x00000000 - 0x7fffffff 69 * 0xffffffff - Unknown design capacity in [mWh] or [mAh] 70 */ 71 uint32_t bif_design_cap; 72 73 /* 74 * 0x00000000 - 0x7fffffff 75 * 0xffffffff - Unknown last full charge capacity in [mWh] or [mAh] 76 */ 77 uint32_t bif_last_cap; 78 79 uint32_t bif_tech; 80 81 /* 82 * 0x00000000 - 0x7fffffff 83 * 0xffffffff - Unknown design voltage in [mV] 84 */ 85 uint32_t bif_voltage; 86 87 /* 88 * 0x00000000 - 0x7fffffff in [mWh] or [mAh] 89 */ 90 uint32_t bif_warn_cap; 91 92 /* 93 * 0x00000000 - 0x7fffffff in [mWh] or [mAh] 94 */ 95 uint32_t bif_low_cap; 96 97 uint32_t bif_gran1_cap; 98 uint32_t bif_gran2_cap; 99 char bif_model[MAXNAMELEN]; 100 char bif_serial[MAXNAMELEN]; 101 char bif_type[MAXNAMELEN]; 102 char bif_oem_info[MAXNAMELEN]; 103 } acpi_bif_t; 104 105 typedef struct acpi_bst { 106 uint32_t bst_state; 107 108 /* 109 * 0x00000000 - 0x7fffffff in [mW] or [mA] 110 * 0xffffffff - Unknown rate 111 */ 112 uint32_t bst_rate; 113 114 /* 115 * 0x00000000 - 0x7fffffff in [mWh] or [mAh] 116 * 0xffffffff - Unknown capacity 117 */ 118 uint32_t bst_rem_cap; 119 120 /* 121 * 0x00000000 - 0x7fffffff in [mV] 122 * 0xffffffff - Unknown voltage 123 */ 124 uint32_t bst_voltage; 125 } acpi_bst_t; 126 127 /* Battery warnning levels in percentage */ 128 typedef struct batt_warn { 129 uint32_t bw_enabled; /* Enabled */ 130 uint32_t bw_charge_warn; /* charge warn threshold */ 131 uint32_t bw_charge_low; /* charge low threshold */ 132 } batt_warn_t; 133 134 #define BATT_DRV_NAME "battery" 135 #define BATT_POWER_KSTAT_NAME "power" 136 #define BATT_BTWARN_KSTAT_NAME "battery warning" 137 #define BATT_BIF_KSTAT_NAME "battery BIF" 138 #define BATT_BST_KSTAT_NAME "battery BST" 139 140 #define AC "AC" 141 #define BATTERY "battery" 142 #define SYSTEM_POWER "system power" 143 #define SUPPORTED_BATTERY_COUNT "supported_battery_count" 144 145 #define BW_ENABLED "enabled" 146 #define BW_POWEROFF_THRESHOLD "warn capacity threshold" 147 #define BW_SHUTDOWN_THRESHOLD "low capacity threshold" 148 149 #define BIF_UNIT "bif_unit" 150 #define BIF_DESIGN_CAP "bif_design_cap" 151 #define BIF_LAST_CAP "bif_last_cap" 152 #define BIF_TECH "bif_tech" 153 #define BIF_VOLTAGE "bif_voltage" 154 #define BIF_WARN_CAP "bif_warn_cap" 155 #define BIF_LOW_CAP "bif_low_cap" 156 #define BIF_GRAN1_CAP "bif_gran1_cap" 157 #define BIF_GRAN2_CAP "bif_gran2_cap" 158 #define BIF_MODEL "bif_model" 159 #define BIF_SERIAL "bif_serial" 160 #define BIF_TYPE "bif_type" 161 #define BIF_OEM_INFO "bif_oem_info" 162 163 #define BST_STATE "bst_state" 164 #define BST_RATE "bst_rate" 165 #define BST_REM_CAP "bst_rem_cap" 166 #define BST_VOLTAGE "bst_voltage" 167 168 #define PSR_AC_PRESENT "psr_ac_present" 169 170 typedef struct batt_power_kstat_s { 171 struct kstat_named batt_power; 172 struct kstat_named batt_supported_battery_count; 173 } batt_power_kstat_t; 174 175 typedef struct batt_warn_kstat_s { 176 struct kstat_named batt_bw_enabled; 177 struct kstat_named batt_bw_charge_warn; 178 struct kstat_named batt_bw_charge_low; 179 } batt_warn_kstat_t; 180 181 /* BIF kstat */ 182 typedef struct batt_bif_kstat_s { 183 struct kstat_named batt_bif_unit; 184 struct kstat_named batt_bif_design_cap; 185 struct kstat_named batt_bif_last_cap; 186 struct kstat_named batt_bif_tech; 187 struct kstat_named batt_bif_voltage; 188 struct kstat_named batt_bif_warn_cap; 189 struct kstat_named batt_bif_low_cap; 190 struct kstat_named batt_bif_gran1_cap; 191 struct kstat_named batt_bif_gran2_cap; 192 struct kstat_named batt_bif_model; 193 struct kstat_named batt_bif_serial; 194 struct kstat_named batt_bif_type; 195 struct kstat_named batt_bif_oem_info; 196 } batt_bif_kstat_t; 197 198 /* BST kstat */ 199 typedef struct batt_bst_kstat_s { 200 struct kstat_named batt_bst_state; 201 struct kstat_named batt_bst_rate; 202 struct kstat_named batt_bst_rem_cap; 203 struct kstat_named batt_bst_voltage; 204 } batt_bst_kstat_t; 205 206 #ifdef __cplusplus 207 } 208 #endif 209 210 #endif /* _BATTERY_H */ 211