Lines Matching +full:linux +full:- +full:keycodes
1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/interrupt.h>
13 #include <linux/irq.h>
14 #include <linux/delay.h>
15 #include <linux/platform_device.h>
16 #include <linux/input.h>
17 #include <linux/input/sh_keysc.h>
18 #include <linux/bitmap.h>
19 #include <linux/pm_runtime.h>
20 #include <linux/io.h>
21 #include <linux/slab.h>
51 return ioread16(p->iomem_base + (reg_nr << 2)); in sh_keysc_read()
57 iowrite16(value, p->iomem_base + (reg_nr << 2)); in sh_keysc_write()
63 struct sh_keysc_info *pdata = &p->pdata; in sh_keysc_level_mode()
68 if (pdata->kycr2_delay) in sh_keysc_level_mode()
69 udelay(pdata->kycr2_delay); in sh_keysc_level_mode()
85 struct sh_keysc_info *pdata = &priv->pdata; in sh_keysc_isr()
86 int keyout_nr = sh_keysc_mode[pdata->mode].keyout; in sh_keysc_isr()
87 int keyin_nr = sh_keysc_mode[pdata->mode].keyin; in sh_keysc_isr()
94 dev_dbg(&pdev->dev, "isr!\n"); in sh_keysc_isr()
110 udelay(pdata->delay); in sh_keysc_isr()
120 keyin_set |= tmp ^ ((1 << keyin_nr) - 1); in sh_keysc_isr()
129 sh_keysc_map_dbg(&pdev->dev, keys, "keys"); in sh_keysc_isr()
133 sh_keysc_map_dbg(&pdev->dev, priv->last_keys, "last_keys"); in sh_keysc_isr()
134 sh_keysc_map_dbg(&pdev->dev, keys0, "keys0"); in sh_keysc_isr()
135 sh_keysc_map_dbg(&pdev->dev, keys1, "keys1"); in sh_keysc_isr()
138 k = pdata->keycodes[i]; in sh_keysc_isr()
142 if (test_bit(i, keys0) == test_bit(i, priv->last_keys)) in sh_keysc_isr()
146 input_event(priv->input, EV_KEY, k, 1); in sh_keysc_isr()
147 __set_bit(i, priv->last_keys); in sh_keysc_isr()
151 input_event(priv->input, EV_KEY, k, 0); in sh_keysc_isr()
152 __clear_bit(i, priv->last_keys); in sh_keysc_isr()
156 input_sync(priv->input); in sh_keysc_isr()
170 if (!dev_get_platdata(&pdev->dev)) { in sh_keysc_probe()
171 dev_err(&pdev->dev, "no platform data defined\n"); in sh_keysc_probe()
172 error = -EINVAL; in sh_keysc_probe()
176 error = -ENXIO; in sh_keysc_probe()
179 dev_err(&pdev->dev, "failed to get I/O memory\n"); in sh_keysc_probe()
189 dev_err(&pdev->dev, "failed to allocate driver data\n"); in sh_keysc_probe()
190 error = -ENOMEM; in sh_keysc_probe()
195 memcpy(&priv->pdata, dev_get_platdata(&pdev->dev), sizeof(priv->pdata)); in sh_keysc_probe()
196 pdata = &priv->pdata; in sh_keysc_probe()
198 priv->iomem_base = ioremap(res->start, resource_size(res)); in sh_keysc_probe()
199 if (priv->iomem_base == NULL) { in sh_keysc_probe()
200 dev_err(&pdev->dev, "failed to remap I/O memory\n"); in sh_keysc_probe()
201 error = -ENXIO; in sh_keysc_probe()
205 priv->input = input_allocate_device(); in sh_keysc_probe()
206 if (!priv->input) { in sh_keysc_probe()
207 dev_err(&pdev->dev, "failed to allocate input device\n"); in sh_keysc_probe()
208 error = -ENOMEM; in sh_keysc_probe()
212 input = priv->input; in sh_keysc_probe()
213 input->evbit[0] = BIT_MASK(EV_KEY); in sh_keysc_probe()
215 input->name = pdev->name; in sh_keysc_probe()
216 input->phys = "sh-keysc-keys/input0"; in sh_keysc_probe()
217 input->dev.parent = &pdev->dev; in sh_keysc_probe()
219 input->id.bustype = BUS_HOST; in sh_keysc_probe()
220 input->id.vendor = 0x0001; in sh_keysc_probe()
221 input->id.product = 0x0001; in sh_keysc_probe()
222 input->id.version = 0x0100; in sh_keysc_probe()
224 input->keycode = pdata->keycodes; in sh_keysc_probe()
225 input->keycodesize = sizeof(pdata->keycodes[0]); in sh_keysc_probe()
226 input->keycodemax = ARRAY_SIZE(pdata->keycodes); in sh_keysc_probe()
229 dev_name(&pdev->dev), pdev); in sh_keysc_probe()
231 dev_err(&pdev->dev, "failed to request IRQ\n"); in sh_keysc_probe()
236 __set_bit(pdata->keycodes[i], input->keybit); in sh_keysc_probe()
237 __clear_bit(KEY_RESERVED, input->keybit); in sh_keysc_probe()
241 dev_err(&pdev->dev, "failed to register input device\n"); in sh_keysc_probe()
245 pm_runtime_enable(&pdev->dev); in sh_keysc_probe()
246 pm_runtime_get_sync(&pdev->dev); in sh_keysc_probe()
248 sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | in sh_keysc_probe()
249 pdata->scan_timing); in sh_keysc_probe()
252 device_init_wakeup(&pdev->dev, 1); in sh_keysc_probe()
261 iounmap(priv->iomem_base); in sh_keysc_probe()
274 input_unregister_device(priv->input); in sh_keysc_remove()
276 iounmap(priv->iomem_base); in sh_keysc_remove()
278 pm_runtime_put_sync(&pdev->dev); in sh_keysc_remove()
279 pm_runtime_disable(&pdev->dev); in sh_keysc_remove()