1 /* linux/arch/arm/plat-s3c/include/plat/gpio-cfg-helper.h
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * http://armlinux.simtec.co.uk/
6 * Ben Dooks <ben@simtec.co.uk>
8 * S3C Platform - GPIO pin configuration helper definitions
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.
15 /* This is meant for core cpu support, machine or other driver files
16 * should not be including this header.
19 #ifndef __PLAT_GPIO_CFG_HELPERS_H
20 #define __PLAT_GPIO_CFG_HELPERS_H __FILE__
22 /* As a note, all gpio configuration functions are entered exclusively, either
23 * with the relevant lock held or the system prevented from doing anything else
24 * by disabling interrupts.
27 static inline int s3c_gpio_do_setcfg(struct s3c_gpio_chip
*chip
,
28 unsigned int off
, unsigned int config
)
30 return (chip
->config
->set_config
)(chip
, off
, config
);
33 static inline unsigned s3c_gpio_do_getcfg(struct s3c_gpio_chip
*chip
,
36 return (chip
->config
->get_config
)(chip
, off
);
39 static inline int s3c_gpio_do_setpull(struct s3c_gpio_chip
*chip
,
40 unsigned int off
, s3c_gpio_pull_t pull
)
42 return (chip
->config
->set_pull
)(chip
, off
, pull
);
45 static inline s3c_gpio_pull_t
s3c_gpio_do_getpull(struct s3c_gpio_chip
*chip
,
48 return chip
->config
->get_pull(chip
, off
);
52 * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration.
53 * @chip: The gpio chip that is being configured.
54 * @off: The offset for the GPIO being configured.
55 * @cfg: The configuration value to set.
57 * This helper deal with the GPIO cases where the control register
58 * has two bits of configuration per gpio, which have the following
62 * 1x = special function
64 extern int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip
*chip
,
65 unsigned int off
, unsigned int cfg
);
68 * s3c_gpio_getcfg_s3c24xx - S3C24XX style GPIO configuration read.
69 * @chip: The gpio chip that is being configured.
70 * @off: The offset for the GPIO being configured.
72 * The reverse of s3c_gpio_setcfg_s3c24xx(). Will return a value whicg
73 * could be directly passed back to s3c_gpio_setcfg_s3c24xx(), from the
74 * S3C_GPIO_SPECIAL() macro.
76 unsigned int s3c_gpio_getcfg_s3c24xx(struct s3c_gpio_chip
*chip
,
80 * s3c_gpio_setcfg_s3c24xx_a - S3C24XX style GPIO configuration (Bank A)
81 * @chip: The gpio chip that is being configured.
82 * @off: The offset for the GPIO being configured.
83 * @cfg: The configuration value to set.
85 * This helper deal with the GPIO cases where the control register
86 * has one bit of configuration for the gpio, where setting the bit
87 * means the pin is in special function mode and unset means output.
89 extern int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip
*chip
,
90 unsigned int off
, unsigned int cfg
);
94 * s3c_gpio_getcfg_s3c24xx_a - S3C24XX style GPIO configuration read (Bank A)
95 * @chip: The gpio chip that is being configured.
96 * @off: The offset for the GPIO being configured.
98 * The reverse of s3c_gpio_setcfg_s3c24xx_a() turning an GPIO into a usable
99 * GPIO configuration value.
101 * @sa s3c_gpio_getcfg_s3c24xx
102 * @sa s3c_gpio_getcfg_s3c64xx_4bit
104 extern unsigned s3c_gpio_getcfg_s3c24xx_a(struct s3c_gpio_chip
*chip
,
108 * s3c_gpio_setcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config.
109 * @chip: The gpio chip that is being configured.
110 * @off: The offset for the GPIO being configured.
111 * @cfg: The configuration value to set.
113 * This helper deal with the GPIO cases where the control register has 4 bits
114 * of control per GPIO, generally in the form of:
117 * others = Special functions (dependent on bank)
119 * Note, since the code to deal with the case where there are two control
120 * registers instead of one, we do not have a separate set of functions for
123 extern int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip
*chip
,
124 unsigned int off
, unsigned int cfg
);
128 * s3c_gpio_getcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config read.
129 * @chip: The gpio chip that is being configured.
130 * @off: The offset for the GPIO being configured.
132 * The reverse of s3c_gpio_setcfg_s3c64xx_4bit(), turning a gpio configuration
133 * register setting into a value the software can use, such as could be passed
134 * to s3c_gpio_setcfg_s3c64xx_4bit().
136 * @sa s3c_gpio_getcfg_s3c24xx
138 extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip
*chip
,
141 /* Pull-{up,down} resistor controls.
143 * S3C2410,S3C2440,S3C24A0 = Pull-UP,
144 * S3C2412,S3C2413 = Pull-Down
145 * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
146 * S3C2443 = Pull-Both [not same as S3C6400]
150 * s3c_gpio_setpull_1up() - Pull configuration for choice of up or none.
151 * @chip: The gpio chip that is being configured.
152 * @off: The offset for the GPIO being configured.
153 * @param: pull: The pull mode being requested.
155 * This is a helper function for the case where we have GPIOs with one
156 * bit configuring the presence of a pull-up resistor.
158 extern int s3c_gpio_setpull_1up(struct s3c_gpio_chip
*chip
,
159 unsigned int off
, s3c_gpio_pull_t pull
);
162 * s3c_gpio_setpull_1down() - Pull configuration for choice of down or none
163 * @chip: The gpio chip that is being configured
164 * @off: The offset for the GPIO being configured
165 * @param: pull: The pull mode being requested
167 * This is a helper function for the case where we have GPIOs with one
168 * bit configuring the presence of a pull-down resistor.
170 extern int s3c_gpio_setpull_1down(struct s3c_gpio_chip
*chip
,
171 unsigned int off
, s3c_gpio_pull_t pull
);
174 * s3c_gpio_setpull_upown() - Pull configuration for choice of up, down or none
175 * @chip: The gpio chip that is being configured.
176 * @off: The offset for the GPIO being configured.
177 * @param: pull: The pull mode being requested.
179 * This is a helper function for the case where we have GPIOs with two
180 * bits configuring the presence of a pull resistor, in the following
182 * 00 = No pull resistor connected
183 * 01 = Pull-up resistor connected
184 * 10 = Pull-down resistor connected
186 extern int s3c_gpio_setpull_updown(struct s3c_gpio_chip
*chip
,
187 unsigned int off
, s3c_gpio_pull_t pull
);
191 * s3c_gpio_getpull_updown() - Get configuration for choice of up, down or none
192 * @chip: The gpio chip that the GPIO pin belongs to
193 * @off: The offset to the pin to get the configuration of.
195 * This helper function reads the state of the pull-{up,down} resistor for the
196 * given GPIO in the same case as s3c_gpio_setpull_upown.
198 extern s3c_gpio_pull_t
s3c_gpio_getpull_updown(struct s3c_gpio_chip
*chip
,
202 * s3c_gpio_getpull_1up() - Get configuration for choice of up or none
203 * @chip: The gpio chip that the GPIO pin belongs to
204 * @off: The offset to the pin to get the configuration of.
206 * This helper function reads the state of the pull-up resistor for the
207 * given GPIO in the same case as s3c_gpio_setpull_1up.
209 extern s3c_gpio_pull_t
s3c_gpio_getpull_1up(struct s3c_gpio_chip
*chip
,
213 * s3c_gpio_getpull_1down() - Get configuration for choice of down or none
214 * @chip: The gpio chip that the GPIO pin belongs to
215 * @off: The offset to the pin to get the configuration of.
217 * This helper function reads the state of the pull-down resistor for the
218 * given GPIO in the same case as s3c_gpio_setpull_1down.
220 extern s3c_gpio_pull_t
s3c_gpio_getpull_1down(struct s3c_gpio_chip
*chip
,
224 * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443.
225 * @chip: The gpio chip that is being configured.
226 * @off: The offset for the GPIO being configured.
227 * @param: pull: The pull mode being requested.
229 * This is a helper function for the case where we have GPIOs with two
230 * bits configuring the presence of a pull resistor, in the following
232 * 00 = Pull-up resistor connected
233 * 10 = Pull-down resistor connected
234 * x1 = No pull up resistor
236 extern int s3c_gpio_setpull_s3c2443(struct s3c_gpio_chip
*chip
,
237 unsigned int off
, s3c_gpio_pull_t pull
);
240 * s3c_gpio_getpull_s3c2443() - Get configuration for s3c2443 pull resistors
241 * @chip: The gpio chip that the GPIO pin belongs to.
242 * @off: The offset to the pin to get the configuration of.
244 * This helper function reads the state of the pull-{up,down} resistor for the
245 * given GPIO in the same case as s3c_gpio_setpull_upown.
247 extern s3c_gpio_pull_t
s3c_gpio_getpull_s3c2443(struct s3c_gpio_chip
*chip
,
250 #endif /* __PLAT_GPIO_CFG_HELPERS_H */