#include <linux/types.h>
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/property.h>
#include <linux/gpio/consumer.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
#include <linux/unaligned.h>
#define TS_POLL_DELAY …
#define TS_POLL_PERIOD …
#define SAMPLE_BITS …
struct ads7846_buf { … } __packed;
struct ads7846_buf_layout { … };
struct ads7846_packet { … };
struct ads7846 { … };
enum ads7846_filter { … };
#if 0
#define CS_CHANGE …
#else
#define CS_CHANGE(xfer) …
#endif
#define ADS_START …
#define ADS_A2A1A0_d_y …
#define ADS_A2A1A0_d_z1 …
#define ADS_A2A1A0_d_z2 …
#define ADS_A2A1A0_d_x …
#define ADS_A2A1A0_temp0 …
#define ADS_A2A1A0_vbatt …
#define ADS_A2A1A0_vaux …
#define ADS_A2A1A0_temp1 …
#define ADS_8_BIT …
#define ADS_12_BIT …
#define ADS_SER …
#define ADS_DFR …
#define ADS_PD10_PDOWN …
#define ADS_PD10_ADC_ON …
#define ADS_PD10_REF_ON …
#define ADS_PD10_ALL_ON …
#define MAX_12BIT …
#define READ_12BIT_DFR(x, adc, vref) …
#define READ_Y(vref) …
#define READ_Z1(vref) …
#define READ_Z2(vref) …
#define READ_X(vref) …
#define PWRDOWN …
#define READ_12BIT_SER(x) …
#define REF_ON …
#define REF_OFF …
enum ads7846_cmds { … };
static int get_pendown_state(struct ads7846 *ts)
{ … }
static void ads7846_report_pen_up(struct ads7846 *ts)
{ … }
static void ads7846_stop(struct ads7846 *ts)
{ … }
static void ads7846_restart(struct ads7846 *ts)
{ … }
static void __ads7846_disable(struct ads7846 *ts)
{ … }
static void __ads7846_enable(struct ads7846 *ts)
{ … }
static void ads7846_disable(struct ads7846 *ts)
{ … }
static void ads7846_enable(struct ads7846 *ts)
{ … }
struct ser_req { … };
struct ads7845_ser_req { … };
static int ads7846_read12_ser(struct device *dev, unsigned command)
{ … }
static int ads7845_read12_ser(struct device *dev, unsigned command)
{ … }
#if IS_ENABLED(CONFIG_HWMON)
#define SHOW(name, var, adjust) …
static inline unsigned null_adjust(struct ads7846 *ts, ssize_t v)
{ … }
SHOW(…)
SHOW(…)
static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
{ … }
static inline unsigned vbatt_adjust(struct ads7846 *ts, ssize_t v)
{ … }
SHOW(…)
SHOW(…)
static umode_t ads7846_is_visible(struct kobject *kobj, struct attribute *attr,
int index)
{ … }
static struct attribute *ads7846_attributes[] = …;
static const struct attribute_group ads7846_attr_group = …;
__ATTRIBUTE_GROUPS(…);
static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
{ … }
#else
static inline int ads784x_hwmon_register(struct spi_device *spi,
struct ads7846 *ts)
{
return 0;
}
#endif
static ssize_t ads7846_pen_down_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR(pen_down, S_IRUGO, ads7846_pen_down_show, NULL);
static ssize_t ads7846_disable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t ads7846_disable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
static struct attribute *ads784x_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int ads7846_debounce_filter(void *ads, int data_idx, int *val)
{ … }
static int ads7846_no_filter(void *ads, int data_idx, int *val)
{ … }
static int ads7846_get_value(struct ads7846_buf *buf)
{ … }
static void ads7846_set_cmd_val(struct ads7846 *ts, enum ads7846_cmds cmd_idx,
u16 val)
{ … }
static u8 ads7846_get_cmd(enum ads7846_cmds cmd_idx, int vref)
{ … }
static bool ads7846_cmd_need_settle(enum ads7846_cmds cmd_idx)
{ … }
static int ads7846_filter(struct ads7846 *ts)
{ … }
static void ads7846_wait_for_hsync(struct ads7846 *ts)
{ … }
static void ads7846_read_state(struct ads7846 *ts)
{ … }
static void ads7846_report_state(struct ads7846 *ts)
{ … }
static irqreturn_t ads7846_hard_irq(int irq, void *handle)
{ … }
static irqreturn_t ads7846_irq(int irq, void *handle)
{ … }
static int ads7846_suspend(struct device *dev)
{ … }
static int ads7846_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
static int ads7846_setup_pendown(struct spi_device *spi,
struct ads7846 *ts,
const struct ads7846_platform_data *pdata)
{ … }
static int ads7846_setup_spi_msg(struct ads7846 *ts,
const struct ads7846_platform_data *pdata)
{ … }
static const struct of_device_id ads7846_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, ads7846_dt_ids);
static const struct spi_device_id ads7846_spi_ids[] = …;
MODULE_DEVICE_TABLE(spi, ads7846_spi_ids);
static const struct ads7846_platform_data *ads7846_get_props(struct device *dev)
{ … }
static void ads7846_regulator_disable(void *regulator)
{ … }
static int ads7846_probe(struct spi_device *spi)
{ … }
static void ads7846_remove(struct spi_device *spi)
{ … }
static struct spi_driver ads7846_driver = …;
module_spi_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;