2 * Copyright (C) 2009 Samsung Electronics
3 * Minkyu Kang <mk7.kang@samsung.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/arch/gpio.h>
30 static struct i2c_gpio_bus *i2c_gpio;
32 void i2c_gpio_init(struct i2c_gpio_bus *bus, int len, int index)
35 struct s5p_gpio_bank *bank;
39 /* init all i2c gpio buses */
40 for (i = 0; i < len; i++) {
41 bank = (struct s5p_gpio_bank *)i2c_gpio[i].bus->gpio_base;
44 gpio_direction_output(bank,
45 i2c_gpio[i].bus->sda_pin, 1);
48 gpio_direction_output(bank,
49 i2c_gpio[i].bus->scl_pin, 1);
53 i2c_set_bus_num(index);
56 void i2c_gpio_set(int line, int value)
58 struct s5p_gpio_bank *bank;
59 unsigned int bus_index;
61 bus_index = i2c_get_bus_num();
63 bank = (struct s5p_gpio_bank *)i2c_gpio[bus_index].bus->gpio_base;
66 line = i2c_gpio[bus_index].bus->sda_pin;
68 line = i2c_gpio[bus_index].bus->scl_pin;
70 gpio_set_value(bank, line, value);
73 int i2c_gpio_get(void)
75 struct s5p_gpio_bank *bank;
76 unsigned int bus_index;
78 bus_index = i2c_get_bus_num();
80 bank = (struct s5p_gpio_bank *)i2c_gpio[bus_index].bus->gpio_base;
82 return gpio_get_value(bank, i2c_gpio[bus_index].bus->sda_pin);
85 void i2c_gpio_dir(int dir)
87 struct s5p_gpio_bank *bank;
88 unsigned int bus_index;
90 bus_index = i2c_get_bus_num();
92 bank = (struct s5p_gpio_bank *)i2c_gpio[bus_index].bus->gpio_base;
95 gpio_direction_output(bank,
96 i2c_gpio[bus_index].bus->sda_pin, 0);
98 gpio_direction_input(bank,
99 i2c_gpio[bus_index].bus->sda_pin);