linux/drivers/input/mouse/cyapa.c

/*
 * Cypress APA trackpad with I2C interface
 *
 * Author: Dudley Du <[email protected]>
 * Further cleanup and restructuring by:
 *   Daniel Kurtz <[email protected]>
 *   Benson Leung <[email protected]>
 *
 * Copyright (C) 2011-2015 Cypress Semiconductor, Inc.
 * Copyright (C) 2011-2012 Google, Inc.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive for
 * more details.
 */

#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/pm_runtime.h>
#include <linux/acpi.h>
#include <linux/of.h>
#include "cyapa.h"


#define CYAPA_ADAPTER_FUNC_NONE
#define CYAPA_ADAPTER_FUNC_I2C
#define CYAPA_ADAPTER_FUNC_SMBUS
#define CYAPA_ADAPTER_FUNC_BOTH

#define CYAPA_FW_NAME

const char product_id[] =;

static int cyapa_reinitialize(struct cyapa *cyapa);

bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
{}

bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
{}

static bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
{}

static inline bool cyapa_is_operational_mode(struct cyapa *cyapa)
{}

/* Returns 0 on success, else negative errno on failure. */
static ssize_t cyapa_i2c_read(struct cyapa *cyapa, u8 reg, size_t len,
					u8 *values)
{}

/**
 * cyapa_i2c_write - Execute i2c block data write operation
 * @cyapa: Handle to this driver
 * @reg: Offset of the data to written in the register map
 * @len: number of bytes to write
 * @values: Data to be written
 *
 * Return negative errno code on error; return zero when success.
 */
static int cyapa_i2c_write(struct cyapa *cyapa, u8 reg,
					 size_t len, const void *values)
{}

static u8 cyapa_check_adapter_functionality(struct i2c_client *client)
{}

/*
 * Query device for its current operating state.
 */
static int cyapa_get_state(struct cyapa *cyapa)
{}

/*
 * Poll device for its status in a loop, waiting up to timeout for a response.
 *
 * When the device switches state, it usually takes ~300 ms.
 * However, when running a new firmware image, the device must calibrate its
 * sensors, which can take as long as 2 seconds.
 *
 * Note: The timeout has granularity of the polling rate, which is 100 ms.
 *
 * Returns:
 *   0 when the device eventually responds with a valid non-busy state.
 *   -ETIMEDOUT if device never responds (too many -EAGAIN)
 *   -EAGAIN    if bootload is busy, or unknown state.
 *   < 0        other errors
 */
int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout)
{}

/*
 * Check if device is operational.
 *
 * An operational device is responding, has exited bootloader, and has
 * firmware supported by this driver.
 *
 * Returns:
 *   -ENODEV no device
 *   -EBUSY  no device or in bootloader
 *   -EIO    failure while reading from device
 *   -ETIMEDOUT timeout failure for bus idle or bus no response
 *   -EAGAIN device is still in bootloader
 *           if ->state = CYAPA_STATE_BL_IDLE, device has invalid firmware
 *   -EINVAL device is in operational mode, but not supported by this driver
 *   0       device is supported
 */
static int cyapa_check_is_operational(struct cyapa *cyapa)
{}


/*
 * Returns 0 on device detected, negative errno on no device detected.
 * And when the device is detected and operational, it will be reset to
 * full power active mode automatically.
 */
static int cyapa_detect(struct cyapa *cyapa)
{}

static int cyapa_open(struct input_dev *input)
{}

static void cyapa_close(struct input_dev *input)
{}

static int cyapa_create_input_dev(struct cyapa *cyapa)
{}

static void cyapa_enable_irq_for_cmd(struct cyapa *cyapa)
{}

static void cyapa_disable_irq_for_cmd(struct cyapa *cyapa)
{}

/*
 * cyapa_sleep_time_to_pwr_cmd and cyapa_pwr_cmd_to_sleep_time
 *
 * These are helper functions that convert to and from integer idle
 * times and register settings to write to the PowerMode register.
 * The trackpad supports between 20ms to 1000ms scan intervals.
 * The time will be increased in increments of 10ms from 20ms to 100ms.
 * From 100ms to 1000ms, time will be increased in increments of 20ms.
 *
 * When Idle_Time < 100, the format to convert Idle_Time to Idle_Command is:
 *   Idle_Command = Idle Time / 10;
 * When Idle_Time >= 100, the format to convert Idle_Time to Idle_Command is:
 *   Idle_Command = Idle Time / 20 + 5;
 */
u8 cyapa_sleep_time_to_pwr_cmd(u16 sleep_time)
{}

u16 cyapa_pwr_cmd_to_sleep_time(u8 pwr_mode)
{}

/* 0 on driver initialize and detected successfully, negative on failure. */
static int cyapa_initialize(struct cyapa *cyapa)
{}

static int cyapa_reinitialize(struct cyapa *cyapa)
{}

static irqreturn_t cyapa_irq(int irq, void *dev_id)
{}

/*
 **************************************************************
 * sysfs interface
 **************************************************************
*/
#ifdef CONFIG_PM_SLEEP
static ssize_t cyapa_show_suspend_scanrate(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
{}

static ssize_t cyapa_update_suspend_scanrate(struct device *dev,
					     struct device_attribute *attr,
					     const char *buf, size_t count)
{}

static DEVICE_ATTR(suspend_scanrate_ms, S_IRUGO|S_IWUSR,
		   cyapa_show_suspend_scanrate,
		   cyapa_update_suspend_scanrate);

static struct attribute *cyapa_power_wakeup_entries[] =;

static const struct attribute_group cyapa_power_wakeup_group =;

static void cyapa_remove_power_wakeup_group(void *data)
{}

static int cyapa_prepare_wakeup_controls(struct cyapa *cyapa)
{}
#else
static inline int cyapa_prepare_wakeup_controls(struct cyapa *cyapa)
{
	return 0;
}
#endif /* CONFIG_PM_SLEEP */

#ifdef CONFIG_PM
static ssize_t cyapa_show_rt_suspend_scanrate(struct device *dev,
					      struct device_attribute *attr,
					      char *buf)
{}

static ssize_t cyapa_update_rt_suspend_scanrate(struct device *dev,
						struct device_attribute *attr,
						const char *buf, size_t count)
{}

static DEVICE_ATTR(runtime_suspend_scanrate_ms, S_IRUGO|S_IWUSR,
		   cyapa_show_rt_suspend_scanrate,
		   cyapa_update_rt_suspend_scanrate);

static struct attribute *cyapa_power_runtime_entries[] =;

static const struct attribute_group cyapa_power_runtime_group =;

static void cyapa_remove_power_runtime_group(void *data)
{}

static int cyapa_start_runtime(struct cyapa *cyapa)
{}
#else
static inline int cyapa_start_runtime(struct cyapa *cyapa)
{
	return 0;
}
#endif /* CONFIG_PM */

static ssize_t cyapa_show_fm_ver(struct device *dev,
				 struct device_attribute *attr, char *buf)
{}

static ssize_t cyapa_show_product_id(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}

static int cyapa_firmware(struct cyapa *cyapa, const char *fw_name)
{}

static ssize_t cyapa_update_fw_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{}

static ssize_t cyapa_calibrate_store(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{}

static ssize_t cyapa_show_baseline(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static char *cyapa_state_to_string(struct cyapa *cyapa)
{}

static ssize_t cyapa_show_mode(struct device *dev,
				   struct device_attribute *attr, char *buf)
{}

static DEVICE_ATTR(firmware_version, S_IRUGO, cyapa_show_fm_ver, NULL);
static DEVICE_ATTR(product_id, S_IRUGO, cyapa_show_product_id, NULL);
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, cyapa_update_fw_store);
static DEVICE_ATTR(baseline, S_IRUGO, cyapa_show_baseline, NULL);
static DEVICE_ATTR(calibrate, S_IWUSR, NULL, cyapa_calibrate_store);
static DEVICE_ATTR(mode, S_IRUGO, cyapa_show_mode, NULL);

static struct attribute *cyapa_attrs[] =;
ATTRIBUTE_GROUPS();

static void cyapa_disable_regulator(void *data)
{}

static int cyapa_probe(struct i2c_client *client)
{}

static int cyapa_suspend(struct device *dev)
{}

static int cyapa_resume(struct device *dev)
{}

static int cyapa_runtime_suspend(struct device *dev)
{}

static int cyapa_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops cyapa_pm_ops =;

static const struct i2c_device_id cyapa_id_table[] =;
MODULE_DEVICE_TABLE(i2c, cyapa_id_table);

#ifdef CONFIG_ACPI
static const struct acpi_device_id cyapa_acpi_id[] =;
MODULE_DEVICE_TABLE(acpi, cyapa_acpi_id);
#endif

#ifdef CONFIG_OF
static const struct of_device_id cyapa_of_match[] =;
MODULE_DEVICE_TABLE(of, cyapa_of_match);
#endif

static struct i2c_driver cyapa_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();