~ubuntu-branches/ubuntu/vivid/linux-fsl-imx51/vivid

« back to all changes in this revision

Viewing changes to arch/arm/mach-stmp378x/include/mach/ddi_bc.h

  • Committer: Bazaar Package Importer
  • Author(s): Andy Whitcroft, Amit Kucheria, Andy Whitcroft, Bryan Wu, Upstream Kernel Changes
  • Date: 2010-01-11 16:26:27 UTC
  • Revision ID: james.westby@ubuntu.com-20100111162627-1q2fl9tcuwcywt1e
Tags: 2.6.31-602.4
[ Amit Kucheria ]

* Update to official 2.6.31 BSP release from Freescale

[ Andy Whitcroft ]

* drop a number of modules no longer built

[ Bryan Wu ]

* [Config] Update configs after applying .31 patchset from Freescale
* [Config] Sync with imx51_defconfig from Freescale BSP

[ Upstream Kernel Changes ]

* Update to official 2.6.31 BSP release from Freescale.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
 
3
 */
 
4
 
 
5
/*
 
6
 * The code contained herein is licensed under the GNU General Public
 
7
 * License. You may obtain a copy of the GNU General Public License
 
8
 * Version 2 or later at the following locations:
 
9
 *
 
10
 * http://www.opensource.org/licenses/gpl-license.html
 
11
 * http://www.gnu.org/copyleft/gpl.html
 
12
 */
 
13
 
 
14
////////////////////////////////////////////////////////////////////////////////
 
15
//! \addtogroup ddi_bc
 
16
//! @{
 
17
//
 
18
// Copyright (c) 2004-2005 SigmaTel, Inc.
 
19
//
 
20
//! \file ddi_bc.h
 
21
//! \brief Header file for the Battery Charger device driver.
 
22
//! \date 06/2005
 
23
//!
 
24
//! This file contains externally visible declarations for the Battery Charger
 
25
//! device driver.
 
26
//!
 
27
//! \see ddi_bc.c and related files.
 
28
//! \todo [PUBS] Add definitions for TBDs in this file.
 
29
////////////////////////////////////////////////////////////////////////////////
 
30
 
 
31
#ifndef _DDI_BC_H
 
32
#define _DDI_BC_H
 
33
 
 
34
#include <linux/types.h>
 
35
 
 
36
////////////////////////////////////////////////////////////////////////////////
 
37
// Includes
 
38
////////////////////////////////////////////////////////////////////////////////
 
39
 
 
40
////////////////////////////////////////////////////////////////////////////////
 
41
// Definitions
 
42
////////////////////////////////////////////////////////////////////////////////
 
43
#define DDI_BC_MAX_RESTART_CYCLES 100
 
44
 
 
45
#define DDI_BC_LIION_CHARGING_VOLTAGE  4200
 
46
#define DDI_BC_ALKALINE_NIMH_CHARGING_VOLTAGE 1750
 
47
 
 
48
//! \brief Defines battery charger states.
 
49
typedef enum _ddi_bc_State {
 
50
        //! \brief TBD
 
51
        DDI_BC_STATE_UNINITIALIZED = 0,
 
52
        //! \brief TBD
 
53
        DDI_BC_STATE_BROKEN = 1,
 
54
        //! \brief TBD
 
55
        DDI_BC_STATE_DISABLED = 2,
 
56
        //! \brief TBD
 
57
        DDI_BC_STATE_WAITING_TO_CHARGE = 3,
 
58
        //! \brief TBD
 
59
        DDI_BC_STATE_CONDITIONING = 4,
 
60
        //! \brief TBD
 
61
        DDI_BC_STATE_CHARGING = 5,
 
62
        //! \brief TBD
 
63
        DDI_BC_STATE_TOPPING_OFF = 6,
 
64
        //! \brief TBD
 
65
        DDI_BC_STATE_DCDC_MODE_WAITING_TO_CHARGE = 7,
 
66
 
 
67
} ddi_bc_State_t;
 
68
 
 
69
typedef enum _ddi_bc_BrokenReason {
 
70
        //! \brief TBD
 
71
        DDI_BC_BROKEN_UNINITIALIZED = 0,
 
72
        //! \brief TBD
 
73
        DDI_BC_BROKEN_CHARGING_TIMEOUT = 1,
 
74
        //! \brief TBD
 
75
        DDI_BC_BROKEN_FORCED_BY_APPLICATION = 2,
 
76
        //! \brief TBD
 
77
        DDI_BC_BROKEN_EXTERNAL_BATTERY_VOLTAGE_DETECTED = 3,
 
78
        //! \brief TBD
 
79
        DDI_BC_BROKEN_NO_BATTERY_DETECTED = 4,
 
80
 
 
81
} ddi_bc_BrokenReason_t;
 
