2 * linux/include/asm-arm/arch-pxa/mfp.h
4 * Multi-Function Pin Definitions
6 * Copyright (C) 2007 Marvell International Ltd.
8 * 2007-8-21: eric miao <eric.miao@marvell.com>
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.
16 #ifndef __ASM_ARCH_MFP_H
17 #define __ASM_ARCH_MFP_H
19 #define mfp_to_gpio(m) ((m) % 128)
21 /* list of all the configurable MFP pins */
178 MFP_PIN_DF_nADV1_ALE,
183 MFP_PIN_DF_nADV2_ALE,
213 /* additional pins on PXA930 */
225 * a possible MFP configuration is represented by a 32-bit integer
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
234 * to facilitate the definition, the following macros are provided
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
242 * MFP_CFG - default MFPR value with alternate function
243 * MFP_CFG_DRV - default MFPR value with alternate function and
245 * MFP_CFG_LPM - default MFPR value with alternate function and
247 * MFP_CFG_X - default MFPR value with alternate function,
248 * pin drive strength and low power mode
251 typedef unsigned long mfp_cfg_t;
253 #define MFP_PIN(x) ((x) & 0x3ff)
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)
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)
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)
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)
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)
300 #define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_INPUT |\
301 MFP_LPM_EDGE_NONE | MFP_PULL_NONE)
303 #define MFP_CFG(pin, af) \
304 ((MFP_CFG_DEFAULT & ~MFP_AF_MASK) |\
305 (MFP_PIN(MFP_PIN_##pin) | MFP_##af))
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))
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))
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))
319 #endif /* __ASM_ARCH_MFP_H */