Convert altera_pio to driver model.
Signed-off-by: Thomas Chou
Acked-by: Chin Liang See
---
v2
fix ranges of pio in dts
fix coding style as Marek suggested.
v3
change gpio_count device tree binding.
v4
change gpio width default to 32.
doc dts binding.
arch/nios2/dts/3c120_devboard.dts| 41
arch/nios2/include/asm/gpio.h| 80 +--
board/altera/nios2-generic/nios2-generic.c | 7 -
configs/nios2-generic_defconfig | 2 +
doc/device-tree-bindings/gpio/altera_pio.txt | 28 +++
drivers/gpio/Kconfig | 7 +
drivers/gpio/altera_pio.c| 316 +++
include/configs/nios2-generic.h | 20 --
8 files changed, 155 insertions(+), 346 deletions(-)
create mode 100644 doc/device-tree-bindings/gpio/altera_pio.txt
diff --git a/arch/nios2/dts/3c120_devboard.dts
b/arch/nios2/dts/3c120_devboard.dts
index a35f5fe..781a652 100644
--- a/arch/nios2/dts/3c120_devboard.dts
+++ b/arch/nios2/dts/3c120_devboard.dts
@@ -68,6 +68,9 @@
<0x4400 0x08004400 0x0040>,
<0x4800 0x08004800 0x0040>,
<0x4c80 0x08004c80 0x0020>,
+ <0x4cc0 0x08004cc0 0x0010>,
+ <0x4ce0 0x08004ce0 0x0010>,
+ <0x4d00 0x08004d00 0x0010>,
<0x4d50 0x08004d50 0x0008>,
<0x8000 0x08008000 0x0020>,
<0x0040 0x0840 0x0020>;
@@ -132,6 +135,44 @@
clock-frequency = <6250>;
u-boot,dm-pre-reloc;
};
+
+ user_led_pio_8out: gpio@0x4cc0 {
+ compatible = "altr,pio-1.0";
+ reg = <0x4cc0 0x0010>;
+ resetvalue = <255>;
+ altr,gpio-bank-width = <8>;
+ #gpio-cells = <2>;
+ gpio-controller;
+ gpio-bank-name = "led";
+ };
+
+ user_dipsw_pio_8in: gpio@0x4ce0 {
+ compatible = "altr,pio-1.0";
+ reg = <0x4ce0 0x0010>;
+ interrupt-parent = <>;
+ interrupts = <8>;
+ edge_type = <2>;
+ level_trigger = <0>;
+ resetvalue = <0>;
+ altr,gpio-bank-width = <8>;
+ #gpio-cells = <2>;
+ gpio-controller;
+ gpio-bank-name = "dipsw";
+ };
+
+ user_pb_pio_4in: gpio@0x4d00 {
+ compatible = "altr,pio-1.0";
+ reg = <0x4d00 0x0010>;
+ interrupt-parent = <>;
+ interrupts = <9>;
+ edge_type = <2>;
+ level_trigger = <0>;
+ resetvalue = <0>;
+ altr,gpio-bank-width = <4>;
+ #gpio-cells = <2>;
+ gpio-controller;
+ gpio-bank-name = "pb";
+ };
};
cfi_flash_64m: flash@0x0 {
diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h
index 908381f..306ab4c 100644
--- a/arch/nios2/include/asm/gpio.h
+++ b/arch/nios2/include/asm/gpio.h
@@ -1,79 +1 @@
-/*
- * nios2 gpio driver
- *
- * This gpio core is described in http://nioswiki.com/GPIO
- * bit[0] data
- * bit[1] output enable
- *
- * When CONFIG_SYS_GPIO_BASE is not defined, the board may either
- * provide its own driver or the altera_pio driver may be used.
- *
- * Copyright (C) 2010 Thomas Chou
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _ASM_NIOS2_GPIO_H_
-#define _ASM_NIOS2_GPIO_H_
-
-#ifdef CONFIG_SYS_GPIO_BASE
-#include
-
-static inline int gpio_request(unsigned gpio, const char *label)
-{
- return 0;
-}
-
-static inline int gpio_free(unsigned gpio)
-{
- return 0;
-}
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2));
- return 0;
-}
-
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
-