Commit | Line | Data |
---|---|---|
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 | ||
27 | typedef unsigned int __bitwise__ s3c_gpio_pull_t; | |
838c6d49 | 28 | typedef unsigned int __bitwise__ s5p_gpio_drvstr_t; |
21b23664 BD |
29 | |
30 | /* forward declaration if gpio-core.h hasn't been included */ | |
31 | struct s3c_gpio_chip; | |
32 | ||
33 | /** | |
34 | * struct s3c_gpio_cfg GPIO configuration | |
35 | * @cfg_eint: Configuration setting when used for external interrupt source | |
36 | * @get_pull: Read the current pull configuration for the GPIO | |
37 | * @set_pull: Set the current pull configuraiton for the GPIO | |
38 | * @set_config: Set the current configuration for the GPIO | |
39 | * @get_config: Read the current configuration for the GPIO | |
40 | * | |
41 | * Each chip can have more than one type of GPIO bank available and some | |
42 | * have different capabilites even when they have the same control register | |
43 | * layouts. Provide an point to vector control routine and provide any | |
44 | * per-bank configuration information that other systems such as the | |
45 | * external interrupt code will need. | |
46 | */ | |
47 | struct s3c_gpio_cfg { | |
48 | unsigned int cfg_eint; | |
49 | ||
50 | s3c_gpio_pull_t (*get_pull)(struct s3c_gpio_chip *chip, unsigned offs); | |
51 | int (*set_pull)(struct s3c_gpio_chip *chip, unsigned offs, | |
52 | s3c_gpio_pull_t pull); | |
53 | ||
54 | unsigned (*get_config)(struct s3c_gpio_chip *chip, unsigned offs); | |
55 | int (*set_config)(struct s3c_gpio_chip *chip, unsigned offs, | |
56 | unsigned config); | |
57 | }; | |
58 | ||
59 | #define S3C_GPIO_SPECIAL_MARK (0xfffffff0) | |
60 | #define S3C_GPIO_SPECIAL(x) (S3C_GPIO_SPECIAL_MARK | (x)) | |
61 | ||
62 | /* Defines for generic pin configurations */ | |
63 | #define S3C_GPIO_INPUT (S3C_GPIO_SPECIAL(0)) | |
64 | #define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1)) | |
65 | #define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x)) | |
66 | ||
67 | #define s3c_gpio_is_cfg_special(_cfg) \ | |
68 | (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK) | |
69 | ||
70 | /** | |
71 | * s3c_gpio_cfgpin() - Change the GPIO function of a pin. | |
72 | * @pin pin The pin number to configure. | |
94143926 | 73 | * @to to The configuration for the pin's function. |
21b23664 BD |
74 | * |
75 | * Configure which function is actually connected to the external | |
76 | * pin, such as an gpio input, output or some form of special function | |
77 | * connected to an internal peripheral block. | |
78 | */ | |
79 | extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to); | |
80 | ||
9933847b BD |
81 | /** |
82 | * s3c_gpio_getcfg - Read the current function for a GPIO pin | |
83 | * @pin: The pin to read the configuration value for. | |
84 | * | |
85 | * Read the configuration state of the given @pin, returning a value that | |
86 | * could be passed back to s3c_gpio_cfgpin(). | |
87 | * | |
88 | * @sa s3c_gpio_cfgpin | |
89 | */ | |
90 | extern unsigned s3c_gpio_getcfg(unsigned int pin); | |
91 | ||
21b23664 BD |
92 | /* Define values for the pull-{up,down} available for each gpio pin. |
93 | * | |
94 | * These values control the state of the weak pull-{up,down} resistors | |
95 | * available on most pins on the S3C series. Not all chips support both | |
96 | * up or down settings, and it may be dependant on the chip that is being | |
97 | * used to whether the particular mode is available. | |
98 | */ | |
99 | #define S3C_GPIO_PULL_NONE ((__force s3c_gpio_pull_t)0x00) | |
100 | #define S3C_GPIO_PULL_DOWN ((__force s3c_gpio_pull_t)0x01) | |
101 | #define S3C_GPIO_PULL_UP ((__force s3c_gpio_pull_t)0x02) | |
102 | ||
103 | /** | |
104 | * s3c_gpio_setpull() - set the state of a gpio pin pull resistor | |
105 | * @pin: The pin number to configure the pull resistor. | |
106 | * @pull: The configuration for the pull resistor. | |
107 | * | |
108 | * This function sets the state of the pull-{up,down} resistor for the | |
109 | * specified pin. It will return 0 if successfull, or a negative error | |
110 | * code if the pin cannot support the requested pull setting. | |
111 | */ | |
112 | extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull); | |
113 | ||
114 | /** | |
115 | * s3c_gpio_getpull() - get the pull resistor state of a gpio pin | |
116 | * @pin: The pin number to get the settings for | |
117 | * | |
118 | * Read the pull resistor value for the specified pin. | |
119 | */ | |
120 | extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin); | |
121 | ||
838c6d49 MS |
122 | /* Define values for the drvstr available for each gpio pin. |
123 | * | |
124 | * These values control the value of the output signal driver strength, | |
125 | * configurable on most pins on the S5C series. | |
126 | */ | |
127 | #define S5P_GPIO_DRVSTR_LV1 ((__force s5p_gpio_drvstr_t)0x00) | |
128 | #define S5P_GPIO_DRVSTR_LV2 ((__force s5p_gpio_drvstr_t)0x01) | |
129 | #define S5P_GPIO_DRVSTR_LV3 ((__force s5p_gpio_drvstr_t)0x10) | |
130 | #define S5P_GPIO_DRVSTR_LV4 ((__force s5p_gpio_drvstr_t)0x11) | |
131 | ||
132 | /** | |
133 | * s5c_gpio_get_drvstr() - get the driver streght value of a gpio pin | |
134 | * @pin: The pin number to get the settings for | |
135 | * | |
136 | * Read the driver streght value for the specified pin. | |
137 | */ | |
138 | extern s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin); | |
139 | ||
140 | /** | |
141 | * s3c_gpio_set_drvstr() - set the driver streght value of a gpio pin | |
142 | * @pin: The pin number to configure the driver streght value | |
143 | * @drvstr: The new value of the driver strength | |
144 | * | |
145 | * This function sets the driver strength value for the specified pin. | |
146 | * It will return 0 if successfull, or a negative error code if the pin | |
147 | * cannot support the requested setting. | |
148 | */ | |
149 | extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr); | |
150 | ||
21b23664 | 151 | #endif /* __PLAT_GPIO_CFG_H */ |