ARM: SAMSUNG: Add GPIO configuration read calls
[deliverable/linux.git] / arch / arm / plat-samsung / include / plat / gpio-cfg-helpers.h
CommitLineData
21b23664
BD
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 int s3c_gpio_do_setpull(struct s3c_gpio_chip *chip,
34 unsigned int off, s3c_gpio_pull_t pull)
35{
36 return (chip->config->set_pull)(chip, off, pull);
37}
38
39/**
40 * s3c_gpio_setcfg_s3c24xx - S3C24XX style GPIO configuration.
41 * @chip: The gpio chip that is being configured.
42 * @off: The offset for the GPIO being configured.
43 * @cfg: The configuration value to set.
44 *
45 * This helper deal with the GPIO cases where the control register
46 * has two bits of configuration per gpio, which have the following
47 * functions:
48 * 00 = input
49 * 01 = output
50 * 1x = special function
51*/
52extern int s3c_gpio_setcfg_s3c24xx(struct s3c_gpio_chip *chip,
53 unsigned int off, unsigned int cfg);
54
97a33999
BD
55/**
56 * s3c_gpio_getcfg_s3c24xx - S3C24XX style GPIO configuration read.
57 * @chip: The gpio chip that is being configured.
58 * @off: The offset for the GPIO being configured.
59 *
60 * The reverse of s3c_gpio_setcfg_s3c24xx(). Will return a value whicg
61 * could be directly passed back to s3c_gpio_setcfg_s3c24xx(), from the
62 * S3C_GPIO_SPECIAL() macro.
63 */
64unsigned int s3c_gpio_getcfg_s3c24xx(struct s3c_gpio_chip *chip,
65 unsigned int off);
66
21b23664
BD
67/**
68 * s3c_gpio_setcfg_s3c24xx_a - S3C24XX style GPIO configuration (Bank A)
69 * @chip: The gpio chip that is being configured.
70 * @off: The offset for the GPIO being configured.
71 * @cfg: The configuration value to set.
72 *
73 * This helper deal with the GPIO cases where the control register
74 * has one bit of configuration for the gpio, where setting the bit
75 * means the pin is in special function mode and unset means output.
76*/
77extern int s3c_gpio_setcfg_s3c24xx_a(struct s3c_gpio_chip *chip,
78 unsigned int off, unsigned int cfg);
79
97a33999
BD
80
81/**
82 * s3c_gpio_getcfg_s3c24xx_a - S3C24XX style GPIO configuration read (Bank A)
83 * @chip: The gpio chip that is being configured.
84 * @off: The offset for the GPIO being configured.
85 *
86 * The reverse of s3c_gpio_setcfg_s3c24xx_a() turning an GPIO into a usable
87 * GPIO configuration value.
88 *
89 * @sa s3c_gpio_getcfg_s3c24xx
90 * @sa s3c_gpio_getcfg_s3c64xx_4bit
91 */
92extern unsigned s3c_gpio_getcfg_s3c24xx_a(struct s3c_gpio_chip *chip,
93 unsigned int off);
94
21b23664
BD
95/**
96 * s3c_gpio_setcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config.
97 * @chip: The gpio chip that is being configured.
98 * @off: The offset for the GPIO being configured.
99 * @cfg: The configuration value to set.
100 *
101 * This helper deal with the GPIO cases where the control register has 4 bits
102 * of control per GPIO, generally in the form of:
103 * 0000 = Input
104 * 0001 = Output
105 * others = Special functions (dependant on bank)
106 *
107 * Note, since the code to deal with the case where there are two control
3ad2f3fb 108 * registers instead of one, we do not have a separate set of functions for
21b23664
BD
109 * each case.
110*/
111extern int s3c_gpio_setcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip,
112 unsigned int off, unsigned int cfg);
113
114
97a33999
BD
115/**
116 * s3c_gpio_getcfg_s3c64xx_4bit - S3C64XX 4bit single register GPIO config read.
117 * @chip: The gpio chip that is being configured.
118 * @off: The offset for the GPIO being configured.
119 *
120 * The reverse of s3c_gpio_setcfg_s3c64xx_4bit(), turning a gpio configuration
121 * register setting into a value the software can use, such as could be passed
122 * to s3c_gpio_setcfg_s3c64xx_4bit().
123 *
124 * @sa s3c_gpio_getcfg_s3c24xx
125 */
126extern unsigned s3c_gpio_getcfg_s3c64xx_4bit(struct s3c_gpio_chip *chip,
127 unsigned int off);
128
21b23664
BD
129/* Pull-{up,down} resistor controls.
130 *
131 * S3C2410,S3C2440,S3C24A0 = Pull-UP,
132 * S3C2412,S3C2413 = Pull-Down
133 * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
134 * S3C2443 = Pull-Both [not same as S3C6400]
135 */
136
137/**
138 * s3c_gpio_setpull_1up() - Pull configuration for choice of up or none.
139 * @chip: The gpio chip that is being configured.
140 * @off: The offset for the GPIO being configured.
141 * @param: pull: The pull mode being requested.
142 *
143 * This is a helper function for the case where we have GPIOs with one
144 * bit configuring the presence of a pull-up resistor.
145 */
146extern int s3c_gpio_setpull_1up(struct s3c_gpio_chip *chip,
147 unsigned int off, s3c_gpio_pull_t pull);
148
149/**
150 * s3c_gpio_setpull_1down() - Pull configuration for choice of down 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
154 *
155 * This is a helper function for the case where we have GPIOs with one
156 * bit configuring the presence of a pull-down resistor.
157 */
158extern int s3c_gpio_setpull_1down(struct s3c_gpio_chip *chip,
159 unsigned int off, s3c_gpio_pull_t pull);
160
161/**
162 * s3c_gpio_setpull_upown() - Pull configuration for choice of up, 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.
166 *
167 * This is a helper function for the case where we have GPIOs with two
168 * bits configuring the presence of a pull resistor, in the following
169 * order:
170 * 00 = No pull resistor connected
171 * 01 = Pull-up resistor connected
172 * 10 = Pull-down resistor connected
173 */
174extern int s3c_gpio_setpull_updown(struct s3c_gpio_chip *chip,
175 unsigned int off, s3c_gpio_pull_t pull);
176
177
178/**
179 * s3c_gpio_getpull_updown() - Get configuration for choice of up, down or none
180 * @chip: The gpio chip that the GPIO pin belongs to
181 * @off: The offset to the pin to get the configuration of.
182 *
183 * This helper function reads the state of the pull-{up,down} resistor for the
184 * given GPIO in the same case as s3c_gpio_setpull_upown.
185*/
186extern s3c_gpio_pull_t s3c_gpio_getpull_updown(struct s3c_gpio_chip *chip,
187 unsigned int off);
188
1ec7269f
BD
189/**
190 * s3c_gpio_getpull_1up() - Get configuration for choice of up or none
191 * @chip: The gpio chip that the GPIO pin belongs to
192 * @off: The offset to the pin to get the configuration of.
193 *
194 * This helper function reads the state of the pull-up resistor for the
195 * given GPIO in the same case as s3c_gpio_setpull_1up.
196*/
197extern s3c_gpio_pull_t s3c_gpio_getpull_1up(struct s3c_gpio_chip *chip,
198 unsigned int off);
199
21b23664
BD
200/**
201 * s3c_gpio_setpull_s3c2443() - Pull configuration for s3c2443.
202 * @chip: The gpio chip that is being configured.
203 * @off: The offset for the GPIO being configured.
204 * @param: pull: The pull mode being requested.
205 *
206 * This is a helper function for the case where we have GPIOs with two
207 * bits configuring the presence of a pull resistor, in the following
208 * order:
209 * 00 = Pull-up resistor connected
210 * 10 = Pull-down resistor connected
211 * x1 = No pull up resistor
212 */
213extern int s3c_gpio_setpull_s3c2443(struct s3c_gpio_chip *chip,
214 unsigned int off, s3c_gpio_pull_t pull);
215
216/**
217 * s3c_gpio_getpull_s3c2443() - Get configuration for s3c2443 pull resistors
218 * @chip: The gpio chip that the GPIO pin belongs to.
219 * @off: The offset to the pin to get the configuration of.
220 *
221 * This helper function reads the state of the pull-{up,down} resistor for the
222 * given GPIO in the same case as s3c_gpio_setpull_upown.
223*/
224extern s3c_gpio_pull_t s3c_gpio_getpull_s3c24xx(struct s3c_gpio_chip *chip,
225 unsigned int off);
226
227#endif /* __PLAT_GPIO_CFG_HELPERS_H */
228
This page took 0.206056 seconds and 5 git commands to generate.