82
 
 
83
//! \brief Defines the battery charger configuration.
 
84
typedef struct _ddi_bc_Cfg {
 
85
        //! \brief Units in milliseconds.
 
86
        //!
 
87
        //! This field configures the expected period between calls to
 
88
        //! ddi_bc_StateMachine. If die temperature monitoring is
 
89
        //! enabled, then the data sheet recommends the period be around
 
90
        //! 100ms or less.
 
91
        //!
 
92
        //! Note that this period defines the minimum time resolution of
 
93
        //! the battery charger.
 
94
 
 
95
        uint32_t u32StateMachinePeriod;
 
96
 
 
97
        //! \brief Units in mA/s.
 
98
        //!
 
99
        //! This field configures the slope of the current ramp. Any
 
100
        //! time the battery charger increases its current draw, it will
 
101
        //! ramp up the current no faster than this rate.
 
102
        //!
 
103
        //! Note that the minimum time resolution of the battery charger
 
104
        //! is the configured period between calls to advance the state
 
105
        //! machine. Also, the hardware has a minimum current resolution
 
106
        //! of 10mA. If the given ramp slope cannot be expressed
 
107
        //! exactly, then the largest expressible smaller slope will be
 
108
        //! the result. If the actual period between calls to
 
109
        //! ddi_bc_StateMachine is irregular, the current may ramp faster
 
110
        //! than indicated.
 
111
 
 
112
        uint16_t u16CurrentRampSlope;
 
113
 
 
114
        //! \brief Units in millivolts.
 
115
        //!
 
116
        //! This field configures the threshold conditioning voltage. If
 
117
        //! the battery�s voltage is below this value, it will be
 
118
        //! conditioned until its voltage rises above the maximum
 
119
        //! conditioning voltage.  After that, the battery will be
 
120
        //! charged normally.
 
121
        //!
 
122
        //! Note that the hardware has a minimum resolution of 8mV. If
 
123
        //! the given voltage cannot be expressed exactly, then the
 
124
        //! smallest expressible larger value will be used.
 
125
 
 
126
        uint16_t u16ConditioningThresholdVoltage;
 
127
 
 
128
        //! \brief Units in millivolts.
 
129
        //!
 
130
        //! This field configures the maximum conditioning voltage. If
 
131
        //! the battery charger is conditioning a battery, normal
 
132
        //! charging begins when the voltage rises above this value.
 
133
        //!
 
134
        //! This value should be slightly higher than the threshold
 
135
        //! conditioning voltage because it is measured while a
 
136
        //! conditioning current is actually flowing to the battery.
 
137
        //! With a conditioning current of 0.1C, reasonable values for
 
138
        //! the threshold and maximum conditioning voltages are 2.9V
 
139
        //! and 3.0V respectively.
 
140
        //!
 
141
        //! Note that the hardware has a minimum resolution of 8mV. If
 
142
        //! the given voltage cannot be expressed exactly, then the
 
143
        //! smallest expressible larger value will be used.
 
144
 
 
145
        uint16_t u16ConditioningMaxVoltage;
 
146
 
 
147
        //! \brief Units in milliamps.
 
148
        //!
 
149
        //! This field configures the maximum conditioning current.
 
150
        //! This is the maximum current that will be offered to a
 
151
        //! battery while it is being conditioned. A typical value is
 
152
        //! 0.1C.
 
153
        //!
 
154
        //! Note that the hardware has a minimum resolution of 10mA
 
155
        //! (see the data sheet for details). If the given current
 
156
        //! cannot be expressed exactly, then the largest expressible
 
157
        //! smaller value will be used.
 
158
 
 
159
        uint16_t u16ConditioningCurrent;
 
160
 
 
161
        //! \brief Units in milliseconds.
 
162
        //!
 
163
        //! This field configures the conditioning time-out. This is
 
164
        //! the maximum amount of time that a battery will be
 
165
        //! conditioned before the battery charger declares it to be
 
166
        //! broken.
 
167
        //!
 
168
        //! Note that the minimum time resolution of the battery
 
169
        //! charger is the configured period between calls to advance
 
170
        //! the state machine. If the given time-out cannot be
 
171
        //! expressed exactly, then the shortest expressible longer
 
172
        //! value will be used.
 
173
 
 
174
        uint32_t u32ConditioningTimeout;
 
175
 
 
176
        //! \brief Units in millivolts.
 
177
        //!
 
178
        //! This field configures the final charging voltage. At this
 
179
        //! writing, only two values are permitted: 4100 or 4200.
 
180
 
 
181
        uint16_t u16ChargingVoltage;
 
182
 
 
183
        //! \brief Units in milliamps.
 
184
        //!
 
185
        //! This field configures the maximum current offered to a
 
186
        //! charging battery.
 
187
        //!
 
188
        //! Note that the hardware has a minimum resolution of 10mA
 
189
        //! (see the data sheet for details). If the given current
 
190
        //! cannot be expressed exactly, then the largest expressible
 
191
        //! smaller value will be used.
 
192
 
 
193
        uint16_t u16ChargingCurrent;
 
194
 
 
195
        //! \brief Units in milliamps.
 
196
        //!
 
197
        //! This field configures the current flow below which a
 
198
        //! charging battery is regarded as fully charged (typical
 
199
        //! 0.1C). At this point, the battery will be topped off.
 
200
        //!
 
201
        //! Note that the hardware has a minimum resolution of 10mA
 
202
        //! (see the data sheet for details). If the given current
 
203
        //! cannot be expressed exactly, then the largest expressible
 
204
        //! smaller value will be used.
 
205
 
 
206
        uint16_t u16ChargingThresholdCurrent;
 
207
 
 
208
        //! \brief Units in milliamps.
 
209
        //!
 
210
        //! When charging while the DCDC converter's are enabled, the charger
 
211
        //! is suppling current to both the battery and the Vbat input of the
 
212
        //! DCDC converter.  Once the total battery charger current falls
 
213
        //! below this level, the charger will then stop charging until the
 
214
        //! the battery voltage reaches the BC_LOW_DCDCMODE_BATTERY_VOLTAGE
 
215
        //! threshold or until the DCDCs are no longer enabled.
 
216
        //!
 
217
        //! Typically, this value should be left at 180 to avoid the risk
 
218
        //! of topping off the battery too long in DCDC mode and avoid
 
219
        //! exceeding the BC_CHARGING_TIMEOUT time which would put the charger
 
220
        //! driver in the broken state and completely disable charging.
 
221
        //!
 
222
        //! Note that the hardware has a minimum resolution of 10mA
 
223
        //! (see the data sheet for details). If the given current
 
224
        //! cannot be expressed exactly, then the largest expressible
 
225
        //! smaller value will be used.
 
226
        uint16_t u16DdcdModeChargingThresholdCurrent;
 
227
 
 
228
        //! \brief Units in milliseconds.
 
229
        //!
 
230
        //! This field configures the charging time-out. This is the
 
231
        //! maximum amount of time that a battery will be charged
 
232
        //! before the battery charger declares it to be broken.
 
233
        //!
 
234
        //! Note that the minimum time resolution of the battery
 
235
        //! charger is the configured period between calls to advance
 
236
        //! the state machine. If the given time-out cannot be
 
237
        //! expressed exactly, then the shortest expressible longer
 
238
        //! value will be used.
 
239
 
 
240
        uint32_t u32ChargingTimeout;
 
241
 
 
242
        //! \brief Units in milliseconds.
 
243
        //!
 
244
        //! This field configures the top-off period. This is the
 
245
        //! amount of time a battery will be held in the Topping Off
 
246
        //! state before it is declared fully charged.
 
247
        //!
 
248
        //! Note that the minimum time resolution of the battery
 
249
        //! charger is the configured period between calls to advance
 
250
        //! the state machine. If the given time-out cannot be
 
251
        //! expressed exactly, then the shortest expressible longer
 
252
        //! value will be used.
 
253
 
 
254
        uint32_t u32TopOffPeriod;
 
255
 
 
256
        //! \brief Units in milliseconds.
 
257
        //!
 
258
        //! This field configures the top-off period when the DCDC
 
259
        //! converters are enabled. To avoid topping off the LiIon
 
260
        //! battery too long and reducing it's long term capacity,
 
261
        //! This time should be kept failry short.
 
262
        //!
 
263
        //! Note that the minimum time resolution of the battery
 
264
        //! charger is the configured period between calls to advance
 
265
        //! the state machine. If the given time-out cannot be
 
266
        //! expressed exactly, then the shortest expressible longer
 
267
        //! value will be used.
 
268
        uint32_t u32DcdcModeTopOffPeriod;
 
269
 
 
270
        //! \brief Causes the battery charger to use an externally generated bias current
 
271
        //!
 
272
        //! If cleared, this causes the battery charger to use an
 
273
        //! externally generated bias current, which is expected to be
 
274
        //! quite precise. Otherwise, the battery charger will
 
275
        //! generate a lesser-quality bias current internally.
 
276
 
 
277
        uint8_t useInternalBias:1;
 
278
 
 
279
        //! \brief Indicates that the battery charger is to monitor the die temperature.
 
280
        //!
 
281
        //! If set, this field indicates that the battery charger is to
 
282
        //! monitor the die temperature. See below for fields that
 
283
        //! configure the details.
 
284
 
 
285
        uint8_t monitorDieTemp:1;
 
286
 
 
287
        //! \brief Indicates that the battery charger is to monitor the battery temperature.
 
288
        //!
 
289
        //! If set, this field indicates that the battery charger is to
 
290
        //! monitor the battery temperature. See below for fields that
 
291
        //! configure the details.
 
292
 
 
293
        uint8_t monitorBatteryTemp:1;
 
294
 
 
295
        //! \brief Units in degrees centigrade.
 
296
        //!
 
297
        //! Note that the hardware reports die temperature in ranges of
 
298
        //! 10 degree resolution minimum (see the data sheet for
 
299
        //! details). If the battery charger is monitoring the die
 
300
        //! temperature, and it rises to a range that includes a
 
301
        //! temperature greater than or equal to this value, the
 
302
        //! charging current will be clamped to the safe current.
 
303
 
 
304
        int8_t u8DieTempHigh;
 
305
 
 
306
        //! \brief Units in degrees centigrade.
 
307
        //!
 
308
        //! Note that the hardware reports die temperature in ranges of
 
309
        //! 10 degrees minimum (see the data sheet for details). If the
 
310
        //! charging current is being clamped because of a high die
 
311
        //! temperature, and it falls to a range that doesn�t include a
 
312
        //! temperatures greater than or equal to this value, the
 
313
        //! charging current clamp will be released.
 
314
 
 
315
        int8_t u8DieTempLow;
 
316
 
 
317
        //! \brief Units in milliamps.
 
318
        //!
 
319
        //! If the battery charger detects a high die temperature, it
 
320
        //! will clamp the charging current at or below this value.
 
321
 
 
322
        uint16_t u16DieTempSafeCurrent;
 
323
 
 
324
        //! \brief If the battery charger is monitoring the battery
 
325
        //! temperature, this field indicates the LRADC channel to
 
326
        //! read.
 
327
 
 
328
        uint8_t u8BatteryTempChannel;
 
329
 
 
330
        //! \brief If the battery charger is monitoring the battery
 
331
        //! temperature, and it rises to a measurement greater than or
 
332
        //! equal to this value, the charging current will be clamped
 
333
        //! to the corresponding safe current.
 
334
 
 
335
        uint16_t u16BatteryTempHigh;
 
336
 
 
337
        //! \brief If the charging current is being clamped because of a high
 
338
        //! battery temperature, and it falls below this value, the
 
339
        //! charging current clamp will be released.
 
340
 
 
341
        uint16_t u16BatteryTempLow;
 
342
 
 
343
        //! \brief Units in milliamps.
 
344
        //!
 
345
        //! If the battery charger detects a high battery temperature,
 
346
        //! it will clamp the charging current at or below this value.
 
347
 
 
348
        uint16_t u16BatteryTempSafeCurrent;
 
349
 
 
350
        //! \brief Units in millivolts.
 
351
        //!
 
352
        //! In the WaitingToCharge state, if we are in DCDC
 
353
        //! operating modes, if the battery voltage measurement
 
354
        //! is below this value, we immediately proceed with charging.
 
355
        //! the low criteria for this value is that it must be high
 
356
        //! to not risk the battery voltage getting too low.  The
 
357
        //! upper criteria is that you do not want the IR voltage
 
358
        //! drop under heavy loads to make you start charging too soon
 
359
        //! because the goal in DCDC operating mode is to not be constantly
 
360
        //! topping off the battery which can shorten its life
 
361
 
 
362
        uint16_t u16LowDcdcBatteryVoltage_mv;
 
363
 
 
364
        uint32_t u32StateMachineNonChargingPeriod;
 
365
} ddi_bc_Cfg_t;
 
