|
@@ -1223,3 +1223,106 @@ void bfin_reset_boot_spi_cs(unsigned short pin)
|
|
|
{
|
|
|
unsigned short gpio = P_IDENT(pin);
|
|
|
port_setup(gpio, GPIO_USAGE);
|
|
|
+ gpio_array[gpio_bank(gpio)]->data_set = gpio_bit(gpio);
|
|
|
+ AWA_DUMMY_READ(data_set);
|
|
|
+ udelay(1);
|
|
|
+}
|
|
|
+
|
|
|
+#if defined(CONFIG_PROC_FS)
|
|
|
+static int gpio_proc_show(struct seq_file *m, void *v)
|
|
|
+{
|
|
|
+ int c, irq, gpio;
|
|
|
+
|
|
|
+ for (c = 0; c < MAX_RESOURCES; c++) {
|
|
|
+ irq = is_reserved(gpio_irq, c, 1);
|
|
|
+ gpio = is_reserved(gpio, c, 1);
|
|
|
+ if (!check_gpio(c) && (gpio || irq))
|
|
|
+ seq_printf(m, "GPIO_%d: \t%s%s \t\tGPIO %s\n", c,
|
|
|
+ get_label(c), (gpio && irq) ? " *" : "",
|
|
|
+ get_gpio_dir(c) ? "OUTPUT" : "INPUT");
|
|
|
+ else if (is_reserved(peri, c, 1))
|
|
|
+ seq_printf(m, "GPIO_%d: \t%s \t\tPeripheral\n", c, get_label(c));
|
|
|
+ else
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int gpio_proc_open(struct inode *inode, struct file *file)
|
|
|
+{
|
|
|
+ return single_open(file, gpio_proc_show, NULL);
|
|
|
+}
|
|
|
+
|
|
|
+static const struct file_operations gpio_proc_ops = {
|
|
|
+ .open = gpio_proc_open,
|
|
|
+ .read = seq_read,
|
|
|
+ .llseek = seq_lseek,
|
|
|
+ .release = single_release,
|
|
|
+};
|
|
|
+
|
|
|
+static __init int gpio_register_proc(void)
|
|
|
+{
|
|
|
+ struct proc_dir_entry *proc_gpio;
|
|
|
+
|
|
|
+ proc_gpio = proc_create("gpio", 0, NULL, &gpio_proc_ops);
|
|
|
+ return proc_gpio == NULL;
|
|
|
+}
|
|
|
+__initcall(gpio_register_proc);
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef CONFIG_GPIOLIB
|
|
|
+static int bfin_gpiolib_direction_input(struct gpio_chip *chip, unsigned gpio)
|
|
|
+{
|
|
|
+ return bfin_gpio_direction_input(gpio);
|
|
|
+}
|
|
|
+
|
|
|
+static int bfin_gpiolib_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
|
|
|
+{
|
|
|
+ return bfin_gpio_direction_output(gpio, level);
|
|
|
+}
|
|
|
+
|
|
|
+static int bfin_gpiolib_get_value(struct gpio_chip *chip, unsigned gpio)
|
|
|
+{
|
|
|
+ return bfin_gpio_get_value(gpio);
|
|
|
+}
|
|
|
+
|
|
|
+static void bfin_gpiolib_set_value(struct gpio_chip *chip, unsigned gpio, int value)
|
|
|
+{
|
|
|
+ return bfin_gpio_set_value(gpio, value);
|
|
|
+}
|
|
|
+
|
|
|
+static int bfin_gpiolib_gpio_request(struct gpio_chip *chip, unsigned gpio)
|
|
|
+{
|
|
|
+ return bfin_gpio_request(gpio, chip->label);
|
|
|
+}
|
|
|
+
|
|
|
+static void bfin_gpiolib_gpio_free(struct gpio_chip *chip, unsigned gpio)
|
|
|
+{
|
|
|
+ return bfin_gpio_free(gpio);
|
|
|
+}
|
|
|
+
|
|
|
+static int bfin_gpiolib_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
|
|
|
+{
|
|
|
+ return gpio + GPIO_IRQ_BASE;
|
|
|
+}
|
|
|
+
|
|
|
+static struct gpio_chip bfin_chip = {
|
|
|
+ .label = "BFIN-GPIO",
|
|
|
+ .direction_input = bfin_gpiolib_direction_input,
|
|
|
+ .get = bfin_gpiolib_get_value,
|
|
|
+ .direction_output = bfin_gpiolib_direction_output,
|
|
|
+ .set = bfin_gpiolib_set_value,
|
|
|
+ .request = bfin_gpiolib_gpio_request,
|
|
|
+ .free = bfin_gpiolib_gpio_free,
|
|
|
+ .to_irq = bfin_gpiolib_gpio_to_irq,
|
|
|
+ .base = 0,
|
|
|
+ .ngpio = MAX_BLACKFIN_GPIOS,
|
|
|
+};
|
|
|
+
|
|
|
+static int __init bfin_gpiolib_setup(void)
|
|
|
+{
|
|
|
+ return gpiochip_add(&bfin_chip);
|
|
|
+}
|
|
|
+arch_initcall(bfin_gpiolib_setup);
|
|
|
+#endif
|