blob: 7e06e6b3297a5fe8077fdc2335b6f900d21ae3d0 [file] [log] [blame]
/*
* Copyright (C) 2017, Teknique Ltd.
*
* 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_NEST_RQ_BATTERY_H__
#define __LINUX_POWER_NEST_RQ_BATTERY_H__
#include <linux/power_supply.h>
#include <linux/types.h>
struct nest_rq_battery {
struct device* dev;
const struct nest_rq_battery_platform_data *pdata;
spinlock_t lock;
struct power_supply battery;
struct power_supply charger;
};
/**
* struct nest_vega_battery_platform_data - platform_data for gpio_charger devices
* @name: Name for the chargers power_supply device
* @supplied_to: Array of battery names to which this chargers supplies power
* @num_supplicants: Number of entries in the supplied_to array
* @vmax_gpio: GPIO which is used to set the Vsys voltage
* @status_gpio: GPIO which is used to indicate the charger status
* @adc_enable_gpio: GPIO which is used to en/disable the adcs
* @temp_adc_chan: ADC channel for reading battery NTC
* @volt_adc_chan: ADC channel for reading battery voltage
* @charger_disable_gpio: GPIO which is used to en/disable the charger
* @charger_rate_gpio: GPIO which is used to toggle the charger current
* @vbridge_adc_chan: ADC channel for reading the vbridge voltage
*/
struct nest_rq_battery_platform_data {
const char *name;
char **supplied_to;
size_t num_supplicants;
//Battery
u32 disconnect_gpio;
u32 vmax_gpio;
u32 status_gpio;
u32 adc_enable_gpio;
u32 heater_enable_gpio;
u32 temp_adc_chan;
u32 volt_adc_chan;
//Charger
u32 charger_enable_gpio;
u32 charger_rate_gpio;
//Vbridge
u32 vbridge_adc_chan;
u32 vbridge_disable_gpio;
u32 acok_gpio;
};
extern struct nest_rq_battery *nest_rq_battery;
void nest_rq_battery_vbridge_disable(struct nest_rq_battery *batt, int state);
int nest_rq_battery_get_voltage(struct nest_rq_battery *batt);
int nest_rq_battery_get_temp(struct nest_rq_battery *batt, int *temp);
#endif //__LINUX_POWER_NEST_RQ_BATTERY_H__