Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / plat-samsung / include / plat / gpio-cfg-helpers.h
bloba181d7ce81cff4f1bb560d919da8da31141864f3
1 /* linux/arch/arm/plat-samsung/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 * Samsung 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 samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
28 unsigned int off, unsigned int config)
30 return (chip->config->set_config)(chip, off, config);
33 static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
34 unsigned int off)
36 return (chip->config->get_config)(chip, off);
39 static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
40 unsigned int off, samsung_gpio_pull_t pull)
42 return (chip->config->set_pull)(chip, off, pull);
45 static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
46 unsigned int off)
48 return chip->config->get_pull(chip, off);
51 /* Pull-{up,down} resistor controls.
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]
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.
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.
68 extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
69 unsigned int off, samsung_gpio_pull_t pull);
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
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.
80 extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
81 unsigned int off, samsung_gpio_pull_t pull);
83 /**
84 * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
85 * down or none
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.
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
98 extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
99 unsigned int off, samsung_gpio_pull_t pull);
102 * samsung_gpio_getpull_updown() - Get configuration for choice of up,
103 * down or none
105 * @chip: The gpio chip that the GPIO pin belongs to
106 * @off: The offset to the pin to get the configuration of.
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.
111 extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
112 unsigned int off);
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.
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.
122 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
123 unsigned int off);
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.
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.
133 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
134 unsigned int off);
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.
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
149 extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
150 unsigned int off, samsung_gpio_pull_t pull);
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.
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.
160 extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
161 unsigned int off);
163 #endif /* __PLAT_GPIO_CFG_HELPERS_H */