1 Index: linux-2.6.30.9/drivers/i2c/busses/Kconfig
2 ===================================================================
3 --- linux-2.6.30.9.orig/drivers/i2c/busses/Kconfig 2009-11-24 21:00:21.000000000 +0100
4 +++ linux-2.6.30.9/drivers/i2c/busses/Kconfig 2009-11-24 21:00:23.000000000 +0100
6 devices such as DaVinci NIC.
7 For details please see http://www.ti.com/davinci
10 + tristate "EP93XX I2C"
11 + depends on I2C && ARCH_EP93XX
14 tristate "GPIO-based bitbanging I2C"
15 depends on GENERIC_GPIO
16 Index: linux-2.6.30.9/drivers/i2c/busses/Makefile
17 ===================================================================
18 --- linux-2.6.30.9.orig/drivers/i2c/busses/Makefile 2009-11-24 21:00:21.000000000 +0100
19 +++ linux-2.6.30.9/drivers/i2c/busses/Makefile 2009-11-24 21:00:23.000000000 +0100
21 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
22 obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
23 obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
24 +obj-$(CONFIG_I2C_EP93XX) += i2c-ep93xx.o
25 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
26 obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
27 obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
28 Index: linux-2.6.30.9/drivers/i2c/busses/i2c-ep93xx.c
29 ===================================================================
30 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
31 +++ linux-2.6.30.9/drivers/i2c/busses/i2c-ep93xx.c 2009-11-24 21:00:38.000000000 +0100
33 +/* ------------------------------------------------------------------------ *
34 + * i2c-ep933xx.c I2C bus glue for Cirrus EP93xx *
35 + * ------------------------------------------------------------------------ *
37 + Copyright (C) 2004 Michael Burian
39 + Based on i2c-parport-light.c
40 + Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
42 + This program is free software; you can redistribute it and/or modify
43 + it under the terms of the GNU General Public License as published by
44 + the Free Software Foundation; either version 2 of the License, or
45 + (at your option) any later version.
47 + This program is distributed in the hope that it will be useful,
48 + but WITHOUT ANY WARRANTY; without even the implied warranty of
49 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 + GNU General Public License for more details.
52 + You should have received a copy of the GNU General Public License
53 + along with this program; if not, write to the Free Software
54 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
55 + * ------------------------------------------------------------------------ */
58 +//#include <linux/config.h>
59 +#include <linux/kernel.h>
60 +#include <linux/module.h>
61 +#include <linux/init.h>
62 +#include <linux/ioport.h>
63 +#include <linux/delay.h>
64 +#include <linux/i2c.h>
65 +#include <linux/i2c-algo-bit.h>
67 +#include <mach/hardware.h>
69 +//1/(2*clockfrequency)
70 +#define EE_DELAY_USEC 50
71 +#define GPIOG_EECLK 1
72 +#define GPIOG_EEDAT 2
74 +/* ----- I2C algorithm call-back functions and structures ----------------- */
77 +static void ep93xx_setscl(void *data, int state)
79 + unsigned int uiPGDR, uiPGDDR;
81 + uiPGDR = inl(GPIO_PGDR);
82 + uiPGDDR = inl(GPIO_PGDDR);
84 + /* Configure the clock line as output. */
85 + uiPGDDR |= GPIOG_EECLK;
86 + outl(uiPGDDR, GPIO_PGDDR);
88 + /* Set clock line to state */
90 + uiPGDR |= GPIOG_EECLK;
92 + uiPGDR &= ~GPIOG_EECLK;
94 + outl(uiPGDR, GPIO_PGDR);
97 +static void ep93xx_setsda(void *data, int state)
99 + unsigned int uiPGDR, uiPGDDR;
101 + uiPGDR = inl(GPIO_PGDR);
102 + uiPGDDR = inl(GPIO_PGDDR);
104 + /* Configure the data line as output. */
105 + uiPGDDR |= GPIOG_EEDAT;
106 + outl(uiPGDDR, GPIO_PGDDR);
108 + /* Set data line to state */
110 + uiPGDR |= GPIOG_EEDAT;
112 + uiPGDR &= ~GPIOG_EEDAT;
114 + outl(uiPGDR, GPIO_PGDR);
117 +static int ep93xx_getscl(void *data)
119 + unsigned int uiPGDR, uiPGDDR;
121 + uiPGDR = inl(GPIO_PGDR);
122 + uiPGDDR = inl(GPIO_PGDDR);
124 + /* Configure the clock line as input */
125 + uiPGDDR &= ~GPIOG_EECLK;
126 + outl(uiPGDDR, GPIO_PGDDR);
128 + /* Return state of the clock line */
129 + return (inl(GPIO_PGDR) & GPIOG_EECLK) ? 1 : 0;
132 +static int ep93xx_getsda(void *data)
134 + unsigned int uiPGDR, uiPGDDR;
135 + uiPGDR = inl(GPIO_PGDR);
136 + uiPGDDR = inl(GPIO_PGDDR);
138 + /* Configure the data line as input */
139 + uiPGDDR &= ~GPIOG_EEDAT;
140 + outl(uiPGDDR, GPIO_PGDDR);
142 + /* Return state of the data line */
143 + return (inl(GPIO_PGDR) & GPIOG_EEDAT) ? 1 : 0;
146 +/* ------------------------------------------------------------------------
147 + * Encapsulate the above functions in the correct operations structure.
148 + * This is only done when more than one hardware adapter is supported.
151 +/* last line (us, ms, timeout)
152 + * us dominates the bit rate: 10us means: 100Kbit/sec(25 means 40kbps)
156 +static struct i2c_algo_bit_data ep93xx_data = {
157 + .setsda = ep93xx_setsda,
158 + .setscl = ep93xx_setscl,
159 + .getsda = ep93xx_getsda,
160 + .getscl = ep93xx_getscl,
166 +/* ----- I2c structure ---------------------------------------------------- */
167 +static struct i2c_adapter ep93xx_adapter = {
168 + .owner = THIS_MODULE,
169 + .class = I2C_CLASS_HWMON,
170 + .algo_data = &ep93xx_data,
171 + .name = "EP93XX I2C bit-bang interface",
174 +/* ----- Module loading, unloading and information ------------------------ */
176 +static int __init i2c_ep93xx_init(void)
178 + unsigned long uiPGDR, uiPGDDR;
180 + /* Read the current value of the GPIO data and data direction registers. */
181 + uiPGDR = inl(GPIO_PGDR);
182 + uiPGDDR = inl(GPIO_PGDDR);
184 + /* If the GPIO pins have not been configured since reset, the data
185 + * and clock lines will be set as inputs and with data value of 0.
186 + * External pullup resisters are pulling them high.
187 + * Set them both high before configuring them as outputs. */
188 + uiPGDR |= (GPIOG_EEDAT | GPIOG_EECLK);
189 + outl(uiPGDR, GPIO_PGDR);
191 + /* Delay to meet the EE Interface timing specification. */
192 + udelay(EE_DELAY_USEC);
195 + /* Configure the EE data and clock lines as outputs. */
196 + uiPGDDR |= (GPIOG_EEDAT | GPIOG_EECLK);
197 + outl(uiPGDDR, GPIO_PGDDR);
199 + /* Delay to meet the EE Interface timing specification. */
200 + udelay(EE_DELAY_USEC);
202 + /* Reset hardware to a sane state (SCL and SDA high) */
203 + ep93xx_setsda(NULL, 1);
204 + ep93xx_setscl(NULL, 1);
206 + if (i2c_bit_add_bus(&ep93xx_adapter) > 0) {
207 + printk(KERN_ERR "i2c-ep93xx: Unable to register with I2C\n");
214 +static void __exit i2c_ep93xx_exit(void)
216 + //i2c_bit_del_bus(&ep93xx_adapter);
217 + i2c_del_adapter(&ep93xx_adapter);
220 +MODULE_AUTHOR("Michael Burian");
221 +MODULE_DESCRIPTION("I2C bus glue for Cirrus EP93xx processors");
222 +MODULE_LICENSE("GPL");
224 +module_init(i2c_ep93xx_init);
225 +module_exit(i2c_ep93xx_exit);