upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / include / mach / gpio.h
1 /* linux/arch/arm/mach-s5pv310/include/mach/gpio.h
2  *
3  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV310 - GPIO lib support
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #ifndef __ASM_ARCH_GPIO_H
14 #define __ASM_ARCH_GPIO_H __FILE__
15
16 #define gpio_get_value  __gpio_get_value
17 #define gpio_set_value  __gpio_set_value
18 #define gpio_cansleep   __gpio_cansleep
19 #define gpio_to_irq     __gpio_to_irq
20
21 /* Practically, GPIO banks upto GPZ are the configurable gpio banks */
22
23 /* GPIO bank sizes */
24 #define S5PV310_GPIO_A0_NR      (8)
25 #define S5PV310_GPIO_A1_NR      (6)
26 #define S5PV310_GPIO_B_NR       (8)
27 #define S5PV310_GPIO_C0_NR      (5)
28 #define S5PV310_GPIO_C1_NR      (5)
29 #define S5PV310_GPIO_D0_NR      (4)
30 #define S5PV310_GPIO_D1_NR      (4)
31 #define S5PV310_GPIO_E0_NR      (5)
32 #define S5PV310_GPIO_E1_NR      (8)
33 #define S5PV310_GPIO_E2_NR      (6)
34 #define S5PV310_GPIO_E3_NR      (8)
35 #define S5PV310_GPIO_E4_NR      (8)
36 #define S5PV310_GPIO_F0_NR      (8)
37 #define S5PV310_GPIO_F1_NR      (8)
38 #define S5PV310_GPIO_F2_NR      (8)
39 #define S5PV310_GPIO_F3_NR      (6)
40 #define S5PV310_GPIO_J0_NR      (8)
41 #define S5PV310_GPIO_J1_NR      (5)
42 #define S5PV310_GPIO_K0_NR      (7)
43 #define S5PV310_GPIO_K1_NR      (7)
44 #define S5PV310_GPIO_K2_NR      (7)
45 #define S5PV310_GPIO_K3_NR      (7)
46 #define S5PV310_GPIO_L0_NR      (8)
47 #define S5PV310_GPIO_L1_NR      (3)
48 #define S5PV310_GPIO_L2_NR      (8)
49 #define S5PV310_GPIO_X0_NR      (8)
50 #define S5PV310_GPIO_X1_NR      (8)
51 #define S5PV310_GPIO_X2_NR      (8)
52 #define S5PV310_GPIO_X3_NR      (8)
53 #define S5PV310_GPIO_Y0_NR      (6)
54 #define S5PV310_GPIO_Y1_NR      (4)
55 #define S5PV310_GPIO_Y2_NR      (6)
56 #define S5PV310_GPIO_Y3_NR      (8)
57 #define S5PV310_GPIO_Y4_NR      (8)
58 #define S5PV310_GPIO_Y5_NR      (8)
59 #define S5PV310_GPIO_Y6_NR      (8)
60 #define S5PV310_GPIO_Z_NR       (7)
61
62 /* GPIO bank numbers */
63
64 #define S5PV310_GPIO_NEXT(__gpio) \
65         ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
66
67 enum s5p_gpio_number {
68         S5PV310_GPIO_A0_START   = 0,
69         S5PV310_GPIO_A1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_A0),
70         S5PV310_GPIO_B_START    = S5PV310_GPIO_NEXT(S5PV310_GPIO_A1),
71         S5PV310_GPIO_C0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_B),
72         S5PV310_GPIO_C1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_C0),
73         S5PV310_GPIO_D0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_C1),
74         S5PV310_GPIO_D1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_D0),
75         S5PV310_GPIO_E0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_D1),
76         S5PV310_GPIO_E1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_E0),
77         S5PV310_GPIO_E2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_E1),
78         S5PV310_GPIO_E3_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_E2),
79         S5PV310_GPIO_E4_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_E3),
80         S5PV310_GPIO_F0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_E4),
81         S5PV310_GPIO_F1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_F0),
82         S5PV310_GPIO_F2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_F1),
83         S5PV310_GPIO_F3_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_F2),
84         S5PV310_GPIO_J0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_F3),
85         S5PV310_GPIO_J1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_J0),
86         S5PV310_GPIO_K0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_J1),
87         S5PV310_GPIO_K1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_K0),
88         S5PV310_GPIO_K2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_K1),
89         S5PV310_GPIO_K3_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_K2),
90         S5PV310_GPIO_L0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_K3),
91         S5PV310_GPIO_L1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_L0),
92         S5PV310_GPIO_L2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_L1),
93         S5PV310_GPIO_X0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_L2),
94         S5PV310_GPIO_X1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_X0),
95         S5PV310_GPIO_X2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_X1),
96         S5PV310_GPIO_X3_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_X2),
97         S5PV310_GPIO_Y0_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_X3),
98         S5PV310_GPIO_Y1_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y0),
99         S5PV310_GPIO_Y2_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y1),
100         S5PV310_GPIO_Y3_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y2),
101         S5PV310_GPIO_Y4_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y3),
102         S5PV310_GPIO_Y5_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y4),
103         S5PV310_GPIO_Y6_START   = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y5),
104         S5PV310_GPIO_Z_START    = S5PV310_GPIO_NEXT(S5PV310_GPIO_Y6),
105 };
106
107 /* S5PV310 GPIO number definitions */
108 #define S5PV310_GPA0(_nr)       (S5PV310_GPIO_A0_START + (_nr))
109 #define S5PV310_GPA1(_nr)       (S5PV310_GPIO_A1_START + (_nr))
110 #define S5PV310_GPB(_nr)        (S5PV310_GPIO_B_START + (_nr))
111 #define S5PV310_GPC0(_nr)       (S5PV310_GPIO_C0_START + (_nr))
112 #define S5PV310_GPC1(_nr)       (S5PV310_GPIO_C1_START + (_nr))
113 #define S5PV310_GPD0(_nr)       (S5PV310_GPIO_D0_START + (_nr))
114 #define S5PV310_GPD1(_nr)       (S5PV310_GPIO_D1_START + (_nr))
115 #define S5PV310_GPE0(_nr)       (S5PV310_GPIO_E0_START + (_nr))
116 #define S5PV310_GPE1(_nr)       (S5PV310_GPIO_E1_START + (_nr))
117 #define S5PV310_GPE2(_nr)       (S5PV310_GPIO_E2_START + (_nr))
118 #define S5PV310_GPE3(_nr)       (S5PV310_GPIO_E3_START + (_nr))
119 #define S5PV310_GPE4(_nr)       (S5PV310_GPIO_E4_START + (_nr))
120 #define S5PV310_GPF0(_nr)       (S5PV310_GPIO_F0_START + (_nr))
121 #define S5PV310_GPF1(_nr)       (S5PV310_GPIO_F1_START + (_nr))
122 #define S5PV310_GPF2(_nr)       (S5PV310_GPIO_F2_START + (_nr))
123 #define S5PV310_GPF3(_nr)       (S5PV310_GPIO_F3_START + (_nr))
124 #define S5PV310_GPJ0(_nr)       (S5PV310_GPIO_J0_START + (_nr))
125 #define S5PV310_GPJ1(_nr)       (S5PV310_GPIO_J1_START + (_nr))
126 #define S5PV310_GPK0(_nr)       (S5PV310_GPIO_K0_START + (_nr))
127 #define S5PV310_GPK1(_nr)       (S5PV310_GPIO_K1_START + (_nr))
128 #define S5PV310_GPK2(_nr)       (S5PV310_GPIO_K2_START + (_nr))
129 #define S5PV310_GPK3(_nr)       (S5PV310_GPIO_K3_START + (_nr))
130 #define S5PV310_GPL0(_nr)       (S5PV310_GPIO_L0_START + (_nr))
131 #define S5PV310_GPL1(_nr)       (S5PV310_GPIO_L1_START + (_nr))
132 #define S5PV310_GPL2(_nr)       (S5PV310_GPIO_L2_START + (_nr))
133 #define S5PV310_GPX0(_nr)       (S5PV310_GPIO_X0_START + (_nr))
134 #define S5PV310_GPX1(_nr)       (S5PV310_GPIO_X1_START + (_nr))
135 #define S5PV310_GPX2(_nr)       (S5PV310_GPIO_X2_START + (_nr))
136 #define S5PV310_GPX3(_nr)       (S5PV310_GPIO_X3_START + (_nr))
137 #define S5PV310_GPY0(_nr)       (S5PV310_GPIO_Y0_START + (_nr))
138 #define S5PV310_GPY1(_nr)       (S5PV310_GPIO_Y1_START + (_nr))
139 #define S5PV310_GPY2(_nr)       (S5PV310_GPIO_Y2_START + (_nr))
140 #define S5PV310_GPY3(_nr)       (S5PV310_GPIO_Y3_START + (_nr))
141 #define S5PV310_GPY4(_nr)       (S5PV310_GPIO_Y4_START + (_nr))
142 #define S5PV310_GPY5(_nr)       (S5PV310_GPIO_Y5_START + (_nr))
143 #define S5PV310_GPY6(_nr)       (S5PV310_GPIO_Y6_START + (_nr))
144 #define S5PV310_GPZ(_nr)        (S5PV310_GPIO_Z_START + (_nr))
145
146 /* the end of the S5PV310 specific gpios */
147 #define S5PV310_GPIO_END        (S5PV310_GPZ(S5PV310_GPIO_Z_NR) + 1)
148 #define S3C_GPIO_END            S5PV310_GPIO_END
149
150 /* define the number of gpios we need to the one after the GPZ() range */
151 #define ARCH_NR_GPIOS           (S5PV310_GPZ(S5PV310_GPIO_Z_NR) +       \
152                                  CONFIG_SAMSUNG_GPIO_EXTRA + 1)
153
154 #define S3C_GPIO_SLP_OUT0       ((__force s3c_gpio_pull_t)0x00)
155 #define S3C_GPIO_SLP_OUT1       ((__force s3c_gpio_pull_t)0x01)
156 #define S3C_GPIO_SLP_INPUT      ((__force s3c_gpio_pull_t)0x02)
157 #define S3C_GPIO_SLP_PREV       ((__force s3c_gpio_pull_t)0x03)
158
159 #define S3C_GPIO_SETPIN_ZERO         0
160 #define S3C_GPIO_SETPIN_ONE          1
161 #define S3C_GPIO_SETPIN_NONE         2
162
163 #define S3C_GPIO_PULL_NONE      ((__force s3c_gpio_pull_t)0x00)
164 #define S3C_GPIO_PULL_DOWN      ((__force s3c_gpio_pull_t)0x01)
165 #define S3C_GPIO_PULL_UP        ((__force s3c_gpio_pull_t)0x03)
166
167 #include <asm-generic/gpio.h>
168
169 #endif /* __ASM_ARCH_GPIO_H */