1c6ff132dSArnd Bergmann /* SPDX-License-Identifier: GPL-2.0 */
2c6ff132dSArnd Bergmann /*
3c6ff132dSArnd Bergmann  * Copyright 2008 Openmoko, Inc.
4c6ff132dSArnd Bergmann  * Copyright 2008 Simtec Electronics
5c6ff132dSArnd Bergmann  *	http://armlinux.simtec.co.uk/
6c6ff132dSArnd Bergmann  *	Ben Dooks <ben@simtec.co.uk>
7c6ff132dSArnd Bergmann  *
8c6ff132dSArnd Bergmann  * S3C6400 - GPIO lib support
9c6ff132dSArnd Bergmann  */
10c6ff132dSArnd Bergmann 
11c6ff132dSArnd Bergmann #ifndef GPIO_SAMSUNG_S3C64XX_H
12c6ff132dSArnd Bergmann #define GPIO_SAMSUNG_S3C64XX_H
13c6ff132dSArnd Bergmann 
14c6ff132dSArnd Bergmann #ifdef CONFIG_GPIO_SAMSUNG
15c6ff132dSArnd Bergmann 
16c6ff132dSArnd Bergmann /* GPIO bank sizes */
17c6ff132dSArnd Bergmann #define S3C64XX_GPIO_A_NR	(8)
18c6ff132dSArnd Bergmann #define S3C64XX_GPIO_B_NR	(7)
19c6ff132dSArnd Bergmann #define S3C64XX_GPIO_C_NR	(8)
20c6ff132dSArnd Bergmann #define S3C64XX_GPIO_D_NR	(5)
21c6ff132dSArnd Bergmann #define S3C64XX_GPIO_E_NR	(5)
22c6ff132dSArnd Bergmann #define S3C64XX_GPIO_F_NR	(16)
23c6ff132dSArnd Bergmann #define S3C64XX_GPIO_G_NR	(7)
24c6ff132dSArnd Bergmann #define S3C64XX_GPIO_H_NR	(10)
25c6ff132dSArnd Bergmann #define S3C64XX_GPIO_I_NR	(16)
26c6ff132dSArnd Bergmann #define S3C64XX_GPIO_J_NR	(12)
27c6ff132dSArnd Bergmann #define S3C64XX_GPIO_K_NR	(16)
28c6ff132dSArnd Bergmann #define S3C64XX_GPIO_L_NR	(15)
29c6ff132dSArnd Bergmann #define S3C64XX_GPIO_M_NR	(6)
30c6ff132dSArnd Bergmann #define S3C64XX_GPIO_N_NR	(16)
31c6ff132dSArnd Bergmann #define S3C64XX_GPIO_O_NR	(16)
32c6ff132dSArnd Bergmann #define S3C64XX_GPIO_P_NR	(15)
33c6ff132dSArnd Bergmann #define S3C64XX_GPIO_Q_NR	(9)
34c6ff132dSArnd Bergmann 
35c6ff132dSArnd Bergmann /* GPIO bank numbes */
36c6ff132dSArnd Bergmann 
37c6ff132dSArnd Bergmann /* CONFIG_S3C_GPIO_SPACE allows the user to select extra
38c6ff132dSArnd Bergmann  * space for debugging purposes so that any accidental
39c6ff132dSArnd Bergmann  * change from one gpio bank to another can be caught.
40c6ff132dSArnd Bergmann */
41c6ff132dSArnd Bergmann 
42c6ff132dSArnd Bergmann #define S3C64XX_GPIO_NEXT(__gpio) \
43c6ff132dSArnd Bergmann 	((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
44c6ff132dSArnd Bergmann 
45c6ff132dSArnd Bergmann enum s3c_gpio_number {
46c6ff132dSArnd Bergmann 	S3C64XX_GPIO_A_START = 0,
47c6ff132dSArnd Bergmann 	S3C64XX_GPIO_B_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_A),
48c6ff132dSArnd Bergmann 	S3C64XX_GPIO_C_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_B),
49c6ff132dSArnd Bergmann 	S3C64XX_GPIO_D_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_C),
50c6ff132dSArnd Bergmann 	S3C64XX_GPIO_E_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_D),
51c6ff132dSArnd Bergmann 	S3C64XX_GPIO_F_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_E),
52c6ff132dSArnd Bergmann 	S3C64XX_GPIO_G_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_F),
53c6ff132dSArnd Bergmann 	S3C64XX_GPIO_H_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_G),
54c6ff132dSArnd Bergmann 	S3C64XX_GPIO_I_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_H),
55c6ff132dSArnd Bergmann 	S3C64XX_GPIO_J_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_I),
56c6ff132dSArnd Bergmann 	S3C64XX_GPIO_K_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_J),
57c6ff132dSArnd Bergmann 	S3C64XX_GPIO_L_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_K),
58c6ff132dSArnd Bergmann 	S3C64XX_GPIO_M_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_L),
59c6ff132dSArnd Bergmann 	S3C64XX_GPIO_N_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_M),
60c6ff132dSArnd Bergmann 	S3C64XX_GPIO_O_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_N),
61c6ff132dSArnd Bergmann 	S3C64XX_GPIO_P_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_O),
62c6ff132dSArnd Bergmann 	S3C64XX_GPIO_Q_START = S3C64XX_GPIO_NEXT(S3C64XX_GPIO_P),
63c6ff132dSArnd Bergmann };
64c6ff132dSArnd Bergmann 
65c6ff132dSArnd Bergmann /* S3C64XX GPIO number definitions. */
66c6ff132dSArnd Bergmann 
67c6ff132dSArnd Bergmann #define S3C64XX_GPA(_nr)	(S3C64XX_GPIO_A_START + (_nr))
68c6ff132dSArnd Bergmann #define S3C64XX_GPB(_nr)	(S3C64XX_GPIO_B_START + (_nr))
69c6ff132dSArnd Bergmann #define S3C64XX_GPC(_nr)	(S3C64XX_GPIO_C_START + (_nr))
70c6ff132dSArnd Bergmann #define S3C64XX_GPD(_nr)	(S3C64XX_GPIO_D_START + (_nr))
71c6ff132dSArnd Bergmann #define S3C64XX_GPE(_nr)	(S3C64XX_GPIO_E_START + (_nr))
72c6ff132dSArnd Bergmann #define S3C64XX_GPF(_nr)	(S3C64XX_GPIO_F_START + (_nr))
73c6ff132dSArnd Bergmann #define S3C64XX_GPG(_nr)	(S3C64XX_GPIO_G_START + (_nr))
74c6ff132dSArnd Bergmann #define S3C64XX_GPH(_nr)	(S3C64XX_GPIO_H_START + (_nr))
75c6ff132dSArnd Bergmann #define S3C64XX_GPI(_nr)	(S3C64XX_GPIO_I_START + (_nr))
76c6ff132dSArnd Bergmann #define S3C64XX_GPJ(_nr)	(S3C64XX_GPIO_J_START + (_nr))
77c6ff132dSArnd Bergmann #define S3C64XX_GPK(_nr)	(S3C64XX_GPIO_K_START + (_nr))
78c6ff132dSArnd Bergmann #define S3C64XX_GPL(_nr)	(S3C64XX_GPIO_L_START + (_nr))
79c6ff132dSArnd Bergmann #define S3C64XX_GPM(_nr)	(S3C64XX_GPIO_M_START + (_nr))
80c6ff132dSArnd Bergmann #define S3C64XX_GPN(_nr)	(S3C64XX_GPIO_N_START + (_nr))
81c6ff132dSArnd Bergmann #define S3C64XX_GPO(_nr)	(S3C64XX_GPIO_O_START + (_nr))
82c6ff132dSArnd Bergmann #define S3C64XX_GPP(_nr)	(S3C64XX_GPIO_P_START + (_nr))
83c6ff132dSArnd Bergmann #define S3C64XX_GPQ(_nr)	(S3C64XX_GPIO_Q_START + (_nr))
84c6ff132dSArnd Bergmann 
85c6ff132dSArnd Bergmann /* the end of the S3C64XX specific gpios */
86c6ff132dSArnd Bergmann #define S3C64XX_GPIO_END	(S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1)
87c6ff132dSArnd Bergmann #define S3C_GPIO_END		S3C64XX_GPIO_END
88c6ff132dSArnd Bergmann 
89c6ff132dSArnd Bergmann /* define the number of gpios we need to the one after the GPQ() range */
90c6ff132dSArnd Bergmann #define GPIO_BOARD_START (S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1)
91c6ff132dSArnd Bergmann 
92c6ff132dSArnd Bergmann #endif /* GPIO_SAMSUNG */
93c6ff132dSArnd Bergmann #endif /* GPIO_SAMSUNG_S3C64XX_H */
94c6ff132dSArnd Bergmann 
95