Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-pxa/include/mach/mfp.h |
| 3 | * |
| 4 | * Multi-Function Pin Definitions |
| 5 | * |
| 6 | * Copyright (C) 2007 Marvell International Ltd. |
| 7 | * |
| 8 | * 2007-8-21: eric miao <eric.miao@marvell.com> |
| 9 | * initial version |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Software Foundation. |
| 14 | */ |
| 15 | |
| 16 | #ifndef __ASM_ARCH_MFP_H |
| 17 | #define __ASM_ARCH_MFP_H |
| 18 | |
| 19 | #define mfp_to_gpio(m) ((m) % 128) |
| 20 | |
| 21 | /* list of all the configurable MFP pins */ |
| 22 | enum { |
| 23 | MFP_PIN_INVALID = -1, |
| 24 | |
| 25 | MFP_PIN_GPIO0 = 0, |
| 26 | MFP_PIN_GPIO1, |
| 27 | MFP_PIN_GPIO2, |
| 28 | MFP_PIN_GPIO3, |
| 29 | MFP_PIN_GPIO4, |
| 30 | MFP_PIN_GPIO5, |
| 31 | MFP_PIN_GPIO6, |
| 32 | MFP_PIN_GPIO7, |
| 33 | MFP_PIN_GPIO8, |
| 34 | MFP_PIN_GPIO9, |
| 35 | MFP_PIN_GPIO10, |
| 36 | MFP_PIN_GPIO11, |
| 37 | MFP_PIN_GPIO12, |
| 38 | MFP_PIN_GPIO13, |
| 39 | MFP_PIN_GPIO14, |
| 40 | MFP_PIN_GPIO15, |
| 41 | MFP_PIN_GPIO16, |
| 42 | MFP_PIN_GPIO17, |
| 43 | MFP_PIN_GPIO18, |
| 44 | MFP_PIN_GPIO19, |
| 45 | MFP_PIN_GPIO20, |
| 46 | MFP_PIN_GPIO21, |
| 47 | MFP_PIN_GPIO22, |
| 48 | MFP_PIN_GPIO23, |
| 49 | MFP_PIN_GPIO24, |
| 50 | MFP_PIN_GPIO25, |
| 51 | MFP_PIN_GPIO26, |
| 52 | MFP_PIN_GPIO27, |
| 53 | MFP_PIN_GPIO28, |
| 54 | MFP_PIN_GPIO29, |
| 55 | MFP_PIN_GPIO30, |
| 56 | MFP_PIN_GPIO31, |
| 57 | MFP_PIN_GPIO32, |
| 58 | MFP_PIN_GPIO33, |
| 59 | MFP_PIN_GPIO34, |
| 60 | MFP_PIN_GPIO35, |
| 61 | MFP_PIN_GPIO36, |
| 62 | MFP_PIN_GPIO37, |
| 63 | MFP_PIN_GPIO38, |
| 64 | MFP_PIN_GPIO39, |
| 65 | MFP_PIN_GPIO40, |
| 66 | MFP_PIN_GPIO41, |
| 67 | MFP_PIN_GPIO42, |
| 68 | MFP_PIN_GPIO43, |
| 69 | MFP_PIN_GPIO44, |
| 70 | MFP_PIN_GPIO45, |
| 71 | MFP_PIN_GPIO46, |
| 72 | MFP_PIN_GPIO47, |
| 73 | MFP_PIN_GPIO48, |
| 74 | MFP_PIN_GPIO49, |
| 75 | MFP_PIN_GPIO50, |
| 76 | MFP_PIN_GPIO51, |
| 77 | MFP_PIN_GPIO52, |
| 78 | MFP_PIN_GPIO53, |
| 79 | MFP_PIN_GPIO54, |
| 80 | MFP_PIN_GPIO55, |
| 81 | MFP_PIN_GPIO56, |
| 82 | MFP_PIN_GPIO57, |
| 83 | MFP_PIN_GPIO58, |
| 84 | MFP_PIN_GPIO59, |
| 85 | MFP_PIN_GPIO60, |
| 86 | MFP_PIN_GPIO61, |
| 87 | MFP_PIN_GPIO62, |
| 88 | MFP_PIN_GPIO63, |
| 89 | MFP_PIN_GPIO64, |
| 90 | MFP_PIN_GPIO65, |
| 91 | MFP_PIN_GPIO66, |
| 92 | MFP_PIN_GPIO67, |
| 93 | MFP_PIN_GPIO68, |
| 94 | MFP_PIN_GPIO69, |
| 95 | MFP_PIN_GPIO70, |
| 96 | MFP_PIN_GPIO71, |
| 97 | MFP_PIN_GPIO72, |
| 98 | MFP_PIN_GPIO73, |
| 99 | MFP_PIN_GPIO74, |
| 100 | MFP_PIN_GPIO75, |
| 101 | MFP_PIN_GPIO76, |
| 102 | MFP_PIN_GPIO77, |
| 103 | MFP_PIN_GPIO78, |
| 104 | MFP_PIN_GPIO79, |
| 105 | MFP_PIN_GPIO80, |
| 106 | MFP_PIN_GPIO81, |
| 107 | MFP_PIN_GPIO82, |
| 108 | MFP_PIN_GPIO83, |
| 109 | MFP_PIN_GPIO84, |
| 110 | MFP_PIN_GPIO85, |
| 111 | MFP_PIN_GPIO86, |
| 112 | MFP_PIN_GPIO87, |
| 113 | MFP_PIN_GPIO88, |
| 114 | MFP_PIN_GPIO89, |
| 115 | MFP_PIN_GPIO90, |
| 116 | MFP_PIN_GPIO91, |
| 117 | MFP_PIN_GPIO92, |
| 118 | MFP_PIN_GPIO93, |
| 119 | MFP_PIN_GPIO94, |
| 120 | MFP_PIN_GPIO95, |
| 121 | MFP_PIN_GPIO96, |
| 122 | MFP_PIN_GPIO97, |
| 123 | MFP_PIN_GPIO98, |
| 124 | MFP_PIN_GPIO99, |
| 125 | MFP_PIN_GPIO100, |
| 126 | MFP_PIN_GPIO101, |
| 127 | MFP_PIN_GPIO102, |
| 128 | MFP_PIN_GPIO103, |
| 129 | MFP_PIN_GPIO104, |
| 130 | MFP_PIN_GPIO105, |
| 131 | MFP_PIN_GPIO106, |
| 132 | MFP_PIN_GPIO107, |
| 133 | MFP_PIN_GPIO108, |
| 134 | MFP_PIN_GPIO109, |
| 135 | MFP_PIN_GPIO110, |
| 136 | MFP_PIN_GPIO111, |
| 137 | MFP_PIN_GPIO112, |
| 138 | MFP_PIN_GPIO113, |
| 139 | MFP_PIN_GPIO114, |
| 140 | MFP_PIN_GPIO115, |
| 141 | MFP_PIN_GPIO116, |
| 142 | MFP_PIN_GPIO117, |
| 143 | MFP_PIN_GPIO118, |
| 144 | MFP_PIN_GPIO119, |
| 145 | MFP_PIN_GPIO120, |
| 146 | MFP_PIN_GPIO121, |
| 147 | MFP_PIN_GPIO122, |
| 148 | MFP_PIN_GPIO123, |
| 149 | MFP_PIN_GPIO124, |
| 150 | MFP_PIN_GPIO125, |
| 151 | MFP_PIN_GPIO126, |
| 152 | MFP_PIN_GPIO127, |
| 153 | MFP_PIN_GPIO0_2, |
| 154 | MFP_PIN_GPIO1_2, |
| 155 | MFP_PIN_GPIO2_2, |
| 156 | MFP_PIN_GPIO3_2, |
| 157 | MFP_PIN_GPIO4_2, |
| 158 | MFP_PIN_GPIO5_2, |
| 159 | MFP_PIN_GPIO6_2, |
| 160 | MFP_PIN_GPIO7_2, |
| 161 | MFP_PIN_GPIO8_2, |
| 162 | MFP_PIN_GPIO9_2, |
| 163 | MFP_PIN_GPIO10_2, |
| 164 | MFP_PIN_GPIO11_2, |
| 165 | MFP_PIN_GPIO12_2, |
| 166 | MFP_PIN_GPIO13_2, |
| 167 | MFP_PIN_GPIO14_2, |
| 168 | MFP_PIN_GPIO15_2, |
| 169 | MFP_PIN_GPIO16_2, |
| 170 | MFP_PIN_GPIO17_2, |
| 171 | |
| 172 | MFP_PIN_ULPI_STP, |
| 173 | MFP_PIN_ULPI_NXT, |
| 174 | MFP_PIN_ULPI_DIR, |
| 175 | |
| 176 | MFP_PIN_nXCVREN, |
| 177 | MFP_PIN_DF_CLE_nOE, |
| 178 | MFP_PIN_DF_nADV1_ALE, |
| 179 | MFP_PIN_DF_SCLK_E, |
| 180 | MFP_PIN_DF_SCLK_S, |
| 181 | MFP_PIN_nBE0, |
| 182 | MFP_PIN_nBE1, |
| 183 | MFP_PIN_DF_nADV2_ALE, |
| 184 | MFP_PIN_DF_INT_RnB, |
| 185 | MFP_PIN_DF_nCS0, |
| 186 | MFP_PIN_DF_nCS1, |
| 187 | MFP_PIN_nLUA, |
| 188 | MFP_PIN_nLLA, |
| 189 | MFP_PIN_DF_nWE, |
| 190 | MFP_PIN_DF_ALE_nWE, |
| 191 | MFP_PIN_DF_nRE_nOE, |
| 192 | MFP_PIN_DF_ADDR0, |
| 193 | MFP_PIN_DF_ADDR1, |
| 194 | MFP_PIN_DF_ADDR2, |
| 195 | MFP_PIN_DF_ADDR3, |
| 196 | MFP_PIN_DF_IO0, |
| 197 | MFP_PIN_DF_IO1, |
| 198 | MFP_PIN_DF_IO2, |
| 199 | MFP_PIN_DF_IO3, |
| 200 | MFP_PIN_DF_IO4, |
| 201 | MFP_PIN_DF_IO5, |
| 202 | MFP_PIN_DF_IO6, |
| 203 | MFP_PIN_DF_IO7, |
| 204 | MFP_PIN_DF_IO8, |
| 205 | MFP_PIN_DF_IO9, |
| 206 | MFP_PIN_DF_IO10, |
| 207 | MFP_PIN_DF_IO11, |
| 208 | MFP_PIN_DF_IO12, |
| 209 | MFP_PIN_DF_IO13, |
| 210 | MFP_PIN_DF_IO14, |
| 211 | MFP_PIN_DF_IO15, |
| 212 | |
| 213 | /* additional pins on PXA930 */ |
| 214 | MFP_PIN_GSIM_UIO, |
| 215 | MFP_PIN_GSIM_UCLK, |
| 216 | MFP_PIN_GSIM_UDET, |
| 217 | MFP_PIN_GSIM_nURST, |
| 218 | MFP_PIN_PMIC_INT, |
| 219 | MFP_PIN_RDY, |
| 220 | |
| 221 | MFP_PIN_MAX, |
| 222 | }; |
| 223 | |
| 224 | /* |
| 225 | * a possible MFP configuration is represented by a 32-bit integer |
| 226 | * |
| 227 | * bit 0.. 9 - MFP Pin Number (1024 Pins Maximum) |
| 228 | * bit 10..12 - Alternate Function Selection |
| 229 | * bit 13..15 - Drive Strength |
| 230 | * bit 16..18 - Low Power Mode State |
| 231 | * bit 19..20 - Low Power Mode Edge Detection |
| 232 | * bit 21..22 - Run Mode Pull State |
| 233 | * |
| 234 | * to facilitate the definition, the following macros are provided |
| 235 | * |
| 236 | * MFP_CFG_DEFAULT - default MFP configuration value, with |
| 237 | * alternate function = 0, |
| 238 | * drive strength = fast 3mA (MFP_DS03X) |
| 239 | * low power mode = default |
| 240 | * edge detection = none |
| 241 | * |
| 242 | * MFP_CFG - default MFPR value with alternate function |
| 243 | * MFP_CFG_DRV - default MFPR value with alternate function and |
| 244 | * pin drive strength |
| 245 | * MFP_CFG_LPM - default MFPR value with alternate function and |
| 246 | * low power mode |
| 247 | * MFP_CFG_X - default MFPR value with alternate function, |
| 248 | * pin drive strength and low power mode |
| 249 | */ |
| 250 | |
| 251 | typedef unsigned long mfp_cfg_t; |
| 252 | |
| 253 | #define MFP_PIN(x) ((x) & 0x3ff) |
| 254 | |
| 255 | #define MFP_AF0 (0x0 << 10) |
| 256 | #define MFP_AF1 (0x1 << 10) |
| 257 | #define MFP_AF2 (0x2 << 10) |
| 258 | #define MFP_AF3 (0x3 << 10) |
| 259 | #define MFP_AF4 (0x4 << 10) |
| 260 | #define MFP_AF5 (0x5 << 10) |
| 261 | #define MFP_AF6 (0x6 << 10) |
| 262 | #define MFP_AF7 (0x7 << 10) |
| 263 | #define MFP_AF_MASK (0x7 << 10) |
| 264 | #define MFP_AF(x) (((x) >> 10) & 0x7) |
| 265 | |
| 266 | #define MFP_DS01X (0x0 << 13) |
| 267 | #define MFP_DS02X (0x1 << 13) |
| 268 | #define MFP_DS03X (0x2 << 13) |
| 269 | #define MFP_DS04X (0x3 << 13) |
| 270 | #define MFP_DS06X (0x4 << 13) |
| 271 | #define MFP_DS08X (0x5 << 13) |
| 272 | #define MFP_DS10X (0x6 << 13) |
| 273 | #define MFP_DS13X (0x7 << 13) |
| 274 | #define MFP_DS_MASK (0x7 << 13) |
| 275 | #define MFP_DS(x) (((x) >> 13) & 0x7) |
| 276 | |
| 277 | #define MFP_LPM_INPUT (0x0 << 16) |
| 278 | #define MFP_LPM_DRIVE_LOW (0x1 << 16) |
| 279 | #define MFP_LPM_DRIVE_HIGH (0x2 << 16) |
| 280 | #define MFP_LPM_PULL_LOW (0x3 << 16) |
| 281 | #define MFP_LPM_PULL_HIGH (0x4 << 16) |
| 282 | #define MFP_LPM_FLOAT (0x5 << 16) |
| 283 | #define MFP_LPM_STATE_MASK (0x7 << 16) |
| 284 | #define MFP_LPM_STATE(x) (((x) >> 16) & 0x7) |
| 285 | |
| 286 | #define MFP_LPM_EDGE_NONE (0x0 << 19) |
| 287 | #define MFP_LPM_EDGE_RISE (0x1 << 19) |
| 288 | #define MFP_LPM_EDGE_FALL (0x2 << 19) |
| 289 | #define MFP_LPM_EDGE_BOTH (0x3 << 19) |
| 290 | #define MFP_LPM_EDGE_MASK (0x3 << 19) |
| 291 | #define MFP_LPM_EDGE(x) (((x) >> 19) & 0x3) |
| 292 | |
| 293 | #define MFP_PULL_NONE (0x0 << 21) |
| 294 | #define MFP_PULL_LOW (0x1 << 21) |
| 295 | #define MFP_PULL_HIGH (0x2 << 21) |
| 296 | #define MFP_PULL_BOTH (0x3 << 21) |
| 297 | #define MFP_PULL_MASK (0x3 << 21) |
| 298 | #define MFP_PULL(x) (((x) >> 21) & 0x3) |
| 299 | |
| 300 | #define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_INPUT |\ |
| 301 | MFP_LPM_EDGE_NONE | MFP_PULL_NONE) |
| 302 | |
| 303 | #define MFP_CFG(pin, af) \ |
| 304 | ((MFP_CFG_DEFAULT & ~MFP_AF_MASK) |\ |
| 305 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af)) |
| 306 | |
| 307 | #define MFP_CFG_DRV(pin, af, drv) \ |
| 308 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK)) |\ |
| 309 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv)) |
| 310 | |
| 311 | #define MFP_CFG_LPM(pin, af, lpm) \ |
| 312 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_LPM_STATE_MASK)) |\ |
| 313 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_LPM_##lpm)) |
| 314 | |
| 315 | #define MFP_CFG_X(pin, af, drv, lpm) \ |
| 316 | ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK | MFP_LPM_STATE_MASK)) |\ |
| 317 | (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv | MFP_LPM_##lpm)) |
| 318 | |
| 319 | #endif /* __ASM_ARCH_MFP_H */ |