Merge branch 'next-samsung-devel' into next-samsung-devel-2
[deliverable/linux.git] / arch / arm / plat-samsung / include / plat / gpio-cfg-helpers.h
CommitLineData
782d8a3c 1/* linux/arch/arm/plat-samsung/include/plat/gpio-cfg-helper.h
21b23664
BD
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 *
782d8a3c 8 * Samsung Platform - GPIO pin configuration helper definitions
21b23664
BD
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
782d8a3c
KK
27static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
28 unsigned int off, unsigned int config)
21b23664
BD
29{
30 return (chip->config->set_config)(chip, off, config);
31}
32
782d8a3c
KK
33static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
34 unsigned int off)
9933847b
BD
35{
36 return (chip->config->get_config)(chip, off);
37}
38
782d8a3c
KK
39static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
40 unsigned int off, samsung_gpio_pull_t pull)
21b23664
BD
41{
42 return (chip->config->set_pull)(chip, off, pull);
43}
44
782d8a3c
KK
45static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
46 unsigned int off)
a6149c09
DM
47{
48 return chip->config->get_pull(chip, off);
49}
50
21b23664
BD
51/* Pull-{up,down} resistor controls.
52 *
af0e060e 53 * S3C2410,S3C2440 = Pull-UP,
21b23664
BD
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/**
782d8a3c 60 * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
21b23664
BD
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 */
782d8a3c
KK
68extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
69 unsigned int off, samsung_gpio_pull_t pull);
21b23664
BD
70
71/**
782d8a3c 72 * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
21b23664
BD
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 */
782d8a3c
KK
80extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
81 unsigned int off, samsung_gpio_pull_t pull);
21b23664
BD
82
83/**
782d8a3c
KK
84 * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
85 * down or none
86 *
21b23664
BD
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 */
782d8a3c
KK
98extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
99 unsigned int off, samsung_gpio_pull_t pull);
21b23664
BD
100
101/**
782d8a3c
KK
102 * samsung_gpio_getpull_updown() - Get configuration for choice of up,
103 * down or none
104 *
21b23664
BD
105 * @chip: The gpio chip that the GPIO pin belongs to
106 * @off: The offset to the pin to get the configuration of.
107 *
782d8a3c
KK
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.
21b23664 110*/
782d8a3c
KK
111extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
112 unsigned int off);
21b23664 113
1ec7269f 114/**
782d8a3c 115 * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
1ec7269f
BD
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
782d8a3c 120 * given GPIO in the same case as s3c24xx_gpio_setpull_1up.
1ec7269f 121*/
782d8a3c
KK
122extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
123 unsigned int off);
1ec7269f 124
812c4e40 125/**
782d8a3c 126 * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
812c4e40
VK
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
782d8a3c 131 * given GPIO in the same case as s3c24xx_gpio_setpull_1down.
812c4e40 132*/
782d8a3c
KK
133extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
134 unsigned int off);
812c4e40 135
21b23664 136/**
782d8a3c 137 * s3c2443_gpio_setpull() - Pull configuration for s3c2443.
21b23664
BD
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 */
782d8a3c
KK
149extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
150 unsigned int off, samsung_gpio_pull_t pull);
21b23664
BD
151
152/**
782d8a3c 153 * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
21b23664
BD
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
782d8a3c 158 * given GPIO in the same case as samsung_gpio_setpull_upown.
21b23664 159*/
782d8a3c 160extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
21b23664
BD
161 unsigned int off);
162
163#endif /* __PLAT_GPIO_CFG_HELPERS_H */
This page took 0.364529 seconds and 5 git commands to generate.