2 * (c) Copyright 2009 Freescale Semiconductors
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <asm/arch/mx25.h>
25 #include <asm/arch/mx25_pins.h>
26 #include <asm/arch/gpio.h>
38 struct gpio_port_addr {
43 struct gpio_port_addr gpio_port[4] = {
51 * Set a GPIO pin's direction
52 * @param port pointer to a gpio_port
53 * @param index gpio pin index value (0~31)
54 * @param is_input 0 for output; non-zero for input
56 static void _set_gpio_direction(u32 port, u32 index, int is_input)
58 u32 reg = gpio_port[port].base + GDIR;
71 * Exported function to set a GPIO pin's direction
72 * @param pin a name defined by \b iomux_pin_name_t
73 * @param is_input 1 (or non-zero) for input; 0 for output
75 void mxc_set_gpio_direction(iomux_pin_name_t pin, int is_input)
78 u32 gpio = IOMUX_TO_GPIO(pin);
80 port = GPIO_TO_PORT(gpio);
81 _set_gpio_direction(port, GPIO_TO_INDEX(gpio), is_input);
85 * Set a GPIO pin's data output
86 * @param port number of gpio port
87 * @param index gpio pin index value (0~31)
88 * @param data value to be set (only 0 or 1 is valid)
90 static void _set_gpio_dataout(u32 port, u32 index, u32 data)
92 u32 reg = gpio_port[port].base + DR;
95 l = (__REG(reg) & (~(1 << index))) | (data << index);
100 * Exported function to set a GPIO pin's data output
101 * @param pin a name defined by \b iomux_pin_name_t
102 * @param data value to be set (only 0 or 1 is valid)
105 void mxc_set_gpio_dataout(iomux_pin_name_t pin, u32 data)
108 u32 gpio = IOMUX_TO_GPIO(pin);
110 port = GPIO_TO_PORT(gpio);
111 _set_gpio_dataout(port, GPIO_TO_INDEX(gpio), (data == 0) ? 0 : 1);