[PORT FROM R2] mrst: Added logic for battery detection in mx17042 platform specific...
authorRamakrishna Pallala <ramakrishna.pallala@intel.com>
Thu, 22 Dec 2011 10:12:51 +0000 (15:42 +0530)
committerbuildbot <buildbot@intel.com>
Tue, 24 Jan 2012 15:21:50 +0000 (07:21 -0800)
BZ: 14245

This patch adds the logic to detect the valid or invalid battery
based on sfi oem0 table population.

R2-Change-Id: I60cc596296a9412e595a6978e0e0f70cab667a5a
Orig-Change-Id: I53b5b82deb9b99641f8db41efccab933f51b28f8
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Conflicts:

arch/x86/kernel/mrst.c

Change-Id: I542548fa37847ece21f079e1a8e26dbc6be74f05
Signed-off-by: Eduardo Mendi <eduardox.mendi@intel.com>
Reviewed-on: http://android.intel.com:8080/32749
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/mrst/mrst.c

index 2894c6c..de5d59b 100644 (file)
@@ -99,6 +99,8 @@ EXPORT_SYMBOL_GPL(__mrst_cpu_chip);
 
 int sfi_mtimer_num;
 
+static bool is_valid_batt;
+
 struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
 int sfi_mrtc_num;
@@ -1005,6 +1007,20 @@ void max17042_i2c_reset_workaround(void)
 }
 EXPORT_SYMBOL(max17042_i2c_reset_workaround);
 
+static int __init msic_battery_check(struct sfi_table_header *table)
+{
+
+       if (!table) {
+       pr_info("invalid battery detected\n");
+       is_valid_batt = false;
+       return -ENODEV;
+       } else {
+       pr_info("valid battery detected\n");
+       is_valid_batt = true;
+       return 0;
+      }
+}
+
 static void *max17042_platform_data(void *info)
 {
        static struct max17042_platform_data platform_data;
@@ -1012,10 +1028,14 @@ static void *max17042_platform_data(void *info)
        int intr = get_gpio_by_name("max17042");
 
        i2c_info->irq = intr + MRST_IRQ_OFFSET;
-
-       platform_data.enable_current_sense = 0;
+       if (is_valid_batt) {
+               platform_data.enable_current_sense = true;
+               platform_data.technology = POWER_SUPPLY_TECHNOLOGY_LION;
+       } else {
+               platform_data.enable_current_sense = false;
+               platform_data.technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
+       }
        platform_data.is_init_done = 0;
-       platform_data.technology = POWER_SUPPLY_TECHNOLOGY_LION;
 
        platform_data.reset_i2c_lines = max17042_i2c_reset_workaround;
 
@@ -2244,6 +2264,11 @@ static int __init mrst_platform_init(void)
 
        /* Get MFD Validation SFI OEMB Layout */
        sfi_table_parse(SFI_SIG_OEMB, NULL, NULL, sfi_parse_oemb);
+       /* Battery Check */
+       if (sfi_table_parse("OEM0", NULL, NULL, msic_battery_check)) {
+       pr_err("Invalid Battery: SFI OEM0 table not found\n");
+       is_valid_batt = false;
+       }
        sfi_table_parse(SFI_SIG_GPIO, NULL, NULL, sfi_parse_gpio);
        sfi_table_parse(SFI_SIG_DEVS, NULL, NULL, sfi_parse_devs);
        return 0;