]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/arm/cpu/arm920t/imx/generic.c
2 * arch/arm/mach-imx/generic.c
5 * Created: april 20th, 2004
6 * Copyright: Synertronixx GmbH
8 * Common code for i.MX machines
10 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm/arch/imx-regs.h>
19 void imx_gpio_mode(int gpio_mode
)
21 unsigned int pin
= gpio_mode
& GPIO_PIN_MASK
;
22 unsigned int port
= (gpio_mode
& GPIO_PORT_MASK
) >> 5;
23 unsigned int ocr
= (gpio_mode
& GPIO_OCR_MASK
) >> 10;
27 if(gpio_mode
& GPIO_PUEN
)
28 PUEN(port
) |= (1<<pin
);
30 PUEN(port
) &= ~(1<<pin
);
33 if(gpio_mode
& GPIO_OUT
)
36 DDIR(port
) &= ~(1<<pin
);
38 /* Primary / alternate function */
39 if(gpio_mode
& GPIO_AF
)
40 GPR(port
) |= (1<<pin
);
42 GPR(port
) &= ~(1<<pin
);
46 GIUS(port
) |= (1<<pin
);
48 GIUS(port
) &= ~(1<<pin
);
50 /* Output / input configuration */
51 /* FIXME: I'm not very sure about OCR and ICONF, someone
52 * should have a look over it
56 tmp
&= ~( 3<<(pin
*2));
57 tmp
|= (ocr
<< (pin
*2));
60 if( gpio_mode
& GPIO_AOUT
)
61 ICONFA1(port
) &= ~( 3<<(pin
*2));
62 if( gpio_mode
& GPIO_BOUT
)
63 ICONFB1(port
) &= ~( 3<<(pin
*2));
66 tmp
&= ~( 3<<((pin
-16)*2));
67 tmp
|= (ocr
<< ((pin
-16)*2));
70 if( gpio_mode
& GPIO_AOUT
)
71 ICONFA2(port
) &= ~( 3<<((pin
-16)*2));
72 if( gpio_mode
& GPIO_BOUT
)
73 ICONFB2(port
) &= ~( 3<<((pin
-16)*2));
77 #endif /* CONFIG_IMX */