linux/drivers/input/touchscreen/goodix.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Driver for Goodix Touchscreens
 *
 *  Copyright (c) 2014 Red Hat Inc.
 *  Copyright (c) 2015 K. Merker <[email protected]>
 *
 *  This code is based on gt9xx.c authored by [email protected]:
 *
 *  2010 - 2012 Goodix Technology.
 */


#include <linux/kernel.h>
#include <linux/dmi.h>
#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/platform_data/x86/soc.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/unaligned.h>
#include "goodix.h"

#define GOODIX_GPIO_INT_NAME
#define GOODIX_GPIO_RST_NAME

#define GOODIX_MAX_HEIGHT
#define GOODIX_MAX_WIDTH
#define GOODIX_INT_TRIGGER
#define GOODIX_CONTACT_SIZE
#define GOODIX_MAX_CONTACT_SIZE
#define GOODIX_MAX_CONTACTS

#define GOODIX_CONFIG_MIN_LENGTH
#define GOODIX_CONFIG_911_LENGTH
#define GOODIX_CONFIG_967_LENGTH
#define GOODIX_CONFIG_GT9X_LENGTH

#define GOODIX_BUFFER_STATUS_READY
#define GOODIX_HAVE_KEY
#define GOODIX_BUFFER_STATUS_TIMEOUT

#define RESOLUTION_LOC
#define MAX_CONTACTS_LOC
#define TRIGGER_LOC

/* Our special handling for GPIO accesses through ACPI is x86 specific */
#if defined CONFIG_X86 && defined CONFIG_ACPI
#define ACPI_GPIO_SUPPORT
#endif

struct goodix_chip_id {};

static int goodix_check_cfg_8(struct goodix_ts_data *ts,
			      const u8 *cfg, int len);
static int goodix_check_cfg_16(struct goodix_ts_data *ts,
			       const u8 *cfg, int len);
static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts);
static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts);

static const struct goodix_chip_data gt1x_chip_data =;

static const struct goodix_chip_data gt911_chip_data =;

static const struct goodix_chip_data gt967_chip_data =;

static const struct goodix_chip_data gt9x_chip_data =;

static const struct goodix_chip_id goodix_chip_ids[] =;

static const unsigned long goodix_irq_flags[] =;

static const struct dmi_system_id nine_bytes_report[] =;

/*
 * Those tablets have their x coordinate inverted
 */
static const struct dmi_system_id inverted_x_screen[] =;

/**
 * goodix_i2c_read - read data from a register of the i2c slave device.
 *
 * @client: i2c device.
 * @reg: the register to read from.
 * @buf: raw write data buffer.
 * @len: length of the buffer to write
 */
int goodix_i2c_read(struct i2c_client *client, u16 reg, u8 *buf, int len)
{}

/**
 * goodix_i2c_write - write data to a register of the i2c slave device.
 *
 * @client: i2c device.
 * @reg: the register to write to.
 * @buf: raw data buffer to write.
 * @len: length of the buffer to write
 */
int goodix_i2c_write(struct i2c_client *client, u16 reg, const u8 *buf, int len)
{}

int goodix_i2c_write_u8(struct i2c_client *client, u16 reg, u8 value)
{}

static const struct goodix_chip_data *goodix_get_chip_data(const char *id)
{}

static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
{}

static int goodix_create_pen_input(struct goodix_ts_data *ts)
{}

static void goodix_ts_report_pen_down(struct goodix_ts_data *ts, u8 *data)
{}

static void goodix_ts_report_pen_up(struct goodix_ts_data *ts)
{}

static void goodix_ts_report_touch_8b(struct goodix_ts_data *ts, u8 *coor_data)
{}

static void goodix_ts_report_touch_9b(struct goodix_ts_data *ts, u8 *coor_data)
{}

static void goodix_ts_release_keys(struct goodix_ts_data *ts)
{}

static void goodix_ts_report_key(struct goodix_ts_data *ts, u8 *data)
{}

/**
 * goodix_process_events - Process incoming events
 *
 * @ts: our goodix_ts_data pointer
 *
 * Called when the IRQ is triggered. Read the current device state, and push
 * the input events to the user space.
 */
static void goodix_process_events(struct goodix_ts_data *ts)
{}

/**
 * goodix_ts_irq_handler - The IRQ handler
 *
 * @irq: interrupt number.
 * @dev_id: private data pointer.
 */
static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
{}

static void goodix_free_irq(struct goodix_ts_data *ts)
{}

static int goodix_request_irq(struct goodix_ts_data *ts)
{}

static int goodix_check_cfg_8(struct goodix_ts_data *ts, const u8 *cfg, int len)
{}

static void goodix_calc_cfg_checksum_8(struct goodix_ts_data *ts)
{}