366
 
 
367
//! Status returned by Battery Charger functions.
 
368
 
 
369
typedef enum _ddi_bc_Status {
 
370
        //! \brief TBD
 
371
        DDI_BC_STATUS_SUCCESS = 0,
 
372
        //! \brief TBD
 
373
        DDI_BC_STATUS_HARDWARE_DISABLED,
 
374
        //! \brief TBD
 
375
        DDI_BC_STATUS_BAD_BATTERY_MODE,
 
376
        //! \brief TBD
 
377
        DDI_BC_STATUS_CLOCK_GATE_CLOSED,
 
378
        //! \brief TBD
 
379
        DDI_BC_STATUS_NOT_INITIALIZED,
 
380
        //! \brief TBD
 
381
        DDI_BC_STATUS_ALREADY_INITIALIZED,
 
382
        //! \brief TBD
 
383
        DDI_BC_STATUS_BROKEN,
 
384
        //! \brief TBD
 
385
        DDI_BC_STATUS_NOT_BROKEN,
 
386
        //! \brief TBD
 
387
        DDI_BC_STATUS_NOT_DISABLED,
 
388
        //! \brief TBD
 
389
        DDI_BC_STATUS_BAD_ARGUMENT,
 
390
        //! \brief TBD
 
391
        DDI_BC_STATUS_CFG_BAD_BATTERY_TEMP_CHANNEL,
 
392
        //! \brief TBD
 
393
        DDI_BC_STATUS_CFG_BAD_CHARGING_VOLTAGE,
 
394
} ddi_bc_Status_t;
 
