Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i.MX2 family: Add GPIO multiplexing support

This patch adds GPIO multiplexing support for the imx1/mxc2
family of procesors.

Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>

authored by

Juergen Beisert and committed by
Robert Schwebel
aa10abd3 259bcaae

+530
+2
arch/arm/plat-mxc/Makefile
··· 4 4 5 5 # Common support 6 6 obj-y := irq.o clock.o gpio.o time.o 7 + 8 + obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o
+156
arch/arm/plat-mxc/iomux-mx1-mx2.c
··· 1 + /* 2 + * arch/arm/mach-mxc/generic.c 3 + * 4 + * author: Sascha Hauer 5 + * Created: april 20th, 2004 6 + * Copyright: Synertronixx GmbH 7 + * 8 + * Common code for i.MX machines 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 as published by 12 + * the Free Software Foundation; either version 2 of the License, or 13 + * (at your option) any later version. 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, write to the Free Software 22 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 + * 24 + */ 25 + 26 + #include <linux/errno.h> 27 + #include <linux/init.h> 28 + #include <linux/kernel.h> 29 + #include <linux/module.h> 30 + #include <linux/string.h> 31 + #include <linux/gpio.h> 32 + 33 + #include <asm/hardware.h> 34 + #include <asm/mach/map.h> 35 + #include <asm/arch/iomux-mx1-mx2.h> 36 + 37 + void mxc_gpio_mode(int gpio_mode) 38 + { 39 + unsigned int pin = gpio_mode & GPIO_PIN_MASK; 40 + unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; 41 + unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT; 42 + unsigned int tmp; 43 + 44 + /* Pullup enable */ 45 + tmp = __raw_readl(VA_GPIO_BASE + MXC_PUEN(port)); 46 + if (gpio_mode & GPIO_PUEN) 47 + tmp |= (1 << pin); 48 + else 49 + tmp &= ~(1 << pin); 50 + __raw_writel(tmp, VA_GPIO_BASE + MXC_PUEN(port)); 51 + 52 + /* Data direction */ 53 + tmp = __raw_readl(VA_GPIO_BASE + MXC_DDIR(port)); 54 + if (gpio_mode & GPIO_OUT) 55 + tmp |= 1 << pin; 56 + else 57 + tmp &= ~(1 << pin); 58 + __raw_writel(tmp, VA_GPIO_BASE + MXC_DDIR(port)); 59 + 60 + /* Primary / alternate function */ 61 + tmp = __raw_readl(VA_GPIO_BASE + MXC_GPR(port)); 62 + if (gpio_mode & GPIO_AF) 63 + tmp |= (1 << pin); 64 + else 65 + tmp &= ~(1 << pin); 66 + __raw_writel(tmp, VA_GPIO_BASE + MXC_GPR(port)); 67 + 68 + /* use as gpio? */ 69 + tmp = __raw_readl(VA_GPIO_BASE + MXC_GIUS(port)); 70 + if (gpio_mode & (GPIO_PF | GPIO_AF)) 71 + tmp &= ~(1 << pin); 72 + else 73 + tmp |= (1 << pin); 74 + __raw_writel(tmp, VA_GPIO_BASE + MXC_GIUS(port)); 75 + 76 + if (pin < 16) { 77 + tmp = __raw_readl(VA_GPIO_BASE + MXC_OCR1(port)); 78 + tmp &= ~(3 << (pin * 2)); 79 + tmp |= (ocr << (pin * 2)); 80 + __raw_writel(tmp, VA_GPIO_BASE + MXC_OCR1(port)); 81 + 82 + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFA1(port)); 83 + tmp &= ~(3 << (pin * 2)); 84 + tmp |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2); 85 + __raw_writel(tmp, VA_GPIO_BASE + MXC_ICONFA1(port)); 86 + 87 + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFB1(port)); 88 + tmp &= ~(3 << (pin * 2)); 89 + tmp |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << (pin * 2); 90 + __raw_writel(tmp, VA_GPIO_BASE + MXC_ICONFB1(port)); 91 + } else { 92 + pin -= 16; 93 + 94 + tmp = __raw_readl(VA_GPIO_BASE + MXC_OCR2(port)); 95 + tmp &= ~(3 << (pin * 2)); 96 + tmp |= (ocr << (pin * 2)); 97 + __raw_writel(tmp, VA_GPIO_BASE + MXC_OCR2(port)); 98 + 99 + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFA2(port)); 100 + tmp &= ~(3 << (pin * 2)); 101 + tmp |= ((gpio_mode >> GPIO_AOUT_SHIFT) & 3) << (pin * 2); 102 + __raw_writel(tmp, VA_GPIO_BASE + MXC_ICONFA2(port)); 103 + 104 + tmp = __raw_readl(VA_GPIO_BASE + MXC_ICONFB2(port)); 105 + tmp &= ~(3 << (pin * 2)); 106 + tmp |= ((gpio_mode >> GPIO_BOUT_SHIFT) & 3) << (pin * 2); 107 + __raw_writel(tmp, VA_GPIO_BASE + MXC_ICONFB2(port)); 108 + } 109 + } 110 + EXPORT_SYMBOL(mxc_gpio_mode); 111 + 112 + int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count, 113 + int alloc_mode, const char *label) 114 + { 115 + const int *p = pin_list; 116 + int i; 117 + unsigned gpio; 118 + unsigned mode; 119 + 120 + for (i = 0; i < count; i++) { 121 + gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK); 122 + mode = *p & ~(GPIO_PIN_MASK | GPIO_PORT_MASK); 123 + 124 + if (gpio >= (GPIO_PORT_MAX + 1) * 32) 125 + goto setup_error; 126 + 127 + if (alloc_mode & MXC_GPIO_ALLOC_MODE_RELEASE) 128 + gpio_free(gpio); 129 + else if (!(alloc_mode & MXC_GPIO_ALLOC_MODE_NO_ALLOC)) 130 + if (gpio_request(gpio, label) 131 + && !(alloc_mode & MXC_GPIO_ALLOC_MODE_TRY_ALLOC)) 132 + goto setup_error; 133 + 134 + if (!(alloc_mode & (MXC_GPIO_ALLOC_MODE_ALLOC_ONLY | 135 + MXC_GPIO_ALLOC_MODE_RELEASE))) 136 + mxc_gpio_mode(gpio | mode); 137 + 138 + p++; 139 + } 140 + return 0; 141 + 142 + setup_error: 143 + if (alloc_mode & (MXC_GPIO_ALLOC_MODE_NO_ALLOC | 144 + MXC_GPIO_ALLOC_MODE_TRY_ALLOC)) 145 + return -EINVAL; 146 + 147 + while (p != pin_list) { 148 + p--; 149 + gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK); 150 + gpio_free(gpio); 151 + } 152 + 153 + return -EINVAL; 154 + } 155 + EXPORT_SYMBOL(mxc_gpio_setup_multiple_pins); 156 +
+372
include/asm-arm/arch-mxc/iomux-mx1-mx2.h
··· 1 + /* 2 + * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de> 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation; either version 2 7 + * of the License, or (at your option) any later version. 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + * You should have received a copy of the GNU General Public License 14 + * along with this program; if not, write to the Free Software 15 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 + * MA 02110-1301, USA. 17 + */ 18 + 19 + #ifndef _MXC_GPIO_MX1_MX2_H 20 + #define _MXC_GPIO_MX1_MX2_H 21 + 22 + #include <linux/io.h> 23 + 24 + #define MXC_GPIO_ALLOC_MODE_NORMAL 0 25 + #define MXC_GPIO_ALLOC_MODE_NO_ALLOC 1 26 + #define MXC_GPIO_ALLOC_MODE_TRY_ALLOC 2 27 + #define MXC_GPIO_ALLOC_MODE_ALLOC_ONLY 4 28 + #define MXC_GPIO_ALLOC_MODE_RELEASE 8 29 + 30 + /* 31 + * GPIO Module and I/O Multiplexer 32 + * x = 0..3 for reg_A, reg_B, reg_C, reg_D 33 + */ 34 + #define VA_GPIO_BASE IO_ADDRESS(GPIO_BASE_ADDR) 35 + #define MXC_DDIR(x) (0x00 + ((x) << 8)) 36 + #define MXC_OCR1(x) (0x04 + ((x) << 8)) 37 + #define MXC_OCR2(x) (0x08 + ((x) << 8)) 38 + #define MXC_ICONFA1(x) (0x0c + ((x) << 8)) 39 + #define MXC_ICONFA2(x) (0x10 + ((x) << 8)) 40 + #define MXC_ICONFB1(x) (0x14 + ((x) << 8)) 41 + #define MXC_ICONFB2(x) (0x18 + ((x) << 8)) 42 + #define MXC_DR(x) (0x1c + ((x) << 8)) 43 + #define MXC_GIUS(x) (0x20 + ((x) << 8)) 44 + #define MXC_SSR(x) (0x24 + ((x) << 8)) 45 + #define MXC_ICR1(x) (0x28 + ((x) << 8)) 46 + #define MXC_ICR2(x) (0x2c + ((x) << 8)) 47 + #define MXC_IMR(x) (0x30 + ((x) << 8)) 48 + #define MXC_ISR(x) (0x34 + ((x) << 8)) 49 + #define MXC_GPR(x) (0x38 + ((x) << 8)) 50 + #define MXC_SWR(x) (0x3c + ((x) << 8)) 51 + #define MXC_PUEN(x) (0x40 + ((x) << 8)) 52 + 53 + #ifdef CONFIG_ARCH_MX1 54 + # define GPIO_PORT_MAX 3 55 + #endif 56 + #ifdef CONFIG_ARCH_MX2 57 + # define GPIO_PORT_MAX 5 58 + #endif 59 + 60 + #ifndef GPIO_PORT_MAX 61 + # error "GPIO config port count unknown!" 62 + #endif 63 + 64 + #define GPIO_PIN_MASK 0x1f 65 + 66 + #define GPIO_PORT_SHIFT 5 67 + #define GPIO_PORT_MASK (0x7 << GPIO_PORT_SHIFT) 68 + 69 + #define GPIO_PORTA (0 << GPIO_PORT_SHIFT) 70 + #define GPIO_PORTB (1 << GPIO_PORT_SHIFT) 71 + #define GPIO_PORTC (2 << GPIO_PORT_SHIFT) 72 + #define GPIO_PORTD (3 << GPIO_PORT_SHIFT) 73 + #define GPIO_PORTE (4 << GPIO_PORT_SHIFT) 74 + #define GPIO_PORTF (5 << GPIO_PORT_SHIFT) 75 + 76 + #define GPIO_OUT (1 << 8) 77 + #define GPIO_IN (0 << 8) 78 + #define GPIO_PUEN (1 << 9) 79 + 80 + #define GPIO_PF (1 << 10) 81 + #define GPIO_AF (1 << 11) 82 + 83 + #define GPIO_OCR_SHIFT 12 84 + #define GPIO_OCR_MASK (3 << GPIO_OCR_SHIFT) 85 + #define GPIO_AIN (0 << GPIO_OCR_SHIFT) 86 + #define GPIO_BIN (1 << GPIO_OCR_SHIFT) 87 + #define GPIO_CIN (2 << GPIO_OCR_SHIFT) 88 + #define GPIO_GPIO (3 << GPIO_OCR_SHIFT) 89 + 90 + #define GPIO_AOUT_SHIFT 14 91 + #define GPIO_AOUT_MASK (3 << GPIO_AOUT_SHIFT) 92 + #define GPIO_AOUT (0 << GPIO_AOUT_SHIFT) 93 + #define GPIO_AOUT_ISR (1 << GPIO_AOUT_SHIFT) 94 + #define GPIO_AOUT_0 (2 << GPIO_AOUT_SHIFT) 95 + #define GPIO_AOUT_1 (3 << GPIO_AOUT_SHIFT) 96 + 97 + #define GPIO_BOUT_SHIFT 16 98 + #define GPIO_BOUT_MASK (3 << GPIO_BOUT_SHIFT) 99 + #define GPIO_BOUT (0 << GPIO_BOUT_SHIFT) 100 + #define GPIO_BOUT_ISR (1 << GPIO_BOUT_SHIFT) 101 + #define GPIO_BOUT_0 (2 << GPIO_BOUT_SHIFT) 102 + #define GPIO_BOUT_1 (3 << GPIO_BOUT_SHIFT) 103 + 104 + extern void mxc_gpio_mode(int gpio_mode); 105 + extern int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count, 106 + int alloc_mode, const char *label); 107 + 108 + /*-------------------------------------------------------------------------*/ 109 + 110 + /* assignements for GPIO alternate/primary functions */ 111 + 112 + /* FIXME: This list is not completed. The correct directions are 113 + * missing on some (many) pins 114 + */ 115 + #ifdef CONFIG_ARCH_MX1 116 + #define PA0_AIN_SPI2_CLK (GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 0) 117 + #define PA0_AF_ETMTRACESYNC (GPIO_PORTA | GPIO_AF | 0) 118 + #define PA1_AOUT_SPI2_RXD (GPIO_GIUS | GPIO_PORTA | GPIO_IN | 1) 119 + #define PA1_PF_TIN (GPIO_PORTA | GPIO_PF | 1) 120 + #define PA2_PF_PWM0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 2) 121 + #define PA3_PF_CSI_MCLK (GPIO_PORTA | GPIO_PF | 3) 122 + #define PA4_PF_CSI_D0 (GPIO_PORTA | GPIO_PF | 4) 123 + #define PA5_PF_CSI_D1 (GPIO_PORTA | GPIO_PF | 5) 124 + #define PA6_PF_CSI_D2 (GPIO_PORTA | GPIO_PF | 6) 125 + #define PA7_PF_CSI_D3 (GPIO_PORTA | GPIO_PF | 7) 126 + #define PA8_PF_CSI_D4 (GPIO_PORTA | GPIO_PF | 8) 127 + #define PA9_PF_CSI_D5 (GPIO_PORTA | GPIO_PF | 9) 128 + #define PA10_PF_CSI_D6 (GPIO_PORTA | GPIO_PF | 10) 129 + #define PA11_PF_CSI_D7 (GPIO_PORTA | GPIO_PF | 11) 130 + #define PA12_PF_CSI_VSYNC (GPIO_PORTA | GPIO_PF | 12) 131 + #define PA13_PF_CSI_HSYNC (GPIO_PORTA | GPIO_PF | 13) 132 + #define PA14_PF_CSI_PIXCLK (GPIO_PORTA | GPIO_PF | 14) 133 + #define PA15_PF_I2C_SDA (GPIO_PORTA | GPIO_OUT | GPIO_PF | 15) 134 + #define PA16_PF_I2C_SCL (GPIO_PORTA | GPIO_OUT | GPIO_PF | 16) 135 + #define PA17_AF_ETMTRACEPKT4 (GPIO_PORTA | GPIO_AF | 17) 136 + #define PA17_AIN_SPI2_SS (GPIO_GIUS | GPIO_PORTA | GPIO_OUT | 17) 137 + #define PA18_AF_ETMTRACEPKT5 (GPIO_PORTA | GPIO_AF | 18) 138 + #define PA19_AF_ETMTRACEPKT6 (GPIO_PORTA | GPIO_AF | 19) 139 + #define PA20_AF_ETMTRACEPKT7 (GPIO_PORTA | GPIO_AF | 20) 140 + #define PA21_PF_A0 (GPIO_PORTA | GPIO_PF | 21) 141 + #define PA22_PF_CS4 (GPIO_PORTA | GPIO_PF | 22) 142 + #define PA23_PF_CS5 (GPIO_PORTA | GPIO_PF | 23) 143 + #define PA24_PF_A16 (GPIO_PORTA | GPIO_PF | 24) 144 + #define PA24_AF_ETMTRACEPKT0 (GPIO_PORTA | GPIO_AF | 24) 145 + #define PA25_PF_A17 (GPIO_PORTA | GPIO_PF | 25) 146 + #define PA25_AF_ETMTRACEPKT1 (GPIO_PORTA | GPIO_AF | 25) 147 + #define PA26_PF_A18 (GPIO_PORTA | GPIO_PF | 26) 148 + #define PA26_AF_ETMTRACEPKT2 (GPIO_PORTA | GPIO_AF | 26) 149 + #define PA27_PF_A19 (GPIO_PORTA | GPIO_PF | 27) 150 + #define PA27_AF_ETMTRACEPKT3 (GPIO_PORTA | GPIO_AF | 27) 151 + #define PA28_PF_A20 (GPIO_PORTA | GPIO_PF | 28) 152 + #define PA28_AF_ETMPIPESTAT0 (GPIO_PORTA | GPIO_AF | 28) 153 + #define PA29_PF_A21 (GPIO_PORTA | GPIO_PF | 29) 154 + #define PA29_AF_ETMPIPESTAT1 (GPIO_PORTA | GPIO_AF | 29) 155 + #define PA30_PF_A22 (GPIO_PORTA | GPIO_PF | 30) 156 + #define PA30_AF_ETMPIPESTAT2 (GPIO_PORTA | GPIO_AF | 30) 157 + #define PA31_PF_A23 (GPIO_PORTA | GPIO_PF | 31) 158 + #define PA31_AF_ETMTRACECLK (GPIO_PORTA | GPIO_AF | 31) 159 + #define PB8_PF_SD_DAT0 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 8) 160 + #define PB8_AF_MS_PIO (GPIO_PORTB | GPIO_AF | 8) 161 + #define PB9_PF_SD_DAT1 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 9) 162 + #define PB9_AF_MS_PI1 (GPIO_PORTB | GPIO_AF | 9) 163 + #define PB10_PF_SD_DAT2 (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 10) 164 + #define PB10_AF_MS_SCLKI (GPIO_PORTB | GPIO_AF | 10) 165 + #define PB11_PF_SD_DAT3 (GPIO_PORTB | GPIO_PF | 11) 166 + #define PB11_AF_MS_SDIO (GPIO_PORTB | GPIO_AF | 11) 167 + #define PB12_PF_SD_CLK (GPIO_PORTB | GPIO_PF | 12) 168 + #define PB12_AF_MS_SCLK0 (GPIO_PORTB | GPIO_AF | 12) 169 + #define PB13_PF_SD_CMD (GPIO_PORTB | GPIO_PF | GPIO_PUEN | 13) 170 + #define PB13_AF_MS_BS (GPIO_PORTB | GPIO_AF | 13) 171 + #define PB14_AF_SSI_RXFS (GPIO_PORTB | GPIO_AF | 14) 172 + #define PB15_AF_SSI_RXCLK (GPIO_PORTB | GPIO_AF | 15) 173 + #define PB16_AF_SSI_RXDAT (GPIO_PORTB | GPIO_IN | GPIO_AF | 16) 174 + #define PB17_AF_SSI_TXDAT (GPIO_PORTB | GPIO_OUT | GPIO_AF | 17) 175 + #define PB18_AF_SSI_TXFS (GPIO_PORTB | GPIO_AF | 18) 176 + #define PB19_AF_SSI_TXCLK (GPIO_PORTB | GPIO_AF | 19) 177 + #define PB20_PF_USBD_AFE (GPIO_PORTB | GPIO_PF | 20) 178 + #define PB21_PF_USBD_OE (GPIO_PORTB | GPIO_PF | 21) 179 + #define PB22_PFUSBD_RCV (GPIO_PORTB | GPIO_PF | 22) 180 + #define PB23_PF_USBD_SUSPND (GPIO_PORTB | GPIO_PF | 23) 181 + #define PB24_PF_USBD_VP (GPIO_PORTB | GPIO_PF | 24) 182 + #define PB25_PF_USBD_VM (GPIO_PORTB | GPIO_PF | 25) 183 + #define PB26_PF_USBD_VPO (GPIO_PORTB | GPIO_PF | 26) 184 + #define PB27_PF_USBD_VMO (GPIO_PORTB | GPIO_PF | 27) 185 + #define PB28_PF_UART2_CTS (GPIO_PORTB | GPIO_OUT | GPIO_PF | 28) 186 + #define PB29_PF_UART2_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 29) 187 + #define PB30_PF_UART2_TXD (GPIO_PORTB | GPIO_OUT | GPIO_PF | 30) 188 + #define PB31_PF_UART2_RXD (GPIO_PORTB | GPIO_IN | GPIO_PF | 31) 189 + #define PC3_PF_SSI_RXFS (GPIO_PORTC | GPIO_PF | 3) 190 + #define PC4_PF_SSI_RXCLK (GPIO_PORTC | GPIO_PF | 4) 191 + #define PC5_PF_SSI_RXDAT (GPIO_PORTC | GPIO_IN | GPIO_PF | 5) 192 + #define PC6_PF_SSI_TXDAT (GPIO_PORTC | GPIO_OUT | GPIO_PF | 6) 193 + #define PC7_PF_SSI_TXFS (GPIO_PORTC | GPIO_PF | 7) 194 + #define PC8_PF_SSI_TXCLK (GPIO_PORTC | GPIO_PF | 8) 195 + #define PC9_PF_UART1_CTS (GPIO_PORTC | GPIO_OUT | GPIO_PF | 9) 196 + #define PC10_PF_UART1_RTS (GPIO_PORTC | GPIO_IN | GPIO_PF | 10) 197 + #define PC11_PF_UART1_TXD (GPIO_PORTC | GPIO_OUT | GPIO_PF | 11) 198 + #define PC12_PF_UART1_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 12) 199 + #define PC13_PF_SPI1_SPI_RDY (GPIO_PORTC | GPIO_PF | 13) 200 + #define PC14_PF_SPI1_SCLK (GPIO_PORTC | GPIO_PF | 14) 201 + #define PC15_PF_SPI1_SS (GPIO_PORTC | GPIO_PF | 15) 202 + #define PC16_PF_SPI1_MISO (GPIO_PORTC | GPIO_PF | 16) 203 + #define PC17_PF_SPI1_MOSI (GPIO_PORTC | GPIO_PF | 17) 204 + #define PC24_BIN_UART3_RI (GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 24) 205 + #define PC25_BIN_UART3_DSR (GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 25) 206 + #define PC26_AOUT_UART3_DTR (GPIO_GIUS | GPIO_PORTC | GPIO_IN | 26) 207 + #define PC27_BIN_UART3_DCD (GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 27) 208 + #define PC28_BIN_UART3_CTS (GPIO_GIUS | GPIO_PORTC | GPIO_OUT | GPIO_BIN | 28) 209 + #define PC29_AOUT_UART3_RTS (GPIO_GIUS | GPIO_PORTC | GPIO_IN | 29) 210 + #define PC30_BIN_UART3_TX (GPIO_GIUS | GPIO_PORTC | GPIO_BIN | 30) 211 + #define PC31_AOUT_UART3_RX (GPIO_GIUS | GPIO_PORTC | GPIO_IN | 31) 212 + #define PD6_PF_LSCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 6) 213 + #define PD7_PF_REV (GPIO_PORTD | GPIO_PF | 7) 214 + #define PD7_AF_UART2_DTR (GPIO_GIUS | GPIO_PORTD | GPIO_IN | GPIO_AF | 7) 215 + #define PD7_AIN_SPI2_SCLK (GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 7) 216 + #define PD8_PF_CLS (GPIO_PORTD | GPIO_PF | 8) 217 + #define PD8_AF_UART2_DCD (GPIO_PORTD | GPIO_OUT | GPIO_AF | 8) 218 + #define PD8_AIN_SPI2_SS (GPIO_GIUS | GPIO_PORTD | GPIO_AIN | 8) 219 + #define PD9_PF_PS (GPIO_PORTD | GPIO_PF | 9) 220 + #define PD9_AF_UART2_RI (GPIO_PORTD | GPIO_OUT | GPIO_AF | 9) 221 + #define PD9_AOUT_SPI2_RXD (GPIO_GIUS | GPIO_PORTD | GPIO_IN | 9) 222 + #define PD10_PF_SPL_SPR (GPIO_PORTD | GPIO_OUT | GPIO_PF | 10) 223 + #define PD10_AF_UART2_DSR (GPIO_PORTD | GPIO_OUT | GPIO_AF | 10) 224 + #define PD10_AIN_SPI2_TXD (GPIO_GIUS | GPIO_PORTD | GPIO_OUT | 10) 225 + #define PD11_PF_CONTRAST (GPIO_PORTD | GPIO_OUT | GPIO_PF | 11) 226 + #define PD12_PF_ACD_OE (GPIO_PORTD | GPIO_OUT | GPIO_PF | 12) 227 + #define PD13_PF_LP_HSYNC (GPIO_PORTD | GPIO_OUT | GPIO_PF | 13) 228 + #define PD14_PF_FLM_VSYNC (GPIO_PORTD | GPIO_OUT | GPIO_PF | 14) 229 + #define PD15_PF_LD0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 15) 230 + #define PD16_PF_LD1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 16) 231 + #define PD17_PF_LD2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17) 232 + #define PD18_PF_LD3 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18) 233 + #define PD19_PF_LD4 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 19) 234 + #define PD20_PF_LD5 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 20) 235 + #define PD21_PF_LD6 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 21) 236 + #define PD22_PF_LD7 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 22) 237 + #define PD23_PF_LD8 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 23) 238 + #define PD24_PF_LD9 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 24) 239 + #define PD25_PF_LD10 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25) 240 + #define PD26_PF_LD11 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26) 241 + #define PD27_PF_LD12 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27) 242 + #define PD28_PF_LD13 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28) 243 + #define PD29_PF_LD14 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29) 244 + #define PD30_PF_LD15 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 30) 245 + #define PD31_PF_TMR2OUT (GPIO_PORTD | GPIO_PF | 31) 246 + #define PD31_BIN_SPI2_TXD (GPIO_GIUS | GPIO_PORTD | GPIO_BIN | 31) 247 + #endif 248 + 249 + #ifdef CONFIG_ARCH_MX2 250 + #define PA5_PF_LSCLK (GPIO_PORTA | GPIO_OUT | GPIO_PF | 5) 251 + #define PA6_PF_LD0 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 6) 252 + #define PA7_PF_LD1 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 7) 253 + #define PA8_PF_LD2 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 8) 254 + #define PA9_PF_LD3 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 9) 255 + #define PA10_PF_LD4 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 10) 256 + #define PA11_PF_LD5 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 11) 257 + #define PA12_PF_LD6 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 12) 258 + #define PA13_PF_LD7 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 13) 259 + #define PA14_PF_LD8 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 14) 260 + #define PA15_PF_LD9 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 15) 261 + #define PA16_PF_LD10 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 16) 262 + #define PA17_PF_LD11 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 17) 263 + #define PA18_PF_LD12 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 18) 264 + #define PA19_PF_LD13 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 19) 265 + #define PA20_PF_LD14 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 20) 266 + #define PA21_PF_LD15 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 21) 267 + #define PA22_PF_LD16 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 22) 268 + #define PA23_PF_LD17 (GPIO_PORTA | GPIO_OUT | GPIO_PF | 23) 269 + #define PA24_PF_REV (GPIO_PORTA | GPIO_OUT | GPIO_PF | 24) 270 + #define PA25_PF_CLS (GPIO_PORTA | GPIO_OUT | GPIO_PF | 25) 271 + #define PA26_PF_PS (GPIO_PORTA | GPIO_OUT | GPIO_PF | 26) 272 + #define PA27_PF_SPL_SPR (GPIO_PORTA | GPIO_OUT | GPIO_PF | 27) 273 + #define PA28_PF_HSYNC (GPIO_PORTA | GPIO_OUT | GPIO_PF | 28) 274 + #define PA29_PF_VSYNC (GPIO_PORTA | GPIO_OUT | GPIO_PF | 29) 275 + #define PA30_PF_CONTRAST (GPIO_PORTA | GPIO_OUT | GPIO_PF | 30) 276 + #define PA31_PF_OE_ACD (GPIO_PORTA | GPIO_OUT | GPIO_PF | 31) 277 + #define PB10_PF_CSI_D0 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 10) 278 + #define PB10_AF_UART6_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 10) 279 + #define PB11_PF_CSI_D1 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 11) 280 + #define PB11_AF_UART6_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 11) 281 + #define PB12_PF_CSI_D2 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 12) 282 + #define PB12_AF_UART6_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 12) 283 + #define PB13_PF_CSI_D3 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 13) 284 + #define PB13_AF_UART6_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 13) 285 + #define PB14_PF_CSI_D4 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 14) 286 + #define PB15_PF_CSI_MCLK (GPIO_PORTB | GPIO_OUT | GPIO_PF | 15) 287 + #define PB16_PF_CSI_PIXCLK (GPIO_PORTB | GPIO_OUT | GPIO_PF | 16) 288 + #define PB17_PF_CSI_D5 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 17) 289 + #define PB18_PF_CSI_D6 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 18) 290 + #define PB18_AF_UART5_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 18) 291 + #define PB19_PF_CSI_D7 (GPIO_PORTB | GPIO_OUT | GPIO_PF | 19) 292 + #define PB19_AF_UART5_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 19) 293 + #define PB20_PF_CSI_VSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 20) 294 + #define PB20_AF_UART5_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 20) 295 + #define PB21_PF_CSI_HSYNC (GPIO_PORTB | GPIO_OUT | GPIO_PF | 21) 296 + #define PB21_AF_UART5_RTS (GPIO_PORTB | GPIO_IN | GPIO_AF | 21) 297 + #define PB26_AF_UART4_RTS (GPIO_PORTB | GPIO_IN | GPIO_PF | 26) 298 + #define PB28_AF_UART4_TXD (GPIO_PORTB | GPIO_OUT | GPIO_AF | 28) 299 + #define PB29_AF_UART4_CTS (GPIO_PORTB | GPIO_OUT | GPIO_AF | 29) 300 + #define PB31_AF_UART4_RXD (GPIO_PORTB | GPIO_IN | GPIO_AF | 31) 301 + #define PC5_PF_I2C2_SDA (GPIO_PORTC | GPIO_IN | GPIO_PF | 5) 302 + #define PC6_PF_I2C2_SCL (GPIO_PORTC | GPIO_IN | GPIO_PF | 6) 303 + #define PC16_PF_SSI4_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 16) 304 + #define PC17_PF_SSI4_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 17) 305 + #define PC18_PF_SSI4_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 18) 306 + #define PC19_PF_SSI4_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 19) 307 + #define PC20_PF_SSI1_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 20) 308 + #define PC21_PF_SSI1_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 21) 309 + #define PC22_PF_SSI1_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 22) 310 + #define PC23_PF_SSI1_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 23) 311 + #define PC24_PF_SSI2_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 24) 312 + #define PC25_PF_SSI2_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 25) 313 + #define PC26_PF_SSI2_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 26) 314 + #define PC27_PF_SSI2_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 27) 315 + #define PC28_PF_SSI3_FS (GPIO_PORTC | GPIO_IN | GPIO_PF | 28) 316 + #define PC29_PF_SSI3_RXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 29) 317 + #define PC30_PF_SSI3_TXD (GPIO_PORTC | GPIO_IN | GPIO_PF | 30) 318 + #define PC31_PF_SSI3_CLK (GPIO_PORTC | GPIO_IN | GPIO_PF | 31) 319 + #define PD0_AIN_FEC_TXD0 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 0) 320 + #define PD1_AIN_FEC_TXD1 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 1) 321 + #define PD2_AIN_FEC_TXD2 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 2) 322 + #define PD3_AIN_FEC_TXD3 (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 3) 323 + #define PD4_AOUT_FEC_RX_ER (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 4) 324 + #define PD5_AOUT_FEC_RXD1 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 5) 325 + #define PD6_AOUT_FEC_RXD2 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 6) 326 + #define PD7_AOUT_FEC_RXD3 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 7) 327 + #define PD8_AF_FEC_MDIO (GPIO_PORTD | GPIO_IN | GPIO_AF | 8) 328 + #define PD9_AIN_FEC_MDC (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 9) 329 + #define PD10_AOUT_FEC_CRS (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 10) 330 + #define PD11_AOUT_FEC_TX_CLK (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 11) 331 + #define PD12_AOUT_FEC_RXD0 (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 12) 332 + #define PD13_AOUT_FEC_RX_DV (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 13) 333 + #define PD14_AOUT_FEC_CLR (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 14) 334 + #define PD15_AOUT_FEC_COL (GPIO_PORTD | GPIO_IN | GPIO_AOUT | 15) 335 + #define PD16_AIN_FEC_TX_ER (GPIO_PORTD | GPIO_OUT | GPIO_AIN | 16) 336 + #define PD17_PF_I2C_DATA (GPIO_PORTD | GPIO_OUT | GPIO_PF | 17) 337 + #define PD18_PF_I2C_CLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 18) 338 + #define PD25_PF_CSPI1_RDY (GPIO_PORTD | GPIO_OUT | GPIO_PF | 25) 339 + #define PD26_PF_CSPI1_SS2 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 26) 340 + #define PD27_PF_CSPI1_SS1 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 27) 341 + #define PD28_PF_CSPI1_SS0 (GPIO_PORTD | GPIO_OUT | GPIO_PF | 28) 342 + #define PD29_PF_CSPI1_SCLK (GPIO_PORTD | GPIO_OUT | GPIO_PF | 29) 343 + #define PD30_PF_CSPI1_MISO (GPIO_PORTD | GPIO_IN | GPIO_PF | 30) 344 + #define PD31_PF_CSPI1_MOSI (GPIO_PORTD | GPIO_OUT | GPIO_PF | 31) 345 + #define PF23_AIN_FEC_TX_EN (GPIO_PORTF | GPIO_OUT | GPIO_AIN | 23) 346 + #define PE3_PF_UART2_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 3) 347 + #define PE4_PF_UART2_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 4) 348 + #define PE6_PF_UART2_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 6) 349 + #define PE7_PF_UART2_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 7) 350 + #define PE8_PF_UART3_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 8) 351 + #define PE9_PF_UART3_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 9) 352 + #define PE10_PF_UART3_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 10) 353 + #define PE11_PF_UART3_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 11) 354 + #define PE12_PF_UART1_TXD (GPIO_PORTE | GPIO_OUT | GPIO_PF | 12) 355 + #define PE13_PF_UART1_RXD (GPIO_PORTE | GPIO_IN | GPIO_PF | 13) 356 + #define PE14_PF_UART1_CTS (GPIO_PORTE | GPIO_OUT | GPIO_PF | 14) 357 + #define PE15_PF_UART1_RTS (GPIO_PORTE | GPIO_IN | GPIO_PF | 15) 358 + #define PE18_AF_CSPI3_MISO (GPIO_PORTE | GPIO_IN | GPIO_AF | 18) 359 + #define PE21_AF_CSPI3_SS (GPIO_PORTE | GPIO_OUT | GPIO_AF | 21) 360 + #define PE22_AF_CSPI3_MOSI (GPIO_PORTE | GPIO_OUT | GPIO_AF | 22) 361 + #define PE23_AF_CSPI3_SCLK (GPIO_PORTE | GPIO_OUT | GPIO_AF | 23) 362 + #endif 363 + 364 + /* decode irq number to use with IMR(x), ISR(x) and friends */ 365 + #define IRQ_TO_REG(irq) ((irq - MXC_MAX_INT_LINES) >> 5) 366 + 367 + #define IRQ_GPIOA(x) (MXC_MAX_INT_LINES + x) 368 + #define IRQ_GPIOB(x) (IRQ_GPIOA(32) + x) 369 + #define IRQ_GPIOC(x) (IRQ_GPIOB(32) + x) 370 + #define IRQ_GPIOD(x) (IRQ_GPIOC(32) + x) 371 + 372 + #endif /* _MXC_GPIO_MX1_MX2_H */