mediatek: power: shutdown when > 60 degree c

Problem: battery temperature over 60 degree could not shut down device
immediately but cause reboot.
Bug ID: 18364809
Solution: set a hard limit = 60 c

Change-Id: If315ec32fcc174266dbb9e80fb87c02c7694d57f
Signed-off-by: Cylen Yao <cylen.yao@mediatek.com>
diff --git a/drivers/misc/mediatek/power/mt6582/charging_hw_6333.c b/drivers/misc/mediatek/power/mt6582/charging_hw_6333.c
index d60dae3..7915659 100644
--- a/drivers/misc/mediatek/power/mt6582/charging_hw_6333.c
+++ b/drivers/misc/mediatek/power/mt6582/charging_hw_6333.c
@@ -25,6 +25,7 @@
 #include <mach/system.h>
 #include <cust_charging.h>
 #include <mach/charging_hw_common.h>
+#include <mach/battery_ssb.h>
 
 // ============================================================ //
 //define
@@ -103,10 +104,10 @@
     }
     battery_xlog_printk(BAT_LOG_CRTI, "polling_time=%d of rgs_power_on_ready\n", polling_time);
 
-#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
-    mt6333_set_rg_cv_sel(0);
-    battery_xlog_printk(BAT_LOG_CRTI, "HIGH_BATTERY_VOLTAGE_SUPPORT\n");
-#endif
+    if (high_battery_volt_enable) {
+        mt6333_set_rg_cv_sel(0);
+        battery_xlog_printk(BAT_LOG_CRTI, "HIGH_BATTERY_VOLTAGE_SUPPORT\n");
+    }
 
     return status;
 }
@@ -324,5 +325,6 @@
     ,charging_get_is_pcm_timer_trigger
     ,charging_set_platform_reset
     ,charging_get_platfrom_boot_mode
+    ,charging_set_power_off
 };
 
diff --git a/drivers/misc/mediatek/power/mt6582/charging_hw_bq24158.c b/drivers/misc/mediatek/power/mt6582/charging_hw_bq24158.c
index 57386f2..a33145d 100644
--- a/drivers/misc/mediatek/power/mt6582/charging_hw_bq24158.c
+++ b/drivers/misc/mediatek/power/mt6582/charging_hw_bq24158.c
@@ -54,6 +54,7 @@
 #include <mach/system.h>
 #include <cust_charging.h>
 #include <mach/charging_hw_common.h>
+#include <mach/battery_ssb.h>
 
  // ============================================================ //
  //global variable
@@ -107,10 +108,10 @@
  // ============================================================ //
  //extern function
  // ============================================================ //
- extern bool mt_usb_is_device(void);
+extern bool mt_usb_is_device(void);
 