395
 
 
396
/////////////////////////////////////////////////////////////////////////////////
 
397
//  BCM Event Codes
 
398
//
 
399
// These are the codes that might be published to PMI Subscribers.
 
400
/////////////////////////////////////////////////////////////////////////////////
 
401
 
 
402
#define DDI_BC_EVENT_GROUP (11<<10)
 
403
 
 
404
//! \brief TBD
 
405
//! \todo [PUBS] Add definition(s)...
 
406
typedef enum {
 
407
        // Use the error code group value to make events unique for the EOI
 
408
        //! \brief TBD
 
409
        ddi_bc_MinEventCode = DDI_BC_EVENT_GROUP,
 
410
        //! \brief TBD
 
411
        ddi_bc_WaitingToChargeCode,
 
412
        //! \brief TBD
 
413
        ddi_bc_State_ConditioningCode,
 
414
        //! \brief TBD
 
415
        ddi_bc_State_Topping_OffCode,
 
416
        //! \brief TBD
 
417
        ddi_bc_State_BrokenCode,
 
418
        //! \brief TBD
 
419
        ddi_bc_SettingChargeCode,
 
420
        //! \brief TBD
 
421
        ddi_bc_RaisingDieTempAlarmCode,
 
422
        //! \brief TBD
 
423
        ddi_bc_DroppingDieTempAlarmCode,
 
424
 
 
425
        //! \brief TBD
 
426
        ddi_bc_MaxEventCode,
 
427
        //! \brief TBD
 
428
        ddi_bc_DcdcModeWaitingToChargeCode
 
429
} ddi_bc_Event_t;
 
