board-redridge: add support to read fuel gauge data from umip
authorRamakrishna Pallala <ramakrishna.pallala@intel.com>
Tue, 10 Apr 2012 09:42:49 +0000 (15:12 +0530)
committerbuildbot <buildbot@intel.com>
Fri, 13 Apr 2012 15:45:16 +0000 (08:45 -0700)
BZ: 30840

This patch removes the WA to initialize the fuel gauge data and
adds the support to read this data from UMIP.

Change-Id: I5784b9442b8232a1db3a2166f64b2d50f5e6bd64
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Reviewed-on: http://android.intel.com:8080/42978
Reviewed-by: Tc, Jenny <jenny.tc@intel.com>
Reviewed-by: Hari, NeelamX <neelamx.hari@intel.com>
Reviewed-by: Lebouc, Christophe <christophe.lebouc@intel.com>
Tested-by: Lebouc, Christophe <christophe.lebouc@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/intel-mid/board-redridge.c
drivers/power/max17042_battery.c

index 5813e20..f94a5ab 100644 (file)
@@ -670,53 +670,45 @@ static bool msic_battery_check(void)
        return false;
 }
 
-static uint16_t cell_char_tbl[] = {
-       /* Data to be written from 0x80h */
-       0xABB0, 0xB2B0, 0xBB10, 0xBBB0, 0xBC10, 0xBC70, 0xBD00, 0xBD70,
-       0xBDC0, 0xBE10, 0xC010, 0xC130, 0xC4A0, 0xC9C0, 0xCD10, 0xD090,
-
-       /* Data to be written from 0x90h */
-       0x0620, 0x0420, 0x1900, 0x3600, 0x3DA0, 0x2CA0, 0x3C20, 0x3500,
-       0x3500, 0x0440, 0x1240, 0x0DF0, 0x08F0, 0x0870, 0x07F0, 0x07F0,
-
-       /* Data to be written from 0xA0h */
-       0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
-       0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
-};
+#define UMIP_REF_FG_TBL                        0x806   /* 2 bytes */
+#define BATT_FG_TBL_BODY               14      /* 144 bytes */
+/**
+ * mfld_fg_restore_config_data - restore config data
+ * @name : Power Supply name
+ * @data : config data output pointer
+ * @len : length of config data
+ *
+ */
+int mfld_fg_restore_config_data(const char *name, void *data, int len)
+{
+       int mip_offset, ret;
 
-/* WA function until UMIP support is provided for FG data */
-static int init_max170xx_fg_config_data(const char *name, void *data, int len)
-{
-       struct max17042_config_data *fg_conf_data =
-                               (struct max17042_config_data *)data;
-
-       fg_conf_data->size = 0x9e;
-       fg_conf_data->table_type = MAX17042_TBL_TYPE_DV10;
-       fg_conf_data->cfg = 0x2210;
-       fg_conf_data->learn_cfg = 0x0006;
-       fg_conf_data->filter_cfg = 0x87A4;
-       fg_conf_data->relax_cfg = 0x506B;
-       memcpy(&fg_conf_data->cell_char_tbl, cell_char_tbl,
-                                       sizeof(cell_char_tbl));
-       fg_conf_data->rcomp0 = 0x0092;
-       fg_conf_data->tempCo = 0x081D;
-       fg_conf_data->etc = 0x0B19;
-       fg_conf_data->kempty0 = 0x0D83;
-       fg_conf_data->ichgt_term = 0x0300;
-       fg_conf_data->soc_empty = 0x0001;
-       fg_conf_data->cycles = 0x00A0;
-       fg_conf_data->full_cap = 0x3988;
-       fg_conf_data->design_cap = 0x3988;
-       fg_conf_data->full_capnom = 0x3988;
-       fg_conf_data->rsense = 1;
+       /* Read the fuel gauge config data from umip */
+       mip_offset = UMIP_REF_FG_TBL + BATT_FG_TBL_BODY;
+       ret = intel_scu_ipc_read_mip((u8 *)data, len, mip_offset, 0);
 
-       return 0;
+       return ret;
 }
+EXPORT_SYMBOL(mfld_fg_restore_config_data);
 
-static int save_max170xx_fg_config_data(const char *name, void *data, int len)
+/**
+ * mfld_fg_save_config_data - save config data
+ * @name : Power Supply name
+ * @data : config data input pointer
+ * @len : length of config data
+ *
+ */
+int mfld_fg_save_config_data(const char *name, void *data, int len)
 {
-       return 0;
+       int mip_offset, ret;
+
+       /* write the fuel gauge config data to umip */
+       mip_offset = UMIP_REF_FG_TBL + BATT_FG_TBL_BODY;
+       ret = intel_scu_ipc_write_umip((u8 *)data, len, mip_offset);
+
+       return ret;
 }
+EXPORT_SYMBOL(mfld_fg_save_config_data);
 
 static void *max17042_platform_data(void *info)
 {
@@ -738,8 +730,8 @@ static void *max17042_platform_data(void *info)
        platform_data.reset_i2c_lines = max17042_i2c_reset_workaround;
        platform_data.enable_current_sense = true;
        platform_data.technology = POWER_SUPPLY_TECHNOLOGY_LION;
-       platform_data.restore_config_data = init_max170xx_fg_config_data;
-       platform_data.save_config_data = save_max170xx_fg_config_data;
+       platform_data.restore_config_data = mfld_fg_restore_config_data;
+       platform_data.save_config_data = mfld_fg_save_config_data;
 
 #ifdef CONFIG_CHARGER_SMB347
        platform_data.battery_status = smb347_get_charging_status;
index f4416c7..acf83af 100644 (file)
@@ -1174,11 +1174,6 @@ static void max17042_restore_conf_data(struct max17042_chip *chip)
                                dev_info(&chip->client->dev,
                                        "config data needs to be loaded\n");
 
-                               /* WA: reset if table tyoe is dv10 */
-                               if (fg_conf_data->table_type ==
-                                                       MAX17042_TBL_TYPE_DV10)
-                                       reset_max17042(chip);
-
                                retval = init_max17042_chip(chip);
                                if (retval < 0) {
                                        dev_err(&chip->client->dev,