1 /* linux/arch/arm/plat-samsung/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 * Samsung 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
samsung_gpio_do_setcfg(struct samsung_gpio_chip * chip,unsigned int off,unsigned int config)27 static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
28 unsigned int off, unsigned int config)
29 {
30 return (chip->config->set_config)(chip, off, config);
31 }
32
samsung_gpio_do_getcfg(struct samsung_gpio_chip * chip,unsigned int off)33 static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
34 unsigned int off)
35 {
36 return (chip->config->get_config)(chip, off);
37 }
38
samsung_gpio_do_setpull(struct samsung_gpio_chip * chip,unsigned int off,samsung_gpio_pull_t pull)39 static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
40 unsigned int off, samsung_gpio_pull_t pull)
41 {
42 return (chip->config->set_pull)(chip, off, pull);
43 }
44
samsung_gpio_do_getpull(struct samsung_gpio_chip * chip,unsigned int off)45 static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
46 unsigned int off)
47 {
48 return chip->config->get_pull(chip, off);
49 }
50
51 /* Pull-{up,down} resistor controls.
52 *
53 * S3C2410,S3C2440 = Pull-UP,
54 * S3C2412,S3C2413 = Pull-Down
55 * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
56 * S3C2443 = Pull-Both [not same as S3C6400]
57 */
58
59 /**
60 * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
61 * @chip: The gpio chip that is being configured.
62 * @off: The offset for the GPIO being configured.
63 * @param: pull: The pull mode being requested.
64 *
65 * This is a helper function for the case where we have GPIOs with one
66 * bit configuring the presence of a pull-up resistor.
67 */
68 extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
69 unsigned int off, samsung_gpio_pull_t pull);
70
71 /**
72 * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
73 * @chip: The gpio chip that is being configured
74 * @off: The offset for the GPIO being configured
75 * @param: pull: The pull mode being requested
76 *
77 * This is a helper function for the case where we have GPIOs with one
78 * bit configuring the presence of a pull-down resistor.
79 */
80 extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
81 unsigned int off, samsung_gpio_pull_t pull);
82
83 /**
84 * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
85 * down or none
86 *
87 * @chip: The gpio chip that is being configured.
88 * @off: The offset for the GPIO being configured.
89 * @param: pull: The pull mode being requested.
90 *
91 * This is a helper function for the case where we have GPIOs with two
92 * bits configuring the presence of a pull resistor, in the following
93 * order:
94 * 00 = No pull resistor connected
95 * 01 = Pull-up resistor connected
96 * 10 = Pull-down resistor connected
97 */
98 extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
99 unsigned int off, samsung_gpio_pull_t pull);
100
101 /**
102 * samsung_gpio_getpull_updown() - Get configuration for choice of up,
103 * down or none
104 *
105 * @chip: The gpio chip that the GPIO pin belongs to
106 * @off: The offset to the pin to get the configuration of.
107 *
108 * This helper function reads the state of the pull-{up,down} resistor
109 * for the given GPIO in the same case as samsung_gpio_setpull_upown.
110 */
111 extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
112 unsigned int off);
113
114 /**
115 * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
116 * @chip: The gpio chip that the GPIO pin belongs to
117 * @off: The offset to the pin to get the configuration of.
118 *
119 * This helper function reads the state of the pull-up resistor for the
120 * given GPIO in the same case as s3c24xx_gpio_setpull_1up.
121 */
122 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
123 unsigned int off);
124
125 /**
126 * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
127 * @chip: The gpio chip that the GPIO pin belongs to
128 * @off: The offset to the pin to get the configuration of.
129 *
130 * This helper function reads the state of the pull-down resistor for the
131 * given GPIO in the same case as s3c24xx_gpio_setpull_1down.
132 */
133 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
134 unsigned int off);
135
136 /**
137 * s3c2443_gpio_setpull() - Pull configuration for s3c2443.
138 * @chip: The gpio chip that is being configured.
139 * @off: The offset for the GPIO being configured.
140 * @param: pull: The pull mode being requested.
141 *
142 * This is a helper function for the case where we have GPIOs with two
143 * bits configuring the presence of a pull resistor, in the following
144 * order:
145 * 00 = Pull-up resistor connected
146 * 10 = Pull-down resistor connected
147 * x1 = No pull up resistor
148 */
149 extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
150 unsigned int off, samsung_gpio_pull_t pull);
151
152 /**
153 * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
154 * @chip: The gpio chip that the GPIO pin belongs to.
155 * @off: The offset to the pin to get the configuration of.
156 *
157 * This helper function reads the state of the pull-{up,down} resistor for the
158 * given GPIO in the same case as samsung_gpio_setpull_upown.
159 */
160 extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
161 unsigned int off);
162
163 #endif /* __PLAT_GPIO_CFG_HELPERS_H */
164