root/include/linux/power/max17042_battery.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: GPL-2.0-or-later */
   2 /*
   3  * Fuel gauge driver for Maxim 17042 / 8966 / 8997
   4  *  Note that Maxim 8966 and 8997 are mfd and this is its subdevice.
   5  *
   6  * Copyright (C) 2011 Samsung Electronics
   7  * MyungJoo Ham <myungjoo.ham@samsung.com>
   8  */
   9 
  10 #ifndef __MAX17042_BATTERY_H_
  11 #define __MAX17042_BATTERY_H_
  12 
  13 #define MAX17042_STATUS_BattAbsent      (1 << 3)
  14 #define MAX17042_BATTERY_FULL           (95)   /* Recommend. FullSOCThr value */
  15 #define MAX17042_DEFAULT_SNS_RESISTOR   (10000)
  16 #define MAX17042_DEFAULT_VMIN           (3000)
  17 #define MAX17042_DEFAULT_VMAX           (4500) /* LiHV cell max */
  18 #define MAX17042_DEFAULT_TEMP_MIN       (0)    /* For sys without temp sensor */
  19 #define MAX17042_DEFAULT_TEMP_MAX       (700)  /* 70 degrees Celcius */
  20 
  21 /* Consider RepCap which is less then 10 units below FullCAP full */
  22 #define MAX17042_FULL_THRESHOLD         10
  23 
  24 #define MAX17042_CHARACTERIZATION_DATA_SIZE 48
  25 
  26 enum max17042_register {
  27         MAX17042_STATUS         = 0x00,
  28         MAX17042_VALRT_Th       = 0x01,
  29         MAX17042_TALRT_Th       = 0x02,
  30         MAX17042_SALRT_Th       = 0x03,
  31         MAX17042_AtRate         = 0x04,
  32         MAX17042_RepCap         = 0x05,
  33         MAX17042_RepSOC         = 0x06,
  34         MAX17042_Age            = 0x07,
  35         MAX17042_TEMP           = 0x08,
  36         MAX17042_VCELL          = 0x09,
  37         MAX17042_Current        = 0x0A,
  38         MAX17042_AvgCurrent     = 0x0B,
  39 
  40         MAX17042_SOC            = 0x0D,
  41         MAX17042_AvSOC          = 0x0E,
  42         MAX17042_RemCap         = 0x0F,
  43         MAX17042_FullCAP        = 0x10,
  44         MAX17042_TTE            = 0x11,
  45         MAX17042_V_empty        = 0x12,
  46 
  47         MAX17042_RSLOW          = 0x14,
  48 
  49         MAX17042_AvgTA          = 0x16,
  50         MAX17042_Cycles         = 0x17,
  51         MAX17042_DesignCap      = 0x18,
  52         MAX17042_AvgVCELL       = 0x19,
  53         MAX17042_MinMaxTemp     = 0x1A,
  54         MAX17042_MinMaxVolt     = 0x1B,
  55         MAX17042_MinMaxCurr     = 0x1C,
  56         MAX17042_CONFIG         = 0x1D,
  57         MAX17042_ICHGTerm       = 0x1E,
  58         MAX17042_AvCap          = 0x1F,
  59         MAX17042_ManName        = 0x20,
  60         MAX17042_DevName        = 0x21,
  61 
  62         MAX17042_FullCAPNom     = 0x23,
  63         MAX17042_TempNom        = 0x24,
  64         MAX17042_TempLim        = 0x25,
  65         MAX17042_TempHot        = 0x26,
  66         MAX17042_AIN            = 0x27,
  67         MAX17042_LearnCFG       = 0x28,
  68         MAX17042_FilterCFG      = 0x29,
  69         MAX17042_RelaxCFG       = 0x2A,
  70         MAX17042_MiscCFG        = 0x2B,
  71         MAX17042_TGAIN          = 0x2C,
  72         MAx17042_TOFF           = 0x2D,
  73         MAX17042_CGAIN          = 0x2E,
  74         MAX17042_COFF           = 0x2F,
  75 
  76         MAX17042_MaskSOC        = 0x32,
  77         MAX17042_SOC_empty      = 0x33,
  78         MAX17042_T_empty        = 0x34,
  79 
  80         MAX17042_FullCAP0       = 0x35,
  81         MAX17042_LAvg_empty     = 0x36,
  82         MAX17042_FCTC           = 0x37,
  83         MAX17042_RCOMP0         = 0x38,
  84         MAX17042_TempCo         = 0x39,
  85         MAX17042_EmptyTempCo    = 0x3A,
  86         MAX17042_K_empty0       = 0x3B,
  87         MAX17042_TaskPeriod     = 0x3C,
  88         MAX17042_FSTAT          = 0x3D,
  89 
  90         MAX17042_SHDNTIMER      = 0x3F,
  91 
  92         MAX17042_dQacc          = 0x45,
  93         MAX17042_dPacc          = 0x46,
  94 
  95         MAX17042_VFSOC0         = 0x48,
  96 
  97         MAX17042_QH             = 0x4D,
  98         MAX17042_QL             = 0x4E,
  99 
 100         MAX17042_VFSOC0Enable   = 0x60,
 101         MAX17042_MLOCKReg1      = 0x62,
 102         MAX17042_MLOCKReg2      = 0x63,
 103 
 104         MAX17042_MODELChrTbl    = 0x80,
 105 
 106         MAX17042_OCV            = 0xEE,
 107 
 108         MAX17042_OCVInternal    = 0xFB,
 109 
 110         MAX17042_VFSOC          = 0xFF,
 111 };
 112 
 113 /* Registers specific to max17047/50 */
 114 enum max17047_register {
 115         MAX17047_QRTbl00        = 0x12,
 116         MAX17047_FullSOCThr     = 0x13,
 117         MAX17047_QRTbl10        = 0x22,
 118         MAX17047_QRTbl20        = 0x32,
 119         MAX17047_V_empty        = 0x3A,
 120         MAX17047_QRTbl30        = 0x42,
 121 };
 122 
 123 enum max170xx_chip_type {
 124         MAXIM_DEVICE_TYPE_UNKNOWN       = 0,
 125         MAXIM_DEVICE_TYPE_MAX17042,
 126         MAXIM_DEVICE_TYPE_MAX17047,
 127         MAXIM_DEVICE_TYPE_MAX17050,
 128 
 129         MAXIM_DEVICE_TYPE_NUM
 130 };
 131 
 132 /*
 133  * used for setting a register to a desired value
 134  * addr : address for a register
 135  * data : setting value for the register
 136  */
 137 struct max17042_reg_data {
 138         u8 addr;
 139         u16 data;
 140 };
 141 
 142 struct max17042_config_data {
 143         /* External current sense resistor value in milli-ohms */
 144         u32     cur_sense_val;
 145 
 146         /* A/D measurement */
 147         u16     tgain;          /* 0x2C */
 148         u16     toff;           /* 0x2D */
 149         u16     cgain;          /* 0x2E */
 150         u16     coff;           /* 0x2F */
 151 
 152         /* Alert / Status */
 153         u16     valrt_thresh;   /* 0x01 */
 154         u16     talrt_thresh;   /* 0x02 */
 155         u16     soc_alrt_thresh;        /* 0x03 */
 156         u16     config;         /* 0x01D */
 157         u16     shdntimer;      /* 0x03F */
 158 
 159         /* App data */
 160         u16     full_soc_thresh;        /* 0x13 */
 161         u16     design_cap;     /* 0x18 */
 162         u16     ichgt_term;     /* 0x1E */
 163 
 164         /* MG3 config */
 165         u16     at_rate;        /* 0x04 */
 166         u16     learn_cfg;      /* 0x28 */
 167         u16     filter_cfg;     /* 0x29 */
 168         u16     relax_cfg;      /* 0x2A */
 169         u16     misc_cfg;       /* 0x2B */
 170         u16     masksoc;        /* 0x32 */
 171 
 172         /* MG3 save and restore */
 173         u16     fullcap;        /* 0x10 */
 174         u16     fullcapnom;     /* 0x23 */
 175         u16     socempty;       /* 0x33 */
 176         u16     lavg_empty;     /* 0x36 */
 177         u16     dqacc;          /* 0x45 */
 178         u16     dpacc;          /* 0x46 */
 179         u16     qrtbl00;        /* 0x12 */
 180         u16     qrtbl10;        /* 0x22 */
 181         u16     qrtbl20;        /* 0x32 */
 182         u16     qrtbl30;        /* 0x42 */
 183 
 184         /* Cell technology from power_supply.h */
 185         u16     cell_technology;
 186 
 187         /* Cell Data */
 188         u16     vempty;         /* 0x12 */
 189         u16     temp_nom;       /* 0x24 */
 190         u16     temp_lim;       /* 0x25 */
 191         u16     fctc;           /* 0x37 */
 192         u16     rcomp0;         /* 0x38 */
 193         u16     tcompc0;        /* 0x39 */
 194         u16     empty_tempco;   /* 0x3A */
 195         u16     kempty0;        /* 0x3B */
 196         u16     cell_char_tbl[MAX17042_CHARACTERIZATION_DATA_SIZE];
 197 } __packed;
 198 
 199 struct max17042_platform_data {
 200         struct max17042_reg_data *init_data;
 201         struct max17042_config_data *config_data;
 202         int num_init_data; /* Number of enties in init_data array */
 203         bool enable_current_sense;
 204         bool enable_por_init; /* Use POR init from Maxim appnote */
 205 
 206         /*
 207          * R_sns in micro-ohms.
 208          * default 10000 (if r_sns = 0) as it is the recommended value by
 209          * the datasheet although it can be changed by board designers.
 210          */
 211         unsigned int r_sns;
 212         int         vmin;       /* in millivolts */
 213         int         vmax;       /* in millivolts */
 214         int         temp_min;   /* in tenths of degree Celsius */
 215         int         temp_max;   /* in tenths of degree Celsius */
 216 };
 217 
 218 #endif /* __MAX17042_BATTERY_H_ */

/* [<][>][^][v][top][bottom][index][help] */