diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-21 15:59:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-21 15:59:04 -0500 |
commit | 1acd2de5facd7fbea499aea64a3a3d0ec7bb9b51 (patch) | |
tree | 21e5aed9925f3171d2c8c472193b1a5b635d8fdd /drivers/input/misc | |
parent | b5ccb078c806f4804aaf85bb59faa9b6fedf85a7 (diff) | |
parent | 4c971aa78314253cce914ed29e3d90df3326d646 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull more input updates from Dmitry Torokhov:
"The second round of updates for the input subsystem.
Updates to ALPS an bfin_roraty drivers and a couple oother fixups"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: psmouse - use IS_ENABLED instead of homegrown code
Input: bfin_rotary - introduce open and close methods
Input: bfin_rotary - convert to use managed resources
Input: bfin_rotary - use generic IO functions
Input: bfin_rotary - move pin lists into into platform data
Input: bfin_rotary - move platform header to linux/platform_data
Input: bfin_rotary - mark suspend and resume code as __maybe_unused
Input: bfin_rotary - fix potential oops in interrupt handler
Input: ALPS - move v7 packet info to Documentation and v6 packet info
Input: ALPS - fix confusing comment in protocol data
Input: ALPS - do not mix trackstick and external PS/2 mouse data
Input: ALPS - fix trackstick detection on some Dell Latitudes
Input: ALPS - consolidate setting protocol parameters
Input: ALPS - split protocol data from model info
Input: ALPS - make Rushmore a separate protocol
Input: ALPS - renumber protocol numbers
Input: adi - remove an unnecessary check
Input: pxa27x_keypad - remove an unneeded NULL check
Input: soc_button_array - use "Windows" key for "Home"
Diffstat (limited to 'drivers/input/misc')
-rw-r--r-- | drivers/input/misc/bfin_rotary.c | 208 | ||||
-rw-r--r-- | drivers/input/misc/soc_button_array.c | 2 |
2 files changed, 118 insertions, 92 deletions
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c index 3f4351579372..a0fc18fdfc0c 100644 --- a/drivers/input/misc/bfin_rotary.c +++ b/drivers/input/misc/bfin_rotary.c | |||
@@ -7,29 +7,37 @@ | |||
7 | 7 | ||
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/interrupt.h> | 9 | #include <linux/interrupt.h> |
10 | #include <linux/io.h> | ||
10 | #include <linux/irq.h> | 11 | #include <linux/irq.h> |
11 | #include <linux/pm.h> | 12 | #include <linux/pm.h> |
12 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
13 | #include <linux/input.h> | 14 | #include <linux/input.h> |
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/platform_data/bfin_rotary.h> | ||
15 | 17 | ||
16 | #include <asm/portmux.h> | 18 | #include <asm/portmux.h> |
17 | #include <asm/bfin_rotary.h> | ||
18 | 19 | ||
19 | static const u16 per_cnt[] = { | 20 | #define CNT_CONFIG_OFF 0 /* CNT Config Offset */ |
20 | P_CNT_CUD, | 21 | #define CNT_IMASK_OFF 4 /* CNT Interrupt Mask Offset */ |
21 | P_CNT_CDG, | 22 | #define CNT_STATUS_OFF 8 /* CNT Status Offset */ |
22 | P_CNT_CZM, | 23 | #define CNT_COMMAND_OFF 12 /* CNT Command Offset */ |
23 | 0 | 24 | #define CNT_DEBOUNCE_OFF 16 /* CNT Debounce Offset */ |
24 | }; | 25 | #define CNT_COUNTER_OFF 20 /* CNT Counter Offset */ |
26 | #define CNT_MAX_OFF 24 /* CNT Maximum Count Offset */ | ||
27 | #define CNT_MIN_OFF 28 /* CNT Minimum Count Offset */ | ||
25 | 28 | ||
26 | struct bfin_rot { | 29 | struct bfin_rot { |
27 | struct input_dev *input; | 30 | struct input_dev *input; |
31 | void __iomem *base; | ||
28 | int irq; | 32 | int irq; |
29 | unsigned int up_key; | 33 | unsigned int up_key; |
30 | unsigned int down_key; | 34 | unsigned int down_key; |
31 | unsigned int button_key; | 35 | unsigned int button_key; |
32 | unsigned int rel_code; | 36 | unsigned int rel_code; |
37 | |||
38 | unsigned short mode; | ||
39 | unsigned short debounce; | ||
40 | |||
33 | unsigned short cnt_config; | 41 | unsigned short cnt_config; |
34 | unsigned short cnt_imask; | 42 | unsigned short cnt_imask; |
35 | unsigned short cnt_debounce; | 43 | unsigned short cnt_debounce; |
@@ -59,18 +67,17 @@ static void report_rotary_event(struct bfin_rot *rotary, int delta) | |||
59 | 67 | ||
60 | static irqreturn_t bfin_rotary_isr(int irq, void *dev_id) | 68 | static irqreturn_t bfin_rotary_isr(int irq, void *dev_id) |
61 | { | 69 | { |
62 | struct platform_device *pdev = dev_id; | 70 | struct bfin_rot *rotary = dev_id; |
63 | struct bfin_rot *rotary = platform_get_drvdata(pdev); | ||
64 | int delta; | 71 | int delta; |
65 | 72 | ||
66 | switch (bfin_read_CNT_STATUS()) { | 73 | switch (readw(rotary->base + CNT_STATUS_OFF)) { |
67 | 74 | ||
68 | case ICII: | 75 | case ICII: |
69 | break; | 76 | break; |
70 | 77 | ||
71 | case UCII: | 78 | case UCII: |
72 | case DCII: | 79 | case DCII: |
73 | delta = bfin_read_CNT_COUNTER(); | 80 | delta = readl(rotary->base + CNT_COUNTER_OFF); |
74 | if (delta) | 81 | if (delta) |
75 | report_rotary_event(rotary, delta); | 82 | report_rotary_event(rotary, delta); |
76 | break; | 83 | break; |
@@ -83,16 +90,52 @@ static irqreturn_t bfin_rotary_isr(int irq, void *dev_id) | |||
83 | break; | 90 | break; |
84 | } | 91 | } |
85 | 92 | ||
86 | bfin_write_CNT_COMMAND(W1LCNT_ZERO); /* Clear COUNTER */ | 93 | writew(W1LCNT_ZERO, rotary->base + CNT_COMMAND_OFF); /* Clear COUNTER */ |
87 | bfin_write_CNT_STATUS(-1); /* Clear STATUS */ | 94 | writew(-1, rotary->base + CNT_STATUS_OFF); /* Clear STATUS */ |
88 | 95 | ||
89 | return IRQ_HANDLED; | 96 | return IRQ_HANDLED; |
90 | } | 97 | } |
91 | 98 | ||
99 | static int bfin_rotary_open(struct input_dev *input) | ||
100 | { | ||
101 | struct bfin_rot *rotary = input_get_drvdata(input); | ||
102 | unsigned short val; | ||
103 | |||
104 | if (rotary->mode & ROT_DEBE) | ||
105 | writew(rotary->debounce & DPRESCALE, | ||
106 | rotary->base + CNT_DEBOUNCE_OFF); | ||
107 | |||
108 | writew(rotary->mode & ~CNTE, rotary->base + CNT_CONFIG_OFF); | ||
109 | |||
110 | val = UCIE | DCIE; | ||
111 | if (rotary->button_key) | ||
112 | val |= CZMIE; | ||
113 | writew(val, rotary->base + CNT_IMASK_OFF); | ||
114 | |||
115 | writew(rotary->mode | CNTE, rotary->base + CNT_CONFIG_OFF); | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static void bfin_rotary_close(struct input_dev *input) | ||
121 | { | ||
122 | struct bfin_rot *rotary = input_get_drvdata(input); | ||
123 | |||
124 | writew(0, rotary->base + CNT_CONFIG_OFF); | ||
125 | writew(0, rotary->base + CNT_IMASK_OFF); | ||
126 | } | ||
127 | |||
128 | static void bfin_rotary_free_action(void *data) | ||
129 | { | ||
130 | peripheral_free_list(data); | ||
131 | } | ||
132 | |||
92 | static int bfin_rotary_probe(struct platform_device *pdev) | 133 | static int bfin_rotary_probe(struct platform_device *pdev) |
93 | { | 134 | { |
94 | struct bfin_rotary_platform_data *pdata = dev_get_platdata(&pdev->dev); | 135 | struct device *dev = &pdev->dev; |
136 | const struct bfin_rotary_platform_data *pdata = dev_get_platdata(dev); | ||
95 | struct bfin_rot *rotary; | 137 | struct bfin_rot *rotary; |
138 | struct resource *res; | ||
96 | struct input_dev *input; | 139 | struct input_dev *input; |
97 | int error; | 140 | int error; |
98 | 141 | ||
@@ -102,18 +145,37 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
102 | return -EINVAL; | 145 | return -EINVAL; |
103 | } | 146 | } |
104 | 147 | ||
105 | error = peripheral_request_list(per_cnt, dev_name(&pdev->dev)); | 148 | if (pdata->pin_list) { |
106 | if (error) { | 149 | error = peripheral_request_list(pdata->pin_list, |
107 | dev_err(&pdev->dev, "requesting peripherals failed\n"); | 150 | dev_name(&pdev->dev)); |
108 | return error; | 151 | if (error) { |
152 | dev_err(dev, "requesting peripherals failed: %d\n", | ||
153 | error); | ||
154 | return error; | ||
155 | } | ||
156 | |||
157 | error = devm_add_action(dev, bfin_rotary_free_action, | ||
158 | pdata->pin_list); | ||
159 | if (error) { | ||
160 | dev_err(dev, "setting cleanup action failed: %d\n", | ||
161 | error); | ||
162 | peripheral_free_list(pdata->pin_list); | ||
163 | return error; | ||
164 | } | ||
109 | } | 165 | } |
110 | 166 | ||
111 | rotary = kzalloc(sizeof(struct bfin_rot), GFP_KERNEL); | 167 | rotary = devm_kzalloc(dev, sizeof(struct bfin_rot), GFP_KERNEL); |
112 | input = input_allocate_device(); | 168 | if (!rotary) |
113 | if (!rotary || !input) { | 169 | return -ENOMEM; |
114 | error = -ENOMEM; | 170 | |
115 | goto out1; | 171 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
116 | } | 172 | rotary->base = devm_ioremap_resource(dev, res); |
173 | if (IS_ERR(rotary->base)) | ||
174 | return PTR_ERR(rotary->base); | ||
175 | |||
176 | input = devm_input_allocate_device(dev); | ||
177 | if (!input) | ||
178 | return -ENOMEM; | ||
117 | 179 | ||
118 | rotary->input = input; | 180 | rotary->input = input; |
119 | 181 | ||
@@ -122,9 +184,8 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
122 | rotary->button_key = pdata->rotary_button_key; | 184 | rotary->button_key = pdata->rotary_button_key; |
123 | rotary->rel_code = pdata->rotary_rel_code; | 185 | rotary->rel_code = pdata->rotary_rel_code; |
124 | 186 | ||
125 | error = rotary->irq = platform_get_irq(pdev, 0); | 187 | rotary->mode = pdata->mode; |
126 | if (error < 0) | 188 | rotary->debounce = pdata->debounce; |
127 | goto out1; | ||
128 | 189 | ||
129 | input->name = pdev->name; | 190 | input->name = pdev->name; |
130 | input->phys = "bfin-rotary/input0"; | 191 | input->phys = "bfin-rotary/input0"; |
@@ -137,6 +198,9 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
137 | input->id.product = 0x0001; | 198 | input->id.product = 0x0001; |
138 | input->id.version = 0x0100; | 199 | input->id.version = 0x0100; |
139 | 200 | ||
201 | input->open = bfin_rotary_open; | ||
202 | input->close = bfin_rotary_close; | ||
203 | |||
140 | if (rotary->up_key) { | 204 | if (rotary->up_key) { |
141 | __set_bit(EV_KEY, input->evbit); | 205 | __set_bit(EV_KEY, input->evbit); |
142 | __set_bit(rotary->up_key, input->keybit); | 206 | __set_bit(rotary->up_key, input->keybit); |
@@ -151,75 +215,43 @@ static int bfin_rotary_probe(struct platform_device *pdev) | |||
151 | __set_bit(rotary->button_key, input->keybit); | 215 | __set_bit(rotary->button_key, input->keybit); |
152 | } | 216 | } |
153 | 217 | ||
154 | error = request_irq(rotary->irq, bfin_rotary_isr, | 218 | /* Quiesce the device before requesting irq */ |
155 | 0, dev_name(&pdev->dev), pdev); | 219 | bfin_rotary_close(input); |
220 | |||
221 | rotary->irq = platform_get_irq(pdev, 0); | ||
222 | if (rotary->irq < 0) { | ||
223 | dev_err(dev, "No rotary IRQ specified\n"); | ||
224 | return -ENOENT; | ||
225 | } | ||
226 | |||
227 | error = devm_request_irq(dev, rotary->irq, bfin_rotary_isr, | ||
228 | 0, dev_name(dev), rotary); | ||
156 | if (error) { | 229 | if (error) { |
157 | dev_err(&pdev->dev, | 230 | dev_err(dev, "unable to claim irq %d; error %d\n", |
158 | "unable to claim irq %d; error %d\n", | ||
159 | rotary->irq, error); | 231 | rotary->irq, error); |
160 | goto out1; | 232 | return error; |
161 | } | 233 | } |
162 | 234 | ||
163 | error = input_register_device(input); | 235 | error = input_register_device(input); |
164 | if (error) { | 236 | if (error) { |
165 | dev_err(&pdev->dev, | 237 | dev_err(dev, "unable to register input device (%d)\n", error); |
166 | "unable to register input device (%d)\n", error); | 238 | return error; |
167 | goto out2; | ||
168 | } | 239 | } |
169 | 240 | ||
170 | if (pdata->rotary_button_key) | ||
171 | bfin_write_CNT_IMASK(CZMIE); | ||
172 | |||
173 | if (pdata->mode & ROT_DEBE) | ||
174 | bfin_write_CNT_DEBOUNCE(pdata->debounce & DPRESCALE); | ||
175 | |||
176 | if (pdata->mode) | ||
177 | bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | | ||
178 | (pdata->mode & ~CNTE)); | ||
179 | |||
180 | bfin_write_CNT_IMASK(bfin_read_CNT_IMASK() | UCIE | DCIE); | ||
181 | bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | CNTE); | ||
182 | |||
183 | platform_set_drvdata(pdev, rotary); | 241 | platform_set_drvdata(pdev, rotary); |
184 | device_init_wakeup(&pdev->dev, 1); | 242 | device_init_wakeup(&pdev->dev, 1); |
185 | 243 | ||
186 | return 0; | 244 | return 0; |
187 | |||
188 | out2: | ||
189 | free_irq(rotary->irq, pdev); | ||
190 | out1: | ||
191 | input_free_device(input); | ||
192 | kfree(rotary); | ||
193 | peripheral_free_list(per_cnt); | ||
194 | |||
195 | return error; | ||
196 | } | 245 | } |
197 | 246 | ||
198 | static int bfin_rotary_remove(struct platform_device *pdev) | 247 | static int __maybe_unused bfin_rotary_suspend(struct device *dev) |
199 | { | ||
200 | struct bfin_rot *rotary = platform_get_drvdata(pdev); | ||
201 | |||
202 | bfin_write_CNT_CONFIG(0); | ||
203 | bfin_write_CNT_IMASK(0); | ||
204 | |||
205 | free_irq(rotary->irq, pdev); | ||
206 | input_unregister_device(rotary->input); | ||
207 | peripheral_free_list(per_cnt); | ||
208 | |||
209 | kfree(rotary); | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | #ifdef CONFIG_PM | ||
215 | static int bfin_rotary_suspend(struct device *dev) | ||
216 | { | 248 | { |
217 | struct platform_device *pdev = to_platform_device(dev); | 249 | struct platform_device *pdev = to_platform_device(dev); |
218 | struct bfin_rot *rotary = platform_get_drvdata(pdev); | 250 | struct bfin_rot *rotary = platform_get_drvdata(pdev); |
219 | 251 | ||
220 | rotary->cnt_config = bfin_read_CNT_CONFIG(); | 252 | rotary->cnt_config = readw(rotary->base + CNT_CONFIG_OFF); |
221 | rotary->cnt_imask = bfin_read_CNT_IMASK(); | 253 | rotary->cnt_imask = readw(rotary->base + CNT_IMASK_OFF); |
222 | rotary->cnt_debounce = bfin_read_CNT_DEBOUNCE(); | 254 | rotary->cnt_debounce = readw(rotary->base + CNT_DEBOUNCE_OFF); |
223 | 255 | ||
224 | if (device_may_wakeup(&pdev->dev)) | 256 | if (device_may_wakeup(&pdev->dev)) |
225 | enable_irq_wake(rotary->irq); | 257 | enable_irq_wake(rotary->irq); |
@@ -227,38 +259,32 @@ static int bfin_rotary_suspend(struct device *dev) | |||
227 | return 0; | 259 | return 0; |
228 | } | 260 | } |
229 | 261 | ||
230 | static int bfin_rotary_resume(struct device *dev) | 262 | static int __maybe_unused bfin_rotary_resume(struct device *dev) |
231 | { | 263 | { |
232 | struct platform_device *pdev = to_platform_device(dev); | 264 | struct platform_device *pdev = to_platform_device(dev); |
233 | struct bfin_rot *rotary = platform_get_drvdata(pdev); | 265 | struct bfin_rot *rotary = platform_get_drvdata(pdev); |
234 | 266 | ||
235 | bfin_write_CNT_DEBOUNCE(rotary->cnt_debounce); | 267 | writew(rotary->cnt_debounce, rotary->base + CNT_DEBOUNCE_OFF); |
236 | bfin_write_CNT_IMASK(rotary->cnt_imask); | 268 | writew(rotary->cnt_imask, rotary->base + CNT_IMASK_OFF); |
237 | bfin_write_CNT_CONFIG(rotary->cnt_config & ~CNTE); | 269 | writew(rotary->cnt_config & ~CNTE, rotary->base + CNT_CONFIG_OFF); |
238 | 270 | ||
239 | if (device_may_wakeup(&pdev->dev)) | 271 | if (device_may_wakeup(&pdev->dev)) |
240 | disable_irq_wake(rotary->irq); | 272 | disable_irq_wake(rotary->irq); |
241 | 273 | ||
242 | if (rotary->cnt_config & CNTE) | 274 | if (rotary->cnt_config & CNTE) |
243 | bfin_write_CNT_CONFIG(rotary->cnt_config); | 275 | writew(rotary->cnt_config, rotary->base + CNT_CONFIG_OFF); |
244 | 276 | ||
245 | return 0; | 277 | return 0; |
246 | } | 278 | } |
247 | 279 | ||
248 | static const struct dev_pm_ops bfin_rotary_pm_ops = { | 280 | static SIMPLE_DEV_PM_OPS(bfin_rotary_pm_ops, |
249 | .suspend = bfin_rotary_suspend, | 281 | bfin_rotary_suspend, bfin_rotary_resume); |
250 | .resume = bfin_rotary_resume, | ||
251 | }; | ||
252 | #endif | ||
253 | 282 | ||
254 | static struct platform_driver bfin_rotary_device_driver = { | 283 | static struct platform_driver bfin_rotary_device_driver = { |
255 | .probe = bfin_rotary_probe, | 284 | .probe = bfin_rotary_probe, |
256 | .remove = bfin_rotary_remove, | ||
257 | .driver = { | 285 | .driver = { |
258 | .name = "bfin-rotary", | 286 | .name = "bfin-rotary", |
259 | #ifdef CONFIG_PM | ||
260 | .pm = &bfin_rotary_pm_ops, | 287 | .pm = &bfin_rotary_pm_ops, |
261 | #endif | ||
262 | }, | 288 | }, |
263 | }; | 289 | }; |
264 | module_platform_driver(bfin_rotary_device_driver); | 290 | module_platform_driver(bfin_rotary_device_driver); |
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c index 79cc0f79896f..e8e010a85484 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c | |||
@@ -195,7 +195,7 @@ static int soc_button_probe(struct platform_device *pdev) | |||
195 | 195 | ||
196 | static struct soc_button_info soc_button_PNP0C40[] = { | 196 | static struct soc_button_info soc_button_PNP0C40[] = { |
197 | { "power", 0, EV_KEY, KEY_POWER, false, true }, | 197 | { "power", 0, EV_KEY, KEY_POWER, false, true }, |
198 | { "home", 1, EV_KEY, KEY_HOME, false, true }, | 198 | { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, |
199 | { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, | 199 | { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false }, |
200 | { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false }, | 200 | { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false }, |
201 | { "rotation_lock", 4, EV_SW, SW_ROTATE_LOCK, false, false }, | 201 | { "rotation_lock", 4, EV_SW, SW_ROTATE_LOCK, false, false }, |