M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -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
@@ -0,0 +1,147 @@
/*
* 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>
enum data_source {
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,
};
/**
* 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.
*/
struct charger_global_desc {
char *rtc_name;
bool (*rtc_only_wakeup)(void);
};
/**
* struct charger_desc
* @psy_name: the name of power-supply-class for charger manager
* @polling_mode:
* Determine which polling mode will be used
* @fullbatt_uV: voltage in microvolt
* If it is not being charged and VBATT >= fullbatt_uV,
* 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 regulator_bulk_data for chargers
* @psy_fuel_gauge: the name of power-supply for fuel gauge
* @temperature_out_of_range:
* Determine whether the status is overheat or cold or normal.
* return_value > 0: overheat
* return_value == 0: normal
* return_value < 0: cold
* @measure_battery_temp:
* true: measure battery temperature
* false: measure ambient temperature
*/
struct charger_desc {
char *psy_name;
enum polling_modes polling_mode;
unsigned int polling_interval_ms;
unsigned int fullbatt_uV;
enum data_source battery_present;
char **psy_charger_stat;
int num_charger_regulators;
struct regulator_bulk_data *charger_regulators;
char *psy_fuel_gauge;
int (*temperature_out_of_range)(int *mC);
bool measure_battery_temp;
};
#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
* @charger_enabled: the state of charger
* @emergency_stop:
* When setting true, stop charging
* @last_temp_mC: the measured temperature in milli-Celsius
* @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
*/
struct charger_manager {
struct list_head entry;
struct device *dev;
struct charger_desc *desc;
struct power_supply *fuel_gauge;
struct power_supply **charger_stat;
bool charger_enabled;
int emergency_stop;
int last_temp_mC;
char psy_name_buf[PSY_NAME_MAX + 1];
struct power_supply charger_psy;
bool status_save_ext_pwr_inserted;
bool status_save_batt;
};
#ifdef CONFIG_CHARGER_MANAGER
extern int setup_charger_manager(struct charger_global_desc *gd);
extern bool cm_suspend_again(void);
#else
static void __maybe_unused setup_charger_manager(struct charger_global_desc *gd)
{ }
static bool __maybe_unused cm_suspend_again(void)
{
return false;
}
#endif
#endif /* _CHARGER_MANAGER_H */
+41
View 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
@@ -0,0 +1,29 @@
/*
* 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);
};
#endif
@@ -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
@@ -0,0 +1,30 @@
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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 LTC4088_CHARGER_H_
#define LTC4088_CHARGER_H_
#define LTC4088_CHARGER_DEV_NAME "ltc4088-charger"
/**
* struct ltc4088_charger_platform_data - platform data for LTC4088 charger
* @gpio_mode_select_d0: GPIO #pin for D0 charger line
* @gpio_mode_select_d1: GPIO #pin for D1 charger line
* @gpio_mode_select_d2: GPIO #pin for D2 charger line
*/
struct ltc4088_charger_platform_data {
unsigned int gpio_mode_select_d0;
unsigned int gpio_mode_select_d1;
unsigned int gpio_mode_select_d2;
};
#endif /* LTC4088_CHARGER_H_ */
@@ -0,0 +1,196 @@
/*
* 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,
};
/*
* 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 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 */
/* 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_ */
@@ -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__ */
+42
View 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
+117
View 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 */