430
 
 
431
////////////////////////////////////////////////////////////////////////////////
 
432
// Prototypes
 
433
////////////////////////////////////////////////////////////////////////////////
 
434
 
 
435
////////////////////////////////////////////////////////////////////////////////
 
436
//! \brief Initialize the Battery Charger.
 
437
//!
 
438
//! \fntype Function
 
439
//!
 
440
//! This function initializes the Battery Charger.
 
441
//!
 
442
//! \param[in]  pCfg  A pointer to the new configuration.
 
443
//!
 
444
//! \retval  DDI_BC_STATUS_SUCCESS
 
445
//!             If the operation succeeded.
 
446
//! \retval  DDI_BC_STATUS_ALREADY_INITIALIZED
 
447
//!             If the Battery Charger is already initialized.
 
448
//! \retval  DDI_BC_STATUS_HARDWARE_DISABLED
 
449
//!             If the Battery Charger hardware is disabled by a laser fuse.
 
450
//! \retval  DDI_BC_STATUS_BAD_BATTERY_MODE
 
451
//!             If the power supply is set up for a non-rechargeable battery.
 
452
//! \retval  DDI_BC_STATUS_CLOCK_GATE_CLOSED
 
453
//!             If the clock gate for the power supply registers is closed.
 
454
//! \retval  DDI_BC_STATUS_CFG_BAD_CHARGING_VOLTAGE
 
