Commit 865fdb08 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'input-for-v6.4-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

 - a new driver for Novatek touch controllers

 - a new driver for power button for NXP BBNSM

 - a skeleton KUnit tests for the input core

 - improvements to Xpad game controller driver to support more devices

 - improvements to edt-ft5x06, hideep and other drivers

* tag 'input-for-v6.4-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (42 commits)
  Revert "Input: xpad - fix support for some third-party controllers"
  dt-bindings: input: pwm-beeper: convert to dt schema
  Input: xpad - fix PowerA EnWired Controller guide button
  Input: xpad - add constants for GIP interface numbers
  Input: synaptics-rmi4 - fix function name in kerneldoc
  Input: raspberrypi-ts - fix refcount leak in rpi_ts_probe
  Input: edt-ft5x06 - select REGMAP_I2C
  Input: melfas_mip4 - report palm touches
  Input: cma3000_d0x - remove unneeded code
  Input: edt-ft5x06 - calculate points data length only once
  Input: edt-ft5x06 - unify the crc check
  Input: edt-ft5x06 - convert to use regmap API
  Input: edt-ft5x06 - don't print error messages with dev_dbg()
  Input: edt-ft5x06 - remove code duplication
  Input: edt-ft5x06 - don't recalculate the CRC
  Input: edt-ft5x06 - add spaces to ensure format specification
  Input: edt-ft5x06 - remove unnecessary blank lines
  Input: edt-ft5x06 - fix indentation
  Input: tsc2007 - enable cansleep pendown GPIO
  Input: Add KUnit tests for some of the input core helper functions
  ...
