]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/plat-samsung/include/plat/gpio-cfg.h
ARM: Merge for-2635/samsung-rtc
[net-next-2.6.git] / arch / arm / plat-samsung / include / plat / gpio-cfg.h
CommitLineData
21b23664
BD
1/* linux/arch/arm/plat-s3c/include/plat/gpio-cfg.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
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 file contains the necessary definitions to get the basic gpio
16 * pin configuration done such as setting a pin to input or output or
17 * changing the pull-{up,down} configurations.
18 */
19
20/* Note, this interface is being added to the s3c64xx arch first and will
21 * be added to the s3c24xx systems later.
22 */
23
24#ifndef __PLAT_GPIO_CFG_H
25#define __PLAT_GPIO_CFG_H __FILE__
26
27typedef unsigned int __bitwise__ s3c_gpio_pull_t;
28
29/* forward declaration if gpio-core.h hasn't been included */
30struct s3c_gpio_chip;
31
32/**
33 * struct s3c_gpio_cfg GPIO configuration
34 * @cfg_eint: Configuration setting when used for external interrupt source
35 * @get_pull: Read the current pull configuration for the GPIO
36 * @set_pull: Set the current pull configuraiton for the GPIO
37 * @set_config: Set the current configuration for the GPIO
38 * @get_config: Read the current configuration for the GPIO
39 *
40 * Each chip can have more than one type of GPIO bank available and some
41 * have different capabilites even when they have the same control register
42 * layouts. Provide an point to vector control routine and provide any
43 * per-bank configuration information that other systems such as the
44 * external interrupt code will need.
45 */
46struct s3c_gpio_cfg {
47 unsigned int cfg_eint;
48
49 s3c_gpio_pull_t (*get_pull)(struct s3c_gpio_chip *chip, unsigned offs);
50 int (*set_pull)(struct s3c_gpio_chip *chip, unsigned offs,
51 s3c_gpio_pull_t pull);
52
53 unsigned (*get_config)(struct s3c_gpio_chip *chip, unsigned offs);
54 int (*set_config)(struct s3c_gpio_chip *chip, unsigned offs,
55 unsigned config);
56};
57
58#define S3C_GPIO_SPECIAL_MARK (0xfffffff0)
59#define S3C_GPIO_SPECIAL(x) (S3C_GPIO_SPECIAL_MARK | (x))
60
61/* Defines for generic pin configurations */
62#define S3C_GPIO_INPUT (S3C_GPIO_SPECIAL(0))
63#define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1))
64#define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x))
65
66#define s3c_gpio_is_cfg_special(_cfg) \
67 (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK)
68
69/**
70 * s3c_gpio_cfgpin() - Change the GPIO function of a pin.
71 * @pin pin The pin number to configure.
72 * @pin to The configuration for the pin's function.
73 *
74 * Configure which function is actually connected to the external
75 * pin, such as an gpio input, output or some form of special function
76 * connected to an internal peripheral block.
77 */
78extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);
79
9933847b
BD
80/**
81 * s3c_gpio_getcfg - Read the current function for a GPIO pin
82 * @pin: The pin to read the configuration value for.
83 *
84 * Read the configuration state of the given @pin, returning a value that
85 * could be passed back to s3c_gpio_cfgpin().
86 *
87 * @sa s3c_gpio_cfgpin
88 */
89extern unsigned s3c_gpio_getcfg(unsigned int pin);
90
21b23664
BD
91/* Define values for the pull-{up,down} available for each gpio pin.
92 *
93 * These values control the state of the weak pull-{up,down} resistors
94 * available on most pins on the S3C series. Not all chips support both
95 * up or down settings, and it may be dependant on the chip that is being
96 * used to whether the particular mode is available.
97 */
98#define S3C_GPIO_PULL_NONE ((__force s3c_gpio_pull_t)0x00)
99#define S3C_GPIO_PULL_DOWN ((__force s3c_gpio_pull_t)0x01)
100#define S3C_GPIO_PULL_UP ((__force s3c_gpio_pull_t)0x02)
101
102/**
103 * s3c_gpio_setpull() - set the state of a gpio pin pull resistor
104 * @pin: The pin number to configure the pull resistor.
105 * @pull: The configuration for the pull resistor.
106 *
107 * This function sets the state of the pull-{up,down} resistor for the
108 * specified pin. It will return 0 if successfull, or a negative error
109 * code if the pin cannot support the requested pull setting.
110*/
111extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull);
112
113/**
114 * s3c_gpio_getpull() - get the pull resistor state of a gpio pin
115 * @pin: The pin number to get the settings for
116 *
117 * Read the pull resistor value for the specified pin.
118*/
119extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin);
120
121#endif /* __PLAT_GPIO_CFG_H */