Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros
ab8500_fg.c File Reference
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/kobject.h>
#include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/abx500.h>
#include <linux/slab.h>
#include <linux/mfd/abx500/ab8500-bm.h>
#include <linux/delay.h>
#include <linux/mfd/abx500/ab8500-gpadc.h>
#include <linux/time.h>
#include <linux/completion.h>

Go to the source code of this file.

Data Structures

struct  ab8500_fg_interrupts
 
struct  ab8500_fg_avg_cap
 
struct  ab8500_fg_battery_capacity
 
struct  ab8500_fg_flags
 
struct  inst_curr_result_list
 
struct  ab8500_fg
 
struct  ab8500_fg_sysfs_entry
 

Macros

#define MILLI_TO_MICRO   1000
 
#define FG_LSB_IN_MA   1627
 
#define QLSB_NANO_AMP_HOURS_X10   1129
 
#define INS_CURR_TIMEOUT   (3 * HZ)
 
#define SEC_TO_SAMPLE(S)   (S * 4)
 
#define NBR_AVG_SAMPLES   20
 
#define LOW_BAT_CHECK_INTERVAL   (2 * HZ)
 
#define VALID_CAPACITY_SEC   (45 * 60) /* 45 minutes */
 
#define BATT_OK_MIN   2360 /* mV */
 
#define BATT_OK_INCREMENT   50 /* mV */
 
#define BATT_OK_MAX_NR_INCREMENTS   0xE
 
#define BATT_OVV   0x01
 
#define interpolate(x, x1, y1, x2, y2)   ((y1) + ((((y2) - (y1)) * ((x) - (x1))) / ((x2) - (x1))));
 
#define to_ab8500_fg_device_info(x)
 

: name of the interrupt

struct ab8500_fg_interrupts - ab8500 fg interupts

function pointer to the isr

#define ab8500_fg_suspend   NULL
 
#define ab8500_fg_resume   NULL
 
enum  ab8500_fg_discharge_state {
  AB8500_FG_DISCHARGE_INIT, AB8500_FG_DISCHARGE_INITMEASURING, AB8500_FG_DISCHARGE_INIT_RECOVERY, AB8500_FG_DISCHARGE_RECOVERY,
  AB8500_FG_DISCHARGE_READOUT_INIT, AB8500_FG_DISCHARGE_READOUT, AB8500_FG_DISCHARGE_WAKEUP
}
 
enum  ab8500_fg_charge_state { AB8500_FG_CHARGE_INIT, AB8500_FG_CHARGE_READOUT }
 
enum  ab8500_fg_calibration_state { AB8500_FG_CALIB_INIT, AB8500_FG_CALIB_WAIT, AB8500_FG_CALIB_END }
 
struct ab8500_fgab8500_fg_get (void)
 
int ab8500_fg_inst_curr_start (struct ab8500_fg *di)
 
int ab8500_fg_inst_curr_done (struct ab8500_fg *di)
 
int ab8500_fg_inst_curr_finalize (struct ab8500_fg *di, int *res)
 
int ab8500_fg_inst_curr_blocking (struct ab8500_fg *di)
 
void ab8500_fg_reinit (void)
 
 subsys_initcall_sync (ab8500_fg_init)
 
 module_exit (ab8500_fg_exit)
 
 MODULE_LICENSE ("GPL v2")
 
 MODULE_AUTHOR ("Johan Palsson, Karl Komierowski")
 
 MODULE_ALIAS ("platform:ab8500-fg")
 
 MODULE_DESCRIPTION ("AB8500 Fuel Gauge driver")
 

Macro Definition Documentation

#define ab8500_fg_resume   NULL

Definition at line 2411 of file ab8500_fg.c.

#define ab8500_fg_suspend   NULL

Definition at line 2410 of file ab8500_fg.c.

#define BATT_OK_INCREMENT   50 /* mV */

Definition at line 48 of file ab8500_fg.c.

#define BATT_OK_MAX_NR_INCREMENTS   0xE

Definition at line 49 of file ab8500_fg.c.

#define BATT_OK_MIN   2360 /* mV */

Definition at line 47 of file ab8500_fg.c.

#define BATT_OVV   0x01

Definition at line 52 of file ab8500_fg.c.

#define FG_LSB_IN_MA   1627

Definition at line 36 of file ab8500_fg.c.

#define INS_CURR_TIMEOUT   (3 * HZ)

