• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/arch/arm/plat-samsung/include/plat/
1/* linux/arch/arm/plat-s3c/include/plat/gpio-cfg-helper.h
2 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 *	http://armlinux.simtec.co.uk/
6 *	Ben Dooks <ben@simtec.co.uk>
7 *
8 * S3C Platform - GPIO pin configuration helper definitions
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 is meant for core cpu support, machine or other driver files
16 * should not be including this header.
17 */
18
19#ifndef __PLAT_GPIO_CFG_HELPERS_H
20#define __PLAT_GPIO_CFG_HELPERS_H __FILE__
21
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.
25*/
26
27static inline int s3c_gpio_do_setcfg(struct s3c_gpio_chip *chip,
28				     unsigned int off, unsigned int config)
29{
30	return (chip->config->set_config)(chip, off, config);
31}
32
33static inline unsigned s3c_gpio_do_getcfg(struct s3c_gpio_chip *chip,
34					  unsigned int off)
35{
36	return (chip->config->get_config)(chip, off);
37}
38
39static inline int s3c_gpio_do_setpull(struct s3c_gpio_chip *chip,
40				      unsigned int off, s3c_gpio_pull_t pull)
41{
42	return (chip->config->set_pull)(chip, off, pull);
43}
44
45/**
46 * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration.
47 * @chip: The gpio chip that is being configured.
48 * @off: The offset for the GPIO being configured.
49 * @cfg: The configuration value to set.
50 *
51 * This helper deal with the GPIO cases where the control register
52 * has two bits of configuration per gpio, which have the following
53 * functions:
54 *	00 = input
55 *	01 = output
56 *	1x = special function
57*/
58extern int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip *chip,
59				   unsigned int off, unsigned int cfg);
60
61/**
62 * s3c_gpio_getcfg_s3c24xx - S3C24XX style GPIO configuration read.
63 * @chip: The gpio chip that is being configured.
64 * @off: The offset for the GPIO being configured.
65 *
66 * The reverse of s3c_gpio_setcfg_s3c24xx(). Will return a value whicg
67 * could be directly passed back to s3c_gpio_setcfg_s3c24xx(), from the
68 * S3C_GPIO_SPECIAL() macro.
69 */
70unsigned int s3c_gpio_getcfg_s3c24xx(struct s3c_gpio_chip *chip,
71				     unsigned int off);
72
73/**
74 * s3c_gpio_setcfg_s3c24xx_a - S3C24XX style GPIO configuration (Bank A)
75 * @chip: The gpio chip that is being configured.
76 * @off: The offset for the GPIO being configured.
77 * @cfg: The configuration value to set.
78 *
79 * This helper deal with the GPIO cases where the control register
80 * has one bit of configuration for the gpio, where setting the bit
81 * means the pin is in special function mode and unset means output.
82*/
83extern int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip,
84				     unsigned int off, unsigned int cfg);
85
86
87/**
88 * s3c_gpio_getcfg_s3c24xx_a - S3C24XX style GPIO configuration read (Bank A)
89 * @chip: The gpio chip that is being configured.
90 * @off: The offset for the GPIO being configured.
91 *
92 * The reverse of s3c_gpio_setcfg_s3c24xx_a() turning an GPIO into a usable
93 * GPIO configuration value.
94 *
95 * @sa s3c_gpio_getcfg_s3c24xx
96 * @sa s3c_gpio_getcfg_s3c64xx_4bit
97 */
98extern unsigned s3c_gpio_getcfg_s3c24xx_a(struct s3c_gpio_chip *chip,
99					  unsigned int off);
100
101/**
102 * s3c_gpio_setcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config.
103 * @chip: The gpio chip that is being configured.
104 * @off: The offset for the GPIO being configured.
105 * @cfg: The configuration value to set.
106 *
107 * This helper deal with the GPIO cases where the control register has 4 bits
108 * of control per GPIO, generally in the form of:
109 *	0000 = Input
110 *	0001 = Output
111 *	others = Special functions (dependant on bank)
112 *
113 * Note, since the code to deal with the case where there are two control
114 * registers instead of one, we do not have a separate set of functions for
115 * each case.
116*/
117extern int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip,
118					unsigned int off, unsigned int cfg);
119
120
121/**
122 * s3c_gpio_getcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config read.
123 * @chip: The gpio chip that is being configured.
124 * @off: The offset for the GPIO being configured.
125 *
126 * The reverse of s3c_gpio_setcfg_s3c64xx_4bit(), turning a gpio configuration
127 * register setting into a value the software can use, such as could be passed
128 * to s3c_gpio_setcfg_s3c64xx_4bit().
129 *
130 * @sa s3c_gpio_getcfg_s3c24xx
131 */
132extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip,
133					     unsigned int off);
134
135/* Pull-{up,down} resistor controls.
136 *
137 * S3C2410,S3C2440,S3C24A0 = Pull-UP,
138 * S3C2412,S3C2413 = Pull-Down
139 * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
140 * S3C2443 = Pull-Both [not same as S3C6400]
141 */
142
143/**
144 * s3c_gpio_setpull_1up() - Pull configuration for choice of up or none.
145 * @chip: The gpio chip that is being configured.
146 * @off: The offset for the GPIO being configured.
147 * @param: pull: The pull mode being requested.
148 *
149 * This is a helper function for the case where we have GPIOs with one
150 * bit configuring the presence of a pull-up resistor.
151 */
152extern int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip,
153				unsigned int off, s3c_gpio_pull_t pull);
154
155/**
156 * s3c_gpio_setpull_1down() - Pull configuration for choice of down or none
157 * @chip: The gpio chip that is being configured
158 * @off: The offset for the GPIO being configured
159 * @param: pull: The pull mode being requested
160 *
161 * This is a helper function for the case where we have GPIOs with one
162 * bit configuring the presence of a pull-down resistor.
163 */
164extern int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip,
165				  unsigned int off, s3c_gpio_pull_t pull);
166
167/**
168 * s3c_gpio_setpull_upown() - Pull configuration for choice of up, down or none
169 * @chip: The gpio chip that is being configured.
170 * @off: The offset for the GPIO being configured.
171 * @param: pull: The pull mode being requested.
172 *
173 * This is a helper function for the case where we have GPIOs with two
174 * bits configuring the presence of a pull resistor, in the following
175 * order:
176 *	00 = No pull resistor connected
177 *	01 = Pull-up resistor connected
178 *	10 = Pull-down resistor connected
179 */
180extern int s3c_gpio_setpull_updown(struct s3c_gpio_chip *chip,
181				   unsigned int off, s3c_gpio_pull_t pull);
182
183
184/**
185 * s3c_gpio_getpull_updown() - Get configuration for choice of up, down or none
186 * @chip: The gpio chip that the GPIO pin belongs to
187 * @off: The offset to the pin to get the configuration of.
188 *
189 * This helper function reads the state of the pull-{up,down} resistor for the
190 * given GPIO in the same case as s3c_gpio_setpull_upown.
191*/
192extern s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip,
193					       unsigned int off);
194
195/**
196 * s3c_gpio_getpull_1up() - Get configuration for choice of up or none
197 * @chip: The gpio chip that the GPIO pin belongs to
198 * @off: The offset to the pin to get the configuration of.
199 *
200 * This helper function reads the state of the pull-up resistor for the
201 * given GPIO in the same case as s3c_gpio_setpull_1up.
202*/
203extern s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip,
204					    unsigned int off);
205
206/**
207 * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443.
208 * @chip: The gpio chip that is being configured.
209 * @off: The offset for the GPIO being configured.
210 * @param: pull: The pull mode being requested.
211 *
212 * This is a helper function for the case where we have GPIOs with two
213 * bits configuring the presence of a pull resistor, in the following
214 * order:
215 *	00 = Pull-up resistor connected
216 *	10 = Pull-down resistor connected
217 *	x1 = No pull up resistor
218 */
219extern int s3c_gpio_setpull_s3c2443(struct s3c_gpio_chip *chip,
220				    unsigned int off, s3c_gpio_pull_t pull);
221
222/**
223 * s3c_gpio_getpull_s3c2443() - Get configuration for s3c2443 pull resistors
224 * @chip: The gpio chip that the GPIO pin belongs to.
225 * @off: The offset to the pin to get the configuration of.
226 *
227 * This helper function reads the state of the pull-{up,down} resistor for the
228 * given GPIO in the same case as s3c_gpio_setpull_upown.
229*/
230extern s3c_gpio_pull_t s3c_gpio_getpull_s3c24xx(struct s3c_gpio_chip *chip,
231						unsigned int off);
232
233#endif /* __PLAT_GPIO_CFG_HELPERS_H */
234