- static kal_uint32 charging_hw_init_bq24158(void *data)
- {
+static kal_uint32 charging_hw_init_bq24158(void *data)
+{
 	kal_uint32 status = STATUS_OK;
 	static bool charging_init_flag = KAL_FALSE;
 	int gpio_number;
@@ -122,33 +123,36 @@
 	gpio_on_mode = GPIO_SWCHARGER_EN_PIN_M_GPIO;
 
 	mt_set_gpio_mode(gpio_number,gpio_on_mode);
-    mt_set_gpio_dir(gpio_number,gpio_on_dir);
-    mt_set_gpio_out(gpio_number,gpio_on_out);
+	mt_set_gpio_dir(gpio_number,gpio_on_dir);
+	mt_set_gpio_out(gpio_number,gpio_on_out);
 #if defined(MTK_WIRELESS_CHARGER_SUPPORT)
 	mt_set_gpio_mode(wireless_charger_gpio_number,0); // 0:GPIO mode
 	mt_set_gpio_dir(wireless_charger_gpio_number,0); // 0: input, 1: output
 #endif
-    battery_xlog_printk(BAT_LOG_FULL, "gpio_number=0x%x,gpio_on_mode=%d,gpio_off_mode=%d\n", gpio_number, gpio_on_mode, gpio_off_mode);
+	battery_xlog_printk(BAT_LOG_FULL, "gpio_number=0x%x,gpio_on_mode=%d,gpio_off_mode=%d\n", gpio_number, gpio_on_mode, gpio_off_mode);
 
 	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode
 
-	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
-        bq24158_config_interface_liao(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
-    #else
-        bq24158_config_interface_liao(0x06,0x70);
-	#endif
+	if (high_battery_volt_enable) {
+		battery_xlog_printk(BAT_LOG_CRTI, "1 high_battery_volt_enable=%d\n", high_battery_volt_enable);
+		bq24158_config_interface_liao(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
+		bq24158_config_interface_liao(0x02,0xaa); // 4.34
+	} else {
+		battery_xlog_printk(BAT_LOG_CRTI, "2 high_battery_volt_enable=%d\n", high_battery_volt_enable);
+		bq24158_config_interface_liao(0x06,0x70);
+		bq24158_config_interface_liao(0x02,0x8e); // 4.2
+	}
+	bq24158_config_interface_liao(0x00,0xC0);	//kick chip watch dog
+	bq24158_config_interface_liao(0x01,0xb8);	//TE=1, CE=0, HZ_MODE=0, OPA_MODE=0
+	bq24158_config_interface_liao(0x05,0x02);
 
-    bq24158_config_interface_liao(0x00,0xC0);	//kick chip watch dog
-    bq24158_config_interface_liao(0x01,0xb8);	//TE=1, CE=0, HZ_MODE=0, OPA_MODE=0
-    bq24158_config_interface_liao(0x05,0x03);
-
-    bq24158_config_interface_liao(0x04,0x1A); //146mA
+	bq24158_config_interface_liao(0x04,0x1A); //146mA
 	if ( !charging_init_flag ) {
 		bq24158_config_interface_liao(0x04,0x1A); //146mA
 		charging_init_flag = KAL_TRUE;
 	}
 	return status;
- }
+}
 
 
 static kal_uint32 charging_dump_register_bq24158(void *data)
@@ -351,6 +355,7 @@
 	,charging_get_is_pcm_timer_trigger
 	,charging_set_platform_reset
 	,charging_get_platfrom_boot_mode
+	,charging_set_power_off
 };
 
 
diff --git a/drivers/misc/mediatek/power/mt6582/charging_hw_bq24196.c b/drivers/misc/mediatek/power/mt6582/charging_hw_bq24196.c
index 179792f..667bf31 100644
--- a/drivers/misc/mediatek/power/mt6582/charging_hw_bq24196.c
+++ b/drivers/misc/mediatek/power/mt6582/charging_hw_bq24196.c
@@ -346,5 +346,6 @@
 	,charging_get_is_pcm_timer_trigger
 	,charging_set_platform_reset
 	,charging_get_platfrom_boot_mode
+	,charging_set_power_off
 };
 
diff --git a/drivers/misc/mediatek/power/mt6582/charging_hw_fan5405.c b/drivers/misc/mediatek/power/mt6582/charging_hw_fan5405.c
index 79b7447..361cc28 100644
--- a/drivers/misc/mediatek/power/mt6582/charging_hw_fan5405.c
+++ b/drivers/misc/mediatek/power/mt6582/charging_hw_fan5405.c
@@ -54,6 +54,7 @@
 #include <mach/system.h>
 #include <cust_charging.h>
 #include <mach/charging_hw_common.h>
+#include <mach/battery_ssb.h>
 
  // ============================================================ //
  //define
@@ -137,11 +138,11 @@
 	upmu_set_rg_usbdl_set(0);       //force leave USBDL mode
 	upmu_set_rg_usbdl_rst(1);		//force leave USBDL mode
 
-	#if defined(HIGH_BATTERY_VOLTAGE_SUPPORT)
-	fan5405_reg_config_interface(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
-	#else
-	fan5405_reg_config_interface(0x06,0x70);
-	#endif
+	if (high_battery_volt_enable) {
+		fan5405_reg_config_interface(0x06,0x77); // ISAFE = 1250mA, VSAFE = 4.34V
+	} else {
+		fan5405_reg_config_interface(0x06,0x70);
+	}
 
 	fan5405_reg_config_interface(0x00,0xC0);	//kick chip watch dog
 	fan5405_reg_config_interface(0x01,0xb8);	//TE=1, CE=0, HZ_MODE=0, OPA_MODE=0
diff --git a/drivers/power/mediatek/battery_common.c b/drivers/power/mediatek/battery_common.c
index 4ea2bc4..5fa83d5 100644
--- a/drivers/power/mediatek/battery_common.c
+++ b/drivers/power/mediatek/battery_common.c
@@ -2334,8 +2334,7 @@
 					    BMT_status.temperature);
 		}
 
-		/* for Sporout MMX special request (shutdown temperature > 60 degree)*/
-		if(BMT_status.temperature >= thermal_shut_down) {
+		if(BMT_status.temperature >= 60) {
 #if defined(CONFIG_POWER_EXT)
 			battery_xlog_printk(BAT_LOG_CRTI,
 					    "[BATTERY] CONFIG_POWER_EXT, no update battery update power down.\n");