OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009-2010 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 /** |
| 34 * @file |
| 35 * <b>NVIDIA Tegra ODM Kit: |
| 36 * Battery Interface</b> |
| 37 * |
| 38 * @b Description: Defines the ODM adaptation interface for |
| 39 * Embedded Controller (EC) based battery interface. |
| 40 * Note that this doesn't use PMU interface. |
| 41 * EC Interface is used to get battery and power supply |
| 42 * information and configure for events. |
| 43 * Battery charging is taken care by EC firmware itself. |
| 44 */ |
| 45 |
| 46 #ifndef INCLUDED_NVODM_BATTERY_H |
| 47 #define INCLUDED_NVODM_BATTERY_H |
| 48 |
| 49 #if defined(__cplusplus) |
| 50 extern "C" |
| 51 { |
| 52 #endif |
| 53 |
| 54 #include "nvodm_services.h" |
| 55 |
| 56 /** |
| 57 * @defgroup nvodm_battery_group Battery Adaptation Interface |
| 58 * |
| 59 * @ingroup nvodm_adaptation |
| 60 * @{ |
| 61 */ |
| 62 |
| 63 /** |
| 64 * Defines an opaque handle that exists for each battery device in the |
| 65 * system, each of which is defined by the customer implementation. |
| 66 */ |
| 67 typedef struct NvOdmBatteryDeviceRec *NvOdmBatteryDeviceHandle; |
| 68 |
| 69 /** |
| 70 * Defines the AC status. |
| 71 */ |
| 72 typedef enum |
| 73 { |
| 74 /// Specifies AC is offline. |
| 75 NvOdmBatteryAcLine_Offline, |
| 76 |
| 77 /// Specifies AC is online. |
| 78 NvOdmBatteryAcLine_Online, |
| 79 |
| 80 /// Specifies backup power. |
| 81 NvOdmBatteryAcLine_BackupPower, |
| 82 |
| 83 NvOdmBatteryAcLine_Num, |
| 84 /// Ignore -- Forces compilers to make 32-bit enums. |
| 85 NvOdmBatteryAcLine_Force32 = 0x7FFFFFFF |
| 86 }NvOdmBatteryAcLineStatus; |
| 87 |
| 88 /** |
| 89 * Defines the battery events. |
| 90 */ |
| 91 typedef enum |
| 92 { |
| 93 /// Indicates battery present state. |
| 94 NvOdmBatteryEventType_Present = 0x01, |
| 95 |
| 96 /// Indicates idle state. |
| 97 NvOdmBatteryEventType_Idle = 0x02, |
| 98 |
| 99 /// Indicates charging state. |
| 100 NvOdmBatteryEventType_Charging = 0x04, |
| 101 |
| 102 /// Indicates disharging state. |
| 103 NvOdmBatteryEventType_Disharging = 0x08, |
| 104 |
| 105 /// Indicates remaining capacity alarm set. |
| 106 NvOdmBatteryEventType_RemainingCapacityAlarm = 0x10, |
| 107 |
| 108 NvOdmBatteryEventType_Num = 0x20, |
| 109 |
| 110 /// Ignore -- Forces compilers to make 32-bit enums. |
| 111 NvOdmBatteryEventType_Force32 = 0x7FFFFFFF |
| 112 }NvOdmBatteryEventType; |
| 113 |
| 114 /** @name Battery Status Defines */ |
| 115 /*@{*/ |
| 116 |
| 117 #define NVODM_BATTERY_STATUS_HIGH 0x01 |
| 118 #define NVODM_BATTERY_STATUS_LOW 0x02 |
| 119 #define NVODM_BATTERY_STATUS_CRITICAL 0x04 |
| 120 #define NVODM_BATTERY_STATUS_CHARGING 0x08 |
| 121 #define NVODM_BATTERY_STATUS_DISCHARGING 0x10 |
| 122 #define NVODM_BATTERY_STATUS_IDLE 0x20 |
| 123 #define NVODM_BATTERY_STATUS_VERY_CRITICAL 0x40 |
| 124 #define NVODM_BATTERY_STATUS_NO_BATTERY 0x80 |
| 125 #define NVODM_BATTERY_STATUS_UNKNOWN 0xFF |
| 126 |
| 127 /*@}*/ |
| 128 /** @name Battery Data Defines */ |
| 129 /*@{*/ |
| 130 #define NVODM_BATTERY_DATA_UNKNOWN 0x7FFFFFFF |
| 131 |
| 132 /*@}*/ |
| 133 /** |
| 134 * Defines battery instances. |
| 135 */ |
| 136 typedef enum |
| 137 { |
| 138 /// Specifies main battery. |
| 139 NvOdmBatteryInst_Main, |
| 140 |
| 141 /// Specifies backup battery. |
| 142 NvOdmBatteryInst_Backup, |
| 143 |
| 144 NvOdmBatteryInst_Num, |
| 145 /// Ignore -- Forces compilers to make 32-bit enums. |
| 146 NvOdmBatteryInst_Force32 = 0x7FFFFFFF |
| 147 |
| 148 }NvOdmBatteryInstance; |
| 149 |
| 150 /** |
| 151 * Defines battery data. |
| 152 */ |
| 153 typedef struct NvOdmBatteryDataRec |
| 154 { |
| 155 /// Specifies battery life percent. |
| 156 NvU32 BatteryLifePercent; |
| 157 |
| 158 /// Specifies battery lifetime. |
| 159 NvU32 BatteryLifeTime; |
| 160 |
| 161 /// Specifies voltage. |
| 162 NvU32 BatteryVoltage; |
| 163 |
| 164 /// Specifies battery current. |
| 165 NvS32 BatteryCurrent; |
| 166 |
| 167 /// Specifies battery average current. |
| 168 NvS32 BatteryAverageCurrent; |
| 169 |
| 170 /// Specifies battery interval. |
| 171 NvU32 BatteryAverageInterval; |
| 172 |
| 173 /// Specifies the mAH consumed. |
| 174 NvU32 BatteryMahConsumed; |
| 175 |
| 176 /// Specifies battery temperature. |
| 177 NvU32 BatteryTemperature; |
| 178 |
| 179 /// Specifies battery remaining capacity. |
| 180 NvU32 BatteryRemainingCapacity; |
| 181 |
| 182 /// Specifies battery last charge full capacity. |
| 183 NvU32 BatteryLastChargeFullCapacity; |
| 184 |
| 185 /// Specifies battery critical capacity. |
| 186 NvU32 BatteryCriticalCapacity; |
| 187 |
| 188 }NvOdmBatteryData; |
| 189 |
| 190 /** |
| 191 * Defines battery chemistry. |
| 192 */ |
| 193 typedef enum |
| 194 { |
| 195 /// Specifies an alkaline battery. |
| 196 NvOdmBatteryChemistry_Alkaline, |
| 197 |
| 198 /// Specifies a nickel-cadmium (NiCd) battery. |
| 199 NvOdmBatteryChemistry_NICD, |
| 200 |
| 201 /// Specifies a nickel-metal hydride (NiMH) battery. |
| 202 NvOdmBatteryChemistry_NIMH, |
| 203 |
| 204 /// Specifies a lithium-ion (Li-ion) battery. |
| 205 NvOdmBatteryChemistry_LION, |
| 206 |
| 207 /// Specifies a lithium-ion polymer (Li-poly) battery. |
| 208 NvOdmBatteryChemistry_LIPOLY, |
| 209 |
| 210 /// Specifies a zinc-air battery. |
| 211 NvOdmBatteryChemistry_XINCAIR, |
| 212 |
| 213 NvOdmBatteryChemistry_Num, |
| 214 /// Ignore -- Forces compilers to make 32-bit enums. |
| 215 NvOdmBatteryChemistry_Force32 = 0x7FFFFFFF |
| 216 }NvOdmBatteryChemistry; |
| 217 |
| 218 /** |
| 219 * Opens the handle for battery ODM. |
| 220 * |
| 221 * @param hDevice A pointer to the handle to the battery ODM. |
| 222 * @param hOdmSemaphore Battery events signal this registered semaphore. |
| 223 * Can Pass NULL if events are not needed by client. |
| 224 * @return NV_TRUE if successful, or NV_FALSE otherwise. |
| 225 */ |
| 226 NvBool NvOdmBatteryDeviceOpen(NvOdmBatteryDeviceHandle *hDevice, |
| 227 NvOdmOsSemaphoreHandle *hOdmSemaphore); |
| 228 |
| 229 /** |
| 230 * Closes the handle for battery ODM. |
| 231 * |
| 232 * @param hDevice A handle to the battery ODM. |
| 233 */ |
| 234 void NvOdmBatteryDeviceClose(NvOdmBatteryDeviceHandle hDevice); |
| 235 |
| 236 /** |
| 237 * Gets the AC line status. |
| 238 * |
| 239 * @param hDevice A handle to the EC. |
| 240 * @param pStatus A pointer to the AC line |
| 241 * status returned by the ODM. |
| 242 * |
| 243 * @return NV_TRUE if successful, or NV_FALSE otherwise. |
| 244 */ |
| 245 NvBool NvOdmBatteryGetAcLineStatus( |
| 246 NvOdmBatteryDeviceHandle hDevice, |
| 247 NvOdmBatteryAcLineStatus *pStatus); |
| 248 |
| 249 |
| 250 /** |
| 251 * Gets the battery status. |
| 252 * |
| 253 * @param hDevice A handle to the EC. |
| 254 * @param batteryInst The battery type. |
| 255 * @param pStatus A pointer to the battery |
| 256 * status returned by the ODM. |
| 257 * |
| 258 * @return NV_TRUE if successful, or NV_FALSE otherwise. |
| 259 */ |
| 260 NvBool NvOdmBatteryGetBatteryStatus( |
| 261 NvOdmBatteryDeviceHandle hDevice, |
| 262 NvOdmBatteryInstance batteryInst, |
| 263 NvU8 *pStatus); |
| 264 |
| 265 /** |
| 266 * Gets the battery data. |
| 267 * |
| 268 * @param hDevice A handle to the EC. |
| 269 * @param batteryInst The battery type. |
| 270 * @param pData A pointer to the battery |
| 271 * data returned by the ODM. |
| 272 * |
| 273 * @return NV_TRUE if successful, or NV_FALSE otherwise. |
| 274 */ |
| 275 NvBool NvOdmBatteryGetBatteryData( |
| 276 NvOdmBatteryDeviceHandle hDevice, |
| 277 NvOdmBatteryInstance batteryInst, |
| 278 NvOdmBatteryData *pData); |
| 279 |
| 280 |
| 281 /** |
| 282 * Gets the battery full lifetime. |
| 283 * |
| 284 * @param hDevice A handle to the EC. |
| 285 * @param batteryInst The battery type. |
| 286 * @param pLifeTime A pointer to the battery |
| 287 * full lifetime returned by the ODM. |
| 288 * |
| 289 */ |
| 290 void NvOdmBatteryGetBatteryFullLifeTime( |
| 291 NvOdmBatteryDeviceHandle hDevice, |
| 292 NvOdmBatteryInstance batteryInst, |
| 293 NvU32 *pLifeTime); |
| 294 |
| 295 /** |
| 296 * Gets the battery chemistry. |
| 297 * |
| 298 * @param hDevice A handle to the EC. |
| 299 * @param batteryInst The battery type. |
| 300 * @param pChemistry A pointer to the battery |
| 301 * chemistry returned by the ODM. |
| 302 * |
| 303 */ |
| 304 void NvOdmBatteryGetBatteryChemistry( |
| 305 NvOdmBatteryDeviceHandle hDevice, |
| 306 NvOdmBatteryInstance batteryInst, |
| 307 NvOdmBatteryChemistry *pChemistry); |
| 308 |
| 309 /** |
| 310 * Gets the battery event. |
| 311 * |
| 312 * @param hDevice A handle to the EC. |
| 313 * @param pBatteryEvent A pointer to the battery events. |
| 314 * |
| 315 */ |
| 316 void NvOdmBatteryGetEvent( |
| 317 NvOdmBatteryDeviceHandle hDevice, |
| 318 NvU8 *pBatteryEvent); |
| 319 |
| 320 |
| 321 /** |
| 322 * Gets the battery manufacturer. |
| 323 * |
| 324 * @param hDevice [IN] A handle to the EC. |
| 325 * @param BatteryInst [IN] The battery type. |
| 326 * @param pBatteryManufacturer [OUT] A pointer to the battery manufacturer. |
| 327 */ |
| 328 NvBool NvOdmBatteryGetManufacturer( |
| 329 NvOdmBatteryDeviceHandle hDevice, |
| 330 NvOdmBatteryInstance BatteryInst, |
| 331 NvU8 *pBatteryManufacturer); |
| 332 |
| 333 /** |
| 334 * Gets the battery model. |
| 335 * |
| 336 * @param hDevice [IN] A handle to the EC. |
| 337 * @param BatteryInst [IN] The battery type. |
| 338 * @param pBatteryModel [OUT] A pointer to the battery model. |
| 339 */ |
| 340 NvBool NvOdmBatteryGetModel( |
| 341 NvOdmBatteryDeviceHandle hDevice, |
| 342 NvOdmBatteryInstance BatteryInst, |
| 343 NvU8 *pBatteryModel); |
| 344 |
| 345 #if defined(__cplusplus) |
| 346 } |
| 347 #endif |
| 348 |
| 349 /** @} */ |
| 350 |
| 351 #endif // INCLUDED_NVODM_BATTERY_H |
OLD | NEW |