#ifndef __ASM_ARCH_MFP_PXA27X_H
#define __ASM_ARCH_MFP_PXA27X_H

/*
 * NOTE:  for those special-function bidirectional GPIOs, as described
 * in the "PXA27x Developer's Manual" Section 24.4.2.1, only its input
 * alternative is preserved, the direction is actually selected by the
 * specific controller, and this should work in most cases.
 */

#include <mach/mfp-pxa2xx.h>

/* Note: GPIO3/GPIO4 will be driven by Power I2C when PCFR/PI2C_EN
 * bit is set, regardless of the GPIO configuration
 */
#define GPIO3_GPIO		MFP_CFG_IN(GPIO3, AF0)
#define GPIO4_GPIO		MFP_CFG_IN(GPIO4, AF0)

/* GPIO */
#define GPIO85_GPIO		MFP_CFG_IN(GPIO85, AF0)
#define GPIO86_GPIO		MFP_CFG_IN(GPIO86, AF0)
#define GPIO87_GPIO		MFP_CFG_IN(GPIO87, AF0)
#define GPIO88_GPIO		MFP_CFG_IN(GPIO88, AF0)
#define GPIO89_GPIO		MFP_CFG_IN(GPIO89, AF0)
#define GPIO90_GPIO		MFP_CFG_IN(GPIO90, AF0)
#define GPIO91_GPIO		MFP_CFG_IN(GPIO91, AF0)
#define GPIO92_GPIO		MFP_CFG_IN(GPIO92, AF0)
#define GPIO93_GPIO		MFP_CFG_IN(GPIO93, AF0)
#define GPIO94_GPIO		MFP_CFG_IN(GPIO94, AF0)
#define GPIO95_GPIO		MFP_CFG_IN(GPIO95, AF0)
#define GPIO96_GPIO		MFP_CFG_IN(GPIO96, AF0)
#define GPIO97_GPIO		MFP_CFG_IN(GPIO97, AF0)
#define GPIO98_GPIO		MFP_CFG_IN(GPIO98, AF0)
#define GPIO99_GPIO		MFP_CFG_IN(GPIO99, AF0)
#define GPIO100_GPIO		MFP_CFG_IN(GPIO100, AF0)
#define GPIO101_GPIO		MFP_CFG_IN(GPIO101, AF0)
#define GPIO102_GPIO		MFP_CFG_IN(GPIO102, AF0)
#define GPIO103_GPIO		MFP_CFG_IN(GPIO103, AF0)
#define GPIO104_GPIO		MFP_CFG_IN(GPIO104, AF0)
#define GPIO105_GPIO		MFP_CFG_IN(GPIO105, AF0)
#define GPIO106_GPIO		MFP_CFG_IN(GPIO106, AF0)
#define GPIO107_GPIO		MFP_CFG_IN(GPIO107, AF0)
#define GPIO108_GPIO		MFP_CFG_IN(GPIO108, AF0)
#define GPIO109_GPIO		MFP_CFG_IN(GPIO109, AF0)
#define GPIO110_GPIO		MFP_CFG_IN(GPIO110, AF0)
#define GPIO111_GPIO		MFP_CFG_IN(GPIO111, AF0)
#define GPIO112_GPIO		MFP_CFG_IN(GPIO112, AF0)
#define GPIO113_GPIO		MFP_CFG_IN(GPIO113, AF0)
#define GPIO114_GPIO		MFP_CFG_IN(GPIO114, AF0)
#define GPIO115_GPIO		MFP_CFG_IN(GPIO115, AF0)
#define GPIO116_GPIO		MFP_CFG_IN(GPIO116, AF0)
#define GPIO117_GPIO		MFP_CFG_IN(GPIO117, AF0)
#define GPIO118_GPIO		MFP_CFG_IN(GPIO118, AF0)
#define GPIO119_GPIO		MFP_CFG_IN(GPIO119, AF0)
#define GPIO120_GPIO		MFP_CFG_IN(GPIO120, AF0)

/* Crystal and Clock Signals */
#define GPIO9_HZ_CLK		MFP_CFG_OUT(GPIO9,  AF1, DRIVE_LOW)
#define GPIO10_HZ_CLK		MFP_CFG_OUT(GPIO10, AF1, DRIVE_LOW)
#define GPIO11_48_MHz		MFP_CFG_OUT(GPIO11, AF3, DRIVE_LOW)
#define GPIO12_48_MHz		MFP_CFG_OUT(GPIO12, AF3, DRIVE_LOW)
#define GPIO13_CLK_EXT		MFP_CFG_IN(GPIO13, AF1)