Definition at line 38 of file ab8500_fg.c.

#define interpolate (   x,
  x1,
  y1,
  x2,
  y2 
)    ((y1) + ((((y2) - (y1)) * ((x) - (x1))) / ((x2) - (x1))));

Definition at line 54 of file ab8500_fg.c.

#define LOW_BAT_CHECK_INTERVAL   (2 * HZ)

Definition at line 44 of file ab8500_fg.c.

#define MILLI_TO_MICRO   1000

Definition at line 35 of file ab8500_fg.c.

#define NBR_AVG_SAMPLES   20

Definition at line 42 of file ab8500_fg.c.

#define QLSB_NANO_AMP_HOURS_X10   1129

Definition at line 37 of file ab8500_fg.c.

#define SEC_TO_SAMPLE (   S)    (S * 4)

Definition at line 40 of file ab8500_fg.c.

#define to_ab8500_fg_device_info (   x)
Value:
struct ab8500_fg, fg_psy);

Definition at line 57 of file ab8500_fg.c.

#define VALID_CAPACITY_SEC   (45 * 60) /* 45 minutes */

Definition at line 46 of file ab8500_fg.c.

Enumeration Type Documentation

Enumerator:
AB8500_FG_CALIB_INIT 
AB8500_FG_CALIB_WAIT 
AB8500_FG_CALIB_END 

Definition at line 100 of file ab8500_fg.c.

Enumerator:
AB8500_FG_CHARGE_INIT 
AB8500_FG_CHARGE_READOUT 

Definition at line 90 of file ab8500_fg.c.

Enumerator:
AB8500_FG_DISCHARGE_INIT 
AB8500_FG_DISCHARGE_INITMEASURING 
AB8500_FG_DISCHARGE_INIT_RECOVERY 
AB8500_FG_DISCHARGE_RECOVERY 
AB8500_FG_DISCHARGE_READOUT_INIT 
AB8500_FG_DISCHARGE_READOUT 
AB8500_FG_DISCHARGE_WAKEUP 

Definition at line 70 of file ab8500_fg.c.

Function Documentation

struct ab8500_fg* ab8500_fg_get ( void  )
read

ab8500_fg_get() - returns a reference to the primary AB8500 fuel gauge (i.e. the first fuel gauge in the instance list)

Definition at line 234 of file ab8500_fg.c.

int ab8500_fg_inst_curr_blocking ( struct ab8500_fg di)

ab8500_fg_inst_curr_blocking() - battery instantaneous current : pointer to the ab8500_fg structure : battery instantenous current(on success)

Returns 0 else error code

Definition at line 684 of file ab8500_fg.c.

int ab8500_fg_inst_curr_done ( struct ab8500_fg di)

ab8500_fg_inst_curr_done() - check if fg conversion is done : pointer to the ab8500_fg structure

Returns 1 if conversion done, 0 if still waiting

Definition at line 577 of file ab8500_fg.c.

int ab8500_fg_inst_curr_finalize ( struct ab8500_fg di,
int res 
)

ab8500_fg_inst_curr_finalize() - battery instantaneous current : pointer to the ab8500_fg structure : battery instantenous current(on success)

Returns 0 or an error code Note: This is part "two" and has to be called at earliest 250 ms after ab8500_fg_inst_curr_start()

Definition at line 591 of file ab8500_fg.c.

int ab8500_fg_inst_curr_start ( struct ab8500_fg di)

ab8500_fg_inst_curr_start() - start battery instantaneous current : pointer to the ab8500_fg structure

Returns 0 or error code Note: This is part "one" and has to be called before ab8500_fg_inst_curr_finalize()

Definition at line 527 of file ab8500_fg.c.

void ab8500_fg_reinit ( void  )

ab8500_fg_reinit() - forces FG algorithm to reinitialize with current values

This function can be used to force the FG algorithm to recalculate a new voltage based battery capacity.

Definition at line 2229 of file ab8500_fg.c.

MODULE_ALIAS ( "platform:ab8500-fg"  )
MODULE_AUTHOR ( "Johan  Palsson,
Karl Komierowski"   
)
MODULE_DESCRIPTION ( "AB8500 Fuel Gauge driver )
module_exit ( ab8500_fg_exit  )
MODULE_LICENSE ( "GPL v2 )
subsys_initcall_sync ( ab8500_fg_init  )