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,201 @@
/* 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.
*/
/*
* Qualcomm PMIC PM8xxx Battery Alarm driver
*
*/
#ifndef __MFD_PM8XXX_BATT_ALARM_H__
#define __MFD_PM8XXX_BATT_ALARM_H__
#include <linux/bitops.h>
#include <linux/errno.h>
#include <linux/notifier.h>
#define PM8XXX_BATT_ALARM_DEV_NAME "pm8xxx-batt-alarm"
/**
* enum pm8xxx_batt_alarm_core_data - PMIC core specific core passed into the
* batter alarm driver as platform data
* @irq_name:
* @reg_addr_batt_alarm_threshold: PMIC threshold register address
* @reg_addr_batt_alarm_ctrl1: PMIC control 1 register address
* @reg_addr_batt_alarm_ctrl2: PMIC control 2 register address
* @reg_addr_batt_alarm_pwm_ctrl: PMIC PWM control register address
*/
struct pm8xxx_batt_alarm_core_data {
char *irq_name;
u16 reg_addr_threshold;
u16 reg_addr_ctrl1;
u16 reg_addr_ctrl2;
u16 reg_addr_pwm_ctrl;
};
/**
* enum pm8xxx_batt_alarm_comparator - battery alarm comparator ID values
*/
enum pm8xxx_batt_alarm_comparator {
PM8XXX_BATT_ALARM_LOWER_COMPARATOR,
PM8XXX_BATT_ALARM_UPPER_COMPARATOR,
};
/**
* enum pm8xxx_batt_alarm_hold_time - hold time required for out of range
* battery voltage needed to trigger a status change. Enum names denote
* hold time in milliseconds.
*/
enum pm8xxx_batt_alarm_hold_time {
PM8XXX_BATT_ALARM_HOLD_TIME_0p125_MS = 0,
PM8XXX_BATT_ALARM_HOLD_TIME_0p25_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_0p5_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_1_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_2_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_4_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_8_MS,
PM8XXX_BATT_ALARM_HOLD_TIME_16_MS,
};
/*
* Bits that are set in the return value of pm8xxx_batt_alarm_status_read
* to indicate crossing of the upper or lower threshold.
*/
#define PM8XXX_BATT_ALARM_STATUS_BELOW_LOWER BIT(0)
#define PM8XXX_BATT_ALARM_STATUS_ABOVE_UPPER BIT(1)
#if defined(CONFIG_MFD_PM8XXX_BATT_ALARM) \
|| defined(CONFIG_MFD_PM8XXX_BATT_ALARM_MODULE)
/**
* pm8xxx_batt_alarm_enable - enable one of the battery voltage threshold
* comparators
* @comparator: selects which comparator to enable
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_enable(enum pm8xxx_batt_alarm_comparator comparator);
/**
* pm8xxx_batt_alarm_disable - disable one of the battery voltage threshold
* comparators
* @comparator: selects which comparator to disable
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_disable(enum pm8xxx_batt_alarm_comparator comparator);
/**
* pm8xxx_batt_alarm_threshold_set - set the lower and upper alarm thresholds
* @comparator: selects which comparator to set the threshold of
* @threshold_mV: battery voltage threshold in millivolts
* set points = 2500-5675 mV in 25 mV steps
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_threshold_set(
enum pm8xxx_batt_alarm_comparator comparator, int threshold_mV);
/**
* pm8xxx_batt_alarm_status_read - get status of both threshold comparators
*
* RETURNS: < 0 = error
* 0 = battery voltage ok
* BIT(0) set = battery voltage below lower threshold
* BIT(1) set = battery voltage above upper threshold
*/
int pm8xxx_batt_alarm_status_read(void);
/**
* pm8xxx_batt_alarm_register_notifier - register a notifier to run when a
* battery voltage change interrupt fires
* @nb: notifier block containing callback function to register
*
* nb->notifier_call must point to a function of this form -
* int (*notifier_call)(struct notifier_block *nb, unsigned long status,
* void *unused);
* "status" will receive the battery alarm status; "unused" will be NULL.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_register_notifier(struct notifier_block *nb);
/**
* pm8xxx_batt_alarm_unregister_notifier - unregister a notifier that is run
* when a battery voltage change interrupt fires
* @nb: notifier block containing callback function to unregister
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_unregister_notifier(struct notifier_block *nb);
/**
* pm8xxx_batt_alarm_hold_time_set - set hold time of interrupt output *
* @hold_time: amount of time that battery voltage must remain outside of the
* threshold range before the battery alarm interrupt triggers
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_hold_time_set(enum pm8xxx_batt_alarm_hold_time hold_time);
/**
* pm8xxx_batt_alarm_pwm_rate_set - set battery alarm update rate *
* @use_pwm: 1 = use PWM update rate, 0 = comparators always active
* @clock_scaler: PWM clock scaler = 2 to 9
* @clock_divider: PWM clock divider = 2 to 8
*
* This function sets the rate at which the battery alarm module enables
* the threshold comparators. The rate is determined by the following equation:
*
* f_update = (1024 Hz) / (clock_divider * (2 ^ clock_scaler))
*
* Thus, the update rate can range from 0.25 Hz to 128 Hz.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_batt_alarm_pwm_rate_set(int use_pwm, int clock_scaler,
int clock_divider);
#else
static inline int
pm8xxx_batt_alarm_enable(enum pm8xxx_batt_alarm_comparator comparator)
{ return -ENODEV; }
static inline int
pm8xxx_batt_alarm_disable(enum pm8xxx_batt_alarm_comparator comparator)
{ return -ENODEV; }
static inline int
pm8xxx_batt_alarm_threshold_set(enum pm8xxx_batt_alarm_comparator comparator,
int threshold_mV)
{ return -ENODEV; }
static inline int pm8xxx_batt_alarm_status_read(void)
{ return -ENODEV; }
static inline int pm8xxx_batt_alarm_register_notifier(struct notifier_block *nb)
{ return -ENODEV; }
static inline int
pm8xxx_batt_alarm_unregister_notifier(struct notifier_block *nb)
{ return -ENODEV; }
static inline int
pm8xxx_batt_alarm_hold_time_set(enum pm8xxx_batt_alarm_hold_time hold_time)
{ return -ENODEV; }
static inline int
pm8xxx_batt_alarm_pwm_rate_set(int use_pwm, int clock_scaler, int clock_divider)
{ return -ENODEV; }
#endif
#endif /* __MFD_PM8XXX_BATT_ALARM_H__ */
@@ -0,0 +1,166 @@
/* Copyright (c) 2012-2013, 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 __PM8XXX_BMS_BATTERYDATA_H
#define __PM8XXX_BMS_BATTERYDATA_H
#include <linux/errno.h>
#define FCC_CC_COLS 5
#define FCC_TEMP_COLS 8
#define PC_CC_ROWS 31
#define PC_CC_COLS 13
#define PC_TEMP_ROWS 31
#define PC_TEMP_COLS 8
#define MAX_SINGLE_LUT_COLS 20
struct single_row_lut {
int x[MAX_SINGLE_LUT_COLS];
int y[MAX_SINGLE_LUT_COLS];
int cols;
};
/**
* struct sf_lut -
* @rows: number of percent charge entries should be <= PC_CC_ROWS
* @cols: number of charge cycle entries should be <= PC_CC_COLS
* @row_entries: the charge cycles/temperature at which sf data
* is available in the table.
* The charge cycles must be in increasing order from 0 to rows.
* @percent: the percent charge at which sf data is available in the table
* The percentcharge must be in decreasing order from 0 to cols.
* @sf: the scaling factor data
*/
struct sf_lut {
int rows;
int cols;
int row_entries[PC_CC_COLS];
int percent[PC_CC_ROWS];
int sf[PC_CC_ROWS][PC_CC_COLS];
};
/**
* struct pc_temp_ocv_lut -
* @rows: number of percent charge entries should be <= PC_TEMP_ROWS
* @cols: number of temperature entries should be <= PC_TEMP_COLS
* @temp: the temperatures at which ocv data is available in the table
* The temperatures must be in increasing order from 0 to rows.
* @percent: the percent charge at which ocv data is available in the table
* The percentcharge must be in decreasing order from 0 to cols.
* @ocv: the open circuit voltage
*/
struct pc_temp_ocv_lut {
int rows;
int cols;
int temp[PC_TEMP_COLS];
int percent[PC_TEMP_ROWS];
int ocv[PC_TEMP_ROWS][PC_TEMP_COLS];
};
enum battery_type {
BATT_UNKNOWN = 0,
BATT_PALLADIUM,
BATT_DESAY,
BATT_OEM,
BATT_QRD_4V35_2000MAH,
};
/**
* struct bms_battery_data -
* @fcc: full charge capacity (mAmpHour)
* @fcc_temp_lut: table to get fcc at a given temp
* @pc_temp_ocv_lut: table to get percent charge given batt temp and cycles
* @pc_sf_lut: table to get percent charge scaling factor given cycles
* and percent charge
* @rbatt_sf_lut: table to get battery resistance scaling factor given
* temperature and percent charge
* @default_rbatt_mohm: the default value of battery resistance to use when
* readings from bms are not available.
* @delta_rbatt_mohm: the resistance to be added towards lower soc to
* compensate for battery capacitance.
* @rbatt_capacitve_mohm: the resistance to be added to compensate for
* battery capacitance
* @flat_ocv_threshold_uv: the voltage where the battery's discharge curve
* starts flattening out.
*/
struct bms_battery_data {
unsigned int fcc;
struct single_row_lut *fcc_temp_lut;
struct single_row_lut *fcc_sf_lut;
struct pc_temp_ocv_lut *pc_temp_ocv_lut;
struct sf_lut *pc_sf_lut;
struct sf_lut *rbatt_sf_lut;
int default_rbatt_mohm;
int delta_rbatt_mohm;
int rbatt_capacitive_mohm;
int flat_ocv_threshold_uv;
};
#if defined(CONFIG_PM8921_BMS) || \
defined(CONFIG_PM8921_BMS_MODULE) || \
defined(CONFIG_QPNP_BMS)
extern struct bms_battery_data palladium_1500_data;
extern struct bms_battery_data desay_5200_data;
extern struct bms_battery_data oem_batt_data;
extern struct bms_battery_data QRD_4v35_2000mAh_data;
int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp);
int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc);
int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut,
int cycles);
int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv,
int batt_temp_degc, int ocv);
int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv,
int batt_temp_degc, int pc);
int linear_interpolate(int y0, int x0, int y1, int x1, int x);
int is_between(int left, int right, int value);
#else
static inline int interpolate_fcc(struct single_row_lut *fcc_temp_lut,
int batt_temp)
{
return -EINVAL;
}
static inline int interpolate_scalingfactor(struct sf_lut *sf_lut,
int row_entry, int pc)
{
return -EINVAL;
}
static inline int interpolate_scalingfactor_fcc(
struct single_row_lut *fcc_sf_lut, int cycles)
{
return -EINVAL;
}
static inline int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv,
int batt_temp_degc, int ocv)
{
return -EINVAL;
}
static inline int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv,
int batt_temp_degc, int pc)
{
return -EINVAL;
}
static inline int linear_interpolate(int y0, int x0, int y1, int x1, int x)
{
return -EINVAL;
}
static inline int is_between(int left, int right, int value)
{
return -EINVAL;
}
#endif
#endif
+93
View File
@@ -0,0 +1,93 @@
/* Copyright (c) 2010-2013, 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 __PMIC8XXX_CCADC_H__
#define __PMIC8XXX_CCADC_H__
#include <linux/mfd/pm8xxx/core.h>
#define PM8XXX_CCADC_DEV_NAME "pm8xxx-ccadc"
struct pm8xxx_ccadc_core_data {
unsigned int batt_temp_channel;
};
/**
* struct pm8xxx_ccadc_platform_data -
* @ccadc_cdata: core data for the ccadc driver containing channel info
* @r_sense_uohm: sense resistor value in (micro Ohms)
* @calib_delay_ms: how often should the adc calculate gain and offset
* @periodic_wakeup: a flag to indicate that this system wakeups periodically
* for calibration/other housekeeping activities. The ccadc
* does a quick calibration while resuming
*/
struct pm8xxx_ccadc_platform_data {
struct pm8xxx_ccadc_core_data ccadc_cdata;
int r_sense_uohm;
unsigned int calib_delay_ms;
bool periodic_wakeup;
};
#define CCADC_READING_RESOLUTION_N 542535
#define CCADC_READING_RESOLUTION_D 100000
static inline s64 pm8xxx_ccadc_reading_to_microvolt(int revision, s64 cc)
{
return div_s64(cc * CCADC_READING_RESOLUTION_N,
CCADC_READING_RESOLUTION_D);
}
#if defined(CONFIG_PM8XXX_CCADC) || defined(CONFIG_PM8XXX_CCADC_MODULE)
/**
* pm8xxx_cc_adjust_for_gain - the function to adjust the voltage read from
* ccadc for gain compensation
* @v: the voltage which needs to be gain compensated in microVolts
*
*
* RETURNS: gain compensated voltage
*/
s64 pm8xxx_cc_adjust_for_gain(s64 uv);
/**
* pm8xxx_calib_ccadc - calibration for ccadc. This will calculate gain
* and offset and reprogram them in the appropriate
* registers
*/
void pm8xxx_calib_ccadc(void);
/**
* pm8xxx_ccadc_get_battery_current - return the battery current based on vsense
* resitor in microamperes
* @result: The pointer where the voltage will be updated. A -ve
* result means that the current is flowing in
* the battery - during battery charging
*
* RETURNS: Error code if there was a problem reading vsense, Zero otherwise
* The result won't be updated in case of an error.
*
*/
int pm8xxx_ccadc_get_battery_current(int *bat_current);
#else
static inline s64 pm8xxx_cc_adjust_for_gain(s64 uv)
{
return -ENXIO;
}
static inline void pm8xxx_calib_ccadc(void)
{
}
static inline int pm8xxx_ccadc_get_battery_current(int *bat_current)
{
return -ENXIO;
}
#endif
#endif /* __PMIC8XXX_CCADC_H__ */
+190
View File
@@ -0,0 +1,190 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8xxx driver header file
*
*/
#ifndef __MFD_PM8XXX_CORE_H
#define __MFD_PM8XXX_CORE_H
#include <linux/mfd/core.h>
enum pm8xxx_version {
PM8XXX_VERSION_8058,
PM8XXX_VERSION_8901,
PM8XXX_VERSION_8921,
PM8XXX_VERSION_8821,
PM8XXX_VERSION_8018,
PM8XXX_VERSION_8922,
PM8XXX_VERSION_8038,
PM8XXX_VERSION_8917,
};
/* PMIC version specific silicon revisions */
#define PM8XXX_REVISION_8058_TEST 0
#define PM8XXX_REVISION_8058_1p0 1
#define PM8XXX_REVISION_8058_2p0 2
#define PM8XXX_REVISION_8058_2p1 3
#define PM8XXX_REVISION_8901_TEST 0
#define PM8XXX_REVISION_8901_1p0 1
#define PM8XXX_REVISION_8901_1p1 2
#define PM8XXX_REVISION_8901_2p0 3
#define PM8XXX_REVISION_8901_2p1 4
#define PM8XXX_REVISION_8901_2p2 5
#define PM8XXX_REVISION_8901_2p3 6
#define PM8XXX_REVISION_8921_TEST 0
#define PM8XXX_REVISION_8921_1p0 1
#define PM8XXX_REVISION_8921_1p1 2
#define PM8XXX_REVISION_8921_2p0 3
#define PM8XXX_REVISION_8921_3p0 4
#define PM8XXX_REVISION_8921_3p1 5
#define PM8XXX_REVISION_8821_TEST 0
#define PM8XXX_REVISION_8821_1p0 1
#define PM8XXX_REVISION_8821_2p0 2
#define PM8XXX_REVISION_8821_2p1 3
#define PM8XXX_REVISION_8018_TEST 0
#define PM8XXX_REVISION_8018_1p0 1
#define PM8XXX_REVISION_8018_2p0 2
#define PM8XXX_REVISION_8018_2p1 3
#define PM8XXX_REVISION_8922_TEST 0
#define PM8XXX_REVISION_8922_1p0 1
#define PM8XXX_REVISION_8922_1p1 2
#define PM8XXX_REVISION_8922_2p0 3
#define PM8XXX_REVISION_8038_TEST 0
#define PM8XXX_REVISION_8038_1p0 1
#define PM8XXX_REVISION_8038_2p0 2
#define PM8XXX_REVISION_8038_2p1 3
#define PM8XXX_REVISION_8917_TEST 0
#define PM8XXX_REVISION_8917_1p0 1
#define PM8XXX_RESTART_UNKNOWN 0
#define PM8XXX_RESTART_CBL 1
#define PM8XXX_RESTART_KPD 2
#define PM8XXX_RESTART_CHG 3
#define PM8XXX_RESTART_SMPL 4
#define PM8XXX_RESTART_RTC 5
#define PM8XXX_RESTART_HARD_RESET 6
#define PM8XXX_RESTART_GEN_PURPOSE 7
#define PM8XXX_RESTART_REASON_MASK 0x07
static const char * const pm8xxx_restart_reason_str[] = {
[0] = "Unknown",
[1] = "Triggered from CBL (external charger)",
[2] = "Triggered from KPD (power key press)",
[3] = "Triggered from CHG (usb charger insertion)",
[4] = "Triggered from SMPL (sudden momentary power loss)",
[5] = "Triggered from RTC (real time clock)",
[6] = "Triggered by Hard Reset",
[7] = "Triggered by General Purpose Trigger",
};
struct pm8xxx_drvdata {
int (*pmic_readb) (const struct device *dev,
u16 addr, u8 *val);
int (*pmic_writeb) (const struct device *dev,
u16 addr, u8 val);
int (*pmic_read_buf) (const struct device *dev,
u16 addr, u8 *buf, int n);
int (*pmic_write_buf) (const struct device *dev,
u16 addr, u8 *buf, int n);
int (*pmic_read_irq_stat) (const struct device *dev,
int irq);
enum pm8xxx_version (*pmic_get_version) (const struct device *dev);
int (*pmic_get_revision) (const struct device *dev);
u8 (*pmic_restart_reason)
(const struct device *dev);
void *pm_chip_data;
};
static inline int pm8xxx_readb(const struct device *dev, u16 addr, u8 *val)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_readb(dev, addr, val);
}
static inline int pm8xxx_writeb(const struct device *dev, u16 addr, u8 val)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_writeb(dev, addr, val);
}
static inline int pm8xxx_read_buf(const struct device *dev, u16 addr, u8 *buf,
int n)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_read_buf(dev, addr, buf, n);
}
static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf,
int n)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_write_buf(dev, addr, buf, n);
}
static inline int pm8xxx_read_irq_stat(const struct device *dev, int irq)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_read_irq_stat(dev, irq);
}
static inline enum pm8xxx_version pm8xxx_get_version(const struct device *dev)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_get_version(dev);
}
static inline int pm8xxx_get_revision(const struct device *dev)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_get_revision(dev);
}
static inline u8 pm8xxx_restart_reason(const struct device *dev)
{
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
if (!dd)
return -EINVAL;
return dd->pmic_restart_reason(dev);
}
#endif
+162
View File
@@ -0,0 +1,162 @@
/*
* 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.
*/
/*
* Qualcomm PMIC8XXX gpio driver header file
*
*/
#ifndef __PM8XXX_GPIO_H
#define __PM8XXX_GPIO_H
#include <linux/errno.h>
#define PM8XXX_GPIO_DEV_NAME "pm8xxx-gpio"
struct pm8xxx_gpio_core_data {
int ngpios;
};
struct pm8xxx_gpio_platform_data {
struct pm8xxx_gpio_core_data gpio_cdata;
int gpio_base;
};
/* GPIO parameters */
/* direction */
#define PM_GPIO_DIR_OUT 0x01
#define PM_GPIO_DIR_IN 0x02
#define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN)
/* output_buffer */
#define PM_GPIO_OUT_BUF_OPEN_DRAIN 1
#define PM_GPIO_OUT_BUF_CMOS 0
/* pull */
#define PM_GPIO_PULL_UP_30 0
#define PM_GPIO_PULL_UP_1P5 1
#define PM_GPIO_PULL_UP_31P5 2
#define PM_GPIO_PULL_UP_1P5_30 3
#define PM_GPIO_PULL_DN 4
#define PM_GPIO_PULL_NO 5
/* vin_sel: Voltage Input Select */
#define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */
#define PM_GPIO_VIN_BB 1 /* ~3.3v */
#define PM_GPIO_VIN_S4 2 /* 1.8v */
#define PM_GPIO_VIN_L15 3
#define PM_GPIO_VIN_L4 4
#define PM_GPIO_VIN_L3 5
#define PM_GPIO_VIN_L17 6
/* vin_sel: Voltage Input select on PM8058 */
#define PM8058_GPIO_VIN_VPH 0
#define PM8058_GPIO_VIN_BB 1
#define PM8058_GPIO_VIN_S3 2
#define PM8058_GPIO_VIN_L3 3
#define PM8058_GPIO_VIN_L7 4
#define PM8058_GPIO_VIN_L6 5
#define PM8058_GPIO_VIN_L5 6
#define PM8058_GPIO_VIN_L2 7
/* vin_sel: Voltage Input Select on PM8038*/
#define PM8038_GPIO_VIN_VPH 0
#define PM8038_GPIO_VIN_BB 1
#define PM8038_GPIO_VIN_L11 2
#define PM8038_GPIO_VIN_L15 3
#define PM8038_GPIO_VIN_L4 4
#define PM8038_GPIO_VIN_L3 5
#define PM8038_GPIO_VIN_L17 6
/* vin_sel: Voltage Input Select on PM8018*/
#define PM8018_GPIO_VIN_L4 0
#define PM8018_GPIO_VIN_L14 1
#define PM8018_GPIO_VIN_S3 2
#define PM8018_GPIO_VIN_L6 3
#define PM8018_GPIO_VIN_L2 4
#define PM8018_GPIO_VIN_L5 5
#define PM8018_GPIO_VIN_L8 6
#define PM8018_GPIO_VIN_VPH 7
/* out_strength */
#define PM_GPIO_STRENGTH_NO 0
#define PM_GPIO_STRENGTH_HIGH 1
#define PM_GPIO_STRENGTH_MED 2
#define PM_GPIO_STRENGTH_LOW 3
/* function */
#define PM_GPIO_FUNC_NORMAL 0
#define PM_GPIO_FUNC_PAIRED 1
#define PM_GPIO_FUNC_1 2
#define PM_GPIO_FUNC_2 3
#define PM_GPIO_DTEST1 4
#define PM_GPIO_DTEST2 5
#define PM_GPIO_DTEST3 6
#define PM_GPIO_DTEST4 7
/**
* struct pm_gpio - structure to specify gpio configurtion values
* @direction: indicates whether the gpio should be input, output, or
* both. Should be of the type PM_GPIO_DIR_*
* @output_buffer: indicates gpio should be configured as CMOS or open
* drain. Should be of the type PM_GPIO_OUT_BUF_*
* @output_value: The gpio output value of the gpio line - 0 or 1
* @pull: Indicates whether a pull up or pull down should be
* applied. If a pullup is required the current strength
* needs to be specified. Current values of 30uA, 1.5uA,
* 31.5uA, 1.5uA with 30uA boost are supported. This value
* should be one of the PM_GPIO_PULL_*
* @vin_sel: specifies the voltage level when the output is set to 1.
* For an input gpio specifies the voltage level at which
* the input is interpreted as a logical 1.
* @out_strength: the amount of current supplied for an output gpio,
* should be of the type PM_GPIO_STRENGTH_*
* @function: choose alternate function for the gpio. Certain gpios
* can be paired (shorted) with each other. Some gpio pin
* can act as alternate functions. This parameter should
* be of type PM_GPIO_FUNC_*
* @inv_int_pol: Invert polarity before feeding the line to the interrupt
* module in pmic. This feature will almost be never used
* since the pm8xxx interrupt block can detect both edges
* and both levels.
* @disable_pin: Disable the gpio by configuring it as high impedance.
*/
struct pm_gpio {
int direction;
int output_buffer;
int output_value;
int pull;
int vin_sel;
int out_strength;
int function;
int inv_int_pol;
int disable_pin;
};
#if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE)
/**
* pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip
* @gpio: gpio number to configure
* @param: configuration values
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_gpio_config(int gpio, struct pm_gpio *param);
#else
static inline int pm8xxx_gpio_config(int gpio, struct pm_gpio *param)
{
return -ENXIO;
}
#endif
#endif
+60
View File
@@ -0,0 +1,60 @@
/*
* 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.
*/
/*
* Qualcomm PMIC irq 8xxx driver header file
*
*/
#ifndef __MFD_PM8XXX_IRQ_H
#define __MFD_PM8XXX_IRQ_H
#include <linux/errno.h>
#include <linux/err.h>
struct pm8xxx_irq_core_data {
u32 rev;
int nirqs;
unsigned int base_addr;
};
struct pm8xxx_irq_platform_data {
int irq_base;
struct pm8xxx_irq_core_data irq_cdata;
int devirq;
int irq_trigger_flag;
int dev_id;
};
struct pm_irq_chip;
#ifdef CONFIG_MFD_PM8XXX_IRQ
int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq);
struct pm_irq_chip *pm8xxx_irq_init(struct device *dev,
const struct pm8xxx_irq_platform_data *pdata);
int pm8xxx_irq_exit(struct pm_irq_chip *chip);
#else
static inline int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq)
{
return -ENXIO;
}
static inline struct pm_irq_chip *pm8xxx_irq_init(const struct device *dev,
const struct pm8xxx_irq_platform_data *pdata)
{
return ERR_PTR(-ENXIO);
}
static inline int pm8xxx_irq_exit(struct pm_irq_chip *chip)
{
return -ENXIO;
}
#endif /* CONFIG_MFD_PM8XXX_IRQ */
#endif /* __MFD_PM8XXX_IRQ_H */
+298
View File
@@ -0,0 +1,298 @@
/*
* Copyright (c) 2011-2013, 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 __MFD_PM8XXX_MISC_H__
#define __MFD_PM8XXX_MISC_H__
#include <linux/err.h>
#define PM8XXX_MISC_DEV_NAME "pm8xxx-misc"
/**
* struct pm8xxx_misc_platform_data - PM8xxx misc driver platform data
* @priority: PMIC prority level in a multi-PMIC system. Lower value means
* greater priority. Actions are performed from highest to lowest
* priority PMIC.
*/
struct pm8xxx_misc_platform_data {
int priority;
};
enum pm8xxx_uart_path_sel {
UART_NONE,
UART_TX1_RX1,
UART_TX2_RX2,
UART_TX3_RX3,
};
enum pm8xxx_coincell_chg_voltage {
PM8XXX_COINCELL_VOLTAGE_3p2V = 1,
PM8XXX_COINCELL_VOLTAGE_3p1V,
PM8XXX_COINCELL_VOLTAGE_3p0V,
PM8XXX_COINCELL_VOLTAGE_2p5V = 16
};
enum pm8xxx_coincell_chg_resistor {
PM8XXX_COINCELL_RESISTOR_2100_OHMS,
PM8XXX_COINCELL_RESISTOR_1700_OHMS,
PM8XXX_COINCELL_RESISTOR_1200_OHMS,
PM8XXX_COINCELL_RESISTOR_800_OHMS
};
enum pm8xxx_coincell_chg_state {
PM8XXX_COINCELL_CHG_DISABLE,
PM8XXX_COINCELL_CHG_ENABLE
};
struct pm8xxx_coincell_chg {
enum pm8xxx_coincell_chg_state state;
enum pm8xxx_coincell_chg_voltage voltage;
enum pm8xxx_coincell_chg_resistor resistor;
};
enum pm8xxx_smpl_delay {
PM8XXX_SMPL_DELAY_0p5,
PM8XXX_SMPL_DELAY_1p0,
PM8XXX_SMPL_DELAY_1p5,
PM8XXX_SMPL_DELAY_2p0,
};
enum pm8xxx_pon_config {
PM8XXX_DISABLE_HARD_RESET = 0,
PM8XXX_SHUTDOWN_ON_HARD_RESET,
PM8XXX_RESTART_ON_HARD_RESET,
};
enum pm8xxx_aux_clk_id {
CLK_MP3_1,
CLK_MP3_2,
};
enum pm8xxx_aux_clk_div {
XO_DIV_NONE,
XO_DIV_1,
XO_DIV_2,
XO_DIV_4,
XO_DIV_8,
XO_DIV_16,
XO_DIV_32,
XO_DIV_64,
};
enum pm8xxx_hsed_bias {
PM8XXX_HSED_BIAS0,
PM8XXX_HSED_BIAS1,
PM8XXX_HSED_BIAS2,
};
#if defined(CONFIG_MFD_PM8XXX_MISC) || defined(CONFIG_MFD_PM8XXX_MISC_MODULE)
/**
* pm8xxx_reset_pwr_off - switch all PM8XXX PMIC chips attached to the system to
* either reset or shutdown when they are turned off
* @reset: 0 = shudown the PMICs, 1 = shutdown and then restart the PMICs
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_reset_pwr_off(int reset);
int pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel);
/**
* pm8xxx_coincell_chg_config - Disables or enables the coincell charger, and
* configures its voltage and resistor settings.
* @chg_config: Holds both voltage and resistor values, and a
* switch to change the state of charger.
* If state is to disable the charger then
* both voltage and resistor are disregarded.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config);
/**
* pm8xxx_smpl_control - enables/disables SMPL detection
* @enable: 0 = shutdown PMIC on power loss, 1 = reset PMIC on power loss
*
* This function enables or disables the Sudden Momentary Power Loss detection
* module. If SMPL detection is enabled, then when a sufficiently long power
* loss event occurs, the PMIC will automatically reset itself. If SMPL
* detection is disabled, then the PMIC will shutdown when power loss occurs.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_smpl_control(int enable);
/**
* pm8xxx_smpl_set_delay - sets the SMPL detection time delay
* @delay: enum value corresponding to delay time
*
* This function sets the time delay of the SMPL detection module. If power
* is reapplied within this interval, then the PMIC reset automatically. The
* SMPL detection module must be enabled for this delay time to take effect.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay);
/**
* pm8xxx_watchdog_reset_control - enables/disables watchdog reset detection
* @enable: 0 = shutdown when PS_HOLD goes low, 1 = reset when PS_HOLD goes low
*
* This function enables or disables the PMIC watchdog reset detection feature.
* If watchdog reset detection is enabled, then the PMIC will reset itself
* when PS_HOLD goes low. If it is not enabled, then the PMIC will shutdown
* when PS_HOLD goes low.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_watchdog_reset_control(int enable);
/**
* pm8xxx_hard_reset_config - Allows different reset configurations
*
* config = DISABLE_HARD_RESET to disable hard reset
* = SHUTDOWN_ON_HARD_RESET to turn off the system on hard reset
* = RESTART_ON_HARD_RESET to restart the system on hard reset
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config);
/**
* pm8xxx_stay_on - enables stay_on feature
*
* PMIC stay-on feature allows PMIC to ignore MSM PS_HOLD=low
* signal so that some special functions like debugging could be
* performed.
*
* This feature should not be used in any product release.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_stay_on(void);
/**
* pm8xxx_preload_dVdd - preload the dVdd regulator during off state.
*
* This can help to reduce fluctuations in the dVdd voltage during startup
* at the cost of additional off state current draw.
*
* This API should only be called if dVdd startup issues are suspected.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_preload_dVdd(void);
/**
* pm8xxx_usb_id_pullup - Control a pullup for USB ID
*
* @enable: enable (1) or disable (0) the pullup
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_usb_id_pullup(int enable);
/**
* pm8xxx_aux_clk_control - Control an auxiliary clock
* @clk_id: ID of clock to be programmed, registers of XO_CNTRL2
* @divider: divisor to use when configuring desired clock
* @enable: enable (1) the designated clock with the supplied division,
* or disable (0) the designated clock
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
enum pm8xxx_aux_clk_div divider,
bool enable);
/**
* pm8xxx_hsed_bias_control - Control the HSED_BIAS signal
* @bias: the bias line to be controlled (of the 3)
* @enable: enable/disable the bias line
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_hsed_bias_control(enum pm8xxx_hsed_bias bias, bool enable);
/**
* pm8xxx_read_register - Read a PMIC register
* @addr: PMIC register address
* @value: Output parameter which gets the value of the register read.
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_read_register(u16 addr, u8 *value);
#else
static inline int pm8xxx_reset_pwr_off(int reset)
{
return -ENODEV;
}
static inline int
pm8xxx_uart_gpio_mux_ctrl(enum pm8xxx_uart_path_sel uart_path_sel)
{
return -ENODEV;
}
static inline int
pm8xxx_coincell_chg_config(struct pm8xxx_coincell_chg *chg_config)
{
return -ENODEV;
}
static inline int pm8xxx_smpl_set_delay(enum pm8xxx_smpl_delay delay)
{
return -ENODEV;
}
static inline int pm8xxx_smpl_control(int enable)
{
return -ENODEV;
}
static inline int pm8xxx_watchdog_reset_control(int enable)
{
return -ENODEV;
}
static inline int pm8xxx_hard_reset_config(enum pm8xxx_pon_config config)
{
return -ENODEV;
}
static inline int pm8xxx_stay_on(void)
{
return -ENODEV;
}
static inline int pm8xxx_preload_dVdd(void)
{
return -ENODEV;
}
static inline int pm8xxx_usb_id_pullup(int enable)
{
return -ENODEV;
}
static inline int pm8xxx_aux_clk_control(enum pm8xxx_aux_clk_id clk_id,
enum pm8xxx_aux_clk_div divider, bool enable)
{
return -ENODEV;
}
static inline int pm8xxx_hsed_bias_control(enum pm8xxx_hsed_bias bias,
bool enable)
{
return -ENODEV;
}
static inline int pm8xxx_read_register(u16 addr, u8 *value)
{
return -ENODEV;
}
#endif
#endif
+263
View File
@@ -0,0 +1,263 @@
/* Copyright (c) 2011-2012, 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 __PM8XXX_MPP_H
#define __PM8XXX_MPP_H
#include <linux/errno.h>
#define PM8XXX_MPP_DEV_NAME "pm8xxx-mpp"
struct pm8xxx_mpp_core_data {
int base_addr;
int nmpps;
};
struct pm8xxx_mpp_platform_data {
struct pm8xxx_mpp_core_data core_data;
int mpp_base;
};
/**
* struct pm8xxx_mpp_config_data - structure to specify mpp configuration values
* @type: MPP type which determines the overall MPP function (i.e. digital
* in/out/bi, analog in/out, current sink, or test). It should be
* set to the value of one of PM8XXX_MPP_TYPE_D_*.
* @level: meaning depends upon MPP type specified
* @control: meaning depends upon MPP type specified
*
* Usage of level argument:
* 1. type = PM8XXX_MPP_TYPE_D_INPUT, PM8XXX_MPP_TYPE_D_OUTPUT,
* PM8XXX_MPP_TYPE_D_BI_DIR, or PM8XXX_MPP_TYPE_DTEST_OUTPUT -
*
* level specifies that digital logic level to use for the MPP. It should
* be set to the value of one of PM8XXX_MPP_DIG_LEVEL_*. Actual regulator
* connections for these level choices are PMIC chip specific.
*
* 2. type = PM8XXX_MPP_TYPE_A_INPUT -
*
* level specifies where in the PMIC chip the analog input value should
* be routed to. It should be set to the value of one of
* PM8XXX_MPP_AIN_AMUX_*.
*
* 3. type = PM8XXX_MPP_TYPE_A_OUTPUT -
*
* level specifies the output analog voltage reference level. It should
* be set to the value of one of PM8XXX_MPP_AOUT_LVL_*.
*
* 4. type = PM8XXX_MPP_TYPE_SINK or PM8XXX_MPP_TYPE_DTEST_SINK -
*
* level specifies the output current level. It should be set to the value
* of one of PM8XXX_MPP_CS_OUT_*.
*
* Usage of control argument:
* 1. type = PM8XXX_MPP_TYPE_D_INPUT -
*
* control specifies how the digital input should be routed in the chip.
* It should be set to the value of one of PM8XXX_MPP_DIN_TO_*.
*
* 2. type = PM8XXX_MPP_TYPE_D_OUTPUT -
*
* control specifies the digital output value. It should be set to the
* value of one of PM8XXX_MPP_DOUT_CTRL_*.
*
* 3. type = PM8XXX_MPP_TYPE_D_BI_DIR -
*
* control specifies the pullup resistor value. It should be set to the
* value of one of PM8XXX_MPP_BI_PULLUP_*.
*
* 4. type = PM8XXX_MPP_TYPE_A_INPUT -
*
* control is unused; a value of 0 is sufficient.
*
* 5. type = PM8XXX_MPP_TYPE_A_OUTPUT -
*
* control specifies if analog output is enabled. It should be set to the
* value of one of PM8XXX_MPP_AOUT_CTRL_*.
*
* 6. type = PM8XXX_MPP_TYPE_SINK -
*
* control specifies if current sinking is enabled. It should be set to
* the value of one of PM8XXX_MPP_CS_CTRL_*.
*
* 7. type = PM8XXX_MPP_TYPE_DTEST_SINK -
*
* control specifies if current sinking is enabled. It should be set to
* the value of one of PM8XXX_MPP_DTEST_CS_CTRL_*.
*
* 8. type = PM8XXX_MPP_TYPE_DTEST_OUTPUT -
*
* control specifies which DTEST bus value to output. It should be set to
* the value of one of PM8XXX_MPP_DTEST_*.
*/
struct pm8xxx_mpp_config_data {
unsigned type;
unsigned level;
unsigned control;
};
/* API */
#if defined(CONFIG_GPIO_PM8XXX_MPP) || defined(CONFIG_GPIO_PM8XXX_MPP_MODULE)
/**
* pm8xxx_mpp_config() - configure control options of a multi-purpose pin (MPP)
* @mpp: global GPIO number corresponding to the MPP
* @config: configuration to set for this MPP
* Context: can sleep
*
* RETURNS: an appropriate -ERRNO error value on error, or zero for success.
*/
int pm8xxx_mpp_config(unsigned mpp, struct pm8xxx_mpp_config_data *config);
#else
static inline int pm8xxx_mpp_config(unsigned mpp,
struct pm8xxx_mpp_config_data *config)
{
return -ENXIO;
}
#endif
/* MPP Type: type */
#define PM8XXX_MPP_TYPE_D_INPUT 0
#define PM8XXX_MPP_TYPE_D_OUTPUT 1
#define PM8XXX_MPP_TYPE_D_BI_DIR 2
#define PM8XXX_MPP_TYPE_A_INPUT 3
#define PM8XXX_MPP_TYPE_A_OUTPUT 4
#define PM8XXX_MPP_TYPE_SINK 5
#define PM8XXX_MPP_TYPE_DTEST_SINK 6
#define PM8XXX_MPP_TYPE_DTEST_OUTPUT 7
/* Digital Input/Output: level */
#define PM8XXX_MPP_DIG_LEVEL_VIO_0 0
#define PM8XXX_MPP_DIG_LEVEL_VIO_1 1
#define PM8XXX_MPP_DIG_LEVEL_VIO_2 2
#define PM8XXX_MPP_DIG_LEVEL_VIO_3 3
#define PM8XXX_MPP_DIG_LEVEL_VIO_4 4
#define PM8XXX_MPP_DIG_LEVEL_VIO_5 5
#define PM8XXX_MPP_DIG_LEVEL_VIO_6 6
#define PM8XXX_MPP_DIG_LEVEL_VIO_7 7
/* Digital Input/Output: level [PM8058] */
#define PM8058_MPP_DIG_LEVEL_VPH 0
#define PM8058_MPP_DIG_LEVEL_S3 1
#define PM8058_MPP_DIG_LEVEL_L2 2
#define PM8058_MPP_DIG_LEVEL_L3 3
/* Digital Input/Output: level [PM8901] */
#define PM8901_MPP_DIG_LEVEL_MSMIO 0
#define PM8901_MPP_DIG_LEVEL_DIG 1
#define PM8901_MPP_DIG_LEVEL_L5 2
#define PM8901_MPP_DIG_LEVEL_S4 3
#define PM8901_MPP_DIG_LEVEL_VPH 4
/* Digital Input/Output: level [PM8921] */
#define PM8921_MPP_DIG_LEVEL_S4 1
#define PM8921_MPP_DIG_LEVEL_L15 3
#define PM8921_MPP_DIG_LEVEL_L17 4
#define PM8921_MPP_DIG_LEVEL_VPH 7
/* Digital Input/Output: level [PM8821] */
#define PM8821_MPP_DIG_LEVEL_1P8 0
#define PM8821_MPP_DIG_LEVEL_VPH 7
/* Digital Input/Output: level [PM8018] */
#define PM8018_MPP_DIG_LEVEL_L4 0
#define PM8018_MPP_DIG_LEVEL_L14 1
#define PM8018_MPP_DIG_LEVEL_S3 2
#define PM8018_MPP_DIG_LEVEL_L6 3
#define PM8018_MPP_DIG_LEVEL_L2 4
#define PM8018_MPP_DIG_LEVEL_L5 5
#define PM8018_MPP_DIG_LEVEL_VPH 7
/* Digital Input/Output: level [PM8038] */
#define PM8038_MPP_DIG_LEVEL_L20 0
#define PM8038_MPP_DIG_LEVEL_L11 1
#define PM8038_MPP_DIG_LEVEL_L5 2
#define PM8038_MPP_DIG_LEVEL_L15 3
#define PM8038_MPP_DIG_LEVEL_L17 4
#define PM8038_MPP_DIG_LEVEL_VPH 7
/* Digital Input: control */
#define PM8XXX_MPP_DIN_TO_INT 0
#define PM8XXX_MPP_DIN_TO_DBUS1 1
#define PM8XXX_MPP_DIN_TO_DBUS2 2
#define PM8XXX_MPP_DIN_TO_DBUS3 3
/* Digital Output: control */
#define PM8XXX_MPP_DOUT_CTRL_LOW 0
#define PM8XXX_MPP_DOUT_CTRL_HIGH 1
#define PM8XXX_MPP_DOUT_CTRL_MPP 2
#define PM8XXX_MPP_DOUT_CTRL_INV_MPP 3
/* Bidirectional: control */
#define PM8XXX_MPP_BI_PULLUP_1KOHM 0
#define PM8XXX_MPP_BI_PULLUP_OPEN 1
#define PM8XXX_MPP_BI_PULLUP_10KOHM 2
#define PM8XXX_MPP_BI_PULLUP_30KOHM 3
/* Analog Input: level */
#define PM8XXX_MPP_AIN_AMUX_CH5 0
#define PM8XXX_MPP_AIN_AMUX_CH6 1
#define PM8XXX_MPP_AIN_AMUX_CH7 2
#define PM8XXX_MPP_AIN_AMUX_CH8 3
#define PM8XXX_MPP_AIN_AMUX_CH9 4
#define PM8XXX_MPP_AIN_AMUX_ABUS1 5
#define PM8XXX_MPP_AIN_AMUX_ABUS2 6
#define PM8XXX_MPP_AIN_AMUX_ABUS3 7
/* Analog Output: level */
#define PM8XXX_MPP_AOUT_LVL_1V25 0
#define PM8XXX_MPP_AOUT_LVL_1V25_2 1
#define PM8XXX_MPP_AOUT_LVL_0V625 2
#define PM8XXX_MPP_AOUT_LVL_0V3125 3
#define PM8XXX_MPP_AOUT_LVL_MPP 4
#define PM8XXX_MPP_AOUT_LVL_ABUS1 5
#define PM8XXX_MPP_AOUT_LVL_ABUS2 6
#define PM8XXX_MPP_AOUT_LVL_ABUS3 7
/* Analog Output: control */
#define PM8XXX_MPP_AOUT_CTRL_DISABLE 0
#define PM8XXX_MPP_AOUT_CTRL_ENABLE 1
#define PM8XXX_MPP_AOUT_CTRL_MPP_HIGH_EN 2
#define PM8XXX_MPP_AOUT_CTRL_MPP_LOW_EN 3
/* Current Sink: level */
#define PM8XXX_MPP_CS_OUT_5MA 0
#define PM8XXX_MPP_CS_OUT_10MA 1
#define PM8XXX_MPP_CS_OUT_15MA 2
#define PM8XXX_MPP_CS_OUT_20MA 3
#define PM8XXX_MPP_CS_OUT_25MA 4
#define PM8XXX_MPP_CS_OUT_30MA 5
#define PM8XXX_MPP_CS_OUT_35MA 6
#define PM8XXX_MPP_CS_OUT_40MA 7
/* Current Sink: control */
#define PM8XXX_MPP_CS_CTRL_DISABLE 0
#define PM8XXX_MPP_CS_CTRL_ENABLE 1
#define PM8XXX_MPP_CS_CTRL_MPP_HIGH_EN 2
#define PM8XXX_MPP_CS_CTRL_MPP_LOW_EN 3
/* DTEST Current Sink: control */
#define PM8XXX_MPP_DTEST_CS_CTRL_EN1 0
#define PM8XXX_MPP_DTEST_CS_CTRL_EN2 1
#define PM8XXX_MPP_DTEST_CS_CTRL_EN3 2
#define PM8XXX_MPP_DTEST_CS_CTRL_EN4 3
/* DTEST Digital Output: control */
#define PM8XXX_MPP_DTEST_DBUS1 0
#define PM8XXX_MPP_DTEST_DBUS2 1
#define PM8XXX_MPP_DTEST_DBUS3 2
#define PM8XXX_MPP_DTEST_DBUS4 3
#endif
+79
View File
@@ -0,0 +1,79 @@
/* Copyright (c) 2010,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 __PM8XXX_NFC_H__
#define __PM8XXX_NFC_H__
struct pm8xxx_nfc_device;
#define PM8XXX_NFC_DEV_NAME "pm8xxx-nfc"
/* masks, flags and status */
#define PM_NFC_VDDLDO_MON_LEVEL 0x0003
#define PM_NFC_VPH_PWR_EN 0x0008
#define PM_NFC_EXT_VDDLDO_EN 0x0010
#define PM_NFC_EN 0x0020
#define PM_NFC_LDO_EN 0x0040
#define PM_NFC_SUPPORT_EN 0x0080
#define PM_NFC_EXT_EN_HIGH 0x0100
#define PM_NFC_MBG_EN_HIGH 0x0200
#define PM_NFC_VDDLDO_OK_HIGH 0x0400
#define PM_NFC_DTEST1_MODE 0x2000
#define PM_NFC_ATEST_EN 0x4000
#define PM_NFC_VDDLDO_MON_EN 0x8000
#define PM_NFC_CTRL_REQ (PM_NFC_SUPPORT_EN |\
PM_NFC_LDO_EN |\
PM_NFC_EN |\
PM_NFC_EXT_VDDLDO_EN |\
PM_NFC_VPH_PWR_EN |\
PM_NFC_VDDLDO_MON_LEVEL)
#define PM_NFC_TEST_REQ (PM_NFC_VDDLDO_MON_EN |\
PM_NFC_DTEST1_MODE |\
PM_NFC_ATEST_EN)
#define PM_NFC_TEST_STATUS (PM_NFC_EXT_EN_HIGH |\
PM_NFC_MBG_EN_HIGH |\
PM_NFC_VDDLDO_OK_HIGH)
/*
* pm8xxx_nfc_request - request a handle to access NFC device
*/
struct pm8xxx_nfc_device *pm8xxx_nfc_request(void);
/*
* pm8xxx_nfc_config - configure NFC signals
*
* @nfcdev: the NFC device
* @mask: signal mask to configure
* @flags: control flags
*/
int pm8xxx_nfc_config(struct pm8xxx_nfc_device *nfcdev, u32 mask, u32 flags);
/*
* pm8xxx_nfc_get_status - get NFC status
*
* @nfcdev: the NFC device
* @mask: of status mask to read
* @status: pointer to the status variable
*/
int pm8xxx_nfc_get_status(struct pm8xxx_nfc_device *nfcdev,
u32 mask, u32 *status);
/*
* pm8xxx_nfc_free - free the NFC device
*/
void pm8xxx_nfc_free(struct pm8xxx_nfc_device *nfcdev);
#endif /* __PM8XXX_NFC_H__ */
+79
View File
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8018 driver header file
*
*/
#ifndef __MFD_PM8018_H
#define __MFD_PM8018_H
#include <linux/device.h>
#include <linux/mfd/pm8xxx/irq.h>
#include <linux/mfd/pm8xxx/gpio.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/rtc.h>
#include <linux/mfd/pm8xxx/tm.h>
#include <linux/input/pmic8xxx-pwrkey.h>
#include <linux/mfd/pm8xxx/misc.h>
#include <linux/regulator/pm8xxx-regulator.h>
#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
#include <linux/mfd/pm8xxx/pwm.h>
#include <linux/leds-pm8xxx.h>
#define PM8018_CORE_DEV_NAME "pm8018-core"
#define PM8018_NR_IRQS 256
#define PM8018_NR_GPIOS 6
#define PM8018_NR_MPPS 6
#define PM8018_GPIO_BLOCK_START 24
#define PM8018_MPP_BLOCK_START 16
#define PM8018_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit))
/* GPIOs and MPPs [1,N] */
#define PM8018_GPIO_IRQ(base, gpio) ((base) + \
PM8018_IRQ_BLOCK_BIT(PM8018_GPIO_BLOCK_START, (gpio)-1))
#define PM8018_MPP_IRQ(base, mpp) ((base) + \
PM8018_IRQ_BLOCK_BIT(PM8018_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8018_RTC_ALARM_IRQ PM8018_IRQ_BLOCK_BIT(4, 7)
#define PM8018_PWRKEY_REL_IRQ PM8018_IRQ_BLOCK_BIT(6, 2)
#define PM8018_PWRKEY_PRESS_IRQ PM8018_IRQ_BLOCK_BIT(6, 3)
#define PM8018_ADC_EOC_USR_IRQ PM8018_IRQ_BLOCK_BIT(9, 6)
#define PM8018_ADC_BATT_TEMP_WARM_IRQ PM8018_IRQ_BLOCK_BIT(9, 1)
#define PM8018_ADC_BATT_TEMP_COLD_IRQ PM8018_IRQ_BLOCK_BIT(9, 0)
#define PM8018_OVERTEMP_IRQ PM8018_IRQ_BLOCK_BIT(4, 2)
#define PM8018_TEMPSTAT_IRQ PM8018_IRQ_BLOCK_BIT(6, 7)
#define PM8018_LVS1_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 0)
struct pm8018_platform_data {
struct pm8xxx_irq_platform_data *irq_pdata;
struct pm8xxx_gpio_platform_data *gpio_pdata;
struct pm8xxx_mpp_platform_data *mpp_pdata;
struct pm8xxx_rtc_platform_data *rtc_pdata;
struct pm8xxx_pwrkey_platform_data *pwrkey_pdata;
struct pm8xxx_misc_platform_data *misc_pdata;
struct pm8xxx_regulator_platform_data *regulator_pdatas;
struct pm8xxx_adc_platform_data *adc_pdata;
int num_regulators;
struct pm8xxx_led_platform_data *leds_pdata;
};
#endif
+91
View File
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8038 driver header file
*
*/
#ifndef __MFD_PM8038_H
#define __MFD_PM8038_H
#include <linux/device.h>
#include <linux/mfd/pm8xxx/irq.h>
#include <linux/mfd/pm8xxx/gpio.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/pwm.h>
#include <linux/mfd/pm8xxx/rtc.h>
#include <linux/input/pmic8xxx-pwrkey.h>
#include <linux/mfd/pm8xxx/misc.h>
#include <linux/regulator/pm8xxx-regulator.h>
#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
#include <linux/mfd/pm8xxx/pm8921-charger.h>
#include <linux/mfd/pm8xxx/pm8921-bms.h>
#include <linux/leds-pm8xxx.h>
#include <linux/mfd/pm8xxx/ccadc.h>
#include <linux/mfd/pm8xxx/spk.h>
#include <linux/mfd/pm8xxx/tm.h>
#define PM8038_CORE_DEV_NAME "pm8038-core"
#define PM8038_NR_IRQS 256
#define PM8038_NR_GPIOS 12
#define PM8038_NR_MPPS 6
#define PM8038_GPIO_BLOCK_START 24
#define PM8038_MPP_BLOCK_START 16
#define PM8038_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit))
/* GPIO and MPPs [1,N] */
#define PM8038_GPIO_IRQ(base, gpio) ((base) + \
PM8038_IRQ_BLOCK_BIT(PM8038_GPIO_BLOCK_START, (gpio)-1))
#define PM8038_MPP_IRQ(base, mpp) ((base) + \
PM8038_IRQ_BLOCK_BIT(PM8038_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8038_RTC_ALARM_IRQ PM8038_IRQ_BLOCK_BIT(4, 7)
#define PM8038_BATT_ALARM_IRQ PM8921_IRQ_BLOCK_BIT(5, 6)
#define PM8038_PWRKEY_REL_IRQ PM8038_IRQ_BLOCK_BIT(6, 2)
#define PM8038_PWRKEY_PRESS_IRQ PM8038_IRQ_BLOCK_BIT(6, 3)
#define PM8038_KEYPAD_IRQ PM8038_IRQ_BLOCK_BIT(9, 2)
#define PM8038_KEYSTUCK_IRQ PM8038_IRQ_BLOCK_BIT(9, 3)
#define PM8038_ADC_EOC_USR_IRQ PM8038_IRQ_BLOCK_BIT(9, 6)
#define PM8038_ADC_BATT_TEMP_WARM_IRQ PM8038_IRQ_BLOCK_BIT(9, 1)
#define PM8038_ADC_BATT_TEMP_COLD_IRQ PM8038_IRQ_BLOCK_BIT(9, 0)
#define PM8038_USB_ID_IN_IRQ(base) (base + PM8921_IRQ_BLOCK_BIT(6, 1))
#define PM8038_RESOUT_IRQ PM8038_IRQ_BLOCK_BIT(6, 4)
#define PM8038_OVERTEMP_IRQ PM8038_IRQ_BLOCK_BIT(4, 2)
#define PM8038_TEMPSTAT_IRQ PM8038_IRQ_BLOCK_BIT(6, 7)
struct pm8038_platform_data {
int irq_base;
struct pm8xxx_gpio_platform_data *gpio_pdata;
struct pm8xxx_irq_platform_data *irq_pdata;
struct pm8xxx_mpp_platform_data *mpp_pdata;
struct pm8xxx_rtc_platform_data *rtc_pdata;
struct pm8xxx_pwrkey_platform_data *pwrkey_pdata;
struct pm8xxx_misc_platform_data *misc_pdata;
struct pm8xxx_regulator_platform_data *regulator_pdatas;
int num_regulators;
struct pm8921_charger_platform_data *charger_pdata;
struct pm8921_bms_platform_data *bms_pdata;
struct pm8xxx_adc_platform_data *adc_pdata;
struct pm8xxx_led_platform_data *leds_pdata;
struct pm8xxx_vibrator_platform_data *vibrator_pdata;
struct pm8xxx_ccadc_platform_data *ccadc_pdata;
struct pm8xxx_spk_platform_data *spk_pdata;
};
#endif
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2012, 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.
*/
/*
* Qualcomm PMIC irq 8821 driver header file
*
*/
#ifndef __MFD_PM8821_IRQ_H
#define __MFD_PM8821_IRQ_H
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/mfd/pm8xxx/irq.h>
#ifdef CONFIG_MFD_PM8821_IRQ
int pm8821_get_irq_stat(struct pm_irq_chip *chip, int irq);
struct pm_irq_chip *pm8821_irq_init(struct device *dev,
const struct pm8xxx_irq_platform_data *pdata);
int pm8821_irq_exit(struct pm_irq_chip *chip);
#else
static inline int pm8821_get_irq_stat(struct pm_irq_chip *chip, int irq)
{
return -ENXIO;
}
static inline struct pm_irq_chip *pm8821_irq_init(const struct device *dev,
const struct pm8xxx_irq_platform_data *pdata)
{
return ERR_PTR(-ENXIO);
}
static inline int pm8821_irq_exit(struct pm_irq_chip *chip)
{
return -ENXIO;
}
#endif /* CONFIG_MFD_PM8821_IRQ */
#endif /* __MFD_PM8821_IRQ_H */
+51
View File
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8821 driver header file
*
*/
#ifndef __MFD_PM8821_H
#define __MFD_PM8821_H
#include <linux/device.h>
#include <linux/mfd/pm8xxx/pm8821-irq.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/tm.h>
#define PM8821_NR_IRQS (112)
#define PM8821_NR_MPPS (4)
#define PM8821_MPP_BLOCK_START (4)
/*
* Block 0 does not exist in PM8821 IRQ SSBI address space,
* IRQ0 is assigned to bit0 of block1
*/
#define PM8821_IRQ_BLOCK_BIT(block, bit) ((block-1) * 8 + (bit))
/* MPPs [1,N] */
#define PM8821_MPP_IRQ(base, mpp) ((base) + \
PM8821_IRQ_BLOCK_BIT(PM8821_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8821_OVERTEMP_IRQ PM8821_IRQ_BLOCK_BIT(5, 2)
#define PM8821_TEMPSTAT_IRQ PM8821_IRQ_BLOCK_BIT(5, 7)
struct pm8821_platform_data {
int irq_base;
struct pm8xxx_irq_platform_data *irq_pdata;
struct pm8xxx_mpp_platform_data *mpp_pdata;
};
#endif
@@ -0,0 +1,242 @@
/* Copyright (c) 2011-2013, 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 __PM8XXX_BMS_H
#define __PM8XXX_BMS_H
#include <linux/errno.h>
#include <linux/mfd/pm8xxx/batterydata-lib.h>
#define PM8921_BMS_DEV_NAME "pm8921-bms"
struct pm8xxx_bms_core_data {
unsigned int batt_temp_channel;
unsigned int vbat_channel;
unsigned int ref625mv_channel;
unsigned int ref1p25v_channel;
unsigned int batt_id_channel;
};
/**
* struct pm8921_bms_platform_data -
* @batt_type: allows to force chose battery calibration data
* @r_sense_uohm: sense resistor value in (micro Ohms)
* @i_test: current at which the unusable charger cutoff is to be
* calculated or the peak system current (mA)
* @v_cutoff: the loaded voltage at which the battery
* is considered empty(mV)
* @enable_fcc_learning: if set the driver will learn full charge
* capacity of the battery upon end of charge
* @min_fcc_learning_soc: minimum SOC as which CC counting for FCC
* learning can start
* @min_fcc_ocv_pc: minimum PC (lookup(OCV)) at which CC counting
* for FCC learning can start
* @max_fcc_learning_samples: Maximum number of FCC measurement cycles to be
* used for FCC update
* @normal_voltage_calc_ms: The period of soc calculation in ms when battery
* voltage higher than cutoff voltage
* @low_voltage_calc_ms: The period of soc calculation in ms when battery
* voltage is near cutoff voltage
* @disable_flat_portion_ocv: feature to disable ocv updates while in sleep
* @ocv_dis_high_soc: the high soc percent when ocv should be disabled
* @ocv_dis_low_soc: the low soc percent when ocv should be enabled
* @low_voltage_detect: feature to enable 0 SOC reporting on low volatge
* @vbatt_cutoff_retries: number of tries before we report a 0 SOC
* @high_ocv_correction_limit_uv: the max amount of OCV corrections
* allowed when ocv is high
* (higher than 3.8V)
* @low_ocv_correction_limit_uv: the max amount of OCV corrections
* allowed when ocv is low
* (lower or equal to 3.8V)
* @hold_soc_est: the min est soc below which the calculated soc
* is allowed to go to 0%
*/
struct pm8921_bms_platform_data {
struct pm8xxx_bms_core_data bms_cdata;
enum battery_type battery_type;
int r_sense_uohm;
unsigned int i_test;
unsigned int v_cutoff;
unsigned int max_voltage_uv;
unsigned int rconn_mohm;
unsigned int alarm_low_mv;
unsigned int alarm_high_mv;
int enable_fcc_learning;
int min_fcc_learning_soc;
int min_fcc_ocv_pc;
int max_fcc_learning_samples;
int shutdown_soc_valid_limit;
int ignore_shutdown_soc;
int adjust_soc_low_threshold;
int chg_term_ua;
int normal_voltage_calc_ms;
int low_voltage_calc_ms;
int disable_flat_portion_ocv;
int ocv_dis_high_soc;
int ocv_dis_low_soc;
int low_voltage_detect;
int vbatt_cutoff_retries;
int high_ocv_correction_limit_uv;
int low_ocv_correction_limit_uv;
int hold_soc_est;
};
#if defined(CONFIG_PM8921_BMS) || defined(CONFIG_PM8921_BMS_MODULE)
/**
* pm8921_bms_get_vsense_avg - return the voltage across the sense
* resitor in microvolts
* @result: The pointer where the voltage will be updated. A -ve
* result means that the current is flowing in
* the battery - during battery charging
*
* RETURNS: Error code if there was a problem reading vsense, Zero otherwise
* The result won't be updated in case of an error.
*
*
*/
int pm8921_bms_get_vsense_avg(int *result);
/**
* pm8921_bms_get_battery_current - return the battery current based on vsense
* resitor in microamperes
* @result: The pointer where the voltage will be updated. A -ve
* result means that the current is flowing in
* the battery - during battery charging
*
* RETURNS: Error code if there was a problem reading vsense, Zero otherwise
* The result won't be updated in case of an error.
*
*/
int pm8921_bms_get_battery_current(int *result);
/**
* pm8921_bms_get_percent_charge - returns the current battery charge in percent
*
*/
int pm8921_bms_get_percent_charge(void);
/**
* pm8921_bms_get_fcc - returns fcc in mAh of the battery depending on its age
* and temperature
*
*/
int pm8921_bms_get_fcc(void);
/**
* pm8921_bms_charging_began - function to notify the bms driver that charging
* has started. Used by the bms driver to keep
* track of chargecycles
*/
void pm8921_bms_charging_began(void);
/**
* pm8921_bms_charging_end - function to notify the bms driver that charging
* has stopped. Used by the bms driver to keep
* track of chargecycles
*/
void pm8921_bms_charging_end(int is_battery_full);
void pm8921_bms_calibrate_hkadc(void);
/**
* pm8921_bms_get_simultaneous_battery_voltage_and_current
* - function to take simultaneous vbat and vsense readings
* this puts the bms in override mode but keeps coulumb couting
* on. Useful when ir compensation needs to be implemented
*/
int pm8921_bms_get_simultaneous_battery_voltage_and_current(int *ibat_ua,
int *vbat_uv);
/**
* pm8921_bms_get_current_max
* - function to get the max current that can be drawn from
* the battery before it dips below the min allowed voltage
*/
int pm8921_bms_get_current_max(void);
/**
* pm8921_bms_invalidate_shutdown_soc - function to notify the bms driver that
* the battery was replaced between reboot
* and so it should not use the shutdown
* soc stored in a coincell backed register
*/
void pm8921_bms_invalidate_shutdown_soc(void);
/**
* pm8921_bms_cc_uah - function to get the coulomb counter based charge. Note
* that the coulomb counter are reset when the current
* consumption is low (below 8mA for more than 5 minutes),
* This will lead in a very low coulomb counter charge
* value upon wakeup from sleep.
*/
int pm8921_bms_cc_uah(int *cc_uah);
/**
* pm8921_bms_battery_removed - function to be called to tell the bms that
* the battery is removed. The bms resets its internal
* history data used to report soc.
*/
void pm8921_bms_battery_removed(void);
/**
* pm8921_bms_battery_inseted - function to be called to tell the bms that
* the battery was inserted. The bms initiates calculations
* for reporting soc.
*/
void pm8921_bms_battery_inserted(void);
#else
static inline int pm8921_bms_get_vsense_avg(int *result)
{
return -ENXIO;
}
static inline int pm8921_bms_get_battery_current(int *result)
{
return -ENXIO;
}
static inline int pm8921_bms_get_percent_charge(void)
{
return -ENXIO;
}
static inline int pm8921_bms_get_fcc(void)
{
return -ENXIO;
}
static inline void pm8921_bms_charging_began(void)
{
}
static inline void pm8921_bms_charging_end(int is_battery_full)
{
}
static inline void pm8921_bms_calibrate_hkadc(void)
{
}
static inline int pm8921_bms_get_simultaneous_battery_voltage_and_current(
int *ibat_ua, int *vbat_uv)
{
return -ENXIO;
}
static inline int pm8921_bms_get_rbatt(void)
{
return -EINVAL;
}
static inline void pm8921_bms_invalidate_shutdown_soc(void)
{
}
static inline int pm8921_bms_cc_uah(int *cc_uah)
{
return -ENXIO;
}
static inline int pm8921_bms_get_current_max(void)
{
return -ENXIO;
}
static inline void pm8921_bms_battery_removed(void) {}
static inline void pm8921_bms_battery_inserted(void) {}
#endif
#endif
@@ -0,0 +1,393 @@
/* Copyright (c) 2011-2013, 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 __PM8XXX_CHARGER_H
#define __PM8XXX_CHARGER_H
#include <linux/errno.h>
#include <linux/power_supply.h>
#define PM8921_CHARGER_DEV_NAME "pm8921-charger"
struct pm8xxx_charger_core_data {
unsigned int vbat_channel;
unsigned int batt_temp_channel;
unsigned int batt_id_channel;
};
enum pm8921_chg_cold_thr {
PM_SMBC_BATT_TEMP_COLD_THR__LOW,
PM_SMBC_BATT_TEMP_COLD_THR__HIGH
};
enum pm8921_chg_hot_thr {
PM_SMBC_BATT_TEMP_HOT_THR__LOW,
PM_SMBC_BATT_TEMP_HOT_THR__HIGH
};
enum pm8921_usb_ov_threshold {
PM_USB_OV_5P5V,
PM_USB_OV_6V,
PM_USB_OV_6P5V,
PM_USB_OV_7V,
};
enum pm8921_usb_debounce_time {
PM_USB_BYPASS_DEBOUNCER,
PM_USB_DEBOUNCE_20P5MS,
PM_USB_DEBOUNCE_40P5MS,
PM_USB_DEBOUNCE_80P5MS,
};
enum pm8921_chg_led_src_config {
LED_SRC_GND,
LED_SRC_VPH_PWR,
LED_SRC_5V,
LED_SRC_MIN_VPH_5V,
LED_SRC_BYPASS,
};
/**
* struct pm8921_charger_platform_data -
* valid range 4 to 512 min. PON default 120 min
* @ttrkl_time: max trckl charging time in minutes
* valid range 1 to 64 mins. PON default 15 min
* @update_time: how often the userland be updated of the charging (msec)
* @alarm_low_mv: the voltage (mV) when low battery alarm is triggered
* @alarm_high_mv: the voltage (mV) when high battery alarm is triggered
* @max_voltage: the max voltage (mV) the battery should be charged up to
* @min_voltage: the voltage (mV) where charging method switches from
* trickle to fast. This is also the minimum voltage the
* system operates at
* @uvd_thresh_voltage: the USB falling UVD threshold (mV) (PM8917 only)
* @safe_current_ma: The upper limit of current allowed to be pushed in
* battery. This ends up writing in a one time
* programmable register.
* @resume_voltage_delta: the (mV) drop to wait for before resume charging
* after the battery has been fully charged
* @resume_charge_percent: the % SOC the charger will drop to after the
* battery is fully charged before resuming
* charging.
* @term_current: the charger current (mA) at which EOC happens
* @cool_temp: the temperature (degC) at which the battery is
* considered cool charging current and voltage is reduced.
* Use INT_MIN to indicate not valid.
* @warm_temp: the temperature (degC) at which the battery is
* considered warm charging current and voltage is reduced
* Use INT_MIN to indicate not valid.
* @temp_check_period: The polling interval in seconds to check battery
* temeperature if it has gone to cool or warm temperature
* area
* @max_bat_chg_current: Max charge current of the battery in mA
* Usually 70% of full charge capacity
* @usb_max_current: Maximum USB current in mA
* @cool_bat_chg_current: chg current (mA) when the battery is cool
* @warm_bat_chg_current: chg current (mA) when the battery is warm
* @cool_bat_voltage: chg voltage (mV) when the battery is cool
* @warm_bat_voltage: chg voltage (mV) when the battery is warm
* @get_batt_capacity_percent:
* a board specific function to return battery
* capacity. If null - a default one will be used
* @has_dc_supply: report DC online if this bit is set in board file
* @trkl_voltage: the trkl voltage in (mV) below which hw controlled
* trkl charging happens with linear charger
* @weak_voltage: the weak voltage (mV) below which hw controlled
* trkl charging happens with switching mode charger
* @trkl_current: the trkl current in (mA) to use for trkl charging phase
* @weak_current: the weak current in (mA) to use for weak charging phase
* @vin_min: the input voltage regulation point (mV) - if the
* voltage falls below this, the charger reduces charge
* current or stop charging temporarily
* @thermal_mitigation: the array of charge currents to use as temperature
* increases
* @thermal_levels: the number of thermal mitigation levels supported
* @cold_thr: if high battery will be cold when VBAT_THERM goes above
* 80% of VREF_THERM (typically 1.8volts), if low the
* battery will be considered cold if VBAT_THERM goes above
* 70% of VREF_THERM. Hardware defaults to low.
* @hot_thr: if high the battery will be considered hot when the
* VBAT_THERM goes below 35% of VREF_THERM, if low the
* battery will be considered hot when VBAT_THERM goes
* below 25% of VREF_THERM. Hardware defaults to low.
* @rconn_mohm: resistance in milliOhm from the vbat sense to ground
* with the battery terminals shorted. This indicates
* resistance of the pads, connectors, battery terminals
* and rsense.
* @led_src_config: Power source for anode of charger indicator LED.
* @btc_override: disable the comparators for conifugrations where a
* suitable voltages don't appear on vbatt therm line
* for the charger to detect battery is either cold / hot.
* @btc_override_cold_degc: Temperature in degCelcius when the battery is
* deemed cold and charging never happens. Used
* only if btc_override = 1
* @btc_override_hot_degc: Temperature in degCelcius when the battery is
* deemed hot and charging never happens. Used
* only if btc_override = 1
* @btc_delay_ms: Delay in milliseconds to monitor the battery temperature
* while charging when btc_override = 1
* @btc_panic_if_cant_stop_chg: flag to instruct the driver to panic if the
* driver couldn't stop charging when battery
* temperature is out of bounds. Used only if
* btc_override = 1
* stop_chg_upon_expiry: flag to indicate that the charger driver should
* stop charging the battery when the safety timer
* expires. If not set the charger driver will
* restart charging upon expiry.
*/
struct pm8921_charger_platform_data {
struct pm8xxx_charger_core_data charger_cdata;
unsigned int ttrkl_time;
unsigned int update_time;
unsigned int max_voltage;
unsigned int min_voltage;
unsigned int uvd_thresh_voltage;
unsigned int safe_current_ma;
unsigned int alarm_low_mv;
unsigned int alarm_high_mv;
unsigned int resume_voltage_delta;
int resume_charge_percent;
unsigned int term_current;
int cool_temp;
int warm_temp;
unsigned int temp_check_period;
unsigned int max_bat_chg_current;
unsigned int usb_max_current;
unsigned int cool_bat_chg_current;
unsigned int warm_bat_chg_current;
unsigned int cool_bat_voltage;
unsigned int warm_bat_voltage;
int hysteresis_temp;
unsigned int (*get_batt_capacity_percent) (void);
int64_t batt_id_min;
int64_t batt_id_max;
bool keep_btm_on_suspend;
bool has_dc_supply;
int trkl_voltage;
int weak_voltage;
int trkl_current;
int weak_current;
int vin_min;
int *thermal_mitigation;
int thermal_levels;
enum pm8921_chg_cold_thr cold_thr;
enum pm8921_chg_hot_thr hot_thr;
int rconn_mohm;
enum pm8921_chg_led_src_config led_src_config;
int battery_less_hardware;
int btc_override;
int btc_override_cold_degc;
int btc_override_hot_degc;
int btc_delay_ms;
int btc_panic_if_cant_stop_chg;
int stop_chg_upon_expiry;
bool disable_chg_rmvl_wrkarnd;
};
enum pm8921_charger_source {
PM8921_CHG_SRC_NONE,
PM8921_CHG_SRC_USB,
PM8921_CHG_SRC_DC,
};
#if defined(CONFIG_PM8921_CHARGER) || defined(CONFIG_PM8921_CHARGER_MODULE)
void pm8921_charger_vbus_draw(unsigned int mA);
int pm8921_charger_register_vbus_sn(void (*callback)(int));
void pm8921_charger_unregister_vbus_sn(void (*callback)(int));
/**
* pm8921_is_usb_chg_plugged_in - is usb plugged in
*
* if usb is under voltage or over voltage this will return false
*/
int pm8921_is_usb_chg_plugged_in(void);
/**
* pm8921_is_dc_chg_plugged_in - is dc plugged in
*
* if dc is under voltage or over voltage this will return false
*/
int pm8921_is_dc_chg_plugged_in(void);
/**
* pm8921_is_battery_present -
*
* returns if the pmic sees the battery present
*/
int pm8921_is_battery_present(void);
/**
* pm8921_set_max_battery_charge_current - set max battery chg current
*
* @ma: max charge current in milliAmperes
*/
int pm8921_set_max_battery_charge_current(int ma);
/**
* pm8921_disable_input_current_limt - disable input current limit
*
* @disable: disable input curren_limit limit
*
* Disabling the charge current limit causes current
* current limits to have no monitoring. An adequate charger
* capable of supplying high current while sustaining VIN_MIN
* is required if input current limiting is disabled.
*/
int pm8921_disable_input_current_limit(bool disable);
/**
* pm8921_set_usb_power_supply_type - set USB supply type
*
* @type: power_supply_type enum
*
* This api lets one set a specific usb power_supply_type.
* USB drivers can distinguish between types of USB connections
* and set the appropriate type for the USB supply.
*/
int pm8921_set_usb_power_supply_type(enum power_supply_type type);
/**
* pm8921_disable_source_current - disable drawing current from source
* @disable: true to disable current drawing from source false otherwise
*
* This function will stop all charging activities and disable any current
* drawn from the charger. The battery provides the system current.
*/
int pm8921_disable_source_current(bool disable);
/**
* pm8921_regulate_input_voltage -
* @voltage: voltage in millivolts to regulate
* allowable values are from 4300mV to 6500mV
*/
int pm8921_regulate_input_voltage(int voltage);
/**
* pm8921_is_battery_charging -
* @source: when the battery is charging the source is updated to reflect which
* charger, usb or dc, is charging the battery.
*
* RETURNS: bool, whether the battery is being charged or not
*/
bool pm8921_is_battery_charging(int *source);
/**
* pm8921_batt_temperature - get battery temp in degC
*
*/
int pm8921_batt_temperature(void);
/**
* pm8921_usb_ovp_set_threshold -
* Set the usb threshold as defined in by
* enum usb_ov_threshold
*/
int pm8921_usb_ovp_set_threshold(enum pm8921_usb_ov_threshold ov);
/**
* pm8921_usb_ovp_set_hystersis -
* @ms: the debounce time enum
*
* Sets the debounce time for usb insertion/removal detection
*
*/
int pm8921_usb_ovp_set_hystersis(enum pm8921_usb_debounce_time ms);
/**
* pm8921_usb_ovp_disable -
*
* when disabled there is no over voltage protection. The usb voltage is
* fed to the pmic as is. This should be disabled only when there is
* over voltage protection circuitry present outside the pmic chip.
*
*/
int pm8921_usb_ovp_disable(int disable);
/**
* pm8921_is_batfet_closed - battery fet status
*
* Returns 1 if batfet is closed 0 if open. On configurations without
* batfet this will return 0.
*/
int pm8921_is_batfet_closed(void);
#else
static inline void pm8921_charger_vbus_draw(unsigned int mA)
{
}
static inline int pm8921_charger_register_vbus_sn(void (*callback)(int))
{
return -ENXIO;
}
static inline void pm8921_charger_unregister_vbus_sn(void (*callback)(int))
{
}
static inline int pm8921_is_usb_chg_plugged_in(void)
{
return -ENXIO;
}
static inline int pm8921_is_dc_chg_plugged_in(void)
{
return -ENXIO;
}
static inline int pm8921_is_battery_present(void)
{
return -ENXIO;
}
static inline int pm8917_set_under_voltage_detection_threshold(int mv)
{
return -ENXIO;
}
static inline int pm8921_disable_input_current_limit(bool disable)
{
return -ENXIO;
}
static inline int pm8921_set_usb_power_supply_type(enum power_supply_type type)
{
return -ENXIO;
}
static inline int pm8921_set_max_battery_charge_current(int ma)
{
return -ENXIO;
}
static inline int pm8921_disable_source_current(bool disable)
{
return -ENXIO;
}
static inline int pm8921_regulate_input_voltage(int voltage)
{
return -ENXIO;
}
static inline bool pm8921_is_battery_charging(int *source)
{
*source = PM8921_CHG_SRC_NONE;
return 0;
}
static inline int pm8921_batt_temperature(void)
{
return -ENXIO;
}
static inline int pm8921_usb_ovp_set_threshold(enum pm8921_usb_ov_threshold ov)
{
return -ENXIO;
}
static inline int pm8921_usb_ovp_set_hystersis(enum pm8921_usb_debounce_time ms)
{
return -ENXIO;
}
static inline int pm8921_usb_ovp_disable(int disable)
{
return -ENXIO;
}
static inline int pm8921_is_batfet_closed(void)
{
return 1;
}
#endif
#endif
+147
View File
@@ -0,0 +1,147 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8921 driver header file
*
*/
#ifndef __MFD_PM8921_H
#define __MFD_PM8921_H
#include <linux/mfd/pm8xxx/irq.h>
#include <linux/mfd/pm8xxx/gpio.h>
#include <linux/mfd/pm8xxx/mpp.h>
#include <linux/mfd/pm8xxx/rtc.h>
#include <linux/mfd/pm8xxx/pwm.h>
#include <linux/mfd/pm8xxx/misc.h>
#include <linux/mfd/pm8xxx/tm.h>
#include <linux/mfd/pm8xxx/batt-alarm.h>
#include <linux/input/pmic8xxx-pwrkey.h>
#include <linux/input/pmic8xxx-keypad.h>
#include <linux/regulator/pm8xxx-regulator.h>
#include <linux/mfd/pm8xxx/pm8921-charger.h>
#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
#include <linux/mfd/pm8xxx/pm8921-bms.h>
#include <linux/leds-pm8xxx.h>
#include <linux/mfd/pm8xxx/vibrator.h>
#include <linux/mfd/pm8xxx/ccadc.h>
#define PM8921_NR_IRQS 256
#define PM8921_NR_GPIOS 44
#define PM8917_NR_GPIOS 38
#define PM8921_NR_MPPS 12
#define PM8917_NR_MPPS 10
#define PM8921_GPIO_BLOCK_START 24
#define PM8921_MPP_BLOCK_START 16
#define PM8921_IRQ_BLOCK_BIT(block, bit) ((block) * 8 + (bit))
/* GPIOs and MPPs [1,N] */
#define PM8921_GPIO_IRQ(base, gpio) ((base) + \
PM8921_IRQ_BLOCK_BIT(PM8921_GPIO_BLOCK_START, (gpio)-1))
#define PM8921_MPP_IRQ(base, mpp) ((base) + \
PM8921_IRQ_BLOCK_BIT(PM8921_MPP_BLOCK_START, (mpp)-1))
/* PMIC Interrupts */
#define PM8921_RTC_ALARM_IRQ PM8921_IRQ_BLOCK_BIT(4, 7)
#define PM8921_BATT_ALARM_IRQ PM8921_IRQ_BLOCK_BIT(5, 6)
#define PM8921_PWRKEY_REL_IRQ PM8921_IRQ_BLOCK_BIT(6, 2)
#define PM8921_PWRKEY_PRESS_IRQ PM8921_IRQ_BLOCK_BIT(6, 3)
#define PM8921_KEYPAD_IRQ PM8921_IRQ_BLOCK_BIT(9, 2)
#define PM8921_KEYSTUCK_IRQ PM8921_IRQ_BLOCK_BIT(9, 3)
#define PM8921_ADC_EOC_USR_IRQ PM8921_IRQ_BLOCK_BIT(9, 6)
#define PM8921_ADC_BATT_TEMP_WARM_IRQ PM8921_IRQ_BLOCK_BIT(9, 1)
#define PM8921_ADC_BATT_TEMP_COLD_IRQ PM8921_IRQ_BLOCK_BIT(9, 0)
#define PM8921_USB_ID_IN_IRQ(base) (base + PM8921_IRQ_BLOCK_BIT(6, 1))
#define PM8921_USBIN_VALID_IRQ PM8921_IRQ_BLOCK_BIT(1, 7)
#define PM8921_USBIN_OV_IRQ PM8921_IRQ_BLOCK_BIT(1, 6)
#define PM8921_BATT_INSERTED_IRQ PM8921_IRQ_BLOCK_BIT(1, 5)
#define PM8921_VBATDET_LOW_IRQ PM8921_IRQ_BLOCK_BIT(1, 4)
#define PM8921_USBIN_UV_IRQ PM8921_IRQ_BLOCK_BIT(1, 3)
#define PM8921_VBAT_OV_IRQ PM8921_IRQ_BLOCK_BIT(1, 2)
#define PM8921_CHGWDOG_IRQ PM8921_IRQ_BLOCK_BIT(1, 1)
#define PM8921_VCP_IRQ PM8921_IRQ_BLOCK_BIT(1, 0)
#define PM8921_ATCDONE_IRQ PM8921_IRQ_BLOCK_BIT(2, 7)
#define PM8921_ATCFAIL_IRQ PM8921_IRQ_BLOCK_BIT(2, 6)
#define PM8921_CHGDONE_IRQ PM8921_IRQ_BLOCK_BIT(2, 5)
#define PM8921_CHGFAIL_IRQ PM8921_IRQ_BLOCK_BIT(2, 4)
#define PM8921_CHGSTATE_IRQ PM8921_IRQ_BLOCK_BIT(2, 3)
#define PM8921_LOOP_CHANGE_IRQ PM8921_IRQ_BLOCK_BIT(2, 2)
#define PM8921_FASTCHG_IRQ PM8921_IRQ_BLOCK_BIT(2, 1)
#define PM8921_TRKLCHG_IRQ PM8921_IRQ_BLOCK_BIT(2, 0)
#define PM8921_BATT_REMOVED_IRQ PM8921_IRQ_BLOCK_BIT(3, 7)
#define PM8921_BATTTEMP_HOT_IRQ PM8921_IRQ_BLOCK_BIT(3, 6)
#define PM8921_CHGHOT_IRQ PM8921_IRQ_BLOCK_BIT(3, 5)
#define PM8921_BATTTEMP_COLD_IRQ PM8921_IRQ_BLOCK_BIT(3, 4)
#define PM8921_CHG_GONE_IRQ PM8921_IRQ_BLOCK_BIT(3, 3)
#define PM8921_BAT_TEMP_OK_IRQ PM8921_IRQ_BLOCK_BIT(3, 2)
#define PM8921_COARSE_DET_LOW_IRQ PM8921_IRQ_BLOCK_BIT(3, 1)
#define PM8921_VDD_LOOP_IRQ PM8921_IRQ_BLOCK_BIT(3, 0)
#define PM8921_VREG_OV_IRQ PM8921_IRQ_BLOCK_BIT(5, 7)
#define PM8921_VBATDET_IRQ PM8921_IRQ_BLOCK_BIT(5, 5)
#define PM8921_BATFET_IRQ PM8921_IRQ_BLOCK_BIT(5, 4)
#define PM8921_PSI_IRQ PM8921_IRQ_BLOCK_BIT(5, 3)
#define PM8921_DCIN_VALID_IRQ PM8921_IRQ_BLOCK_BIT(5, 2)
#define PM8921_DCIN_OV_IRQ PM8921_IRQ_BLOCK_BIT(5, 1)
#define PM8921_DCIN_UV_IRQ PM8921_IRQ_BLOCK_BIT(5, 0)
#define PM8921_BMS_SBI_WRITE_OK PM8921_IRQ_BLOCK_BIT(15, 7)
#define PM8921_BMS_CC_THR PM8921_IRQ_BLOCK_BIT(15, 6)
#define PM8921_BMS_VSENSE_THR PM8921_IRQ_BLOCK_BIT(15, 5)
#define PM8921_BMS_VSENSE_FOR_R PM8921_IRQ_BLOCK_BIT(15, 4)
#define PM8921_BMS_OCV_FOR_R PM8921_IRQ_BLOCK_BIT(15, 3)
#define PM8921_BMS_GOOD_OCV PM8921_IRQ_BLOCK_BIT(15, 2)
#define PM8921_BMS_VSENSE_AVG PM8921_IRQ_BLOCK_BIT(15, 1)
#define PM8921_BMS_CCADC_EOC PM8921_IRQ_BLOCK_BIT(15, 0)
#define PM8921_OVERTEMP_IRQ PM8921_IRQ_BLOCK_BIT(4, 2)
#define PM8921_TEMPSTAT_IRQ PM8921_IRQ_BLOCK_BIT(6, 7)
#define PM8921_RESOUT_IRQ PM8921_IRQ_BLOCK_BIT(6, 4)
#define PM8921_USB_OTG_OCP_IRQ PM8921_IRQ_BLOCK_BIT(6, 0)
#define PM8921_LVS7_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 7)
#define PM8921_LVS6_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 6)
#define PM8921_LVS5_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 5)
#define PM8921_LVS4_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 4)
#define PM8921_LVS3_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 3)
#define PM8921_LVS2_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 2)
#define PM8921_LVS1_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 1)
#define PM8921_HDMI_MVS_OCP_IRQ PM8921_IRQ_BLOCK_BIT(13, 0)
/* PMIC I/O Resources */
#define PM8921_RTC_BASE 0x11D
struct pm8921_platform_data {
int irq_base;
struct pm8xxx_irq_platform_data *irq_pdata;
struct pm8xxx_gpio_platform_data *gpio_pdata;
struct pm8xxx_mpp_platform_data *mpp_pdata;
struct pm8xxx_rtc_platform_data *rtc_pdata;
struct pm8xxx_pwrkey_platform_data *pwrkey_pdata;
struct pm8xxx_keypad_platform_data *keypad_pdata;
struct pm8921_charger_platform_data *charger_pdata;
struct pm8921_bms_platform_data *bms_pdata;
struct pm8xxx_misc_platform_data *misc_pdata;
struct pm8xxx_regulator_platform_data *regulator_pdatas;
int num_regulators;
struct pm8xxx_adc_platform_data *adc_pdata;
struct pm8xxx_led_platform_data *leds_pdata;
struct pm8xxx_vibrator_platform_data *vibrator_pdata;
struct pm8xxx_ccadc_platform_data *ccadc_pdata;
struct pm8xxx_pwm_platform_data *pwm_pdata;
};
#endif
@@ -0,0 +1,604 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC 8921/8018 ADC driver header file
*
*/
#ifndef __PM8XXX_ADC_H
#define __PM8XXX_ADC_H
#include <linux/kernel.h>
#include <linux/list.h>
/**
* enum pm8xxx_adc_channels - PM8XXX AMUX arbiter channels
* %CHANNEL_VCOIN: Backup voltage for certain register set
* %CHANNEL_VBAT: Battery voltage
* %CHANNEL_DCIN: Charger input voltage without internal OVP
* %CHANNEL_ICHG: Charge-current monitor
* %CHANNEL_VPH_PWR: Main system power
* %CHANNEL_IBAT: Battery charge current
* %CHANNEL_MPP_1: 16:1 pre-mux unity scale MPP input
* %CHANNEL_MPP_2: 16:1 pre-mux 1/3 scale MPP input
* %CHANNEL_BATT_THERM: Battery temperature
* %CHANNEL_BATT_ID: Battery detection
* %CHANNEL_USBIN: Charger input voltage with internal OVP
* %CHANNEL_DIE_TEMP: Pmic_die temperature
* %CHANNEL_625MV: 625mv reference channel
* %CHANNEL_125V: 1.25v reference channel
* %CHANNEL_CHG_TEMP: Charger temperature
* %CHANNEL_MUXOFF: Channel to reduce input load on the mux
* %CHANNEL_NONE: Do not use this channel
*/
enum pm8xxx_adc_channels {
CHANNEL_VCOIN = 0,
CHANNEL_VBAT,
CHANNEL_DCIN,
CHANNEL_ICHG,
CHANNEL_VPH_PWR,
CHANNEL_IBAT,
CHANNEL_MPP_1,
CHANNEL_MPP_2,
CHANNEL_BATT_THERM,
/* PM8018 ADC Arbiter uses a single channel on AMUX8
* to read either Batt_id or Batt_therm.
*/
CHANNEL_BATT_ID_THERM = CHANNEL_BATT_THERM,
CHANNEL_BATT_ID,
CHANNEL_USBIN,
CHANNEL_DIE_TEMP,
CHANNEL_625MV,
CHANNEL_125V,
CHANNEL_CHG_TEMP,
CHANNEL_MUXOFF,
CHANNEL_NONE,
ADC_MPP_1_ATEST_8 = 20,
ADC_MPP_1_USB_SNS_DIV20,
ADC_MPP_1_DCIN_SNS_DIV20,
ADC_MPP_1_AMUX3,
ADC_MPP_1_AMUX4,
ADC_MPP_1_AMUX5,
ADC_MPP_1_AMUX6,
ADC_MPP_1_AMUX7,
ADC_MPP_1_AMUX8,
ADC_MPP_1_ATEST_1,
ADC_MPP_1_ATEST_2,
ADC_MPP_1_ATEST_3,
ADC_MPP_1_ATEST_4,
ADC_MPP_1_ATEST_5,
ADC_MPP_1_ATEST_6,
ADC_MPP_1_ATEST_7,
ADC_MPP_2_ATEST_8 = 40,
ADC_MPP_2_USB_SNS_DIV20,
ADC_MPP_2_DCIN_SNS_DIV20,
ADC_MPP_2_AMUX3,
ADC_MPP_2_AMUX4,
ADC_MPP_2_AMUX5,
ADC_MPP_2_AMUX6,
ADC_MPP_2_AMUX7,
ADC_MPP_2_AMUX8,
ADC_MPP_2_ATEST_1,
ADC_MPP_2_ATEST_2,
ADC_MPP_2_ATEST_3,
ADC_MPP_2_ATEST_4,
ADC_MPP_2_ATEST_5,
ADC_MPP_2_ATEST_6,
ADC_MPP_2_ATEST_7,
ADC_CHANNEL_MAX_NUM,
};
#define PM8XXX_ADC_PMIC_0 0x0
#define PM8XXX_CHANNEL_ADC_625_UV 625000
#define PM8XXX_CHANNEL_MPP_SCALE1_IDX 20
#define PM8XXX_CHANNEL_MPP_SCALE3_IDX 40
#define PM8XXX_AMUX_MPP_3 0x3
#define PM8XXX_AMUX_MPP_4 0x4
#define PM8XXX_AMUX_MPP_5 0x5
#define PM8XXX_AMUX_MPP_6 0x6
#define PM8XXX_AMUX_MPP_7 0x7
#define PM8XXX_AMUX_MPP_8 0x8
#define PM8XXX_ADC_DEV_NAME "pm8xxx-adc"
/**
* enum pm8xxx_adc_decimation_type - Sampling rate supported
* %ADC_DECIMATION_TYPE1: 512
* %ADC_DECIMATION_TYPE2: 1K
* %ADC_DECIMATION_TYPE3: 2K
* %ADC_DECIMATION_TYPE4: 4k
* %ADC_DECIMATION_NONE: Do not use this Sampling type
*
* The Sampling rate is specific to each channel of the PM8XXX ADC arbiter.
*/
enum pm8xxx_adc_decimation_type {
ADC_DECIMATION_TYPE1 = 0,
ADC_DECIMATION_TYPE2,
ADC_DECIMATION_TYPE3,
ADC_DECIMATION_TYPE4,
ADC_DECIMATION_NONE,
};
/**
* enum pm8xxx_adc_calib_type - PM8XXX ADC Calibration type
* %ADC_CALIB_ABSOLUTE: Use 625mV and 1.25V reference channels
* %ADC_CALIB_RATIOMETRIC: Use reference Voltage/GND
* %ADC_CALIB_CONFIG_NONE: Do not use this calibration type
*
* Use the input reference voltage depending on the calibration type
* to calcluate the offset and gain parameters. The calibration is
* specific to each channel of the PM8XXX ADC.
*/
enum pm8xxx_adc_calib_type {
ADC_CALIB_ABSOLUTE = 0,
ADC_CALIB_RATIOMETRIC,
ADC_CALIB_NONE,
};
/**
* enum pm8xxx_adc_channel_scaling_param - pre-scaling AMUX ratio
* %CHAN_PATH_SCALING1: ratio of {1, 1}
* %CHAN_PATH_SCALING2: ratio of {1, 3}
* %CHAN_PATH_SCALING3: ratio of {1, 4}
* %CHAN_PATH_SCALING4: ratio of {1, 6}
* %CHAN_PATH_NONE: Do not use this pre-scaling ratio type
*
* The pre-scaling is applied for signals to be within the voltage range
* of the ADC.
*/
enum pm8xxx_adc_channel_scaling_param {
CHAN_PATH_SCALING1 = 0,
CHAN_PATH_SCALING2,
CHAN_PATH_SCALING3,
CHAN_PATH_SCALING4,
CHAN_PATH_SCALING_NONE,
};
/**
* enum pm8xxx_adc_amux_input_rsv - HK/XOADC reference voltage
* %AMUX_RSV0: XO_IN/XOADC_GND
* %AMUX_RSV1: PMIC_IN/XOADC_GND
* %AMUX_RSV2: PMIC_IN/BMS_CSP
* %AMUX_RSV3: not used
* %AMUX_RSV4: XOADC_GND/XOADC_GND
* %AMUX_RSV5: XOADC_VREF/XOADC_GND
* %AMUX_NONE: Do not use this input reference voltage selection
*/
enum pm8xxx_adc_amux_input_rsv {
AMUX_RSV0 = 0,
AMUX_RSV1,
AMUX_RSV2,
AMUX_RSV3,
AMUX_RSV4,
AMUX_RSV5,
AMUX_NONE,
};
/**
* enum pm8xxx_adc_premux_mpp_scale_type - 16:1 pre-mux scale ratio
* %PREMUX_MPP_SCALE_0: No scaling to the input signal
* %PREMUX_MPP_SCALE_1: Unity scaling selected by the user for MPP input
* %PREMUX_MPP_SCALE_1_DIV3: 1/3 pre-scale to the input MPP signal
* %PREMUX_MPP_NONE: Do not use this pre-scale mpp type
*/
enum pm8xxx_adc_premux_mpp_scale_type {
PREMUX_MPP_SCALE_0 = 0,
PREMUX_MPP_SCALE_1,
PREMUX_MPP_SCALE_1_DIV3,
PREMUX_MPP_NONE,
};
/**
* enum pm8xxx_adc_scale_fn_type - Scaling function for pm8921 pre calibrated
* digital data relative to ADC reference
* %ADC_SCALE_DEFAULT: Default scaling to convert raw adc code to voltage
* %ADC_SCALE_BATT_THERM: Conversion to temperature based on btm parameters
* %ADC_SCALE_PMIC_THERM: Returns result in milli degree's Centigrade
* %ADC_SCALE_XTERN_CHGR_CUR: Returns current across 0.1 ohm resistor
* %ADC_SCALE_XOTHERM: Returns XO thermistor voltage in degree's Centigrade
* %ADC_SCALE_NONE: Do not use this scaling type
*/
enum pm8xxx_adc_scale_fn_type {
ADC_SCALE_DEFAULT = 0,
ADC_SCALE_BATT_THERM,
ADC_SCALE_PA_THERM,
ADC_SCALE_PMIC_THERM,
ADC_SCALE_XOTHERM,
ADC_SCALE_NONE,
};
/**
* struct pm8xxx_adc_linear_graph - Represent ADC characteristics
* @dy: Numerator slope to calculate the gain
* @dx: Denominator slope to calculate the gain
* @adc_vref: A/D word of the voltage reference used for the channel
* @adc_gnd: A/D word of the ground reference used for the channel
*
* Each ADC device has different offset and gain parameters which are computed
* to calibrate the device.
*/
struct pm8xxx_adc_linear_graph {
int64_t dy;
int64_t dx;
int64_t adc_vref;
int64_t adc_gnd;
};
/**
* struct pm8xxx_adc_map_pt - Map the graph representation for ADC channel
* @x: Represent the ADC digitized code
* @y: Represent the physical data which can be temperature, voltage,
* resistance
*/
struct pm8xxx_adc_map_pt {
int32_t x;
int32_t y;
};
/**
* struct pm8xxx_adc_scaling_ratio - Represent scaling ratio for adc input
* @num: Numerator scaling parameter
* @den: Denominator scaling parameter
*/
struct pm8xxx_adc_scaling_ratio {
int32_t num;
int32_t den;
};
/**
* struct pm8xxx_adc_properties - Represent the ADC properties
* @adc_reference: Reference voltage for PM8XXX ADC
* @bitresolution: ADC bit resolution for PM8XXX ADC
* @biploar: Polarity for PM8XXX ADC
*/
struct pm8xxx_adc_properties {
uint32_t adc_vdd_reference;
uint32_t bitresolution;
bool bipolar;
};
/**
* struct pm8xxx_adc_chan_properties - Represent channel properties of the ADC
* @offset_gain_numerator: The inverse numerator of the gain applied to the
* input channel
* @offset_gain_denominator: The inverse denominator of the gain applied to the
* input channel
* @adc_graph: ADC graph for the channel of struct type pm8xxx_adc_linear_graph
*/
struct pm8xxx_adc_chan_properties {
uint32_t offset_gain_numerator;
uint32_t offset_gain_denominator;
struct pm8xxx_adc_linear_graph adc_graph[2];
};
/**
* struct pm8xxx_adc_chan_result - Represent the result of the PM8XXX ADC
* @chan: The channel number of the requested conversion
* @adc_code: The pre-calibrated digital output of a given ADC relative to the
* the ADC reference
* @measurement: In units specific for a given ADC; most ADC uses reference
* voltage but some ADC uses reference current. This measurement
* here is a number relative to a reference of a given ADC
* @physical: The data meaningful for each individual channel whether it is
* voltage, current, temperature, etc.
* All voltage units are represented in micro - volts.
* -Battery temperature units are represented as 0.1 DegC
* -PA Therm temperature units are represented as DegC
* -PMIC Die temperature units are represented as 0.001 DegC
*/
struct pm8xxx_adc_chan_result {
uint32_t chan;
int32_t adc_code;
int64_t measurement;
int64_t physical;
};
#if defined(CONFIG_SENSORS_PM8XXX_ADC) \
|| defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE)
/**
* pm8xxx_adc_scale_default() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: Physical result to be stored.
*/
int32_t pm8xxx_adc_scale_default(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
/**
* pm8xxx_adc_scale_tdkntcg_therm() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset. Returns the temperature of the xo therm in mili
degC.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: physical result to be stored.
*/
int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
/**
* pm8xxx_adc_scale_batt_therm() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset. Returns the temperature in degC.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: physical result to be stored.
*/
int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
/**
* pm8xxx_adc_scale_pa_therm() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset. Returns the temperature in degC.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: physical result to be stored.
*/
int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
/**
* pm8xxx_adc_scale_pmic_therm() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset. Performs the AMUX out as 2mv/K and returns
* the temperature in mili degC.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: physical result to be stored.
*/
int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
/**
* pm8xxx_adc_scale_batt_id() - Scales the pre-calibrated digital output
* of an ADC to the ADC reference and compensates for the
* gain and offset.
* @adc_code: pre-calibrated digital ouput of the ADC.
* @adc_prop: adc properties of the pm8xxx adc such as bit resolution,
* reference voltage.
* @chan_prop: individual channel properties to compensate the i/p scaling,
* slope and offset.
* @chan_rslt: physical result to be stored.
*/
int32_t pm8xxx_adc_scale_batt_id(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt);
#else
static inline int32_t pm8xxx_adc_scale_default(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t pm8xxx_adc_tdkntcg_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t pm8xxx_adc_scale_batt_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t pm8xxx_adc_scale_pa_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t pm8xxx_adc_scale_pmic_therm(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
static inline int32_t pm8xxx_adc_scale_batt_id(int32_t adc_code,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop,
struct pm8xxx_adc_chan_result *chan_rslt)
{ return -ENXIO; }
#endif
/**
* struct pm8xxx_adc_scale_fn - Scaling function prototype
* @chan: Function pointer to one of the scaling functions
* which takes the adc properties, channel properties,
* and returns the physical result
*/
struct pm8xxx_adc_scale_fn {
int32_t (*chan) (int32_t,
const struct pm8xxx_adc_properties *,
const struct pm8xxx_adc_chan_properties *,
struct pm8xxx_adc_chan_result *);
};
/**
* struct pm8xxx_adc_amux - AMUX properties for individual channel
* @name: Channel name
* @channel_name: Channel in integer used from pm8xxx_adc_channels
* @chan_path_prescaling: Channel scaling performed on the input signal
* @adc_rsv: Input reference Voltage/GND selection to the ADC
* @adc_decimation: Sampling rate desired for the channel
* adc_scale_fn: Scaling function to convert to the data meaningful for
* each individual channel whether it is voltage, current,
* temperature, etc and compensates the channel properties
*/
struct pm8xxx_adc_amux {
char *name;
enum pm8xxx_adc_channels channel_name;
enum pm8xxx_adc_channel_scaling_param chan_path_prescaling;
enum pm8xxx_adc_amux_input_rsv adc_rsv;
enum pm8xxx_adc_decimation_type adc_decimation;
enum pm8xxx_adc_scale_fn_type adc_scale_fn;
};
/**
* struct pm8xxx_adc_arb_btm_param - PM8XXX ADC BTM parameters to set threshold
* temperature for client notification
* @low_thr_temp: low temperature threshold request for notification
* @high_thr_temp: high temperature threshold request for notification
* @low_thr_voltage: low temperature converted to voltage by arbiter driver
* @high_thr_voltage: high temperature converted to voltage by arbiter driver
* @interval: Interval period to check for temperature notification
* @btm_warm_fn: Remote function call for warm threshold.
* @btm_cool_fn: Remote function call for cold threshold.
*
* BTM client passes the parameters to be set for the
* temperature threshold notifications. The client is
* responsible for setting the new threshold
* levels once the thresholds are reached
*/
struct pm8xxx_adc_arb_btm_param {
int32_t low_thr_temp;
int32_t high_thr_temp;
uint64_t low_thr_voltage;
uint64_t high_thr_voltage;
int32_t interval;
void (*btm_warm_fn) (bool);
void (*btm_cool_fn) (bool);
};
int32_t pm8xxx_adc_batt_scaler(struct pm8xxx_adc_arb_btm_param *,
const struct pm8xxx_adc_properties *adc_prop,
const struct pm8xxx_adc_chan_properties *chan_prop);
/**
* struct pm8xxx_adc_platform_data - PM8XXX ADC platform data
* @adc_prop: ADC specific parameters, voltage and channel setup
* @adc_channel: Channel properties of the ADC arbiter
* @adc_num_board_channel: Number of channels added in the board file
* @adc_mpp_base: PM8XXX MPP0 base passed from board file. This is used
* to offset the PM8XXX MPP passed to configure the
* the MPP to AMUX mapping.
*/
struct pm8xxx_adc_platform_data {
struct pm8xxx_adc_properties *adc_prop;
struct pm8xxx_adc_amux *adc_channel;
uint32_t adc_num_board_channel;
uint32_t adc_mpp_base;
};
/* Public API */
#if defined(CONFIG_SENSORS_PM8XXX_ADC) \
|| defined(CONFIG_SENSORS_PM8XXX_ADC_MODULE)
/**
* pm8xxx_adc_read() - Performs ADC read on the channel.
* @channel: Input channel to perform the ADC read.
* @result: Structure pointer of type adc_chan_result
* in which the ADC read results are stored.
*/
uint32_t pm8xxx_adc_read(enum pm8xxx_adc_channels channel,
struct pm8xxx_adc_chan_result *result);
/**
* pm8xxx_adc_mpp_config_read() - Configure's the PM8XXX MPP
* to AMUX6 and performs an ADC read.
*
* On PM8921 ADC the MPP needs to first be configured
* as an analog input to the AMUX pre-mux channel before
* issuing a read request. PM8921 MPP 8 is mapped to AMUX8
* and is common between remote processor's.
*
* On PM8018 ADC the MPP is directly connected to the AMUX
* pre-mux. Therefore clients of the PM8018 MPP do not need
* to configure the MPP as an analog input to the pre-mux.
* Clients can directly issue request on the pre-mux AMUX
* channel to read the ADC on the MPP. Clients can directly
* call the pm8xxx_adc_read().
* @mpp_num PM8XXX MPP number to configure to AMUX6.
* @channel: Input channel to perform the ADC read.
* a) 'ADC_MPP_1_AMUX6' if the input voltage is less than 1.8V
* b) 'ADC_MPP_2_AMUX6' if the input voltage is greater then 1.8V
* the input voltage is pre-divided by 3 and passed to the ADC.
* The appropriate scaling function needs to be selected to let
* the driver know a post scaling is required before returning
* the result.
* @result: Structure pointer of type adc_chan_result
* in which the ADC read results are stored.
*/
uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num,
enum pm8xxx_adc_channels channel,
struct pm8xxx_adc_chan_result *result);
/**
* pm8xxx_adc_btm_start() - Configure the BTM registers and start
monitoring the BATT_THERM channel for
threshold warm/cold temperature set
by the Battery client. The btm_start
api is to be used after calling the
pm8xxx_btm_configure() api which sets
the temperature thresholds, interval
and functions to call when warm/cold
events are triggered.
* @param: none.
*/
uint32_t pm8xxx_adc_btm_start(void);
/**
* pm8xxx_adc_btm_end() - Configures the BTM registers to stop
* monitoring the BATT_THERM channel for
* warm/cold events and disables the
* interval timer.
* @param: none.
*/
uint32_t pm8xxx_adc_btm_end(void);
/**
* pm8xxx_adc_btm_configure() - Configures the BATT_THERM channel
* parameters for warm/cold thresholds.
* Sets the interval timer for perfoming
* reading the temperature done by the HW.
* @btm_param: Structure pointer of type adc_arb_btm_param *
* which client provides for threshold warm/cold,
* interval and functions to call when warm/cold
* events are triggered.
*/
uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *);
#else
static inline uint32_t pm8xxx_adc_read(uint32_t channel,
struct pm8xxx_adc_chan_result *result)
{ return -ENXIO; }
static inline uint32_t pm8xxx_adc_mpp_config_read(uint32_t mpp_num,
enum pm8xxx_adc_channels channel,
struct pm8xxx_adc_chan_result *result)
{ return -ENXIO; }
static inline uint32_t pm8xxx_adc_btm_start(void)
{ return -ENXIO; }
static inline uint32_t pm8xxx_adc_btm_end(void)
{ return -ENXIO; }
static inline uint32_t pm8xxx_adc_btm_configure(
struct pm8xxx_adc_arb_btm_param *param)
{ return -ENXIO; }
#endif
#endif /* PM8XXX_ADC_H */
+172
View File
@@ -0,0 +1,172 @@
/* Copyright (c) 2011-2013, 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 __PM8XXX_PWM_H__
#define __PM8XXX_PWM_H__
#include <linux/pwm.h>
#define PM8XXX_PWM_DEV_NAME "pm8xxx-pwm"
#define PM8XXX_PWM_PERIOD_MIN 7 /* usec: 19.2M, n=6, m=0, pre=2 */
#define PM8XXX_PWM_PERIOD_MAX (384 * USEC_PER_SEC) /* 1K, n=9, m=7, pre=6 */
#define PM_PWM_LUT_SIZE 64
#define PM_PWM_LUT_DUTY_TIME_MAX 512 /* ms */
#define PM_PWM_LUT_PAUSE_MAX (7000 * PM_PWM_LUT_DUTY_TIME_MAX)
/* Flags for Look Up Table */
#define PM_PWM_LUT_LOOP 0x01
#define PM_PWM_LUT_RAMP_UP 0x02
#define PM_PWM_LUT_REVERSE 0x04
#define PM_PWM_LUT_PAUSE_HI_EN 0x10
#define PM_PWM_LUT_PAUSE_LO_EN 0x20
#define PM_PWM_LUT_NO_TABLE 0x100
#define PM_PWM_BANK_LO 0x1000
#define PM_PWM_BANK_HI 0x2000
/**
* PWM frequency/period control
*
* PWM Frequency = ClockFrequency / (N * T)
* or
* PWM Period = Clock Period * (N * T)
* where
* N = 2^9 or 2^6 for 9-bit or 6-bit PWM size
* T = Pre-divide * 2^m, m = 0..7 (exponent)
*
*/
enum pm_pwm_size {
PM_PWM_SIZE_6BIT = 6,
PM_PWM_SIZE_9BIT = 9,
};
enum pm_pwm_clk {
PM_PWM_CLK_1KHZ,
PM_PWM_CLK_32KHZ,
PM_PWM_CLK_19P2MHZ,
};
enum pm_pwm_pre_div {
PM_PWM_PDIV_2,
PM_PWM_PDIV_3,
PM_PWM_PDIV_5,
PM_PWM_PDIV_6,
};
/**
* struct pm8xxx_pwm_period - PWM period structure
* @pwm_size: enum pm_pwm_size
* @clk: enum pm_pwm_clk
* @pre_div: enum pm_pwm_pre_div
* @pre_div_exp: exponent of 2 as part of pre-divider: 0..7
*/
struct pm8xxx_pwm_period {
enum pm_pwm_size pwm_size;
enum pm_pwm_clk clk;
enum pm_pwm_pre_div pre_div;
int pre_div_exp;
};
/**
* struct pm8xxx_pwm_duty_cycles - PWM duty cycle info
* duty_pcts - pointer to an array of duty percentage for a pwm period
* num_duty_pcts - total entries in duty_pcts array
* duty_ms - duty cycle time in ms
* start_idx - index in the LUT
*/
struct pm8xxx_pwm_duty_cycles {
int *duty_pcts;
int num_duty_pcts;
int duty_ms;
int start_idx;
};
/**
* struct pm8xxx_pwm_platform_data - PWM platform data
* dtest_channel - Enable LPG DTEST mode for this LPG channel
*/
struct pm8xxx_pwm_platform_data {
int dtest_channel;
};
/**
* pm8xxx_pwm_config_period - change PWM period
*
* @pwm: the PWM device
* @pwm_p: period in struct pm8xxx_pwm_period
*/
int pm8xxx_pwm_config_period(struct pwm_device *pwm,
struct pm8xxx_pwm_period *pwm_p);
/**
* pm8xxx_pwm_config_pwm_value - change a PWM device configuration
* @pwm: the PWM device
* @pwm_value: the duty cycle in raw PWM value (< 2^pwm_size)
*/
int pm8xxx_pwm_config_pwm_value(struct pwm_device *pwm, int pwm_value);
/**
* pm8xxx_pwm_lut_config - change a PWM device configuration to use LUT
* @pwm: the PWM device
* @period_us: period in micro second
* @duty_pct: arrary of duty cycles in percent, like 20, 50.
* @duty_time_ms: time for each duty cycle in millisecond
* @start_idx: start index in lookup table from 0 to MAX-1
* @idx_len: number of index
* @pause_lo: pause time in millisecond at low index
* @pause_hi: pause time in millisecond at high index
* @flags: control flags
*/
int pm8xxx_pwm_lut_config(struct pwm_device *pwm, int period_us,
int duty_pct[], int duty_time_ms, int start_idx,
int len, int pause_lo, int pause_hi, int flags);
/**
* pm8xxx_pwm_lut_enable - control a PWM device to start/stop LUT ramp
* @pwm: the PWM device
* @start: to start (1), or stop (0)
*/
int pm8xxx_pwm_lut_enable(struct pwm_device *pwm, int start);
/* Standard APIs supported */
/**
* pwm_request - request a PWM device
* @pwm_id: PWM id or channel
* @label: the label to identify the user
*/
/**
* pwm_free - free a PWM device
* @pwm: the PWM device
*/
/**
* pwm_config - change a PWM device configuration
* @pwm: the PWM device
* @period_us: period in microsecond
* @duty_us: duty cycle in microsecond
*/
/**
* pwm_enable - start a PWM output toggling
* @pwm: the PWM device
*/
/**
* pwm_disable - stop a PWM output toggling
* @pwm: the PWM device
*/
#endif /* __PM8XXX_PWM_H__ */
+271
View File
@@ -0,0 +1,271 @@
/* Copyright (c) 2011-2012, 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 __MFD_PM8XXX_REGULATOR_H__
#define __MFD_PM8XXX_REGULATOR_H__
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/pm8xxx-regulator.h>
/**
* enum pm8xxx_regulator_type - possible PM8XXX voltage regulator types
* %PM8XXX_REGULATOR_TYPE_PLDO: PMOS low drop-out linear regulator
* %PM8XXX_REGULATOR_TYPE_NLDO: NMOS low drop-out linear regulator
* %PM8XXX_REGULATOR_TYPE_NLDO1200: NMOS low drop-out linear regulator
* capable of supplying up to 1200 mA
* %PM8XXX_REGULATOR_TYPE_SMPS: switched-mode power supply (buck)
* %PM8XXX_REGULATOR_TYPE_FTSMPS: fast transient switched-mode power
* supply (buck)
* %PM8XXX_REGULATOR_TYPE_VS: voltage switch capable of sourcing 100mA
* %PM8XXX_REGULATOR_TYPE_VS300: voltage switch capable of sourcing 300mA
* %PM8XXX_REGULATOR_TYPE_NCP: negative charge pump
* %PM8XXX_REGULATOR_TYPE_BOOST: boost regulator
* %PM8XXX_REGULATOR_TYPE_MAX: used internally for error checking; not
* a valid regulator type.
*
* Each of these has a different register control interface.
*/
enum pm8xxx_regulator_type {
PM8XXX_REGULATOR_TYPE_PLDO,
PM8XXX_REGULATOR_TYPE_NLDO,
PM8XXX_REGULATOR_TYPE_NLDO1200,
PM8XXX_REGULATOR_TYPE_SMPS,
PM8XXX_REGULATOR_TYPE_FTSMPS,
PM8XXX_REGULATOR_TYPE_VS,
PM8XXX_REGULATOR_TYPE_VS300,
PM8XXX_REGULATOR_TYPE_NCP,
PM8XXX_REGULATOR_TYPE_BOOST,
PM8XXX_REGULATOR_TYPE_MAX,
};
/**
* struct pm8xxx_vreg - regulator configuration and state data used by the
* pm8xxx-regulator driver
* @rdesc: regulator description
* @rdesc_pc: pin control regulator description. rdesc_pc.name == NULL
* implies that there is no pin control version of this
* regulator.
* @type: regulator type
* @hpm_min_load: minimum load in uA that will result in the regulator
* being set to high power mode
* @ctrl_addr: control register SSBI address
* @test_addr: test register SSBI address (not needed for all types)
* @clk_ctrl_addr: clock control register SSBI address (only used by SMPS
* type regulators)
* @sleep_ctrl_addr: sleep control register SSBI address (only used by SMPS
* type regulators)
* @pfm_ctrl_addr: pulse-frequency modulation control register SSBI address
* (only used by FTSMPS type regulators)
* @pwr_cnfg_addr: power configuration register SSBI address (only used by
* FTSMPS type regulators)
* @pdata: this platform data struct is filled based using the
* platform data pointed to in a core platform data struct
* @rdev: pointer to regulator device which is created with
* regulator_register
* @rdev_pc: pointer to pin controlled regulator device which is
* created with regulator_register
* @dev: pointer to pm8xxx-regulator device
* @dev_pc: pointer to pin control pm8xxx-regulator device
* @pc_lock: mutex lock to handle sharing between pin controlled and
* non-pin controlled versions of a given regulator. Note,
* this lock must be initialized in the PMIC core driver.)
* @save_uV: current regulator voltage in uV
* @mode: current mode of the regulator
* @write_count: number of SSBI writes that have taken place for this
* regulator. This is used for debug printing to determine
* if a given operation is redundant.
* @prev_write_count: number of SSBI writes that have taken place for this
* regulator at the start of an operation. This is used for
* debug printing to determine if a given operation is
* redundant.
* @is_enabled: true if the regulator is currently enabled, false if not
* @is_enabled_pc: true if the pin controlled version of the regulator is
* currently enabled (i.e. pin control is active), false if
* not
* @test_reg: last value read from or written to each of the banks of
* the test register
* @ctrl_reg: last value read from or written to the control register
* @clk_ctrl_reg: last value read from or written to the clock control
* register
* @sleep_ctrl_reg: last value read from or written to the sleep control
* register
* @pfm_ctrl_reg: last value read from or written to the PFM control
* register
* @pwr_cnfg_reg: last value read from or written to the power
* configuration register
*
* This data structure should only need to be instantiated in a PMIC core driver
* It is used to specify PMIC specific as opposed to board specific
* configuration data. It is also used to hold all state variables needed by
* the pm8xxx-regulator driver as these variables need to be shared between
* pin controlled and non-pin controlled versions of a given regulator, which
* are probed separately.
*/
struct pm8xxx_vreg {
/* Configuration data */
struct regulator_desc rdesc;
struct regulator_desc rdesc_pc;
enum pm8xxx_regulator_type type;
const int hpm_min_load;
const u16 ctrl_addr;
const u16 test_addr;
const u16 clk_ctrl_addr;
const u16 sleep_ctrl_addr;
const u16 pfm_ctrl_addr;
const u16 pwr_cnfg_addr;
/* State data */
struct pm8xxx_regulator_platform_data pdata;
struct regulator_dev *rdev;
struct regulator_dev *rdev_pc;
struct device *dev;
struct device *dev_pc;
struct mutex pc_lock;
int save_uV;
int mode;
u32 write_count;
u32 prev_write_count;
bool is_enabled;
bool is_enabled_pc;
u8 test_reg[REGULATOR_TEST_BANKS_MAX];
u8 ctrl_reg;
u8 clk_ctrl_reg;
u8 sleep_ctrl_reg;
u8 pfm_ctrl_reg;
u8 pwr_cnfg_reg;
};
/**
* struct pm8xxx_regulator_core_platform_data - platform data specified in a
* PMIC core driver and utilized in the pm8xxx-regulator driver
* @vreg: pointer to pm8xxx_vreg data structure that may be shared
* between pin controlled and non-pin controlled versions
* of a given regulator. Note that this data must persist
* as long as the regulator device is in use.
* @pdata: pointer to platform data passed in from a board file
* @is_pin_controlled: true if the regulator driver represents the pin control
* portion of a regulator, false if not.
*
* This data structure should only be needed in a PMIC core driver.
*/
struct pm8xxx_regulator_core_platform_data {
struct pm8xxx_vreg *vreg;
struct pm8xxx_regulator_platform_data *pdata;
bool is_pin_controlled;
};
/* Helper macros */
#define PLDO(_name, _pc_name, _ctrl_addr, _test_addr, _hpm_min_load) \
{ \
.type = PM8XXX_REGULATOR_TYPE_PLDO, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \
.rdesc.name = _name, \
.rdesc_pc.name = _pc_name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define NLDO(_name, _pc_name, _ctrl_addr, _test_addr, _hpm_min_load) \
{ \
.type = PM8XXX_REGULATOR_TYPE_NLDO, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \
.rdesc.name = _name, \
.rdesc_pc.name = _pc_name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define NLDO1200(_name, _ctrl_addr, _test_addr, _hpm_min_load) \
{ \
.type = PM8XXX_REGULATOR_TYPE_NLDO1200, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \
.rdesc.name = _name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define SMPS(_name, _pc_name, _ctrl_addr, _test_addr, _clk_ctrl_addr, \
_sleep_ctrl_addr, _hpm_min_load) \
{ \
.type = PM8XXX_REGULATOR_TYPE_SMPS, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.clk_ctrl_addr = _clk_ctrl_addr, \
.sleep_ctrl_addr = _sleep_ctrl_addr, \
.hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \
.rdesc.name = _name, \
.rdesc_pc.name = _pc_name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define FTSMPS(_name, _pwm_ctrl_addr, _fts_cnfg1_addr, _pfm_ctrl_addr, \
_pwr_cnfg_addr, _hpm_min_load) \
{ \
.type = PM8XXX_REGULATOR_TYPE_FTSMPS, \
.ctrl_addr = _pwm_ctrl_addr, \
.test_addr = _fts_cnfg1_addr, \
.pfm_ctrl_addr = _pfm_ctrl_addr, \
.pwr_cnfg_addr = _pwr_cnfg_addr, \
.hpm_min_load = PM8XXX_VREG_##_hpm_min_load##_HPM_MIN_LOAD, \
.rdesc.name = _name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define VS(_name, _pc_name, _ctrl_addr, _test_addr) \
{ \
.type = PM8XXX_REGULATOR_TYPE_VS, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.rdesc.name = _name, \
.rdesc_pc.name = _pc_name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define VS300(_name, _ctrl_addr, _test_addr) \
{ \
.type = PM8XXX_REGULATOR_TYPE_VS300, \
.ctrl_addr = _ctrl_addr, \
.test_addr = _test_addr, \
.rdesc.name = _name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define NCP(_name, _ctrl_addr) \
{ \
.type = PM8XXX_REGULATOR_TYPE_NCP, \
.ctrl_addr = _ctrl_addr, \
.rdesc.name = _name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#define BOOST(_name, _ctrl_addr) \
{ \
.type = PM8XXX_REGULATOR_TYPE_BOOST, \
.ctrl_addr = _ctrl_addr, \
.rdesc.name = _name, \
.write_count = 0, \
.prev_write_count = -1, \
}
#endif
+26
View File
@@ -0,0 +1,26 @@
/* Copyright (c) 2010-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 __RTC_PM8XXX_H__
#define __RTC_PM8XXX_H__
#define PM8XXX_RTC_DEV_NAME "rtc-pm8xxx"
/**
* struct pm8xxx_rtc_pdata - RTC driver platform data
* @rtc_write_enable: variable stating RTC write capability
*/
struct pm8xxx_rtc_platform_data {
bool rtc_write_enable;
bool rtc_alarm_powerup;
};
#endif /* __RTC_PM8XXX_H__ */
+55
View File
@@ -0,0 +1,55 @@
/* Copyright (c) 2012, 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 __SPK_PM8XXX_H__
#define __SPK_PM8XXX_H__
#define PM8XXX_SPK_DEV_NAME "pm8xxx-spk"
/**
* struct pm8xxx_spk_pdata - SPK driver platform data
* @spk_add_enable: variable stating SPK secondary input adding capability
*/
struct pm8xxx_spk_platform_data {
bool spk_add_enable;
int cd_ng_threshold;
int cd_nf_preamp_bias;
int cd_ng_hold;
int cd_ng_max_atten;
int noise_mute;
int cd_ng_decay_rate;
int cd_ng_attack_rate;
int cd_delay;
};
/*
* pm8xxx_spk_mute - mute/unmute speaker pamp
*
* @mute: bool value for mute
*/
int pm8xxx_spk_mute(bool mute);
/*
* pm8xxx_spk_gain - Set Speaker gain
*
* @gain: Speaker gain
*/
int pm8xxx_spk_gain(u8 gain);
/*
* pm8xxx_spk_enable - Enable/Disable Speaker
*
* @enable: bool enable/disable Speaker
*/
int pm8xxx_spk_enable(int enable);
#endif /* __SPK_PM8XXX_H__ */
+76
View File
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2011-2012, 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.
*/
/*
* Qualcomm PMIC PM8xxx Thermal Manager driver
*/
#ifndef __PM8XXX_TM_H
#define __PM8XXX_TM_H
#include <linux/errno.h>
#define PM8XXX_TM_DEV_NAME "pm8xxx-tm"
/**
* enum pm8xxx_tm_adc_type - support ADC API types for PMIC thermal manager
* %PM8XXX_TM_ADC_NONE: Do not call any ADC API and instead estimate
* PMIC temerature based on over temperature stage.
* %PM8XXX_TM_ADC_PM8058_ADC: Use the pmic8058-xoadc ADC API
* %PM8XXX_TM_ADC_PM8XXX_ADC: Use the pm8xxx-adc ADC API
*/
enum pm8xxx_tm_adc_type {
PM8XXX_TM_ADC_NONE,
PM8XXX_TM_ADC_PM8058_ADC,
PM8XXX_TM_ADC_PM8XXX_ADC,
};
/**
* struct pm8xxx_tm_core_data - PM8XXX thermal manager core data
* @tm_name: Thermal zone name for the device
* @irq_name_temp_stat: String name used to identify TEMP_STAT IRQ
* @irq_name_over_temp: String name used to identify OVER_TEMP IRQ
* @reg_addr_temp_alarm_ctrl: PMIC SSBI address for temp alarm control
* register
* @reg_addr_temp_alarm_pwm: PMIC SSBI address for temp alarm pwm register
* @adc_type: Determines which ADC API to use in order to read
* the PMIC die temperature.
* @adc_channel: ADC channel identifier
* If adc_type == PM8XXX_TM_ADC_PM8XXX_ADC, then
* use a value from enum pm8xxx_adc_channels.
* If adc_type == PM8XXX_TM_ADC_PM8058_ADC, then
* use a channel value specified in
* <linux/pmic8058-xoadc.h>
* @default_no_adc_temp: Default temperature in millicelcius to report
* while stage == 0 and stage has never been
* greater than 0 if adc_type == PM8XXX_TM_ADC_NONE
* @allow_software_override: true --> writing "enabled" to thermalfs mode
* file results in software override of PMIC
* automatic over temperature shutdown
* false --> PMIC automatic over temperature
* shutdown always enabled. mode file cannot be
* set to "enabled".
*/
struct pm8xxx_tm_core_data {
char *tm_name;
char *irq_name_temp_stat;
char *irq_name_over_temp;
u16 reg_addr_temp_alarm_ctrl;
u16 reg_addr_temp_alarm_pwm;
enum pm8xxx_tm_adc_type adc_type;
int adc_channel;
unsigned long default_no_adc_temp;
bool allow_software_override;
};
#endif
+65
View File
@@ -0,0 +1,65 @@
/* Copyright (c) 2010,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 __PM8XXX_UPL_H__
#define __PM8XXX_UPL_H__
struct pm8xxx_upl_device;
#define PM8XXX_UPL_DEV_NAME "pm8xxx-upl"
/* control masks and flags */
#define PM8XXX_UPL_MOD_ENABLE_MASK (0x10)
#define PM8XXX_UPL_MOD_ENABLE (0x10)
#define PM8XXX_UPL_MOD_DISABLE (0x00)
#define PM8XXX_UPL_OUT_DTEST_MASK (0xE0)
#define PM8XXX_UPL_OUT_GPIO_ONLY (0x00)
#define PM8XXX_UPL_OUT_DTEST_1 (0x80)
#define PM8XXX_UPL_OUT_DTEST_2 (0xA0)
#define PM8XXX_UPL_OUT_DTEST_3 (0xC0)
#define PM8XXX_UPL_OUT_DTEST_4 (0xE0)
#define PM8XXX_UPL_IN_A_MASK (0x01)
#define PM8XXX_UPL_IN_A_GPIO (0x00)
#define PM8XXX_UPL_IN_A_DTEST (0x01)
#define PM8XXX_UPL_IN_B_MASK (0x02)
#define PM8XXX_UPL_IN_B_GPIO (0x00)
#define PM8XXX_UPL_IN_B_DTEST (0x02)
#define PM8XXX_UPL_IN_C_MASK (0x04)
#define PM8XXX_UPL_IN_C_GPIO (0x00)
#define PM8XXX_UPL_IN_C_DTEST (0x04)
#define PM8XXX_UPL_IN_D_MASK (0x08)
#define PM8XXX_UPL_IN_D_GPIO (0x00)
#define PM8XXX_UPL_IN_D_DTEST (0x08)
/*
* pm8xxx_upl_request - request a handle to access UPL device
*/
struct pm8xxx_upl_device *pm8xxx_upl_request(void);
int pm8xxx_upl_read_truthtable(struct pm8xxx_upl_device *upldev,
u16 *truthtable);
int pm8xxx_upl_write_truthtable(struct pm8xxx_upl_device *upldev,
u16 truthtable);
/*
* pm8xxx_upl_config - configure UPL I/O settings and UPL enable/disable
*
* @upldev: the UPL device
* @mask: setting mask to configure
* @flags: setting flags
*/
int pm8xxx_upl_config(struct pm8xxx_upl_device *upldev, u32 mask, u32 flags);
#endif /* __PM8XXX_UPL_H__ */
@@ -0,0 +1,39 @@
/* Copyright (c) 2010-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 __PMIC8XXX_VIBRATOR_H__
#define __PMIC8XXX_VIBRATOR_H__
#define PM8XXX_VIBRATOR_DEV_NAME "pm8xxx-vib"
enum pm8xxx_vib_en_mode {
PM8XXX_VIB_MANUAL,
PM8XXX_VIB_DTEST1,
PM8XXX_VIB_DTEST2,
PM8XXX_VIB_DTEST3
};
struct pm8xxx_vib_config {
u16 drive_mV;
u8 active_low;
enum pm8xxx_vib_en_mode enable_mode;
};
struct pm8xxx_vibrator_platform_data {
int initial_vibrate_ms;
int max_timeout_ms;
int level_mV;
};
int pm8xxx_vibrator_config(struct pm8xxx_vib_config *vib_config);
#endif /* __PMIC8XXX_VIBRATOR_H__ */