hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpio/gpio-twl6040.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Access to GPOs on TWL6040 chip
34 *
....@@ -6,28 +7,15 @@
67 * Authors:
78 * Sergio Aguirre <saaguirre@ti.com>
89 * 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
2310 */
2411
2512 #include <linux/module.h>
2613 #include <linux/init.h>
2714 #include <linux/kthread.h>
2815 #include <linux/irq.h>
29
-#include <linux/gpio.h>
16
+#include <linux/gpio/driver.h>
3017 #include <linux/platform_device.h>
18
+#include <linux/bitops.h>
3119 #include <linux/of.h>
3220
3321 #include <linux/mfd/twl6040.h>
....@@ -41,7 +29,12 @@
4129 if (ret < 0)
4230 return ret;
4331
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;
4538 }
4639
4740 static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
....@@ -62,9 +55,9 @@
6255 return;
6356
6457 if (value)
65
- gpoctl = ret | (1 << offset);
58
+ gpoctl = ret | BIT(offset);
6659 else
67
- gpoctl = ret & ~(1 << offset);
60
+ gpoctl = ret & ~BIT(offset);
6861
6962 twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
7063 }
....@@ -74,6 +67,7 @@
7467 .owner = THIS_MODULE,
7568 .get = twl6040gpo_get,
7669 .direction_output = twl6040gpo_direction_out,
70
+ .get_direction = twl6040gpo_get_direction,
7771 .set = twl6040gpo_set,
7872 .can_sleep = true,
7973 };