mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-09-07 16:58:04 -04:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
16
include/linux/power/ab8500.h
Normal file
16
include/linux/power/ab8500.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (C) ST-Ericsson 2013
|
||||
* Author: Hongbo Zhang <hongbo.zhang@linaro.com>
|
||||
* License terms: GNU General Public License v2
|
||||
*/
|
||||
|
||||
#ifndef PWR_AB8500_H
|
||||
#define PWR_AB8500_H
|
||||
|
||||
extern const struct abx500_res_to_temp ab8500_temp_tbl_a_thermistor[];
|
||||
extern const int ab8500_temp_tbl_a_size;
|
||||
|
||||
extern const struct abx500_res_to_temp ab8500_temp_tbl_b_thermistor[];
|
||||
extern const int ab8500_temp_tbl_b_size;
|
||||
|
||||
#endif /* PWR_AB8500_H */
|
58
include/linux/power/bq2415x_charger.h
Normal file
58
include/linux/power/bq2415x_charger.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* bq2415x charger driver
|
||||
*
|
||||
* Copyright (C) 2011-2013 Pali Rohár <pali.rohar@gmail.com>
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef BQ2415X_CHARGER_H
|
||||
#define BQ2415X_CHARGER_H
|
||||
|
||||
/*
|
||||
* This is platform data for bq2415x chip. It contains default board
|
||||
* voltages and currents which can be also later configured via sysfs. If
|
||||
* value is -1 then default chip value (specified in datasheet) will be
|
||||
* used.
|
||||
*
|
||||
* Value resistor_sense is needed for for configuring charge and
|
||||
* termination current. It it is less or equal to zero, configuring charge
|
||||
* and termination current will not be possible.
|
||||
*
|
||||
* For automode support is needed to provide name of power supply device
|
||||
* in value notify_device. Device driver must immediately report property
|
||||
* POWER_SUPPLY_PROP_CURRENT_MAX when current changed.
|
||||
*/
|
||||
|
||||
/* Supported modes with maximal current limit */
|
||||
enum bq2415x_mode {
|
||||
BQ2415X_MODE_OFF, /* offline mode (charger disabled) */
|
||||
BQ2415X_MODE_NONE, /* unknown charger (100mA) */
|
||||
BQ2415X_MODE_HOST_CHARGER, /* usb host/hub charger (500mA) */
|
||||
BQ2415X_MODE_DEDICATED_CHARGER, /* dedicated charger (unlimited) */
|
||||
BQ2415X_MODE_BOOST, /* boost mode (charging disabled) */
|
||||
};
|
||||
|
||||
struct bq2415x_platform_data {
|
||||
int current_limit; /* mA */
|
||||
int weak_battery_voltage; /* mV */
|
||||
int battery_regulation_voltage; /* mV */
|
||||
int charge_current; /* mA */
|
||||
int termination_current; /* mA */
|
||||
int resistor_sense; /* m ohm */
|
||||
const char *notify_device; /* name */
|
||||
};
|
||||
|
||||
#endif
|
20
include/linux/power/bq24190_charger.h
Normal file
20
include/linux/power/bq24190_charger.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Platform data for the TI bq24190 battery charger driver.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef _BQ24190_CHARGER_H_
|
||||
#define _BQ24190_CHARGER_H_
|
||||
|
||||
#if defined(CONFIG_FUELGAUGE_MAX17058_POWER) || defined(CONFIG_FUELGAUGE_S2MG001_POWER)
|
||||
#include <linux/power/sec_charging_common.h>
|
||||
#endif
|
||||
|
||||
struct bq24190_platform_data {
|
||||
unsigned int gpio_int; /* GPIO pin that's connected to INT# */
|
||||
};
|
||||
|
||||
#endif
|
39
include/linux/power/bq24735-charger.h
Normal file
39
include/linux/power/bq24735-charger.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __CHARGER_BQ24735_H_
|
||||
#define __CHARGER_BQ24735_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
struct bq24735_platform {
|
||||
uint32_t charge_current;
|
||||
uint32_t charge_voltage;
|
||||
uint32_t input_current;
|
||||
|
||||
const char *name;
|
||||
|
||||
int status_gpio;
|
||||
int status_gpio_active_low;
|
||||
bool status_gpio_valid;
|
||||
|
||||
char **supplied_to;
|
||||
size_t num_supplicants;
|
||||
};
|
||||
|
||||
#endif /* __CHARGER_BQ24735_H_ */
|
19
include/linux/power/bq27x00_battery.h
Normal file
19
include/linux/power/bq27x00_battery.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __LINUX_BQ27X00_BATTERY_H__
|
||||
#define __LINUX_BQ27X00_BATTERY_H__
|
||||
|
||||
/**
|
||||
* struct bq27000_plaform_data - Platform data for bq27000 devices
|
||||
* @name: Name of the battery. If NULL the driver will fallback to "bq27000".
|
||||
* @read: HDQ read callback.
|
||||
* This function should provide access to the HDQ bus the battery is
|
||||
* connected to.
|
||||
* The first parameter is a pointer to the battery device, the second the
|
||||
* register to be read. The return value should either be the content of
|
||||
* the passed register or an error value.
|
||||
*/
|
||||
struct bq27000_platform_data {
|
||||
const char *name;
|
||||
int (*read)(struct device *dev, unsigned int);
|
||||
};
|
||||
|
||||
#endif
|
288
include/linux/power/charger-manager.h
Normal file
288
include/linux/power/charger-manager.h
Normal file
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
|
||||
* MyungJoo.Ham <myungjoo.ham@samsung.com>
|
||||
*
|
||||
* Charger Manager.
|
||||
* This framework enables to control and multiple chargers and to
|
||||
* monitor charging even in the context of suspend-to-RAM with
|
||||
* an interface combining the chargers.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
**/
|
||||
|
||||
#ifndef _CHARGER_MANAGER_H
|
||||
#define _CHARGER_MANAGER_H
|
||||
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/extcon.h>
|
||||
|
||||
enum data_source {
|
||||
CM_BATTERY_PRESENT,
|
||||
CM_NO_BATTERY,
|
||||
CM_FUEL_GAUGE,
|
||||
CM_CHARGER_STAT,
|
||||
};
|
||||
|
||||
enum polling_modes {
|
||||
CM_POLL_DISABLE = 0,
|
||||
CM_POLL_ALWAYS,
|
||||
CM_POLL_EXTERNAL_POWER_ONLY,
|
||||
CM_POLL_CHARGING_ONLY,
|
||||
};
|
||||
|
||||
enum cm_event_types {
|
||||
CM_EVENT_UNKNOWN = 0,
|
||||
CM_EVENT_BATT_FULL,
|
||||
CM_EVENT_BATT_IN,
|
||||
CM_EVENT_BATT_OUT,
|
||||
CM_EVENT_BATT_OVERHEAT,
|
||||
CM_EVENT_BATT_COLD,
|
||||
CM_EVENT_EXT_PWR_IN_OUT,
|
||||
CM_EVENT_CHG_START_STOP,
|
||||
CM_EVENT_OTHERS,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct charger_global_desc
|
||||
* @rtc_name: the name of RTC used to wake up the system from suspend.
|
||||
* @rtc_only_wakeup:
|
||||
* If the system is woken up by waekup-sources other than the RTC or
|
||||
* callbacks, Charger Manager should recognize with
|
||||
* rtc_only_wakeup() returning false.
|
||||
* If the RTC given to CM is the only wakeup reason,
|
||||
* rtc_only_wakeup should return true.
|
||||
* @assume_timer_stops_in_suspend:
|
||||
* Assume that the jiffy timer stops in suspend-to-RAM.
|
||||
* When enabled, CM does not rely on jiffies value in
|
||||
* suspend_again and assumes that jiffies value does not
|
||||
* change during suspend.
|
||||
*/
|
||||
struct charger_global_desc {
|
||||
char *rtc_name;
|
||||
|
||||
bool (*rtc_only_wakeup)(void);
|
||||
|
||||
bool assume_timer_stops_in_suspend;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct charger_cable
|
||||
* @extcon_name: the name of extcon device.
|
||||
* @name: the name of charger cable(external connector).
|
||||
* @extcon_dev: the extcon device.
|
||||
* @wq: the workqueue to control charger according to the state of
|
||||
* charger cable. If charger cable is attached, enable charger.
|
||||
* But if charger cable is detached, disable charger.
|
||||
* @nb: the notifier block to receive changed state from EXTCON
|
||||
* (External Connector) when charger cable is attached/detached.
|
||||
* @attached: the state of charger cable.
|
||||
* true: the charger cable is attached
|
||||
* false: the charger cable is detached
|
||||
* @charger: the instance of struct charger_regulator.
|
||||
* @cm: the Charger Manager representing the battery.
|
||||
*/
|
||||
struct charger_cable {
|
||||
const char *extcon_name;
|
||||
const char *name;
|
||||
|
||||
/* The charger-manager use Exton framework*/
|
||||
struct extcon_specific_cable_nb extcon_dev;
|
||||
struct work_struct wq;
|
||||
struct notifier_block nb;
|
||||
|
||||
/* The state of charger cable */
|
||||
bool attached;
|
||||
|
||||
struct charger_regulator *charger;
|
||||
|
||||
/*
|
||||
* Set min/max current of regulator to protect over-current issue
|
||||
* according to a kind of charger cable when cable is attached.
|
||||
*/
|
||||
int min_uA;
|
||||
int max_uA;
|
||||
|
||||
struct charger_manager *cm;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct charger_regulator
|
||||
* @regulator_name: the name of regulator for using charger.
|
||||
* @consumer: the regulator consumer for the charger.
|
||||
* @externally_control:
|
||||
* Set if the charger-manager cannot control charger,
|
||||
* the charger will be maintained with disabled state.
|
||||
* @cables:
|
||||
* the array of charger cables to enable/disable charger
|
||||
* and set current limit according to constratint data of
|
||||
* struct charger_cable if only charger cable included
|
||||
* in the array of charger cables is attached/detached.
|
||||
* @num_cables: the number of charger cables.
|
||||
* @attr_g: Attribute group for the charger(regulator)
|
||||
* @attr_name: "name" sysfs entry
|
||||
* @attr_state: "state" sysfs entry
|
||||
* @attr_externally_control: "externally_control" sysfs entry
|
||||
* @attrs: Arrays pointing to attr_name/state/externally_control for attr_g
|
||||
*/
|
||||
struct charger_regulator {
|
||||
/* The name of regulator for charging */
|
||||
const char *regulator_name;
|
||||
struct regulator *consumer;
|
||||
|
||||
/* charger never on when system is on */
|
||||
int externally_control;
|
||||
|
||||
/*
|
||||
* Store constraint information related to current limit,
|
||||
* each cable have different condition for charging.
|
||||
*/
|
||||
struct charger_cable *cables;
|
||||
int num_cables;
|
||||
|
||||
struct attribute_group attr_g;
|
||||
struct device_attribute attr_name;
|
||||
struct device_attribute attr_state;
|
||||
struct device_attribute attr_externally_control;
|
||||
struct attribute *attrs[4];
|
||||
|
||||
struct charger_manager *cm;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct charger_desc
|
||||
* @psy_name: the name of power-supply-class for charger manager
|
||||
* @polling_mode:
|
||||
* Determine which polling mode will be used
|
||||
* @fullbatt_vchkdrop_ms:
|
||||
* @fullbatt_vchkdrop_uV:
|
||||
* Check voltage drop after the battery is fully charged.
|
||||
* If it has dropped more than fullbatt_vchkdrop_uV after
|
||||
* fullbatt_vchkdrop_ms, CM will restart charging.
|
||||
* @fullbatt_uV: voltage in microvolt
|
||||
* If VBATT >= fullbatt_uV, it is assumed to be full.
|
||||
* @fullbatt_soc: state of Charge in %
|
||||
* If state of Charge >= fullbatt_soc, it is assumed to be full.
|
||||
* @fullbatt_full_capacity: full capacity measure
|
||||
* If full capacity of battery >= fullbatt_full_capacity,
|
||||
* it is assumed to be full.
|
||||
* @polling_interval_ms: interval in millisecond at which
|
||||
* charger manager will monitor battery health
|
||||
* @battery_present:
|
||||
* Specify where information for existance of battery can be obtained
|
||||
* @psy_charger_stat: the names of power-supply for chargers
|
||||
* @num_charger_regulator: the number of entries in charger_regulators
|
||||
* @charger_regulators: array of charger regulators
|
||||
* @psy_fuel_gauge: the name of power-supply for fuel gauge
|
||||
* @thermal_zone : the name of thermal zone for battery
|
||||
* @temp_min : Minimum battery temperature for charging.
|
||||
* @temp_max : Maximum battery temperature for charging.
|
||||
* @temp_diff : Temperature diffential to restart charging.
|
||||
* @measure_battery_temp:
|
||||
* true: measure battery temperature
|
||||
* false: measure ambient temperature
|
||||
* @charging_max_duration_ms: Maximum possible duration for charging
|
||||
* If whole charging duration exceed 'charging_max_duration_ms',
|
||||
* cm stop charging.
|
||||
* @discharging_max_duration_ms:
|
||||
* Maximum possible duration for discharging with charger cable
|
||||
* after full-batt. If discharging duration exceed 'discharging
|
||||
* max_duration_ms', cm start charging.
|
||||
*/
|
||||
struct charger_desc {
|
||||
const char *psy_name;
|
||||
|
||||
enum polling_modes polling_mode;
|
||||
unsigned int polling_interval_ms;
|
||||
|
||||
unsigned int fullbatt_vchkdrop_ms;
|
||||
unsigned int fullbatt_vchkdrop_uV;
|
||||
unsigned int fullbatt_uV;
|
||||
unsigned int fullbatt_soc;
|
||||
unsigned int fullbatt_full_capacity;
|
||||
|
||||
enum data_source battery_present;
|
||||
|
||||
const char **psy_charger_stat;
|
||||
|
||||
int num_charger_regulators;
|
||||
struct charger_regulator *charger_regulators;
|
||||
|
||||
const char *psy_fuel_gauge;
|
||||
|
||||
const char *thermal_zone;
|
||||
|
||||
int temp_min;
|
||||
int temp_max;
|
||||
int temp_diff;
|
||||
|
||||
bool measure_battery_temp;
|
||||
|
||||
u32 charging_max_duration_ms;
|
||||
u32 discharging_max_duration_ms;
|
||||
};
|
||||
|
||||
#define PSY_NAME_MAX 30
|
||||
|
||||
/**
|
||||
* struct charger_manager
|
||||
* @entry: entry for list
|
||||
* @dev: device pointer
|
||||
* @desc: instance of charger_desc
|
||||
* @fuel_gauge: power_supply for fuel gauge
|
||||
* @charger_stat: array of power_supply for chargers
|
||||
* @tzd_batt : thermal zone device for battery
|
||||
* @charger_enabled: the state of charger
|
||||
* @fullbatt_vchk_jiffies_at:
|
||||
* jiffies at the time full battery check will occur.
|
||||
* @fullbatt_vchk_work: work queue for full battery check
|
||||
* @emergency_stop:
|
||||
* When setting true, stop charging
|
||||
* @psy_name_buf: the name of power-supply-class for charger manager
|
||||
* @charger_psy: power_supply for charger manager
|
||||
* @status_save_ext_pwr_inserted:
|
||||
* saved status of external power before entering suspend-to-RAM
|
||||
* @status_save_batt:
|
||||
* saved status of battery before entering suspend-to-RAM
|
||||
* @charging_start_time: saved start time of enabling charging
|
||||
* @charging_end_time: saved end time of disabling charging
|
||||
*/
|
||||
struct charger_manager {
|
||||
struct list_head entry;
|
||||
struct device *dev;
|
||||
struct charger_desc *desc;
|
||||
|
||||
#ifdef CONFIG_THERMAL
|
||||
struct thermal_zone_device *tzd_batt;
|
||||
#endif
|
||||
bool charger_enabled;
|
||||
|
||||
unsigned long fullbatt_vchk_jiffies_at;
|
||||
struct delayed_work fullbatt_vchk_work;
|
||||
|
||||
int emergency_stop;
|
||||
|
||||
char psy_name_buf[PSY_NAME_MAX + 1];
|
||||
struct power_supply charger_psy;
|
||||
|
||||
bool status_save_ext_pwr_inserted;
|
||||
bool status_save_batt;
|
||||
|
||||
u64 charging_start_time;
|
||||
u64 charging_end_time;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CHARGER_MANAGER
|
||||
extern int setup_charger_manager(struct charger_global_desc *gd);
|
||||
extern bool cm_suspend_again(void);
|
||||
extern void cm_notify_event(struct power_supply *psy,
|
||||
enum cm_event_types type, char *msg);
|
||||
#else
|
||||
static inline int setup_charger_manager(struct charger_global_desc *gd)
|
||||
{ return 0; }
|
||||
static inline bool cm_suspend_again(void) { return false; }
|
||||
static inline void cm_notify_event(struct power_supply *psy,
|
||||
enum cm_event_types type, char *msg) { }
|
||||
#endif
|
||||
#endif /* _CHARGER_MANAGER_H */
|
29
include/linux/power/generic-adc-battery.h
Normal file
29
include/linux/power/generic-adc-battery.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2012, Anish Kumar <anish198519851985@gmail.com>
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef GENERIC_ADC_BATTERY_H
|
||||
#define GENERIC_ADC_BATTERY_H
|
||||
|
||||
/**
|
||||
* struct gab_platform_data - platform_data for generic adc iio battery driver.
|
||||
* @battery_info: recommended structure to specify static power supply
|
||||
* parameters
|
||||
* @cal_charge: calculate charge level.
|
||||
* @gpio_charge_finished: gpio for the charger.
|
||||
* @gpio_inverted: Should be 1 if the GPIO is active low otherwise 0
|
||||
* @jitter_delay: delay required after the interrupt to check battery
|
||||
* status.Default set is 10ms.
|
||||
*/
|
||||
struct gab_platform_data {
|
||||
struct power_supply_info battery_info;
|
||||
int (*cal_charge)(long value);
|
||||
int gpio_charge_finished;
|
||||
bool gpio_inverted;
|
||||
int jitter_delay;
|
||||
};
|
||||
|
||||
#endif /* GENERIC_ADC_BATTERY_H */
|
41
include/linux/power/gpio-charger.h
Normal file
41
include/linux/power/gpio-charger.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
|
||||
*
|
||||
* 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; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_POWER_GPIO_CHARGER_H__
|
||||
#define __LINUX_POWER_GPIO_CHARGER_H__
|
||||
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* struct gpio_charger_platform_data - platform_data for gpio_charger devices
|
||||
* @name: Name for the chargers power_supply device
|
||||
* @type: Type of the charger
|
||||
* @gpio: GPIO which is used to indicate the chargers status
|
||||
* @gpio_active_low: Should be set to 1 if the GPIO is active low otherwise 0
|
||||
* @supplied_to: Array of battery names to which this chargers supplies power
|
||||
* @num_supplicants: Number of entries in the supplied_to array
|
||||
*/
|
||||
struct gpio_charger_platform_data {
|
||||
const char *name;
|
||||
enum power_supply_type type;
|
||||
|
||||
int gpio;
|
||||
int gpio_active_low;
|
||||
|
||||
char **supplied_to;
|
||||
size_t num_supplicants;
|
||||
};
|
||||
|
||||
#endif
|
30
include/linux/power/isp1704_charger.h
Normal file
30
include/linux/power/isp1704_charger.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* ISP1704 USB Charger Detection driver
|
||||
*
|
||||
* Copyright (C) 2011 Nokia 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ISP1704_CHARGER_H
|
||||
#define __ISP1704_CHARGER_H
|
||||
|
||||
struct isp1704_charger_data {
|
||||
void (*set_power)(bool on);
|
||||
int enable_gpio;
|
||||
};
|
||||
|
||||
#endif
|
24
include/linux/power/jz4740-battery.h
Normal file
24
include/linux/power/jz4740-battery.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (C) 2009, Jiejing Zhang <kzjeef@gmail.com>
|
||||
*
|
||||
* 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; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __JZ4740_BATTERY_H
|
||||
#define __JZ4740_BATTERY_H
|
||||
|
||||
struct jz_battery_platform_data {
|
||||
struct power_supply_info info;
|
||||
int gpio_charge; /* GPIO port of Charger state */
|
||||
int gpio_charge_active_low;
|
||||
};
|
||||
|
||||
#endif
|
213
include/linux/power/max17042_battery.h
Normal file
213
include/linux/power/max17042_battery.h
Normal file
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* Fuel gauge driver for Maxim 17042 / 8966 / 8997
|
||||
* Note that Maxim 8966 and 8997 are mfd and this is its subdevice.
|
||||
*
|
||||
* Copyright (C) 2011 Samsung Electronics
|
||||
* MyungJoo Ham <myungjoo.ham@samsung.com>
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __MAX17042_BATTERY_H_
|
||||
#define __MAX17042_BATTERY_H_
|
||||
|
||||
#define MAX17042_STATUS_BattAbsent (1 << 3)
|
||||
#define MAX17042_BATTERY_FULL (100)
|
||||
#define MAX17042_DEFAULT_SNS_RESISTOR (10000)
|
||||
|
||||
#define MAX17042_CHARACTERIZATION_DATA_SIZE 48
|
||||
|
||||
enum max17042_register {
|
||||
MAX17042_STATUS = 0x00,
|
||||
MAX17042_VALRT_Th = 0x01,
|
||||
MAX17042_TALRT_Th = 0x02,
|
||||
MAX17042_SALRT_Th = 0x03,
|
||||
MAX17042_AtRate = 0x04,
|
||||
MAX17042_RepCap = 0x05,
|
||||
MAX17042_RepSOC = 0x06,
|
||||
MAX17042_Age = 0x07,
|
||||
MAX17042_TEMP = 0x08,
|
||||
MAX17042_VCELL = 0x09,
|
||||
MAX17042_Current = 0x0A,
|
||||
MAX17042_AvgCurrent = 0x0B,
|
||||
|
||||
MAX17042_SOC = 0x0D,
|
||||
MAX17042_AvSOC = 0x0E,
|
||||
MAX17042_RemCap = 0x0F,
|
||||
MAX17042_FullCAP = 0x10,
|
||||
MAX17042_TTE = 0x11,
|
||||
MAX17042_V_empty = 0x12,
|
||||
|
||||
MAX17042_RSLOW = 0x14,
|
||||
|
||||
MAX17042_AvgTA = 0x16,
|
||||
MAX17042_Cycles = 0x17,
|
||||
MAX17042_DesignCap = 0x18,
|
||||
MAX17042_AvgVCELL = 0x19,
|
||||
MAX17042_MinMaxTemp = 0x1A,
|
||||
MAX17042_MinMaxVolt = 0x1B,
|
||||
MAX17042_MinMaxCurr = 0x1C,
|
||||
MAX17042_CONFIG = 0x1D,
|
||||
MAX17042_ICHGTerm = 0x1E,
|
||||
MAX17042_AvCap = 0x1F,
|
||||
MAX17042_ManName = 0x20,
|
||||
MAX17042_DevName = 0x21,
|
||||
|
||||
MAX17042_FullCAPNom = 0x23,
|
||||
MAX17042_TempNom = 0x24,
|
||||
MAX17042_TempLim = 0x25,
|
||||
MAX17042_TempHot = 0x26,
|
||||
MAX17042_AIN = 0x27,
|
||||
MAX17042_LearnCFG = 0x28,
|
||||
MAX17042_FilterCFG = 0x29,
|
||||
MAX17042_RelaxCFG = 0x2A,
|
||||
MAX17042_MiscCFG = 0x2B,
|
||||
MAX17042_TGAIN = 0x2C,
|
||||
MAx17042_TOFF = 0x2D,
|
||||
MAX17042_CGAIN = 0x2E,
|
||||
MAX17042_COFF = 0x2F,
|
||||
|
||||
MAX17042_MaskSOC = 0x32,
|
||||
MAX17042_SOC_empty = 0x33,
|
||||
MAX17042_T_empty = 0x34,
|
||||
|
||||
MAX17042_FullCAP0 = 0x35,
|
||||
MAX17042_LAvg_empty = 0x36,
|
||||
MAX17042_FCTC = 0x37,
|
||||
MAX17042_RCOMP0 = 0x38,
|
||||
MAX17042_TempCo = 0x39,
|
||||
MAX17042_EmptyTempCo = 0x3A,
|
||||
MAX17042_K_empty0 = 0x3B,
|
||||
MAX17042_TaskPeriod = 0x3C,
|
||||
MAX17042_FSTAT = 0x3D,
|
||||
|
||||
MAX17042_SHDNTIMER = 0x3F,
|
||||
|
||||
MAX17042_dQacc = 0x45,
|
||||
MAX17042_dPacc = 0x46,
|
||||
|
||||
MAX17042_VFSOC0 = 0x48,
|
||||
|
||||
MAX17042_QH = 0x4D,
|
||||
MAX17042_QL = 0x4E,
|
||||
|
||||
MAX17042_VFSOC0Enable = 0x60,
|
||||
MAX17042_MLOCKReg1 = 0x62,
|
||||
MAX17042_MLOCKReg2 = 0x63,
|
||||
|
||||
MAX17042_MODELChrTbl = 0x80,
|
||||
|
||||
MAX17042_OCV = 0xEE,
|
||||
|
||||
MAX17042_OCVInternal = 0xFB,
|
||||
|
||||
MAX17042_VFSOC = 0xFF,
|
||||
};
|
||||
|
||||
/* Registers specific to max17047/50 */
|
||||
enum max17047_register {
|
||||
MAX17047_QRTbl00 = 0x12,
|
||||
MAX17047_FullSOCThr = 0x13,
|
||||
MAX17047_QRTbl10 = 0x22,
|
||||
MAX17047_QRTbl20 = 0x32,
|
||||
MAX17047_V_empty = 0x3A,
|
||||
MAX17047_QRTbl30 = 0x42,
|
||||
};
|
||||
|
||||
enum max170xx_chip_type {MAX17042, MAX17047};
|
||||
|
||||
/*
|
||||
* used for setting a register to a desired value
|
||||
* addr : address for a register
|
||||
* data : setting value for the register
|
||||
*/
|
||||
struct max17042_reg_data {
|
||||
u8 addr;
|
||||
u16 data;
|
||||
};
|
||||
|
||||
struct max17042_config_data {
|
||||
/* External current sense resistor value in milli-ohms */
|
||||
u32 cur_sense_val;
|
||||
|
||||
/* A/D measurement */
|
||||
u16 tgain; /* 0x2C */
|
||||
u16 toff; /* 0x2D */
|
||||
u16 cgain; /* 0x2E */
|
||||
u16 coff; /* 0x2F */
|
||||
|
||||
/* Alert / Status */
|
||||
u16 valrt_thresh; /* 0x01 */
|
||||
u16 talrt_thresh; /* 0x02 */
|
||||
u16 soc_alrt_thresh; /* 0x03 */
|
||||
u16 config; /* 0x01D */
|
||||
u16 shdntimer; /* 0x03F */
|
||||
|
||||
/* App data */
|
||||
u16 full_soc_thresh; /* 0x13 */
|
||||
u16 design_cap; /* 0x18 */
|
||||
u16 ichgt_term; /* 0x1E */
|
||||
|
||||
/* MG3 config */
|
||||
u16 at_rate; /* 0x04 */
|
||||
u16 learn_cfg; /* 0x28 */
|
||||
u16 filter_cfg; /* 0x29 */
|
||||
u16 relax_cfg; /* 0x2A */
|
||||
u16 misc_cfg; /* 0x2B */
|
||||
u16 masksoc; /* 0x32 */
|
||||
|
||||
/* MG3 save and restore */
|
||||
u16 fullcap; /* 0x10 */
|
||||
u16 fullcapnom; /* 0x23 */
|
||||
u16 socempty; /* 0x33 */
|
||||
u16 lavg_empty; /* 0x36 */
|
||||
u16 dqacc; /* 0x45 */
|
||||
u16 dpacc; /* 0x46 */
|
||||
u16 qrtbl00; /* 0x12 */
|
||||
u16 qrtbl10; /* 0x22 */
|
||||
u16 qrtbl20; /* 0x32 */
|
||||
u16 qrtbl30; /* 0x42 */
|
||||
|
||||
/* Cell technology from power_supply.h */
|
||||
u16 cell_technology;
|
||||
|
||||
/* Cell Data */
|
||||
u16 vempty; /* 0x12 */
|
||||
u16 temp_nom; /* 0x24 */
|
||||
u16 temp_lim; /* 0x25 */
|
||||
u16 fctc; /* 0x37 */
|
||||
u16 rcomp0; /* 0x38 */
|
||||
u16 tcompc0; /* 0x39 */
|
||||
u16 empty_tempco; /* 0x3A */
|
||||
u16 kempty0; /* 0x3B */
|
||||
u16 cell_char_tbl[MAX17042_CHARACTERIZATION_DATA_SIZE];
|
||||
} __packed;
|
||||
|
||||
struct max17042_platform_data {
|
||||
struct max17042_reg_data *init_data;
|
||||
struct max17042_config_data *config_data;
|
||||
int num_init_data; /* Number of enties in init_data array */
|
||||
bool enable_current_sense;
|
||||
bool enable_por_init; /* Use POR init from Maxim appnote */
|
||||
|
||||
/*
|
||||
* R_sns in micro-ohms.
|
||||
* default 10000 (if r_sns = 0) as it is the recommended value by
|
||||
* the datasheet although it can be changed by board designers.
|
||||
*/
|
||||
unsigned int r_sns;
|
||||
};
|
||||
|
||||
#endif /* __MAX17042_BATTERY_H_ */
|
43
include/linux/power/max17058_fuelgauge.h
Executable file
43
include/linux/power/max17058_fuelgauge.h
Executable file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* max17058_fuelgauge.h
|
||||
* Samsung MAX17058 Fuel Gauge Header
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MAX17058_FUELGAUGE_H
|
||||
#define __MAX17058_FUELGAUGE_H __FILE__
|
||||
|
||||
/* Slave address should be shifted to the right 1bit.
|
||||
* R/W bit should NOT be included.
|
||||
*/
|
||||
#define SEC_FUELGAUGE_I2C_SLAVEADDR 0x36
|
||||
|
||||
#define MAX17058_REG_VCELL 0x02
|
||||
#define MAX17058_REG_SOC 0x04
|
||||
#define MAX17058_REG_MODE 0x06
|
||||
#define MAX17058_REG_VERSION 0x08
|
||||
#define MAX17058_REG_CONFIG 0x0C
|
||||
#define MAX17058_REG_VRESET 0x18
|
||||
#define MAX17058_REG_STATUS 0x1A
|
||||
#define MAX17058_REG_CMD 0xFE
|
||||
|
||||
struct battery_data_t {
|
||||
u8 *type_str;
|
||||
};
|
||||
|
||||
struct sec_fg_info {
|
||||
bool dummy;
|
||||
};
|
||||
|
||||
#endif /* __MAX17058_FUELGAUGE_H */
|
57
include/linux/power/max8903_charger.h
Normal file
57
include/linux/power/max8903_charger.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* max8903_charger.h - Maxim 8903 USB/Adapter Charger Driver
|
||||
*
|
||||
* Copyright (C) 2011 Samsung Electronics
|
||||
* MyungJoo Ham <myungjoo.ham@samsung.com>
|
||||
*
|
||||
* 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MAX8903_CHARGER_H__
|
||||
#define __MAX8903_CHARGER_H__
|
||||
|
||||
struct max8903_pdata {
|
||||
/*
|
||||
* GPIOs
|
||||
* cen, chg, flt, and usus are optional.
|
||||
* dok, dcm, and uok are not optional depending on the status of
|
||||
* dc_valid and usb_valid.
|
||||
*/
|
||||
int cen; /* Charger Enable input */
|
||||
int dok; /* DC(Adapter) Power OK output */
|
||||
int uok; /* USB Power OK output */
|
||||
int chg; /* Charger status output */
|
||||
int flt; /* Fault output */
|
||||
int dcm; /* Current-Limit Mode input (1: DC, 2: USB) */
|
||||
int usus; /* USB Suspend Input (1: suspended) */
|
||||
|
||||
/*
|
||||
* DC(Adapter/TA) is wired
|
||||
* When dc_valid is true,
|
||||
* dok and dcm should be valid.
|
||||
*
|
||||
* At least one of dc_valid or usb_valid should be true.
|
||||
*/
|
||||
bool dc_valid;
|
||||
/*
|
||||
* USB is wired
|
||||
* When usb_valid is true,
|
||||
* uok should be valid.
|
||||
*/
|
||||
bool usb_valid;
|
||||
};
|
||||
|
||||
#endif /* __MAX8903_CHARGER_H__ */
|
124
include/linux/power/s2mpu06_charger.h
Normal file
124
include/linux/power/s2mpu06_charger.h
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* drivers/power/s2mpu06_charger.h
|
||||
*
|
||||
* Header of S2MPU06 Charger Driver
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics
|
||||
* Develope by Nguyen Tien Dat <tiendat.nt@samsung.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef S2MPU06_CHARGER_H
|
||||
#define S2MPU06_CHARGER_H
|
||||
#include <linux/mfd/samsung/s2mpu06.h>
|
||||
#include <linux/mfd/samsung/s2mpu06-private.h>
|
||||
#include <linux/of_gpio.h>
|
||||
|
||||
#define MASK(width, shift) (((0x1 << (width)) - 1) << shift)
|
||||
|
||||
#define S2MPU06_CHG_REG_PMIC_STATUS 0x08
|
||||
#define S2MPU06_CHG_REG_STATUS1 0x09
|
||||
#define S2MPU06_CHG_REG_STATUS2 0x0A
|
||||
#define S2MPU06_CHG_REG_STATUS3 0x0B
|
||||
#define S2MPU06_CHG_REG_STATUS4 0x0C
|
||||
#define S2MPU06_CHG_REG_CTRL1 0x0D
|
||||
#define S2MPU06_CHG_REG_CTRL2 0x0E
|
||||
#define S2MPU06_CHG_REG_CTRL3 0x0F
|
||||
#define S2MPU06_CHG_REG_CTRL4 0x10
|
||||
#define S2MPU06_CHG_REG_CTRL5 0x11
|
||||
#define S2MPU06_CHG_REG_CTRL6 0x12
|
||||
#define S2MPU06_CHG_REG_CTRL7 0x13
|
||||
#define S2MPU06_CHG_REG_CTRL8 0x14
|
||||
#define S2MPU06_CHG_REG_CTRL9 0x15
|
||||
#define S2MPU06_CHG_REG_CTRL10 0x16
|
||||
#define S2MPU06_CHG_REG_CTRL11 0x17
|
||||
#define S2MPU06_CHG_REG_CTRL12 0x18
|
||||
#define S2MPU06_CHG_REG_CTRL13 0x19
|
||||
#define S2MPU06_CHG_REG_CTRL14 0x1A
|
||||
#define S2MPU06_CHG_REG_CTRL15 0x1B
|
||||
#define S2MPU06_CHG_REG_CTRL16 0x1C
|
||||
#define S2MPU06_CHG_REG_CTRL17 0x1D
|
||||
#define S2MPU06_CHG_REG_CTRL18 0x1E
|
||||
#define S2MPU06_CHG_REG_CTRL19 0x1F
|
||||
#define S2MPU06_CHG_REG_CTRL20 0x20
|
||||
#define S2MPU06_CHG_REG_CTRL21 0x21
|
||||
#define S2MPU06_CHG_REG_CTRL22 0x22
|
||||
#define S2MPU06_CHG_REG_CTRL23 0x23
|
||||
|
||||
|
||||
/* S2MPU06_CHG_STATUS1 */
|
||||
#define CHG_STATUS1_OTG_SS_ENB 0
|
||||
#define CHG_STATUS1_CHGVIN_STS 2
|
||||
#define CHG_STATUS1_BOOST_STS 3
|
||||
#define CHG_STATUS1_CHG_DONE 4
|
||||
#define CHG_STATUS1_CHG_STS 5
|
||||
#define CHG_STATUS1_VBAT_LVL 6
|
||||
|
||||
/* S2MPU06_CHG_STATUS2 */
|
||||
#define DET_BAT_STATUS_SHIFT 3
|
||||
#define DET_BAT_STATUS_MASK BIT(DET_BAT_STATUS_SHIFT)
|
||||
#define CHGVINOVP_STS_SHIFT 6
|
||||
|
||||
/* S2MPU06_CHG_CTRL1 */
|
||||
#define EN_CHG_SHIFT 7
|
||||
#define EN_CHG_MASK BIT(EN_CHG_SHIFT)
|
||||
|
||||
/* S2MPU06_CHG_CTRL2 */
|
||||
#define FAST_CHARGING_CURRENT_SHIFT 0
|
||||
#define FAST_CHARGING_CURRENT_WIDTH 7
|
||||
#define FAST_CHARGING_CURRENT_MASK MASK(FAST_CHARGING_CURRENT_WIDTH,\
|
||||
FAST_CHARGING_CURRENT_SHIFT)
|
||||
|
||||
/* S2MPU06_CHG_CTRL3 */
|
||||
#define CHG_MODE_SHIFT 4
|
||||
#define CHG_MODE_WIDTH 2
|
||||
#define CHG_MODE_MASK MASK(CHG_MODE_WIDTH, CHG_MODE_SHIFT)
|
||||
#define CHG_MODE_OFF 0
|
||||
#define CHG_MODE_EN 1
|
||||
#define CHG_MODE_OTG_BOOST 3
|
||||
|
||||
/* S2MPU06_CHG_CTRL4 */
|
||||
#define FIRST_TOPOFF_CURRENT_SHIFT 0
|
||||
#define FIRST_TOPOFF_CURRENT_WIDTH 7
|
||||
#define FIRST_TOPOFF_CURRENT_MASK MASK(FIRST_TOPOFF_CURRENT_WIDTH,\
|
||||
FIRST_TOPOFF_CURRENT_SHIFT)
|
||||
#define SET_VIN_DROP_SHIFT 1
|
||||
#define SET_VIN_DROP_WIDTH 3
|
||||
#define SET_VIN_DROP_MASK MASK(SET_VIN_DROP_WIDTH, SET_VIN_DROP_SHIFT)
|
||||
|
||||
|
||||
/* S2MPU06_CHG_CTRL5 */
|
||||
#define SET_VF_VBAT_SHIFT 1
|
||||
#define SET_VF_VBAT_WIDTH 3
|
||||
#define SET_VF_VBAT_MASK MASK(SET_VF_VBAT_WIDTH, SET_VF_VBAT_SHIFT)
|
||||
|
||||
#define S2MPU06_IVR_4200MV 0xA0
|
||||
#define S2MPU06_IVR_4300MV 0xA4
|
||||
#define S2MPU06_IVR_4400MV 0xA8
|
||||
#define S2MPU06_IVR_4500MV 0xAC
|
||||
#define S2MPU06_IVR_4600MV 0xB0
|
||||
#define S2MPU06_IVR_4700MV 0xB4
|
||||
#define S2MPU06_IVR_4800MV 0xB8
|
||||
|
||||
/* S2MPU06_CHG_REG_CTRL8 */
|
||||
#define EN_BST_ST_DN_MASK 0x80
|
||||
|
||||
/* S2MPU06_CHG_REG_CTRL14 */
|
||||
#define OTG_EN_MASK 0x80
|
||||
|
||||
#define FAKE_BAT_LEVEL 50
|
||||
|
||||
enum {
|
||||
CHG_REG = 0,
|
||||
CHG_DATA,
|
||||
CHG_REGS,
|
||||
};
|
||||
|
||||
struct charger_info {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#endif /*S2MPU06_CHARGER_H*/
|
71
include/linux/power/s2mpu06_fuelgauge.h
Normal file
71
include/linux/power/s2mpu06_fuelgauge.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* s2mpu06_fuelgauge.h
|
||||
* Samsung S2MPU06 Fuel Gauge Header
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __S2MPU06_FUELGAUGE_H
|
||||
#define __S2MPU06_FUELGAUGE_H __FILE__
|
||||
#include <linux/mfd/samsung/s2mpu06.h>
|
||||
#include <linux/mfd/samsung/s2mpu06-private.h>
|
||||
|
||||
#if defined(ANDROID_ALARM_ACTIVATED)
|
||||
#include <linux/android_alarm.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Slave address should be shifted to the right 1bit.
|
||||
* R/W bit should NOT be included.
|
||||
*/
|
||||
|
||||
#define S2MPU06_FG_REG_STATUS 0x00
|
||||
#define S2MPU06_FG_REG_IRQ 0x02
|
||||
#define S2MPU06_FG_REG_RVBAT 0x04
|
||||
#define S2MPU06_FG_REG_ROCV 0x06
|
||||
#define S2MPU06_FG_REG_RCUR 0x08
|
||||
#define S2MPU06_FG_REG_RSOC_SYS 0x0A
|
||||
#define S2MPU06_FG_REG_RSOC 0x0C
|
||||
#define S2MPU06_FG_REG_RTEMP 0x0E
|
||||
#define S2MPU06_FG_REG_RBATCAP 0x10
|
||||
#define S2MPU06_FG_REG_RZADJ 0x12
|
||||
#define S2MPU06_FG_REG_RBATZ0 0x14
|
||||
#define S2MPU06_FG_REG_RBATZ1 0x16
|
||||
#define S2MPU06_FG_REG_IRQ_LVL 0x18
|
||||
#define S2MPU06_FG_REG_START 0x1A
|
||||
#define S2MPU06_FG_REG_MONSEL 0x1E
|
||||
#define S2MPU06_FG_REG_MONOUT_SEL 0x1F
|
||||
#define S2MPU06_FG_REG_MONOUT 0x20
|
||||
|
||||
struct sec_fg_info {
|
||||
/* test print count */
|
||||
int pr_cnt;
|
||||
/* full charge comp */
|
||||
u32 previous_fullcap;
|
||||
u32 previous_vffullcap;
|
||||
/* low battery comp */
|
||||
int low_batt_comp_flag;
|
||||
/* low battery boot */
|
||||
int low_batt_boot_flag;
|
||||
bool is_low_batt_alarm;
|
||||
|
||||
/* battery info */
|
||||
u32 soc;
|
||||
|
||||
/* miscellaneous */
|
||||
unsigned long fullcap_check_interval;
|
||||
int full_check_flag;
|
||||
bool is_first_check;
|
||||
};
|
||||
|
||||
#endif /* __S2MPU06_FUELGAUGE_H */
|
92
include/linux/power/s2mpw01_charger.h
Executable file
92
include/linux/power/s2mpw01_charger.h
Executable file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* drivers/battery/s2mpw01_charger.h
|
||||
*
|
||||
* Header of S2MPW01 Charger Driver
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics
|
||||
* Develope by Nguyen Tien Dat <tiendat.nt@samsung.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef S2MPW01_CHARGER_H
|
||||
#define S2MPW01_CHARGER_H
|
||||
#include <linux/mfd/samsung/s2mpw01.h>
|
||||
#include <linux/mfd/samsung/s2mpw01-private.h>
|
||||
|
||||
#define MASK(width, shift) (((0x1 << (width)) - 1) << shift)
|
||||
|
||||
#define S2MPW01_CHG_REG_INT1 0x00
|
||||
#define S2MPW01_CHG_REG_INT2 0x01
|
||||
#define S2MPW01_CHG_REG_INT3 0x02
|
||||
#define S2MPW01_CHG_REG_INT1M 0x03
|
||||
#define S2MPW01_CHG_REG_INT2M 0x04
|
||||
#define S2MPW01_CHG_REG_INT3M 0x05
|
||||
#define S2MPW01_CHG_REG_STATUS1 0x06
|
||||
#define S2MPW01_CHG_REG_STATUS2 0x07
|
||||
#define S2MPW01_CHG_REG_STATUS3 0x08
|
||||
#define S2MPW01_CHG_REG_CTRL1 0x09
|
||||
#define S2MPW01_CHG_REG_CTRL2 0x0A
|
||||
#define S2MPW01_CHG_REG_CTRL3 0x0B
|
||||
#define S2MPW01_CHG_REG_CTRL4 0x0C
|
||||
#define S2MPW01_CHG_REG_CTRL5 0x0D
|
||||
#define S2MPW01_CHG_REG_CTRL6 0x0E
|
||||
#define S2MPW01_CHG_REG_CTRL7 0x0F
|
||||
#define S2MPW01_CHG_REG_CTRL8 0x10
|
||||
#define S2MPW01_CHG_REG_CTRL9 0x11
|
||||
|
||||
|
||||
/* S2MPW01_CHG_STATUS1 */
|
||||
#define CHG_STATUS1_RE_CHG 0
|
||||
#define CHG_STATUS1_CHG_DONE 1
|
||||
#define CHG_STATUS1_TOP_OFF 2
|
||||
#define CHG_STATUS1_PRE_CHG 3
|
||||
#define CHG_STATUS1_CHG_STS 4
|
||||
#define CHG_STATUS1_CIN2BAT 5
|
||||
#define CHG_STATUS1_CHGVINOVP 6
|
||||
#define CHG_STATUS1_CHGVIN 7
|
||||
|
||||
/* S2MPW01_CHG_STATUS2 */
|
||||
#define DET_BAT_STATUS_SHIFT 7
|
||||
#define DET_BAT_STATUS_MASK BIT(DET_BAT_STATUS_SHIFT)
|
||||
|
||||
/* S2MPW01_CHG_CTRL1 */
|
||||
#define EN_CHG_SHIFT 7
|
||||
#define EN_CHG_MASK BIT(EN_CHG_SHIFT)
|
||||
|
||||
/* S2MPW01_CHG_CTRL2 */
|
||||
#define FAST_CHARGING_CURRENT_SHIFT 1
|
||||
#define FAST_CHARGING_CURRENT_WIDTH 3
|
||||
#define FAST_CHARGING_CURRENT_MASK MASK(FAST_CHARGING_CURRENT_WIDTH,\
|
||||
FAST_CHARGING_CURRENT_SHIFT)
|
||||
|
||||
/* S2MPW01_CHG_CTRL4 */
|
||||
#define FIRST_TOPOFF_CURRENT_SHIFT 4
|
||||
#define FIRST_TOPOFF_CURRENT_WIDTH 4
|
||||
#define FIRST_TOPOFF_CURRENT_MASK MASK(FIRST_TOPOFF_CURRENT_WIDTH,\
|
||||
FIRST_TOPOFF_CURRENT_SHIFT)
|
||||
#define SET_VIN_DROP_SHIFT 1
|
||||
#define SET_VIN_DROP_WIDTH 3
|
||||
#define SET_VIN_DROP_MASK MASK(SET_VIN_DROP_WIDTH, SET_VIN_DROP_SHIFT)
|
||||
|
||||
|
||||
/* S2MPW01_CHG_CTRL5 */
|
||||
#define SET_VF_VBAT_SHIFT 1
|
||||
#define SET_VF_VBAT_WIDTH 3
|
||||
#define SET_VF_VBAT_MASK MASK(SET_VF_VBAT_WIDTH, SET_VF_VBAT_SHIFT)
|
||||
|
||||
#define FAKE_BAT_LEVEL 50
|
||||
|
||||
enum {
|
||||
CHG_REG = 0,
|
||||
CHG_DATA,
|
||||
CHG_REGS,
|
||||
};
|
||||
|
||||
struct charger_info {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#endif /*S2MPW01_CHARGER_H*/
|
123
include/linux/power/s2mpw01_fuelgauge.h
Executable file
123
include/linux/power/s2mpw01_fuelgauge.h
Executable file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* s2mpw01_fuelgauge.h
|
||||
* Samsung S2MPW01 Fuel Gauge Header
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __S2MPW01_FUELGAUGE_H
|
||||
#define __S2MPW01_FUELGAUGE_H __FILE__
|
||||
#include <linux/mfd/samsung/s2mpw01.h>
|
||||
#include <linux/mfd/samsung/s2mpw01-private.h>
|
||||
|
||||
#if defined(ANDROID_ALARM_ACTIVATED)
|
||||
#include <linux/android_alarm.h>
|
||||
#endif
|
||||
|
||||
#include <linux/power/sec_charging_common.h>
|
||||
|
||||
/* Slave address should be shifted to the right 1bit.
|
||||
* R/W bit should NOT be included.
|
||||
*/
|
||||
|
||||
#define S2MPW01_FG_REG_STATUS 0x00
|
||||
#define S2MPW01_FG_REG_IRQ 0x02
|
||||
#define S2MPW01_FG_REG_INTM 0x03
|
||||
#define S2MPW01_FG_REG_RVBAT 0x04
|
||||
#define S2MPW01_FG_REG_ROCV 0x06
|
||||
#define S2MPW01_FG_REG_RCUR 0x08
|
||||
#define S2MPW01_FG_REG_RSOC_SYS 0x0A
|
||||
#define S2MPW01_FG_REG_RSOC 0x0C
|
||||
#define S2MPW01_FG_REG_RTEMP 0x0E
|
||||
#define S2MPW01_FG_REG_RBATCAP 0x10
|
||||
#define S2MPW01_FG_REG_RZADJ 0x12
|
||||
#define S2MPW01_FG_REG_RBATZ0 0x14
|
||||
#define S2MPW01_FG_REG_RBATZ1 0x16
|
||||
#define S2MPW01_FG_REG_IRQ_LVL 0x18
|
||||
#define S2MPW01_FG_REG_START 0x1A
|
||||
|
||||
struct sec_fg_info {
|
||||
/* test print count */
|
||||
int pr_cnt;
|
||||
/* full charge comp */
|
||||
/* struct delayed_work full_comp_work; */
|
||||
u32 previous_fullcap;
|
||||
u32 previous_vffullcap;
|
||||
/* low battery comp */
|
||||
int low_batt_comp_flag;
|
||||
/* low battery boot */
|
||||
int low_batt_boot_flag;
|
||||
bool is_low_batt_alarm;
|
||||
|
||||
/* battery info */
|
||||
u32 soc;
|
||||
|
||||
/* miscellaneous */
|
||||
unsigned long fullcap_check_interval;
|
||||
int full_check_flag;
|
||||
bool is_first_check;
|
||||
};
|
||||
|
||||
typedef struct s2mpw01_fuelgauge_platform_data {
|
||||
int capacity_max;
|
||||
int capacity_max_margin;
|
||||
int capacity_min;
|
||||
int capacity_calculation_type;
|
||||
int fuel_alert_soc;
|
||||
int fullsocthr;
|
||||
int fg_irq;
|
||||
|
||||
char *fuelgauge_name;
|
||||
|
||||
bool repeated_fuelalert;
|
||||
|
||||
struct sec_charging_current *charging_current;
|
||||
} s2mpw01_fuelgauge_platform_data_t;
|
||||
|
||||
struct s2mpw01_fuelgauge_data {
|
||||
struct device *dev;
|
||||
struct i2c_client *i2c;
|
||||
struct i2c_client *pmic;
|
||||
|
||||
struct mutex fuelgauge_mutex;
|
||||
struct s2mpw01_fuelgauge_platform_data *pdata;
|
||||
struct power_supply psy_fg;
|
||||
/* struct delayed_work isr_work; */
|
||||
|
||||
int cable_type;
|
||||
bool is_charging;
|
||||
|
||||
/* HW-dedicated fuel guage info structure
|
||||
* used in individual fuel gauge file only
|
||||
* (ex. dummy_fuelgauge.c)
|
||||
*/
|
||||
struct sec_fg_info info;
|
||||
bool is_fuel_alerted;
|
||||
struct wake_lock fuel_alert_wake_lock;
|
||||
|
||||
unsigned int capacity_old; /* only for atomic calculation */
|
||||
unsigned int capacity_max; /* only for dynamic calculation */
|
||||
unsigned int standard_capacity;
|
||||
|
||||
bool initial_update_of_soc;
|
||||
struct mutex fg_lock;
|
||||
struct delayed_work isr_work;
|
||||
|
||||
/* register programming */
|
||||
int reg_addr;
|
||||
u8 reg_data[2];
|
||||
|
||||
unsigned int pre_soc;
|
||||
int fg_irq;
|
||||
};
|
||||
#endif /* __S2MPW01_FUELGAUGE_H */
|
112
include/linux/power/s2mu003_charger.h
Normal file
112
include/linux/power/s2mu003_charger.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef S2MU003_CHARGER_H
|
||||
#define S2MU003_CHARGER_H
|
||||
#include <linux/mfd/samsung/s2mu003.h>
|
||||
#include <linux/mfd/samsung/s2mu003_irq.h>
|
||||
|
||||
#define S2MU003_CHG_STATUS1 0x00
|
||||
#define S2MU003_CHG_CTRL1 0x01
|
||||
#define S2MU003_CHG_CTRL2 0x02
|
||||
#define S2MU003_CHG_CTRL3 0x04
|
||||
#define S2MU003_CHG_CTRL4 0x05
|
||||
#define S2MU003_CHG_CTRL5 0x06
|
||||
#define S2MU003_SOFTRESET 0x07
|
||||
#define S2MU003_CHG_CTRL6 0x08
|
||||
#define S2MU003_CHG_CTRL7 0x09
|
||||
#define S2MU003_CHG_CTRL8 0x0A
|
||||
#define S2MU003_CHG_STATUS2 0x0B
|
||||
#define S2MU003_CHG_STATUS3 0x0C
|
||||
#define S2MU003_CHG_STATUS4 0x0D
|
||||
#define S2MU003_CHG_CTRL9 0x0E
|
||||
|
||||
#define S2MU003_OTG_SS_ENB_MASK (1 << 0)
|
||||
#define S2MU003_OPAMODE_MASK (1 << 0)
|
||||
#define S2MU003_CHG_EN_MASK (1 << 6)
|
||||
#define S2MU003_TIMEREN_MASK (1 << 0)
|
||||
#define S2MU003_SEL_SWFREQ_MASK (1 << 2)
|
||||
#define S2MU003_EN_CHGT_MASK (1 << 3)
|
||||
#define S2MU003_TEEN_MASK (1 << 3)
|
||||
#define S2MU003_AICR_LIMIT_MASK (0x7 << 5)
|
||||
#define S2MU003_AICR_LIMIT_SHIFT 5
|
||||
#define S2MU003_MIVR_MASK (0x7 << 5)
|
||||
#define S2MU003_MIVR_SHIFT 5
|
||||
#define S2MU003_VOREG_MASK (0x3f << 2)
|
||||
#define S2MU003_VOREG_SHIFT 2
|
||||
#define S2MU003_IEOC_MASK 0x07
|
||||
#define S2MU003_IEOC_SHIFT 0
|
||||
#define S2MU003_ICHRG_MASK 0xf0
|
||||
#define S2MU003_ICHRG_SHIFT 4
|
||||
|
||||
#define S2MU003_CHG_IRQ1 0x60
|
||||
#define S2MU003_CHG_IRQ2 0x61
|
||||
#define S2MU003_CHG_IRQ3 0x62
|
||||
|
||||
#define S2MU003_CHG_IRQ_CTRL1 0x63
|
||||
#define S2MU003_CHG_IRQ_CTRL2 0x64
|
||||
#define S2MU003_CHG_IRQ_CTRL3 0x65
|
||||
|
||||
#define S2MU003_CHG_DONE_DISABLE 0x74
|
||||
#define S2MU003_CHG_DONE_SEL 0x1
|
||||
#define S2MU003_CHG_DONE_SEL_SHIFT 7
|
||||
|
||||
/* S2MU003_CHG_STAT */
|
||||
#define S2MU003_OTG_SS_ENB (0x01 << 0)
|
||||
#define S2MU003_CHGVIN_STS (0x01 << 2)
|
||||
#define S2MU003_BOOST_STS (0x01 << 3)
|
||||
#define S2MU003_CHG_DONE (0x01 << 4)
|
||||
#define S2MU003_CHG_STS (0x01 << 5)
|
||||
#define S2MU003_VBAT_LVL (0x01 << 6)
|
||||
|
||||
/* S2MU003_CHG_STAT2 */
|
||||
#define S2MU003_CHG_CHGTSD (0x01 << 7)
|
||||
#define S2MU003_CHG_CHGVINOVP (0x01 << 6)
|
||||
#define S2MU003_CHG_TOPOFF (0x01 << 5)
|
||||
#define S2MU003_CHG_BATLV (0x01 << 4)
|
||||
#define S2MU003_CHG_BATP (0x01 << 3)
|
||||
#define S2MU003_CHG_CHGVINIR (0x01 << 2)
|
||||
#define S2MU003_CHG_EOC (0x01 << 1)
|
||||
|
||||
/* S2MU003_CHR_CTRL1 */
|
||||
#define S2MU003_IAICR 0x101
|
||||
#define S2MU003_IAICR_SHIFT 5
|
||||
#define S2MU003_HIGHER_OCP 0x1
|
||||
#define S2MU003_HIGHER_OCP_SHIFT 4
|
||||
#define S2MU003_TERMINATION_EN 0x0
|
||||
#define S2MU003_TERMINATION_EN_SHIFT 3
|
||||
#define S2MU003_SEL_SWFREQ 0x1
|
||||
#define S2MU003_SEL_SWFREQ_SHIFT 2
|
||||
#define S2MU003_HIGH_IMPEDANCE 0
|
||||
#define S2MU003_HIGH_IMPEDANCE_SHIFT 1
|
||||
#define S2MU003_OPA_MODE 2
|
||||
#define S2MU003_OPA_MODE_SHIFT 0
|
||||
|
||||
/* S2MU003_CHG_CTRL2 */
|
||||
#define S2MU003_REG_VOLTAGE 0x011100
|
||||
#define S2MU003_REG_VOLTAGE_SHIFT 2
|
||||
#define S2MU003_TDEG_EOC 0x0
|
||||
#define S2MU003_TDEG_EOC_SHIFT 0
|
||||
|
||||
/* S2MU003_CHG_CTRL3 */
|
||||
#define S2MU003_PPC_TE 0x0
|
||||
#define S2MU003_PPC_TE_SHIFT 7
|
||||
#define S2MU003_CHG_EN 0x1
|
||||
#define S2MU003_CHG_EN_SHIFT 6
|
||||
|
||||
#define FAKE_BAT_LEVEL 50
|
||||
|
||||
enum {
|
||||
CHG_REG = 0,
|
||||
CHG_DATA,
|
||||
CHG_REGS,
|
||||
};
|
||||
|
||||
struct charger_info {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#endif /*S2MU003_CHARGER_H*/
|
114
include/linux/power/s2mu003_fuelgauge.h
Normal file
114
include/linux/power/s2mu003_fuelgauge.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __S2MU003_FUELGAUGE_H
|
||||
#define __S2MU003_FUELGAUGE_H __FILE__
|
||||
|
||||
#if defined(ANDROID_ALARM_ACTIVATED)
|
||||
#include <linux/android_alarm.h>
|
||||
#endif
|
||||
|
||||
#include <linux/power/sec_charging_common.h>
|
||||
|
||||
/*
|
||||
* Slave address should be shifted to the right 1bit.
|
||||
* R/W bit should NOT be included.
|
||||
*/
|
||||
#define SEC_FUELGAUGE_I2C_SLAVEADDR 0x76
|
||||
|
||||
#define S2MU003_REG_STATUS 0x00
|
||||
#define S2MU003_REG_IRQ 0x02
|
||||
#define S2MU003_REG_RVBAT 0x04
|
||||
#define S2MU003_REG_ROCV 0x06
|
||||
#define S2MU003_REG_RSOC 0x0A
|
||||
#define S2MU003_REG_RTEMP 0x0E
|
||||
#define S2MU003_REG_RBATCAP 0x10
|
||||
#define S2MU003_REG_RZADJ 0x12
|
||||
#define S2MU003_REG_RBATZ0 0x14
|
||||
#define S2MU003_REG_RBATZ1 0x16
|
||||
#define S2MU003_REG_IRQ_LVL 0x18
|
||||
#define S2MU003_REG_START 0x1A
|
||||
|
||||
struct sec_fg_info {
|
||||
/* test print count */
|
||||
int pr_cnt;
|
||||
/* full charge comp */
|
||||
/* struct delayed_work full_comp_work; */
|
||||
u32 previous_fullcap;
|
||||
u32 previous_vffullcap;
|
||||
/* low battery comp */
|
||||
int low_batt_comp_flag;
|
||||
/* low battery boot */
|
||||
int low_batt_boot_flag;
|
||||
bool is_low_batt_alarm;
|
||||
|
||||
/* battery info */
|
||||
u32 soc;
|
||||
|
||||
/* miscellaneous */
|
||||
unsigned long fullcap_check_interval;
|
||||
int full_check_flag;
|
||||
bool is_first_check;
|
||||
};
|
||||
|
||||
struct s2mu003_platform_data {
|
||||
int capacity_max;
|
||||
int capacity_max_margin;
|
||||
int capacity_min;
|
||||
int capacity_calculation_type;
|
||||
int fuel_alert_soc;
|
||||
int fullsocthr;
|
||||
int fg_irq;
|
||||
|
||||
char *fuelgauge_name;
|
||||
|
||||
bool repeated_fuelalert;
|
||||
|
||||
struct sec_charging_current *charging_current;
|
||||
};
|
||||
|
||||
struct s2mu003_fuelgauge_data {
|
||||
struct device *dev;
|
||||
struct i2c_client *i2c;
|
||||
struct i2c_client *pmic;
|
||||
s2mu003_mfd_chip_t *s2mu003;
|
||||
struct mutex fuelgauge_mutex;
|
||||
struct s2mu003_platform_data *pdata;
|
||||
struct power_supply psy_fg;
|
||||
/* struct delayed_work isr_work; */
|
||||
|
||||
int cable_type;
|
||||
bool is_charging;
|
||||
|
||||
/*
|
||||
* HW-dedicated fuel guage info structure
|
||||
* used in individual fuel gauge file only
|
||||
* (ex. dummy_fuelgauge.c)
|
||||
*/
|
||||
struct sec_fg_info info;
|
||||
bool is_fuel_alerted;
|
||||
struct wake_lock fuel_alert_wake_lock;
|
||||
|
||||
unsigned int capacity_old; /* only for atomic calculation */
|
||||
unsigned int capacity_max; /* only for dynamic calculation */
|
||||
unsigned int standard_capacity;
|
||||
|
||||
bool initial_update_of_soc;
|
||||
struct mutex fg_lock;
|
||||
|
||||
/* register programming */
|
||||
int reg_addr;
|
||||
u8 reg_data[2];
|
||||
|
||||
unsigned int pre_soc;
|
||||
int fg_irq;
|
||||
};
|
||||
#endif /* __S2MU003_FUELGAUGE_H */
|
188
include/linux/power/s2mu005_charger.h
Normal file
188
include/linux/power/s2mu005_charger.h
Normal file
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* drivers/battery/s2mu005_charger.h
|
||||
*
|
||||
* Header of S2MU005 Charger Driver
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics
|
||||
* Develope by Nguyen Tien Dat <tiendat.nt@samsung.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef S2MU005_CHARGER_H
|
||||
#define S2MU005_CHARGER_H
|
||||
#include <linux/mfd/samsung/s2mu005.h>
|
||||
#include <linux/mfd/samsung/s2mu005-private.h>
|
||||
|
||||
#define MASK(width, shift) (((0x1 << (width)) - 1) << shift)
|
||||
|
||||
#define S2MU005_CHG_STATUS0 0x08
|
||||
#define S2MU005_CHG_STATUS1 0x09
|
||||
#define S2MU005_CHG_STATUS2 0x0A
|
||||
#define S2MU005_CHG_STATUS3 0x0B
|
||||
#define S2MU005_CHG_STATUS4 0x0C
|
||||
#define S2MU005_CHG_STATUS5 0x0D
|
||||
#define S2MU005_CHG_CTRL0 0x0E
|
||||
#define S2MU005_CHG_CTRL1 0x0F
|
||||
#define S2MU005_CHG_CTRL2 0x10
|
||||
#define S2MU005_CHG_CTRL3 0x11
|
||||
#define S2MU005_CHG_CTRL4 0x12
|
||||
#define S2MU005_CHG_CTRL5 0x13
|
||||
#define S2MU005_CHG_CTRL6 0x14
|
||||
#define S2MU005_CHG_CTRL7 0x15
|
||||
#define S2MU005_CHG_CTRL8 0x16
|
||||
#define S2MU005_CHG_CTRL9 0x17
|
||||
#define S2MU005_CHG_CTRL10 0x18
|
||||
#define S2MU005_CHG_CTRL11 0x19
|
||||
#define S2MU005_CHG_CTRL12 0x1A
|
||||
#define S2MU005_CHG_CTRL13 0x1B
|
||||
#define S2MU005_CHG_CTRL14 0x1C
|
||||
#define S2MU005_CHG_CTRL15 0x1D
|
||||
#define S2MU005_CHG_CTRL16 0x1E
|
||||
#define S2MU005_CHG_CTRL17 0x1F
|
||||
#define S2MU005_CHG_CTRL18 0x20
|
||||
|
||||
/* S2MU005_SC_INT_MASK */
|
||||
#define VMID_M_SHIFT 5
|
||||
#define VMID_M_MASK BIT(VMID_M_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_STATUS0 */
|
||||
#define VBUS_OK_SHIFT 7
|
||||
#define VBUS_OK_MASK BIT(VBUS_OK_SHIFT)
|
||||
|
||||
#define WCIN_OK_SHIFT 6
|
||||
#define S2MU005_WCIN_OK_MASK BIT(WCIN_OK_SHIFT)
|
||||
|
||||
#define VMID_OK_SHIFT 5
|
||||
#define VMID_OK_MASK BIT(VMID_OK_SHIFT)
|
||||
|
||||
#define CHG_OK_SHIFT 4
|
||||
#define CHG_OK_MASK BIT(CHG_OK_SHIFT)
|
||||
|
||||
#define CHG_STATUS_SHIFT 0
|
||||
#define CHG_STATUS_WIDTH 4
|
||||
#define CHG_STATUS_MASK MASK(CHG_STATUS_WIDTH, CHG_STATUS_SHIFT)
|
||||
|
||||
#define CHG_STATUS_PRE_CHARGE 2
|
||||
#define CHG_STATUS_COOL_CHARGE 3
|
||||
#define CHG_STATUS_CC 4
|
||||
#define CHG_STATUS_CV 5
|
||||
#define CHG_STATUS_DONE_FLAG 6
|
||||
#define CHG_STATUS_TOP_OFF 7
|
||||
#define CHG_STATUS_DONE 8
|
||||
|
||||
/* S2MU005_CHG_STATUS1 */
|
||||
#define DET_BAT_STATUS_SHIFT 7
|
||||
#define DET_BAT_STATUS_MASK BIT(DET_BAT_STATUS_SHIFT)
|
||||
|
||||
|
||||
/* S2MU005_CHG_STATUS2 */
|
||||
#define BAT_STATUS_SHIFT 4
|
||||
#define BAT_STATUS_WIDTH 3
|
||||
#define BAT_STATUS_MASK MASK(BAT_STATUS_WIDTH, BAT_STATUS_SHIFT)
|
||||
|
||||
#define BAT_OVP_DET 0
|
||||
#define BAT_SELF_DISCHARGING 1
|
||||
#define LOW_BATTERY_DETECTION_IN_CHARGING 2
|
||||
#define COOL_CHARGE_DET 5
|
||||
#define FAST_CHARGE_DET 6
|
||||
#define BAT_VOL_DET 7
|
||||
|
||||
/* S2MU005_CHG_STATUS3 */
|
||||
#define CHG_EVENT_STATUS_SHIFT 0
|
||||
#define CHG_EVENT_STATUS_WIDTH 4
|
||||
#define CHG_EVENT_STATUS_MASK MASK(CHG_EVENT_STATUS_WIDTH, CHG_EVENT_STATUS_SHIFT)
|
||||
|
||||
#define THREMAL_SHUT_DOWN 1
|
||||
#define THERMAL_FOLDBACK 2
|
||||
#define VSYS_OVER_VOVP 3
|
||||
#define VSYS_OVER_VUVLO 4
|
||||
#define WATCHDOG_SUSPENSION 5
|
||||
#define WATCHDOG_AP_RESET 6
|
||||
|
||||
/* S2MU005_CHG_CTRL0 */
|
||||
#define EN_CHG_SHIFT 4
|
||||
#define EN_CHG_MASK BIT(EN_CHG_SHIFT)
|
||||
|
||||
#define REG_MODE_SHIFT 0
|
||||
#define REG_MODE_WIDTH 3
|
||||
#define REG_MODE_MASK MASK(REG_MODE_WIDTH, REG_MODE_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL1 */
|
||||
#define SET_VIN_DROP_SHIFT 4
|
||||
#define SET_VIN_DROP_WIDTH 3
|
||||
#define SET_VIN_DROP_MASK MASK(SET_VIN_DROP_WIDTH, SET_VIN_DROP_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL2 */
|
||||
#define INPUT_CURRENT_LIMIT_SHIFT 0
|
||||
#define INPUT_CURRENT_LIMIT_WIDTH 6
|
||||
#define INPUT_CURRENT_LIMIT_MASK MASK(INPUT_CURRENT_LIMIT_WIDTH,\
|
||||
INPUT_CURRENT_LIMIT_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL4 */
|
||||
#define OTG_OCP_SW_ON_SHIFT 5
|
||||
#define OTG_OCP_SW_ON_MASK BIT(OTG_OCP_SW_ON_SHIFT)
|
||||
|
||||
#define OTG_OCP_SW_OFF_SHIFT 4
|
||||
#define OTG_OCP_SW_OFF_MASK BIT(OTG_OCP_SW_OFF_SHIFT)
|
||||
|
||||
#define SET_OTG_OCP_SHIFT 2
|
||||
#define SET_OTG_OCP_WIDTH 2
|
||||
#define SET_OTG_OCP_MASK MASK(SET_OTG_OCP_WIDTH, SET_OTG_OCP_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL5 */
|
||||
#define SET_VF_VMID_BST_SHIFT 0
|
||||
#define SET_VF_VMID_BST_WIDTH 5
|
||||
#define SET_VF_VMID_BST_MASK MASK(SET_VF_VMID_BST_WIDTH, SET_VF_VMID_BST_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL7 */
|
||||
#define FAST_CHARGING_CURRENT_SHIFT 0
|
||||
#define FAST_CHARGING_CURRENT_WIDTH 6
|
||||
#define FAST_CHARGING_CURRENT_MASK MASK(FAST_CHARGING_CURRENT_WIDTH,\
|
||||
FAST_CHARGING_CURRENT_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL8 */
|
||||
#define SET_VF_VBAT_SHIFT 1
|
||||
#define SET_VF_VBAT_WIDTH 6
|
||||
#define SET_VF_VBAT_MASK MASK(SET_VF_VBAT_WIDTH, SET_VF_VBAT_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL10 */
|
||||
#define SECOND_TOPOFF_CURRENT_SHIFT 4
|
||||
#define SECOND_TOPOFF_CURRENT_WIDTH 4
|
||||
#define SECOND_TOPOFF_CURRENT_MASK MASK(SECOND_TOPOFF_CURRENT_WIDTH,\
|
||||
SECOND_TOPOFF_CURRENT_SHIFT)
|
||||
|
||||
#define FIRST_TOPOFF_CURRENT_SHIFT 0
|
||||
#define FIRST_TOPOFF_CURRENT_WIDTH 4
|
||||
#define FIRST_TOPOFF_CURRENT_MASK MASK(FIRST_TOPOFF_CURRENT_WIDTH,\
|
||||
FIRST_TOPOFF_CURRENT_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL11 */
|
||||
#define SET_OSC_BST_SHIFT 5
|
||||
#define SET_OSC_BST_WIDTH 2
|
||||
#define SET_OSC_BST_MASK MASK(SET_OSC_BST_WIDTH, SET_OSC_BST_SHIFT)
|
||||
|
||||
#define SET_OSC_BUCK_SHIFT 3
|
||||
#define SET_OSC_BUCK_WIDTH 2
|
||||
#define SET_OSC_BUCK_MASK MASK(SET_OSC_BUCK_WIDTH, SET_OSC_BUCK_SHIFT)
|
||||
|
||||
/* S2MU005_CHG_CTRL15 */
|
||||
#define T_EN_OTG_SHIFT 2
|
||||
#define T_EN_OTG_WIDTH 2
|
||||
#define T_EN_OTG_MASK MASK(T_EN_OTG_WIDTH, T_EN_OTG_SHIFT)
|
||||
|
||||
#define FAKE_BAT_LEVEL 50
|
||||
|
||||
enum {
|
||||
CHG_REG = 0,
|
||||
CHG_DATA,
|
||||
CHG_REGS,
|
||||
};
|
||||
|
||||
struct charger_info {
|
||||
int dummy;
|
||||
};
|
||||
|
||||
#endif /*S2MU005_CHARGER_H*/
|
118
include/linux/power/s2mu005_fuelgauge.h
Normal file
118
include/linux/power/s2mu005_fuelgauge.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* s2mu005_fuelgauge.h
|
||||
* Samsung S2MU005 Fuel Gauge Header
|
||||
*
|
||||
* Copyright (C) 2015 Samsung Electronics, Inc.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __S2MU005_FUELGAUGE_H
|
||||
#define __S2MU005_FUELGAUGE_H __FILE__
|
||||
|
||||
#if defined(ANDROID_ALARM_ACTIVATED)
|
||||
#include <linux/android_alarm.h>
|
||||
#endif
|
||||
|
||||
#include <linux/battery/sec_charging_common.h>
|
||||
|
||||
/* Slave address should be shifted to the right 1bit.
|
||||
* R/W bit should NOT be included.
|
||||
*/
|
||||
|
||||
#define S2MU005_REG_STATUS 0x00
|
||||
#define S2MU005_REG_IRQ 0x02
|
||||
#define S2MU005_REG_RVBAT 0x04
|
||||
#define S2MU005_REG_RCUR_CC 0x06
|
||||
#define S2MU005_REG_RSOC 0x08
|
||||
#define S2MU005_REG_MONOUT 0x0A
|
||||
#define S2MU005_REG_MONOUT_SEL 0x0C
|
||||
#define S2MU005_REG_RBATCAP 0x0E
|
||||
#define S2MU005_REG_RZADJ 0x12
|
||||
#define S2MU005_REG_RBATZ0 0x16
|
||||
#define S2MU005_REG_RBATZ1 0x18
|
||||
#define S2MU005_REG_IRQ_LVL 0x1A
|
||||
#define S2MU005_REG_START 0x1E
|
||||
|
||||
struct sec_fg_info {
|
||||
/* test print count */
|
||||
int pr_cnt;
|
||||
/* full charge comp */
|
||||
/* struct delayed_work full_comp_work; */
|
||||
u32 previous_fullcap;
|
||||
u32 previous_vffullcap;
|
||||
/* low battery comp */
|
||||
int low_batt_comp_flag;
|
||||
/* low battery boot */
|
||||
int low_batt_boot_flag;
|
||||
bool is_low_batt_alarm;
|
||||
|
||||
/* battery info */
|
||||
u32 soc;
|
||||
|
||||
/* miscellaneous */
|
||||
unsigned long fullcap_check_interval;
|
||||
int full_check_flag;
|
||||
bool is_first_check;
|
||||
};
|
||||
|
||||
struct s2mu005_platform_data {
|
||||
int capacity_max;
|
||||
int capacity_max_margin;
|
||||
int capacity_min;
|
||||
int capacity_calculation_type;
|
||||
int fuel_alert_soc;
|
||||
int fullsocthr;
|
||||
int fg_irq;
|
||||
|
||||
char *fuelgauge_name;
|
||||
|
||||
bool repeated_fuelalert;
|
||||
|
||||
struct sec_charging_current *charging_current;
|
||||
};
|
||||
|
||||
struct s2mu005_fuelgauge_data {
|
||||
struct device *dev;
|
||||
struct i2c_client *i2c;
|
||||
struct i2c_client *pmic;
|
||||
struct mutex fuelgauge_mutex;
|
||||
struct s2mu005_platform_data *pdata;
|
||||
struct power_supply psy_fg;
|
||||
/* struct delayed_work isr_work; */
|
||||
|
||||
int cable_type;
|
||||
bool is_charging;
|
||||
|
||||
/* HW-dedicated fuel guage info structure
|
||||
* used in individual fuel gauge file only
|
||||
* (ex. dummy_fuelgauge.c)
|
||||
*/
|
||||
struct sec_fg_info info;
|
||||
bool is_fuel_alerted;
|
||||
struct wake_lock fuel_alert_wake_lock;
|
||||
|
||||
unsigned int capacity_old; /* only for atomic calculation */
|
||||
unsigned int capacity_max; /* only for dynamic calculation */
|
||||
unsigned int standard_capacity;
|
||||
|
||||
bool initial_update_of_soc;
|
||||
struct mutex fg_lock;
|
||||
struct delayed_work isr_work;
|
||||
|
||||
/* register programming */
|
||||
int reg_addr;
|
||||
u8 reg_data[2];
|
||||
|
||||
unsigned int pre_soc;
|
||||
int fg_irq;
|
||||
};
|
||||
#endif /* __S2MU005_FUELGAUGE_H */
|
42
include/linux/power/sbs-battery.h
Normal file
42
include/linux/power/sbs-battery.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Gas Gauge driver for SBS Compliant Gas Gauges
|
||||
*
|
||||
* Copyright (c) 2010, NVIDIA 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; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_POWER_SBS_BATTERY_H_
|
||||
#define __LINUX_POWER_SBS_BATTERY_H_
|
||||
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* struct sbs_platform_data - platform data for sbs devices
|
||||
* @battery_detect: GPIO which is used to detect battery presence
|
||||
* @battery_detect_present: gpio state when battery is present (0 / 1)
|
||||
* @i2c_retry_count: # of times to retry on i2c IO failure
|
||||
* @poll_retry_count: # of times to retry looking for new status after
|
||||
* external change notification
|
||||
*/
|
||||
struct sbs_platform_data {
|
||||
int battery_detect;
|
||||
int battery_detect_present;
|
||||
int i2c_retry_count;
|
||||
int poll_retry_count;
|
||||
};
|
||||
|
||||
#endif
|
640
include/linux/power/sec_charging_common.h
Executable file
640
include/linux/power/sec_charging_common.h
Executable file
|
@ -0,0 +1,640 @@
|
|||
/*
|
||||
* sec_charging_common.h
|
||||
* Samsung Mobile Charging Common Header
|
||||
*
|
||||
* Copyright (C) 2012 Samsung Electronics, Inc.
|
||||
*
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SEC_CHARGING_COMMON_H
|
||||
#define __SEC_CHARGING_COMMON_H __FILE__
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/device.h>
|
||||
|
||||
/* definitions */
|
||||
#define SEC_SIZEOF_POWER_SUPPLY_TYPE POWER_SUPPLY_TYPE_WIRELESS_REMOVE
|
||||
|
||||
enum sec_battery_voltage_mode {
|
||||
/* average voltage */
|
||||
SEC_BATTERY_VOLTAGE_AVERAGE = 0,
|
||||
/* open circuit voltage */
|
||||
SEC_BATTERY_VOLTAGE_OCV,
|
||||
};
|
||||
|
||||
enum sec_battery_current_mode {
|
||||
/* uA */
|
||||
SEC_BATTERY_CURRENT_UA = 0,
|
||||
/* mA */
|
||||
SEC_BATTERY_CURRENT_MA,
|
||||
};
|
||||
|
||||
enum sec_battery_capacity_mode {
|
||||
/* designed capacity */
|
||||
SEC_BATTERY_CAPACITY_DESIGNED = 0,
|
||||
/* absolute capacity by fuel gauge */
|
||||
SEC_BATTERY_CAPACITY_ABSOLUTE,
|
||||
/* temperary capacity in the time */
|
||||
SEC_BATTERY_CAPACITY_TEMPERARY,
|
||||
/* current capacity now */
|
||||
SEC_BATTERY_CAPACITY_CURRENT,
|
||||
};
|
||||
|
||||
/* ADC type */
|
||||
enum sec_battery_adc_type {
|
||||
/* NOT using this ADC channel */
|
||||
SEC_BATTERY_ADC_TYPE_NONE = 0,
|
||||
/* ADC in AP */
|
||||
SEC_BATTERY_ADC_TYPE_AP,
|
||||
/* ADC by additional IC */
|
||||
SEC_BATTERY_ADC_TYPE_IC,
|
||||
SEC_BATTERY_ADC_TYPE_NUM
|
||||
};
|
||||
|
||||
enum sec_battery_adc_channel {
|
||||
SEC_BAT_ADC_CHANNEL_CABLE_CHECK = 0,
|
||||
SEC_BAT_ADC_CHANNEL_BAT_CHECK,
|
||||
SEC_BAT_ADC_CHANNEL_TEMP,
|
||||
SEC_BAT_ADC_CHANNEL_TEMP_AMBIENT,
|
||||
SEC_BAT_ADC_CHANNEL_FULL_CHECK,
|
||||
SEC_BAT_ADC_CHANNEL_VOLTAGE_NOW,
|
||||
SEC_BAT_ADC_CHANNEL_NUM
|
||||
};
|
||||
|
||||
/* charging mode */
|
||||
enum sec_battery_charging_mode {
|
||||
/* no charging */
|
||||
SEC_BATTERY_CHARGING_NONE = 0,
|
||||
/* 1st charging */
|
||||
SEC_BATTERY_CHARGING_1ST,
|
||||
/* 2nd charging */
|
||||
SEC_BATTERY_CHARGING_2ND,
|
||||
/* recharging */
|
||||
SEC_BATTERY_CHARGING_RECHARGING,
|
||||
};
|
||||
|
||||
struct sec_bat_adc_api {
|
||||
bool (*init)(struct platform_device *);
|
||||
bool (*exit)(void);
|
||||
int (*read)(unsigned int);
|
||||
};
|
||||
#define sec_bat_adc_api_t struct sec_bat_adc_api
|
||||
|
||||
/* monitor activation */
|
||||
enum sec_battery_polling_time_type {
|
||||
/* same order with power supply status */
|
||||
SEC_BATTERY_POLLING_TIME_BASIC = 0,
|
||||
SEC_BATTERY_POLLING_TIME_CHARGING,
|
||||
SEC_BATTERY_POLLING_TIME_DISCHARGING,
|
||||
SEC_BATTERY_POLLING_TIME_NOT_CHARGING,
|
||||
SEC_BATTERY_POLLING_TIME_SLEEP,
|
||||
};
|
||||
|
||||
enum sec_battery_monitor_polling {
|
||||
/* polling work queue */
|
||||
SEC_BATTERY_MONITOR_WORKQUEUE,
|
||||
/* alarm polling */
|
||||
SEC_BATTERY_MONITOR_ALARM,
|
||||
/* timer polling (NOT USE) */
|
||||
SEC_BATTERY_MONITOR_TIMER,
|
||||
};
|
||||
#define sec_battery_monitor_polling_t \
|
||||
enum sec_battery_monitor_polling
|
||||
|
||||
/* full charged check : POWER_SUPPLY_PROP_STATUS */
|
||||
enum sec_battery_full_charged {
|
||||
SEC_BATTERY_FULLCHARGED_NONE = 0,
|
||||
/* current check by ADC */
|
||||
SEC_BATTERY_FULLCHARGED_ADC,
|
||||
/* fuel gauge current check */
|
||||
SEC_BATTERY_FULLCHARGED_FG_CURRENT,
|
||||
/* time check */
|
||||
SEC_BATTERY_FULLCHARGED_TIME,
|
||||
/* SOC check */
|
||||
SEC_BATTERY_FULLCHARGED_SOC,
|
||||
/* charger GPIO, NO additional full condition */
|
||||
SEC_BATTERY_FULLCHARGED_CHGGPIO,
|
||||
/* charger interrupt, NO additional full condition */
|
||||
SEC_BATTERY_FULLCHARGED_CHGINT,
|
||||
/* charger power supply property, NO additional full condition */
|
||||
SEC_BATTERY_FULLCHARGED_CHGPSY,
|
||||
};
|
||||
#define sec_battery_full_charged_t \
|
||||
enum sec_battery_full_charged
|
||||
|
||||
/* full check condition type (can be used overlapped) */
|
||||
#define sec_battery_full_condition_t unsigned int
|
||||
/* SEC_BATTERY_FULL_CONDITION_NOTIMEFULL
|
||||
* full-charged by absolute-timer only in high voltage
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_NOTIMEFULL 1
|
||||
/* SEC_BATTERY_FULL_CONDITION_SLEEPINFULL
|
||||
* change polling time as sleep polling time even in full-charged
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_NOSLEEPINFULL 2
|
||||
/* SEC_BATTERY_FULL_CONDITION_SOC
|
||||
* use capacity for full-charged check
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_SOC 4
|
||||
/* SEC_BATTERY_FULL_CONDITION_VCELL
|
||||
* use VCELL for full-charged check
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_VCELL 8
|
||||
/* SEC_BATTERY_FULL_CONDITION_AVGVCELL
|
||||
* use average VCELL for full-charged check
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_AVGVCELL 16
|
||||
/* SEC_BATTERY_FULL_CONDITION_OCV
|
||||
* use OCV for full-charged check
|
||||
*/
|
||||
#define SEC_BATTERY_FULL_CONDITION_OCV 32
|
||||
|
||||
/* recharge check condition type (can be used overlapped) */
|
||||
#define sec_battery_recharge_condition_t unsigned int
|
||||
/* SEC_BATTERY_RECHARGE_CONDITION_SOC
|
||||
* use capacity for recharging check
|
||||
*/
|
||||
#define SEC_BATTERY_RECHARGE_CONDITION_SOC 1
|
||||
/* SEC_BATTERY_RECHARGE_CONDITION_AVGVCELL
|
||||
* use average VCELL for recharging check
|
||||
*/
|
||||
#define SEC_BATTERY_RECHARGE_CONDITION_AVGVCELL 2
|
||||
/* SEC_BATTERY_RECHARGE_CONDITION_VCELL
|
||||
* use VCELL for recharging check
|
||||
*/
|
||||
#define SEC_BATTERY_RECHARGE_CONDITION_VCELL 4
|
||||
|
||||
/* battery check : POWER_SUPPLY_PROP_PRESENT */
|
||||
enum sec_battery_check {
|
||||
/* No Check for internal battery */
|
||||
SEC_BATTERY_CHECK_NONE,
|
||||
/* by ADC */
|
||||
SEC_BATTERY_CHECK_ADC,
|
||||
/* by callback function (battery certification by 1 wired)*/
|
||||
SEC_BATTERY_CHECK_CALLBACK,
|
||||
/* by PMIC */
|
||||
SEC_BATTERY_CHECK_PMIC,
|
||||
/* by fuel gauge */
|
||||
SEC_BATTERY_CHECK_FUELGAUGE,
|
||||
/* by charger */
|
||||
SEC_BATTERY_CHECK_CHARGER,
|
||||
/* by interrupt (use check_battery_callback() to check battery) */
|
||||
SEC_BATTERY_CHECK_INT,
|
||||
};
|
||||
#define sec_battery_check_t \
|
||||
enum sec_battery_check
|
||||
|
||||
/* OVP, UVLO check : POWER_SUPPLY_PROP_HEALTH */
|
||||
enum sec_battery_ovp_uvlo {
|
||||
/* by callback function */
|
||||
SEC_BATTERY_OVP_UVLO_CALLBACK,
|
||||
/* by PMIC polling */
|
||||
SEC_BATTERY_OVP_UVLO_PMICPOLLING,
|
||||
/* by PMIC interrupt */
|
||||
SEC_BATTERY_OVP_UVLO_PMICINT,
|
||||
/* by charger polling */
|
||||
SEC_BATTERY_OVP_UVLO_CHGPOLLING,
|
||||
/* by charger interrupt */
|
||||
SEC_BATTERY_OVP_UVLO_CHGINT,
|
||||
};
|
||||
#define sec_battery_ovp_uvlo_t \
|
||||
enum sec_battery_ovp_uvlo
|
||||
|
||||
/* thermal source */
|
||||
enum sec_battery_thermal_source {
|
||||
/* by fuel gauge */
|
||||
SEC_BATTERY_THERMAL_SOURCE_FG,
|
||||
/* by external source */
|
||||
SEC_BATTERY_THERMAL_SOURCE_CALLBACK,
|
||||
/* by ADC */
|
||||
SEC_BATTERY_THERMAL_SOURCE_ADC,
|
||||
};
|
||||
#define sec_battery_thermal_source_t \
|
||||
enum sec_battery_thermal_source
|
||||
|
||||
/* temperature check type */
|
||||
enum sec_battery_temp_check {
|
||||
SEC_BATTERY_TEMP_CHECK_NONE = 0, /* no temperature check */
|
||||
SEC_BATTERY_TEMP_CHECK_ADC, /* by ADC value */
|
||||
SEC_BATTERY_TEMP_CHECK_TEMP, /* by temperature */
|
||||
};
|
||||
#define sec_battery_temp_check_t \
|
||||
enum sec_battery_temp_check
|
||||
|
||||
/* cable check (can be used overlapped) */
|
||||
#define sec_battery_cable_check_t unsigned int
|
||||
/* SEC_BATTERY_CABLE_CHECK_NOUSBCHARGE
|
||||
* for USB cable in tablet model,
|
||||
* status is stuck into discharging,
|
||||
* but internal charging logic is working
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_NOUSBCHARGE 1
|
||||
/* SEC_BATTERY_CABLE_CHECK_NOINCOMPATIBLECHARGE
|
||||
* for incompatible charger
|
||||
* (Not compliant to USB specification,
|
||||
* cable type is POWER_SUPPLY_TYPE_UNKNOWN),
|
||||
* do NOT charge and show message to user
|
||||
* (only for VZW)
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_NOINCOMPATIBLECHARGE 2
|
||||
/* SEC_BATTERY_CABLE_CHECK_PSY
|
||||
* check cable by power supply set_property
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_PSY 4
|
||||
/* SEC_BATTERY_CABLE_CHECK_INT
|
||||
* check cable by interrupt
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_INT 8
|
||||
/* SEC_BATTERY_CABLE_CHECK_CHGINT
|
||||
* check cable by charger interrupt
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_CHGINT 16
|
||||
/* SEC_BATTERY_CABLE_CHECK_POLLING
|
||||
* check cable by GPIO polling
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_CHECK_POLLING 32
|
||||
|
||||
/* check cable source (can be used overlapped) */
|
||||
#define sec_battery_cable_source_t unsigned int
|
||||
/* SEC_BATTERY_CABLE_SOURCE_EXTERNAL
|
||||
* already given by external argument
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_SOURCE_EXTERNAL 1
|
||||
/* SEC_BATTERY_CABLE_SOURCE_CALLBACK
|
||||
* by callback (MUIC, USB switch)
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_SOURCE_CALLBACK 2
|
||||
/* SEC_BATTERY_CABLE_SOURCE_ADC
|
||||
* by ADC
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_SOURCE_ADC 4
|
||||
/* SEC_BATTERY_CABLE_SOURCE_EXTENDED
|
||||
* use extended cable type
|
||||
*/
|
||||
#define SEC_BATTERY_CABLE_SOURCE_EXTENDED 8
|
||||
|
||||
/* capacity calculation type (can be used overlapped) */
|
||||
#define sec_fuelgauge_capacity_type_t int
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_RESET
|
||||
* use capacity information to reset fuel gauge
|
||||
* (only for driver algorithm, can NOT be set by user)
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_RESET (-1)
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_RAW
|
||||
* use capacity information from fuel gauge directly
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_RAW 1
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_SCALE
|
||||
* rescale capacity by scaling, need min and max value for scaling
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_SCALE 2
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_DYNAMIC_SCALE
|
||||
* change only maximum capacity dynamically
|
||||
* to keep time for every SOC unit
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_DYNAMIC_SCALE 4
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC
|
||||
* change capacity value by only -1 or +1
|
||||
* no sudden change of capacity
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_ATOMIC 8
|
||||
/* SEC_FUELGAUGE_CAPACITY_TYPE_SKIP_ABNORMAL
|
||||
* skip current capacity value
|
||||
* if it is abnormal value
|
||||
*/
|
||||
#define SEC_FUELGAUGE_CAPACITY_TYPE_SKIP_ABNORMAL 16
|
||||
|
||||
/* charger function settings (can be used overlapped) */
|
||||
#define sec_charger_functions_t unsigned int
|
||||
/* SEC_CHARGER_NO_GRADUAL_CHARGING_CURRENT
|
||||
* disable gradual charging current setting
|
||||
* SUMMIT:AICL, MAXIM:regulation loop
|
||||
*/
|
||||
#define SEC_CHARGER_NO_GRADUAL_CHARGING_CURRENT 1
|
||||
|
||||
/* SEC_CHARGER_MINIMUM_SIOP_CHARGING_CURRENT
|
||||
* charging current should be over than USB charging current
|
||||
*/
|
||||
#define SEC_CHARGER_MINIMUM_SIOP_CHARGING_CURRENT 2
|
||||
|
||||
/**
|
||||
* struct sec_bat_adc_table_data - adc to temperature table for sec battery
|
||||
* driver
|
||||
* @adc: adc value
|
||||
* @temperature: temperature(C) * 10
|
||||
*/
|
||||
|
||||
struct sec_bat_adc_table_data {
|
||||
#ifdef CONFIG_OF
|
||||
int adc;
|
||||
int data;
|
||||
#else
|
||||
int adc;
|
||||
int data;
|
||||
#endif
|
||||
};
|
||||
#define sec_bat_adc_table_data_t \
|
||||
struct sec_bat_adc_table_data
|
||||
|
||||
struct sec_bat_adc_region {
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
#define sec_bat_adc_region_t \
|
||||
struct sec_bat_adc_region
|
||||
|
||||
struct sec_charging_current {
|
||||
#ifdef CONFIG_OF
|
||||
unsigned int input_current_limit;
|
||||
unsigned int fast_charging_current;
|
||||
unsigned int full_check_current_1st;
|
||||
unsigned int full_check_current_2nd;
|
||||
#else
|
||||
int input_current_limit;
|
||||
int fast_charging_current;
|
||||
int full_check_current_1st;
|
||||
int full_check_current_2nd;
|
||||
#endif
|
||||
};
|
||||
#define sec_charging_current_t \
|
||||
struct sec_charging_current
|
||||
|
||||
struct sec_battery_platform_data {
|
||||
/* NO NEED TO BE CHANGED */
|
||||
/* callback functions */
|
||||
void (*initial_check)(void);
|
||||
void (*monitor_additional_check)(void);
|
||||
bool (*bat_gpio_init)(void);
|
||||
bool (*fg_gpio_init)(void);
|
||||
bool (*chg_gpio_init)(void);
|
||||
bool (*is_lpm)(void);
|
||||
bool (*check_jig_status) (void);
|
||||
bool (*is_interrupt_cable_check_possible)(int);
|
||||
int (*check_cable_callback)(void);
|
||||
int (*get_cable_from_extended_cable_type)(int);
|
||||
bool (*cable_switch_check)(void);
|
||||
bool (*cable_switch_normal)(void);
|
||||
bool (*check_cable_result_callback)(int);
|
||||
bool (*check_battery_callback)(void);
|
||||
bool (*check_battery_result_callback)(void);
|
||||
int (*ovp_uvlo_callback)(void);
|
||||
bool (*ovp_uvlo_result_callback)(int);
|
||||
bool (*fuelalert_process)(bool);
|
||||
bool (*get_temperature_callback)(
|
||||
enum power_supply_property,
|
||||
union power_supply_propval*);
|
||||
|
||||
/* ADC API for each ADC type */
|
||||
sec_bat_adc_api_t adc_api[SEC_BATTERY_ADC_TYPE_NUM];
|
||||
/* ADC region by power supply type
|
||||
* ADC region should be exclusive
|
||||
*/
|
||||
sec_bat_adc_region_t *cable_adc_value;
|
||||
/* charging current for type (0: not use) */
|
||||
sec_charging_current_t *charging_current;
|
||||
#ifdef CONFIG_OF
|
||||
unsigned int *polling_time;
|
||||
char *chip_vendor;
|
||||
unsigned int temp_adc_type;
|
||||
#else
|
||||
int *polling_time;
|
||||
#endif
|
||||
/* NO NEED TO BE CHANGED */
|
||||
|
||||
char *pmic_name;
|
||||
|
||||
/* battery */
|
||||
char *vendor;
|
||||
int technology;
|
||||
int battery_type;
|
||||
void *battery_data;
|
||||
|
||||
int bat_gpio_ta_nconnected;
|
||||
/* 1 : active high, 0 : active low */
|
||||
int bat_polarity_ta_nconnected;
|
||||
int bat_irq;
|
||||
int bat_irq_gpio;
|
||||
unsigned long bat_irq_attr;
|
||||
int jig_irq;
|
||||
unsigned long jig_irq_attr;
|
||||
sec_battery_cable_check_t cable_check_type;
|
||||
sec_battery_cable_source_t cable_source_type;
|
||||
|
||||
bool use_LED; /* use charging LED */
|
||||
|
||||
bool event_check;
|
||||
/* sustaining event after deactivated (second) */
|
||||
unsigned int event_waiting_time;
|
||||
|
||||
/* Monitor setting */
|
||||
sec_battery_monitor_polling_t polling_type;
|
||||
/* for initial check */
|
||||
unsigned int monitor_initial_count;
|
||||
|
||||
/* Battery check */
|
||||
sec_battery_check_t battery_check_type;
|
||||
/* how many times do we need to check battery */
|
||||
unsigned int check_count;
|
||||
/* ADC */
|
||||
/* battery check ADC maximum value */
|
||||
unsigned int check_adc_max;
|
||||
/* battery check ADC minimum value */
|
||||
unsigned int check_adc_min;
|
||||
|
||||
/* OVP/UVLO check */
|
||||
sec_battery_ovp_uvlo_t ovp_uvlo_check_type;
|
||||
|
||||
sec_battery_thermal_source_t thermal_source;
|
||||
#ifdef CONFIG_OF
|
||||
sec_bat_adc_table_data_t *temp_adc_table;
|
||||
sec_bat_adc_table_data_t *temp_amb_adc_table;
|
||||
#else
|
||||
const sec_bat_adc_table_data_t *temp_adc_table;
|
||||
const sec_bat_adc_table_data_t *temp_amb_adc_table;
|
||||
#endif
|
||||
unsigned int temp_adc_table_size;
|
||||
unsigned int temp_amb_adc_table_size;
|
||||
|
||||
sec_battery_temp_check_t temp_check_type;
|
||||
unsigned int temp_check_count;
|
||||
/*
|
||||
* limit can be ADC value or Temperature
|
||||
* depending on temp_check_type
|
||||
* temperature should be temp x 10 (0.1 degree)
|
||||
*/
|
||||
int temp_highlimit_threshold_event;
|
||||
int temp_highlimit_recovery_event;
|
||||
int temp_high_threshold_event;
|
||||
int temp_high_recovery_event;
|
||||
int temp_low_threshold_event;
|
||||
int temp_low_recovery_event;
|
||||
int temp_highlimit_threshold_normal;
|
||||
int temp_highlimit_recovery_normal;
|
||||
int temp_high_threshold_normal;
|
||||
int temp_high_recovery_normal;
|
||||
int temp_low_threshold_normal;
|
||||
int temp_low_recovery_normal;
|
||||
int temp_highlimit_threshold_lpm;
|
||||
int temp_highlimit_recovery_lpm;
|
||||
int temp_high_threshold_lpm;
|
||||
int temp_high_recovery_lpm;
|
||||
int temp_low_threshold_lpm;
|
||||
int temp_low_recovery_lpm;
|
||||
|
||||
/* If these is NOT full check type or NONE full check type,
|
||||
* it is skipped
|
||||
*/
|
||||
/* 1st full check */
|
||||
sec_battery_full_charged_t full_check_type;
|
||||
/* 2nd full check */
|
||||
sec_battery_full_charged_t full_check_type_2nd;
|
||||
unsigned int full_check_count;
|
||||
int chg_gpio_full_check;
|
||||
/* 1 : active high, 0 : active low */
|
||||
int chg_polarity_full_check;
|
||||
sec_battery_full_condition_t full_condition_type;
|
||||
unsigned int full_condition_soc;
|
||||
unsigned int full_condition_vcell;
|
||||
unsigned int full_condition_avgvcell;
|
||||
unsigned int full_condition_ocv;
|
||||
|
||||
unsigned int recharge_check_count;
|
||||
sec_battery_recharge_condition_t recharge_condition_type;
|
||||
unsigned int recharge_condition_soc;
|
||||
unsigned int recharge_condition_avgvcell;
|
||||
unsigned int recharge_condition_vcell;
|
||||
|
||||
/* for absolute timer (second) */
|
||||
unsigned long charging_total_time;
|
||||
/* for recharging timer (second) */
|
||||
unsigned long recharging_total_time;
|
||||
/* reset charging for abnormal malfunction (0: not use) */
|
||||
unsigned long charging_reset_time;
|
||||
|
||||
/* fuel gauge */
|
||||
char *fuelgauge_name;
|
||||
int fg_irq;
|
||||
unsigned long fg_irq_attr;
|
||||
/* fuel alert SOC (-1: not use) */
|
||||
int fuel_alert_soc;
|
||||
/* fuel alert can be repeated */
|
||||
bool repeated_fuelalert;
|
||||
sec_fuelgauge_capacity_type_t capacity_calculation_type;
|
||||
/* soc should be soc x 10 (0.1% degree)
|
||||
* only for scaling
|
||||
*/
|
||||
int capacity_max;
|
||||
int capacity_max_margin;
|
||||
int capacity_min;
|
||||
|
||||
/* charger */
|
||||
char *charger_name;
|
||||
int chg_gpio_en;
|
||||
/* 1 : active high, 0 : active low */
|
||||
int chg_polarity_en;
|
||||
int chg_gpio_curr_adj;
|
||||
/* 1 : active high, 0 : active low */
|
||||
int chg_polarity_curr_adj;
|
||||
int chg_gpio_status;
|
||||
/* 1 : active high, 0 : active low */
|
||||
int chg_polarity_status;
|
||||
int chg_irq;
|
||||
unsigned long chg_irq_attr;
|
||||
/* float voltage (mV) */
|
||||
#ifdef CONFIG_OF
|
||||
unsigned int chg_float_voltage;
|
||||
#else
|
||||
int chg_float_voltage;
|
||||
#endif
|
||||
sec_charger_functions_t chg_functions_setting;
|
||||
|
||||
/* ADC setting */
|
||||
unsigned int adc_check_count;
|
||||
/* ADC type for each channel */
|
||||
unsigned int adc_type[];
|
||||
};
|
||||
#define sec_battery_platform_data_t \
|
||||
struct sec_battery_platform_data
|
||||
|
||||
static inline struct power_supply *get_power_supply_by_name(char *name)
|
||||
{
|
||||
if (!name)
|
||||
return (struct power_supply *)NULL;
|
||||
else
|
||||
return power_supply_get_by_name(name);
|
||||
}
|
||||
|
||||
#define psy_do_property(name, function, property, value) \
|
||||
{ \
|
||||
struct power_supply *psy; \
|
||||
int ret; \
|
||||
psy = get_power_supply_by_name((name)); \
|
||||
if (!psy) { \
|
||||
value.intval = 0; \
|
||||
} else { \
|
||||
ret = psy->function##_property(psy, (property), &(value)); \
|
||||
if (ret < 0) { \
|
||||
value.intval = 0; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define psy_do_property_dup(name, function, property, value) \
|
||||
{ \
|
||||
int ret; \
|
||||
psy = get_power_supply_by_name((name)); \
|
||||
if (!psy) { \
|
||||
value.intval = 0; \
|
||||
} else { \
|
||||
ret = psy->function##_property(psy, (property), &(value)); \
|
||||
if (ret < 0) { \
|
||||
value.intval = 0; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifndef CONFIG_OF
|
||||
#define adc_init(pdev, pdata, channel) \
|
||||
(((pdata)->adc_api)[((((pdata)->adc_type[(channel)]) < \
|
||||
SEC_BATTERY_ADC_TYPE_NUM) ? ((pdata)->adc_type[(channel)]) : \
|
||||
SEC_BATTERY_ADC_TYPE_NONE)].init((pdev)))
|
||||
|
||||
#define adc_exit(pdata, channel) \
|
||||
(((pdata)->adc_api)[((pdata)->adc_type[(channel)])].exit())
|
||||
|
||||
#define adc_read(pdata, channel) \
|
||||
(((pdata)->adc_api)[((pdata)->adc_type[(channel)])].read((channel)))
|
||||
#endif
|
||||
|
||||
#define get_battery_data(driver) \
|
||||
(((struct battery_data_t *)(driver)->pdata->battery_data) \
|
||||
[(driver)->pdata->battery_type])
|
||||
|
||||
#define GET_MAIN_CABLE_TYPE(extended) \
|
||||
((extended >> ONLINE_TYPE_MAIN_SHIFT)&0xf)
|
||||
#define GET_SUB_CABLE_TYPE(extended) \
|
||||
((extended >> ONLINE_TYPE_SUB_SHIFT)&0xf)
|
||||
#define GET_POWER_CABLE_TYPE(extended) \
|
||||
((extended >> ONLINE_TYPE_PWR_SHIFT)&0xf)
|
||||
|
||||
#endif /* __SEC_CHARGING_COMMON_H */
|
109
include/linux/power/sec_fuelgauge.h
Normal file
109
include/linux/power/sec_fuelgauge.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* sec_fuelgauge.h
|
||||
* Samsung Mobile Fuel Gauge Header
|
||||
*
|
||||
* Copyright (C) 2012 Samsung Electronics, Inc.
|
||||
*
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SEC_FUELGAUGE_H
|
||||
#define __SEC_FUELGAUGE_H __FILE__
|
||||
|
||||
#include <linux/power/sec_charging_common.h>
|
||||
|
||||
#if defined(CONFIG_FUELGAUGE_S2MG001_POWER)
|
||||
#include <linux/power/s2mg001_fuelgauge.h>
|
||||
#elif defined(CONFIG_FUELGAUGE_MAX17058_POWER)
|
||||
#include <linux/power/max17058_fuelgauge.h>
|
||||
#endif
|
||||
|
||||
struct sec_fuelgauge_reg_data {
|
||||
u8 reg_addr;
|
||||
u8 reg_data1;
|
||||
u8 reg_data2;
|
||||
};
|
||||
|
||||
struct sec_fuelgauge_info {
|
||||
struct i2c_client *client;
|
||||
sec_battery_platform_data_t *pdata;
|
||||
struct power_supply psy_fg;
|
||||
struct delayed_work isr_work;
|
||||
|
||||
int cable_type;
|
||||
bool is_charging;
|
||||
|
||||
/* HW-dedicated fuel guage info structure
|
||||
* used in individual fuel gauge file only
|
||||
* (ex. dummy_fuelgauge.c)
|
||||
*/
|
||||
struct sec_fg_info info;
|
||||
|
||||
bool is_fuel_alerted;
|
||||
struct wake_lock fuel_alert_wake_lock;
|
||||
|
||||
unsigned int capacity_old; /* only for atomic calculation */
|
||||
unsigned int capacity_max; /* only for dynamic calculation */
|
||||
|
||||
bool initial_update_of_soc;
|
||||
struct mutex fg_lock;
|
||||
|
||||
/* register programming */
|
||||
int reg_addr;
|
||||
u8 reg_data[2];
|
||||
|
||||
int fg_irq;
|
||||
};
|
||||
|
||||
bool sec_hal_fg_init(struct i2c_client *);
|
||||
bool sec_hal_fg_suspend(struct i2c_client *);
|
||||
bool sec_hal_fg_resume(struct i2c_client *);
|
||||
bool sec_hal_fg_fuelalert_init(struct i2c_client *, int);
|
||||
bool sec_hal_fg_is_fuelalerted(struct i2c_client *);
|
||||
bool sec_hal_fg_fuelalert_process(void *, bool);
|
||||
bool sec_hal_fg_full_charged(struct i2c_client *);
|
||||
bool sec_hal_fg_reset(struct i2c_client *);
|
||||
bool sec_hal_fg_get_property(struct i2c_client *,
|
||||
enum power_supply_property,
|
||||
union power_supply_propval *);
|
||||
bool sec_hal_fg_set_property(struct i2c_client *,
|
||||
enum power_supply_property,
|
||||
const union power_supply_propval *);
|
||||
|
||||
ssize_t sec_hal_fg_show_attrs(struct device *dev,
|
||||
const ptrdiff_t offset, char *buf);
|
||||
|
||||
ssize_t sec_hal_fg_store_attrs(struct device *dev,
|
||||
const ptrdiff_t offset,
|
||||
const char *buf, size_t count);
|
||||
|
||||
ssize_t sec_fg_show_attrs(struct device *dev,
|
||||
struct device_attribute *attr, char *buf);
|
||||
|
||||
ssize_t sec_fg_store_attrs(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count);
|
||||
|
||||
#define SEC_FG_ATTR(_name) \
|
||||
{ \
|
||||
.attr = {.name = #_name, .mode = 0664}, \
|
||||
.show = sec_fg_show_attrs, \
|
||||
.store = sec_fg_store_attrs, \
|
||||
}
|
||||
|
||||
enum {
|
||||
FG_REG = 0,
|
||||
FG_DATA,
|
||||
FG_REGS,
|
||||
};
|
||||
|
||||
#endif /* __SEC_FUELGAUGE_H */
|
318
include/linux/power/smartreflex.h
Normal file
318
include/linux/power/smartreflex.h
Normal file
|
@ -0,0 +1,318 @@
|
|||
/*
|
||||
* OMAP Smartreflex Defines and Routines
|
||||
*
|
||||
* Author: Thara Gopinath <thara@ti.com>
|
||||
*
|
||||
* Copyright (C) 2010 Texas Instruments, Inc.
|
||||
* Thara Gopinath <thara@ti.com>
|
||||
*
|
||||
* Copyright (C) 2008 Nokia Corporation
|
||||
* Kalle Jokiniemi
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
* Lesly A M <x0080970@ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef __POWER_SMARTREFLEX_H
|
||||
#define __POWER_SMARTREFLEX_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/platform_data/voltage-omap.h>
|
||||
|
||||
/*
|
||||
* Different Smartreflex IPs version. The v1 is the 65nm version used in
|
||||
* OMAP3430. The v2 is the update for the 45nm version of the IP
|
||||
* used in OMAP3630 and OMAP4430
|
||||
*/
|
||||
#define SR_TYPE_V1 1
|
||||
#define SR_TYPE_V2 2
|
||||
|
||||
/* SMART REFLEX REG ADDRESS OFFSET */
|
||||
#define SRCONFIG 0x00
|
||||
#define SRSTATUS 0x04
|
||||
#define SENVAL 0x08
|
||||
#define SENMIN 0x0C
|
||||
#define SENMAX 0x10
|
||||
#define SENAVG 0x14
|
||||
#define AVGWEIGHT 0x18
|
||||
#define NVALUERECIPROCAL 0x1c
|
||||
#define SENERROR_V1 0x20
|
||||
#define ERRCONFIG_V1 0x24
|
||||
#define IRQ_EOI 0x20
|
||||
#define IRQSTATUS_RAW 0x24
|
||||
#define IRQSTATUS 0x28
|
||||
#define IRQENABLE_SET 0x2C
|
||||
#define IRQENABLE_CLR 0x30
|
||||
#define SENERROR_V2 0x34
|
||||
#define ERRCONFIG_V2 0x38
|
||||
|
||||
/* Bit/Shift Positions */
|
||||
|
||||
/* SRCONFIG */
|
||||
#define SRCONFIG_ACCUMDATA_SHIFT 22
|
||||
#define SRCONFIG_SRCLKLENGTH_SHIFT 12
|
||||
#define SRCONFIG_SENNENABLE_V1_SHIFT 5
|
||||
#define SRCONFIG_SENPENABLE_V1_SHIFT 3
|
||||
#define SRCONFIG_SENNENABLE_V2_SHIFT 1
|
||||
#define SRCONFIG_SENPENABLE_V2_SHIFT 0
|
||||
#define SRCONFIG_CLKCTRL_SHIFT 0
|
||||
|
||||
#define SRCONFIG_ACCUMDATA_MASK (0x3ff << 22)
|
||||
|
||||
#define SRCONFIG_SRENABLE BIT(11)
|
||||
#define SRCONFIG_SENENABLE BIT(10)
|
||||
#define SRCONFIG_ERRGEN_EN BIT(9)
|
||||
#define SRCONFIG_MINMAXAVG_EN BIT(8)
|
||||
#define SRCONFIG_DELAYCTRL BIT(2)
|
||||
|
||||
/* AVGWEIGHT */
|
||||
#define AVGWEIGHT_SENPAVGWEIGHT_SHIFT 2
|
||||
#define AVGWEIGHT_SENNAVGWEIGHT_SHIFT 0
|
||||
|
||||
/* NVALUERECIPROCAL */
|
||||
#define NVALUERECIPROCAL_SENPGAIN_SHIFT 20
|
||||
#define NVALUERECIPROCAL_SENNGAIN_SHIFT 16
|
||||
#define NVALUERECIPROCAL_RNSENP_SHIFT 8
|
||||
#define NVALUERECIPROCAL_RNSENN_SHIFT 0
|
||||
|
||||
/* ERRCONFIG */
|
||||
#define ERRCONFIG_ERRWEIGHT_SHIFT 16
|
||||
#define ERRCONFIG_ERRMAXLIMIT_SHIFT 8
|
||||
#define ERRCONFIG_ERRMINLIMIT_SHIFT 0
|
||||
|
||||
#define SR_ERRWEIGHT_MASK (0x07 << 16)
|
||||
#define SR_ERRMAXLIMIT_MASK (0xff << 8)
|
||||
#define SR_ERRMINLIMIT_MASK (0xff << 0)
|
||||
|
||||
#define ERRCONFIG_VPBOUNDINTEN_V1 BIT(31)
|
||||
#define ERRCONFIG_VPBOUNDINTST_V1 BIT(30)
|
||||
#define ERRCONFIG_MCUACCUMINTEN BIT(29)
|
||||
#define ERRCONFIG_MCUACCUMINTST BIT(28)
|
||||
#define ERRCONFIG_MCUVALIDINTEN BIT(27)
|
||||
#define ERRCONFIG_MCUVALIDINTST BIT(26)
|
||||
#define ERRCONFIG_MCUBOUNDINTEN BIT(25)
|
||||
#define ERRCONFIG_MCUBOUNDINTST BIT(24)
|
||||
#define ERRCONFIG_MCUDISACKINTEN BIT(23)
|
||||
#define ERRCONFIG_VPBOUNDINTST_V2 BIT(23)
|
||||
#define ERRCONFIG_MCUDISACKINTST BIT(22)
|
||||
#define ERRCONFIG_VPBOUNDINTEN_V2 BIT(22)
|
||||
|
||||
#define ERRCONFIG_STATUS_V1_MASK (ERRCONFIG_VPBOUNDINTST_V1 | \
|
||||
ERRCONFIG_MCUACCUMINTST | \
|
||||
ERRCONFIG_MCUVALIDINTST | \
|
||||
ERRCONFIG_MCUBOUNDINTST | \
|
||||
ERRCONFIG_MCUDISACKINTST)
|
||||
/* IRQSTATUS */
|
||||
#define IRQSTATUS_MCUACCUMINT BIT(3)
|
||||
#define IRQSTATUS_MCVALIDINT BIT(2)
|
||||
#define IRQSTATUS_MCBOUNDSINT BIT(1)
|
||||
#define IRQSTATUS_MCUDISABLEACKINT BIT(0)
|
||||
|
||||
/* IRQENABLE_SET and IRQENABLE_CLEAR */
|
||||
#define IRQENABLE_MCUACCUMINT BIT(3)
|
||||
#define IRQENABLE_MCUVALIDINT BIT(2)
|
||||
#define IRQENABLE_MCUBOUNDSINT BIT(1)
|
||||
#define IRQENABLE_MCUDISABLEACKINT BIT(0)
|
||||
|
||||
/* Common Bit values */
|
||||
|
||||
#define SRCLKLENGTH_12MHZ_SYSCLK 0x3c
|
||||
#define SRCLKLENGTH_13MHZ_SYSCLK 0x41
|
||||
#define SRCLKLENGTH_19MHZ_SYSCLK 0x60
|
||||
#define SRCLKLENGTH_26MHZ_SYSCLK 0x82
|
||||
#define SRCLKLENGTH_38MHZ_SYSCLK 0xC0
|
||||
|
||||
/*
|
||||
* 3430 specific values. Maybe these should be passed from board file or
|
||||
* pmic structures.
|
||||
*/
|
||||
#define OMAP3430_SR_ACCUMDATA 0x1f4
|
||||
|
||||
#define OMAP3430_SR1_SENPAVGWEIGHT 0x03
|
||||
#define OMAP3430_SR1_SENNAVGWEIGHT 0x03
|
||||
|
||||
#define OMAP3430_SR2_SENPAVGWEIGHT 0x01
|
||||
#define OMAP3430_SR2_SENNAVGWEIGHT 0x01
|
||||
|
||||
#define OMAP3430_SR_ERRWEIGHT 0x04
|
||||
#define OMAP3430_SR_ERRMAXLIMIT 0x02
|
||||
|
||||
struct omap_sr {
|
||||
char *name;
|
||||
struct list_head node;
|
||||
struct platform_device *pdev;
|
||||
struct omap_sr_nvalue_table *nvalue_table;
|
||||
struct voltagedomain *voltdm;
|
||||
struct dentry *dbg_dir;
|
||||
unsigned int irq;
|
||||
int srid;
|
||||
int ip_type;
|
||||
int nvalue_count;
|
||||
bool autocomp_active;
|
||||
u32 clk_length;
|
||||
u32 err_weight;
|
||||
u32 err_minlimit;
|
||||
u32 err_maxlimit;
|
||||
u32 accum_data;
|
||||
u32 senn_avgweight;
|
||||
u32 senp_avgweight;
|
||||
u32 senp_mod;
|
||||
u32 senn_mod;
|
||||
void __iomem *base;
|
||||
};
|
||||
|
||||
/**
|
||||
* test_cond_timeout - busy-loop, testing a condition
|
||||
* @cond: condition to test until it evaluates to true
|
||||
* @timeout: maximum number of microseconds in the timeout
|
||||
* @index: loop index (integer)
|
||||
*
|
||||
* Loop waiting for @cond to become true or until at least @timeout
|
||||
* microseconds have passed. To use, define some integer @index in the
|
||||
* calling code. After running, if @index == @timeout, then the loop has
|
||||
* timed out.
|
||||
*
|
||||
* Copied from omap_test_timeout */
|
||||
#define sr_test_cond_timeout(cond, timeout, index) \
|
||||
({ \
|
||||
for (index = 0; index < timeout; index++) { \
|
||||
if (cond) \
|
||||
break; \
|
||||
udelay(1); \
|
||||
} \
|
||||
})
|
||||
|
||||
/**
|
||||
* struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
|
||||
* pmic specific info to smartreflex driver
|
||||
*
|
||||
* @sr_pmic_init: API to initialize smartreflex on the PMIC side.
|
||||
*/
|
||||
struct omap_sr_pmic_data {
|
||||
void (*sr_pmic_init) (void);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct omap_smartreflex_dev_attr - Smartreflex Device attribute.
|
||||
*
|
||||
* @sensor_voltdm_name: Name of voltdomain of SR instance
|
||||
*/
|
||||
struct omap_smartreflex_dev_attr {
|
||||
const char *sensor_voltdm_name;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_POWER_AVS_OMAP
|
||||
/*
|
||||
* The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
|
||||
* The smartreflex class driver should pass the class type.
|
||||
* Should be used to populate the class_type field of the
|
||||
* omap_smartreflex_class_data structure.
|
||||
*/
|
||||
#define SR_CLASS1 0x1
|
||||
#define SR_CLASS2 0x2
|
||||
#define SR_CLASS3 0x3
|
||||
|
||||
/**
|
||||
* struct omap_sr_class_data - Smartreflex class driver info
|
||||
*
|
||||
* @enable: API to enable a particular class smaartreflex.
|
||||
* @disable: API to disable a particular class smartreflex.
|
||||
* @configure: API to configure a particular class smartreflex.
|
||||
* @notify: API to notify the class driver about an event in SR.
|
||||
* Not needed for class3.
|
||||
* @notify_flags: specify the events to be notified to the class driver
|
||||
* @class_type: specify which smartreflex class.
|
||||
* Can be used by the SR driver to take any class
|
||||
* based decisions.
|
||||
*/
|
||||
struct omap_sr_class_data {
|
||||
int (*enable)(struct omap_sr *sr);
|
||||
int (*disable)(struct omap_sr *sr, int is_volt_reset);
|
||||
int (*configure)(struct omap_sr *sr);
|
||||
int (*notify)(struct omap_sr *sr, u32 status);
|
||||
u8 notify_flags;
|
||||
u8 class_type;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct omap_sr_nvalue_table - Smartreflex n-target value info
|
||||
*
|
||||
* @efuse_offs: The offset of the efuse where n-target values are stored.
|
||||
* @nvalue: The n-target value.
|
||||
* @errminlimit: The value of the ERRMINLIMIT bitfield for this n-target
|
||||
* @volt_nominal: microvolts DC that the VDD is initially programmed to
|
||||
*/
|
||||
struct omap_sr_nvalue_table {
|
||||
u32 efuse_offs;
|
||||
u32 nvalue;
|
||||
u32 errminlimit;
|
||||
unsigned long volt_nominal;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct omap_sr_data - Smartreflex platform data.
|
||||
*
|
||||
* @name: instance name
|
||||
* @ip_type: Smartreflex IP type.
|
||||
* @senp_mod: SENPENABLE value of the sr CONFIG register
|
||||
* @senn_mod: SENNENABLE value for sr CONFIG register
|
||||
* @err_weight ERRWEIGHT value of the sr ERRCONFIG register
|
||||
* @err_maxlimit ERRMAXLIMIT value of the sr ERRCONFIG register
|
||||
* @accum_data ACCUMDATA value of the sr CONFIG register
|
||||
* @senn_avgweight SENNAVGWEIGHT value of the sr AVGWEIGHT register
|
||||
* @senp_avgweight SENPAVGWEIGHT value of the sr AVGWEIGHT register
|
||||
* @nvalue_count: Number of distinct nvalues in the nvalue table
|
||||
* @enable_on_init: whether this sr module needs to enabled at
|
||||
* boot up or not.
|
||||
* @nvalue_table: table containing the efuse offsets and nvalues
|
||||
* corresponding to them.
|
||||
* @voltdm: Pointer to the voltage domain associated with the SR
|
||||
*/
|
||||
struct omap_sr_data {
|
||||
const char *name;
|
||||
int ip_type;
|
||||
u32 senp_mod;
|
||||
u32 senn_mod;
|
||||
u32 err_weight;
|
||||
u32 err_maxlimit;
|
||||
u32 accum_data;
|
||||
u32 senn_avgweight;
|
||||
u32 senp_avgweight;
|
||||
int nvalue_count;
|
||||
bool enable_on_init;
|
||||
struct omap_sr_nvalue_table *nvalue_table;
|
||||
struct voltagedomain *voltdm;
|
||||
};
|
||||
|
||||
/* Smartreflex module enable/disable interface */
|
||||
void omap_sr_enable(struct voltagedomain *voltdm);
|
||||
void omap_sr_disable(struct voltagedomain *voltdm);
|
||||
void omap_sr_disable_reset_volt(struct voltagedomain *voltdm);
|
||||
|
||||
/* API to register the pmic specific data with the smartreflex driver. */
|
||||
void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data);
|
||||
|
||||
/* Smartreflex driver hooks to be called from Smartreflex class driver */
|
||||
int sr_enable(struct omap_sr *sr, unsigned long volt);
|
||||
void sr_disable(struct omap_sr *sr);
|
||||
int sr_configure_errgen(struct omap_sr *sr);
|
||||
int sr_disable_errgen(struct omap_sr *sr);
|
||||
int sr_configure_minmax(struct omap_sr *sr);
|
||||
|
||||
/* API to register the smartreflex class driver with the smartreflex driver */
|
||||
int sr_register_class(struct omap_sr_class_data *class_data);
|
||||
#else
|
||||
static inline void omap_sr_enable(struct voltagedomain *voltdm) {}
|
||||
static inline void omap_sr_disable(struct voltagedomain *voltdm) {}
|
||||
static inline void omap_sr_disable_reset_volt(
|
||||
struct voltagedomain *voltdm) {}
|
||||
static inline void omap_sr_register_pmic(
|
||||
struct omap_sr_pmic_data *pmic_data) {}
|
||||
#endif
|
||||
#endif
|
117
include/linux/power/smb347-charger.h
Normal file
117
include/linux/power/smb347-charger.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Summit Microelectronics SMB347 Battery Charger Driver
|
||||
*
|
||||
* Copyright (C) 2011, Intel Corporation
|
||||
*
|
||||
* Authors: Bruce E. Robertson <bruce.e.robertson@intel.com>
|
||||
* Mika Westerberg <mika.westerberg@linux.intel.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef SMB347_CHARGER_H
|
||||
#define SMB347_CHARGER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
enum {
|
||||
/* use the default compensation method */
|
||||
SMB347_SOFT_TEMP_COMPENSATE_DEFAULT = -1,
|
||||
|
||||
SMB347_SOFT_TEMP_COMPENSATE_NONE,
|
||||
SMB347_SOFT_TEMP_COMPENSATE_CURRENT,
|
||||
SMB347_SOFT_TEMP_COMPENSATE_VOLTAGE,
|
||||
};
|
||||
|
||||
/* Use default factory programmed value for hard/soft temperature limit */
|
||||
#define SMB347_TEMP_USE_DEFAULT -273
|
||||
|
||||
/*
|
||||
* Charging enable can be controlled by software (via i2c) by
|
||||
* smb347-charger driver or by EN pin (active low/high).
|
||||
*/
|
||||
enum smb347_chg_enable {
|
||||
SMB347_CHG_ENABLE_SW,
|
||||
SMB347_CHG_ENABLE_PIN_ACTIVE_LOW,
|
||||
SMB347_CHG_ENABLE_PIN_ACTIVE_HIGH,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct smb347_charger_platform_data - platform data for SMB347 charger
|
||||
* @battery_info: Information about the battery
|
||||
* @max_charge_current: maximum current (in uA) the battery can be charged
|
||||
* @max_charge_voltage: maximum voltage (in uV) the battery can be charged
|
||||
* @pre_charge_current: current (in uA) to use in pre-charging phase
|
||||
* @termination_current: current (in uA) used to determine when the
|
||||
* charging cycle terminates
|
||||
* @pre_to_fast_voltage: voltage (in uV) treshold used for transitioning to
|
||||
* pre-charge to fast charge mode
|
||||
* @mains_current_limit: maximum input current drawn from AC/DC input (in uA)
|
||||
* @usb_hc_current_limit: maximum input high current (in uA) drawn from USB
|
||||
* input
|
||||
* @chip_temp_threshold: die temperature where device starts limiting charge
|
||||
* current [%100 - %130] (in degree C)
|
||||
* @soft_cold_temp_limit: soft cold temperature limit [%0 - %15] (in degree C),
|
||||
* granularity is 5 deg C.
|
||||
* @soft_hot_temp_limit: soft hot temperature limit [%40 - %55] (in degree C),
|
||||
* granularity is 5 deg C.
|
||||
* @hard_cold_temp_limit: hard cold temperature limit [%-5 - %10] (in degree C),
|
||||
* granularity is 5 deg C.
|
||||
* @hard_hot_temp_limit: hard hot temperature limit [%50 - %65] (in degree C),
|
||||
* granularity is 5 deg C.
|
||||
* @suspend_on_hard_temp_limit: suspend charging when hard limit is hit
|
||||
* @soft_temp_limit_compensation: compensation method when soft temperature
|
||||
* limit is hit
|
||||
* @charge_current_compensation: current (in uA) for charging compensation
|
||||
* current when temperature hits soft limits
|
||||
* @use_mains: AC/DC input can be used
|
||||
* @use_usb: USB input can be used
|
||||
* @use_usb_otg: USB OTG output can be used (not implemented yet)
|
||||
* @irq_gpio: GPIO number used for interrupts (%-1 if not used)
|
||||
* @enable_control: how charging enable/disable is controlled
|
||||
* (driver/pin controls)
|
||||
*
|
||||
* @use_main, @use_usb, and @use_usb_otg are means to enable/disable
|
||||
* hardware support for these. This is useful when we want to have for
|
||||
* example OTG charging controlled via OTG transceiver driver and not by
|
||||
* the SMB347 hardware.
|
||||
*
|
||||
* Hard and soft temperature limit values are given as described in the
|
||||
* device data sheet and assuming NTC beta value is %3750. Even if this is
|
||||
* not the case, these values should be used. They can be mapped to the
|
||||
* corresponding NTC beta values with the help of table %2 in the data
|
||||
* sheet. So for example if NTC beta is %3375 and we want to program hard
|
||||
* hot limit to be %53 deg C, @hard_hot_temp_limit should be set to %50.
|
||||
*
|
||||
* If zero value is given in any of the current and voltage values, the
|
||||
* factory programmed default will be used. For soft/hard temperature
|
||||
* values, pass in %SMB347_TEMP_USE_DEFAULT instead.
|
||||
*/
|
||||
struct smb347_charger_platform_data {
|
||||
struct power_supply_info battery_info;
|
||||
unsigned int max_charge_current;
|
||||
unsigned int max_charge_voltage;
|
||||
unsigned int pre_charge_current;
|
||||
unsigned int termination_current;
|
||||
unsigned int pre_to_fast_voltage;
|
||||
unsigned int mains_current_limit;
|
||||
unsigned int usb_hc_current_limit;
|
||||
unsigned int chip_temp_threshold;
|
||||
int soft_cold_temp_limit;
|
||||
int soft_hot_temp_limit;
|
||||
int hard_cold_temp_limit;
|
||||
int hard_hot_temp_limit;
|
||||
bool suspend_on_hard_temp_limit;
|
||||
unsigned int soft_temp_limit_compensation;
|
||||
unsigned int charge_current_compensation;
|
||||
bool use_mains;
|
||||
bool use_usb;
|
||||
bool use_usb_otg;
|
||||
int irq_gpio;
|
||||
enum smb347_chg_enable enable_control;
|
||||
};
|
||||
|
||||
#endif /* SMB347_CHARGER_H */
|
39
include/linux/power/twl4030_madc_battery.h
Normal file
39
include/linux/power/twl4030_madc_battery.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Dumb driver for LiIon batteries using TWL4030 madc.
|
||||
*
|
||||
* Copyright 2013 Golden Delicious Computers
|
||||
* Nikolaus Schaller <hns@goldelico.com>
|
||||
*
|
||||
* 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; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TWL4030_MADC_BATTERY_H
|
||||
#define __TWL4030_MADC_BATTERY_H
|
||||
|
||||
/*
|
||||
* Usually we can assume 100% @ 4.15V and 0% @ 3.3V but curves differ for
|
||||
* charging and discharging!
|
||||
*/
|
||||
|
||||
struct twl4030_madc_bat_calibration {
|
||||
short voltage; /* in mV - specify -1 for end of list */
|
||||
short level; /* in percent (0 .. 100%) */
|
||||
};
|
||||
|
||||
struct twl4030_madc_bat_platform_data {
|
||||
unsigned int capacity; /* total capacity in uAh */
|
||||
struct twl4030_madc_bat_calibration *charging;
|
||||
int charging_size;
|
||||
struct twl4030_madc_bat_calibration *discharging;
|
||||
int discharging_size;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue