#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/mfd/da903x.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/notifier.h>
#define DA9030_FAULT_LOG …
#define DA9030_FAULT_LOG_OVER_TEMP …
#define DA9030_FAULT_LOG_VBAT_OVER …
#define DA9030_CHARGE_CONTROL …
#define DA9030_CHRG_CHARGER_ENABLE …
#define DA9030_ADC_MAN_CONTROL …
#define DA9030_ADC_TBATREF_ENABLE …
#define DA9030_ADC_LDO_INT_ENABLE …
#define DA9030_ADC_AUTO_CONTROL …
#define DA9030_ADC_TBAT_ENABLE …
#define DA9030_ADC_VBAT_IN_TXON …
#define DA9030_ADC_VCH_ENABLE …
#define DA9030_ADC_ICH_ENABLE …
#define DA9030_ADC_VBAT_ENABLE …
#define DA9030_ADC_AUTO_SLEEP_ENABLE …
#define DA9030_VBATMON …
#define DA9030_VBATMONTXON …
#define DA9030_TBATHIGHP …
#define DA9030_TBATHIGHN …
#define DA9030_TBATLOW …
#define DA9030_VBAT_RES …
#define DA9030_VBATMIN_RES …
#define DA9030_VBATMINTXON_RES …
#define DA9030_ICHMAX_RES …
#define DA9030_ICHMIN_RES …
#define DA9030_ICHAVERAGE_RES …
#define DA9030_VCHMAX_RES …
#define DA9030_VCHMIN_RES …
#define DA9030_TBAT_RES …
struct da9030_adc_res { … };
struct da9030_battery_thresholds { … };
struct da9030_charger { … };
static inline int da9030_reg_to_mV(int reg)
{ … }
static inline int da9030_millivolt_to_reg(int mV)
{ … }
static inline int da9030_reg_to_mA(int reg)
{ … }
#ifdef CONFIG_DEBUG_FS
static int bat_debug_show(struct seq_file *s, void *data)
{ … }
DEFINE_SHOW_ATTRIBUTE(…);
static struct dentry *da9030_bat_create_debugfs(struct da9030_charger *charger)
{ … }
static void da9030_bat_remove_debugfs(struct da9030_charger *charger)
{ … }
#else
static inline struct dentry *da9030_bat_create_debugfs(struct da9030_charger *charger)
{
return NULL;
}
static inline void da9030_bat_remove_debugfs(struct da9030_charger *charger)
{
}
#endif
static inline void da9030_read_adc(struct da9030_charger *charger,
struct da9030_adc_res *adc)
{ … }
static void da9030_charger_update_state(struct da9030_charger *charger)
{ … }
static void da9030_set_charge(struct da9030_charger *charger, int on)
{ … }
static void da9030_charger_check_state(struct da9030_charger *charger)
{ … }
static void da9030_charging_monitor(struct work_struct *work)
{ … }
static enum power_supply_property da9030_battery_props[] = …;
static void da9030_battery_check_status(struct da9030_charger *charger,
union power_supply_propval *val)
{ … }
static void da9030_battery_check_health(struct da9030_charger *charger,
union power_supply_propval *val)
{ … }
static int da9030_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static void da9030_battery_vbat_event(struct da9030_charger *charger)
{ … }
static int da9030_battery_event(struct notifier_block *nb, unsigned long event,
void *data)
{ … }
static void da9030_battery_convert_thresholds(struct da9030_charger *charger,
struct da9030_battery_info *pdata)
{ … }
static void da9030_battery_setup_psy(struct da9030_charger *charger)
{
struct power_supply_desc *psy_desc = &charger->psy_desc;
struct power_supply_info *info = charger->battery_info;
psy_desc->name = info->name;
psy_desc->use_for_apm = info->use_for_apm;
psy_desc->type = POWER_SUPPLY_TYPE_BATTERY;
psy_desc->get_property = da9030_battery_get_property;
psy_desc->properties = da9030_battery_props;
psy_desc->num_properties = ARRAY_SIZE(da9030_battery_props);
};
static int da9030_battery_charger_init(struct da9030_charger *charger)
{ … }
static int da9030_battery_probe(struct platform_device *pdev)
{ … }
static void da9030_battery_remove(struct platform_device *dev)
{ … }
static struct platform_driver da903x_battery_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;