Linux 6.13-rc4
[linux.git] / arch / sh / boards / mach-sdk7786 / gpio.c
blobc4587d1013e6118e07c7755394cf68f1d41801ad
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * SDK7786 FPGA USRGPIR Support.
5 * Copyright (C) 2010 Paul Mundt
6 */
7 #include <linux/init.h>
8 #include <linux/interrupt.h>
9 #include <linux/gpio/driver.h>
10 #include <linux/irq.h>
11 #include <linux/kernel.h>
12 #include <linux/spinlock.h>
13 #include <linux/io.h>
14 #include <mach/fpga.h>
16 #define NR_FPGA_GPIOS 8
18 static const char *usrgpir_gpio_names[NR_FPGA_GPIOS] = {
19 "in0", "in1", "in2", "in3", "in4", "in5", "in6", "in7",
22 static int usrgpir_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
24 /* always in */
25 return 0;
28 static int usrgpir_gpio_get(struct gpio_chip *chip, unsigned gpio)
30 return !!(fpga_read_reg(USRGPIR) & (1 << gpio));
33 static struct gpio_chip usrgpir_gpio_chip = {
34 .label = "sdk7786-fpga",
35 .names = usrgpir_gpio_names,
36 .direction_input = usrgpir_gpio_direction_input,
37 .get = usrgpir_gpio_get,
38 .base = -1, /* don't care */
39 .ngpio = NR_FPGA_GPIOS,
42 static int __init usrgpir_gpio_setup(void)
44 return gpiochip_add_data(&usrgpir_gpio_chip, NULL);
46 device_initcall(usrgpir_gpio_setup);