#include <asm/setup.h>
#include <asm/intel-mid.h>
#include <asm/processor.h>
+#include <linux/power/intel_mid_powersupply.h>
+#include <asm/intel_scu_ipc.h>
unsigned long __init intel_mid_calibrate_tsc(void)
{
return -EINVAL;
}
early_param("mrfld_simulation", set_simulation_platform);
+
+struct plat_battery_config *plat_batt_config;
+EXPORT_SYMBOL(plat_batt_config);
+
+static int __init get_plat_batt_config(void)
+{
+ int ret;
+ plat_batt_config = kzalloc(sizeof(struct plat_battery_config),
+ GFP_KERNEL);
+ if (!plat_batt_config) {
+ pr_err("%s : Error in allocating"
+ "plat_battery_config\n", __func__);
+ return -ENOMEM;
+ }
+ ret = intel_scu_ipc_read_mip((u8 *) plat_batt_config,
+ sizeof(struct plat_battery_config), BATT_SMIP_BASE_OFFSET, 1);
+ if (ret) {
+ pr_err("%s(): Error in reading platform battery"
+ " configuration\n", __func__);
+ kfree(plat_batt_config);
+ plat_batt_config = NULL;
+ }
+ return ret;
+}
+/* FIXME: SMIP access is failing. So disabling the SMIP read */
+/*rootfs_initcall(get_plat_batt_config); */
+
+struct batt_charging_profile *batt_chrg_profile;
+EXPORT_SYMBOL(batt_chrg_profile);
+
+static int __init sfi_parse_batt(struct sfi_table_header *table)
+{
+ struct sfi_table_simple *sb;
+ struct batt_charging_profile *pentry;
+ int totentrs = 0, totlen = 0;
+
+ sb = (struct sfi_table_simple *)table;
+ totentrs = SFI_GET_NUM_ENTRIES(sb, struct batt_charging_profile);
+ if (totentrs) {
+ batt_chrg_profile = kzalloc(
+ sizeof(struct batt_charging_profile), GFP_KERNEL);
+ if (!batt_chrg_profile) {
+ pr_info("%s(): Error in kzalloc\n", __func__);
+ return -ENOMEM;
+ }
+ pentry = (struct batt_charging_profile *)sb->pentry;
+ totlen = totentrs * sizeof(*pentry);
+ if (totlen <= sizeof(batt_chrg_profile))
+ memcpy(batt_chrg_profile, pentry, totlen);
+ else {
+ pr_err("%s: Error in copying batt charge profile\n");
+ kfree(batt_chrg_profile);
+ return -ENOMEM;
+ }
+ }
+ return 0;
+
+}
+
+static int __init mrfl_platform_init(void)
+{
+ sfi_table_parse(SFI_SIG_OEM0, NULL, NULL, sfi_parse_batt);
+ return 0;
+}
+arch_initcall(mrfl_platform_init);
#include <linux/wakelock.h>
#include <linux/async.h>
#include <linux/reboot.h>
+#include <linux/power/intel_mid_powersupply.h>
/*TODO remove this below header file once tangier_otg.h is available*/
#include <linux/usb/penwell_otg.h>
#include <asm/intel_basincove_gpadc.h>
chrgr_drv_cxt->chrgr_props_cxt.vbus_vol = 4200;
}
-static int get_charging_profile(struct charging_profile *chrg_profile)
-{
- /*
- * TODO: Get battery profile from platfrom layer. Using hardcoded sample
- * value till this is done.
- */
-
- memcpy(chrg_profile->batt_id, "UNKNOWN", sizeof("UNKNOWN"));
- chrg_profile->voltage_max = 4200;
- chrg_profile->capacity = 1500;
- chrg_profile->battery_type = 2; /* POWER_SUPPLY_TECHNOLOGY_LION */
- chrg_profile->temp_mon_ranges = 4;
-
- chrg_profile->temp_mon_range[0].temp_low_lim = 45;
- chrg_profile->temp_mon_range[0].temp_up_lim = 60;
- chrg_profile->temp_mon_range[0].rbatt = 120;
- chrg_profile->temp_mon_range[0].full_chrg_cur = 950;
- chrg_profile->temp_mon_range[0].full_chrg_vol = 4100;
- chrg_profile->temp_mon_range[0].maint_chrg_cur = 950;
- chrg_profile->temp_mon_range[0].maint_chrg_vol_ll = 4000;
- chrg_profile->temp_mon_range[0].maint_chrg_vol_ul = 4050;
-
- chrg_profile->temp_mon_range[1].temp_low_lim = 10;
- chrg_profile->temp_mon_range[1].temp_up_lim = 45;
- chrg_profile->temp_mon_range[1].rbatt = 120;
- chrg_profile->temp_mon_range[1].full_chrg_cur = 950;
- chrg_profile->temp_mon_range[1].full_chrg_vol = 4200;
- chrg_profile->temp_mon_range[1].maint_chrg_cur = 950;
- chrg_profile->temp_mon_range[1].maint_chrg_vol_ll = 4100;
- chrg_profile->temp_mon_range[1].maint_chrg_vol_ul = 4150;
-
- chrg_profile->temp_mon_range[2].temp_low_lim = 0;
- chrg_profile->temp_mon_range[2].temp_up_lim = 10;
- chrg_profile->temp_mon_range[2].rbatt = 120;
- chrg_profile->temp_mon_range[2].full_chrg_cur = 950;
- chrg_profile->temp_mon_range[2].full_chrg_vol = 4100;
- chrg_profile->temp_mon_range[2].maint_chrg_cur = 950;
- chrg_profile->temp_mon_range[2].maint_chrg_vol_ll = 4000;
- chrg_profile->temp_mon_range[2].maint_chrg_vol_ul = 4050;
-
- chrg_profile->temp_mon_range[3].temp_low_lim = -10;
- chrg_profile->temp_mon_range[3].temp_up_lim = 0;
- chrg_profile->temp_mon_range[3].rbatt = 120;
- chrg_profile->temp_mon_range[3].full_chrg_cur = 950;
- chrg_profile->temp_mon_range[3].full_chrg_vol = 3900;
- chrg_profile->temp_mon_range[3].maint_chrg_cur = 950;
- chrg_profile->temp_mon_range[3].maint_chrg_vol_ll = 3950;
- chrg_profile->temp_mon_range[3].maint_chrg_vol_ul = 3950;
-
- return 0;
-}
-
-static void populate_invalid_chrg_profile(struct charging_profile *chrg_profile)
+static void populate_invalid_chrg_profile
+ (struct batt_charging_profile *chrg_profile)
{
/*
}
-static int get_batt_config(struct battery_config *batt_config)
+static void populate_default_battery_config(
+ struct plat_battery_config *batt_config)
{
/*TODO: Get battery configuration from platfrom layer.Using default
return 0;
}
-static void populate_default_battery_config(struct battery_config *batt_config)
-{
- batt_config->vbatt_sh_min = BATT_DEAD_CUTOFF_VOLT;
- batt_config->vbatt_crit = BATT_CRIT_CUTOFF_VOLT;
- batt_config->temp_high = MSIC_BATT_TEMP_MAX;
- batt_config->temp_low = MSIC_BATT_TEMP_MIN;
-}
/*TO BE FIXED : event handler stub*/
static int pmic_bc_event_handler(void *arg, int event, struct otg_bc_cap *cap)
return -ENOMEM;
}
chrgr_drv_cxt->chrg_profile =
- kzalloc(sizeof(struct charging_profile), GFP_KERNEL);
+ kzalloc(sizeof(struct batt_charging_profile), GFP_KERNEL);
if (!chrgr_drv_cxt->chrg_profile) {
dev_err(&pdev->dev, "%s(): memory allocation failed: Unable to"
}
chrgr_drv_cxt->batt_config =
- kzalloc(sizeof(struct battery_config), GFP_KERNEL);
+ kzalloc(sizeof(struct plat_battery_config), GFP_KERNEL);
if (!chrgr_drv_cxt->batt_config) {
dev_err(&pdev->dev, "%s(): memory allocation failed: Unable to"
INIT_DELAYED_WORK(&chrgr_drv_cxt->chrg_callback_dwrk,
bc_chrg_callback_worker);
- if (get_charging_profile(chrgr_drv_cxt->chrg_profile)) {
+ if (get_batt_charging_profile(chrgr_drv_cxt->chrg_profile)) {
dev_err(&pdev->dev, "%s() :Failed to get battery properties\n",
__func__);
populate_invalid_chrg_profile(chrgr_drv_cxt->chrg_profile);
#define SCHGRIRQ1_ADDR 0x4F
#define BATT_PRESENT 1
#define BATT_NOT_PRESENT 0
-#define BATT_STRING_MAX 8
-#define BATTID_STR_LEN 8
-#define BATT_PROF_MAX_TEMP_NR_RNG 6
#define CHARGER_PRESENT 1
#define CHARGER_NOT_PRESENT 0
/* Bit definitions */
-/* Temperature Monitoring Table */
-struct temp_mon_table {
- short int temp_up_lim;
- short int temp_low_lim;
- short int rbatt;
- short int full_chrg_vol;
- short int full_chrg_cur;
- short int maint_chrg_vol_ll;
- short int maint_chrg_vol_ul;
- short int maint_chrg_cur;
-} __packed;
-
-/*Battery properties */
-struct charging_profile {
- char batt_id[BATTID_STR_LEN];
- unsigned short int voltage_max;
- unsigned int capacity;
- u8 battery_type;
- u8 temp_mon_ranges;
- struct temp_mon_table temp_mon_range[BATT_PROF_MAX_TEMP_NR_RNG];
-} __packed;
struct bc_batt_props_cxt {
unsigned int status;
unsigned int health;
bool present;
};
-
struct bc_charger_props_cxt {
unsigned int charging_mode;
unsigned int charger_present;
char charger_vender[BATT_STRING_MAX];
};
-/* Battery Settings info from platfrom layer*/
-struct battery_config {
- u8 smip_rev;
- u8 fpo; /* fixed implementation options */
- u8 fpo1; /* fixed implementation options1 */
- u8 rsys; /* System Resistance for Fuel gauging */
-
- /* Minimum voltage necessary to
- * be able to safely shut down */
- short int vbatt_sh_min;
-
- /* Voltage at which the battery driver
- * should report the LEVEL as CRITICAL */
- short int vbatt_crit;
-
- short int itc; /* Charge termination current */
- short int temp_high; /* Safe Temp Upper Limit */
- short int temp_low; /* Safe Temp lower Limit */
- u8 brd_id; /* Unique Board ID */
-} __packed;
/*
* basinc cove charger driver info
struct platform_device *pdev;
bool invalid_batt;
bool is_batt_present;
-
- struct charging_profile *chrg_profile;
- struct battery_config *batt_config;
+ struct batt_charging_profile *chrg_profile;
+ struct plat_battery_config *batt_config;
/* lock to protect the charger properties
* locking is applied wherever read or write
--- /dev/null
+/*
+ * intel_mid_powersupply.h - Intel MID Power Supply header file
+ *
+ * Copyright (C) 2011 Intel Corporation
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * Author: Jenny TC <jenny.tc@intel.com>
+ */
+
+#ifndef __INTEL_MID_POWERSUPPLY_H_
+#define __INTEL_MID_POWERSUPPLY_H_
+
+
+/* Battery data Offset range in SMIP */
+#define BATT_SMIP_BASE_OFFSET 0x314
+
+#define BATT_STRING_MAX 8
+#define BATTID_STR_LEN 8
+#define BATT_PROF_MAX_TEMP_NR_RNG 6
+/* Temperature Monitoring Table */
+
+struct temp_mon_table {
+ short int temp_up_lim;
+ short int temp_low_lim;
+ short int rbatt;
+ short int full_chrg_vol;
+ short int full_chrg_cur;
+ short int maint_chrg_vol_ll;
+ short int maint_chrg_vol_ul;
+ short int maint_chrg_cur;
+} __packed;
+
+/* Charging Profile */
+/* FIXME: make the batt_chargig profile generic */
+struct batt_charging_profile {
+ char batt_id[BATTID_STR_LEN];
+ unsigned short int voltage_max;
+ unsigned int capacity;
+ u8 battery_type;
+ u8 temp_mon_ranges;
+ struct temp_mon_table temp_mon_range[BATT_PROF_MAX_TEMP_NR_RNG];
+} __packed;
+
+/* Battery Configuration info */
+struct plat_battery_config {
+ u8 smip_rev;
+ u8 fpo; /* fixed implementation options */
+ u8 fpo1; /* fixed implementation options1 */
+ u8 rsys; /* System Resistance for Fuel gauging */
+
+ /* Minimum voltage necessary to
+ * be able to safely shut down */
+ short int vbatt_sh_min;
+
+ /* Voltage at which the battery driver
+ * should report the LEVEL as CRITICAL */
+ short int vbatt_crit;
+
+ short int itc; /* Charge termination current */
+ short int temp_high; /* Safe Temp Upper Limit */
+ short int temp_low; /* Safe Temp lower Limit */
+ u8 brd_id; /* Unique Board ID */
+} __packed;
+
+
+extern struct batt_charging_profile *batt_chrg_profile;
+
+extern struct plat_battery_config *plat_batt_config;
+
+static inline int get_batt_charging_profile
+ (struct batt_charging_profile *chrg_profile)
+{
+
+ if (batt_chrg_profile) {
+ memcpy(chrg_profile, batt_chrg_profile,
+ sizeof(struct batt_charging_profile));
+ return 0;
+ }
+ return -EINVAL;
+}
+static inline int get_batt_config(struct plat_battery_config *batt_config)
+{
+ if (plat_batt_config) {
+ memcpy(batt_config, plat_batt_config,
+ sizeof(struct plat_battery_config));
+ return 0;
+ }
+ return -EINVAL;
+}
+
+#endif
#define SFI_SIG_DEVS "DEVS"
#define SFI_SIG_GPIO "GPIO"
#define SFI_SIG_OEMB "OEMB"
+#define SFI_SIG_OEM0 "OEM0"
#define SFI_SIGNATURE_SIZE 4
#define SFI_OEM_ID_SIZE 6