parents c8c655c3 9a87ffc9
......@@ -45,7 +45,7 @@ properties:
when the keyboard has a custom design for the top row keys.
dependencies:
function-row-phsymap: [ 'linux,keymap' ]
function-row-physmap: [ 'linux,keymap' ]
google,needs-ghost-filter: [ 'linux,keymap' ]
required:
......
* PWM beeper device tree bindings
Registers a PWM device as beeper.
Required properties:
- compatible: should be "pwm-beeper"
- pwms: phandle to the physical PWM device
Optional properties:
- amp-supply: phandle to a regulator that acts as an amplifier for the beeper
- beeper-hz: bell frequency in Hz
Example:
beeper_amp: amplifier {
compatible = "fixed-regulator";
gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
};
beeper {
compatible = "pwm-beeper";
pwms = <&pwm0>;
amp-supply = <&beeper_amp>;
};
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/input/pwm-beeper.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: PWM beeper
maintainers:
- Sascha Hauer <s.hauer@pengutronix.de>
properties:
compatible:
const: pwm-beeper
pwms:
maxItems: 1
amp-supply:
description: an amplifier for the beeper
beeper-hz:
description: bell frequency in Hz
minimum: 10
maximum: 10000
required:
- compatible
- pwms
unevaluatedProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
beeper {
compatible = "pwm-beeper";
pwms = <&pwm0>;
amp-supply = <&beeper_amp>;
beeper-hz = <1000>;
};
......@@ -14877,6 +14877,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git
F: tools/include/nolibc/
F: tools/testing/selftests/nolibc/
NOVATEK NVT-TS I2C TOUCHSCREEN DRIVER
M: Hans de Goede <hdegoede@redhat.com>
L: linux-input@vger.kernel.org
S: Maintained
F: drivers/input/touchscreen/novatek-nvt-ts.c
NSDEPS
M: Matthias Maennich <maennich@google.com>
S: Maintained
......
......@@ -25,6 +25,7 @@
#include <linux/spi/pxa2xx_spi.h>
#include <linux/mtd/sharpsl.h>
#include <linux/mtd/physmap.h>
#include <linux/input-event-codes.h>
#include <linux/input/matrix_keypad.h>
#include <linux/regulator/machine.h>
#include <linux/io.h>
......
......@@ -166,6 +166,16 @@ config INPUT_EVBUG
To compile this driver as a module, choose M here: the
module will be called evbug.
config INPUT_KUNIT_TEST
tristate "KUnit tests for Input" if !KUNIT_ALL_TESTS
depends on INPUT && KUNIT=y
default KUNIT_ALL_TESTS
help
Say Y here if you want to build the KUnit tests for the input
subsystem.
If in doubt, say "N".
config INPUT_APMPOWER
tristate "Input Power Event -> APM Bridge" if EXPERT
depends on INPUT && APM_EMULATION
......
......@@ -26,6 +26,7 @@ obj-$(CONFIG_INPUT_JOYSTICK) += joystick/
obj-$(CONFIG_INPUT_TABLET) += tablet/
obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/
obj-$(CONFIG_INPUT_MISC) += misc/
obj-$(CONFIG_INPUT_KUNIT_TEST) += tests/
obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
......
......@@ -126,7 +126,6 @@ static const struct xpad_device {
char *name;
u8 mapping;
u8 xtype;
u8 packet_type;
} xpad_device[] = {
{ 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
{ 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 },
......@@ -475,6 +474,7 @@ static const struct usb_device_id xpad_table[] = {
XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */
XPAD_XBOXONE_VENDOR(0x0f0d), /* Hori Controllers */
XPAD_XBOX360_VENDOR(0x1038), /* SteelSeries Controllers */
XPAD_XBOXONE_VENDOR(0x10f5), /* Turtle Beach Controllers */
XPAD_XBOX360_VENDOR(0x11c9), /* Nacon GC100XF */
XPAD_XBOX360_VENDOR(0x1209), /* Ardwiino Controllers */
XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
......@@ -493,6 +493,7 @@ static const struct usb_device_id xpad_table[] = {
XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */
XPAD_XBOX360_VENDOR(0x2563), /* OneXPlayer Gamepad */
XPAD_XBOX360_VENDOR(0x260d), /* Dareu H101 */
XPAD_XBOX360_VENDOR(0x2c22), /* Qanba Controllers */
XPAD_XBOX360_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller */
XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */
XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke X-Box One pad */
......@@ -559,6 +560,9 @@ struct xboxone_init_packet {
#define GIP_MOTOR_LT BIT(3)
#define GIP_MOTOR_ALL (GIP_MOTOR_R | GIP_MOTOR_L | GIP_MOTOR_RT | GIP_MOTOR_LT)
#define GIP_WIRED_INTF_DATA 0
#define GIP_WIRED_INTF_AUDIO 1
/*
* This packet is required for all Xbox One pads with 2015
* or later firmware installed (or present from the factory).
......@@ -1392,6 +1396,21 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad)
unsigned long flags;
int retval;
if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) {
/*
* Explicitly disable the audio interface. This is needed
* for some controllers, such as the PowerA Enhanced Wired
* Controller for Series X|S (0x20d6:0x200e) to report the
* guide button.
*/
retval = usb_set_interface(xpad->udev,
GIP_WIRED_INTF_AUDIO, 0);
if (retval)
dev_warn(&xpad->dev->dev,
"unable to disable audio interface: %d\n",
retval);
}
spin_lock_irqsave(&xpad->odata_lock, flags);
/*
......@@ -2003,7 +2022,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
}
if (xpad->xtype == XTYPE_XBOXONE &&
intf->cur_altsetting->desc.bInterfaceNumber != 0) {
intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) {
/*
* The Xbox One controller lists three interfaces all with the
* same interface class, subclass and protocol. Differentiate by
......
......@@ -770,6 +770,9 @@ gpio_keys_get_devtree_pdata(struct device *dev)
&button->type))
button->type = EV_KEY;
fwnode_property_read_u32(child, "linux,input-value",
(u32 *)&button->value);
button->wakeup =
fwnode_property_read_bool(child, "wakeup-source") ||
/* legacy name */
......
......@@ -320,7 +320,7 @@ static int iqs62x_keys_remove(struct platform_device *pdev)
if (ret)
dev_err(&pdev->dev, "Failed to unregister notifier: %d\n", ret);
return ret;
return 0;
}
static struct platform_driver iqs62x_keys_platform_driver = {
......
......@@ -425,14 +425,12 @@ matrix_keypad_parse_dt(struct device *dev)
return ERR_PTR(-EINVAL);
}
if (of_get_property(np, "linux,no-autorepeat", NULL))
pdata->no_autorepeat = true;
pdata->no_autorepeat = of_property_read_bool(np, "linux,no-autorepeat");
pdata->wakeup = of_property_read_bool(np, "wakeup-source") ||
of_property_read_bool(np, "linux,wakeup"); /* legacy */
if (of_get_property(np, "gpio-activelow", NULL))
pdata->active_low = true;
pdata->active_low = of_property_read_bool(np, "gpio-activelow");
pdata->drive_inactive_cols =
of_property_read_bool(np, "drive-inactive-cols");
......
......@@ -274,8 +274,7 @@ static int omap4_keypad_parse_dt(struct device *dev,
if (err)
return err;
if (of_get_property(np, "linux,input-no-autorepeat", NULL))
keypad_data->no_autorepeat = true;
keypad_data->no_autorepeat = of_property_read_bool(np, "linux,input-no-autorepeat");
return 0;
}
......
......@@ -291,8 +291,7 @@ samsung_keypad_parse_dt(struct device *dev)
*keymap++ = KEY(row, col, key_code);
}
if (of_get_property(np, "linux,input-no-autorepeat", NULL))
pdata->no_autorepeat = true;
pdata->no_autorepeat = of_property_read_bool(np, "linux,input-no-autorepeat");
pdata->wakeup = of_property_read_bool(np, "wakeup-source") ||
/* legacy name */
......
......@@ -259,7 +259,7 @@ static struct platform_driver keyscan_device_driver = {
.driver = {
.name = "st-keyscan",
.pm = pm_sleep_ptr(&keyscan_dev_pm_ops),
.of_match_table = of_match_ptr(keyscan_of_match),
.of_match_table = keyscan_of_match,
}
};
......
......@@ -504,8 +504,7 @@ static int tegra_kbc_parse_dt(struct tegra_kbc *kbc)
if (!of_property_read_u32(np, "nvidia,repeat-delay-ms", &prop))
kbc->repeat_cnt = prop;
if (of_find_property(np, "nvidia,needs-ghost-filter", NULL))
kbc->use_ghost_filter = true;
kbc->use_ghost_filter = of_property_present(np, "nvidia,needs-ghost-filter");
if (of_property_read_bool(np, "wakeup-source") ||
of_property_read_bool(np, "nvidia,wakeup-source")) /* legacy */
......
......@@ -354,7 +354,7 @@ static struct i2c_driver tm2_touchkey_driver = {
.driver = {
.name = TM2_TOUCHKEY_DEV_NAME,
.pm = pm_sleep_ptr(&tm2_touchkey_pm_ops),
.of_match_table = of_match_ptr(tm2_touchkey_of_match),
.of_match_table = tm2_touchkey_of_match,
},
.probe_new = tm2_touchkey_probe,
.id_table = tm2_touchkey_id_table,
......
......@@ -119,6 +119,17 @@ config INPUT_ATMEL_CAPTOUCH
To compile this driver as a module, choose M here: the
module will be called atmel_captouch.
config INPUT_BBNSM_PWRKEY
tristate "NXP BBNSM Power Key Driver"
depends on ARCH_MXC || COMPILE_TEST
depends on OF
help
This is the bbnsm powerkey driver for the NXP i.MX application
processors.
To compile this driver as a module, choose M here; the
module will be called bbnsm_pwrkey.
config INPUT_BMA150
tristate "BMA150/SMB380 acceleration sensor support"
depends on I2C
......
......@@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_ATC260X_ONKEY) += atc260x-onkey.o
obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
obj-$(CONFIG_INPUT_ATMEL_CAPTOUCH) += atmel_captouch.o
obj-$(CONFIG_INPUT_BBNSM_PWRKEY) += nxp-bbnsm-pwrkey.o
obj-$(CONFIG_INPUT_BMA150) += bma150.o
obj-$(CONFIG_INPUT_CM109) += cm109.o
obj-$(CONFIG_INPUT_CMA3000) += cma3000_d0x.o
......
......@@ -325,8 +325,6 @@ struct cma3000_accl_data *cma3000_init(struct device *dev, int irq,
input_dev->open = cma3000_open;
input_dev->close = cma3000_close;
__set_bit(EV_ABS, input_dev->evbit);
input_set_abs_params(input_dev, ABS_X,
-data->g_range, data->g_range, pdata->fuzz_x, 0);
input_set_abs_params(input_dev, ABS_Y,
......
......@@ -265,7 +265,7 @@ static inline int hp_sdc_rtc_read_ct(struct timespec64 *res) {
return 0;
}
static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
static int __maybe_unused hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
{
#define YN(bit) ("no")
#define NY(bit) ("yes")
......
// SPDX-License-Identifier: GPL-2.0+
//
// Copyright 2022 NXP.
#include <linux/device.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/regmap.h>
#define BBNSM_CTRL 0x8
#define BBNSM_INT_EN 0x10
#define BBNSM_EVENTS 0x14
#define BBNSM_PAD_CTRL 0x24
#define BBNSM_BTN_PRESSED BIT(7)
#define BBNSM_PWR_ON BIT(6)
#define BBNSM_BTN_OFF BIT(5)
#define BBNSM_EMG_OFF BIT(4)
#define BBNSM_PWRKEY_EVENTS (BBNSM_PWR_ON | BBNSM_BTN_OFF | BBNSM_EMG_OFF)
#define BBNSM_DP_EN BIT(24)
#define DEBOUNCE_TIME 30
#define REPEAT_INTERVAL 60
struct bbnsm_pwrkey {
struct regmap *regmap;
int irq;
int keycode;
int keystate; /* 1:pressed */
struct timer_list check_timer;
struct input_dev *input;
};
static void bbnsm_pwrkey_check_for_events(struct timer_list *t)
{
struct bbnsm_pwrkey *bbnsm = from_timer(bbnsm, t, check_timer);
struct input_dev *input = bbnsm->input;
u32 state;
regmap_read(bbnsm->regmap, BBNSM_EVENTS, &state);
state = state & BBNSM_BTN_PRESSED ? 1 : 0;
/* only report new event if status changed */
if (state ^ bbnsm->keystate) {
bbnsm->keystate = state;
input_event(input, EV_KEY, bbnsm->keycode, state);
input_sync(input);
pm_relax(bbnsm->input->dev.parent);
}
/* repeat check if pressed long */
if (state)
mod_timer(&bbnsm->check_timer,
jiffies + msecs_to_jiffies(REPEAT_INTERVAL));
}
static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id)
{
struct platform_device *pdev = dev_id;
struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev);
u32 event;
regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event);
if (!(event & BBNSM_BTN_OFF))
return IRQ_NONE;
pm_wakeup_event(bbnsm->input->dev.parent, 0);
mod_timer(&bbnsm->check_timer,
jiffies + msecs_to_jiffies(DEBOUNCE_TIME));
/* clear PWR OFF */
regmap_write(bbnsm->regmap, BBNSM_EVENTS, BBNSM_BTN_OFF);
return IRQ_HANDLED;
}
static void bbnsm_pwrkey_act(void *pdata)
{
struct bbnsm_pwrkey *bbnsm = pdata;
timer_shutdown_sync(&bbnsm->check_timer);
}
static int bbnsm_pwrkey_probe(struct platform_device *pdev)
{
struct bbnsm_pwrkey *bbnsm;
struct input_dev *input;
struct device_node *np = pdev->dev.of_node;
int error;
bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL);
if (!bbnsm)
return -ENOMEM;
bbnsm->regmap = syscon_node_to_regmap(np->parent);
if (IS_ERR(bbnsm->regmap)) {
dev_err(&pdev->dev, "bbnsm pwerkey get regmap failed\n");
return PTR_ERR(bbnsm->regmap);
}
if (device_property_read_u32(&pdev->dev, "linux,code",
&bbnsm->keycode)) {
bbnsm->keycode = KEY_POWER;
dev_warn(&pdev->dev, "key code is not specified, using default KEY_POWER\n");
}
bbnsm->irq = platform_get_irq(pdev, 0);
if (bbnsm->irq < 0)
return -EINVAL;
/* config the BBNSM power related register */
regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, BBNSM_DP_EN, BBNSM_DP_EN);
/* clear the unexpected interrupt before driver ready */
regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, BBNSM_PWRKEY_EVENTS,
BBNSM_PWRKEY_EVENTS);
timer_setup(&bbnsm->check_timer, bbnsm_pwrkey_check_for_events, 0);
input = devm_input_allocate_device(&pdev->dev);
if (!input) {
dev_err(&pdev->dev, "failed to allocate the input device\n");
return -ENOMEM;
}
input->name = pdev->name;
input->phys = "bbnsm-pwrkey/input0";
input->id.bustype = BUS_HOST;
input_set_capability(input, EV_KEY, bbnsm->keycode);
/* input customer action to cancel release timer */
error = devm_add_action(&pdev->dev, bbnsm_pwrkey_act, bbnsm);
if (error) {
dev_err(&pdev->dev, "failed to register remove action\n");
return error;
}
bbnsm->input = input;
platform_set_drvdata(pdev, bbnsm);
error = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_pwrkey_interrupt,
IRQF_SHARED, pdev->name, pdev);
if (error) {
dev_err(&pdev->dev, "interrupt not available.\n");
return error;
}
error = input_register_device(input);
if (error) {
dev_err(&pdev->dev, "failed to register input device\n");
return error;
}
device_init_wakeup(&pdev->dev, true);
error = dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
if (error)
dev_warn(&pdev->dev, "irq wake enable failed.\n");
return 0;
}
static const struct of_device_id bbnsm_pwrkey_ids[] = {
{ .compatible = "nxp,imx93-bbnsm-pwrkey" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids);
static struct platform_driver bbnsm_pwrkey_driver = {
.driver = {
.name = "bbnsm_pwrkey",
.of_match_table = bbnsm_pwrkey_ids,
},
.probe = bbnsm_pwrkey_probe,
};
module_platform_driver(bbnsm_pwrkey_driver);
MODULE_AUTHOR("Jacky Bai <ping.bai@nxp.com>");
MODULE_DESCRIPTION("NXP bbnsm power key Driver");
MODULE_LICENSE("GPL");
......@@ -285,7 +285,7 @@ void rmi_unregister_function(struct rmi_function *fn)
}
/**
* rmi_register_function_handler - register a handler for an RMI function
* __rmi_register_function_handler - register a handler for an RMI function
* @handler: RMI handler that should be registered.
* @owner: pointer to module that implements the handler
* @mod_name: name of the module implementing the handler
......
CONFIG_KUNIT=y
CONFIG_INPUT=y
CONFIG_INPUT_KUNIT_TEST=y
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_INPUT_KUNIT_TEST) += input_test.o
// SPDX-License-Identifier: GPL-2.0
/*
* KUnit test for the input core.
*
* Copyright (c) 2023 Red Hat Inc
*/
#include <linux/delay.h>
#include <linux/input.h>
#include <kunit/test.h>
#define POLL_INTERVAL 100
static int input_test_init(struct kunit *test)
{
struct input_dev *input_dev;
int ret;
input_dev = input_allocate_device();
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, input_dev);
input_dev->name = "Test input device";
input_dev->id.bustype = BUS_VIRTUAL;
input_dev->id.vendor = 1;
input_dev->id.product = 1;
input_dev->id.version = 1;
input_set_capability(input_dev, EV_KEY, BTN_LEFT);
input_set_capability(input_dev, EV_KEY, BTN_RIGHT);
ret = input_register_device(input_dev);
if (ret) {
input_free_device(input_dev);
KUNIT_ASSERT_FAILURE(test, "Register device failed: %d", ret);
}
test->priv = input_dev;
return 0;
}
static void input_test_exit(struct kunit *test)
{
struct input_dev *input_dev = test->priv;
input_unregister_device(input_dev);
input_free_device(input_dev);
}
static void input_test_poll(struct input_dev *input) { }
static void input_test_polling(struct kunit *test)
{
struct input_dev *input_dev = test->priv;
/* Must fail because a poll handler has not been set-up yet */
KUNIT_ASSERT_EQ(test, input_get_poll_interval(input_dev), -EINVAL);
KUNIT_ASSERT_EQ(test, input_setup_polling(input_dev, input_test_poll), 0);
input_set_poll_interval(input_dev, POLL_INTERVAL);
/* Must succeed because poll handler was set-up and poll interval set */
KUNIT_ASSERT_EQ(test, input_get_poll_interval(input_dev), POLL_INTERVAL);
}
static void input_test_timestamp(struct kunit *test)
{
const ktime_t invalid_timestamp = ktime_set(0, 0);
struct input_dev *input_dev = test->priv;
ktime_t *timestamp, time;
timestamp = input_get_timestamp(input_dev);
time = timestamp[INPUT_CLK_MONO];
/* The returned timestamp must always be valid */
KUNIT_ASSERT_EQ(test, ktime_compare(time, invalid_timestamp), 1);
time = ktime_get();
input_set_timestamp(input_dev, time);
timestamp = input_get_timestamp(input_dev);
/* The timestamp must be the same than set before */
KUNIT_ASSERT_EQ(test, ktime_compare(timestamp[INPUT_CLK_MONO], time), 0);
}
static void input_test_match_device_id(struct kunit *test)
{
struct input_dev *input_dev = test->priv;
struct input_device_id id;
/*
* Must match when the input device bus, vendor, product, version
* and events capable of handling are the same and fail to match
* otherwise.
*/
id.flags = INPUT_DEVICE_ID_MATCH_BUS;
id.bustype = BUS_VIRTUAL;
KUNIT_ASSERT_TRUE(test, input_match_device_id(input_dev, &id));
id.bustype = BUS_I2C;
KUNIT_ASSERT_FALSE(test, input_match_device_id(input_dev, &id));
id.flags = INPUT_DEVICE_ID_MATCH_VENDOR;
id.vendor = 1;
KUNIT_ASSERT_TRUE(test, input_match_device_id(input_dev, &id));
id.vendor = 2;
KUNIT_ASSERT_FALSE(test, input_match_device_id(input_dev, &id));
id.flags = INPUT_DEVICE_ID_MATCH_PRODUCT;
id.product = 1;
KUNIT_ASSERT_TRUE(test, input_match_device_id(input_dev, &id));
id.product = 2;
KUNIT_ASSERT_FALSE(test, input_match_device_id(input_dev, &id));
id.flags = INPUT_DEVICE_ID_MATCH_VERSION;
id.version = 1;
KUNIT_ASSERT_TRUE(test, input_match_device_id(input_dev, &id));
id.version = 2;
KUNIT_ASSERT_FALSE(test, input_match_device_id(input_dev, &id));
id.flags = INPUT_DEVICE_ID_MATCH_EVBIT;
__set_bit(EV_KEY, id.evbit);
KUNIT_ASSERT_TRUE(test, input_match_device_id(input_dev, &id));
__set_bit(EV_ABS, id.evbit);
KUNIT_ASSERT_FALSE(test, input_match_device_id(input_dev, &id));
}
static struct kunit_case input_tests[] = {
KUNIT_CASE(input_test_polling),
KUNIT_CASE(input_test_timestamp),
KUNIT_CASE(input_test_match_device_id),
{ /* sentinel */ }
};
static struct kunit_suite input_test_suite = {
.name = "input_core",
.init = input_test_init,
.exit = input_test_exit,
.test_cases = input_tests,
};
kunit_test_suite(input_test_suite);
MODULE_AUTHOR("Javier Martinez Canillas <javierm@redhat.com>");
MODULE_LICENSE("GPL");
......@@ -654,6 +654,16 @@ config TOUCHSCREEN_MTOUCH
To compile this driver as a module, choose M here: the
module will be called mtouch.
config TOUCHSCREEN_NOVATEK_NVT_TS
tristate "Novatek NVT-ts touchscreen support"
depends on I2C
help
Say Y here if you have a Novatek NVT-ts touchscreen.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called novatek-nvt-ts.
config TOUCHSCREEN_IMAGIS
tristate "Imagis touchscreen support"
depends on I2C
......@@ -758,6 +768,7 @@ config TOUCHSCREEN_PENMOUNT
config TOUCHSCREEN_EDT_FT5X06
tristate "EDT FocalTech FT5x06 I2C Touchscreen support"
depends on I2C
select REGMAP_I2C
help
Say Y here if you have an EDT "Polytouch" touchscreen based
on the FocalTech FT5x06 family of controllers connected to
......
......@@ -67,6 +67,7 @@ obj-$(CONFIG_TOUCHSCREEN_MMS114) += mms114.o
obj-$(CONFIG_TOUCHSCREEN_MSG2638) += msg2638.o
obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
obj-$(CONFIG_TOUCHSCREEN_NOVATEK_NVT_TS) += novatek-nvt-ts.o
obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
obj-$(CONFIG_TOUCHSCREEN_HP7XX) += jornada720_ts.o
obj-$(CONFIG_TOUCHSCREEN_IPAQ_MICRO) += ipaq-micro-ts.o
......
......@@ -511,7 +511,7 @@ static struct platform_driver iproc_ts_driver = {
.probe = iproc_ts_probe,
.driver = {
.name = IPROC_TS_NAME,
.of_match_table = of_match_ptr(iproc_ts_of_match),
.of_match_table = iproc_ts_of_match,
},
};
......
This diff is collapsed.
......@@ -35,6 +35,7 @@
#define HIDEEP_EVENT_ADDR 0x240
/* command list */
#define HIDEEP_WORK_MODE 0x081e
#define HIDEEP_RESET_CMD 0x9800
/* event bit */
......@@ -271,9 +272,14 @@ static int hideep_pgm_w_reg(struct hideep_ts *ts, u32 addr, u32 val)
#define SW_RESET_IN_PGM(clk) \
{ \
__be32 data = cpu_to_be32(0x01); \
hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CNT, (clk)); \
hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x03); \
hideep_pgm_w_reg(ts, HIDEEP_SYSCON_WDT_CON, 0x01); \
/* \
* The first write may already cause a reset, use a raw \
* write for the second write to avoid error logging. \
*/ \
hideep_pgm_w_mem(ts, HIDEEP_SYSCON_WDT_CON, &data, 1); \
}
#define SET_FLASH_PIO(ce) \
......@@ -467,9 +473,9 @@ static int hideep_program_nvm(struct hideep_ts *ts,
u32 addr = 0;
int error;
error = hideep_nvm_unlock(ts);
if (error)
return error;
error = hideep_nvm_unlock(ts);
if (error)
return error;
while (ucode_len > 0) {
xfer_len = min_t(size_t, ucode_len, HIDEEP_NVM_PAGE_SIZE);
......@@ -959,6 +965,21 @@ static const struct attribute_group hideep_ts_attr_group = {
.attrs = hideep_ts_sysfs_entries,
};
static void hideep_set_work_mode(struct hideep_ts *ts)
{
/*
* Reset touch report format to the native HiDeep 20 protocol if requested.
* This is necessary to make touchscreens which come up in I2C-HID mode
* work with this driver.
*
* Note this is a kernel internal device-property set by x86 platform code,
* this MUST not be used in devicetree files without first adding it to
* the DT bindings.
*/
if (device_property_read_bool(&ts->client->dev, "hideep,force-native-protocol"))
regmap_write(ts->reg, HIDEEP_WORK_MODE, 0x00);
}
static int hideep_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
......@@ -982,6 +1003,8 @@ static int hideep_resume(struct device *dev)
return error;
}
hideep_set_work_mode(ts);
enable_irq(client->irq);
return 0;
......@@ -1058,6 +1081,8 @@ static int hideep_probe(struct i2c_client *client)
return error;
}
hideep_set_work_mode(ts);
error = hideep_init_input(ts);
if (error)
return error;
......
......@@ -466,7 +466,7 @@ static void mip4_report_touch(struct mip4_ts *ts, u8 *packet)
{
int id;
bool __always_unused hover;
bool __always_unused palm;
bool palm;
bool state;
u16 x, y;
u8 __always_unused pressure_stage = 0;
......@@ -522,21 +522,21 @@ static void mip4_report_touch(struct mip4_ts *ts, u8 *packet)
if (unlikely(id < 0 || id >= MIP4_MAX_FINGERS)) {
dev_err(&ts->client->dev, "Screen - invalid slot ID: %d\n", id);
} else if (state) {
/* Press or Move event */
input_mt_slot(ts->input, id);
input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, true);
goto out;
}
input_mt_slot(ts->input, id);
if (input_mt_report_slot_state(ts->input,
palm ? MT_TOOL_PALM : MT_TOOL_FINGER,
state)) {
input_report_abs(ts->input, ABS_MT_POSITION_X, x);
input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
input_report_abs(ts->input, ABS_MT_PRESSURE, pressure);
input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, touch_major);
input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, touch_minor);
} else {
/* Release event */
input_mt_slot(ts->input, id);
input_mt_report_slot_inactive(ts->input);
}
out:
input_mt_sync_frame(ts->input);
}
......@@ -1483,6 +1483,7 @@ static int mip4_probe(struct i2c_client *client)
input->keycodesize = sizeof(*ts->key_code);
input->keycodemax = ts->key_num;
input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
input_set_abs_params(input, ABS_MT_PRESSURE,
......
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Novatek i2c touchscreen controller as found on
* the Acer Iconia One 7 B1-750 tablet. The Touchscreen controller
* model-number is unknown. Android calls this a "NVT-ts" touchscreen,
* but that may apply to other Novatek controller models too.
*
* Copyright (c) 2023 Hans de Goede <hdegoede@redhat.com>
*/
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/module.h>
#include <asm/unaligned.h>
#define NVT_TS_TOUCH_START 0x00
#define NVT_TS_TOUCH_SIZE 6
#define NVT_TS_PARAMETERS_START 0x78
/* These are offsets from NVT_TS_PARAMETERS_START */
#define NVT_TS_PARAMS_WIDTH 0x04
#define NVT_TS_PARAMS_HEIGHT 0x06
#define NVT_TS_PARAMS_MAX_TOUCH 0x09
#define NVT_TS_PARAMS_MAX_BUTTONS 0x0a
#define NVT_TS_PARAMS_IRQ_TYPE 0x0b
#define NVT_TS_PARAMS_WAKE_TYPE 0x0c
#define NVT_TS_PARAMS_CHIP_ID 0x0e
#define NVT_TS_PARAMS_SIZE 0x0f
#define NVT_TS_SUPPORTED_WAKE_TYPE 0x05
#define NVT_TS_SUPPORTED_CHIP_ID 0x05
#define NVT_TS_MAX_TOUCHES 10
#define NVT_TS_MAX_SIZE 4096
#define NVT_TS_TOUCH_INVALID 0xff
#define NVT_TS_TOUCH_SLOT_SHIFT 3
#define NVT_TS_TOUCH_TYPE_MASK GENMASK(2, 0)
#define NVT_TS_TOUCH_NEW 1
#define NVT_TS_TOUCH_UPDATE 2
#define NVT_TS_TOUCH_RELEASE 3
static const int nvt_ts_irq_type[4] = {
IRQF_TRIGGER_RISING,
IRQF_TRIGGER_FALLING,
IRQF_TRIGGER_LOW,
IRQF_TRIGGER_HIGH
};
struct nvt_ts_data {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *reset_gpio;
struct touchscreen_properties prop;
int max_touches;
u8 buf[NVT_TS_TOUCH_SIZE * NVT_TS_MAX_TOUCHES];
};
static int nvt_ts_read_data(struct i2c_client *client, u8 reg, u8 *data, int count)
{
struct i2c_msg msg[2] = {
{
.addr = client->addr,
.len = 1,
.buf = &reg,
},
{
.addr = client->addr,
.flags = I2C_M_RD,
.len = count,
.buf = data,
}
};
int ret;
ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
if (ret != ARRAY_SIZE(msg)) {
dev_err(&client->dev, "Error reading from 0x%02x: %d\n", reg, ret);
return (ret < 0) ? ret : -EIO;
}
return 0;
}
static irqreturn_t nvt_ts_irq(int irq, void *dev_id)
{
struct nvt_ts_data *data = dev_id;
struct device *dev = &data->client->dev;
int i, error, slot, x, y;
bool active;
u8 *touch;
error = nvt_ts_read_data(data->client, NVT_TS_TOUCH_START, data->buf,
data->max_touches * NVT_TS_TOUCH_SIZE);
if (error)
return IRQ_HANDLED;
for (i = 0; i < data->max_touches; i++) {
touch = &data->buf[i * NVT_TS_TOUCH_SIZE];
if (touch[0] == NVT_TS_TOUCH_INVALID)
continue;
slot = touch[0] >> NVT_TS_TOUCH_SLOT_SHIFT;
if (slot < 1 || slot > data->max_touches) {
dev_warn(dev, "slot %d out of range, ignoring\n", slot);
continue;
}
switch (touch[0] & NVT_TS_TOUCH_TYPE_MASK) {
case NVT_TS_TOUCH_NEW:
case NVT_TS_TOUCH_UPDATE:
active = true;
break;
case NVT_TS_TOUCH_RELEASE:
active = false;
break;
default:
dev_warn(dev, "slot %d unknown state %d\n", slot, touch[0] & 7);
continue;
}
slot--;
x = (touch[1] << 4) | (touch[3] >> 4);
y = (touch[2] << 4) | (touch[3] & 0x0f);
input_mt_slot(data->input, slot);
input_mt_report_slot_state(data->input, MT_TOOL_FINGER, active);
touchscreen_report_pos(data->input, &data->prop, x, y, true);
}
input_mt_sync_frame(data->input);
input_sync(data->input);
return IRQ_HANDLED;
}
static int nvt_ts_start(struct input_dev *dev)
{
struct nvt_ts_data *data = input_get_drvdata(dev);
enable_irq(data->client->irq);
gpiod_set_value_cansleep(data->reset_gpio, 0);
return 0;
}
static void nvt_ts_stop(struct input_dev *dev)
{
struct nvt_ts_data *data = input_get_drvdata(dev);
disable_irq(data->client->irq);
gpiod_set_value_cansleep(data->reset_gpio, 1);
}
static int nvt_ts_suspend(struct device *dev)
{
struct nvt_ts_data *data = i2c_get_clientdata(to_i2c_client(dev));
mutex_lock(&data->input->mutex);
if (input_device_enabled(data->input))
nvt_ts_stop(data->input);
mutex_unlock(&data->input->mutex);
return 0;
}
static int nvt_ts_resume(struct device *dev)
{
struct nvt_ts_data *data = i2c_get_clientdata(to_i2c_client(dev));
mutex_lock(&data->input->mutex);
if (input_device_enabled(data->input))
nvt_ts_start(data->input);
mutex_unlock(&data->input->mutex);
return 0;
}
static DEFINE_SIMPLE_DEV_PM_OPS(nvt_ts_pm_ops, nvt_ts_suspend, nvt_ts_resume);
static int nvt_ts_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
int error, width, height, irq_type;
struct nvt_ts_data *data;
struct input_dev *input;
if (!client->irq) {
dev_err(dev, "Error no irq specified\n");
return -EINVAL;
}
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->client = client;
i2c_set_clientdata(client, data);
data->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
error = PTR_ERR_OR_ZERO(data->reset_gpio);
if (error) {
dev_err(dev, "failed to request reset GPIO: %d\n", error);
return error;
}
/* Wait for controller to come out of reset before params read */
msleep(100);
error = nvt_ts_read_data(data->client, NVT_TS_PARAMETERS_START,
data->buf, NVT_TS_PARAMS_SIZE);
gpiod_set_value_cansleep(data->reset_gpio, 1); /* Put back in reset */
if (error)
return error;
width = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_WIDTH]);
height = get_unaligned_be16(&data->buf[NVT_TS_PARAMS_HEIGHT]);
data->max_touches = data->buf[NVT_TS_PARAMS_MAX_TOUCH];
irq_type = data->buf[NVT_TS_PARAMS_IRQ_TYPE];
if (width > NVT_TS_MAX_SIZE || height >= NVT_TS_MAX_SIZE ||
data->max_touches > NVT_TS_MAX_TOUCHES ||
irq_type >= ARRAY_SIZE(nvt_ts_irq_type) ||
data->buf[NVT_TS_PARAMS_WAKE_TYPE] != NVT_TS_SUPPORTED_WAKE_TYPE ||
data->buf[NVT_TS_PARAMS_CHIP_ID] != NVT_TS_SUPPORTED_CHIP_ID) {
dev_err(dev, "Unsupported touchscreen parameters: %*ph\n",
NVT_TS_PARAMS_SIZE, data->buf);
return -EIO;
}
dev_dbg(dev, "Detected %dx%d touchscreen with %d max touches\n",
width, height, data->max_touches);
if (data->buf[NVT_TS_PARAMS_MAX_BUTTONS])
dev_warn(dev, "Touchscreen buttons are not supported\n");
input = devm_input_allocate_device(dev);
if (!input)
return -ENOMEM;
input->name = client->name;
input->id.bustype = BUS_I2C;
input->open = nvt_ts_start;
input->close = nvt_ts_stop;
input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0);
touchscreen_parse_properties(input, true, &data->prop);
error = input_mt_init_slots(input, data->max_touches,
INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
if (error)
return error;
data->input = input;
input_set_drvdata(input, data);
error = devm_request_threaded_irq(dev, client->irq, NULL, nvt_ts_irq,
IRQF_ONESHOT | IRQF_NO_AUTOEN |
nvt_ts_irq_type[irq_type],
client->name, data);
if (error) {
dev_err(dev, "failed to request irq: %d\n", error);
return error;
}
error = input_register_device(input);
if (error) {
dev_err(dev, "failed to request irq: %d\n", error);
return error;
}
return 0;
}
static const struct i2c_device_id nvt_ts_i2c_id[] = {
{ "NVT-ts" },
{ }
};
MODULE_DEVICE_TABLE(i2c, nvt_ts_i2c_id);
static struct i2c_driver nvt_ts_driver = {
.driver = {
.name = "novatek-nvt-ts",
.pm = pm_sleep_ptr(&nvt_ts_pm_ops),
},
.probe_new = nvt_ts_probe,
.id_table = nvt_ts_i2c_id,
};
module_i2c_driver(nvt_ts_driver);
MODULE_DESCRIPTION("Novatek NVT-ts touchscreen driver");
MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
MODULE_LICENSE("GPL");
......@@ -134,7 +134,7 @@ static int rpi_ts_probe(struct platform_device *pdev)
return -ENOENT;
}
fw = rpi_firmware_get(fw_node);
fw = devm_rpi_firmware_get(&pdev->dev, fw_node);
of_node_put(fw_node);
if (!fw)
return -EPROBE_DEFER;
......@@ -160,7 +160,6 @@ static int rpi_ts_probe(struct platform_device *pdev)
touchbuf = (u32)ts->fw_regs_phys;
error = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF,
&touchbuf, sizeof(touchbuf));
rpi_firmware_put(fw);
if (error || touchbuf != 0) {
dev_warn(dev, "Failed to set touchbuf, %d\n", error);
return error;
......
......@@ -400,7 +400,7 @@ MODULE_DEVICE_TABLE(of, sun4i_ts_of_match);
static struct platform_driver sun4i_ts_driver = {
.driver = {
.name = "sun4i-ts",
.of_match_table = of_match_ptr(sun4i_ts_of_match),
.of_match_table = sun4i_ts_of_match,
},
.probe = sun4i_ts_probe,
.remove = sun4i_ts_remove,
......
......@@ -172,19 +172,6 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
return IRQ_HANDLED;
}
static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
{
struct tsc2007 *ts = handle;
if (tsc2007_is_pen_down(ts))
return IRQ_WAKE_THREAD;
if (ts->clear_penirq)
ts->clear_penirq();
return IRQ_HANDLED;
}
static void tsc2007_stop(struct tsc2007 *ts)
{
ts->stopped = true;
......@@ -226,7 +213,7 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct tsc2007 *ts = i2c_get_clientdata(client);
return gpiod_get_value(ts->gpiod);
return gpiod_get_value_cansleep(ts->gpiod);
}
static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
......@@ -376,7 +363,7 @@ static int tsc2007_probe(struct i2c_client *client)
}
err = devm_request_threaded_irq(&client->dev, ts->irq,
tsc2007_hard_irq, tsc2007_soft_irq,
NULL, tsc2007_soft_irq,
IRQF_ONESHOT,
client->dev.driver->name, ts);
if (err) {
......
......@@ -260,7 +260,7 @@ static int zinitix_init_regulators(struct bt541_ts_data *bt541)
* so check if "vddo" is present and in that case use these names.
* Else use the proper supply names on the component.
*/
if (of_find_property(dev->of_node, "vddo-supply", NULL)) {
if (of_property_present(dev->of_node, "vddo-supply")) {
bt541->supplies[0].supply = "vdd";
bt541->supplies[1].supply = "vddo";
} else {
......
......@@ -3,8 +3,9 @@
#define _MATRIX_KEYPAD_H
#include <linux/types.h>
#include <linux/input.h>
#include <linux/of.h>
struct device;
struct input_dev;
#define MATRIX_MAX_ROWS 32
#define MATRIX_MAX_COLS 32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment