]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-s5pc1xx/gpio.h
Merge branch 'master' of git://git.denx.de/u-boot-nds32
[karo-tx-uboot.git] / arch / arm / include / asm / arch-s5pc1xx / gpio.h
1 /*
2  * (C) Copyright 2009 Samsung Electronics
3  * Minkyu Kang <mk7.kang@samsung.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #ifndef __ASM_ARCH_GPIO_H
9 #define __ASM_ARCH_GPIO_H
10
11 #ifndef __ASSEMBLY__
12 struct s5p_gpio_bank {
13         unsigned int    con;
14         unsigned int    dat;
15         unsigned int    pull;
16         unsigned int    drv;
17         unsigned int    pdn_con;
18         unsigned int    pdn_pull;
19         unsigned char   res1[8];
20 };
21
22 struct s5pc100_gpio {
23         struct s5p_gpio_bank a0;
24         struct s5p_gpio_bank a1;
25         struct s5p_gpio_bank b;
26         struct s5p_gpio_bank c;
27         struct s5p_gpio_bank d;
28         struct s5p_gpio_bank e0;
29         struct s5p_gpio_bank e1;
30         struct s5p_gpio_bank f0;
31         struct s5p_gpio_bank f1;
32         struct s5p_gpio_bank f2;
33         struct s5p_gpio_bank f3;
34         struct s5p_gpio_bank g0;
35         struct s5p_gpio_bank g1;
36         struct s5p_gpio_bank g2;
37         struct s5p_gpio_bank g3;
38         struct s5p_gpio_bank i;
39         struct s5p_gpio_bank j0;
40         struct s5p_gpio_bank j1;
41         struct s5p_gpio_bank j2;
42         struct s5p_gpio_bank j3;
43         struct s5p_gpio_bank j4;
44         struct s5p_gpio_bank k0;
45         struct s5p_gpio_bank k1;
46         struct s5p_gpio_bank k2;
47         struct s5p_gpio_bank k3;
48         struct s5p_gpio_bank l0;
49         struct s5p_gpio_bank l1;
50         struct s5p_gpio_bank l2;
51         struct s5p_gpio_bank l3;
52         struct s5p_gpio_bank l4;
53         struct s5p_gpio_bank h0;
54         struct s5p_gpio_bank h1;
55         struct s5p_gpio_bank h2;
56         struct s5p_gpio_bank h3;
57 };
58
59 struct s5pc110_gpio {
60         struct s5p_gpio_bank a0;
61         struct s5p_gpio_bank a1;
62         struct s5p_gpio_bank b;
63         struct s5p_gpio_bank c0;
64         struct s5p_gpio_bank c1;
65         struct s5p_gpio_bank d0;
66         struct s5p_gpio_bank d1;
67         struct s5p_gpio_bank e0;
68         struct s5p_gpio_bank e1;
69         struct s5p_gpio_bank f0;
70         struct s5p_gpio_bank f1;
71         struct s5p_gpio_bank f2;
72         struct s5p_gpio_bank f3;
73         struct s5p_gpio_bank g0;
74         struct s5p_gpio_bank g1;
75         struct s5p_gpio_bank g2;
76         struct s5p_gpio_bank g3;
77         struct s5p_gpio_bank i;
78         struct s5p_gpio_bank j0;
79         struct s5p_gpio_bank j1;
80         struct s5p_gpio_bank j2;
81         struct s5p_gpio_bank j3;
82         struct s5p_gpio_bank j4;
83         struct s5p_gpio_bank mp0_1;
84         struct s5p_gpio_bank mp0_2;
85         struct s5p_gpio_bank mp0_3;
86         struct s5p_gpio_bank mp0_4;
87         struct s5p_gpio_bank mp0_5;
88         struct s5p_gpio_bank mp0_6;
89         struct s5p_gpio_bank mp0_7;
90         struct s5p_gpio_bank mp1_0;
91         struct s5p_gpio_bank mp1_1;
92         struct s5p_gpio_bank mp1_2;
93         struct s5p_gpio_bank mp1_3;
94         struct s5p_gpio_bank mp1_4;
95         struct s5p_gpio_bank mp1_5;
96         struct s5p_gpio_bank mp1_6;
97         struct s5p_gpio_bank mp1_7;
98         struct s5p_gpio_bank mp1_8;
99         struct s5p_gpio_bank mp2_0;
100         struct s5p_gpio_bank mp2_1;
101         struct s5p_gpio_bank mp2_2;
102         struct s5p_gpio_bank mp2_3;
103         struct s5p_gpio_bank mp2_4;
104         struct s5p_gpio_bank mp2_5;
105         struct s5p_gpio_bank mp2_6;
106         struct s5p_gpio_bank mp2_7;
107         struct s5p_gpio_bank mp2_8;
108         struct s5p_gpio_bank res1[48];
109         struct s5p_gpio_bank h0;
110         struct s5p_gpio_bank h1;
111         struct s5p_gpio_bank h2;
112         struct s5p_gpio_bank h3;
113 };
114
115 /* functions */
116 void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg);
117 void s5p_gpio_direction_output(struct s5p_gpio_bank *bank, int gpio, int en);
118 void s5p_gpio_direction_input(struct s5p_gpio_bank *bank, int gpio);
119 void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en);
120 unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio);
121 void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode);
122 void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode);
123 void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode);
124
125 /* GPIO pins per bank  */
126 #define GPIO_PER_BANK 8
127
128 static inline unsigned int s5p_gpio_base(int nr)
129 {
130         return S5PC110_GPIO_BASE;
131 }
132
133 static inline unsigned int s5p_gpio_part_max(int nr)
134 {
135         return 0;
136 }
137
138 #define s5pc110_gpio_get_nr(bank, pin)    \
139         ((((((unsigned int)&(((struct s5pc110_gpio *)S5PC110_GPIO_BASE)->bank))\
140             - S5PC110_GPIO_BASE) / sizeof(struct s5p_gpio_bank)) \
141           * GPIO_PER_BANK) + pin)
142 #endif
143
144 /* Pin configurations */
145 #define GPIO_INPUT      0x0
146 #define GPIO_OUTPUT     0x1
147 #define GPIO_IRQ        0xf
148 #define GPIO_FUNC(x)    (x)
149
150 /* Pull mode */
151 #define GPIO_PULL_NONE  0x0
152 #define GPIO_PULL_DOWN  0x1
153 #define GPIO_PULL_UP    0x2
154
155 /* Drive Strength level */
156 #define GPIO_DRV_1X     0x0
157 #define GPIO_DRV_3X     0x1
158 #define GPIO_DRV_2X     0x2
159 #define GPIO_DRV_4X     0x3
160 #define GPIO_DRV_FAST   0x0
161 #define GPIO_DRV_SLOW   0x1
162
163 #endif