/* OS Timer Signals */
#define GPIO11_EXT_SYNC_0	MFP_CFG_IN(GPIO11, AF1)
#define GPIO12_EXT_SYNC_1	MFP_CFG_IN(GPIO12, AF1)
#define GPIO9_CHOUT_0		MFP_CFG_OUT(GPIO9,  AF3, DRIVE_LOW)
#define GPIO10_CHOUT_1		MFP_CFG_OUT(GPIO10, AF3, DRIVE_LOW)
#define GPIO11_CHOUT_0		MFP_CFG_OUT(GPIO11, AF1, DRIVE_LOW)
#define GPIO12_CHOUT_1		MFP_CFG_OUT(GPIO12, AF1, DRIVE_LOW)

/* SDRAM and Static Memory I/O Signals */
#define GPIO20_nSDCS_2		MFP_CFG_OUT(GPIO20, AF1, DRIVE_HIGH)
#define GPIO21_nSDCS_3		MFP_CFG_OUT(GPIO21, AF1, DRIVE_HIGH)
#define GPIO15_nCS_1		MFP_CFG_OUT(GPIO15, AF2, DRIVE_HIGH)
#define GPIO78_nCS_2		MFP_CFG_OUT(GPIO78, AF2, DRIVE_HIGH)
#define GPIO79_nCS_3		MFP_CFG_OUT(GPIO79, AF2, DRIVE_HIGH)
#define GPIO80_nCS_4		MFP_CFG_OUT(GPIO80, AF2, DRIVE_HIGH)
#define GPIO33_nCS_5		MFP_CFG_OUT(GPIO33, AF2, DRIVE_HIGH)

/* Miscellaneous I/O and DMA Signals */
#define GPIO21_DVAL_0		MFP_CFG_OUT(GPIO21, AF2, DRIVE_HIGH)
#define GPIO116_DVAL_0		MFP_CFG_OUT(GPIO116, AF1, DRIVE_HIGH)
#define GPIO33_DVAL_1		MFP_CFG_OUT(GPIO33, AF1, DRIVE_HIGH)
#define GPIO96_DVAL_1		MFP_CFG_OUT(GPIO96, AF2, DRIVE_HIGH)
#define GPIO18_RDY		MFP_CFG_IN(GPIO18, AF1)
#define GPIO20_DREQ_0		MFP_CFG_IN(GPIO20, AF1)
#define GPIO115_DREQ_0		MFP_CFG_IN(GPIO115, AF1)
#define GPIO80_DREQ_1		MFP_CFG_IN(GPIO80, AF1)
#define GPIO97_DREQ_1		MFP_CFG_IN(GPIO97, AF2)
#define GPIO85_DREQ_2		MFP_CFG_IN(GPIO85, AF2)
#define GPIO100_DREQ_2		MFP_CFG_IN(GPIO100, AF2)

/* Alternate Bus Master Mode I/O Signals */
#define GPIO20_MBREQ		MFP_CFG_IN(GPIO20, AF2)
#define GPIO80_MBREQ		MFP_CFG_IN(GPIO80, AF2)
#define GPIO96_MBREQ		MFP_CFG_IN(GPIO96, AF2)
#define GPIO115_MBREQ		MFP_CFG_IN(GPIO115, AF3)
#define GPIO21_MBGNT		MFP_CFG_OUT(GPIO21, AF3, DRIVE_LOW)
#define GPIO33_MBGNT		MFP_CFG_OUT(GPIO33, AF3, DRIVE_LOW)
#define GPIO97_MBGNT		MFP_CFG_OUT(GPIO97, AF2, DRIVE_LOW)
#define GPIO116_MBGNT		MFP_CFG_OUT(GPIO116, AF3, DRIVE_LOW)

