Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mfp.h
Go to the documentation of this file.
1 /*
2  * arch/arm/plat-pxa/include/plat/mfp.h
3  *
4  * Common Multi-Function Pin Definitions
5  *
6  * Copyright (C) 2007 Marvell International Ltd.
7  *
8  * 2007-8-21: eric miao <[email protected]>
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_PLAT_MFP_H
17 #define __ASM_PLAT_MFP_H
18 
19 #define mfp_to_gpio(m) ((m) % 256)
20 
21 /* list of all the configurable MFP pins */
22 enum {
24 
153 
218 
220 
239 
243 
290 
297 
310 
311  /* additional pins on PXA930 */
318 
319  /* additional pins on MMP2 */
325 
327 };
328 
329 /*
330  * a possible MFP configuration is represented by a 32-bit integer
331  *
332  * bit 0.. 9 - MFP Pin Number (1024 Pins Maximum)
333  * bit 10..12 - Alternate Function Selection
334  * bit 13..15 - Drive Strength
335  * bit 16..18 - Low Power Mode State
336  * bit 19..20 - Low Power Mode Edge Detection
337  * bit 21..22 - Run Mode Pull State
338  *
339  * to facilitate the definition, the following macros are provided
340  *
341  * MFP_CFG_DEFAULT - default MFP configuration value, with
342  * alternate function = 0,
343  * drive strength = fast 3mA (MFP_DS03X)
344  * low power mode = default
345  * edge detection = none
346  *
347  * MFP_CFG - default MFPR value with alternate function
348  * MFP_CFG_DRV - default MFPR value with alternate function and
349  * pin drive strength
350  * MFP_CFG_LPM - default MFPR value with alternate function and
351  * low power mode
352  * MFP_CFG_X - default MFPR value with alternate function,
353  * pin drive strength and low power mode
354  */
355 
356 typedef unsigned long mfp_cfg_t;
357 
358 #define MFP_PIN(x) ((x) & 0x3ff)
359 
360 #define MFP_AF0 (0x0 << 10)
361 #define MFP_AF1 (0x1 << 10)
362 #define MFP_AF2 (0x2 << 10)
363 #define MFP_AF3 (0x3 << 10)
364 #define MFP_AF4 (0x4 << 10)
365 #define MFP_AF5 (0x5 << 10)
366 #define MFP_AF6 (0x6 << 10)
367 #define MFP_AF7 (0x7 << 10)
368 #define MFP_AF_MASK (0x7 << 10)
369 #define MFP_AF(x) (((x) >> 10) & 0x7)
370 
371 #define MFP_DS01X (0x0 << 13)
372 #define MFP_DS02X (0x1 << 13)
373 #define MFP_DS03X (0x2 << 13)
374 #define MFP_DS04X (0x3 << 13)
375 #define MFP_DS06X (0x4 << 13)
376 #define MFP_DS08X (0x5 << 13)
377 #define MFP_DS10X (0x6 << 13)
378 #define MFP_DS13X (0x7 << 13)
379 #define MFP_DS_MASK (0x7 << 13)
380 #define MFP_DS(x) (((x) >> 13) & 0x7)
381 
382 #define MFP_LPM_DEFAULT (0x0 << 16)
383 #define MFP_LPM_DRIVE_LOW (0x1 << 16)
384 #define MFP_LPM_DRIVE_HIGH (0x2 << 16)
385 #define MFP_LPM_PULL_LOW (0x3 << 16)
386 #define MFP_LPM_PULL_HIGH (0x4 << 16)
387 #define MFP_LPM_FLOAT (0x5 << 16)
388 #define MFP_LPM_INPUT (0x6 << 16)
389 #define MFP_LPM_STATE_MASK (0x7 << 16)
390 #define MFP_LPM_STATE(x) (((x) >> 16) & 0x7)
391 
392 #define MFP_LPM_EDGE_NONE (0x0 << 19)
393 #define MFP_LPM_EDGE_RISE (0x1 << 19)
394 #define MFP_LPM_EDGE_FALL (0x2 << 19)
395 #define MFP_LPM_EDGE_BOTH (0x3 << 19)
396 #define MFP_LPM_EDGE_MASK (0x3 << 19)
397 #define MFP_LPM_EDGE(x) (((x) >> 19) & 0x3)
398 
399 #define MFP_PULL_NONE (0x0 << 21)
400 #define MFP_PULL_LOW (0x1 << 21)
401 #define MFP_PULL_HIGH (0x2 << 21)
402 #define MFP_PULL_BOTH (0x3 << 21)
403 #define MFP_PULL_FLOAT (0x4 << 21)
404 #define MFP_PULL_MASK (0x7 << 21)
405 #define MFP_PULL(x) (((x) >> 21) & 0x7)
406 
407 #define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_DEFAULT |\
408  MFP_LPM_EDGE_NONE | MFP_PULL_NONE)
409 
410 #define MFP_CFG(pin, af) \
411  ((MFP_CFG_DEFAULT & ~MFP_AF_MASK) |\
412  (MFP_PIN(MFP_PIN_##pin) | MFP_##af))
413 
414 #define MFP_CFG_DRV(pin, af, drv) \
415  ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK)) |\
416  (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv))
417 
418 #define MFP_CFG_LPM(pin, af, lpm) \
419  ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_LPM_STATE_MASK)) |\
420  (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_LPM_##lpm))
421 
422 #define MFP_CFG_X(pin, af, drv, lpm) \
423  ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK | MFP_LPM_STATE_MASK)) |\
424  (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv | MFP_LPM_##lpm))
425 
426 #if defined(CONFIG_PXA3xx) || defined(CONFIG_PXA95x) || defined(CONFIG_ARCH_MMP)
427 /*
428  * each MFP pin will have a MFPR register, since the offset of the
429  * register varies between processors, the processor specific code
430  * should initialize the pin offsets by mfp_init()
431  *
432  * mfp_init_base() - accepts a virtual base for all MFPR registers and
433  * initialize the MFP table to a default state
434  *
435  * mfp_init_addr() - accepts a table of "mfp_addr_map" structure, which
436  * represents a range of MFP pins from "start" to "end", with the offset
437  * beginning at "offset", to define a single pin, let "end" = -1.
438  *
439  * use
440  *
441  * MFP_ADDR_X() to define a range of pins
442  * MFP_ADDR() to define a single pin
443  * MFP_ADDR_END to signal the end of pin offset definitions
444  */
445 struct mfp_addr_map {
446  unsigned int start;
447  unsigned int end;
448  unsigned long offset;
449 };
450 
451 #define MFP_ADDR_X(start, end, offset) \
452  { MFP_PIN_##start, MFP_PIN_##end, offset }
453 
454 #define MFP_ADDR(pin, offset) \
455  { MFP_PIN_##pin, -1, offset }
456 
457 #define MFP_ADDR_END { MFP_PIN_INVALID, 0 }
458 
459 void __init mfp_init_base(void __iomem *mfpr_base);
460 void __init mfp_init_addr(struct mfp_addr_map *map);
461 
462 /*
463  * mfp_{read, write}() - for direct read/write access to the MFPR register
464  * mfp_config() - for configuring a group of MFPR registers
465  * mfp_config_lpm() - configuring all low power MFPR registers for suspend
466  * mfp_config_run() - configuring all run time MFPR registers after resume
467  */
468 unsigned long mfp_read(int mfp);
469 void mfp_write(int mfp, unsigned long mfpr_val);
470 void mfp_config(unsigned long *mfp_cfgs, int num);
471 void mfp_config_run(void);
472 void mfp_config_lpm(void);
473 #endif /* CONFIG_PXA3xx || CONFIG_PXA95x || CONFIG_ARCH_MMP */
474 
475 #endif /* __ASM_PLAT_MFP_H */