1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
drivers/i2c/algos/i2c-algo-bit.c | 24 +++++++++++++++++++
drivers/i2c/busses/i2c-ixp4xx.c | 47 ++++++++++++++++++++++++++++++++++++---
2 files changed, 67 insertions(+), 4 deletions(-)
--- linux-nas100d.orig/drivers/i2c/busses/i2c-ixp4xx.c 2005-11-11 22:22:43.000000000 +0100
+++ linux-nas100d/drivers/i2c/busses/i2c-ixp4xx.c 2005-11-14 17:06:04.000000000 +0100
@@ -47,16 +47,26 @@ static inline int ixp4xx_sda_pin(void *d
static void ixp4xx_bit_setscl(void *data, int val)
{
+#ifndef CONFIG_MACH_NAS100D
gpio_line_set(ixp4xx_scl_pin(data), 0);
gpio_line_config(ixp4xx_scl_pin(data),
val ? IXP4XX_GPIO_IN : IXP4XX_GPIO_OUT );
+#else
+ gpio_line_config(ixp4xx_scl_pin(data), IXP4XX_GPIO_OUT);
+ gpio_line_set(ixp4xx_scl_pin(data), val ? 1 : 0);
+#endif
}
static void ixp4xx_bit_setsda(void *data, int val)
{
+#ifndef CONFIG_MACH_NAS100D
gpio_line_set(ixp4xx_sda_pin(data), 0);
gpio_line_config(ixp4xx_sda_pin(data),
val ? IXP4XX_GPIO_IN : IXP4XX_GPIO_OUT );
+#else
+ gpio_line_config(ixp4xx_sda_pin(data), IXP4XX_GPIO_OUT);
+ gpio_line_set(ixp4xx_sda_pin(data), val ? 1 : 0);
+#endif
}
static int ixp4xx_bit_getscl(void *data)
@@ -65,7 +75,17 @@ static int ixp4xx_bit_getscl(void *data)
gpio_line_config(ixp4xx_scl_pin(data), IXP4XX_GPIO_IN );
gpio_line_get(ixp4xx_scl_pin(data), &scl);
-
+#ifdef CONFIG_MACH_NAS100D
+ {
+ int i;
+ for (i = 0; i <= 0x0f; i++)
+ {
+ gpio_line_get(ixp4xx_scl_pin(data), &scl);
+ if (scl == 0)
+ break;
+ }
+ }
+#endif
return scl;
}
@@ -76,6 +96,17 @@ static int ixp4xx_bit_getsda(void *data)
gpio_line_config(ixp4xx_sda_pin(data), IXP4XX_GPIO_IN );
gpio_line_get(ixp4xx_sda_pin(data), &sda);
+#ifdef CONFIG_MACH_NAS100D
+ {
+ int i;
+ for (i = 0; i <= 0x0f; i++)
+ {
+ gpio_line_get(ixp4xx_sda_pin(data), &sda);
+ if (sda == 0)
+ break;
+ }
+ }
+#endif
return sda;
}
@@ -127,17 +158,27 @@ static int ixp4xx_i2c_probe(struct devic
drv_data->algo_data.udelay = 10;
drv_data->algo_data.mdelay = 10;
drv_data->algo_data.timeout = 100;
-
+#ifdef CONFIG_MACH_NAS100D
+ drv_data->algo_data.getscl = NULL;
+ drv_data->algo_data.udelay = 120;
+ drv_data->algo_data.mdelay = 120;
+#endif
drv_data->adapter.id = I2C_HW_B_IXP4XX;
drv_data->adapter.algo_data = &drv_data->algo_data;
drv_data->adapter.dev.parent = &plat_dev->dev;
+#ifdef CONFIG_MACH_NAS100D
+ gpio_line_config(gpio->scl_pin, IXP4XX_GPIO_OUT);
+ gpio_line_config(gpio->sda_pin, IXP4XX_GPIO_OUT);
+ gpio_line_set(gpio->scl_pin, IXP4XX_GPIO_HIGH);
+ gpio_line_set(gpio->sda_pin, IXP4XX_GPIO_HIGH);
+#else
gpio_line_config(gpio->scl_pin, IXP4XX_GPIO_IN);
gpio_line_config(gpio->sda_pin, IXP4XX_GPIO_IN);
gpio_line_set(gpio->scl_pin, 0);
gpio_line_set(gpio->sda_pin, 0);
-
+#endif
if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) {
printk(KERN_ERR "ERROR: Could not install %s\n", dev->bus_id);
--- linux-nas100d.orig/drivers/i2c/algos/i2c-algo-bit.c 2005-11-14 14:28:20.000000000 +0100
+++ linux-nas100d/drivers/i2c/algos/i2c-algo-bit.c 2005-11-14 17:10:32.000000000 +0100
@@ -81,7 +81,6 @@ static inline int sclhi(struct i2c_algo_
unsigned long start;
setscl(adap,1);
-
/* Not all adapters have scl sense line... */
if (adap->getscl == NULL ) {
udelay(adap->udelay);
@@ -111,6 +110,10 @@ static void i2c_start(struct i2c_algo_bi
{
/* assert: scl, sda are high */
DEBPROTO(printk("S "));
+#ifdef CONFIG_MACH_NAS100D
+ sclhi(adap);
+ sdahi(adap);
+#endif
sdalo(adap);
scllo(adap);
}
@@ -132,6 +135,9 @@ static void i2c_stop(struct i2c_algo_bit
{
DEBPROTO(printk("P\n"));
/* assert: scl is low */
+#ifdef CONFIG_MACH_NAS100D
+ scllo(adap);
+#endif
sdalo(adap);
sclhi(adap);
sdahi(adap);
@@ -154,6 +160,9 @@ static int i2c_outb(struct i2c_adapter *
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
/* assert: scl is low */
+#ifdef CONFIG_MACH_NAS100D
+ scllo(adap);
+#endif
for ( i=7 ; i>=0 ; i-- ) {
sb = c & ( 1 << i );
setsda(adap,sb);
@@ -181,7 +190,14 @@ static int i2c_outb(struct i2c_adapter *
DEBPROTO( printk(KERN_DEBUG "[%2.2x]",c&0xff) );
DEBPROTO(if (0==ack){ printk(KERN_DEBUG " A ");} else printk(KERN_DEBUG " NA ") );
+#ifdef CONFIG_MACH_NAS100D
+ sdalo(adap);
+#endif
scllo(adap);
+
+#ifdef CONFIG_MACH_NAS100D
+ udelay(adap->udelay);
+#endif
return 0==ack; /* return 1 if device acked */
/* assert: scl is low (sda undef) */
}
@@ -196,8 +212,14 @@ static int i2c_inb(struct i2c_adapter *i
struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
/* assert: scl is low */
+#ifdef CONFIG_MACH_NAS100D
+ setscl(adap,0);
+#endif
sdahi(adap);
for (i=0;i<8;i++) {
+#ifdef CONFIG_MAC_NAS100D
+ getsda(adap);
+#endif
if (sclhi(adap)<0) { /* timeout */
DEB2(printk(KERN_DEBUG " i2c_inb: timeout at bit #%d\n", 7-i));
return -ETIMEDOUT;
|