/* PC CARD */
#define GPIO15_nPCE_1		MFP_CFG_OUT(GPIO15, AF1, DRIVE_HIGH)
#define GPIO85_nPCE_1		MFP_CFG_OUT(GPIO85, AF1, DRIVE_HIGH)
#define GPIO86_nPCE_1		MFP_CFG_OUT(GPIO86, AF1, DRIVE_HIGH)
#define GPIO102_nPCE_1		MFP_CFG_OUT(GPIO102, AF1, DRIVE_HIGH)
#define GPIO54_nPCE_2		MFP_CFG_OUT(GPIO54, AF2, DRIVE_HIGH)
#define GPIO78_nPCE_2		MFP_CFG_OUT(GPIO78, AF1, DRIVE_HIGH)
#define GPIO87_nPCE_2		MFP_CFG_IN(GPIO87, AF1)
#define GPIO55_nPREG		MFP_CFG_OUT(GPIO55, AF2, DRIVE_HIGH)
#define GPIO50_nPIOR		MFP_CFG_OUT(GPIO50, AF2, DRIVE_HIGH)
#define GPIO51_nPIOW		MFP_CFG_OUT(GPIO51, AF2, DRIVE_HIGH)
#define GPIO49_nPWE		MFP_CFG_OUT(GPIO49, AF2, DRIVE_HIGH)
#define GPIO48_nPOE		MFP_CFG_OUT(GPIO48, AF2, DRIVE_HIGH)
#define GPIO57_nIOIS16		MFP_CFG_IN(GPIO57, AF1)
#define GPIO56_nPWAIT		MFP_CFG_IN(GPIO56, AF1)
#define GPIO79_PSKTSEL		MFP_CFG_OUT(GPIO79, AF1, DRIVE_HIGH)
#define GPIO104_PSKTSEL		MFP_CFG_OUT(GPIO104, AF1, DRIVE_HIGH)

/* I2C */
#define GPIO117_I2C_SCL		MFP_CFG_IN(GPIO117, AF1)
#define GPIO118_I2C_SDA		MFP_CFG_IN(GPIO118, AF1)

/* FFUART */
#define GPIO9_FFUART_CTS	MFP_CFG_IN(GPIO9, AF3)
#define GPIO26_FFUART_CTS	MFP_CFG_IN(GPIO26, AF3)
#define GPIO35_FFUART_CTS	MFP_CFG_IN(GPIO35, AF1)
#define GPIO100_FFUART_CTS	MFP_CFG_IN(GPIO100, AF3)
#define GPIO10_FFUART_DCD	MFP_CFG_IN(GPIO10, AF1)
#define GPIO36_FFUART_DCD	MFP_CFG_IN(GPIO36, AF1)
#define GPIO33_FFUART_DSR	MFP_CFG_IN(GPIO33, AF2)
#define GPIO37_FFUART_DSR	MFP_CFG_IN(GPIO37, AF1)
#define GPIO38_FFUART_RI	MFP_CFG_IN(GPIO38, AF1)
#define GPIO89_FFUART_RI	MFP_CFG_IN(GPIO89, AF3)
#define GPIO19_FFUART_RXD	MFP_CFG_IN(GPIO19, AF3)
#define GPIO33_FFUART_RXD	MFP_CFG_IN(GPIO33, AF1)
#define GPIO34_FFUART_RXD	MFP_CFG_IN(GPIO34, AF1)
#define GPIO41_FFUART_RXD	MFP_CFG_IN(GPIO41, AF1)
#define GPIO53_FFUART_RXD	MFP_CFG_IN(GPIO53, AF1)
#define GPIO85_FFUART_RXD	MFP_CFG_IN(GPIO85, AF1)
#define GPIO96_FFUART_RXD	MFP_CFG_IN(GPIO96, AF3)
#define GPIO102_FFUART_RXD	MFP_CFG_IN(GPIO102, AF3)
#define GPIO16_FFUART_TXD	MFP_CFG_OUT(GPIO16, AF3, DRIVE_HIGH)
#define GPIO37_FFUART_TXD	MFP_CFG_OUT(GPIO37, AF3, DRIVE_HIGH)
#define GPIO39_FFUART_TXD	MFP_CFG_OUT(GPIO39, AF2, DRIVE_HIGH)
#define GPIO83_FFUART_TXD	MFP_CFG_OUT(GPIO83, AF2, DRIVE_HIGH)
#define GPIO99_FFUART_TXD	MFP_CFG_OUT(GPIO99, AF3, DRIVE_HIGH)
#define GPIO27_FFUART_RTS	MFP_CFG_OUT(GPIO27, AF3, DRIVE_HIGH)
#define GPIO41_FFUART_RTS	MFP_CFG_OUT(GPIO41, AF2, DRIVE_HIGH)
#define GPIO83_FFUART_RTS	MFP_CFG_OUT(GPIO83, AF3, DRIVE_HIGH)
#define GPIO98_FFUART_RTS	MFP_CFG_OUT(GPIO98, AF3, DRIVE_HIGH)
#define GPIO40_FFUART_DTR	MFP_CFG_OUT(GPIO40, AF2, DRIVE_HIGH)
#define GPIO82_FFUART_DTR	MFP_CFG_OUT(GPIO82, AF3, DRIVE_HIGH)

