Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gpio-cfg.h
Go to the documentation of this file.
1 /* linux/arch/arm/plat-s3c/include/plat/gpio-cfg.h
2  *
3  * Copyright 2008 Openmoko, Inc.
4  * Copyright 2008 Simtec Electronics
5  * http://armlinux.simtec.co.uk/
6  * Ben Dooks <[email protected]>
7  *
8  * S3C Platform - GPIO pin configuration
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13 */
14 
15 /* This file contains the necessary definitions to get the basic gpio
16  * pin configuration done such as setting a pin to input or output or
17  * changing the pull-{up,down} configurations.
18  */
19 
20 /* Note, this interface is being added to the s3c64xx arch first and will
21  * be added to the s3c24xx systems later.
22  */
23 
24 #ifndef __PLAT_GPIO_CFG_H
25 #define __PLAT_GPIO_CFG_H __FILE__
26 
27 #include <linux/types.h>
28 
29 typedef unsigned int __bitwise__ samsung_gpio_pull_t;
30 typedef unsigned int __bitwise__ s5p_gpio_drvstr_t;
31 
32 /* forward declaration if gpio-core.h hasn't been included */
33 struct samsung_gpio_chip;
34 
55  unsigned int cfg_eint;
56 
58  int (*set_pull)(struct samsung_gpio_chip *chip, unsigned offs,
60 
61  unsigned (*get_config)(struct samsung_gpio_chip *chip, unsigned offs);
62  int (*set_config)(struct samsung_gpio_chip *chip, unsigned offs,
63  unsigned config);
64 };
65 
66 #define S3C_GPIO_SPECIAL_MARK (0xfffffff0)
67 #define S3C_GPIO_SPECIAL(x) (S3C_GPIO_SPECIAL_MARK | (x))
68 
69 /* Defines for generic pin configurations */
70 #define S3C_GPIO_INPUT (S3C_GPIO_SPECIAL(0))
71 #define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1))
72 #define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x))
73 
74 #define samsung_gpio_is_cfg_special(_cfg) \
75  (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK)
76 
100 extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);
101 
111 extern unsigned s3c_gpio_getcfg(unsigned int pin);
112 
123 extern int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr,
124  unsigned int cfg);
125 
126 /* Define values for the pull-{up,down} available for each gpio pin.
127  *
128  * These values control the state of the weak pull-{up,down} resistors
129  * available on most pins on the S3C series. Not all chips support both
130  * up or down settings, and it may be dependent on the chip that is being
131  * used to whether the particular mode is available.
132  */
133 #define S3C_GPIO_PULL_NONE ((__force samsung_gpio_pull_t)0x00)
134 #define S3C_GPIO_PULL_DOWN ((__force samsung_gpio_pull_t)0x01)
135 #define S3C_GPIO_PULL_UP ((__force samsung_gpio_pull_t)0x02)
136 
148 extern int s3c_gpio_setpull(unsigned int pin, samsung_gpio_pull_t pull);
149 
156 extern samsung_gpio_pull_t s3c_gpio_getpull(unsigned int pin);
157 
158 /* configure `all` aspects of an gpio */
159 
174 extern int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr,
175  unsigned int cfg, samsung_gpio_pull_t pull);
176 
177 static inline int s3c_gpio_cfgrange_nopull(unsigned int pin, unsigned int size,
178  unsigned int cfg)
179 {
180  return s3c_gpio_cfgall_range(pin, size, cfg, S3C_GPIO_PULL_NONE);
181 }
182 
183 /* Define values for the drvstr available for each gpio pin.
184  *
185  * These values control the value of the output signal driver strength,
186  * configurable on most pins on the S5P series.
187  */
188 #define S5P_GPIO_DRVSTR_LV1 ((__force s5p_gpio_drvstr_t)0x0)
189 #define S5P_GPIO_DRVSTR_LV2 ((__force s5p_gpio_drvstr_t)0x2)
190 #define S5P_GPIO_DRVSTR_LV3 ((__force s5p_gpio_drvstr_t)0x1)
191 #define S5P_GPIO_DRVSTR_LV4 ((__force s5p_gpio_drvstr_t)0x3)
192 
199 extern s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin);
200 
210 extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr);
211 
228 extern int s5p_register_gpio_interrupt(int pin);
229 
240 #ifdef CONFIG_S5P_GPIO_INT
241 extern int s5p_register_gpioint_bank(int chain_irq, int start, int nr_groups);
242 #else
243 #define s5p_register_gpioint_bank(chain_irq, start, nr_groups) do { } while (0)
244 #endif
245 
246 #endif /* __PLAT_GPIO_CFG_H */