455
//!             If the charging voltage is not either 4100 or 4200.
 
456
//! \retval  DDI_BC_STATUS_CFG_BAD_BATTERY_TEMP_CHANNEL
 
457
//!             If the LRADC channel number for monitoring battery temperature
 
458
//!             is bad.
 
459
//!
 
460
//! \internal
 
461
//! \see To view the function definition, see ddi_bc_init.c.
 
462
////////////////////////////////////////////////////////////////////////////////
 
463
extern ddi_bc_Status_t ddi_bc_Init(ddi_bc_Cfg_t * pCfg);
 
464
////////////////////////////////////////////////////////////////////////////////
 
465
//!
 
466
//! \brief Report the Battery Charger configuration.
 
467
//!
 
468
//! \fntype Function
 
469
//!
 
470
//! This function reports the Battery Charger configuration.
 
471
//!
 
472
//! Note that, if the Battery Charger has not yet been initialized, the data
 
473
//! returned by this function is unknown.
 
474
//!
 
475
//! \param[in,out]  pCfg  A pointer to a structure that will receive the data.
 
476
//!
 
477
//! \internal
 
478
//! \see To view the function definition, see ddi_bc_api.c.
 
479
////////////////////////////////////////////////////////////////////////////////
 
480
extern void ddi_bc_QueryCfg(ddi_bc_Cfg_t * pCfg);
 
481
////////////////////////////////////////////////////////////////////////////////
 
482
//!
 
483
//! \brief Shut down the Battery Charger.
 
484
//!
 
485
//! \fntype Function
 
486
//!
 
487
//! This function immediately shuts down the Battery Charger hardware and
 
488
//! returns the state machine to the Uninitialized state. Use this function to
 
489
//! safely �mummify� the battery charger before retiring it from memory.
 
490
//!
 
491
//! \internal
 
492
//! \see To view the function definition, see ddi_bc_api.c.
 
493
////////////////////////////////////////////////////////////////////////////////
 
494
extern void ddi_bc_ShutDown(void);
 
495
////////////////////////////////////////////////////////////////////////////////
 
496
//!
 
497
//! \brief Advances the state machine.
 
498
//!
 
499
//! \fntype Function
 
500
//!
 
501
//! This function advances the state machine.
 
502
//!
 
503
//! \retval DDI_BC_STATUS_SUCCESS          If all goes well
 
504
//! \retval DDI_BC_STATUS_NOT_INITIALIZED  If the Battery Charger is not yet
 
505
//!                                        initialized.
 
506
//! \retval DDI_BC_STATUS_BROKEN           If the battery violated a time-out
 
507
//!                                        and has been declared broken.
 
508
//!
 
509
//! \internal
 
510
//! \see To view the function definition, see ddi_bc_api.c.
 
511
////////////////////////////////////////////////////////////////////////////////
 
512
extern ddi_bc_Status_t ddi_bc_StateMachine(void);
 
513
////////////////////////////////////////////////////////////////////////////////
 
514
//!
 
515
//! \brief Get the Battery Charger's current state.
 
516
//!
 
517
//! \fntype Function
 
518
//!
 
519
//! This function returns the current state.
 
520
//!
 
521
//! \retval The current state.
 
522
//!
 
523
//! \internal
 
524
//! \see To view the function definition, see ddi_bc_api.c.
 
525
////////////////////////////////////////////////////////////////////////////////
 
526
extern ddi_bc_State_t ddi_bc_GetState(void);
 
527
////////////////////////////////////////////////////////////////////////////////
 
528
//!
 
529
//! \brief Disable the Battery Charger.
 
530
//!
 
531
//! \fntype Function
 
532
//!
 
533
//! This function forces the Battery Charger into the Disabled state.
 
534
//!
 
535
//! \retval DDI_BC_STATUS_SUCCESS          If all goes well
 
536
//! \retval DDI_BC_STATUS_NOT_INITIALIZED  If the Battery Charger is not yet
 
537
//!                                        initialized.
 
538
//!
 
