.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Rockchip RK805 PMIC Power Key driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Joseph Chen <chenjh@rock-chips.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify it |
---|
9 | | - * under the terms of the GNU General Public License as published by the |
---|
10 | | - * Free Software Foundation; either version 2 of the License, or (at your |
---|
11 | | - * option) any later version. |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/errno.h> |
---|
.. | .. |
---|
17 | 13 | #include <linux/interrupt.h> |
---|
18 | 14 | #include <linux/kernel.h> |
---|
19 | 15 | #include <linux/module.h> |
---|
| 16 | +#include <linux/of.h> |
---|
20 | 17 | #include <linux/platform_device.h> |
---|
21 | 18 | |
---|
22 | 19 | static irqreturn_t pwrkey_fall_irq(int irq, void *_pwr) |
---|
.. | .. |
---|
43 | 40 | { |
---|
44 | 41 | struct input_dev *pwr; |
---|
45 | 42 | int fall_irq, rise_irq; |
---|
| 43 | + struct device_node *np; |
---|
46 | 44 | int err; |
---|
| 45 | + |
---|
| 46 | + np = of_get_child_by_name(pdev->dev.parent->of_node, "pwrkey"); |
---|
| 47 | + if (np && !of_device_is_available(np)) { |
---|
| 48 | + dev_info(&pdev->dev, "device is disabled\n"); |
---|
| 49 | + return -EINVAL; |
---|
| 50 | + } |
---|
47 | 51 | |
---|
48 | 52 | pwr = devm_input_allocate_device(&pdev->dev); |
---|
49 | 53 | if (!pwr) { |
---|
.. | .. |
---|
57 | 61 | input_set_capability(pwr, EV_KEY, KEY_POWER); |
---|
58 | 62 | |
---|
59 | 63 | fall_irq = platform_get_irq(pdev, 0); |
---|
60 | | - if (fall_irq < 0) { |
---|
61 | | - dev_err(&pdev->dev, "Can't get fall irq: %d\n", fall_irq); |
---|
| 64 | + if (fall_irq < 0) |
---|
62 | 65 | return fall_irq; |
---|
63 | | - } |
---|
64 | 66 | |
---|
65 | 67 | rise_irq = platform_get_irq(pdev, 1); |
---|
66 | | - if (rise_irq < 0) { |
---|
67 | | - dev_err(&pdev->dev, "Can't get rise irq: %d\n", rise_irq); |
---|
| 68 | + if (rise_irq < 0) |
---|
68 | 69 | return rise_irq; |
---|
69 | | - } |
---|
70 | 70 | |
---|
71 | 71 | err = devm_request_any_context_irq(&pwr->dev, fall_irq, |
---|
72 | 72 | pwrkey_fall_irq, |
---|
.. | .. |
---|
106 | 106 | }; |
---|
107 | 107 | module_platform_driver(rk805_pwrkey_driver); |
---|
108 | 108 | |
---|
| 109 | +MODULE_ALIAS("platform:rk805-pwrkey"); |
---|
109 | 110 | MODULE_AUTHOR("Joseph Chen <chenjh@rock-chips.com>"); |
---|
110 | 111 | MODULE_DESCRIPTION("RK805 PMIC Power Key driver"); |
---|
111 | 112 | MODULE_LICENSE("GPL"); |
---|