mirror of https://gitee.com/openkylin/linux.git
Merge branch 'ib-ab8500-5.4-rc1' into HEAD
Immutable branch as considerable overlap with mfd, power and hwmon.
This commit is contained in:
commit
16922ffee1
|
@ -69,6 +69,18 @@ Required child device properties:
|
|||
- compatible : "stericsson,ab8500-[bm|btemp|charger|fg|gpadc|gpio|ponkey|
|
||||
pwm|regulator|rtc|sysctrl|usb]";
|
||||
|
||||
A few child devices require ADC channels from the GPADC node. Those follow the
|
||||
standard bindings from iio/iio-bindings.txt and iio/adc/adc.txt
|
||||
|
||||
abx500-temp : io-channels "aux1" and "aux2" for measuring external
|
||||
temperatures.
|
||||
ab8500-fg : io-channel "main_bat_v" for measuring main battery voltage,
|
||||
ab8500-btemp : io-channels "btemp_ball" and "bat_ctrl" for measuring the
|
||||
battery voltage.
|
||||
ab8500-charger : io-channels "main_charger_v", "main_charger_c", "vbus_v",
|
||||
"usb_charger_c" for measuring voltage and current of the
|
||||
different charging supplies.
|
||||
|
||||
Optional child device properties:
|
||||
- interrupts : contains the device IRQ(s) using the 2-cell format (see above)
|
||||
- interrupt-names : contains names of IRQ resource in the order in which they were
|
||||
|
@ -102,8 +114,115 @@ ab8500 {
|
|||
39 0x4>;
|
||||
interrupt-names = "HW_CONV_END", "SW_CONV_END";
|
||||
vddadc-supply = <&ab8500_ldo_tvout_reg>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
#io-channel-cells = <1>;
|
||||
|
||||
/* GPADC channels */
|
||||
bat_ctrl: channel@1 {
|
||||
reg = <0x01>;
|
||||
};
|
||||
btemp_ball: channel@2 {
|
||||
reg = <0x02>;
|
||||
};
|
||||
main_charger_v: channel@3 {
|
||||
reg = <0x03>;
|
||||
};
|
||||
acc_detect1: channel@4 {
|
||||
reg = <0x04>;
|
||||
};
|
||||
acc_detect2: channel@5 {
|
||||
reg = <0x05>;
|
||||
};
|
||||
adc_aux1: channel@6 {
|
||||
reg = <0x06>;
|
||||
};
|
||||
adc_aux2: channel@7 {
|
||||
reg = <0x07>;
|
||||
};
|
||||
main_batt_v: channel@8 {
|
||||
reg = <0x08>;
|
||||
};
|
||||
vbus_v: channel@9 {
|
||||
reg = <0x09>;
|
||||
};
|
||||
main_charger_c: channel@a {
|
||||
reg = <0x0a>;
|
||||
};
|
||||
usb_charger_c: channel@b {
|
||||
reg = <0x0b>;
|
||||
};
|
||||
bk_bat_v: channel@c {
|
||||
reg = <0x0c>;
|
||||
};
|
||||
die_temp: channel@d {
|
||||
reg = <0x0d>;
|
||||
};
|
||||
usb_id: channel@e {
|
||||
reg = <0x0e>;
|
||||
};
|
||||
xtal_temp: channel@12 {
|
||||
reg = <0x12>;
|
||||
};
|
||||
vbat_true_meas: channel@13 {
|
||||
reg = <0x13>;
|
||||
};
|
||||
bat_ctrl_and_ibat: channel@1c {
|
||||
reg = <0x1c>;
|
||||
};
|
||||
vbat_meas_and_ibat: channel@1d {
|
||||
reg = <0x1d>;
|
||||
};
|
||||
vbat_true_meas_and_ibat: channel@1e {
|
||||
reg = <0x1e>;
|
||||
};
|
||||
bat_temp_and_ibat: channel@1f {
|
||||
reg = <0x1f>;
|
||||
};
|
||||
};
|
||||
|
||||
ab8500_temp {
|
||||
compatible = "stericsson,abx500-temp";
|
||||
io-channels = <&gpadc 0x06>,
|
||||
<&gpadc 0x07>;
|
||||
io-channel-name = "aux1", "aux2";
|
||||
};
|
||||
|
||||
ab8500_battery: ab8500_battery {
|
||||
stericsson,battery-type = "LIPO";
|
||||
thermistor-on-batctrl;
|
||||
};
|
||||
|
||||
ab8500_fg {
|
||||
compatible = "stericsson,ab8500-fg";
|
||||
battery = <&ab8500_battery>;
|
||||
io-channels = <&gpadc 0x08>;
|
||||
io-channel-name = "main_bat_v";
|
||||
};
|
||||
|
||||
ab8500_btemp {
|
||||
compatible = "stericsson,ab8500-btemp";
|
||||
battery = <&ab8500_battery>;
|
||||
io-channels = <&gpadc 0x02>,
|
||||
<&gpadc 0x01>;
|
||||
io-channel-name = "btemp_ball",
|
||||
"bat_ctrl";
|
||||
};
|
||||
|
||||
ab8500_charger {
|
||||
compatible = "stericsson,ab8500-charger";
|
||||
battery = <&ab8500_battery>;
|
||||
vddadc-supply = <&ab8500_ldo_tvout_reg>;
|
||||
io-channels = <&gpadc 0x03>,
|
||||
<&gpadc 0x0a>,
|
||||
<&gpadc 0x09>,
|
||||
<&gpadc 0x0b>;
|
||||
io-channel-name = "main_charger_v",
|
||||
"main_charger_c",
|
||||
"vbus_v",
|
||||
"usb_charger_c";
|
||||
};
|
||||
|
||||
ab8500-usb {
|
||||
compatible = "stericsson,ab8500-usb";
|
||||
interrupts = < 90 0x4
|
||||
|
|
|
@ -2005,6 +2005,7 @@ F: drivers/dma/ste_dma40*
|
|||
F: drivers/hwspinlock/u8500_hsem.c
|
||||
F: drivers/i2c/busses/i2c-nomadik.c
|
||||
F: drivers/i2c/busses/i2c-stu300.c
|
||||
F: drivers/iio/adc/ab8500-gpadc.c
|
||||
F: drivers/mfd/ab3100*
|
||||
F: drivers/mfd/ab8500*
|
||||
F: drivers/mfd/abx500*
|
||||
|
|
|
@ -40,7 +40,8 @@ comment "Native drivers"
|
|||
|
||||
config SENSORS_AB8500
|
||||
tristate "AB8500 thermal monitoring"
|
||||
depends on AB8500_GPADC && AB8500_BM
|
||||
depends on AB8500_GPADC && AB8500_BM && (IIO = y)
|
||||
default n
|
||||
help
|
||||
If you say yes here you get support for the thermal sensor part
|
||||
of the AB8500 chip. The driver includes thermal management for
|
||||
|
|
|
@ -17,20 +17,24 @@
|
|||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/mfd/abx500.h>
|
||||
#include <linux/mfd/abx500/ab8500-bm.h>
|
||||
#include <linux/mfd/abx500/ab8500-gpadc.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/power/ab8500.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
#include "abx500.h"
|
||||
|
||||
#define DEFAULT_POWER_OFF_DELAY (HZ * 10)
|
||||
#define THERMAL_VCC 1800
|
||||
#define PULL_UP_RESISTOR 47000
|
||||
/* Number of monitored sensors should not greater than NUM_SENSORS */
|
||||
#define NUM_MONITORED_SENSORS 4
|
||||
|
||||
#define AB8500_SENSOR_AUX1 0
|
||||
#define AB8500_SENSOR_AUX2 1
|
||||
#define AB8500_SENSOR_BTEMP_BALL 2
|
||||
#define AB8500_SENSOR_BAT_CTRL 3
|
||||
#define NUM_MONITORED_SENSORS 4
|
||||
|
||||
struct ab8500_gpadc_cfg {
|
||||
const struct abx500_res_to_temp *temp_tbl;
|
||||
|
@ -40,7 +44,8 @@ struct ab8500_gpadc_cfg {
|
|||
};
|
||||
|
||||
struct ab8500_temp {
|
||||
struct ab8500_gpadc *gpadc;
|
||||
struct iio_channel *aux1;
|
||||
struct iio_channel *aux2;
|
||||
struct ab8500_btemp *btemp;
|
||||
struct delayed_work power_off_work;
|
||||
struct ab8500_gpadc_cfg cfg;
|
||||
|
@ -82,15 +87,21 @@ static int ab8500_read_sensor(struct abx500_temp *data, u8 sensor, int *temp)
|
|||
int voltage, ret;
|
||||
struct ab8500_temp *ab8500_data = data->plat_data;
|
||||
|
||||
if (sensor == BAT_CTRL) {
|
||||
*temp = ab8500_btemp_get_batctrl_temp(ab8500_data->btemp);
|
||||
} else if (sensor == BTEMP_BALL) {
|
||||
if (sensor == AB8500_SENSOR_BTEMP_BALL) {
|
||||
*temp = ab8500_btemp_get_temp(ab8500_data->btemp);
|
||||
} else {
|
||||
voltage = ab8500_gpadc_convert(ab8500_data->gpadc, sensor);
|
||||
if (voltage < 0)
|
||||
return voltage;
|
||||
|
||||
} else if (sensor == AB8500_SENSOR_BAT_CTRL) {
|
||||
*temp = ab8500_btemp_get_batctrl_temp(ab8500_data->btemp);
|
||||
} else if (sensor == AB8500_SENSOR_AUX1) {
|
||||
ret = iio_read_channel_processed(ab8500_data->aux1, &voltage);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = ab8500_voltage_to_temp(&ab8500_data->cfg, voltage, temp);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else if (sensor == AB8500_SENSOR_AUX2) {
|
||||
ret = iio_read_channel_processed(ab8500_data->aux2, &voltage);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = ab8500_voltage_to_temp(&ab8500_data->cfg, voltage, temp);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
@ -164,10 +175,6 @@ int abx500_hwmon_init(struct abx500_temp *data)
|
|||
if (!ab8500_data)
|
||||
return -ENOMEM;
|
||||
|
||||
ab8500_data->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
if (IS_ERR(ab8500_data->gpadc))
|
||||
return PTR_ERR(ab8500_data->gpadc);
|
||||
|
||||
ab8500_data->btemp = ab8500_btemp_get();
|
||||
if (IS_ERR(ab8500_data->btemp))
|
||||
return PTR_ERR(ab8500_data->btemp);
|
||||
|
@ -181,15 +188,25 @@ int abx500_hwmon_init(struct abx500_temp *data)
|
|||
ab8500_data->cfg.tbl_sz = ab8500_temp_tbl_a_size;
|
||||
|
||||
data->plat_data = ab8500_data;
|
||||
ab8500_data->aux1 = devm_iio_channel_get(&data->pdev->dev, "aux1");
|
||||
if (IS_ERR(ab8500_data->aux1)) {
|
||||
if (PTR_ERR(ab8500_data->aux1) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&data->pdev->dev, "failed to get AUX1 ADC channel\n");
|
||||
return PTR_ERR(ab8500_data->aux1);
|
||||
}
|
||||
ab8500_data->aux2 = devm_iio_channel_get(&data->pdev->dev, "aux2");
|
||||
if (IS_ERR(ab8500_data->aux2)) {
|
||||
if (PTR_ERR(ab8500_data->aux2) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&data->pdev->dev, "failed to get AUX2 ADC channel\n");
|
||||
return PTR_ERR(ab8500_data->aux2);
|
||||
}
|
||||
|
||||
/*
|
||||
* ADC_AUX1 and ADC_AUX2, connected to external NTC
|
||||
* BTEMP_BALL and BAT_CTRL, fixed usage
|
||||
*/
|
||||
data->gpadc_addr[0] = ADC_AUX1;
|
||||
data->gpadc_addr[1] = ADC_AUX2;
|
||||
data->gpadc_addr[2] = BTEMP_BALL;
|
||||
data->gpadc_addr[3] = BAT_CTRL;
|
||||
data->gpadc_addr[0] = AB8500_SENSOR_AUX1;
|
||||
data->gpadc_addr[1] = AB8500_SENSOR_AUX2;
|
||||
data->gpadc_addr[2] = AB8500_SENSOR_BTEMP_BALL;
|
||||
data->gpadc_addr[3] = AB8500_SENSOR_BAT_CTRL;
|
||||
data->monitored_sensors = NUM_MONITORED_SENSORS;
|
||||
|
||||
data->ops.read_sensor = ab8500_read_sensor;
|
||||
|
|
|
@ -6,6 +6,16 @@
|
|||
|
||||
menu "Analog to digital converters"
|
||||
|
||||
config AB8500_GPADC
|
||||
bool "ST-Ericsson AB8500 GPADC driver"
|
||||
depends on AB8500_CORE && REGULATOR_AB8500
|
||||
default y
|
||||
help
|
||||
AB8500 Analog Baseband, mixed signal integrated circuit GPADC
|
||||
(General Purpose Analog to Digital Converter) driver used to monitor
|
||||
internal voltages, convert accessory and battery, AC (charger, mains)
|
||||
and USB voltages integral to the U8500 platform.
|
||||
|
||||
config AD_SIGMA_DELTA
|
||||
tristate
|
||||
select IIO_BUFFER
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
|
||||
# When adding new entries keep the list in alphabetical order
|
||||
obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o
|
||||
obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o
|
||||
obj-$(CONFIG_AD7124) += ad7124.o
|
||||
obj-$(CONFIG_AD7266) += ad7266.o
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1210,13 +1210,6 @@ config AB8500_DEBUG
|
|||
Select this option if you want debug information using the debug
|
||||
filesystem, debugfs.
|
||||
|
||||
config AB8500_GPADC
|
||||
bool "ST-Ericsson AB8500 GPADC driver"
|
||||
depends on AB8500_CORE && REGULATOR_AB8500
|
||||
default y
|
||||
help
|
||||
AB8500 GPADC driver used to convert Acc and battery/ac/usb voltage
|
||||
|
||||
config MFD_DB8500_PRCMU
|
||||
bool "ST-Ericsson DB8500 Power Reset Control Management Unit"
|
||||
depends on UX500_SOC_DB8500
|
||||
|
|
|
@ -177,7 +177,6 @@ obj-$(CONFIG_ABX500_CORE) += abx500-core.o
|
|||
obj-$(CONFIG_AB3100_CORE) += ab3100-core.o
|
||||
obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o
|
||||
obj-$(CONFIG_AB8500_DEBUG) += ab8500-debugfs.o
|
||||
obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o
|
||||
obj-$(CONFIG_MFD_DB8500_PRCMU) += db8500-prcmu.o
|
||||
# ab8500-core need to come after db8500-prcmu (which provides the channel)
|
||||
obj-$(CONFIG_AB8500_CORE) += ab8500-core.o ab8500-sysctrl.o
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
|
||||
#include <linux/mfd/abx500.h>
|
||||
#include <linux/mfd/abx500/ab8500.h>
|
||||
#include <linux/mfd/abx500/ab8500-gpadc.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
#include <linux/string.h>
|
||||
|
@ -103,11 +102,6 @@ static int num_irqs;
|
|||
static struct device_attribute **dev_attr;
|
||||
static char **event_name;
|
||||
|
||||
static u8 avg_sample = SAMPLE_16;
|
||||
static u8 trig_edge = RISING_EDGE;
|
||||
static u8 conv_type = ADC_SW;
|
||||
static u8 trig_timer;
|
||||
|
||||
/**
|
||||
* struct ab8500_reg_range
|
||||
* @first: the first address of the range
|
||||
|
@ -152,7 +146,6 @@ static struct hwreg_cfg hwreg_cfg = {
|
|||
};
|
||||
|
||||
#define AB8500_NAME_STRING "ab8500"
|
||||
#define AB8500_ADC_NAME_STRING "gpadc"
|
||||
#define AB8500_NUM_BANKS AB8500_DEBUG_FIELD_LAST
|
||||
|
||||
#define AB8500_REV_REG 0x80
|
||||
|
@ -1646,633 +1639,6 @@ static int ab8500_modem_show(struct seq_file *s, void *p)
|
|||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_modem);
|
||||
|
||||
static int ab8500_gpadc_bat_ctrl_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int bat_ctrl_raw;
|
||||
int bat_ctrl_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
BAT_CTRL, bat_ctrl_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", bat_ctrl_convert, bat_ctrl_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_bat_ctrl);
|
||||
|
||||
static int ab8500_gpadc_btemp_ball_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int btemp_ball_raw;
|
||||
int btemp_ball_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
|
||||
btemp_ball_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_btemp_ball);
|
||||
|
||||
static int ab8500_gpadc_main_charger_v_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int main_charger_v_raw;
|
||||
int main_charger_v_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
MAIN_CHARGER_V, main_charger_v_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", main_charger_v_convert, main_charger_v_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_charger_v);
|
||||
|
||||
static int ab8500_gpadc_acc_detect1_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int acc_detect1_raw;
|
||||
int acc_detect1_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
|
||||
acc_detect1_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", acc_detect1_convert, acc_detect1_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_acc_detect1);
|
||||
|
||||
static int ab8500_gpadc_acc_detect2_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int acc_detect2_raw;
|
||||
int acc_detect2_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
ACC_DETECT2, acc_detect2_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", acc_detect2_convert, acc_detect2_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_acc_detect2);
|
||||
|
||||
static int ab8500_gpadc_aux1_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int aux1_raw;
|
||||
int aux1_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
|
||||
aux1_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", aux1_convert, aux1_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_aux1);
|
||||
|
||||
static int ab8500_gpadc_aux2_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int aux2_raw;
|
||||
int aux2_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
|
||||
aux2_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", aux2_convert, aux2_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_aux2);
|
||||
|
||||
static int ab8500_gpadc_main_bat_v_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int main_bat_v_raw;
|
||||
int main_bat_v_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
|
||||
main_bat_v_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", main_bat_v_convert, main_bat_v_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_bat_v);
|
||||
|
||||
static int ab8500_gpadc_vbus_v_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int vbus_v_raw;
|
||||
int vbus_v_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
|
||||
vbus_v_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", vbus_v_convert, vbus_v_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_vbus_v);
|
||||
|
||||
static int ab8500_gpadc_main_charger_c_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int main_charger_c_raw;
|
||||
int main_charger_c_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
MAIN_CHARGER_C, main_charger_c_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", main_charger_c_convert, main_charger_c_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_charger_c);
|
||||
|
||||
static int ab8500_gpadc_usb_charger_c_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int usb_charger_c_raw;
|
||||
int usb_charger_c_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
USB_CHARGER_C, usb_charger_c_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", usb_charger_c_convert, usb_charger_c_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_usb_charger_c);
|
||||
|
||||
static int ab8500_gpadc_bk_bat_v_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int bk_bat_v_raw;
|
||||
int bk_bat_v_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
BK_BAT_V, bk_bat_v_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", bk_bat_v_convert, bk_bat_v_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_bk_bat_v);
|
||||
|
||||
static int ab8500_gpadc_die_temp_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int die_temp_raw;
|
||||
int die_temp_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
|
||||
die_temp_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", die_temp_convert, die_temp_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_die_temp);
|
||||
|
||||
static int ab8500_gpadc_usb_id_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int usb_id_raw;
|
||||
int usb_id_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID,
|
||||
usb_id_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", usb_id_convert, usb_id_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_usb_id);
|
||||
|
||||
static int ab8540_gpadc_xtal_temp_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int xtal_temp_raw;
|
||||
int xtal_temp_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP,
|
||||
xtal_temp_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", xtal_temp_convert, xtal_temp_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_xtal_temp);
|
||||
|
||||
static int ab8540_gpadc_vbat_true_meas_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int vbat_true_meas_raw;
|
||||
int vbat_true_meas_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS,
|
||||
avg_sample, trig_edge, trig_timer, conv_type);
|
||||
vbat_true_meas_convert =
|
||||
ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS,
|
||||
vbat_true_meas_raw);
|
||||
|
||||
seq_printf(s, "%d,0x%X\n", vbat_true_meas_convert, vbat_true_meas_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_true_meas);
|
||||
|
||||
static int ab8540_gpadc_bat_ctrl_and_ibat_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int bat_ctrl_raw;
|
||||
int bat_ctrl_convert;
|
||||
int ibat_raw;
|
||||
int ibat_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT,
|
||||
avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
|
||||
|
||||
bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL,
|
||||
bat_ctrl_raw);
|
||||
ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
|
||||
ibat_raw);
|
||||
|
||||
seq_printf(s,
|
||||
"%d,0x%X\n"
|
||||
"%d,0x%X\n",
|
||||
bat_ctrl_convert, bat_ctrl_raw,
|
||||
ibat_convert, ibat_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_bat_ctrl_and_ibat);
|
||||
|
||||
static int ab8540_gpadc_vbat_meas_and_ibat_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int vbat_meas_raw;
|
||||
int vbat_meas_convert;
|
||||
int ibat_raw;
|
||||
int ibat_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT,
|
||||
avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
|
||||
vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
|
||||
vbat_meas_raw);
|
||||
ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
|
||||
ibat_raw);
|
||||
|
||||
seq_printf(s,
|
||||
"%d,0x%X\n"
|
||||
"%d,0x%X\n",
|
||||
vbat_meas_convert, vbat_meas_raw,
|
||||
ibat_convert, ibat_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_meas_and_ibat);
|
||||
|
||||
static int ab8540_gpadc_vbat_true_meas_and_ibat_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int vbat_true_meas_raw;
|
||||
int vbat_true_meas_convert;
|
||||
int ibat_raw;
|
||||
int ibat_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc,
|
||||
VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge,
|
||||
trig_timer, conv_type, &ibat_raw);
|
||||
vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc,
|
||||
VBAT_TRUE_MEAS, vbat_true_meas_raw);
|
||||
ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
|
||||
ibat_raw);
|
||||
|
||||
seq_printf(s,
|
||||
"%d,0x%X\n"
|
||||
"%d,0x%X\n",
|
||||
vbat_true_meas_convert, vbat_true_meas_raw,
|
||||
ibat_convert, ibat_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_true_meas_and_ibat);
|
||||
|
||||
static int ab8540_gpadc_bat_temp_and_ibat_show(struct seq_file *s, void *p)
|
||||
{
|
||||
int bat_temp_raw;
|
||||
int bat_temp_convert;
|
||||
int ibat_raw;
|
||||
int ibat_convert;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT,
|
||||
avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
|
||||
bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
|
||||
bat_temp_raw);
|
||||
ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
|
||||
ibat_raw);
|
||||
|
||||
seq_printf(s,
|
||||
"%d,0x%X\n"
|
||||
"%d,0x%X\n",
|
||||
bat_temp_convert, bat_temp_raw,
|
||||
ibat_convert, ibat_raw);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_bat_temp_and_ibat);
|
||||
|
||||
static int ab8540_gpadc_otp_calib_show(struct seq_file *s, void *p)
|
||||
{
|
||||
struct ab8500_gpadc *gpadc;
|
||||
u16 vmain_l, vmain_h, btemp_l, btemp_h;
|
||||
u16 vbat_l, vbat_h, ibat_l, ibat_h;
|
||||
|
||||
gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h,
|
||||
&vbat_l, &vbat_h, &ibat_l, &ibat_h);
|
||||
seq_printf(s,
|
||||
"VMAIN_L:0x%X\n"
|
||||
"VMAIN_H:0x%X\n"
|
||||
"BTEMP_L:0x%X\n"
|
||||
"BTEMP_H:0x%X\n"
|
||||
"VBAT_L:0x%X\n"
|
||||
"VBAT_H:0x%X\n"
|
||||
"IBAT_L:0x%X\n"
|
||||
"IBAT_H:0x%X\n",
|
||||
vmain_l, vmain_h, btemp_l, btemp_h,
|
||||
vbat_l, vbat_h, ibat_l, ibat_h);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_otp_calib);
|
||||
|
||||
static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
|
||||
{
|
||||
seq_printf(s, "%d\n", avg_sample);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, ab8500_gpadc_avg_sample_print,
|
||||
inode->i_private);
|
||||
}
|
||||
|
||||
static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
|
||||
const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct device *dev = ((struct seq_file *)(file->private_data))->private;
|
||||
unsigned long user_avg_sample;
|
||||
int err;
|
||||
|
||||
err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
|
||||
|| (user_avg_sample == SAMPLE_8)
|
||||
|| (user_avg_sample == SAMPLE_16)) {
|
||||
avg_sample = (u8) user_avg_sample;
|
||||
} else {
|
||||
dev_err(dev,
|
||||
"debugfs err input: should be egal to 1, 4, 8 or 16\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations ab8500_gpadc_avg_sample_fops = {
|
||||
.open = ab8500_gpadc_avg_sample_open,
|
||||
.read = seq_read,
|
||||
.write = ab8500_gpadc_avg_sample_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
|
||||
{
|
||||
seq_printf(s, "%d\n", trig_edge);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, ab8500_gpadc_trig_edge_print,
|
||||
inode->i_private);
|
||||
}
|
||||
|
||||
static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
|
||||
const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct device *dev = ((struct seq_file *)(file->private_data))->private;
|
||||
unsigned long user_trig_edge;
|
||||
int err;
|
||||
|
||||
err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if ((user_trig_edge == RISING_EDGE)
|
||||
|| (user_trig_edge == FALLING_EDGE)) {
|
||||
trig_edge = (u8) user_trig_edge;
|
||||
} else {
|
||||
dev_err(dev, "Wrong input:\n"
|
||||
"Enter 0. Rising edge\n"
|
||||
"Enter 1. Falling edge\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations ab8500_gpadc_trig_edge_fops = {
|
||||
.open = ab8500_gpadc_trig_edge_open,
|
||||
.read = seq_read,
|
||||
.write = ab8500_gpadc_trig_edge_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
|
||||
{
|
||||
seq_printf(s, "%d\n", trig_timer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, ab8500_gpadc_trig_timer_print,
|
||||
inode->i_private);
|
||||
}
|
||||
|
||||
static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
|
||||
const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct device *dev = ((struct seq_file *)(file->private_data))->private;
|
||||
unsigned long user_trig_timer;
|
||||
int err;
|
||||
|
||||
err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (user_trig_timer & ~0xFF) {
|
||||
dev_err(dev,
|
||||
"debugfs error input: should be between 0 to 255\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
trig_timer = (u8) user_trig_timer;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations ab8500_gpadc_trig_timer_fops = {
|
||||
.open = ab8500_gpadc_trig_timer_open,
|
||||
.read = seq_read,
|
||||
.write = ab8500_gpadc_trig_timer_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
|
||||
{
|
||||
seq_printf(s, "%d\n", conv_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return single_open(file, ab8500_gpadc_conv_type_print,
|
||||
inode->i_private);
|
||||
}
|
||||
|
||||
static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
|
||||
const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct device *dev = ((struct seq_file *)(file->private_data))->private;
|
||||
unsigned long user_conv_type;
|
||||
int err;
|
||||
|
||||
err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if ((user_conv_type == ADC_SW)
|
||||
|| (user_conv_type == ADC_HW)) {
|
||||
conv_type = (u8) user_conv_type;
|
||||
} else {
|
||||
dev_err(dev, "Wrong input:\n"
|
||||
"Enter 0. ADC SW conversion\n"
|
||||
"Enter 1. ADC HW conversion\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations ab8500_gpadc_conv_type_fops = {
|
||||
.open = ab8500_gpadc_conv_type_open,
|
||||
.read = seq_read,
|
||||
.write = ab8500_gpadc_conv_type_write,
|
||||
.llseek = seq_lseek,
|
||||
.release = single_release,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
/*
|
||||
* return length of an ASCII numerical value, 0 is string is not a
|
||||
* numerical value.
|
||||
|
@ -2647,7 +2013,6 @@ static const struct file_operations ab8500_hwreg_fops = {
|
|||
static int ab8500_debug_probe(struct platform_device *plf)
|
||||
{
|
||||
struct dentry *ab8500_dir;
|
||||
struct dentry *ab8500_gpadc_dir;
|
||||
struct ab8500 *ab8500;
|
||||
struct resource *res;
|
||||
|
||||
|
@ -2689,9 +2054,6 @@ static int ab8500_debug_probe(struct platform_device *plf)
|
|||
|
||||
ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
|
||||
|
||||
ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
|
||||
ab8500_dir);
|
||||
|
||||
debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir,
|
||||
&plf->dev, &ab8500_bank_registers_fops);
|
||||
debugfs_create_file("all-banks", S_IRUGO, ab8500_dir,
|
||||
|
@ -2727,83 +2089,6 @@ static int ab8500_debug_probe(struct platform_device *plf)
|
|||
&plf->dev, &ab8500_hwreg_fops);
|
||||
debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_dir, &plf->dev, &ab8500_modem_fops);
|
||||
debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_bat_ctrl_fops);
|
||||
debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_btemp_ball_fops);
|
||||
debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_main_charger_v_fops);
|
||||
debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_acc_detect1_fops);
|
||||
debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_acc_detect2_fops);
|
||||
debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_aux1_fops);
|
||||
debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_aux2_fops);
|
||||
debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_main_bat_v_fops);
|
||||
debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_vbus_v_fops);
|
||||
debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_main_charger_c_fops);
|
||||
debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_usb_charger_c_fops);
|
||||
debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_bk_bat_v_fops);
|
||||
debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_die_temp_fops);
|
||||
debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_usb_id_fops);
|
||||
if (is_ab8540(ab8500)) {
|
||||
debugfs_create_file("xtal_temp", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_xtal_temp_fops);
|
||||
debugfs_create_file("vbattruemeas", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_vbat_true_meas_fops);
|
||||
debugfs_create_file("batctrl_and_ibat", (S_IRUGO | S_IWUGO),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_bat_ctrl_and_ibat_fops);
|
||||
debugfs_create_file("vbatmeas_and_ibat", (S_IRUGO | S_IWUGO),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_vbat_meas_and_ibat_fops);
|
||||
debugfs_create_file("vbattruemeas_and_ibat", (S_IRUGO | S_IWUGO),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_vbat_true_meas_and_ibat_fops);
|
||||
debugfs_create_file("battemp_and_ibat", (S_IRUGO | S_IWUGO),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_bat_temp_and_ibat_fops);
|
||||
debugfs_create_file("otp_calib", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8540_gpadc_otp_calib_fops);
|
||||
}
|
||||
debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_avg_sample_fops);
|
||||
debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_trig_edge_fops);
|
||||
debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_trig_timer_fops);
|
||||
debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP),
|
||||
ab8500_gpadc_dir, &plf->dev,
|
||||
&ab8500_gpadc_conv_type_fops);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -629,7 +629,7 @@ config BATTERY_GAUGE_LTC2941
|
|||
|
||||
config AB8500_BM
|
||||
bool "AB8500 Battery Management Driver"
|
||||
depends on AB8500_CORE && AB8500_GPADC
|
||||
depends on AB8500_CORE && AB8500_GPADC && (IIO = y)
|
||||
help
|
||||
Say Y to include support for AB8500 battery management.
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <linux/mfd/abx500.h>
|
||||
#include <linux/mfd/abx500/ab8500.h>
|
||||
#include <linux/mfd/abx500/ab8500-bm.h>
|
||||
#include <linux/mfd/abx500/ab8500-gpadc.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
|
||||
#define VTVOUT_V 1800
|
||||
|
||||
|
@ -79,7 +79,8 @@ struct ab8500_btemp_ranges {
|
|||
* @bat_temp: Dispatched battery temperature in degree Celsius
|
||||
* @prev_bat_temp Last measured battery temperature in degree Celsius
|
||||
* @parent: Pointer to the struct ab8500
|
||||
* @gpadc: Pointer to the struct gpadc
|
||||
* @adc_btemp_ball: ADC channel for the battery ball temperature
|
||||
* @adc_bat_ctrl: ADC channel for the battery control
|
||||
* @fg: Pointer to the struct fg
|
||||
* @bm: Platform specific battery management information
|
||||
* @btemp_psy: Structure for BTEMP specific battery properties
|
||||
|
@ -96,7 +97,8 @@ struct ab8500_btemp {
|
|||
int bat_temp;
|
||||
int prev_bat_temp;
|
||||
struct ab8500 *parent;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
struct iio_channel *btemp_ball;
|
||||
struct iio_channel *bat_ctrl;
|
||||
struct ab8500_fg *fg;
|
||||
struct abx500_bm_data *bm;
|
||||
struct power_supply *btemp_psy;
|
||||
|
@ -177,13 +179,13 @@ static int ab8500_btemp_batctrl_volt_to_res(struct ab8500_btemp *di,
|
|||
*/
|
||||
static int ab8500_btemp_read_batctrl_voltage(struct ab8500_btemp *di)
|
||||
{
|
||||
int vbtemp;
|
||||
int vbtemp, ret;
|
||||
static int prev;
|
||||
|
||||
vbtemp = ab8500_gpadc_convert(di->gpadc, BAT_CTRL);
|
||||
if (vbtemp < 0) {
|
||||
ret = iio_read_channel_processed(di->bat_ctrl, &vbtemp);
|
||||
if (ret < 0) {
|
||||
dev_err(di->dev,
|
||||
"%s gpadc conversion failed, using previous value",
|
||||
"%s ADC conversion failed, using previous value",
|
||||
__func__);
|
||||
return prev;
|
||||
}
|
||||
|
@ -455,7 +457,7 @@ static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di,
|
|||
*/
|
||||
static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
|
||||
{
|
||||
int temp;
|
||||
int temp, ret;
|
||||
static int prev;
|
||||
int rbat, rntc, vntc;
|
||||
u8 id;
|
||||
|
@ -480,10 +482,10 @@ static int ab8500_btemp_measure_temp(struct ab8500_btemp *di)
|
|||
di->bm->bat_type[id].r_to_t_tbl,
|
||||
di->bm->bat_type[id].n_temp_tbl_elements, rbat);
|
||||
} else {
|
||||
vntc = ab8500_gpadc_convert(di->gpadc, BTEMP_BALL);
|
||||
if (vntc < 0) {
|
||||
ret = iio_read_channel_processed(di->btemp_ball, &vntc);
|
||||
if (ret < 0) {
|
||||
dev_err(di->dev,
|
||||
"%s gpadc conversion failed,"
|
||||
"%s ADC conversion failed,"
|
||||
" using previous value\n", __func__);
|
||||
return prev;
|
||||
}
|
||||
|
@ -1024,7 +1026,22 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
|
|||
/* get parent data */
|
||||
di->dev = &pdev->dev;
|
||||
di->parent = dev_get_drvdata(pdev->dev.parent);
|
||||
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
|
||||
/* Get ADC channels */
|
||||
di->btemp_ball = devm_iio_channel_get(&pdev->dev, "btemp_ball");
|
||||
if (IS_ERR(di->btemp_ball)) {
|
||||
if (PTR_ERR(di->btemp_ball) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get BTEMP BALL ADC channel\n");
|
||||
return PTR_ERR(di->btemp_ball);
|
||||
}
|
||||
di->bat_ctrl = devm_iio_channel_get(&pdev->dev, "bat_ctrl");
|
||||
if (IS_ERR(di->bat_ctrl)) {
|
||||
if (PTR_ERR(di->bat_ctrl) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get BAT CTRL ADC channel\n");
|
||||
return PTR_ERR(di->bat_ctrl);
|
||||
}
|
||||
|
||||
di->initialized = false;
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#include <linux/mfd/abx500/ab8500.h>
|
||||
#include <linux/mfd/abx500.h>
|
||||
#include <linux/mfd/abx500/ab8500-bm.h>
|
||||
#include <linux/mfd/abx500/ab8500-gpadc.h>
|
||||
#include <linux/mfd/abx500/ux500_chargalg.h>
|
||||
#include <linux/usb/otg.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
|
||||
/* Charger constants */
|
||||
#define NO_PW_CONN 0
|
||||
|
@ -233,7 +233,10 @@ struct ab8500_charger_max_usb_in_curr {
|
|||
* @current_stepping_sessions:
|
||||
* Counter for current stepping sessions
|
||||
* @parent: Pointer to the struct ab8500
|
||||
* @gpadc: Pointer to the struct gpadc
|
||||
* @adc_main_charger_v ADC channel for main charger voltage
|
||||
* @adc_main_charger_c ADC channel for main charger current
|
||||
* @adc_vbus_v ADC channel for USB charger voltage
|
||||
* @adc_usb_charger_c ADC channel for USB charger current
|
||||
* @bm: Platform specific battery management information
|
||||
* @flags: Structure for information about events triggered
|
||||
* @usb_state: Structure for usb stack information
|
||||
|
@ -283,7 +286,10 @@ struct ab8500_charger {
|
|||
int is_aca_rid;
|
||||
atomic_t current_stepping_sessions;
|
||||
struct ab8500 *parent;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
struct iio_channel *adc_main_charger_v;
|
||||
struct iio_channel *adc_main_charger_c;
|
||||
struct iio_channel *adc_vbus_v;
|
||||
struct iio_channel *adc_usb_charger_c;
|
||||
struct abx500_bm_data *bm;
|
||||
struct ab8500_charger_event_flags flags;
|
||||
struct ab8500_charger_usb_state usb_state;
|
||||
|
@ -459,13 +465,13 @@ static void ab8500_charger_set_usb_connected(struct ab8500_charger *di,
|
|||
*/
|
||||
static int ab8500_charger_get_ac_voltage(struct ab8500_charger *di)
|
||||
{
|
||||
int vch;
|
||||
int vch, ret;
|
||||
|
||||
/* Only measure voltage if the charger is connected */
|
||||
if (di->ac.charger_connected) {
|
||||
vch = ab8500_gpadc_convert(di->gpadc, MAIN_CHARGER_V);
|
||||
if (vch < 0)
|
||||
dev_err(di->dev, "%s gpadc conv failed,\n", __func__);
|
||||
ret = iio_read_channel_processed(di->adc_main_charger_v, &vch);
|
||||
if (ret < 0)
|
||||
dev_err(di->dev, "%s ADC conv failed,\n", __func__);
|
||||
} else {
|
||||
vch = 0;
|
||||
}
|
||||
|
@ -510,13 +516,13 @@ static int ab8500_charger_ac_cv(struct ab8500_charger *di)
|
|||
*/
|
||||
static int ab8500_charger_get_vbus_voltage(struct ab8500_charger *di)
|
||||
{
|
||||
int vch;
|
||||
int vch, ret;
|
||||
|
||||
/* Only measure voltage if the charger is connected */
|
||||
if (di->usb.charger_connected) {
|
||||
vch = ab8500_gpadc_convert(di->gpadc, VBUS_V);
|
||||
if (vch < 0)
|
||||
dev_err(di->dev, "%s gpadc conv failed\n", __func__);
|
||||
ret = iio_read_channel_processed(di->adc_vbus_v, &vch);
|
||||
if (ret < 0)
|
||||
dev_err(di->dev, "%s ADC conv failed,\n", __func__);
|
||||
} else {
|
||||
vch = 0;
|
||||
}
|
||||
|
@ -532,13 +538,13 @@ static int ab8500_charger_get_vbus_voltage(struct ab8500_charger *di)
|
|||
*/
|
||||
static int ab8500_charger_get_usb_current(struct ab8500_charger *di)
|
||||
{
|
||||
int ich;
|
||||
int ich, ret;
|
||||
|
||||
/* Only measure current if the charger is online */
|
||||
if (di->usb.charger_online) {
|
||||
ich = ab8500_gpadc_convert(di->gpadc, USB_CHARGER_C);
|
||||
if (ich < 0)
|
||||
dev_err(di->dev, "%s gpadc conv failed\n", __func__);
|
||||
ret = iio_read_channel_processed(di->adc_usb_charger_c, &ich);
|
||||
if (ret < 0)
|
||||
dev_err(di->dev, "%s ADC conv failed,\n", __func__);
|
||||
} else {
|
||||
ich = 0;
|
||||
}
|
||||
|
@ -554,13 +560,13 @@ static int ab8500_charger_get_usb_current(struct ab8500_charger *di)
|
|||
*/
|
||||
static int ab8500_charger_get_ac_current(struct ab8500_charger *di)
|
||||
{
|
||||
int ich;
|
||||
int ich, ret;
|
||||
|
||||
/* Only measure current if the charger is online */
|
||||
if (di->ac.charger_online) {
|
||||
ich = ab8500_gpadc_convert(di->gpadc, MAIN_CHARGER_C);
|
||||
if (ich < 0)
|
||||
dev_err(di->dev, "%s gpadc conv failed\n", __func__);
|
||||
ret = iio_read_channel_processed(di->adc_main_charger_c, &ich);
|
||||
if (ret < 0)
|
||||
dev_err(di->dev, "%s ADC conv failed,\n", __func__);
|
||||
} else {
|
||||
ich = 0;
|
||||
}
|
||||
|
@ -3371,7 +3377,39 @@ static int ab8500_charger_probe(struct platform_device *pdev)
|
|||
/* get parent data */
|
||||
di->dev = &pdev->dev;
|
||||
di->parent = dev_get_drvdata(pdev->dev.parent);
|
||||
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
|
||||
/* Get ADC channels */
|
||||
di->adc_main_charger_v = devm_iio_channel_get(&pdev->dev,
|
||||
"main_charger_v");
|
||||
if (IS_ERR(di->adc_main_charger_v)) {
|
||||
if (PTR_ERR(di->adc_main_charger_v) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get ADC main charger voltage\n");
|
||||
return PTR_ERR(di->adc_main_charger_v);
|
||||
}
|
||||
di->adc_main_charger_c = devm_iio_channel_get(&pdev->dev,
|
||||
"main_charger_c");
|
||||
if (IS_ERR(di->adc_main_charger_c)) {
|
||||
if (PTR_ERR(di->adc_main_charger_c) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get ADC main charger current\n");
|
||||
return PTR_ERR(di->adc_main_charger_v);
|
||||
}
|
||||
di->adc_vbus_v = devm_iio_channel_get(&pdev->dev, "vbus_v");
|
||||
if (IS_ERR(di->adc_vbus_v)) {
|
||||
if (PTR_ERR(di->adc_vbus_v) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get ADC USB charger voltage\n");
|
||||
return PTR_ERR(di->adc_vbus_v);
|
||||
}
|
||||
di->adc_usb_charger_c = devm_iio_channel_get(&pdev->dev,
|
||||
"usb_charger_c");
|
||||
if (IS_ERR(di->adc_usb_charger_c)) {
|
||||
if (PTR_ERR(di->adc_usb_charger_c) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get ADC USB charger current\n");
|
||||
return PTR_ERR(di->adc_usb_charger_c);
|
||||
}
|
||||
|
||||
/* initialize lock */
|
||||
spin_lock_init(&di->usb_state.usb_lock);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <linux/mfd/abx500.h>
|
||||
#include <linux/mfd/abx500/ab8500.h>
|
||||
#include <linux/mfd/abx500/ab8500-bm.h>
|
||||
#include <linux/mfd/abx500/ab8500-gpadc.h>
|
||||
#include <linux/iio/consumer.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#define MILLI_TO_MICRO 1000
|
||||
|
@ -182,7 +182,7 @@ struct inst_curr_result_list {
|
|||
* @bat_cap: Structure for battery capacity specific parameters
|
||||
* @avg_cap: Average capacity filter
|
||||
* @parent: Pointer to the struct ab8500
|
||||
* @gpadc: Pointer to the struct gpadc
|
||||
* @main_bat_v: ADC channel for the main battery voltage
|
||||
* @bm: Platform specific battery management information
|
||||
* @fg_psy: Structure that holds the FG specific battery properties
|
||||
* @fg_wq: Work queue for running the FG algorithm
|
||||
|
@ -224,7 +224,7 @@ struct ab8500_fg {
|
|||
struct ab8500_fg_battery_capacity bat_cap;
|
||||
struct ab8500_fg_avg_cap avg_cap;
|
||||
struct ab8500 *parent;
|
||||
struct ab8500_gpadc *gpadc;
|
||||
struct iio_channel *main_bat_v;
|
||||
struct abx500_bm_data *bm;
|
||||
struct power_supply *fg_psy;
|
||||
struct workqueue_struct *fg_wq;
|
||||
|
@ -829,13 +829,13 @@ static void ab8500_fg_acc_cur_work(struct work_struct *work)
|
|||
*/
|
||||
static int ab8500_fg_bat_voltage(struct ab8500_fg *di)
|
||||
{
|
||||
int vbat;
|
||||
int vbat, ret;
|
||||
static int prev;
|
||||
|
||||
vbat = ab8500_gpadc_convert(di->gpadc, MAIN_BAT_V);
|
||||
if (vbat < 0) {
|
||||
ret = iio_read_channel_processed(di->main_bat_v, &vbat);
|
||||
if (ret < 0) {
|
||||
dev_err(di->dev,
|
||||
"%s gpadc conversion failed, using previous value\n",
|
||||
"%s ADC conversion failed, using previous value\n",
|
||||
__func__);
|
||||
return prev;
|
||||
}
|
||||
|
@ -3066,7 +3066,14 @@ static int ab8500_fg_probe(struct platform_device *pdev)
|
|||
/* get parent data */
|
||||
di->dev = &pdev->dev;
|
||||
di->parent = dev_get_drvdata(pdev->dev.parent);
|
||||
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
|
||||
|
||||
di->main_bat_v = devm_iio_channel_get(&pdev->dev, "main_bat_v");
|
||||
if (IS_ERR(di->main_bat_v)) {
|
||||
if (PTR_ERR(di->main_bat_v) == -ENODEV)
|
||||
return -EPROBE_DEFER;
|
||||
dev_err(&pdev->dev, "failed to get main battery ADC channel\n");
|
||||
return PTR_ERR(di->main_bat_v);
|
||||
}
|
||||
|
||||
psy_cfg.supplied_to = supply_interface;
|
||||
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2010 ST-Ericsson SA
|
||||
*
|
||||
* Author: Arun R Murthy <arun.murthy@stericsson.com>
|
||||
* Author: Daniel Willerud <daniel.willerud@stericsson.com>
|
||||
* Author: M'boumba Cedric Madianga <cedric.madianga@stericsson.com>
|
||||
*/
|
||||
|
||||
#ifndef _AB8500_GPADC_H
|
||||
#define _AB8500_GPADC_H
|
||||
|
||||
/* GPADC source: From datasheet(ADCSwSel[4:0] in GPADCCtrl2
|
||||
* and ADCHwSel[4:0] in GPADCCtrl3 ) */
|
||||
#define BAT_CTRL 0x01
|
||||
#define BTEMP_BALL 0x02
|
||||
#define MAIN_CHARGER_V 0x03
|
||||
#define ACC_DETECT1 0x04
|
||||
#define ACC_DETECT2 0x05
|
||||
#define ADC_AUX1 0x06
|
||||
#define ADC_AUX2 0x07
|
||||
#define MAIN_BAT_V 0x08
|
||||
#define VBUS_V 0x09
|
||||
#define MAIN_CHARGER_C 0x0A
|
||||
#define USB_CHARGER_C 0x0B
|
||||
#define BK_BAT_V 0x0C
|
||||
#define DIE_TEMP 0x0D
|
||||
#define USB_ID 0x0E
|
||||
#define XTAL_TEMP 0x12
|
||||
#define VBAT_TRUE_MEAS 0x13
|
||||
#define BAT_CTRL_AND_IBAT 0x1C
|
||||
#define VBAT_MEAS_AND_IBAT 0x1D
|
||||
#define VBAT_TRUE_MEAS_AND_IBAT 0x1E
|
||||
#define BAT_TEMP_AND_IBAT 0x1F
|
||||
|
||||
/* Virtual channel used only for ibat convertion to ampere
|
||||
* Battery current conversion (ibat) cannot be requested as a single conversion
|
||||
* but it is always in combination with other input requests
|
||||
*/
|
||||
#define IBAT_VIRTUAL_CHANNEL 0xFF
|
||||
|
||||
#define SAMPLE_1 1
|
||||
#define SAMPLE_4 4
|
||||
#define SAMPLE_8 8
|
||||
#define SAMPLE_16 16
|
||||
#define RISING_EDGE 0
|
||||
#define FALLING_EDGE 1
|
||||
|
||||
/* Arbitrary ADC conversion type constants */
|
||||
#define ADC_SW 0
|
||||
#define ADC_HW 1
|
||||
|
||||
struct ab8500_gpadc;
|
||||
|
||||
struct ab8500_gpadc *ab8500_gpadc_get(char *name);
|
||||
int ab8500_gpadc_sw_hw_convert(struct ab8500_gpadc *gpadc, u8 channel,
|
||||
u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
|
||||
static inline int ab8500_gpadc_convert(struct ab8500_gpadc *gpadc, u8 channel)
|
||||
{
|
||||
return ab8500_gpadc_sw_hw_convert(gpadc, channel,
|
||||
SAMPLE_16, 0, 0, ADC_SW);
|
||||
}
|
||||
|
||||
int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
|
||||
u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type);
|
||||
int ab8500_gpadc_double_read_raw(struct ab8500_gpadc *gpadc, u8 channel,
|
||||
u8 avg_sample, u8 trig_edge, u8 trig_timer, u8 conv_type,
|
||||
int *ibat);
|
||||
int ab8500_gpadc_ad_to_voltage(struct ab8500_gpadc *gpadc,
|
||||
u8 channel, int ad_value);
|
||||
void ab8540_gpadc_get_otp(struct ab8500_gpadc *gpadc,
|
||||
u16 *vmain_l, u16 *vmain_h, u16 *btemp_l, u16 *btemp_h,
|
||||
u16 *vbat_l, u16 *vbat_h, u16 *ibat_l, u16 *ibat_h);
|
||||
|
||||
#endif /* _AB8500_GPADC_H */
|
Loading…
Reference in New Issue