539
//! \internal
 
540
//! \see To view the function definition, see ddi_bc_api.c.
 
541
////////////////////////////////////////////////////////////////////////////////
 
542
extern ddi_bc_Status_t ddi_bc_SetDisable(void);
 
543
////////////////////////////////////////////////////////////////////////////////
 
544
//!
 
545
//! \brief Enable the Battery Charger.
 
546
//!
 
547
//! \fntype Function
 
548
//!
 
549
//! If the Battery Charger is in the Disabled state, this function moves it to
 
550
//! the Waiting to Charge state.
 
551
//!
 
552
//! \retval DDI_BC_STATUS_SUCCESS          If all goes well
 
553
//! \retval DDI_BC_STATUS_NOT_INITIALIZED  If the Battery Charger is not yet
 
554
//!                                        initialized.
 
555
//! \retval DDI_BC_STATUS_NOT_DISABLED     If the Battery Charger is not
 
556
//!                                        disabled.
 
557
//!
 
558
//! \internal
 
559
//! \see To view the function definition, see ddi_bc_api.c.
 
560
////////////////////////////////////////////////////////////////////////////////
 
561
extern ddi_bc_Status_t ddi_bc_SetEnable(void);
 
562
////////////////////////////////////////////////////////////////////////////////
 
563
//!
 
564
//! \brief Declare the battery to be broken.
 
565
//!
 
566
//! \fntype Function
 
567
//!
 
568
//! This function forces the Battery Charger into the Broken state.
 
569
//!
 
570
//! \retval DDI_BC_STATUS_SUCCESS          If all goes well
 
571
//! \retval DDI_BC_STATUS_NOT_INITIALIZED  If the Battery Charger is not yet
 
572
//!                                        initialized.
 
573
//!
 
574
//! \internal
 
575
//! \see To view the function definition, see ddi_bc_api.c.
 
576
////////////////////////////////////////////////////////////////////////////////
 
577
extern ddi_bc_Status_t ddi_bc_SetBroken(void);
 
578
////////////////////////////////////////////////////////////////////////////////
 
579
//!
 
580
//! \brief Declare the battery to be fixed.
 
581
//!
 
582
//! \fntype Function
 
583
//!
 
584
//! If the Battery Charger is in the Broken state, this function moves it to
 
585
//! the Disabled state.
 
586
//!
 
587
//! \retval DDI_BC_STATUS_SUCCESS          If all goes well
 
588
//! \retval DDI_BC_STATUS_NOT_INITIALIZED  If the Battery Charger is not yet
 
589
//!                                        initialized.
 
590
//! \retval DDI_BC_STATUS_NOT_BROKEN       If the Battery Charger is not broken.
 
591
//!
 
592
//! \internal
 
593
//! \see To view the function definition, see ddi_bc_api.c.
 
594
////////////////////////////////////////////////////////////////////////////////
 
595
extern ddi_bc_Status_t ddi_bc_SetFixed(void);
 
596
////////////////////////////////////////////////////////////////////////////////
 
597
//!
 
598
//! \brief Set the current limit.
 
599
//!
 
600
//! \fntype Function
 
601
//!
 
602
//! This function applies a limit to the current that the Battery Charger can
 
603
//! draw.
 
604
//!
 
605
//! \param[in]  u16Limit  The maximum current the Battery Charger can draw
 
606
//!                       (in mA).
 
607
//!
 
608
//! \retval  The expressible version of the limit.
 
609
//!
 
610
//! \internal
 
611
//! \see To view the function definition, see ddi_bc_api.c.
 
612
////////////////////////////////////////////////////////////////////////////////
 
613
extern uint16_t ddi_bc_SetCurrentLimit(uint16_t u16Limit);
 
614
 
 
615
////////////////////////////////////////////////////////////////////////////////
 
616
//!
 
617
//! \brief Report the current limit.
 
618
//!
 
619
//! \fntype Function
 
620
//!
 
621
//! This function reports the limit to the current that the Battery Charger can
 
622
//! draw.
 
623
//!
 
624
//! \retval  The current limit.
 
625
//!
 
626
//! \internal
 
627
//! \see To view the function definition, see ddi_bc_api.c.
 
628
////////////////////////////////////////////////////////////////////////////////
 
629
extern uint16_t ddi_bc_GetCurrentLimit(void);
 
630
 
 
631
////////////////////////////////////////////////////////////////////////////////
 
