I have new e-mail address. Thanks to Kaloz ;)
[openwrt/svn-archive/archive.git] / target / linux / adm5120-2.6 / files / include / asm-mips / mach-adm5120 / gpio.h
1 /*
2 * $Id$
3 *
4 * ADM5120 GPIO wrappers for arch-neutral GPIO calls
5 *
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 *
24 */
25
26 #ifndef _ADM5120_GPIO_H_
27 #define _ADM5120_GPIO_H_
28
29 #include <asm/mach-adm5120/adm5120_switch.h>
30
31 #define ADM5120_GPIO_PIN0 0
32 #define ADM5120_GPIO_PIN1 1
33 #define ADM5120_GPIO_PIN2 2
34 #define ADM5120_GPIO_PIN3 3
35 #define ADM5120_GPIO_PIN4 4
36 #define ADM5120_GPIO_PIN5 5
37 #define ADM5120_GPIO_PIN6 6
38 #define ADM5120_GPIO_PIN7 7
39 #define ADM5120_GPIO_P0L0 8
40 #define ADM5120_GPIO_P0L1 9
41 #define ADM5120_GPIO_P0L2 10
42 #define ADM5120_GPIO_P1L0 11
43 #define ADM5120_GPIO_P1L1 12
44 #define ADM5120_GPIO_P1L2 13
45 #define ADM5120_GPIO_P2L0 14
46 #define ADM5120_GPIO_P2L1 15
47 #define ADM5120_GPIO_P2L2 16
48 #define ADM5120_GPIO_P3L0 17
49 #define ADM5120_GPIO_P3L1 18
50 #define ADM5120_GPIO_P3L2 19
51 #define ADM5120_GPIO_P4L0 20
52 #define ADM5120_GPIO_P4L1 21
53 #define ADM5120_GPIO_P4L2 22
54 #define ADM5120_GPIO_MAX 22
55 #define ADM5120_GPIO_COUNT ADM5120_GPIO_MAX+1
56
57 #define ADM5120_GPIO_LOW 0
58 #define ADM5120_GPIO_HIGH 1
59
60 #define ADM5120_GPIO_SWITCH 0x10
61 #define ADM5120_GPIO_FLASH (ADM5120_GPIO_SWITCH | LED_MODE_FLASH)
62 #define ADM5120_GPIO_LINK (ADM5120_GPIO_SWITCH | LED_MODE_LINK)
63 #define ADM5120_GPIO_SPEED (ADM5120_GPIO_SWITCH | LED_MODE_SPEED)
64 #define ADM5120_GPIO_DUPLEX (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX)
65 #define ADM5120_GPIO_ACT (ADM5120_GPIO_SWITCH | LED_MODE_ACT)
66 #define ADM5120_GPIO_COLL (ADM5120_GPIO_SWITCH | LED_MODE_COLL)
67 #define ADM5120_GPIO_LINK_ACT (ADM5120_GPIO_SWITCH | LED_MODE_LINK_ACT)
68 #define ADM5120_GPIO_DUPLEX_COLL (ADM5120_GPIO_SWITCH | LED_MODE_DUPLEX_COLL)
69 #define ADM5120_GPIO_10M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_10M_ACT)
70 #define ADM5120_GPIO_100M_ACT (ADM5120_GPIO_SWITCH | LED_MODE_100M_ACT)
71
72 extern int adm5120_gpio_direction_input(unsigned gpio);
73 extern int adm5120_gpio_direction_output(unsigned gpio, int value);
74 extern int adm5120_gpio_get_value(unsigned gpio);
75 extern void adm5120_gpio_set_value(unsigned gpio, int value);
76 extern int adm5120_gpio_request(unsigned gpio, const char *label);
77 extern void adm5120_gpio_free(unsigned gpio);
78 extern int adm5120_gpio_to_irq(unsigned gpio);
79 extern int adm5120_irq_to_gpio(unsigned irq);
80
81 /*
82 * Wrappers for the generic GPIO layer
83 */
84 static inline int gpio_direction_input(unsigned gpio)
85 {
86 return adm5120_gpio_direction_input(gpio);
87 }
88
89 static inline int gpio_direction_output(unsigned gpio, int value)
90 {
91 return adm5120_gpio_direction_output(gpio,value);
92 }
93
94 static inline int gpio_get_value(unsigned gpio)
95 {
96 return adm5120_gpio_get_value(gpio);
97 }
98
99 static inline void gpio_set_value(unsigned gpio, int value)
100 {
101 adm5120_gpio_set_value(gpio, value);
102 }
103
104 static inline int gpio_request(unsigned gpio, const char *label)
105 {
106 return adm5120_gpio_request(gpio, label);
107 }
108
109 static inline void gpio_free(unsigned gpio)
110 {
111 adm5120_gpio_free(gpio);
112 }
113
114 static inline int gpio_to_irq(unsigned gpio)
115 {
116 return adm5120_gpio_to_irq(gpio);
117 }
118
119 static inline int irq_to_gpio(unsigned irq)
120 {
121 return adm5120_irq_to_gpio(irq);
122 }
123
124 #include <asm-generic/gpio.h> /* cansleep wrappers */
125
126 #endif