#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/mfd/twl.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#define DRIVER_NAME …
#define TWL6030_GPADC_USED_CHANNELS …
#define TWL6030_GPADC_MAX_CHANNELS …
#define TWL6032_GPADC_USED_CHANNELS …
#define TWL6032_GPADC_MAX_CHANNELS …
#define TWL6030_GPADC_NUM_TRIM_REGS …
#define TWL6030_GPADC_CTRL_P1 …
#define TWL6032_GPADC_GPSELECT_ISB …
#define TWL6032_GPADC_CTRL_P1 …
#define TWL6032_GPADC_GPCH0_LSB …
#define TWL6032_GPADC_GPCH0_MSB …
#define TWL6030_GPADC_CTRL_P1_SP1 …
#define TWL6030_GPADC_GPCH0_LSB …
#define TWL6030_GPADC_RT_SW1_EOC_MASK …
#define TWL6030_GPADC_TRIM1 …
#define TWL6030_REG_TOGGLE1 …
#define TWL6030_GPADCS …
#define TWL6030_GPADCR …
#define USB_VBUS_CTRL_SET …
#define USB_ID_CTRL_SET …
#define TWL6030_MISC1 …
#define VBUS_MEAS …
#define ID_MEAS …
#define VAC_MEAS …
#define VBAT_MEAS …
#define BB_MEAS …
struct twl6030_chnl_calib { … };
struct twl6030_ideal_code { … };
struct twl6030_gpadc_data;
struct twl6030_gpadc_platform_data { … };
struct twl6030_gpadc_data { … };
static const struct twl6030_ideal_code
twl6030_ideal[TWL6030_GPADC_USED_CHANNELS] = …;
static const struct twl6030_ideal_code
twl6032_ideal[TWL6032_GPADC_USED_CHANNELS] = …;
static inline int twl6030_gpadc_write(u8 reg, u8 val)
{ … }
static inline int twl6030_gpadc_read(u8 reg, u8 *val)
{ … }
static int twl6030_gpadc_enable_irq(u8 mask)
{ … }
static void twl6030_gpadc_disable_irq(u8 mask)
{ … }
static irqreturn_t twl6030_gpadc_irq_handler(int irq, void *indio_dev)
{ … }
static int twl6030_start_conversion(int channel)
{ … }
static int twl6032_start_conversion(int channel)
{ … }
static u8 twl6030_channel_to_reg(int channel)
{ … }
static u8 twl6032_channel_to_reg(int channel)
{ … }
static int twl6030_gpadc_lookup(const struct twl6030_ideal_code *ideal,
int channel, int size)
{ … }
static int twl6030_channel_calibrated(const struct twl6030_gpadc_platform_data
*pdata, int channel)
{ … }
static int twl6030_gpadc_make_correction(struct twl6030_gpadc_data *gpadc,
int channel, int raw_code)
{ … }
static int twl6030_gpadc_get_raw(struct twl6030_gpadc_data *gpadc,
int channel, int *res)
{ … }
static int twl6030_gpadc_get_processed(struct twl6030_gpadc_data *gpadc,
int channel, int *val)
{ … }
static int twl6030_gpadc_read_raw(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
int *val, int *val2, long mask)
{ … }
static void twl6030_calibrate_channel(struct twl6030_gpadc_data *gpadc,
int channel, int d1, int d2)
{ … }
static inline int twl6030_gpadc_get_trim_offset(s8 d)
{ … }
static int twl6030_calibration(struct twl6030_gpadc_data *gpadc)
{ … }
static int twl6032_get_trim_value(u8 *trim_regs, unsigned int reg0,
unsigned int reg1, unsigned int mask0, unsigned int mask1,
unsigned int shift0)
{ … }
static int twl6032_calibration(struct twl6030_gpadc_data *gpadc)
{ … }
#define TWL6030_GPADC_CHAN(chn, _type, chan_info) …
static const struct iio_chan_spec twl6030_gpadc_iio_channels[] = …;
static const struct iio_chan_spec twl6032_gpadc_iio_channels[] = …;
static const struct iio_info twl6030_gpadc_iio_info = …;
static const struct twl6030_gpadc_platform_data twl6030_pdata = …;
static const struct twl6030_gpadc_platform_data twl6032_pdata = …;
static const struct of_device_id of_twl6030_match_tbl[] = …;
MODULE_DEVICE_TABLE(of, of_twl6030_match_tbl);
static int twl6030_gpadc_probe(struct platform_device *pdev)
{ … }
static void twl6030_gpadc_remove(struct platform_device *pdev)
{ … }
static int twl6030_gpadc_suspend(struct device *pdev)
{
int ret;
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCR,
TWL6030_REG_TOGGLE1);
if (ret)
dev_err(pdev, "error resetting GPADC (%d)!\n", ret);
return 0;
};
static int twl6030_gpadc_resume(struct device *pdev)
{
int ret;
ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS,
TWL6030_REG_TOGGLE1);
if (ret)
dev_err(pdev, "error setting GPADC (%d)!\n", ret);
return 0;
};
static DEFINE_SIMPLE_DEV_PM_OPS(twl6030_gpadc_pm_ops, twl6030_gpadc_suspend,
twl6030_gpadc_resume);
static struct platform_driver twl6030_gpadc_driver = …;
module_platform_driver(…) …;
MODULE_ALIAS(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;