diff options
| author | Moritz Fischer <moritz.fischer@ettus.com> | 2015-01-10 17:04:14 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-01-10 17:17:10 -0500 |
| commit | 846a7fc8f4bc8f0d04be8d953ecba28152b14de4 (patch) | |
| tree | 49466b37e79ded79a5012f53ccf057376e3d7267 | |
| parent | b388de88308fde104fb6520dbf9e7b342fd5761a (diff) | |
Input: add support for NI Ettus Research USRP E3x0 button
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | Documentation/devicetree/bindings/input/e3x0-button.txt | 25 | ||||
| -rw-r--r-- | Documentation/devicetree/bindings/vendor-prefixes.txt | 1 | ||||
| -rw-r--r-- | drivers/input/misc/Kconfig | 10 | ||||
| -rw-r--r-- | drivers/input/misc/Makefile | 1 | ||||
| -rw-r--r-- | drivers/input/misc/e3x0-button.c | 157 |
5 files changed, 194 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/input/e3x0-button.txt b/Documentation/devicetree/bindings/input/e3x0-button.txt new file mode 100644 index 000000000000..751665e8e47a --- /dev/null +++ b/Documentation/devicetree/bindings/input/e3x0-button.txt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | National Instruments Ettus Research USRP E3x0 button driver | ||
| 2 | |||
| 3 | This module is part of the NI Ettus Research USRP E3x0 SDR. | ||
| 4 | |||
| 5 | This module provides a simple power button event via two interrupts. | ||
| 6 | |||
| 7 | Required properties: | ||
| 8 | - compatible: should be one of the following | ||
| 9 | - "ettus,e3x0-button": For devices such as the NI Ettus Research USRP E3x0 | ||
| 10 | - interrupt-parent: | ||
| 11 | - a phandle to the interrupt controller that it is attached to. | ||
| 12 | - interrupts: should be one of the following | ||
| 13 | - <0 30 1>, <0 31 1>: For devices such as the NI Ettus Research USRP E3x0 | ||
| 14 | - interrupt-names: should be one of the following | ||
| 15 | - "press", "release": For devices such as the NI Ettus Research USRP E3x0 | ||
| 16 | |||
| 17 | Note: Interrupt numbers might vary depending on the FPGA configuration. | ||
| 18 | |||
| 19 | Example: | ||
| 20 | button { | ||
| 21 | compatible = "ettus,e3x0-button"; | ||
| 22 | interrupt-parent = <&intc>; | ||
| 23 | interrupts = <0 30 1>, <0 31 1>; | ||
| 24 | interrupt-names = "press", "release"; | ||
| 25 | } | ||
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index e6469ec7a90e..9f18b4f5cf09 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
| @@ -48,6 +48,7 @@ epcos EPCOS AG | |||
| 48 | epfl Ecole Polytechnique Fédérale de Lausanne | 48 | epfl Ecole Polytechnique Fédérale de Lausanne |
| 49 | epson Seiko Epson Corp. | 49 | epson Seiko Epson Corp. |
| 50 | est ESTeem Wireless Modems | 50 | est ESTeem Wireless Modems |
| 51 | ettus NI Ettus Research | ||
| 51 | eukrea Eukréa Electromatique | 52 | eukrea Eukréa Electromatique |
| 52 | excito Excito | 53 | excito Excito |
| 53 | fsl Freescale Semiconductor | 54 | fsl Freescale Semiconductor |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 9e610c4862a2..6deb8dae3205 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
| @@ -93,6 +93,16 @@ config INPUT_BMA150 | |||
| 93 | To compile this driver as a module, choose M here: the | 93 | To compile this driver as a module, choose M here: the |
| 94 | module will be called bma150. | 94 | module will be called bma150. |
| 95 | 95 | ||
| 96 | config INPUT_E3X0_BUTTON | ||
| 97 | tristate "NI Ettus Research USRP E3x0 Button support." | ||
| 98 | default n | ||
| 99 | help | ||
| 100 | Say Y here to enable support for the NI Ettus Research | ||
| 101 | USRP E3x0 Button. | ||
| 102 | |||
| 103 | To compile this driver as a module, choose M here: the | ||
| 104 | module will be called e3x0_button. | ||
| 105 | |||
| 96 | config INPUT_PCSPKR | 106 | config INPUT_PCSPKR |
| 97 | tristate "PC Speaker support" | 107 | tristate "PC Speaker support" |
| 98 | depends on PCSPKR_PLATFORM | 108 | depends on PCSPKR_PLATFORM |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index f8d9ea7c059a..403a1a54a76c 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
| @@ -26,6 +26,7 @@ obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o | |||
| 26 | obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o | 26 | obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o |
| 27 | obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o | 27 | obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o |
| 28 | obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o | 28 | obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o |
| 29 | obj-$(CONFIG_INPUT_E3X0_BUTTON) += e3x0-button.o | ||
| 29 | obj-$(CONFIG_INPUT_DRV260X_HAPTICS) += drv260x.o | 30 | obj-$(CONFIG_INPUT_DRV260X_HAPTICS) += drv260x.o |
| 30 | obj-$(CONFIG_INPUT_DRV2667_HAPTICS) += drv2667.o | 31 | obj-$(CONFIG_INPUT_DRV2667_HAPTICS) += drv2667.o |
| 31 | obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o | 32 | obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o |
diff --git a/drivers/input/misc/e3x0-button.c b/drivers/input/misc/e3x0-button.c new file mode 100644 index 000000000000..13bfca8a7b16 --- /dev/null +++ b/drivers/input/misc/e3x0-button.c | |||
| @@ -0,0 +1,157 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2014, National Instruments Corp. All rights reserved. | ||
| 3 | * | ||
| 4 | * Driver for NI Ettus Research USRP E3x0 Button Driver | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; version 2 of the License. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/device.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/platform_device.h> | ||
| 20 | #include <linux/input.h> | ||
| 21 | #include <linux/interrupt.h> | ||
| 22 | #include <linux/of.h> | ||
| 23 | #include <linux/slab.h> | ||
| 24 | |||
| 25 | static irqreturn_t e3x0_button_release_handler(int irq, void *data) | ||
| 26 | { | ||
| 27 | struct input_dev *idev = data; | ||
| 28 | |||
| 29 | input_report_key(idev, KEY_POWER, 0); | ||
| 30 | input_sync(idev); | ||
| 31 | |||
| 32 | return IRQ_HANDLED; | ||
| 33 | } | ||
| 34 | |||
| 35 | static irqreturn_t e3x0_button_press_handler(int irq, void *data) | ||
| 36 | { | ||
| 37 | struct input_dev *idev = data; | ||
| 38 | |||
| 39 | input_report_key(idev, KEY_POWER, 1); | ||
| 40 | pm_wakeup_event(idev->dev.parent, 0); | ||
| 41 | input_sync(idev); | ||
| 42 | |||
| 43 | return IRQ_HANDLED; | ||
| 44 | } | ||
| 45 | |||
| 46 | static int __maybe_unused e3x0_button_suspend(struct device *dev) | ||
| 47 | { | ||
| 48 | struct platform_device *pdev = to_platform_device(dev); | ||
| 49 | |||
| 50 | if (device_may_wakeup(dev)) | ||
| 51 | enable_irq_wake(platform_get_irq_byname(pdev, "press")); | ||
| 52 | |||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | static int __maybe_unused e3x0_button_resume(struct device *dev) | ||
| 57 | { | ||
| 58 | struct platform_device *pdev = to_platform_device(dev); | ||
| 59 | |||
| 60 | if (device_may_wakeup(dev)) | ||
| 61 | disable_irq_wake(platform_get_irq_byname(pdev, "press")); | ||
| 62 | |||
| 63 | return 0; | ||
| 64 | } | ||
| 65 | |||
| 66 | static SIMPLE_DEV_PM_OPS(e3x0_button_pm_ops, | ||
| 67 | e3x0_button_suspend, e3x0_button_resume); | ||
| 68 | |||
| 69 | static int e3x0_button_probe(struct platform_device *pdev) | ||
| 70 | { | ||
| 71 | struct input_dev *input; | ||
| 72 | int irq_press, irq_release; | ||
| 73 | int error; | ||
| 74 | |||
| 75 | irq_press = platform_get_irq_byname(pdev, "press"); | ||
| 76 | if (irq_press < 0) { | ||
| 77 | dev_err(&pdev->dev, "No IRQ for 'press', error=%d\n", | ||
| 78 | irq_press); | ||
| 79 | return irq_press; | ||
| 80 | } | ||
| 81 | |||
| 82 | irq_release = platform_get_irq_byname(pdev, "release"); | ||
| 83 | if (irq_release < 0) { | ||
| 84 | dev_err(&pdev->dev, "No IRQ for 'release', error=%d\n", | ||
| 85 | irq_release); | ||
| 86 | return irq_release; | ||
| 87 | } | ||
| 88 | |||
| 89 | input = devm_input_allocate_device(&pdev->dev); | ||
| 90 | if (!input) | ||
| 91 | return -ENOMEM; | ||
| 92 | |||
| 93 | input->name = "NI Ettus Research USRP E3x0 Button Driver"; | ||
| 94 | input->phys = "e3x0_button/input0"; | ||
| 95 | input->dev.parent = &pdev->dev; | ||
| 96 | |||
| 97 | input_set_capability(input, EV_KEY, KEY_POWER); | ||
| 98 | |||
| 99 | error = devm_request_irq(&pdev->dev, irq_press, | ||
| 100 | e3x0_button_press_handler, 0, | ||
| 101 | "e3x0-button", input); | ||
| 102 | if (error) { | ||
| 103 | dev_err(&pdev->dev, "Failed to request 'press' IRQ#%d: %d\n", | ||
| 104 | irq_press, error); | ||
| 105 | return error; | ||
| 106 | } | ||
| 107 | |||
| 108 | error = devm_request_irq(&pdev->dev, irq_release, | ||
| 109 | e3x0_button_release_handler, 0, | ||
