Tizen 2.0 Release
[platform/kernel/u-boot.git] / arch / arm / include / asm / arch-s5p64xx / gpio.h
1 /*
2  * (C) Copyright 2009 Samsung Electronics
3  * Minkyu Kang <mk7.kang@samsung.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA
19  */
20
21 #ifndef __ASM_ARCH_GPIO_H
22 #define __ASM_ARCH_GPIO_H
23
24 #ifndef __ASSEMBLY__
25 struct s5p_gpio_bank {
26         unsigned int    con;
27         unsigned int    dat;
28         unsigned int    pull;
29         unsigned int    drv;
30         unsigned int    pdn_con;
31         unsigned int    pdn_pull;
32         unsigned char   res1[8];
33 };
34
35 struct s5p6442_gpio {
36         struct s5p_gpio_bank gpio_a0;
37         struct s5p_gpio_bank gpio_a1;
38         struct s5p_gpio_bank gpio_b;
39         struct s5p_gpio_bank gpio_c0;
40         struct s5p_gpio_bank gpio_c1;
41         struct s5p_gpio_bank gpio_d0;
42         struct s5p_gpio_bank gpio_d1;
43         struct s5p_gpio_bank gpio_e0;
44         struct s5p_gpio_bank gpio_e1;
45         struct s5p_gpio_bank gpio_f0;
46         struct s5p_gpio_bank gpio_f1;
47         struct s5p_gpio_bank gpio_f2;
48         struct s5p_gpio_bank gpio_f3;
49         struct s5p_gpio_bank gpio_g0;
50         struct s5p_gpio_bank gpio_g1;
51         struct s5p_gpio_bank gpio_g2;
52         struct s5p_gpio_bank gpio_j0;
53         struct s5p_gpio_bank gpio_j1;
54         struct s5p_gpio_bank gpio_j2;
55         struct s5p_gpio_bank gpio_j3;
56         struct s5p_gpio_bank gpio_j4;
57         struct s5p_gpio_bank gpio_mp0_1;
58         struct s5p_gpio_bank gpio_mp0_2;
59         struct s5p_gpio_bank gpio_mp0_3;
60         struct s5p_gpio_bank gpio_mp0_4;
61         struct s5p_gpio_bank gpio_mp0_5;
62         struct s5p_gpio_bank gpio_mp0_6;
63         struct s5p_gpio_bank gpio_mp0_7;
64         struct s5p_gpio_bank gpio_mp1_0;
65         struct s5p_gpio_bank gpio_mp1_1;
66         struct s5p_gpio_bank gpio_mp1_2;
67         struct s5p_gpio_bank gpio_mp1_3;
68         struct s5p_gpio_bank gpio_mp1_4;
69         struct s5p_gpio_bank gpio_mp1_5;
70         struct s5p_gpio_bank gpio_mp1_6;
71         struct s5p_gpio_bank gpio_mp1_7;
72         struct s5p_gpio_bank gpio_mp1_8;
73         struct s5p_gpio_bank res1[59];
74         struct s5p_gpio_bank gpio_h0;
75         struct s5p_gpio_bank gpio_h1;
76         struct s5p_gpio_bank gpio_h2;
77         struct s5p_gpio_bank gpio_h3;
78 };
79
80 /* functions */
81 void gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg);
82 void gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int enable);
83 void gpio_direction_input(struct s5p_gpio_bank *bank, int gpio);
84 void gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int enable);
85 unsigned int gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
86 void gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
87 void gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
88 void gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
89 #endif
90
91 /* Pin configurations */
92 #define GPIO_INPUT      0x0
93 #define GPIO_OUTPUT     0x1
94 #define GPIO_IRQ        0xf
95 #define GPIO_FUNC(x)    (x)
96
97 /* Pull mode */
98 #define GPIO_PULL_NONE  0x0
99 #define GPIO_PULL_DOWN  0x1
100 #define GPIO_PULL_UP    0x2
101
102 /* Drive Strength level */
103 #define GPIO_DRV_1x     0x0
104 #define GPIO_DRV_2x     0x1
105 #define GPIO_DRV_3x     0x2
106 #define GPIO_DRV_4x     0x3
107 #define GPIO_DRV_FAST   0x0
108 #define GPIO_DRV_SLOW   0x1
109
110 #endif