.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
1 | 2 | /* |
---|
2 | 3 | * Access to GPOs on TWL6040 chip |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Authors: |
---|
7 | 8 | * Sergio Aguirre <saaguirre@ti.com> |
---|
8 | 9 | * Peter Ujfalusi <peter.ujfalusi@ti.com> |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
13 | | - * (at your option) any later version. |
---|
14 | | - * |
---|
15 | | - * This program is distributed in the hope that it will be useful, |
---|
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | | - * GNU General Public License for more details. |
---|
19 | | - * |
---|
20 | | - * You should have received a copy of the GNU General Public License |
---|
21 | | - * along with this program; if not, write to the Free Software |
---|
22 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
23 | 10 | */ |
---|
24 | 11 | |
---|
25 | 12 | #include <linux/module.h> |
---|
26 | 13 | #include <linux/init.h> |
---|
27 | 14 | #include <linux/kthread.h> |
---|
28 | 15 | #include <linux/irq.h> |
---|
29 | | -#include <linux/gpio.h> |
---|
| 16 | +#include <linux/gpio/driver.h> |
---|
30 | 17 | #include <linux/platform_device.h> |
---|
| 18 | +#include <linux/bitops.h> |
---|
31 | 19 | #include <linux/of.h> |
---|
32 | 20 | |
---|
33 | 21 | #include <linux/mfd/twl6040.h> |
---|
.. | .. |
---|
41 | 29 | if (ret < 0) |
---|
42 | 30 | return ret; |
---|
43 | 31 | |
---|
44 | | - return (ret >> offset) & 1; |
---|
| 32 | + return !!(ret & BIT(offset)); |
---|
| 33 | +} |
---|
| 34 | + |
---|
| 35 | +static int twl6040gpo_get_direction(struct gpio_chip *chip, unsigned offset) |
---|
| 36 | +{ |
---|
| 37 | + return GPIO_LINE_DIRECTION_OUT; |
---|
45 | 38 | } |
---|
46 | 39 | |
---|
47 | 40 | static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset, |
---|
.. | .. |
---|
62 | 55 | return; |
---|
63 | 56 | |
---|
64 | 57 | if (value) |
---|
65 | | - gpoctl = ret | (1 << offset); |
---|
| 58 | + gpoctl = ret | BIT(offset); |
---|
66 | 59 | else |
---|
67 | | - gpoctl = ret & ~(1 << offset); |
---|
| 60 | + gpoctl = ret & ~BIT(offset); |
---|
68 | 61 | |
---|
69 | 62 | twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl); |
---|
70 | 63 | } |
---|
.. | .. |
---|
74 | 67 | .owner = THIS_MODULE, |
---|
75 | 68 | .get = twl6040gpo_get, |
---|
76 | 69 | .direction_output = twl6040gpo_direction_out, |
---|
| 70 | + .get_direction = twl6040gpo_get_direction, |
---|
77 | 71 | .set = twl6040gpo_set, |
---|
78 | 72 | .can_sleep = true, |
---|
79 | 73 | }; |
---|