diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 884320e..222c7fc 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -419,6 +419,18 @@ config SCx200_ACB This support is also available as a module. If so, the module will be called scx200_acb. +config AU1100_I2C + tristate "Au1100 I2C using GPIO pins" + depends on SOC_AU1100 + select I2C_ALGOBIT + help + Enable the use of two GPIO pins of a Au1100 processor as an I2C bus. + + If you don't know what to do here, say N. + + This support is also available as a module. If so, the module + will be called i2c-au1100. + config I2C_SIS5595 tristate "SiS 5595" depends on I2C && PCI diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index ac56df5..adb7576 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o +obj-$(CONFIG_AU1100_I2C) += i2c-au1100.o ifeq ($(CONFIG_I2C_DEBUG_BUS),y) EXTRA_CFLAGS += -DDEBUG diff --git a/drivers/i2c/busses/i2c-au1100.c b/drivers/i2c/busses/i2c-au1100.c new file mode 100644 index 0000000..e010cf8 --- /dev/null +++ b/drivers/i2c/busses/i2c-au1100.c @@ -0,0 +1,139 @@ +/* + i2c-au1100.c - I2C support for Au1100 + + Copyright (c) 2006 Rodolfo Giometti + Copyright (c) 2006 Eurotech S.p.A. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define NAME "au1100_i2c" + +#if 0 + /* put here the per-board settings */ +#else +/* The default GPIOs */ +static int scl = 31; +static int sda = 30; +#endif + +module_param(scl, int, 0); +MODULE_PARM_DESC(scl, "GPIO line for SCL"); +module_param(sda, int, 0); +MODULE_PARM_DESC(sda, "GPIO line for SDA"); + +/* --- Local functions ----------------------------------------------------- */ + +static inline void au1100_gpio_set(int gpio, int state) +{ + if (state) + au_writel(1< 31 || sda > 31 || scl == sda) { + printk(KERN_ERR NAME ": invalid \"scl\" and \"sda\" values\n"); + return -EINVAL; + } + + /* Configure GPIOs as outputs */ + au1100_gpio_set(scl, 1); + au1100_gpio_set(sda, 1); + + if (i2c_bit_add_bus(&au1100_i2c_ops) < 0) { + printk(KERN_ERR NAME ": adapter \"%s\" registration failed\n", + au1100_i2c_ops.name); + return -ENODEV; + } + + pr_info(NAME ": Au1100 I2C Driver enabled\n"); + + return 0; +} + +static void au1100_i2c_cleanup(void) +{ + i2c_bit_del_bus(&au1100_i2c_ops); +} + +module_init(au1100_i2c_init); +module_exit(au1100_i2c_cleanup); + +MODULE_AUTHOR("Rodolfo Giometti "); +MODULE_DESCRIPTION("Au1100 I2C Driver"); +MODULE_LICENSE("GPL");