aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-01-02 01:49:29 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-01-02 01:54:42 -0500
commit3c8a23c29d30eec7a20fbb3e47e5346d9ada687b (patch)
treebc0918b6e71e8c50118b9c7637e72fdafbd93687
parentb3495cecb24c8e38e1b0c569c69c983b6a2d6d9c (diff)
Input: gpio_tilt - delete driver
This driver was merged in 2011 as a tool for detecting the orientation of a screen. The device driver assumes board file setup using the platform data from <linux/input/gpio_tilt.h>. But no boards in the kernel tree defines this platform data. As I am faced with refactoring drivers to use GPIO descriptors and pass decriptor tables from boards, or use the device tree device drivers like these creates a serious problem: I cannot fix them and cannot test them, not even compile-test them with a system actually using it (no in-tree boardfile). I suggest to delete this driver and rewrite it using device tree if it is still in use on actively maintained systems. I can also offer to rewrite it out of the blue using device tree if someone promise to test it and help me iterate it. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Heiko Stuebner <heiko@sntech.de> Patchwork-Id: 10133609 Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--Documentation/gpio/drivers-on-gpio.txt5
-rw-r--r--Documentation/input/devices/gpio-tilt.rst103
-rw-r--r--drivers/input/misc/Kconfig14
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/gpio_tilt_polled.c210
-rw-r--r--include/linux/input/gpio_tilt.h74
6 files changed, 0 insertions, 407 deletions
diff --git a/Documentation/gpio/drivers-on-gpio.txt b/Documentation/gpio/drivers-on-gpio.txt
index 9a78d385b92e..a2ccbab12eb7 100644
--- a/Documentation/gpio/drivers-on-gpio.txt
+++ b/Documentation/gpio/drivers-on-gpio.txt
@@ -28,11 +28,6 @@ hardware descriptions such as device tree or ACPI:
28- gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from 28- gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from
29 an external speaker connected to a GPIO line. 29 an external speaker connected to a GPIO line.
30 30
31- gpio-tilt-polled: drivers/input/misc/gpio_tilt_polled.c provides tilt
32 detection switches using GPIO, which is useful for your homebrewn pinball
33 machine if for nothing else. It can detect different tilt angles of the
34 monitored object.
35
36- extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an 31- extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an
37 external connector status, such as a headset line for an audio driver or an 32 external connector status, such as a headset line for an audio driver or an
38 HDMI connector. It will provide a better userspace sysfs interface than GPIO. 33 HDMI connector. It will provide a better userspace sysfs interface than GPIO.
diff --git a/Documentation/input/devices/gpio-tilt.rst b/Documentation/input/devices/gpio-tilt.rst
deleted file mode 100644
index fa6e64570aa7..000000000000
--- a/Documentation/input/devices/gpio-tilt.rst
+++ /dev/null
@@ -1,103 +0,0 @@
1Driver for tilt-switches connected via GPIOs
2============================================
3
4Generic driver to read data from tilt switches connected via gpios.
5Orientation can be provided by one or more than one tilt switches,
6i.e. each tilt switch providing one axis, and the number of axes
7is also not limited.
8
9
10Data structures
11---------------
12
13The array of struct gpio in the gpios field is used to list the gpios
14that represent the current tilt state.
15
16The array of struct gpio_tilt_axis describes the axes that are reported
17to the input system. The values set therein are used for the
18input_set_abs_params calls needed to init the axes.
19
20The array of struct gpio_tilt_state maps gpio states to the corresponding
21values to report. The gpio state is represented as a bitfield where the
22bit-index corresponds to the index of the gpio in the struct gpio array.
23In the same manner the values stored in the axes array correspond to
24the elements of the gpio_tilt_axis-array.
25
26
27Example
28-------
29
30Example configuration for a single TS1003 tilt switch that rotates around
31one axis in 4 steps and emits the current tilt via two GPIOs::
32
33 static int sg060_tilt_enable(struct device *dev) {
34 /* code to enable the sensors */
35 };
36
37 static void sg060_tilt_disable(struct device *dev) {
38 /* code to disable the sensors */
39 };
40
41 static struct gpio sg060_tilt_gpios[] = {
42 { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" },
43 { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" },
44 };
45
46 static struct gpio_tilt_state sg060_tilt_states[] = {
47 {
48 .gpios = (0 << 1) | (0 << 0),
49 .axes = (int[]) {
50 0,
51 },
52 }, {
53 .gpios = (0 << 1) | (1 << 0),
54 .axes = (int[]) {
55 1, /* 90 degrees */
56 },
57 }, {
58 .gpios = (1 << 1) | (1 << 0),
59 .axes = (int[]) {
60 2, /* 180 degrees */
61 },
62 }, {
63 .gpios = (1 << 1) | (0 << 0),
64 .axes = (int[]) {
65 3, /* 270 degrees */
66 },
67 },
68 };
69
70 static struct gpio_tilt_axis sg060_tilt_axes[] = {
71 {
72 .axis = ABS_RY,
73 .min = 0,
74 .max = 3,
75 .fuzz = 0,
76 .flat = 0,
77 },
78 };
79
80 static struct gpio_tilt_platform_data sg060_tilt_pdata= {
81 .gpios = sg060_tilt_gpios,
82 .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios),
83
84 .axes = sg060_tilt_axes,
85 .nr_axes = ARRAY_SIZE(sg060_tilt_axes),
86
87 .states = sg060_tilt_states,
88 .nr_states = ARRAY_SIZE(sg060_tilt_states),
89
90 .debounce_interval = 100,
91
92 .poll_interval = 1000,
93 .enable = sg060_tilt_enable,
94 .disable = sg060_tilt_disable,
95 };
96
97 static struct platform_device sg060_device_tilt = {
98 .name = "gpio-tilt-polled",
99 .id = -1,
100 .dev = {
101 .platform_data = &sg060_tilt_pdata,
102 },
103 };
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 9f082a388388..4791e73839d9 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -268,20 +268,6 @@ config INPUT_GPIO_BEEPER
268 To compile this driver as a module, choose M here: the 268 To compile this driver as a module, choose M here: the
269 module will be called gpio-beeper. 269 module will be called gpio-beeper.
270 270
271config INPUT_GPIO_TILT_POLLED
272 tristate "Polled GPIO tilt switch"
273 depends on GPIOLIB || COMPILE_TEST
274 select INPUT_POLLDEV
275 help
276 This driver implements support for tilt switches connected
277 to GPIO pins that are not capable of generating interrupts.
278
279 The list of gpios to use and the mapping of their states
280 to specific angles is done via platform data.
281
282 To compile this driver as a module, choose M here: the
283 module will be called gpio_tilt_polled.
284
285config INPUT_GPIO_DECODER 271config INPUT_GPIO_DECODER
286 tristate "Polled GPIO Decoder Input driver" 272 tristate "Polled GPIO Decoder Input driver"
287 depends on GPIOLIB || COMPILE_TEST 273 depends on GPIOLIB || COMPILE_TEST
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 4b6118d313fe..a8f61af865aa 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -36,7 +36,6 @@ obj-$(CONFIG_INPUT_DRV2665_HAPTICS) += drv2665.o
36obj-$(CONFIG_INPUT_DRV2667_HAPTICS) += drv2667.o 36obj-$(CONFIG_INPUT_DRV2667_HAPTICS) += drv2667.o
37obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o 37obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o
38obj-$(CONFIG_INPUT_GPIO_BEEPER) += gpio-beeper.o 38obj-$(CONFIG_INPUT_GPIO_BEEPER) += gpio-beeper.o
39obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o
40obj-$(CONFIG_INPUT_GPIO_DECODER) += gpio_decoder.o 39obj-$(CONFIG_INPUT_GPIO_DECODER) += gpio_decoder.o
41obj-$(CONFIG_INPUT_HISI_POWERKEY) += hisi_powerkey.o 40obj-$(CONFIG_INPUT_HISI_POWERKEY) += hisi_powerkey.o
42obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 41obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
diff --git a/drivers/input/misc/gpio_tilt_polled.c b/drivers/input/misc/gpio_tilt_polled.c
deleted file mode 100644
index 6e217a45e39a..000000000000
--- a/drivers/input/misc/gpio_tilt_polled.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/*
2 * Driver for tilt switches connected via GPIO lines
3 * not capable of generating interrupts
4 *
5 * Copyright (C) 2011 Heiko Stuebner <heiko@sntech.de>
6 *
7 * based on: drivers/input/keyboard/gpio_keys_polled.c
8 *
9 * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org>
10 * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/slab.h>
20#include <linux/input.h>
21#include <linux/input-polldev.h>
22#include <linux/ioport.h>
23#include <linux/platform_device.h>
24#include <linux/gpio.h>
25#include <linux/input/gpio_tilt.h>
26
27#define DRV_NAME "gpio-tilt-polled"
28
29struct gpio_tilt_polled_dev {
30 struct input_polled_dev *poll_dev;
31 struct device *dev;
32 const struct gpio_tilt_platform_data *pdata;
33
34 int last_state;
35
36 int threshold;
37 int count;
38};
39
40static void gpio_tilt_polled_poll(struct input_polled_dev *dev)
41{
42 struct gpio_tilt_polled_dev *tdev = dev->private;
43 const struct gpio_tilt_platform_data *pdata = tdev->pdata;
44 struct input_dev *input = dev->input;
45 struct gpio_tilt_state *tilt_state = NULL;
46 int state, i;
47
48 if (tdev->count < tdev->threshold) {
49 tdev->count++;
50 } else {
51 state = 0;
52 for (i = 0; i < pdata->nr_gpios; i++)
53 state |= (!!gpio_get_value(pdata->gpios[i].gpio) << i);
54
55 if (state != tdev->last_state) {
56 for (i = 0; i < pdata->nr_states; i++)
57 if (pdata->states[i].gpios == state)
58 tilt_state = &pdata->states[i];
59
60 if (tilt_state) {
61 for (i = 0; i < pdata->nr_axes; i++)
62 input_report_abs(input,
63 pdata->axes[i].axis,
64 tilt_state->axes[i]);
65
66 input_sync(input);
67 }
68
69 tdev->count = 0;
70 tdev->last_state = state;
71 }
72 }
73}
74
75static void gpio_tilt_polled_open(struct input_polled_dev *dev)
76{
77 struct gpio_tilt_polled_dev *tdev = dev->private;
78 const struct gpio_tilt_platform_data *pdata = tdev->pdata;
79
80 if (pdata->enable)
81 pdata->enable(tdev->dev);
82
83 /* report initial state of the axes */
84 tdev->last_state = -1;
85 tdev->count = tdev->threshold;
86 gpio_tilt_polled_poll(tdev->poll_dev);
87}
88
89static void gpio_tilt_polled_close(struct input_polled_dev *dev)
90{
91 struct gpio_tilt_polled_dev *tdev = dev->private;
92 const struct gpio_tilt_platform_data *pdata = tdev->pdata;
93
94 if (pdata->disable)
95 pdata->disable(tdev->dev);
96}
97
98static int gpio_tilt_polled_probe(struct platform_device *pdev)
99{
100 const struct gpio_tilt_platform_data *pdata =
101 dev_get_platdata(&pdev->dev);
102 struct device *dev = &pdev->dev;
103 struct gpio_tilt_polled_dev *tdev;
104 struct input_polled_dev *poll_dev;
105 struct input_dev *input;
106 int error, i;
107
108 if (!pdata || !pdata->poll_interval)
109 return -EINVAL;
110
111 tdev = kzalloc(sizeof(struct gpio_tilt_polled_dev), GFP_KERNEL);
112 if (!tdev) {
113 dev_err(dev, "no memory for private data\n");
114 return -ENOMEM;
115 }
116
117 error = gpio_request_array(pdata->gpios, pdata->nr_gpios);
118 if (error) {
119 dev_err(dev,
120 "Could not request tilt GPIOs: %d\n", error);
121 goto err_free_tdev;
122 }
123
124 poll_dev = input_allocate_polled_device();
125 if (!poll_dev) {
126 dev_err(dev, "no memory for polled device\n");
127 error = -ENOMEM;
128 goto err_free_gpios;
129 }
130
131 poll_dev->private = tdev;
132 poll_dev->poll = gpio_tilt_polled_poll;
133 poll_dev->poll_interval = pdata->poll_interval;
134 poll_dev->open = gpio_tilt_polled_open;
135 poll_dev->close = gpio_tilt_polled_close;
136
137 input = poll_dev->input;
138
139 input->name = pdev->name;
140 input->phys = DRV_NAME"/input0";
141 input->dev.parent = dev;
142
143 input->id.bustype = BUS_HOST;
144 input->id.vendor = 0x0001;
145 input->id.product = 0x0001;
146 input->id.version = 0x0100;
147
148 __set_bit(EV_ABS, input->evbit);
149 for (i = 0; i < pdata->nr_axes; i++)
150 input_set_abs_params(input, pdata->axes[i].axis,
151 pdata->axes[i].min, pdata->axes[i].max,
152 pdata->axes[i].fuzz, pdata->axes[i].flat);
153
154 tdev->threshold = DIV_ROUND_UP(pdata->debounce_interval,
155 pdata->poll_interval);
156
157 tdev->poll_dev = poll_dev;
158 tdev->dev = dev;
159 tdev->pdata = pdata;
160
161 error = input_register_polled_device(poll_dev);
162 if (error) {
163 dev_err(dev, "unable to register polled device, err=%d\n",
164 error);
165 goto err_free_polldev;
166 }
167
168 platform_set_drvdata(pdev, tdev);
169
170 return 0;
171
172err_free_polldev:
173 input_free_polled_device(poll_dev);
174err_free_gpios:
175 gpio_free_array(pdata->gpios, pdata->nr_gpios);
176err_free_tdev:
177 kfree(tdev);
178
179 return error;
180}
181
182static int gpio_tilt_polled_remove(struct platform_device *pdev)
183{
184 struct gpio_tilt_polled_dev *tdev = platform_get_drvdata(pdev);
185 const struct gpio_tilt_platform_data *pdata = tdev->pdata;
186
187 input_unregister_polled_device(tdev->poll_dev);
188 input_free_polled_device(tdev->poll_dev);
189
190 gpio_free_array(pdata->gpios, pdata->nr_gpios);
191
192 kfree(tdev);
193
194 return 0;
195}
196
197static struct platform_driver gpio_tilt_polled_driver = {
198 .probe = gpio_tilt_polled_probe,
199 .remove = gpio_tilt_polled_remove,
200 .driver = {
201 .name = DRV_NAME,
202 },
203};
204
205module_platform_driver(gpio_tilt_polled_driver);
206
207MODULE_LICENSE("GPL v2");
208MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
209MODULE_DESCRIPTION("Polled GPIO tilt driver");
210MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/include/linux/input/gpio_tilt.h b/include/linux/input/gpio_tilt.h
deleted file mode 100644
index f9d932476a80..000000000000
--- a/include/linux/input/gpio_tilt.h
+++ /dev/null
@@ -1,74 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _INPUT_GPIO_TILT_H
3#define _INPUT_GPIO_TILT_H
4
5/**
6 * struct gpio_tilt_axis - Axis used by the tilt switch
7 * @axis: Constant describing the axis, e.g. ABS_X
8 * @min: minimum value for abs_param
9 * @max: maximum value for abs_param
10 * @fuzz: fuzz value for abs_param
11 * @flat: flat value for abs_param
12 */
13struct gpio_tilt_axis {
14 int axis;
15 int min;
16 int max;
17 int fuzz;
18 int flat;
19};
20
21/**
22 * struct gpio_tilt_state - state description
23 * @gpios: bitfield of gpio target-states for the value
24 * @axes: array containing the axes settings for the gpio state
25 * The array indizes must correspond to the axes defined
26 * in platform_data
27 *
28 * This structure describes a supported axis settings
29 * and the necessary gpio-state which represent it.
30 *
31 * The n-th bit in the bitfield describes the state of the n-th GPIO
32 * from the gpios-array defined in gpio_regulator_config below.
33 */
34struct gpio_tilt_state {
35 int gpios;
36 int *axes;
37};
38
39/**
40 * struct gpio_tilt_platform_data
41 * @gpios: Array containing the gpios determining the tilt state
42 * @nr_gpios: Number of gpios
43 * @axes: Array of gpio_tilt_axis descriptions
44 * @nr_axes: Number of axes
45 * @states: Array of gpio_tilt_state entries describing
46 * the gpio state for specific tilts
47 * @nr_states: Number of states available
48 * @debounce_interval: debounce ticks interval in msecs
49 * @poll_interval: polling interval in msecs - for polling driver only
50 * @enable: callback to enable the tilt switch
51 * @disable: callback to disable the tilt switch
52 *
53 * This structure contains gpio-tilt-switch configuration
54 * information that must be passed by platform code to the
55 * gpio-tilt input driver.
56 */
57struct gpio_tilt_platform_data {
58 struct gpio *gpios;
59 int nr_gpios;
60
61 struct gpio_tilt_axis *axes;
62 int nr_axes;
63
64 struct gpio_tilt_state *states;
65 int nr_states;
66
67 int debounce_interval;
68
69 unsigned int poll_interval;
70 int (*enable)(struct device *dev);
71 void (*disable)(struct device *dev);
72};
73
74#endif