You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input subsystem updates from Dmitry Torokhov: - updated support for Synaptics RMI4 devices, including support for SMBus controllers, firmware update support, sensor tuning, and PS/2 guest support - ALPS driver now supports tracksticks on SS5 controllers - i8042 now uses chassis info to skip selftest on Asus laptops as list of individual models became too unwieldy - miscellaneous fixes to other drivers * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (67 commits) Input: imx6ul_tsc - generalize the averaging property Input: drv260x - use generic device properties Input: drv260x - use temporary for &client->dev Input: drv260x - fix input device's parent assignment Input: synaptics-rmi4 - add support for F34 V7 bootloader Input: drv260x - fix initializing overdrive voltage Input: ALPS - fix protcol -> protocol Input: i8042 - comment #else/#endif of CONFIG_PNP Input: lpc32xx-keys - fix invalid error handling of a requested irq Input: synaptics-rmi4 - fix debug for sensor clip Input: synaptics-rmi4 - store the attn data in the driver Input: synaptics-rmi4 - allow to add attention data Input: synaptics-rmi4 - f03 - grab data passed by transport device Input: synaptics-rmi4 - add support for F03 Input: imx6ul_tsc - convert int to u32 Input: imx6ul_tsc - add mask when set REG_ADC_CFG Input: synaptics-rmi4 - have only one struct platform data Input: synaptics-rmi4 - remove EXPORT_SYMBOL_GPL for internal functions Input: synaptics-rmi4 - remove mutex calls while updating the firmware Input: drv2667 - fix misuse of regmap_update_bits ...
This commit is contained in:
@@ -1,32 +1,47 @@
|
||||
* Dialog DA9062/63 OnKey Module
|
||||
* Dialog DA9061/62/63 OnKey Module
|
||||
|
||||
This module is part of the DA9062/DA9063. For more details about entire
|
||||
chips see Documentation/devicetree/bindings/mfd/da9062.txt and
|
||||
Documentation/devicetree/bindings/mfd/da9063.txt
|
||||
This module is part of the DA9061/DA9062/DA9063. For more details about entire
|
||||
DA9062 and DA9061 chips see Documentation/devicetree/bindings/mfd/da9062.txt
|
||||
For DA9063 see Documentation/devicetree/bindings/mfd/da9063.txt
|
||||
|
||||
This module provides KEY_POWER, KEY_SLEEP and events.
|
||||
This module provides the KEY_POWER event.
|
||||
|
||||
Required properties:
|
||||
|
||||
- compatible: should be one of:
|
||||
dlg,da9062-onkey
|
||||
dlg,da9063-onkey
|
||||
- compatible: should be one of the following valid compatible string lines:
|
||||
"dlg,da9061-onkey", "dlg,da9062-onkey"
|
||||
"dlg,da9062-onkey"
|
||||
"dlg,da9063-onkey"
|
||||
|
||||
Optional properties:
|
||||
|
||||
- dlg,disable-key-power : Disable power-down using a long key-press. If this
|
||||
- dlg,disable-key-power : Disable power-down using a long key-press. If this
|
||||
entry exists the OnKey driver will remove support for the KEY_POWER key
|
||||
press. If this entry does not exist then by default the key-press
|
||||
triggered power down is enabled and the OnKey will support both KEY_POWER
|
||||
and KEY_SLEEP.
|
||||
press when triggered using a long press of the OnKey.
|
||||
|
||||
Example:
|
||||
|
||||
pmic0: da9062@58 {
|
||||
Example: DA9063
|
||||
|
||||
pmic0: da9063@58 {
|
||||
onkey {
|
||||
compatible = "dlg,da9063-onkey";
|
||||
dlg,disable-key-power;
|
||||
};
|
||||
};
|
||||
|
||||
Example: DA9062
|
||||
|
||||
pmic0: da9062@58 {
|
||||
onkey {
|
||||
compatible = "dlg,da9062-onkey";
|
||||
dlg,disable-key-power;
|
||||
};
|
||||
};
|
||||
|
||||
Example: DA9061 using a fall-back compatible for the DA9062 onkey driver
|
||||
|
||||
pmic0: da9061@58 {
|
||||
onkey {
|
||||
compatible = "dlg,da9061-onkey", "dlg,da9062-onkey";
|
||||
dlg,disable-key-power;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,6 +17,8 @@ Optional properties:
|
||||
This value depends on the touch screen.
|
||||
- pre-charge-time: the touch screen need some time to precharge.
|
||||
This value depends on the touch screen.
|
||||
- touchscreen-average-samples: Number of data samples which are averaged for
|
||||
each read. Valid values are 1, 4, 8, 16 and 32.
|
||||
|
||||
Example:
|
||||
tsc: tsc@02040000 {
|
||||
@@ -32,5 +34,6 @@ Example:
|
||||
xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>;
|
||||
measure-delay-time = <0xfff>;
|
||||
pre-charge-time = <0xffff>;
|
||||
touchscreen-average-samples = <32>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -18,6 +18,8 @@ Optional properties:
|
||||
- touchscreen-inverted-y : See touchscreen.txt
|
||||
- touchscreen-swapped-x-y : See touchscreen.txt
|
||||
- silead,max-fingers : maximum number of fingers the touchscreen can detect
|
||||
- vddio-supply : regulator phandle for controller VDDIO
|
||||
- avdd-supply : regulator phandle for controller AVDD
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ Optional properties for Touchscreens:
|
||||
- touchscreen-fuzz-pressure : pressure noise value of the absolute input
|
||||
device (arbitrary range dependent on the
|
||||
controller)
|
||||
- touchscreen-average-samples : Number of data samples which are averaged
|
||||
for each read (valid values dependent on the
|
||||
controller)
|
||||
- touchscreen-inverted-x : X axis is inverted (boolean)
|
||||
- touchscreen-inverted-y : Y axis is inverted (boolean)
|
||||
- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
|
||||
|
||||
@@ -134,6 +134,7 @@ static const struct xpad_device {
|
||||
{ 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
|
||||
{ 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
|
||||
{ 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
|
||||
{ 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
|
||||
{ 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
|
||||
{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
|
||||
{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
|
||||
@@ -1044,9 +1045,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
|
||||
packet->data[7] = 0x00;
|
||||
packet->data[8] = strong / 512; /* left actuator */
|
||||
packet->data[9] = weak / 512; /* right actuator */
|
||||
packet->data[10] = 0xFF;
|
||||
packet->data[11] = 0x00;
|
||||
packet->data[12] = 0x00;
|
||||
packet->data[10] = 0xFF; /* on period */
|
||||
packet->data[11] = 0x00; /* off period */
|
||||
packet->data[12] = 0xFF; /* repeat count */
|
||||
packet->len = 13;
|
||||
packet->pending = true;
|
||||
break;
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
#include <linux/gpio_keys.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
struct gpio_button_data {
|
||||
const struct gpio_keys_button *button;
|
||||
struct input_dev *input;
|
||||
struct gpio_desc *gpiod;
|
||||
|
||||
struct timer_list release_timer;
|
||||
unsigned int release_delay; /* in msecs, for IRQ-only buttons */
|
||||
@@ -140,7 +140,7 @@ static void gpio_keys_disable_button(struct gpio_button_data *bdata)
|
||||
*/
|
||||
disable_irq(bdata->irq);
|
||||
|
||||
if (gpio_is_valid(bdata->button->gpio))
|
||||
if (bdata->gpiod)
|
||||
cancel_delayed_work_sync(&bdata->work);
|
||||
else
|
||||
del_timer_sync(&bdata->release_timer);
|
||||
@@ -358,19 +358,20 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
|
||||
const struct gpio_keys_button *button = bdata->button;
|
||||
struct input_dev *input = bdata->input;
|
||||
unsigned int type = button->type ?: EV_KEY;
|
||||
int state = gpio_get_value_cansleep(button->gpio);
|
||||
int state;
|
||||
|
||||
state = gpiod_get_value_cansleep(bdata->gpiod);
|
||||
if (state < 0) {
|
||||
dev_err(input->dev.parent, "failed to get gpio state\n");
|
||||
dev_err(input->dev.parent,
|
||||
"failed to get gpio state: %d\n", state);
|
||||
return;
|
||||
}
|
||||
|
||||
state = (state ? 1 : 0) ^ button->active_low;
|
||||
if (type == EV_ABS) {
|
||||
if (state)
|
||||
input_event(input, type, button->code, button->value);
|
||||
} else {
|
||||
input_event(input, type, button->code, !!state);
|
||||
input_event(input, type, button->code, state);
|
||||
}
|
||||
input_sync(input);
|
||||
}
|
||||
@@ -456,7 +457,7 @@ static void gpio_keys_quiesce_key(void *data)
|
||||
{
|
||||
struct gpio_button_data *bdata = data;
|
||||
|
||||
if (gpio_is_valid(bdata->button->gpio))
|
||||
if (bdata->gpiod)
|
||||
cancel_delayed_work_sync(&bdata->work);
|
||||
else
|
||||
del_timer_sync(&bdata->release_timer);
|
||||
@@ -465,7 +466,8 @@ static void gpio_keys_quiesce_key(void *data)
|
||||
static int gpio_keys_setup_key(struct platform_device *pdev,
|
||||
struct input_dev *input,
|
||||
struct gpio_button_data *bdata,
|
||||
const struct gpio_keys_button *button)
|
||||
const struct gpio_keys_button *button,
|
||||
struct fwnode_handle *child)
|
||||
{
|
||||
const char *desc = button->desc ? button->desc : "gpio_keys";
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -478,18 +480,56 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
|
||||
bdata->button = button;
|
||||
spin_lock_init(&bdata->lock);
|
||||
|
||||
if (gpio_is_valid(button->gpio)) {
|
||||
if (child) {
|
||||
bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, child);
|
||||
if (IS_ERR(bdata->gpiod)) {
|
||||
error = PTR_ERR(bdata->gpiod);
|
||||
if (error == -ENOENT) {
|
||||
/*
|
||||
* GPIO is optional, we may be dealing with
|
||||
* purely interrupt-driven setup.
|
||||
*/
|
||||
bdata->gpiod = NULL;
|
||||
} else {
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev, "failed to get gpio: %d\n",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
} else {
|
||||
error = gpiod_direction_input(bdata->gpiod);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to configure GPIO %d as input: %d\n",
|
||||
desc_to_gpio(bdata->gpiod), error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
} else if (gpio_is_valid(button->gpio)) {
|
||||
/*
|
||||
* Legacy GPIO number, so request the GPIO here and
|
||||
* convert it to descriptor.
|
||||
*/
|
||||
unsigned flags = GPIOF_IN;
|
||||
|
||||
error = devm_gpio_request_one(&pdev->dev, button->gpio,
|
||||
GPIOF_IN, desc);
|
||||
if (button->active_low)
|
||||
flags |= GPIOF_ACTIVE_LOW;
|
||||
|
||||
error = devm_gpio_request_one(&pdev->dev, button->gpio, flags,
|
||||
desc);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "Failed to request GPIO %d, error %d\n",
|
||||
button->gpio, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
bdata->gpiod = gpio_to_desc(button->gpio);
|
||||
if (!bdata->gpiod)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (bdata->gpiod) {
|
||||
if (button->debounce_interval) {
|
||||
error = gpio_set_debounce(button->gpio,
|
||||
error = gpiod_set_debounce(bdata->gpiod,
|
||||
button->debounce_interval * 1000);
|
||||
/* use timer if gpiolib doesn't provide debounce */
|
||||
if (error < 0)
|
||||
@@ -500,7 +540,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
|
||||
if (button->irq) {
|
||||
bdata->irq = button->irq;
|
||||
} else {
|
||||
irq = gpio_to_irq(button->gpio);
|
||||
irq = gpiod_to_irq(bdata->gpiod);
|
||||
if (irq < 0) {
|
||||
error = irq;
|
||||
dev_err(dev,
|
||||
@@ -518,9 +558,10 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
|
||||
|
||||
} else {
|
||||
if (!button->irq) {
|
||||
dev_err(dev, "No IRQ specified\n");
|
||||
dev_err(dev, "Found button without gpio or irq\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bdata->irq = button->irq;
|
||||
|
||||
if (button->type && button->type != EV_KEY) {
|
||||
@@ -575,7 +616,7 @@ static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata)
|
||||
|
||||
for (i = 0; i < ddata->pdata->nbuttons; i++) {
|
||||
struct gpio_button_data *bdata = &ddata->data[i];
|
||||
if (gpio_is_valid(bdata->button->gpio))
|
||||
if (bdata->gpiod)
|
||||
gpio_keys_gpio_report_event(bdata);
|
||||
}
|
||||
input_sync(input);
|
||||
@@ -612,25 +653,18 @@ static void gpio_keys_close(struct input_dev *input)
|
||||
* Handlers for alternative sources of platform_data
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
/*
|
||||
* Translate OpenFirmware node properties into platform_data
|
||||
* Translate properties into platform_data
|
||||
*/
|
||||
static struct gpio_keys_platform_data *
|
||||
gpio_keys_get_devtree_pdata(struct device *dev)
|
||||
{
|
||||
struct device_node *node, *pp;
|
||||
struct gpio_keys_platform_data *pdata;
|
||||
struct gpio_keys_button *button;
|
||||
int error;
|
||||
struct fwnode_handle *child;
|
||||
int nbuttons;
|
||||
int i;
|
||||
|
||||
node = dev->of_node;
|
||||
if (!node)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
nbuttons = of_get_available_child_count(node);
|
||||
nbuttons = device_get_child_node_count(dev);
|
||||
if (nbuttons == 0)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
@@ -640,64 +674,47 @@ gpio_keys_get_devtree_pdata(struct device *dev)
|
||||
if (!pdata)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
|
||||
button = (struct gpio_keys_button *)(pdata + 1);
|
||||
|
||||
pdata->buttons = button;
|
||||
pdata->nbuttons = nbuttons;
|
||||
|
||||
pdata->rep = !!of_get_property(node, "autorepeat", NULL);
|
||||
pdata->rep = device_property_read_bool(dev, "autorepeat");
|
||||
|
||||
of_property_read_string(node, "label", &pdata->name);
|
||||
device_property_read_string(dev, "label", &pdata->name);
|
||||
|
||||
i = 0;
|
||||
for_each_available_child_of_node(node, pp) {
|
||||
enum of_gpio_flags flags;
|
||||
device_for_each_child_node(dev, child) {
|
||||
if (is_of_node(child))
|
||||
button->irq =
|
||||
irq_of_parse_and_map(to_of_node(child), 0);
|
||||
|
||||
button = &pdata->buttons[i++];
|
||||
|
||||
button->gpio = of_get_gpio_flags(pp, 0, &flags);
|
||||
if (button->gpio < 0) {
|
||||
error = button->gpio;
|
||||
if (error != -ENOENT) {
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev,
|
||||
"Failed to get gpio flags, error: %d\n",
|
||||
error);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
} else {
|
||||
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
|
||||
}
|
||||
|
||||
button->irq = irq_of_parse_and_map(pp, 0);
|
||||
|
||||
if (!gpio_is_valid(button->gpio) && !button->irq) {
|
||||
dev_err(dev, "Found button without gpios or irqs\n");
|
||||
if (fwnode_property_read_u32(child, "linux,code",
|
||||
&button->code)) {
|
||||
dev_err(dev, "Button without keycode\n");
|
||||
fwnode_handle_put(child);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
if (of_property_read_u32(pp, "linux,code", &button->code)) {
|
||||
dev_err(dev, "Button without keycode: 0x%x\n",
|
||||
button->gpio);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
fwnode_property_read_string(child, "label", &button->desc);
|
||||
|
||||
button->desc = of_get_property(pp, "label", NULL);
|
||||
|
||||
if (of_property_read_u32(pp, "linux,input-type", &button->type))
|
||||
if (fwnode_property_read_u32(child, "linux,input-type",
|
||||
&button->type))
|
||||
button->type = EV_KEY;
|
||||
|
||||
button->wakeup = of_property_read_bool(pp, "wakeup-source") ||
|
||||
/* legacy name */
|
||||
of_property_read_bool(pp, "gpio-key,wakeup");
|
||||
button->wakeup =
|
||||
fwnode_property_read_bool(child, "wakeup-source") ||
|
||||
/* legacy name */
|
||||
fwnode_property_read_bool(child, "gpio-key,wakeup");
|
||||
|
||||
button->can_disable = !!of_get_property(pp, "linux,can-disable", NULL);
|
||||
button->can_disable =
|
||||
fwnode_property_read_bool(child, "linux,can-disable");
|
||||
|
||||
if (of_property_read_u32(pp, "debounce-interval",
|
||||
if (fwnode_property_read_u32(child, "debounce-interval",
|
||||
&button->debounce_interval))
|
||||
button->debounce_interval = 5;
|
||||
}
|
||||
|
||||
if (pdata->nbuttons == 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
button++;
|
||||
}
|
||||
|
||||
return pdata;
|
||||
}
|
||||
@@ -708,20 +725,11 @@ static const struct of_device_id gpio_keys_of_match[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, gpio_keys_of_match);
|
||||
|
||||
#else
|
||||
|
||||
static inline struct gpio_keys_platform_data *
|
||||
gpio_keys_get_devtree_pdata(struct device *dev)
|
||||
{
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int gpio_keys_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
|
||||
struct fwnode_handle *child = NULL;
|
||||
struct gpio_keys_drvdata *ddata;
|
||||
struct input_dev *input;
|
||||
size_t size;
|
||||
@@ -774,14 +782,28 @@ static int gpio_keys_probe(struct platform_device *pdev)
|
||||
const struct gpio_keys_button *button = &pdata->buttons[i];
|
||||
struct gpio_button_data *bdata = &ddata->data[i];
|
||||
|
||||
error = gpio_keys_setup_key(pdev, input, bdata, button);
|
||||
if (error)
|
||||
if (!dev_get_platdata(dev)) {
|
||||
child = device_get_next_child_node(&pdev->dev, child);
|
||||
if (!child) {
|
||||
dev_err(&pdev->dev,
|
||||
"missing child device node for entry %d\n",
|
||||
i);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
error = gpio_keys_setup_key(pdev, input, bdata, button, child);
|
||||
if (error) {
|
||||
fwnode_handle_put(child);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (button->wakeup)
|
||||
wakeup = 1;
|
||||
}
|
||||
|
||||
fwnode_handle_put(child);
|
||||
|
||||
error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
|
||||
if (error) {
|
||||
dev_err(dev, "Unable to export keys/switches, error: %d\n",
|
||||
@@ -814,8 +836,7 @@ static int gpio_keys_remove(struct platform_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int gpio_keys_suspend(struct device *dev)
|
||||
static int __maybe_unused gpio_keys_suspend(struct device *dev)
|
||||
{
|
||||
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
||||
struct input_dev *input = ddata->input;
|
||||
@@ -837,7 +858,7 @@ static int gpio_keys_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int gpio_keys_resume(struct device *dev)
|
||||
static int __maybe_unused gpio_keys_resume(struct device *dev)
|
||||
{
|
||||
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
||||
struct input_dev *input = ddata->input;
|
||||
@@ -863,7 +884,6 @@ static int gpio_keys_resume(struct device *dev)
|
||||
gpio_keys_report_state(ddata);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops, gpio_keys_suspend, gpio_keys_resume);
|
||||
|
||||
@@ -873,7 +893,7 @@ static struct platform_driver gpio_keys_device_driver = {
|
||||
.driver = {
|
||||
.name = "gpio-keys",
|
||||
.pm = &gpio_keys_pm_ops,
|
||||
.of_match_table = of_match_ptr(gpio_keys_of_match),
|
||||
.of_match_table = gpio_keys_of_match,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
#define DRV_NAME "gpio-keys-polled"
|
||||
|
||||
struct gpio_keys_button_data {
|
||||
struct gpio_desc *gpiod;
|
||||
int last_state;
|
||||
int count;
|
||||
int threshold;
|
||||
int can_sleep;
|
||||
};
|
||||
|
||||
struct gpio_keys_polled_dev {
|
||||
@@ -46,7 +46,7 @@ struct gpio_keys_polled_dev {
|
||||
};
|
||||
|
||||
static void gpio_keys_button_event(struct input_polled_dev *dev,
|
||||
struct gpio_keys_button *button,
|
||||
const struct gpio_keys_button *button,
|
||||
int state)
|
||||
{
|
||||
struct gpio_keys_polled_dev *bdev = dev->private;
|
||||
@@ -70,21 +70,22 @@ static void gpio_keys_button_event(struct input_polled_dev *dev,
|
||||
}
|
||||
|
||||
static void gpio_keys_polled_check_state(struct input_polled_dev *dev,
|
||||
struct gpio_keys_button *button,
|
||||
const struct gpio_keys_button *button,
|
||||
struct gpio_keys_button_data *bdata)
|
||||
{
|
||||
int state;
|
||||
|
||||
if (bdata->can_sleep)
|
||||
state = !!gpiod_get_value_cansleep(button->gpiod);
|
||||
else
|
||||
state = !!gpiod_get_value(button->gpiod);
|
||||
state = gpiod_get_value_cansleep(bdata->gpiod);
|
||||
if (state < 0) {
|
||||
dev_err(dev->input->dev.parent,
|
||||
"failed to get gpio state: %d\n", state);
|
||||
} else {
|
||||
gpio_keys_button_event(dev, button, state);
|
||||
|
||||
gpio_keys_button_event(dev, button, state);
|
||||
|
||||
if (state != bdata->last_state) {
|
||||
bdata->count = 0;
|
||||
bdata->last_state = state;
|
||||
if (state != bdata->last_state) {
|
||||
bdata->count = 0;
|
||||
bdata->last_state = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,48 +143,35 @@ static void gpio_keys_polled_close(struct input_polled_dev *dev)
|
||||
pdata->disable(bdev->dev);
|
||||
}
|
||||
|
||||
static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct device *dev)
|
||||
static struct gpio_keys_platform_data *
|
||||
gpio_keys_polled_get_devtree_pdata(struct device *dev)
|
||||
{
|
||||
struct gpio_keys_platform_data *pdata;
|
||||
struct gpio_keys_button *button;
|
||||
struct fwnode_handle *child;
|
||||
int error;
|
||||
int nbuttons;
|
||||
|
||||
nbuttons = device_get_child_node_count(dev);
|
||||
if (nbuttons == 0)
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
pdata = devm_kzalloc(dev, sizeof(*pdata) + nbuttons * sizeof(*button),
|
||||
GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
|
||||
button = (struct gpio_keys_button *)(pdata + 1);
|
||||
|
||||
pdata->buttons = button;
|
||||
pdata->nbuttons = nbuttons;
|
||||
|
||||
pdata->rep = device_property_present(dev, "autorepeat");
|
||||
device_property_read_u32(dev, "poll-interval", &pdata->poll_interval);
|
||||
|
||||
device_for_each_child_node(dev, child) {
|
||||
struct gpio_desc *desc;
|
||||
|
||||
desc = devm_get_gpiod_from_child(dev, NULL, child);
|
||||
if (IS_ERR(desc)) {
|
||||
error = PTR_ERR(desc);
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev,
|
||||
"Failed to get gpio flags, error: %d\n",
|
||||
error);
|
||||
fwnode_handle_put(child);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
button = &pdata->buttons[pdata->nbuttons++];
|
||||
button->gpiod = desc;
|
||||
|
||||
if (fwnode_property_read_u32(child, "linux,code", &button->code)) {
|
||||
dev_err(dev, "Button without keycode: %d\n",
|
||||
pdata->nbuttons - 1);
|
||||
if (fwnode_property_read_u32(child, "linux,code",
|
||||
&button->code)) {
|
||||
dev_err(dev, "button without keycode\n");
|
||||
fwnode_handle_put(child);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
@@ -206,10 +194,9 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
|
||||
if (fwnode_property_read_u32(child, "debounce-interval",
|
||||
&button->debounce_interval))
|
||||
button->debounce_interval = 5;
|
||||
}
|
||||
|
||||
if (pdata->nbuttons == 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
button++;
|
||||
}
|
||||
|
||||
return pdata;
|
||||
}
|
||||
@@ -220,7 +207,7 @@ static void gpio_keys_polled_set_abs_params(struct input_dev *input,
|
||||
int i, min = 0, max = 0;
|
||||
|
||||
for (i = 0; i < pdata->nbuttons; i++) {
|
||||
struct gpio_keys_button *button = &pdata->buttons[i];
|
||||
const struct gpio_keys_button *button = &pdata->buttons[i];
|
||||
|
||||
if (button->type != EV_ABS || button->code != code)
|
||||
continue;
|
||||
@@ -230,6 +217,7 @@ static void gpio_keys_polled_set_abs_params(struct input_dev *input,
|
||||
if (button->value > max)
|
||||
max = button->value;
|
||||
}
|
||||
|
||||
input_set_abs_params(input, code, min, max, 0, 0);
|
||||
}
|
||||
|
||||
@@ -242,6 +230,7 @@ MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
|
||||
static int gpio_keys_polled_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct fwnode_handle *child = NULL;
|
||||
const struct gpio_keys_platform_data *pdata = dev_get_platdata(dev);
|
||||
struct gpio_keys_polled_dev *bdev;
|
||||
struct input_polled_dev *poll_dev;
|
||||
@@ -254,10 +243,6 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
|
||||
pdata = gpio_keys_polled_get_devtree_pdata(dev);
|
||||
if (IS_ERR(pdata))
|
||||
return PTR_ERR(pdata);
|
||||
if (!pdata) {
|
||||
dev_err(dev, "missing platform data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pdata->poll_interval) {
|
||||
@@ -300,20 +285,48 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
|
||||
__set_bit(EV_REP, input->evbit);
|
||||
|
||||
for (i = 0; i < pdata->nbuttons; i++) {
|
||||
struct gpio_keys_button *button = &pdata->buttons[i];
|
||||
const struct gpio_keys_button *button = &pdata->buttons[i];
|
||||
struct gpio_keys_button_data *bdata = &bdev->data[i];
|
||||
unsigned int type = button->type ?: EV_KEY;
|
||||
|
||||
if (button->wakeup) {
|
||||
dev_err(dev, DRV_NAME " does not support wakeup\n");
|
||||
fwnode_handle_put(child);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Legacy GPIO number so request the GPIO here and
|
||||
* convert it to descriptor.
|
||||
*/
|
||||
if (!button->gpiod && gpio_is_valid(button->gpio)) {
|
||||
if (!dev_get_platdata(dev)) {
|
||||
/* No legacy static platform data */
|
||||
child = device_get_next_child_node(dev, child);
|
||||
if (!child) {
|
||||
dev_err(dev, "missing child device node\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bdata->gpiod = devm_get_gpiod_from_child(dev, NULL,
|
||||
child);
|
||||
if (IS_ERR(bdata->gpiod)) {
|
||||
error = PTR_ERR(bdata->gpiod);
|
||||
if (error != -EPROBE_DEFER)
|
||||
dev_err(dev,
|
||||
"failed to get gpio: %d\n",
|
||||
error);
|
||||
fwnode_handle_put(child);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = gpiod_direction_input(bdata->gpiod);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to configure GPIO %d as input: %d\n",
|
||||
desc_to_gpio(bdata->gpiod), error);
|
||||
fwnode_handle_put(child);
|
||||
return error;
|
||||
}
|
||||
} else if (gpio_is_valid(button->gpio)) {
|
||||
/*
|
||||
* Legacy GPIO number so request the GPIO here and
|
||||
* convert it to descriptor.
|
||||
*/
|
||||
unsigned flags = GPIOF_IN;
|
||||
|
||||
if (button->active_low)
|
||||
@@ -322,18 +335,21 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
|
||||
error = devm_gpio_request_one(&pdev->dev, button->gpio,
|
||||
flags, button->desc ? : DRV_NAME);
|
||||
if (error) {
|
||||
dev_err(dev, "unable to claim gpio %u, err=%d\n",
|
||||
dev_err(dev,
|
||||
"unable to claim gpio %u, err=%d\n",
|
||||
button->gpio, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
button->gpiod = gpio_to_desc(button->gpio);
|
||||
bdata->gpiod = gpio_to_desc(button->gpio);
|
||||
if (!bdata->gpiod) {
|
||||
dev_err(dev,
|
||||
"unable to convert gpio %u to descriptor\n",
|
||||
button->gpio);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ERR(button->gpiod))
|
||||
return PTR_ERR(button->gpiod);
|
||||
|
||||
bdata->can_sleep = gpiod_cansleep(button->gpiod);
|
||||
bdata->last_state = -1;
|
||||
bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
|
||||
pdata->poll_interval);
|
||||
@@ -344,6 +360,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
|
||||
button->code);
|
||||
}
|
||||
|
||||
fwnode_handle_put(child);
|
||||
|
||||
bdev->poll_dev = poll_dev;
|
||||
bdev->dev = dev;
|
||||
bdev->pdata = pdata;
|
||||
|
||||
@@ -182,7 +182,7 @@ static int lpc32xx_kscan_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0 || irq >= NR_IRQS) {
|
||||
if (irq < 0) {
|
||||
dev_err(&pdev->dev, "failed to get platform irq\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
|
||||
error = of_property_read_u32(np, "marvell,debounce-interval",
|
||||
&pdata->debounce_interval);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to parse debpunce-interval\n");
|
||||
dev_err(dev, "failed to parse debounce-interval\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,11 +164,18 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
|
||||
int error, col, row;
|
||||
u8 reg, state, code;
|
||||
|
||||
/* Initial read of the key event FIFO */
|
||||
error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®);
|
||||
do {
|
||||
error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®);
|
||||
if (error < 0) {
|
||||
dev_err(&keypad_data->client->dev,
|
||||
"unable to read REG_KEY_EVENT_A\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Assume that key code 0 signifies empty FIFO */
|
||||
if (reg <= 0)
|
||||
break;
|
||||
|
||||
/* Assume that key code 0 signifies empty FIFO */
|
||||
while (error >= 0 && reg > 0) {
|
||||
state = reg & KEY_EVENT_VALUE;
|
||||
code = reg & KEY_EVENT_CODE;
|
||||
|
||||
@@ -184,11 +191,7 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
|
||||
|
||||
/* Read for next loop */
|
||||
error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®);
|
||||
}
|
||||
|
||||
if (error < 0)
|
||||
dev_err(&keypad_data->client->dev,
|
||||
"unable to read REG_KEY_EVENT_A\n");
|
||||
} while (1);
|
||||
|
||||
input_sync(input);
|
||||
}
|
||||
|
||||
@@ -625,11 +625,12 @@ config INPUT_DA9055_ONKEY
|
||||
will be called da9055_onkey.
|
||||
|
||||
config INPUT_DA9063_ONKEY
|
||||
tristate "Dialog DA9062/63 OnKey"
|
||||
tristate "Dialog DA9063/62/61 OnKey"
|
||||
depends on MFD_DA9063 || MFD_DA9062
|
||||
help
|
||||
Support the ONKEY of Dialog DA9063 and DA9062 Power Management ICs
|
||||
as an input device capable of reporting the power button status.
|
||||
Support the ONKEY of Dialog DA9063, DA9062 and DA9061 Power
|
||||
Management ICs as an input device capable of reporting the
|
||||
power button status.
|
||||
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called da9063_onkey.
|
||||
|
||||
@@ -538,8 +538,13 @@ static int bma150_probe(struct i2c_client *client,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note if the IIO CONFIG_BMA180 driver is enabled we want to fail
|
||||
* the probe for the bma180 as the iio driver is preferred.
|
||||
*/
|
||||
chip_id = i2c_smbus_read_byte_data(client, BMA150_CHIP_ID_REG);
|
||||
if (chip_id != BMA150_CHIP_ID && chip_id != BMA180_CHIP_ID) {
|
||||
if (chip_id != BMA150_CHIP_ID &&
|
||||
(IS_ENABLED(CONFIG_BMA180) || chip_id != BMA180_CHIP_ID)) {
|
||||
dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -643,7 +648,9 @@ static UNIVERSAL_DEV_PM_OPS(bma150_pm, bma150_suspend, bma150_resume, NULL);
|
||||
|
||||
static const struct i2c_device_id bma150_id[] = {
|
||||
{ "bma150", 0 },
|
||||
#if !IS_ENABLED(CONFIG_BMA180)
|
||||
{ "bma180", 0 },
|
||||
#endif
|
||||
{ "smb380", 0 },
|
||||
{ "bma023", 0 },
|
||||
{ }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* OnKey device driver for DA9063 and DA9062 PMICs
|
||||
* OnKey device driver for DA9063, DA9062 and DA9061 PMICs
|
||||
* Copyright (C) 2015 Dialog Semiconductor Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -87,6 +87,7 @@ static const struct of_device_id da9063_compatible_reg_id_table[] = {
|
||||
{ .compatible = "dlg,da9062-onkey", .data = &da9062_regs },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, da9063_compatible_reg_id_table);
|
||||
|
||||
static void da9063_poll_on(struct work_struct *work)
|
||||
{
|
||||
@@ -149,13 +150,13 @@ static void da9063_poll_on(struct work_struct *work)
|
||||
* and then send shutdown command
|
||||
*/
|
||||
dev_dbg(&onkey->input->dev,
|
||||
"Sending SHUTDOWN to DA9063 ...\n");
|
||||
"Sending SHUTDOWN to PMIC ...\n");
|
||||
error = regmap_write(onkey->regmap,
|
||||
config->onkey_shutdown,
|
||||
config->onkey_shutdown_mask);
|
||||
if (error)
|
||||
dev_err(&onkey->input->dev,
|
||||
"Cannot SHUTDOWN DA9063: %d\n",
|
||||
"Cannot SHUTDOWN PMIC: %d\n",
|
||||
error);
|
||||
}
|
||||
}
|
||||
@@ -300,6 +301,6 @@ static struct platform_driver da9063_onkey_driver = {
|
||||
module_platform_driver(da9063_onkey_driver);
|
||||
|
||||
MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>");
|
||||
MODULE_DESCRIPTION("Onkey device driver for Dialog DA9063 and DA9062");
|
||||
MODULE_DESCRIPTION("Onkey device driver for Dialog DA9063, DA9062 and DA9061");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:" DA9063_DRVNAME_ONKEY);
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
@@ -27,7 +25,6 @@
|
||||
#include <linux/regulator/consumer.h>
|
||||
|
||||
#include <dt-bindings/input/ti-drv260x.h>
|
||||
#include <linux/platform_data/drv260x-pdata.h>
|
||||
|
||||
#define DRV260X_STATUS 0x0
|
||||
#define DRV260X_MODE 0x1
|
||||
@@ -468,90 +465,39 @@ static const struct regmap_config drv260x_regmap_config = {
|
||||
.cache_type = REGCACHE_NONE,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static int drv260x_parse_dt(struct device *dev,
|
||||
struct drv260x_data *haptics)
|
||||
{
|
||||
struct device_node *np = dev->of_node;
|
||||
unsigned int voltage;
|
||||
int error;
|
||||
|
||||
error = of_property_read_u32(np, "mode", &haptics->mode);
|
||||
if (error) {
|
||||
dev_err(dev, "%s: No entry for mode\n", __func__);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = of_property_read_u32(np, "library-sel", &haptics->library);
|
||||
if (error) {
|
||||
dev_err(dev, "%s: No entry for library selection\n",
|
||||
__func__);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = of_property_read_u32(np, "vib-rated-mv", &voltage);
|
||||
if (!error)
|
||||
haptics->rated_voltage = drv260x_calculate_voltage(voltage);
|
||||
|
||||
|
||||
error = of_property_read_u32(np, "vib-overdrive-mv", &voltage);
|
||||
if (!error)
|
||||
haptics->overdrive_voltage = drv260x_calculate_voltage(voltage);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int drv260x_parse_dt(struct device *dev,
|
||||
struct drv260x_data *haptics)
|
||||
{
|
||||
dev_err(dev, "no platform data defined\n");
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int drv260x_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
const struct drv260x_platform_data *pdata = dev_get_platdata(&client->dev);
|
||||
struct device *dev = &client->dev;
|
||||
struct drv260x_data *haptics;
|
||||
u32 voltage;
|
||||
int error;
|
||||
|
||||
haptics = devm_kzalloc(&client->dev, sizeof(*haptics), GFP_KERNEL);
|
||||
haptics = devm_kzalloc(dev, sizeof(*haptics), GFP_KERNEL);
|
||||
if (!haptics)
|
||||
return -ENOMEM;
|
||||
|
||||
haptics->rated_voltage = DRV260X_DEF_OD_CLAMP_VOLT;
|
||||
haptics->rated_voltage = DRV260X_DEF_RATED_VOLT;
|
||||
|
||||
if (pdata) {
|
||||
haptics->mode = pdata->mode;
|
||||
haptics->library = pdata->library_selection;
|
||||
if (pdata->vib_overdrive_voltage)
|
||||
haptics->overdrive_voltage = drv260x_calculate_voltage(pdata->vib_overdrive_voltage);
|
||||
if (pdata->vib_rated_voltage)
|
||||
haptics->rated_voltage = drv260x_calculate_voltage(pdata->vib_rated_voltage);
|
||||
} else if (client->dev.of_node) {
|
||||
error = drv260x_parse_dt(&client->dev, haptics);
|
||||
if (error)
|
||||
return error;
|
||||
} else {
|
||||
dev_err(&client->dev, "Platform data not set\n");
|
||||
return -ENODEV;
|
||||
error = device_property_read_u32(dev, "mode", &haptics->mode);
|
||||
if (error) {
|
||||
dev_err(dev, "Can't fetch 'mode' property: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (haptics->mode < DRV260X_LRA_MODE ||
|
||||
haptics->mode > DRV260X_ERM_MODE) {
|
||||
dev_err(&client->dev,
|
||||
"Vibrator mode is invalid: %i\n",
|
||||
haptics->mode);
|
||||
dev_err(dev, "Vibrator mode is invalid: %i\n", haptics->mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
error = device_property_read_u32(dev, "library-sel", &haptics->library);
|
||||
if (error) {
|
||||
dev_err(dev, "Can't fetch 'library-sel' property: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (haptics->library < DRV260X_LIB_EMPTY ||
|
||||
haptics->library > DRV260X_ERM_LIB_F) {
|
||||
dev_err(&client->dev,
|
||||
dev_err(dev,
|
||||
"Library value is invalid: %i\n", haptics->library);
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -559,40 +505,44 @@ static int drv260x_probe(struct i2c_client *client,
|
||||
if (haptics->mode == DRV260X_LRA_MODE &&
|
||||
haptics->library != DRV260X_LIB_EMPTY &&
|
||||
haptics->library != DRV260X_LIB_LRA) {
|
||||
dev_err(&client->dev,
|
||||
"LRA Mode with ERM Library mismatch\n");
|
||||
dev_err(dev, "LRA Mode with ERM Library mismatch\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (haptics->mode == DRV260X_ERM_MODE &&
|
||||
(haptics->library == DRV260X_LIB_EMPTY ||
|
||||
haptics->library == DRV260X_LIB_LRA)) {
|
||||
dev_err(&client->dev,
|
||||
"ERM Mode with LRA Library mismatch\n");
|
||||
dev_err(dev, "ERM Mode with LRA Library mismatch\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
haptics->regulator = devm_regulator_get(&client->dev, "vbat");
|
||||
error = device_property_read_u32(dev, "vib-rated-mv", &voltage);
|
||||
haptics->rated_voltage = error ? DRV260X_DEF_RATED_VOLT :
|
||||
drv260x_calculate_voltage(voltage);
|
||||
|
||||
error = device_property_read_u32(dev, "vib-overdrive-mv", &voltage);
|
||||
haptics->overdrive_voltage = error ? DRV260X_DEF_OD_CLAMP_VOLT :
|
||||
drv260x_calculate_voltage(voltage);
|
||||
|
||||
haptics->regulator = devm_regulator_get(dev, "vbat");
|
||||
if (IS_ERR(haptics->regulator)) {
|
||||
error = PTR_ERR(haptics->regulator);
|
||||
dev_err(&client->dev,
|
||||
"unable to get regulator, error: %d\n", error);
|
||||
dev_err(dev, "unable to get regulator, error: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
haptics->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
|
||||
haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable",
|
||||
GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(haptics->enable_gpio))
|
||||
return PTR_ERR(haptics->enable_gpio);
|
||||
|
||||
haptics->input_dev = devm_input_allocate_device(&client->dev);
|
||||
haptics->input_dev = devm_input_allocate_device(dev);
|
||||
if (!haptics->input_dev) {
|
||||
dev_err(&client->dev, "Failed to allocate input device\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
haptics->input_dev->name = "drv260x:haptics";
|
||||
haptics->input_dev->dev.parent = client->dev.parent;
|
||||
haptics->input_dev->close = drv260x_close;
|
||||
input_set_drvdata(haptics->input_dev, haptics);
|
||||
input_set_capability(haptics->input_dev, EV_FF, FF_RUMBLE);
|
||||
@@ -600,8 +550,7 @@ static int drv260x_probe(struct i2c_client *client,
|
||||
error = input_ff_create_memless(haptics->input_dev, NULL,
|
||||
drv260x_haptics_play);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "input_ff_create() failed: %d\n",
|
||||
error);
|
||||
dev_err(dev, "input_ff_create() failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -613,21 +562,19 @@ static int drv260x_probe(struct i2c_client *client,
|
||||
haptics->regmap = devm_regmap_init_i2c(client, &drv260x_regmap_config);
|
||||
if (IS_ERR(haptics->regmap)) {
|
||||
error = PTR_ERR(haptics->regmap);
|
||||
dev_err(&client->dev, "Failed to allocate register map: %d\n",
|
||||
error);
|
||||
dev_err(dev, "Failed to allocate register map: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = drv260x_init(haptics);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "Device init failed: %d\n", error);
|
||||
dev_err(dev, "Device init failed: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
error = input_register_device(haptics->input_dev);
|
||||
if (error) {
|
||||
dev_err(&client->dev, "couldn't register input device: %d\n",
|
||||
error);
|
||||
dev_err(dev, "couldn't register input device: %d\n", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,8 +125,8 @@ static void drv2665_close(struct input_dev *input)
|
||||
|
||||
cancel_work_sync(&haptics->work);
|
||||
|
||||
error = regmap_update_bits(haptics->regmap,
|
||||
DRV2665_CTRL_2, DRV2665_STANDBY, 1);
|
||||
error = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
|
||||
DRV2665_STANDBY, DRV2665_STANDBY);
|
||||
if (error)
|
||||
dev_err(&haptics->client->dev,
|
||||
"Failed to enter standby mode: %d\n", error);
|
||||
@@ -240,7 +240,7 @@ static int __maybe_unused drv2665_suspend(struct device *dev)
|
||||
|
||||
if (haptics->input_dev->users) {
|
||||
ret = regmap_update_bits(haptics->regmap, DRV2665_CTRL_2,
|
||||
DRV2665_STANDBY, 1);
|
||||
DRV2665_STANDBY, DRV2665_STANDBY);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to set standby mode\n");
|
||||
regulator_disable(haptics->regulator);
|
||||
|
||||
@@ -256,7 +256,7 @@ static void drv2667_close(struct input_dev *input)
|
||||
cancel_work_sync(&haptics->work);
|
||||
|
||||
error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
|
||||
DRV2667_STANDBY, 1);
|
||||
DRV2667_STANDBY, DRV2667_STANDBY);
|
||||
if (error)
|
||||
dev_err(&haptics->client->dev,
|
||||
"Failed to enter standby mode: %d\n", error);
|
||||
@@ -415,7 +415,7 @@ static int __maybe_unused drv2667_suspend(struct device *dev)
|
||||
|
||||
if (haptics->input_dev->users) {
|
||||
ret = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
|
||||
DRV2667_STANDBY, 1);
|
||||
DRV2667_STANDBY, DRV2667_STANDBY);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to set standby mode\n");
|
||||
regulator_disable(haptics->regulator);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/gpio_keys.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
/*
|
||||
@@ -92,7 +93,7 @@ soc_button_device_create(struct platform_device *pdev,
|
||||
continue;
|
||||
|
||||
gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
|
||||
if (gpio < 0)
|
||||
if (!gpio_is_valid(gpio))
|
||||
continue;
|
||||
|
||||
gpio_keys[n_buttons].type = info->event_type;
|
||||
@@ -166,6 +167,11 @@ static int soc_button_probe(struct platform_device *pdev)
|
||||
|
||||
button_info = (struct soc_button_info *)id->driver_data;
|
||||
|
||||
if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) {
|
||||
dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
+31
-25
@@ -1153,15 +1153,13 @@ static void alps_process_packet_v7(struct psmouse *psmouse)
|
||||
alps_process_touchpad_packet_v7(psmouse);
|
||||
}
|
||||
|
||||
static unsigned char alps_get_pkt_id_ss4_v2(unsigned char *byte)
|
||||
static enum SS4_PACKET_ID alps_get_pkt_id_ss4_v2(unsigned char *byte)
|
||||
{
|
||||
unsigned char pkt_id = SS4_PACKET_ID_IDLE;
|
||||
enum SS4_PACKET_ID pkt_id = SS4_PACKET_ID_IDLE;
|
||||
|
||||
switch (byte[3] & 0x30) {
|
||||
case 0x00:
|
||||
if (byte[0] == 0x18 && byte[1] == 0x10 && byte[2] == 0x00 &&
|
||||
(byte[3] & 0x88) == 0x08 && byte[4] == 0x10 &&
|
||||
byte[5] == 0x00) {
|
||||
if (SS4_IS_IDLE_V2(byte)) {
|
||||
pkt_id = SS4_PACKET_ID_IDLE;
|
||||
} else {
|
||||
pkt_id = SS4_PACKET_ID_ONE;
|
||||
@@ -1188,7 +1186,7 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
|
||||
unsigned char *p, struct psmouse *psmouse)
|
||||
{
|
||||
struct alps_data *priv = psmouse->private;
|
||||
unsigned char pkt_id;
|
||||
enum SS4_PACKET_ID pkt_id;
|
||||
unsigned int no_data_x, no_data_y;
|
||||
|
||||
pkt_id = alps_get_pkt_id_ss4_v2(p);
|
||||
@@ -1267,18 +1265,12 @@ static int alps_decode_ss4_v2(struct alps_fields *f,
|
||||
break;
|
||||
|
||||
case SS4_PACKET_ID_STICK:
|
||||
if (!(priv->flags & ALPS_DUALPOINT)) {
|
||||
psmouse_warn(psmouse,
|
||||
"Rejected trackstick packet from non DualPoint device");
|
||||
} else {
|
||||
int x = (s8)(((p[0] & 1) << 7) | (p[1] & 0x7f));
|
||||
int y = (s8)(((p[3] & 1) << 7) | (p[2] & 0x7f));
|
||||
int pressure = (s8)(p[4] & 0x7f);
|
||||
|
||||
input_report_rel(priv->dev2, REL_X, x);
|
||||
input_report_rel(priv->dev2, REL_Y, -y);
|
||||
input_report_abs(priv->dev2, ABS_PRESSURE, pressure);
|
||||
}
|
||||
/*
|
||||
* x, y, and pressure are decoded in
|
||||
* alps_process_packet_ss4_v2()
|
||||
*/
|
||||
f->first_mp = 0;
|
||||
f->is_mp = 0;
|
||||
break;
|
||||
|
||||
case SS4_PACKET_ID_IDLE:
|
||||
@@ -1346,6 +1338,27 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
|
||||
|
||||
priv->multi_packet = 0;
|
||||
|
||||
/* Report trackstick */
|
||||
if (alps_get_pkt_id_ss4_v2(packet) == SS4_PACKET_ID_STICK) {
|
||||
if (!(priv->flags & ALPS_DUALPOINT)) {
|
||||
psmouse_warn(psmouse,
|
||||
"Rejected trackstick packet from non DualPoint device");
|
||||
return;
|
||||
}
|
||||
|
||||
input_report_rel(dev2, REL_X, SS4_TS_X_V2(packet));
|
||||
input_report_rel(dev2, REL_Y, SS4_TS_Y_V2(packet));
|
||||
input_report_abs(dev2, ABS_PRESSURE, SS4_TS_Z_V2(packet));
|
||||
|
||||
input_report_key(dev2, BTN_LEFT, f->ts_left);
|
||||
input_report_key(dev2, BTN_RIGHT, f->ts_right);
|
||||
input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
|
||||
|
||||
input_sync(dev2);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Report touchpad */
|
||||
alps_report_mt_data(psmouse, (f->fingers <= 4) ? f->fingers : 4);
|
||||
|
||||
input_mt_report_finger_count(dev, f->fingers);
|
||||
@@ -1356,13 +1369,6 @@ static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
|
||||
|
||||
input_report_abs(dev, ABS_PRESSURE, f->pressure);
|
||||
input_sync(dev);
|
||||
|
||||
if (priv->flags & ALPS_DUALPOINT) {
|
||||
input_report_key(dev2, BTN_LEFT, f->ts_left);
|
||||
input_report_key(dev2, BTN_RIGHT, f->ts_right);
|
||||
input_report_key(dev2, BTN_MIDDLE, f->ts_middle);
|
||||
input_sync(dev2);
|
||||
}
|
||||
}
|
||||
|
||||
static bool alps_is_valid_package_ss4_v2(struct psmouse *psmouse)
|
||||
|
||||
@@ -54,7 +54,15 @@ enum SS4_PACKET_ID {
|
||||
|
||||
#define SS4_MASK_NORMAL_BUTTONS 0x07
|
||||
|
||||
#define SS4_1F_X_V2(_b) ((_b[0] & 0x0007) | \
|
||||
#define SS4_IS_IDLE_V2(_b) (((_b[0]) == 0x18) && \
|
||||
((_b[1]) == 0x10) && \
|
||||
((_b[2]) == 0x00) && \
|
||||
((_b[3] & 0x88) == 0x08) && \
|
||||
((_b[4]) == 0x10) && \
|
||||
((_b[5]) == 0x00) \
|
||||
)
|
||||
|
||||
#define SS4_1F_X_V2(_b) (((_b[0]) & 0x0007) | \
|
||||
((_b[1] << 3) & 0x0078) | \
|
||||
((_b[1] << 2) & 0x0380) | \
|
||||
((_b[2] << 5) & 0x1C00) \
|
||||
@@ -101,6 +109,18 @@ enum SS4_PACKET_ID {
|
||||
#define SS4_IS_MF_CONTINUE(_b) ((_b[2] & 0x10) == 0x10)
|
||||
#define SS4_IS_5F_DETECTED(_b) ((_b[2] & 0x10) == 0x10)
|
||||
|
||||
#define SS4_TS_X_V2(_b) (s8)( \
|
||||
((_b[0] & 0x01) << 7) | \
|
||||
(_b[1] & 0x7F) \
|
||||
)
|
||||
|
||||
#define SS4_TS_Y_V2(_b) (s8)( \
|
||||
((_b[3] & 0x01) << 7) | \
|
||||
(_b[2] & 0x7F) \
|
||||
)
|
||||
|
||||
#define SS4_TS_Z_V2(_b) (s8)(_b[4] & 0x7F)
|
||||
|
||||
|
||||
#define SS4_MFPACKET_NO_AX 8160 /* X-Coordinate value */
|
||||
#define SS4_MFPACKET_NO_AY 4080 /* Y-Coordinate value */
|
||||
@@ -146,7 +166,7 @@ struct alps_protocol_info {
|
||||
* (aka command mode response) identifies the firmware minor version. This
|
||||
* can be used to distinguish different hardware models which are not
|
||||
* uniquely identifiable through their E7 responses.
|
||||
* @protocol_info: information about protcol used by the device.
|
||||
* @protocol_info: information about protocol used by the device.
|
||||
*
|
||||
* Many (but not all) ALPS touchpads can be identified by looking at the
|
||||
* values returned in the "E7 report" and/or the "EC report." This table
|
||||
|
||||
@@ -1093,19 +1093,18 @@ static int elan_probe(struct i2c_client *client,
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
dev_info(&client->dev,
|
||||
"Elan Touchpad: Module ID: 0x%04x, Firmware: 0x%04x, Sample: 0x%04x, IAP: 0x%04x\n",
|
||||
data->product_id,
|
||||
data->fw_version,
|
||||
data->sm_version,
|
||||
data->iap_version);
|
||||
|
||||
dev_dbg(&client->dev,
|
||||
"Elan Touchpad Information:\n"
|
||||
" Module product ID: 0x%04x\n"
|
||||
" Firmware Version: 0x%04x\n"
|
||||
" Sample Version: 0x%04x\n"
|
||||
" IAP Version: 0x%04x\n"
|
||||
"Elan Touchpad Extra Information:\n"
|
||||
" Max ABS X,Y: %d,%d\n"
|
||||
" Width X,Y: %d,%d\n"
|
||||
" Resolution X,Y: %d,%d (dots/mm)\n",
|
||||
data->product_id,
|
||||
data->fw_version,
|
||||
data->sm_version,
|
||||
data->iap_version,
|
||||
data->max_x, data->max_y,
|
||||
data->width_x, data->width_y,
|
||||
data->x_res, data->y_res);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user