static int goodix_check_cfg_16(struct goodix_ts_data *ts, const u8 *cfg,
			       int len)
{}

static void goodix_calc_cfg_checksum_16(struct goodix_ts_data *ts)
{}

/**
 * goodix_check_cfg - Checks if config fw is valid
 *
 * @ts: goodix_ts_data pointer
 * @cfg: firmware config data
 * @len: config data length
 */
static int goodix_check_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len)
{}

/**
 * goodix_send_cfg - Write fw config to device
 *
 * @ts: goodix_ts_data pointer
 * @cfg: config firmware to write to device
 * @len: config data length
 */
int goodix_send_cfg(struct goodix_ts_data *ts, const u8 *cfg, int len)
{}

#ifdef ACPI_GPIO_SUPPORT
static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts)
{}

static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value)
{}
#else
static int goodix_pin_acpi_direction_input(struct goodix_ts_data *ts)
{
	dev_err(&ts->client->dev,
		"%s called on device without ACPI support\n", __func__);
	return -EINVAL;
}

static int goodix_pin_acpi_output_method(struct goodix_ts_data *ts, int value)
{
	dev_err(&ts->client->dev,
		"%s called on device without ACPI support\n", __func__);
	return -EINVAL;
}
#endif

static int goodix_irq_direction_output(struct goodix_ts_data *ts, int value)
{}

static int goodix_irq_direction_input(struct goodix_ts_data *ts)
{}

int goodix_int_sync(struct goodix_ts_data *ts)
{}

/**
 * goodix_reset_no_int_sync - Reset device, leaving interrupt line in output mode
 *
 * @ts: goodix_ts_data pointer
 */
int goodix_reset_no_int_sync(struct goodix_ts_data *ts)
{}

/**
 * goodix_reset - Reset device during power on
 *
 * @ts: goodix_ts_data pointer
 */
static int goodix_reset(struct goodix_ts_data *ts)
{}

#ifdef ACPI_GPIO_SUPPORT
static const struct acpi_gpio_params first_gpio =;
static const struct acpi_gpio_params second_gpio =;

static const struct acpi_gpio_mapping acpi_goodix_int_first_gpios[] =;

static const struct acpi_gpio_mapping acpi_goodix_int_last_gpios[] =;

static const struct acpi_gpio_mapping acpi_goodix_reset_only_gpios[] =;

static int goodix_resource(struct acpi_resource *ares, void *data)
{}

/*
 * This function gets called in case we fail to get the irq GPIO directly
 * because the ACPI tables lack GPIO-name to APCI _CRS index mappings
 * (no _DSD UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 data).
 * In that case we add our own mapping and then goodix_get_gpio_config()
 * retries to get the GPIOs based on the added mapping.
 */
static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
{}
#else
static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
{
	return -EINVAL;
}
#endif /* CONFIG_X86 && CONFIG_ACPI */

/**
 * goodix_get_gpio_config - Get GPIO config from ACPI/DT
 *
 * @ts: goodix_ts_data pointer
 */
static int goodix_get_gpio_config(struct goodix_ts_data *ts)
{}

/**
 * goodix_read_config - Read the embedded configuration of the panel
 *
 * @ts: our goodix_ts_data pointer
 *
 * Must be called during probe
 */
static void goodix_read_config(struct goodix_ts_data *ts)
{}

/**
 * goodix_read_version - Read goodix touchscreen version
 *
 * @ts: our goodix_ts_data pointer
 */
static int goodix_read_version(struct goodix_ts_data *ts)
{}

/**
 * goodix_i2c_test - I2C test function to check if the device answers.
 *
 * @client: the i2c client
 */
static int goodix_i2c_test(struct i2c_client *client)
{}

/**
 * goodix_configure_dev - Finish device initialization
 *
 * @ts: our goodix_ts_data pointer
 *
 * Must be called from probe to finish initialization of the device.
 * Contains the common initialization code for both devices that
 * declare gpio pins and devices that do not. It is either called
 * directly from probe or from request_firmware_wait callback.
 */
static int goodix_configure_dev(struct goodix_ts_data *ts)
{}

/**
 * goodix_config_cb - Callback to finish device init
 *
 * @cfg: firmware config
 * @ctx: our goodix_ts_data pointer
 *
 * request_firmware_wait callback that finishes
 * initialization of the device.
 */
static void goodix_config_cb(const struct firmware *cfg, void *ctx)
{}

static void goodix_disable_regulators(void *arg)
{}

static int goodix_ts_probe(struct i2c_client *client)
{}

static void goodix_ts_remove(struct i2c_client *client)
{}

static int goodix_suspend(struct device *dev)
{}

static int goodix_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(goodix_pm_ops, goodix_suspend, goodix_resume);

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

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

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

static struct i2c_driver goodix_ts_driver =;
module_i2c_driver();

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