2 * arch/arm/mach-imx/generic.c
5 * Created: april 20th, 2004
6 * Copyright: Synertronixx GmbH
8 * Common code for i.MX machines
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.
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.
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
30 #include <asm/arch/imx-regs.h>
32 void imx_gpio_mode(int gpio_mode
)
34 unsigned int pin
= gpio_mode
& GPIO_PIN_MASK
;
35 unsigned int port
= (gpio_mode
& GPIO_PORT_MASK
) >> 5;
36 unsigned int ocr
= (gpio_mode
& GPIO_OCR_MASK
) >> 10;
40 if(gpio_mode
& GPIO_PUEN
)
41 PUEN(port
) |= (1<<pin
);
43 PUEN(port
) &= ~(1<<pin
);
46 if(gpio_mode
& GPIO_OUT
)
49 DDIR(port
) &= ~(1<<pin
);
51 /* Primary / alternate function */
52 if(gpio_mode
& GPIO_AF
)
53 GPR(port
) |= (1<<pin
);
55 GPR(port
) &= ~(1<<pin
);
59 GIUS(port
) |= (1<<pin
);
61 GIUS(port
) &= ~(1<<pin
);
63 /* Output / input configuration */
64 /* FIXME: I'm not very sure about OCR and ICONF, someone
65 * should have a look over it
69 tmp
&= ~( 3<<(pin
*2));
70 tmp
|= (ocr
<< (pin
*2));
73 if( gpio_mode
& GPIO_AOUT
)
74 ICONFA1(port
) &= ~( 3<<(pin
*2));
75 if( gpio_mode
& GPIO_BOUT
)
76 ICONFB1(port
) &= ~( 3<<(pin
*2));
79 tmp
&= ~( 3<<((pin
-16)*2));
80 tmp
|= (ocr
<< ((pin
-16)*2));
83 if( gpio_mode
& GPIO_AOUT
)
84 ICONFA2(port
) &= ~( 3<<((pin
-16)*2));
85 if( gpio_mode
& GPIO_BOUT
)
86 ICONFB2(port
) &= ~( 3<<((pin
-16)*2));
90 #endif /* CONFIG_IMX */