/* BTUART */
#define GPIO44_BTUART_CTS	MFP_CFG_IN(GPIO44, AF1)
#define GPIO42_BTUART_RXD	MFP_CFG_IN(GPIO42, AF1)
#define GPIO45_BTUART_RTS	MFP_CFG_OUT(GPIO45, AF2, DRIVE_HIGH)
#define GPIO45_BTUART_RTS_LPM_LOW	MFP_CFG_OUT(GPIO45, AF2, DRIVE_LOW)
#define GPIO43_BTUART_TXD	MFP_CFG_OUT(GPIO43, AF2, DRIVE_HIGH)
#define GPIO43_BTUART_TXD_LPM_LOW	MFP_CFG_OUT(GPIO43, AF2, DRIVE_LOW)

/* STUART */
#define GPIO46_STUART_RXD	MFP_CFG_IN(GPIO46, AF2)
#define GPIO47_STUART_TXD	MFP_CFG_OUT(GPIO47, AF1, DRIVE_HIGH)

/* FICP */
#define GPIO42_FICP_RXD		MFP_CFG_IN(GPIO42, AF2)
#define GPIO46_FICP_RXD		MFP_CFG_IN(GPIO46, AF1)
#define GPIO43_FICP_TXD		MFP_CFG_OUT(GPIO43, AF1, DRIVE_HIGH)
#define GPIO47_FICP_TXD		MFP_CFG_OUT(GPIO47, AF2, DRIVE_HIGH)

/* PWM 0/1/2/3 */
#define GPIO11_PWM2_OUT		MFP_CFG_OUT(GPIO11, AF2, DRIVE_LOW)
#define GPIO12_PWM3_OUT		MFP_CFG_OUT(GPIO12, AF2, DRIVE_LOW)
#define GPIO16_PWM0_OUT		MFP_CFG_OUT(GPIO16, AF2, DRIVE_LOW)
#define GPIO17_PWM1_OUT		MFP_CFG_OUT(GPIO17, AF2, DRIVE_LOW)
#define GPIO38_PWM1_OUT		MFP_CFG_OUT(GPIO38, AF3, DRIVE_LOW)
#define GPIO46_PWM2_OUT		MFP_CFG_OUT(GPIO46, AF2, DRIVE_LOW)
#define GPIO47_PWM3_OUT		MFP_CFG_OUT(GPIO47, AF3, DRIVE_LOW)
#define GPIO79_PWM2_OUT		MFP_CFG_OUT(GPIO79, AF3, DRIVE_LOW)
#define GPIO80_PWM3_OUT		MFP_CFG_OUT(GPIO80, AF3, DRIVE_LOW)
#define GPIO115_PWM1_OUT	MFP_CFG_OUT(GPIO115, AF3, DRIVE_LOW)

/* AC97 */
#define GPIO31_AC97_SYNC	MFP_CFG_OUT(GPIO31, AF2, DRIVE_LOW)
#define GPIO94_AC97_SYNC	MFP_CFG_OUT(GPIO94, AF1, DRIVE_LOW)
#define GPIO30_AC97_SDATA_OUT	MFP_CFG_OUT(GPIO30, AF2, DRIVE_LOW)
#define GPIO93_AC97_SDATA_OUT	MFP_CFG_OUT(GPIO93, AF1, DRIVE_LOW)
#define GPIO45_AC97_SYSCLK	MFP_CFG_OUT(GPIO45, AF1, DRIVE_LOW)
#define GPIO89_AC97_SYSCLK	MFP_CFG_OUT(GPIO89, AF1, DRIVE_LOW)
#define GPIO98_AC97_SYSCLK	MFP_CFG_OUT(GPIO98, AF1, DRIVE_LOW)
#define GPIO95_AC97_nRESET	MFP_CFG_OUT(GPIO95, AF1, DRIVE_LOW)
#define GPIO113_AC97_nRESET	MFP_CFG_OUT(GPIO113, AF2, DRIVE_LOW)
#define GPIO28_AC97_BITCLK	MFP_CFG_IN(GPIO28, AF1)
#define GPIO29_AC97_SDATA_IN_0	MFP_CFG_IN(GPIO29, AF1)
#define GPIO116_AC97_SDATA_IN_0	MFP_CFG_IN(GPIO116, AF2)
#define GPIO99_AC97_SDATA_IN_1	MFP_CFG_IN(GPIO99, AF2)