632
//!
 
633
//! \brief Set the current threshold.
 
634
//!
 
635
//! \fntype Function
 
636
//!
 
637
//!
 
638
//! \param[in]  u16Current Current threshold where charger deactivates (in mA).
 
639
//!
 
640
//!
 
641
////////////////////////////////////////////////////////////////////////////////
 
642
extern uint16_t ddi_bc_SetCurrentThreshold(uint16_t u16Current);
 
643
 
 
644
////////////////////////////////////////////////////////////////////////////////
 
645
//!
 
646
//! \brief Set the battery charger state machine period.
 
647
//!
 
648
//! \fntype Function
 
649
//!
 
650
//! This function sets a new state machine period.  The Period and Slope should
 
651
//! be coordinated to achieve the minimal ramp step current which will minimize
 
652
//! transients on the system.
 
653
//!
 
654
//! \param[in]  u32StateMachinePeriod  (in milliseconds)
 
655
//! \param[in]  u16CurrentRampSlope (in mA/s)
 
656
//!
 
657
//! \retval SUCCESS                        If all goes well
 
658
//! \retval ERROR_DDI_BCM_NOT_INITIALIZED  If the Battery Charger is not yet
 
659
//!                                        initialized.
 
660
//!
 
661
////////////////////////////////////////////////////////////////////////////////
 
662
extern ddi_bc_Status_t ddi_bc_SetNewPeriodAndSlope(uint32_t
 
663
                                                   u32StateMachinePeriod,
 
664
                                                   uint16_t
 
665
                                                   u16CurrentRampSlope);
 
666
 
 
667
////////////////////////////////////////////////////////////////////////////////
 
668
//!
 
669
//! \brief Report the state machine period.
 
670
//!
 
671
//! \fntype Function
 
672
//!
 
673
//! This function reports the battery charger period.
 
674
//!
 
675
//! \retval  The battery charger period (in milliseconds).
 
676
//!
 
677
////////////////////////////////////////////////////////////////////////////////
 
678
extern uint32_t ddi_bc_GetStateMachinePeriod(void);
 
679
 
 
680
////////////////////////////////////////////////////////////////////////////////
 
681
//!
 
682
//! \brief Report the current ramp slope.
 
683
//!
 
684
//! \fntype Function
 
685
//!
 
686
//! This function reports the current ramp slope.
 
687
//!
 
688
//! \retval  The current ramp slope (in mA/s).
 
689
//!
 
690
////////////////////////////////////////////////////////////////////////////////
 
691
extern uint32_t ddi_bc_GetCurrentRampSlope(void);
 
692
 
 
693
////////////////////////////////////////////////////////////////////////////////
 
694
//!
 
695
//! \brief Report the time spent in the present state (milliseconds)
 
696
//!
 
697
//! \fntype Function
 
698
//!
 
699
//! This function reports the time spent in the present charging state.  Note that
 
700
//! for the states that actually charge the battery, this time does not include the
 
701
//! time spent under alarm conditions such as die termperature alarm or battery
 
702
//! temperature alarm.
 
703
//!
 
704
//! \retval  The time spent in the current state in milliseconds.
 
705
//!
 
706
////////////////////////////////////////////////////////////////////////////////
 
707
uint32_t ddi_bc_GetStateTime(void);
 
708
 
 
709
////////////////////////////////////////////////////////////////////////////////
 
710
//!
 
711
//! \brief Report the reason for being in the broken state
 
712
//!
 
713
//! \fntype Function
 
714
//!
 
715
//!
 
716
//! \retval  ddi_bc_BrokenReason_t enumeration
 
717
//!
 
718
////////////////////////////////////////////////////////////////////////////////
 
719
ddi_bc_BrokenReason_t ddi_bc_GetBrokenReason(void);
 
720
 
 
721
////////////////////////////////////////////////////////////////////////////////
 
722
//!
 
723
//! \brief Restart the charge cycle
 
724
//!
 
725
//! \fntype Function
 
726
//!
 
727
//! \retval  SUCCESS
 
728
//!
 
729
////////////////////////////////////////////////////////////////////////////////
 
730
ddi_bc_Status_t ddi_bc_ForceChargingToStart(void);
 
731
 
 
732
////////////////////////////////////////////////////////////////////////////////
 
733
// End of file
 
734
////////////////////////////////////////////////////////////////////////////////
 
735
#endif                          // _DDI_BC_H
 
736
//! @}