static void *platform_get_batt_charge_profile(void)
{
#ifdef CONFIG_BTNS_PMIC
	int retval = 0;
	retval = get_batt_prop(&ps_batt_chrg_prof);
	if (retval) {
		pr_err("Error reading battery profile from battid framework. Use hard coded value.\n");
		memcpy(&batt_chg_profile, &atl_820_batt, sizeof(struct ps_pse_mod_prof));
		ps_batt_chrg_prof.batt_prof = &batt_chg_profile;
		ps_batt_chrg_prof.chrg_prof_type = PSE_MOD_CHRG_PROF;
	}
#if defined(CONFIG_POWER_SUPPLY_CHARGING_ALGO_STEP) && defined(CONFIG_POWER_SUPPLY_BATTID)
	ps_batt_chrg_prof.chrg_prof_type = STEP_MOD_CHRG_PROF;
#endif
#else
	if (!em_config_get_charge_profile(&batt_chg_profile))
		ps_batt_chrg_prof.chrg_prof_type = CHRG_PROF_NONE;
	else
		ps_batt_chrg_prof.chrg_prof_type = PSE_MOD_CHRG_PROF;

	ps_batt_chrg_prof.batt_prof = &batt_chg_profile;
#endif
	battery_prop_changed(POWER_SUPPLY_BATTERY_INSERTED, &ps_batt_chrg_prof);
	return &ps_batt_chrg_prof;
}
static void *platform_get_batt_charge_profile(void)
{
	if (!em_config_get_charge_profile(&batt_chg_profile))
		ps_batt_chrg_prof.chrg_prof_type = CHRG_PROF_NONE;
	else
		ps_batt_chrg_prof.chrg_prof_type = PSE_MOD_CHRG_PROF;

	ps_batt_chrg_prof.batt_prof = &batt_chg_profile;
	battery_prop_changed(POWER_SUPPLY_BATTERY_INSERTED, &ps_batt_chrg_prof);
	return &ps_batt_chrg_prof;
}
static void *platform_byt_get_batt_charge_profile(void)
{
	struct ps_temp_chg_table temp_mon_range[BATT_TEMP_NR_RNG];

	char batt_str[] = "INTN0001";

	/*
	 * WA: hard coding the profile
	 * till we get OEM0 table from FW.
	 */
	memcpy(byt_batt_chg_profile.batt_id, batt_str, strlen(batt_str));

	byt_batt_chg_profile.battery_type = 0x2;
	byt_batt_chg_profile.capacity = 0x2C52;
	byt_batt_chg_profile.voltage_max = 4350;
	byt_batt_chg_profile.chrg_term_ma = 300;
	byt_batt_chg_profile.low_batt_mV = 3400;
	byt_batt_chg_profile.disch_tmp_ul = 55;
	byt_batt_chg_profile.disch_tmp_ll = 0;
	byt_batt_chg_profile.temp_mon_ranges = 5;

	temp_mon_range[0].temp_up_lim = 55;
	temp_mon_range[0].full_chrg_vol = 4100;
	temp_mon_range[0].full_chrg_cur = 1800;
	temp_mon_range[0].maint_chrg_vol_ll = 4050;
	temp_mon_range[0].maint_chrg_vol_ul = 4100;
	temp_mon_range[0].maint_chrg_cur = 1800;

	temp_mon_range[1].temp_up_lim = 45;
	temp_mon_range[1].full_chrg_vol = 4350;
	temp_mon_range[1].full_chrg_cur = 1800;
	temp_mon_range[1].maint_chrg_vol_ll = 4300;
	temp_mon_range[1].maint_chrg_vol_ul = 4350;
	temp_mon_range[1].maint_chrg_cur = 1800;

	temp_mon_range[2].temp_up_lim = 23;
	temp_mon_range[2].full_chrg_vol = 4350;
	temp_mon_range[2].full_chrg_cur = 1400;
	temp_mon_range[2].maint_chrg_vol_ll = 4300;
	temp_mon_range[2].maint_chrg_vol_ul = 4350;
	temp_mon_range[2].maint_chrg_cur = 1400;

	temp_mon_range[3].temp_up_lim = 10;
	temp_mon_range[3].full_chrg_vol = 4350;
	temp_mon_range[3].full_chrg_cur = 1000;
	temp_mon_range[3].maint_chrg_vol_ll = 4300;
	temp_mon_range[3].maint_chrg_vol_ul = 4350;
	temp_mon_range[3].maint_chrg_cur = 1000;

	temp_mon_range[4].temp_up_lim = 0;
	temp_mon_range[4].full_chrg_vol = 0;
	temp_mon_range[4].full_chrg_cur = 0;
	temp_mon_range[4].maint_chrg_vol_ll = 0;
	temp_mon_range[4].maint_chrg_vol_ul = 0;
	temp_mon_range[4].maint_chrg_vol_ul = 0;
	temp_mon_range[4].maint_chrg_cur = 0;

	memcpy(byt_batt_chg_profile.temp_mon_range,
		temp_mon_range,
		BATT_TEMP_NR_RNG * sizeof(struct ps_temp_chg_table));

	byt_batt_chg_profile.temp_low_lim = 0;

	byt_ps_batt_chrg_prof.chrg_prof_type = PSE_MOD_CHRG_PROF;
	byt_ps_batt_chrg_prof.batt_prof = &byt_batt_chg_profile;
	battery_prop_changed(POWER_SUPPLY_BATTERY_INSERTED,
					&byt_ps_batt_chrg_prof);
	return &byt_ps_batt_chrg_prof;
}
static void platform_get_sfi_batt_table(void *table, bool fpo_override_bit)
{
	struct sfi_table_simple *sb =
			 (struct sfi_table_simple *)get_oem0_table();
	struct platform_batt_profile *batt_prof;
	u8 *bprof_ptr;

	int num_entries, i;

	pr_debug("%s\n", __func__);

	if (sb == NULL) {
		pr_debug("Invalid Battery detected\n");
		return;
	}

	/* Allocate the memory for sharing battery profile */
	ps_pse_mod_prof = kzalloc(
				sizeof(*ps_pse_mod_prof),
				GFP_KERNEL);
	if (!ps_pse_mod_prof) {
		pr_debug("%s: Error in kzalloc\n", __func__);
		kfree(ps_pse_mod_prof);
		ps_pse_mod_prof = NULL;
		return;
	}

	ps_batt_chrg_prof = kzalloc(
				sizeof(*ps_batt_chrg_prof),
				GFP_KERNEL);
	if (!ps_batt_chrg_prof) {
		pr_debug("%s: Error in kzalloc\n", __func__);
		kfree(ps_batt_chrg_prof);
		kfree(ps_pse_mod_prof);
		ps_batt_chrg_prof = NULL;
		ps_pse_mod_prof = NULL;
		return;
	}

	bprof_ptr = (u8 *)sb->pentry;
	memcpy(ps_pse_mod_prof->batt_id, bprof_ptr, BATTID_STR_LEN);

	bprof_ptr += BATTID_STR_LEN;
	ps_pse_mod_prof->voltage_max = *(u16 *)bprof_ptr;
	bprof_ptr += 2;

	if (fpo_override_bit) {
		pr_info("OVERRIDE. Read battery profile from SMIP\n");
		ps_pse_mod_prof->capacity = *(u32 *)(bprof_ptr);
		bprof_ptr += 4;
	} else if (INTEL_MID_BOARD(3, PHONE, CLVTP, VB, PRO, PR1B)) {
		pr_info("PR1 Battery detected\n");
		ps_pse_mod_prof->capacity = *(u16 *)(bprof_ptr);
		bprof_ptr += 2;
	} else {
		pr_info("PR2 Battery detected\n");
		ps_pse_mod_prof->capacity = *(u32 *)(bprof_ptr);
		bprof_ptr += 4;
	}

	ps_pse_mod_prof->battery_type = *bprof_ptr;
	ps_pse_mod_prof->temp_mon_ranges = *++bprof_ptr;
	ps_pse_mod_prof->chrg_term_ma = 128;
	ps_pse_mod_prof->low_batt_mV = 3400;
	ps_pse_mod_prof->disch_tmp_ul = 60;
	ps_pse_mod_prof->disch_tmp_ll = 0;

	num_entries = SFI_GET_NUM_ENTRIES(sb, struct platform_batt_profile);
	batt_prof = (struct platform_batt_profile *)table;

	pr_info("num_entries = %d\n", num_entries);

	if (num_entries) {
		/* Fill the local structure for back up*/
		memcpy(batt_prof->batt_id,
				ps_pse_mod_prof->batt_id, BATTID_STR_LEN);
		batt_prof->voltage_max = ps_pse_mod_prof->voltage_max;
		batt_prof->capacity = ps_pse_mod_prof->capacity;
		batt_prof->battery_type = ps_pse_mod_prof->battery_type;
		batt_prof->temp_mon_ranges = ps_pse_mod_prof->temp_mon_ranges;
		memcpy(batt_prof->temp_mon_range, bprof_ptr+1,
			TEMP_NR_RNG * sizeof(struct platform_temp_mon_table));
	} else {
		batt_prof->temp_mon_ranges = 0;
		memcpy((void *)batt_prof->batt_id,
			(void *)"UNKNOWN", 8);
	}


	for (i = 0; i < batt_prof->temp_mon_ranges; i++) {
		ps_pse_mod_prof->temp_mon_range[i].temp_up_lim =
			batt_prof->temp_mon_range[i].temp_up_lim;
		ps_pse_mod_prof->temp_mon_range[i].full_chrg_vol =
			batt_prof->temp_mon_range[i].full_chrg_vol;
		ps_pse_mod_prof->temp_mon_range[i].full_chrg_cur =
			batt_prof->temp_mon_range[i].full_chrg_cur;
		ps_pse_mod_prof->temp_mon_range[i].maint_chrg_vol_ll =
			batt_prof->temp_mon_range[i].maint_chrg_vol_ll;
		ps_pse_mod_prof->temp_mon_range[i].maint_chrg_vol_ul =
			batt_prof->temp_mon_range[i].maint_chrg_vol_ul;
		ps_pse_mod_prof->temp_mon_range[i].maint_chrg_cur =
			batt_prof->temp_mon_range[i].maint_chrg_cur;
	}

	/* Change need in SMIP since temp zone 4 has all 0's */
	ps_pse_mod_prof->temp_mon_range[0].temp_up_lim = 60;

	ps_batt_chrg_prof->chrg_prof_type = PSE_MOD_CHRG_PROF;
	ps_batt_chrg_prof->batt_prof = ps_pse_mod_prof;

	/* Dump the battery charging profile*/
	dump_batt_chrg_profile(ps_pse_mod_prof, batt_prof);

#ifdef CONFIG_POWER_SUPPLY_BATTID
	battery_prop_changed(POWER_SUPPLY_BATTERY_INSERTED,
				ps_batt_chrg_prof);
#endif

}