/* I2S */
#define GPIO28_I2S_BITCLK_IN	MFP_CFG_IN(GPIO28, AF2)
#define GPIO28_I2S_BITCLK_OUT	MFP_CFG_OUT(GPIO28, AF1, DRIVE_LOW)
#define GPIO29_I2S_SDATA_IN	MFP_CFG_IN(GPIO29, AF2)
#define GPIO30_I2S_SDATA_OUT	MFP_CFG_OUT(GPIO30, AF1, DRIVE_LOW)
#define GPIO31_I2S_SYNC		MFP_CFG_OUT(GPIO31, AF1, DRIVE_LOW)
#define GPIO113_I2S_SYSCLK	MFP_CFG_OUT(GPIO113, AF1, DRIVE_LOW)

/* SSP 1 */
#define GPIO23_SSP1_SCLK_IN	MFP_CFG_IN(GPIO23, AF2)
#define GPIO23_SSP1_SCLK	MFP_CFG_OUT(GPIO23, AF2, DRIVE_LOW)
#define GPIO29_SSP1_SCLK	MFP_CFG_IN(GPIO29, AF3)
#define GPIO27_SSP1_SYSCLK	MFP_CFG_OUT(GPIO27, AF1, DRIVE_LOW)
#define GPIO53_SSP1_SYSCLK	MFP_CFG_OUT(GPIO53, AF3, DRIVE_LOW)
#define GPIO24_SSP1_SFRM	MFP_CFG_IN(GPIO24, AF2)
#define GPIO28_SSP1_SFRM	MFP_CFG_IN(GPIO28, AF3)
#define GPIO25_SSP1_TXD		MFP_CFG_OUT(GPIO25, AF2, DRIVE_LOW)
#define GPIO57_SSP1_TXD		MFP_CFG_OUT(GPIO57, AF3, DRIVE_LOW)
#define GPIO26_SSP1_RXD		MFP_CFG_IN(GPIO26, AF1)
#define GPIO27_SSP1_SCLKEN	MFP_CFG_IN(GPIO27, AF2)

/* SSP 2 */
#define GPIO19_SSP2_SCLK	MFP_CFG_IN(GPIO19, AF1)
#define GPIO22_SSP2_SCLK	MFP_CFG_IN(GPIO22, AF3)
#define GPIO29_SSP2_SCLK	MFP_CFG_OUT(GPIO29, AF3, DRIVE_LOW)
#define GPIO36_SSP2_SCLK	MFP_CFG_IN(GPIO36, AF2)
#define GPIO50_SSP2_SCLK	MFP_CFG_IN(GPIO50, AF3)
#define GPIO22_SSP2_SYSCLK	MFP_CFG_OUT(GPIO22, AF2, DRIVE_LOW)
#define GPIO14_SSP2_SFRM	MFP_CFG_IN(GPIO14, AF2)
#define GPIO37_SSP2_SFRM	MFP_CFG_IN(GPIO37, AF2)
#define GPIO87_SSP2_SFRM	MFP_CFG_OUT(GPIO87, AF3, DRIVE_LOW)
#define GPIO88_SSP2_SFRM	MFP_CFG_IN(GPIO88, AF3)
#define GPIO13_SSP2_TXD		MFP_CFG_OUT(GPIO13, AF1, DRIVE_LOW)
#define GPIO38_SSP2_TXD		MFP_CFG_OUT(GPIO38, AF2, DRIVE_LOW)
#define GPIO87_SSP2_TXD		MFP_CFG_OUT(GPIO87, AF1, DRIVE_LOW)
#define GPIO89_SSP2_TXD		MFP_CFG_OUT(GPIO89, AF3, DRIVE_LOW)
#define GPIO11_SSP2_RXD		MFP_CFG_IN(GPIO11, AF2)
#define GPIO29_SSP2_RXD		MFP_CFG_OUT(GPIO29, AF1, DRIVE_LOW)
#define GPIO40_SSP2_RXD		MFP_CFG_IN(GPIO40, AF1)
