]> git.pld-linux.org Git - packages/kernel.git/blob - 2.6.0-t5-i2c.patch
+CONFIG_IP_NF_MATCH_LAYER7=m
[packages/kernel.git] / 2.6.0-t5-i2c.patch
1 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/Kconfig i2c-2.5/drivers/i2c/Kconfig
2 --- linux-2.6.0-test5/drivers/i2c/Kconfig       Mon Sep  8 19:49:57 2003
3 +++ i2c-2.5/drivers/i2c/Kconfig Tue Sep 23 10:12:58 2003
4 @@ -22,10 +22,20 @@
5           If you want I2C support, you should say Y here and also to the
6           specific driver for your bus adapter(s) below.
7  
8 -         This I2C support is also available as a module.  If you want to
9 -         compile it as a module, say M here and read
10 -         <file:Documentation/modules.txt>.
11 -         The module will be called i2c-core.
12 +         This I2C support can also be built as a module.  If so, the module
13 +         will be called i2c-core.
14 +
15 +config I2C_CHARDEV
16 +       tristate "I2C device interface"
17 +       depends on I2C
18 +       help
19 +         Say Y here to use i2c-* device files, usually found in the /dev
20 +         directory on your system.  They make it possible to have user-space
21 +         programs use the I2C bus.  Information on how to do this is
22 +         contained in the file <file:Documentation/i2c/dev-interface>.
23 +
24 +         This support is also available as a module.  If so, the module 
25 +         will be called i2c-dev.
26  
27  config I2C_ALGOBIT
28         tristate "I2C bit-banging interfaces"
29 @@ -35,105 +45,8 @@
30           adapters.  Say Y if you own an I2C adapter belonging to this class
31           and then say Y to the specific driver for you adapter below.
32  
33 -         This support is also available as a module.  If you want to compile
34 -         it as a module, say M here and read
35 -         <file:Documentation/modules.txt>.
36 -         The module will be called i2c-algo-bit.
37 -
38 -config I2C_PROSAVAGE
39 -       tristate "S3/VIA (Pro)Savage"
40 -       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
41 -       help
42 -         If you say yes to this option, support will be included for the
43 -         I2C bus and DDC bus of the S3VIA embedded Savage4 and ProSavage8
44 -         graphics processors.
45 -         chipsets supported:
46 -           S3/VIA KM266/VT8375 aka ProSavage8
47 -           S3/VIA KM133/VT8365 aka Savage4
48 -
49 -         This can also be built as a module which can be inserted and removed
50 -         while the kernel is running.  If you want to compile it as a module,
51 -         say M here and read <file:Documentation/modules.txt>.
52 -         The module will be called i2c-prosavage.
53 -
54 -         You will also need the latest user-space utilties: you can find them
55 -         in the lm_sensors package, which you can download at
56 -         http://www.lm-sensors.nu
57 -
58 -config I2C_PHILIPSPAR
59 -       tristate "Philips style parallel port adapter"
60 -       depends on I2C_ALGOBIT && PARPORT
61 -       ---help---
62 -         This supports parallel-port I2C adapters made by Philips.  Say Y if
63 -         you own such an adapter.
64 -
65 -         This driver is also available as a module.  If you want to compile
66 -         it as a module, say M here and read
67 -         <file:Documentation/modules.txt>.
68 -         The module will be called i2c-philips-par.
69 -
70 -         Note that if you want support for different parallel port devices,
71 -         life will be much easier if you compile them all as modules.
72 -
73 -config I2C_ELV
74 -       tristate "ELV adapter"
75 -       depends on I2C_ALGOBIT && ISA
76 -       help
77 -         This supports parallel-port I2C adapters called ELV.  Say Y if you
78 -         own such an adapter.
79 -
80 -         This driver is also available as a module.  If you want to compile
81 -         it as a module, say M here and read
82 -         <file:Documentation/modules.txt>.
83 -         The module will be called i2c-elv.
84 -
85 -config I2C_VELLEMAN
86 -       tristate "Velleman K9000 adapter"
87 -       depends on I2C_ALGOBIT && ISA
88 -       help
89 -         This supports the Velleman K9000 parallel-port I2C adapter.  Say Y
90 -         if you own such an adapter.
91 -
92 -         This driver is also available as a module.  If you want to compile
93 -         it as a module, say M here and read
94 -         <file:Documentation/modules.txt>.
95 -         The module will be called i2c-velleman.
96 -
97 -config SCx200_I2C
98 -       tristate "NatSemi SCx200 I2C using GPIO pins"
99 -       depends on SCx200 && I2C_ALGOBIT
100 -       help
101 -         Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
102 -
103 -         If you don't know what to do here, say N.
104 -
105 -         If compiled as a module, it will be called scx200_i2c.
106 -
107 -config SCx200_I2C_SCL
108 -       int "GPIO pin used for SCL"
109 -       depends on SCx200_I2C
110 -       default "12"
111 -       help
112 -         Enter the GPIO pin number used for the SCL signal.  This value can
113 -         also be specified with a module parameter.
114 -
115 -config SCx200_I2C_SDA
116 -       int "GPIO pin used for SDA"
117 -       depends on SCx200_I2C
118 -       default "13"
119 -       help
120 -         Enter the GPIO pin number used for the SSA signal.  This value can
121 -         also be specified with a module parameter.
122 -
123 -config SCx200_ACB
124 -       tristate "NatSemi SCx200 ACCESS.bus"
125 -       depends on I2C_ALGOBIT!=n && I2C
126 -       help
127 -         Enable the use of the ACCESS.bus controllers of a SCx200 processor.
128 -
129 -         If you don't know what to do here, say N.
130 -
131 -         If compiled as a module, it will be called scx200_acb.
132 +         This support is also available as a module.  If so, the module 
133 +         will be called i2c-algo-bit.
134  
135  config I2C_ALGOPCF
136         tristate "I2C PCF 8584 interfaces"
137 @@ -143,35 +56,10 @@
138           Say Y if you own an I2C adapter belonging to this class and then say
139           Y to the specific driver for you adapter below.
140  
141 -         This support is also available as a module.  If you want to compile
142 -         it as a module, say M here and read
143 -         <file:Documentation/modules.txt>.
144 -         The module will be called i2c-algo-pcf.
145 -
146 -config I2C_ELEKTOR
147 -       tristate "Elektor ISA card"
148 -       depends on I2C_ALGOPCF && BROKEN_ON_SMP
149 -       help
150 -         This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
151 -         such an adapter.
152 +         This support is also available as a module.  If so, the module 
153 +         will be called i2c-algo-pcf.
154  
155 -         This driver is also available as a module.  If you want to compile
156 -         it as a module, say M here and read
157 -         <file:Documentation/modules.txt>.
158 -         The module will be called i2c-elektor.
159 -
160 -config I2C_KEYWEST
161 -       tristate "Powermac Keywest I2C interface"
162 -       depends on I2C && PPC_PMAC
163 -       help
164 -         This supports the use of the I2C interface in the combo-I/O
165 -         chip on recent Apple machines.  Say Y if you have such a machine.
166 -
167 -         This driver is also available as a module.  If you want to compile
168 -         it as a module, say M here and read Documentation/modules.txt.
169 -         The module will be called i2c-keywest.
170 -
171 -config ITE_I2C_ALGO
172 +config I2C_ALGOITE
173         tristate "ITE I2C Algorithm"
174         depends on MIPS_ITE8172 && I2C
175         help
176 @@ -179,56 +67,13 @@
177           systems. Say Y if you have one of these. You should also say Y for
178           the ITE I2C peripheral driver support below.
179  
180 -         This support is also available as a module. If you want to compile
181 -         it as a module, say M here and read Documentation/modules.txt.
182 -         The module will be called i2c-algo-ite.
183 -
184 -config ITE_I2C_ADAP
185 -       tristate "ITE I2C Adapter"
186 -       depends on ITE_I2C_ALGO
187 -       help
188 -         This supports the ITE8172 I2C peripheral found on some MIPS
189 -         systems. Say Y if you have one of these. You should also say Y for
190 -         the ITE I2C driver algorithm support above.
191 -
192 -         This support is also available as a module. If you want to compile
193 -         it as a module, say M here and read Documentation/modules.txt.
194 -         The module will be called i2c-adap-ite.
195 +         This support is also available as a module.  If so, the module 
196 +         will be called i2c-algo-ite.
197  
198  config I2C_ALGO8XX
199         tristate "MPC8xx CPM I2C interface"
200         depends on 8xx && I2C
201  
202 -config I2C_RPXLITE
203 -       tristate "Embedded Planet RPX Lite/Classic suppoort"
204 -       depends on (RPXLITE || RPXCLASSIC) && I2C_ALGO8XX
205 -
206 -config I2C_IBM_OCP_ALGO
207 -       tristate "IBM on-chip I2C Algorithm"
208 -       depends on IBM_OCP && I2C
209 -
210 -config I2C_IBM_OCP_ADAP
211 -       tristate "IBM on-chip I2C Adapter"
212 -       depends on I2C_IBM_OCP_ALGO
213 -
214 -config I2C_IOP3XX
215 -       tristate "Intel XScale IOP3xx on-chip I2C interface"
216 -       depends on ARCH_IOP3XX && I2C
217 -
218 -config I2C_CHARDEV
219 -       tristate "I2C device interface"
220 -       depends on I2C
221 -       help
222 -         Say Y here to use i2c-* device files, usually found in the /dev
223 -         directory on your system.  They make it possible to have user-space
224 -         programs use the I2C bus.  Information on how to do this is
225 -         contained in the file <file:Documentation/i2c/dev-interface>.
226 -
227 -         This code is also available as a module.  If you want to compile
228 -         it as a module, say M here and read
229 -         <file:Documentation/modules.txt>.
230 -         The module will be called i2c-dev.
231 -
232         source drivers/i2c/busses/Kconfig
233         source drivers/i2c/chips/Kconfig
234  
235 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/Makefile i2c-2.5/drivers/i2c/Makefile
236 --- linux-2.6.0-test5/drivers/i2c/Makefile      Mon Sep  8 19:49:51 2003
237 +++ i2c-2.5/drivers/i2c/Makefile        Tue Sep 23 10:12:58 2003
238 @@ -1,21 +1,11 @@
239  #
240 -# Makefile for the kernel i2c bus driver.
241 +# Makefile for the i2c core.
242  #
243  
244  obj-$(CONFIG_I2C)              += i2c-core.o
245  obj-$(CONFIG_I2C_CHARDEV)      += i2c-dev.o
246 +obj-$(CONFIG_I2C_SENSOR)       += i2c-sensor.o
247  obj-$(CONFIG_I2C_ALGOBIT)      += i2c-algo-bit.o
248 -obj-$(CONFIG_I2C_PROSAVAGE)    += i2c-prosavage.o
249 -obj-$(CONFIG_I2C_PHILIPSPAR)   += i2c-philips-par.o
250 -obj-$(CONFIG_I2C_ELV)          += i2c-elv.o
251 -obj-$(CONFIG_I2C_VELLEMAN)     += i2c-velleman.o
252  obj-$(CONFIG_I2C_ALGOPCF)      += i2c-algo-pcf.o
253 -obj-$(CONFIG_I2C_ELEKTOR)      += i2c-elektor.o
254 -obj-$(CONFIG_I2C_KEYWEST)      += i2c-keywest.o
255 -obj-$(CONFIG_ITE_I2C_ALGO)     += i2c-algo-ite.o
256 -obj-$(CONFIG_ITE_I2C_ADAP)     += i2c-adap-ite.o
257 -obj-$(CONFIG_SCx200_I2C)       += scx200_i2c.o
258 -obj-$(CONFIG_SCx200_ACB)       += scx200_acb.o
259 -obj-$(CONFIG_I2C_SENSOR)       += i2c-sensor.o
260 -obj-$(CONFIG_I2C_IOP3XX)       += i2c-iop3xx.o
261 +obj-$(CONFIG_I2C_ALGOITE)      += i2c-algo-ite.o
262  obj-y                          += busses/ chips/
263 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/Kconfig i2c-2.5/drivers/i2c/busses/Kconfig
264 --- linux-2.6.0-test5/drivers/i2c/busses/Kconfig        Mon Sep  8 19:50:22 2003
265 +++ i2c-2.5/drivers/i2c/busses/Kconfig  Tue Sep 23 10:12:59 2003
266 @@ -2,10 +2,10 @@
267  # Sensor device configuration
268  #
269  
270 -menu "I2C Hardware Sensors Mainboard support"
271 +menu "I2C Hardware Bus support"
272  
273  config I2C_ALI1535
274 -       tristate "  ALI 1535"
275 +       tristate "ALI 1535"
276         depends on I2C && PCI && EXPERIMENTAL
277         help
278           If you say yes to this option, support will be included for the SMB
279 @@ -13,63 +13,61 @@
280           controller is part of the 7101 device, which is an ACPI-compliant
281           Power Management Unit (PMU).
282  
283 -         This can also be built as a module.  If so, the module will be
284 -         called i2c-ali1535.
285 -
286 -         You will also need the latest user-space utilties: you can find them
287 -         in the lm_sensors package, which you can download at
288 -         http://www.lm-sensors.nu
289 +         This driver can also be built as a module.  If so, the module
290 +         will be called i2c-ali1535.
291  
292  config I2C_ALI15X3
293 -       tristate "  ALI 15x3"
294 +       tristate "ALI 15x3"
295         depends on I2C && PCI && EXPERIMENTAL
296         help
297           If you say yes to this option, support will be included for the
298           Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces.
299  
300 -         This can also be built as a module.  If so, the module will be
301 -         called i2c-ali15x3.
302 -
303 -         You will also need the latest user-space utilties: you can find them
304 -         in the lm_sensors package, which you can download at
305 -         http://www.lm-sensors.nu
306 +         This driver can also be built as a module.  If so, the module
307 +         will be called i2c-ali15x3.
308  
309  config I2C_AMD756
310 -       tristate "  AMD 756/766"
311 +       tristate "AMD 756/766"
312         depends on I2C && EXPERIMENTAL
313         help
314           If you say yes to this option, support will be included for the AMD
315           756/766/768 mainboard I2C interfaces.
316  
317 -         This can also be built as a module which can be inserted and removed 
318 -         while the kernel is running.  If you want to compile it as a module,
319 -         say M here and read <file:Documentation/modules.txt>.
320 -
321 -         The module will be called i2c-amd756.
322 -
323 -         You will also need the latest user-space utilties: you can find them
324 -         in the lm_sensors package, which you can download at 
325 -         http://www.lm-sensors.nu
326 +         This driver can also be built as a module.  If so, the module
327 +         will be called i2c-amd756.
328  
329  config I2C_AMD8111
330 -       tristate "  AMD 8111"
331 +       tristate "AMD 8111"
332         depends on I2C && EXPERIMENTAL
333         help
334           If you say yes to this option, support will be included for the AMD
335           8111 mainboard I2C interfaces.
336  
337 -         This can also be built as a module which can be inserted and removed 
338 -         while the kernel is running.  If you want to compile it as a module,
339 -         say M here and read <file:Documentation/modules.txt>.
340 -
341 -         The module will be called i2c-amd8111.
342 -
343 -         You will also need the latest user-space utilties: you can find them
344 -         in the lm_sensors package, which you can download at 
345 -         http://www.lm-sensors.nu
346 +         This driver can also be built as a module.  If so, the module
347 +         will be called i2c-amd8111.
348 +
349 +config I2C_ELEKTOR
350 +       tristate "Elektor ISA card"
351 +       depends on I2C_ALGOPCF && BROKEN_ON_SMP
352 +       help
353 +         This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
354 +         such an adapter.
355 +
356 +         This support is also available as a module.  If so, the module 
357 +         will be called i2c-elektor.
358 +
359 +config I2C_ELV
360 +       tristate "ELV adapter"
361 +       depends on I2C_ALGOBIT && ISA
362 +       help
363 +         This supports parallel-port I2C adapters called ELV.  Say Y if you
364 +         own such an adapter.
365 +
366 +         This support is also available as a module.  If so, the module 
367 +         will be called i2c-elv.
368  
369  config I2C_I801
370 -       tristate "  Intel 801"
371 +       tristate "Intel 801"
372         depends on I2C && PCI && EXPERIMENTAL
373         help
374           If you say yes to this option, support will be included for the Intel
375 @@ -81,53 +79,84 @@
376             82801CA/CAM
377             82801DB
378  
379 -         This can also be built as a module which can be inserted and removed 
380 -         while the kernel is running.  If you want to compile it as a module,
381 -         say M here and read <file:Documentation/modules.txt>.
382 -
383 -         The module will be called i2c-i801.
384 -
385 -         You will also need the latest user-space utilties: you can find them
386 -         in the lm_sensors package, which you can download at 
387 -         http://www.lm-sensors.nu
388 +         This driver can also be built as a module.  If so, the module
389 +         will be called i2c-i801.
390 +
391 +config I2C_I810
392 +       tristate "Intel 810/815"
393 +       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
394 +       help
395 +         If you say yes to this option, support will be included for the Intel
396 +         810/815 family of mainboard I2C interfaces.  Specifically, the 
397 +         following versions of the chipset is supported:
398 +           i810AA
399 +           i810AB
400 +           i810E
401 +           i815
402 +
403 +         This driver can also be built as a module.  If so, the module
404 +         will be called i2c-i810.
405 +
406 +config I2C_IBM_IIC
407 +       tristate "IBM IIC I2C"
408 +       depends on IBM_OCP && I2C
409 +
410 +config I2C_IOP3XX
411 +       tristate "Intel XScale IOP3xx on-chip I2C interface"
412 +       depends on ARCH_IOP3XX && I2C
413  
414  config I2C_ISA
415 -       tristate "  ISA Bus support"
416 +       tristate "ISA Bus support"
417         depends on I2C && ISA && EXPERIMENTAL
418         help
419           If you say yes to this option, support will be included for i2c
420           interfaces that are on the ISA bus.
421  
422 -         This can also be built as a module which can be inserted and removed 
423 -         while the kernel is running.  If you want to compile it as a module,
424 -         say M here and read <file:Documentation/modules.txt>.
425 -
426 -         The module will be called i2c-isa.
427 -
428 -         You will also need the latest user-space utilties: you can find them
429 -         in the lm_sensors package, which you can download at 
430 -         http://www.lm-sensors.nu
431 +         This driver can also be built as a module.  If so, the module
432 +         will be called i2c-isa.
433 +
434 +config I2C_ITE
435 +       tristate "ITE I2C Adapter"
436 +       depends on I2C_ALGOITE
437 +       help
438 +         This supports the ITE8172 I2C peripheral found on some MIPS
439 +         systems. Say Y if you have one of these. You should also say Y for
440 +         the ITE I2C driver algorithm support above.
441 +
442 +         This support is also available as a module.  If so, the module 
443 +         will be called i2c-ite.
444 +
445 +config I2C_KEYWEST
446 +       tristate "Powermac Keywest I2C interface"
447 +       depends on I2C && PPC_PMAC
448 +       help
449 +         This supports the use of the I2C interface in the combo-I/O
450 +         chip on recent Apple machines.  Say Y if you have such a machine.
451 +
452 +         This support is also available as a module.  If so, the module 
453 +         will be called i2c-keywest.
454  
455  config I2C_NFORCE2
456 -       tristate "  Nvidia Nforce2"
457 +       tristate "Nvidia Nforce2"
458         depends on I2C && PCI && EXPERIMENTAL
459         help
460           If you say yes to this option, support will be included for the Nvidia
461           Nforce2 family of mainboard I2C interfaces.
462  
463 -         This can also be built as a module which can be inserted and removed
464 -         while the kernel is running.  If you want to compile it as a module,
465 -         say M here and read <file:Documentation/modules.txt>.
466 -
467 -         The module will be called i2c-nforce2.
468 -
469 -         You will also need the latest user-space utilties: you can find them
470 -         in the lm_sensors package, which you can download at
471 -         http://www.lm-sensors.nu
472 +         This driver can also be built as a module.  If so, the module
473 +         will be called i2c-nforce2.
474 +
475 +config I2C_PHILIPSPAR
476 +       tristate "Philips style parallel port adapter"
477 +       depends on I2C_ALGOBIT && PARPORT
478 +       help
479 +         This supports parallel-port I2C adapters made by Philips.
480  
481 +         This support is also available as a module.  If so, the module 
482 +         will be called i2c-philips-par.
483  
484  config I2C_PIIX4
485 -       tristate "  Intel PIIX4"
486 +       tristate "Intel PIIX4"
487         depends on I2C && PCI && EXPERIMENTAL
488         help
489           If you say yes to this option, support will be included for the Intel
490 @@ -139,19 +168,97 @@
491             Serverworks CSB5
492             SMSC Victory66
493  
494 -         This can also be built as a module which can be inserted and removed 
495 -         while the kernel is running.  If you want to compile it as a module,
496 -         say M here and read <file:Documentation/modules.txt>.
497 -
498 -         The module will be called i2c-piix4.
499 -
500 -         You will also need the latest user-space utilties: you can find them
501 -         in the lm_sensors package, which you can download at 
502 -         http://www.lm-sensors.nu
503 +         This driver can also be built as a module.  If so, the module
504 +         will be called i2c-piix4.
505 +
506 +config I2C_PROSAVAGE
507 +       tristate "S3/VIA (Pro)Savage"
508 +       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
509 +       help
510 +         If you say yes to this option, support will be included for the
511 +         I2C bus and DDC bus of the S3VIA embedded Savage4 and ProSavage8
512 +         graphics processors.
513 +         chipsets supported:
514 +           S3/VIA KM266/VT8375 aka ProSavage8
515 +           S3/VIA KM133/VT8365 aka Savage4
516 +
517 +         This support is also available as a module.  If so, the module 
518 +         will be called i2c-prosavage.
519 +
520 +config I2C_RPXLITE
521 +       tristate "Embedded Planet RPX Lite/Classic suppoort"
522 +       depends on (RPXLITE || RPXCLASSIC) && I2C_ALGO8XX
523 +
524 +config I2C_SAVAGE4
525 +       tristate "S3 Savage 4"
526 +       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
527 +       help
528 +         If you say yes to this option, support will be included for the 
529 +         S3 Savage 4 I2C interface.
530 +
531 +         This driver can also be built as a module.  If so, the module
532 +         will be called i2c-savage4.
533 +
534 +config SCx200_I2C
535 +       tristate "NatSemi SCx200 I2C using GPIO pins"
536 +       depends on SCx200 && I2C_ALGOBIT
537 +       help
538 +         Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
539 +
540 +         If you don't know what to do here, say N.
541 +
542 +         This support is also available as a module.  If so, the module 
543 +         will be called scx200_i2c.
544 +
545 +config SCx200_I2C_SCL
546 +       int "GPIO pin used for SCL"
547 +       depends on SCx200_I2C
548 +       default "12"
549 +       help
550 +         Enter the GPIO pin number used for the SCL signal.  This value can
551 +         also be specified with a module parameter.
552 +
553 +config SCx200_I2C_SDA
554 +       int "GPIO pin used for SDA"
555 +       depends on SCx200_I2C
556 +       default "13"
557 +       help
558 +         Enter the GPIO pin number used for the SSA signal.  This value can
559 +         also be specified with a module parameter.
560 +
561 +config SCx200_ACB
562 +       tristate "NatSemi SCx200 ACCESS.bus"
563 +       depends on I2C_ALGOBIT!=n && I2C
564 +       help
565 +         Enable the use of the ACCESS.bus controllers of a SCx200 processor.
566 +
567 +         If you don't know what to do here, say N.
568 +
569 +         This support is also available as a module.  If so, the module 
570 +         will be called scx200_acb.
571 +
572 +config I2C_SIS5595
573 +       tristate "SiS 5595"
574 +       depends on I2C && PCI && EXPERIMENTAL
575 +       help
576 +         If you say yes to this option, support will be included for the 
577 +         SiS5595 SMBus (a subset of I2C) interface.
578 +
579 +         This driver can also be built as a module.  If so, the module
580 +         will be called i2c-sis5595.
581 +
582 +config I2C_SIS630
583 +       tristate "SiS 630"
584 +       depends on I2C && PCI && EXPERIMENTAL
585 +       help
586 +         If you say yes to this option, support will be included for the 
587 +         SiS630 SMBus (a subset of I2C) interface.
588  
589 +         This driver can also be built as a module.  If so, the module
590 +         will be called i2c-sis630.
591  
592  config I2C_SIS96X
593 -       tristate "  SiS 96x"
594 +       tristate "SiS 96x"
595         depends on I2C && PCI && EXPERIMENTAL
596         help
597           If you say yes to this option, support will be included for the SiS
598 @@ -164,19 +271,32 @@
599             650/961
600             735
601  
602 -         This can also be built as a module which can be inserted and removed 
603 -         while the kernel is running.  If you want to compile it as a module,
604 -         say M here and read <file:Documentation/modules.txt>.
605 -
606 -         The module will be called i2c-sis96x.
607 -
608 -         You will also need the latest user-space utilties: you can find them
609 -         in the lm_sensors package, which you can download at 
610 -         http://www.lm-sensors.nu
611 +         This driver can also be built as a module.  If so, the module
612 +         will be called i2c-sis96x.
613  
614 +config I2C_VELLEMAN
615 +       tristate "Velleman K9000 adapter"
616 +       depends on I2C_ALGOBIT && ISA
617 +       help
618 +         This supports the Velleman K9000 parallel-port I2C adapter.  Say Y
619 +         if you own such an adapter.
620 +
621 +         This support is also available as a module.  If so, the module 
622 +         will be called i2c-velleman.
623 +
624 +config I2C_VIA
625 +       tristate "VIA 82C58B"
626 +       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
627 +       help
628 +
629 +         If you say yes to this option, support will be included for the VIA
630 +          82C586B I2C interface
631 +
632 +         This driver can also be built as a module.  If so, the module
633 +         will be called i2c-via.
634  
635  config I2C_VIAPRO
636 -       tristate "  VIA 82C596/82C686/823x"
637 +       tristate "VIA 82C596/82C686/823x"
638         depends on I2C && PCI && EXPERIMENTAL
639         help
640  
641 @@ -190,15 +310,18 @@
642           8233A
643           8235
644  
645 -         This can also be built as a module which can be inserted and removed
646 -         while the kernel is running.  If you want to compile it as a module,
647 -         say M here and read <file:Documentation/modules.txt>.
648 -
649 -         The module will be called i2c-viapro.
650 -
651 -         You will also need the latest user-space utilties: you can find them
652 -         in the lm_sensors package, which you can download at
653 -         http://www.lm-sensors.nu
654 +         This driver can also be built as a module.  If so, the module
655 +         will be called i2c-viapro.
656  
657 -endmenu
658 +config I2C_VOODOO3
659 +       tristate "Voodoo 3"
660 +       depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
661 +       help
662 +
663 +         If you say yes to this option, support will be included for the
664 +         Voodoo 3 I2C interface.
665 +
666 +         This driver can also be built as a module.  If so, the module
667 +         will be called i2c-voodoo3.
668  
669 +endmenu
670 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/Makefile i2c-2.5/drivers/i2c/busses/Makefile
671 --- linux-2.6.0-test5/drivers/i2c/busses/Makefile       Mon Sep  8 19:49:52 2003
672 +++ i2c-2.5/drivers/i2c/busses/Makefile Tue Sep 23 10:12:59 2003
673 @@ -1,14 +1,32 @@
674  #
675 -# Makefile for the kernel hardware sensors bus drivers.
676 +# Makefile for the i2c bus drivers.
677  #
678  
679  obj-$(CONFIG_I2C_ALI1535)      += i2c-ali1535.o
680  obj-$(CONFIG_I2C_ALI15X3)      += i2c-ali15x3.o
681  obj-$(CONFIG_I2C_AMD756)       += i2c-amd756.o
682  obj-$(CONFIG_I2C_AMD8111)      += i2c-amd8111.o
683 +obj-$(CONFIG_I2C_ELEKTOR)      += i2c-elektor.o
684 +obj-$(CONFIG_I2C_ELV)          += i2c-elv.o
685  obj-$(CONFIG_I2C_I801)         += i2c-i801.o
686 +obj-$(CONFIG_I2C_I810)         += i2c-i810.o
687 +obj-$(CONFIG_I2C_IBM_IIC)      += i2c-ibm_iic.o
688 +obj-$(CONFIG_I2C_IOP3XX)       += i2c-iop3xx.o
689  obj-$(CONFIG_I2C_ISA)          += i2c-isa.o
690 +obj-$(CONFIG_I2C_ITE)          += i2c-ite.o
691 +obj-$(CONFIG_I2C_KEYWEST)      += i2c-keywest.o
692  obj-$(CONFIG_I2C_NFORCE2)      += i2c-nforce2.o
693 +obj-$(CONFIG_I2C_PHILIPSPAR)   += i2c-philips-par.o
694  obj-$(CONFIG_I2C_PIIX4)                += i2c-piix4.o
695 +obj-$(CONFIG_I2C_PROSAVAGE)    += i2c-prosavage.o
696 +obj-$(CONFIG_I2C_RPXLITE)      += i2c-rpx.o
697 +obj-$(CONFIG_I2C_SAVAGE4)      += i2c-savage4.o
698 +obj-$(CONFIG_I2C_SIS5595)      += i2c-sis5595.o
699 +obj-$(CONFIG_I2C_SIS630)       += i2c-sis630.o
700  obj-$(CONFIG_I2C_SIS96X)       += i2c-sis96x.o
701 +obj-$(CONFIG_I2C_VELLEMAN)     += i2c-velleman.o
702 +obj-$(CONFIG_I2C_VIA)          += i2c-via.o
703  obj-$(CONFIG_I2C_VIAPRO)       += i2c-viapro.o
704 +obj-$(CONFIG_I2C_VOODOO3)      += i2c-voodoo3.o
705 +obj-$(CONFIG_SCx200_ACB)       += scx200_acb.o
706 +obj-$(CONFIG_SCx200_I2C)       += scx200_i2c.o
707 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-ali1535.c i2c-2.5/drivers/i2c/busses/i2c-ali1535.c
708 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-ali1535.c  Mon Sep  8 19:50:22 2003
709 +++ i2c-2.5/drivers/i2c/busses/i2c-ali1535.c    Tue Sep 23 10:12:59 2003
710 @@ -481,7 +481,6 @@
711  
712  static struct i2c_adapter ali1535_adapter = {
713         .owner          = THIS_MODULE,
714 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI1535,
715         .algo           = &smbus_algorithm,
716         .name           = "unset",
717  };
718 @@ -507,7 +506,7 @@
719         /* set up the driverfs linkage to our parent device */
720         ali1535_adapter.dev.parent = &dev->dev;
721  
722 -       snprintf(ali1535_adapter.name, DEVICE_NAME_SIZE, 
723 +       snprintf(ali1535_adapter.name, I2C_NAME_SIZE, 
724                 "SMBus ALI1535 adapter at %04x", ali1535_smba);
725         return i2c_add_adapter(&ali1535_adapter);
726  }
727 @@ -526,7 +525,6 @@
728  
729  static int __init i2c_ali1535_init(void)
730  {
731 -       printk(KERN_INFO "i2c-ali1535 version %s (%s)\n", I2C_VERSION, I2C_DATE);
732         return pci_module_init(&ali1535_driver);
733  }
734  
735 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-ali15x3.c i2c-2.5/drivers/i2c/busses/i2c-ali15x3.c
736 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-ali15x3.c  Mon Sep  8 19:50:06 2003
737 +++ i2c-2.5/drivers/i2c/busses/i2c-ali15x3.c    Tue Sep 23 10:12:59 2003
738 @@ -471,7 +471,6 @@
739  
740  static struct i2c_adapter ali15x3_adapter = {
741         .owner          = THIS_MODULE,
742 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
743         .class          = I2C_ADAP_CLASS_SMBUS,
744         .algo           = &smbus_algorithm,
745         .name           = "unset",
746 @@ -498,7 +497,7 @@
747         /* set up the driverfs linkage to our parent device */
748         ali15x3_adapter.dev.parent = &dev->dev;
749  
750 -       snprintf(ali15x3_adapter.name, DEVICE_NAME_SIZE,
751 +       snprintf(ali15x3_adapter.name, I2C_NAME_SIZE,
752                 "SMBus ALI15X3 adapter at %04x", ali15x3_smba);
753         return i2c_add_adapter(&ali15x3_adapter);
754  }
755 @@ -518,7 +517,6 @@
756  
757  static int __init i2c_ali15x3_init(void)
758  {
759 -       printk("i2c-ali15x3.o version %s (%s)\n", I2C_VERSION, I2C_DATE);
760         return pci_module_init(&ali15x3_driver);
761  }
762  
763 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-amd756.c i2c-2.5/drivers/i2c/busses/i2c-amd756.c
764 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-amd756.c   Mon Sep  8 19:50:22 2003
765 +++ i2c-2.5/drivers/i2c/busses/i2c-amd756.c     Tue Sep 23 10:12:59 2003
766 @@ -37,7 +37,6 @@
767  
768  /* #define DEBUG 1 */
769  
770 -#include <linux/version.h>
771  #include <linux/module.h>
772  #include <linux/pci.h>
773  #include <linux/kernel.h>
774 @@ -304,7 +303,6 @@
775  
776  static struct i2c_adapter amd756_adapter = {
777         .owner          = THIS_MODULE,
778 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
779         .class          = I2C_ADAP_CLASS_SMBUS,
780         .algo           = &smbus_algorithm,
781         .name           = "unset",
782 @@ -369,7 +367,7 @@
783         /* set up the driverfs linkage to our parent device */
784         amd756_adapter.dev.parent = &pdev->dev;
785  
786 -       snprintf(amd756_adapter.name, DEVICE_NAME_SIZE,
787 +       snprintf(amd756_adapter.name, I2C_NAME_SIZE,
788                 "SMBus AMD75x adapter at %04x", amd756_ioport);
789  
790         error = i2c_add_adapter(&amd756_adapter);
791 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-amd8111.c i2c-2.5/drivers/i2c/busses/i2c-amd8111.c
792 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-amd8111.c  Mon Sep  8 19:50:22 2003
793 +++ i2c-2.5/drivers/i2c/busses/i2c-amd8111.c    Tue Sep 23 10:12:59 2003
794 @@ -356,9 +356,8 @@
795                 goto out_kfree;
796  
797         smbus->adapter.owner = THIS_MODULE;
798 -       snprintf(smbus->adapter.name, DEVICE_NAME_SIZE,
799 +       snprintf(smbus->adapter.name, I2C_NAME_SIZE,
800                 "SMBus2 AMD8111 adapter at %04x", smbus->base);
801 -       smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111;
802         smbus->adapter.class = I2C_ADAP_CLASS_SMBUS;
803         smbus->adapter.algo = &smbus_algorithm;
804         smbus->adapter.algo_data = smbus;
805 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-elektor.c i2c-2.5/drivers/i2c/busses/i2c-elektor.c
806 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-elektor.c  Thu Jan  1 00:00:00 1970
807 +++ i2c-2.5/drivers/i2c/busses/i2c-elektor.c    Tue Sep 23 10:12:59 2003
808 @@ -0,0 +1,286 @@
809 +/* ------------------------------------------------------------------------- */
810 +/* i2c-elektor.c i2c-hw access for PCF8584 style isa bus adaptes             */
811 +/* ------------------------------------------------------------------------- */
812 +/*   Copyright (C) 1995-97 Simon G. Vogl
813 +                   1998-99 Hans Berglund
814 +
815 +    This program is free software; you can redistribute it and/or modify
816 +    it under the terms of the GNU General Public License as published by
817 +    the Free Software Foundation; either version 2 of the License, or
818 +    (at your option) any later version.
819 +
820 +    This program is distributed in the hope that it will be useful,
821 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
822 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
823 +    GNU General Public License for more details.
824 +
825 +    You should have received a copy of the GNU General Public License
826 +    along with this program; if not, write to the Free Software
827 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
828 +/* ------------------------------------------------------------------------- */
829 +
830 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
831 +   Frodo Looijaard <frodol@dds.nl> */
832 +
833 +/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 
834 +   for Alpha Processor Inc. UP-2000(+) boards */
835 +
836 +#include <linux/kernel.h>
837 +#include <linux/ioport.h>
838 +#include <linux/module.h>
839 +#include <linux/delay.h>
840 +#include <linux/slab.h>
841 +#include <linux/init.h>
842 +#include <linux/interrupt.h>
843 +#include <linux/pci.h>
844 +#include <linux/wait.h>
845 +
846 +#include <linux/i2c.h>
847 +#include <linux/i2c-algo-pcf.h>
848 +
849 +#include <asm/io.h>
850 +#include <asm/irq.h>
851 +
852 +#include "../i2c-pcf8584.h"
853 +
854 +#define DEFAULT_BASE 0x330
855 +
856 +static int base;
857 +static int irq;
858 +static int clock  = 0x1c;
859 +static int own    = 0x55;
860 +static int mmapped;
861 +static int i2c_debug;
862 +
863 +/* vdovikin: removed static struct i2c_pcf_isa gpi; code - 
864 +  this module in real supports only one device, due to missing arguments
865 +  in some functions, called from the algo-pcf module. Sometimes it's
866 +  need to be rewriten - but for now just remove this for simpler reading */
867 +
868 +static wait_queue_head_t pcf_wait;
869 +static int pcf_pending;
870 +
871 +/* ----- global defines -----------------------------------------------        */
872 +#define DEB(x) if (i2c_debug>=1) x
873 +#define DEB2(x) if (i2c_debug>=2) x
874 +#define DEB3(x) if (i2c_debug>=3) x
875 +#define DEBE(x)        x       /* error messages                               */
876 +
877 +/* ----- local functions ----------------------------------------------        */
878 +
879 +static void pcf_isa_setbyte(void *data, int ctl, int val)
880 +{
881 +       int address = ctl ? (base + 1) : base;
882 +
883 +       /* enable irq if any specified for serial operation */
884 +       if (ctl && irq && (val & I2C_PCF_ESO)) {
885 +               val |= I2C_PCF_ENI;
886 +       }
887 +
888 +       DEB3(printk(KERN_DEBUG "i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255));
889 +
890 +       switch (mmapped) {
891 +       case 0: /* regular I/O */
892 +               outb(val, address);
893 +               break;
894 +       case 2: /* double mapped I/O needed for UP2000 board,
895 +                   I don't know why this... */
896 +               writeb(val, address);
897 +               /* fall */
898 +       case 1: /* memory mapped I/O */
899 +               writeb(val, address);
900 +               break;
901 +       }
902 +}
903 +
904 +static int pcf_isa_getbyte(void *data, int ctl)
905 +{
906 +       int address = ctl ? (base + 1) : base;
907 +       int val = mmapped ? readb(address) : inb(address);
908 +
909 +       DEB3(printk(KERN_DEBUG "i2c-elektor: Read 0x%X 0x%02X\n", address, val));
910 +
911 +       return (val);
912 +}
913 +
914 +static int pcf_isa_getown(void *data)
915 +{
916 +       return (own);
917 +}
918 +
919 +
920 +static int pcf_isa_getclock(void *data)
921 +{
922 +       return (clock);
923 +}
924 +
925 +static void pcf_isa_waitforpin(void) {
926 +
927 +       int timeout = 2;
928 +
929 +       if (irq > 0) {
930 +               cli();
931 +               if (pcf_pending == 0) {
932 +                       interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
933 +               } else
934 +                       pcf_pending = 0;
935 +               sti();
936 +       } else {
937 +               udelay(100);
938 +       }
939 +}
940 +
941 +
942 +static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
943 +       pcf_pending = 1;
944 +       wake_up_interruptible(&pcf_wait);
945 +       return IRQ_HANDLED;
946 +}
947 +
948 +
949 +static int pcf_isa_init(void)
950 +{
951 +       if (!mmapped) {
952 +               if (!request_region(base, 2, "i2c (isa bus adapter)")) {
953 +                       printk(KERN_ERR
954 +                              "i2c-elektor: requested I/O region (0x%X:2) "
955 +                              "is in use.\n", base);
956 +                       return -ENODEV;
957 +               }
958 +       }
959 +       if (irq > 0) {
960 +               if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", 0) < 0) {
961 +                       printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq);
962 +                       irq = 0;
963 +               } else
964 +                       enable_irq(irq);
965 +       }
966 +       return 0;
967 +}
968 +
969 +/* ------------------------------------------------------------------------
970 + * Encapsulate the above functions in the correct operations structure.
971 + * This is only done when more than one hardware adapter is supported.
972 + */
973 +static struct i2c_algo_pcf_data pcf_isa_data = {
974 +       .setpcf     = pcf_isa_setbyte,
975 +       .getpcf     = pcf_isa_getbyte,
976 +       .getown     = pcf_isa_getown,
977 +       .getclock   = pcf_isa_getclock,
978 +       .waitforpin = pcf_isa_waitforpin,
979 +       .udelay     = 10,
980 +       .mdelay     = 10,
981 +       .timeout    = 100,
982 +};
983 +
984 +static struct i2c_adapter pcf_isa_ops = {
985 +       .owner          = THIS_MODULE,
986 +       .id             = I2C_HW_P_ELEK,
987 +       .algo_data      = &pcf_isa_data,
988 +       .name           = "PCF8584 ISA adapter",
989 +};
990 +
991 +static int __init i2c_pcfisa_init(void) 
992 +{
993 +#ifdef __alpha__
994 +       /* check to see we have memory mapped PCF8584 connected to the 
995 +       Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
996 +       if (base == 0) {
997 +               
998 +               struct pci_dev *cy693_dev =
999 +                    pci_find_device(PCI_VENDOR_ID_CONTAQ, 
1000 +                                   PCI_DEVICE_ID_CONTAQ_82C693, NULL);
1001 +
1002 +               if (cy693_dev) {
1003 +                       char config;
1004 +                       /* yeap, we've found cypress, let's check config */
1005 +                       if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
1006 +                               
1007 +                               DEB3(printk(KERN_DEBUG "i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config));
1008 +
1009 +                               /* UP2000 board has this register set to 0xe1,
1010 +                                   but the most significant bit as seems can be 
1011 +                                  reset during the proper initialisation
1012 +                                   sequence if guys from API decides to do that
1013 +                                   (so, we can even enable Tsunami Pchip
1014 +                                   window for the upper 1 Gb) */
1015 +
1016 +                               /* so just check for ROMCS at 0xe0000,
1017 +                                   ROMCS enabled for writes
1018 +                                  and external XD Bus buffer in use. */
1019 +                               if ((config & 0x7f) == 0x61) {
1020 +                                       /* seems to be UP2000 like board */
1021 +                                       base = 0xe0000;
1022 +                                        /* I don't know why we need to
1023 +                                           write twice */
1024 +                                       mmapped = 2;
1025 +                                        /* UP2000 drives ISA with
1026 +                                          8.25 MHz (PCI/4) clock
1027 +                                          (this can be read from cypress) */
1028 +                                       clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
1029 +                                       printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n");
1030 +                               }
1031 +                       }
1032 +               }
1033 +       }
1034 +#endif
1035 +
1036 +       /* sanity checks for mmapped I/O */
1037 +       if (mmapped && base < 0xc8000) {
1038 +               printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base);
1039 +               return -ENODEV;
1040 +       }
1041 +
1042 +       printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n");
1043 +
1044 +       if (base == 0) {
1045 +               base = DEFAULT_BASE;
1046 +       }
1047 +
1048 +       init_waitqueue_head(&pcf_wait);
1049 +       if (pcf_isa_init())
1050 +               return -ENODEV;
1051 +       if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
1052 +               goto fail;
1053 +       
1054 +       printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base);
1055 +
1056 +       return 0;
1057 +
1058 + fail:
1059 +       if (irq > 0) {
1060 +               disable_irq(irq);
1061 +               free_irq(irq, 0);
1062 +       }
1063 +
1064 +       if (!mmapped)
1065 +               release_region(base , 2);
1066 +       return -ENODEV;
1067 +}
1068 +
1069 +static void i2c_pcfisa_exit(void)
1070 +{
1071 +       i2c_pcf_del_bus(&pcf_isa_ops);
1072 +
1073 +       if (irq > 0) {
1074 +               disable_irq(irq);
1075 +               free_irq(irq, 0);
1076 +       }
1077 +
1078 +       if (!mmapped)
1079 +               release_region(base , 2);
1080 +}
1081 +
1082 +MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
1083 +MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
1084 +MODULE_LICENSE("GPL");
1085 +
1086 +MODULE_PARM(base, "i");
1087 +MODULE_PARM(irq, "i");
1088 +MODULE_PARM(clock, "i");
1089 +MODULE_PARM(own, "i");
1090 +MODULE_PARM(mmapped, "i");
1091 +MODULE_PARM(i2c_debug, "i");
1092 +
1093 +module_init(i2c_pcfisa_init);
1094 +module_exit(i2c_pcfisa_exit);
1095 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-elv.c i2c-2.5/drivers/i2c/busses/i2c-elv.c
1096 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-elv.c      Thu Jan  1 00:00:00 1970
1097 +++ i2c-2.5/drivers/i2c/busses/i2c-elv.c        Tue Sep 23 10:12:59 2003
1098 @@ -0,0 +1,173 @@
1099 +/* ------------------------------------------------------------------------- */
1100 +/* i2c-elv.c i2c-hw access for philips style parallel port adapters         */
1101 +/* ------------------------------------------------------------------------- */
1102 +/*   Copyright (C) 1995-2000 Simon G. Vogl
1103 +
1104 +    This program is free software; you can redistribute it and/or modify
1105 +    it under the terms of the GNU General Public License as published by
1106 +    the Free Software Foundation; either version 2 of the License, or
1107 +    (at your option) any later version.
1108 +
1109 +    This program is distributed in the hope that it will be useful,
1110 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1112 +    GNU General Public License for more details.
1113 +
1114 +    You should have received a copy of the GNU General Public License
1115 +    along with this program; if not, write to the Free Software
1116 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
1117 +/* ------------------------------------------------------------------------- */
1118 +
1119 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
1120 +   Frodo Looijaard <frodol@dds.nl> */
1121 +
1122 +#include <linux/kernel.h>
1123 +#include <linux/module.h>
1124 +#include <linux/delay.h>
1125 +#include <linux/slab.h>
1126 +#include <linux/init.h>
1127 +#include <linux/ioport.h>
1128 +#include <linux/errno.h>
1129 +#include <linux/i2c.h>
1130 +#include <linux/i2c-algo-bit.h>
1131 +#include <asm/io.h>
1132 +
1133 +#define DEFAULT_BASE 0x378
1134 +static int base=0;
1135 +static unsigned char port_data = 0;
1136 +
1137 +/* ----- global defines -----------------------------------------------        */
1138 +#define DEB(x)         /* should be reasonable open, close &c.         */
1139 +#define DEB2(x)        /* low level debugging - very slow              */
1140 +#define DEBE(x)        x       /* error messages                               */
1141 +#define DEBINIT(x) x   /* detection status messages                    */
1142 +
1143 +/* --- Convenience defines for the parallel port:                      */
1144 +#define BASE   (unsigned int)(data)
1145 +#define DATA   BASE                    /* Centronics data port         */
1146 +#define STAT   (BASE+1)                /* Centronics status port       */
1147 +#define CTRL   (BASE+2)                /* Centronics control port      */
1148 +
1149 +
1150 +/* ----- local functions ----------------------------------------------        */
1151 +
1152 +
1153 +static void bit_elv_setscl(void *data, int state)
1154 +{
1155 +       if (state) {
1156 +               port_data &= 0xfe;
1157 +       } else {
1158 +               port_data |=1;
1159 +       }
1160 +       outb(port_data, DATA);
1161 +}
1162 +
1163 +static void bit_elv_setsda(void *data, int state)
1164 +{
1165 +       if (state) {
1166 +               port_data &=0xfd;
1167 +       } else {
1168 +               port_data |=2;
1169 +       }
1170 +       outb(port_data, DATA);
1171 +} 
1172 +
1173 +static int bit_elv_getscl(void *data)
1174 +{
1175 +       return ( 0 == ( (inb_p(STAT)) & 0x08 ) );
1176 +}
1177 +
1178 +static int bit_elv_getsda(void *data)
1179 +{
1180 +       return ( 0 == ( (inb_p(STAT)) & 0x40 ) );
1181 +}
1182 +
1183 +static int bit_elv_init(void)
1184 +{
1185 +       if (!request_region(base, (base == 0x3bc) ? 3 : 8,
1186 +                               "i2c (ELV adapter)"))
1187 +               return -ENODEV;
1188 +
1189 +       if (inb(base+1) & 0x80) {       /* BUSY should be high  */
1190 +               DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n"));
1191 +               goto fail;
1192 +       } 
1193 +
1194 +       outb(0x0c,base+2);      /* SLCT auf low         */
1195 +       udelay(400);
1196 +       if (!(inb(base+1) && 0x10)) {
1197 +               outb(0x04,base+2);
1198 +               DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n"));
1199 +               goto fail;
1200 +       }
1201 +
1202 +       port_data = 0;
1203 +       bit_elv_setsda((void*)base,1);
1204 +       bit_elv_setscl((void*)base,1);
1205 +       return 0;
1206 +
1207 +fail:
1208 +       release_region(base , (base == 0x3bc) ? 3 : 8);
1209 +       return -ENODEV;
1210 +}
1211 +
1212 +/* ------------------------------------------------------------------------
1213 + * Encapsulate the above functions in the correct operations structure.
1214 + * This is only done when more than one hardware adapter is supported.
1215 + */
1216 +static struct i2c_algo_bit_data bit_elv_data = {
1217 +       .setsda         = bit_elv_setsda,
1218 +       .setscl         = bit_elv_setscl,
1219 +       .getsda         = bit_elv_getsda,
1220 +       .getscl         = bit_elv_getscl,
1221 +       .udelay         = 80,
1222 +       .mdelay         = 80,
1223 +       .timeout        = HZ
1224 +};
1225 +
1226 +static struct i2c_adapter bit_elv_ops = {
1227 +       .owner          = THIS_MODULE,
1228 +       .algo_data      = &bit_elv_data,
1229 +       .name           = "ELV Parallel port adaptor",
1230 +};
1231 +
1232 +static int __init i2c_bitelv_init(void)
1233 +{
1234 +       printk(KERN_INFO "i2c ELV parallel port adapter driver\n");
1235 +       if (base==0) {
1236 +               /* probe some values */
1237 +               base=DEFAULT_BASE;
1238 +               bit_elv_data.data=(void*)DEFAULT_BASE;
1239 +               if (bit_elv_init()==0) {
1240 +                       if(i2c_bit_add_bus(&bit_elv_ops) < 0)
1241 +                               return -ENODEV;
1242 +               } else {
1243 +                       return -ENODEV;
1244 +               }
1245 +       } else {
1246 +               i2c_set_adapdata(&bit_elv_ops, (void *)base);
1247 +               if (bit_elv_init()==0) {
1248 +                       if(i2c_bit_add_bus(&bit_elv_ops) < 0)
1249 +                               return -ENODEV;
1250 +               } else {
1251 +                       return -ENODEV;
1252 +               }
1253 +       }
1254 +       printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base);
1255 +       return 0;
1256 +}
1257 +
1258 +static void __exit i2c_bitelv_exit(void)
1259 +{
1260 +       i2c_bit_del_bus(&bit_elv_ops);
1261 +       release_region(base , (base == 0x3bc) ? 3 : 8);
1262 +}
1263 +
1264 +MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
1265 +MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter");
1266 +MODULE_LICENSE("GPL");
1267 +
1268 +MODULE_PARM(base, "i");
1269 +
1270 +module_init(i2c_bitelv_init);
1271 +module_exit(i2c_bitelv_exit);
1272 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-frodo.c i2c-2.5/drivers/i2c/busses/i2c-frodo.c
1273 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-frodo.c    Thu Jan  1 00:00:00 1970
1274 +++ i2c-2.5/drivers/i2c/busses/i2c-frodo.c      Tue Sep 23 10:12:59 2003
1275 @@ -0,0 +1,85 @@
1276 +
1277 +/*
1278 + * linux/drivers/i2c/i2c-frodo.c
1279 + *
1280 + * Author: Abraham van der Merwe <abraham@2d3d.co.za>
1281 + *
1282 + * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
1283 + * Development board (Frodo).
1284 + *
1285 + * This source code is free software; you can redistribute it and/or
1286 + * modify it under the terms of the GNU General Public License
1287 + * version 2 as published by the Free Software Foundation.
1288 + */
1289 +
1290 +#include <linux/module.h>
1291 +#include <linux/kernel.h>
1292 +#include <linux/init.h>
1293 +#include <linux/delay.h>
1294 +#include <linux/i2c.h>
1295 +#include <linux/i2c-algo-bit.h>
1296 +#include <asm/hardware.h>
1297 +
1298 +
1299 +static void frodo_setsda (void *data,int state)
1300 +{
1301 +       if (state)
1302 +               FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
1303 +       else
1304 +               FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
1305 +}
1306 +
1307 +static void frodo_setscl (void *data,int state)
1308 +{
1309 +       if (state)
1310 +               FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
1311 +       else
1312 +               FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
1313 +}
1314 +
1315 +static int frodo_getsda (void *data)
1316 +{
1317 +       return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
1318 +}
1319 +
1320 +static int frodo_getscl (void *data)
1321 +{
1322 +       return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
1323 +}
1324 +
1325 +static struct i2c_algo_bit_data bit_frodo_data = {
1326 +       .setsda         = frodo_setsda,
1327 +       .setscl         = frodo_setscl,
1328 +       .getsda         = frodo_getsda,
1329 +       .getscl         = frodo_getscl,
1330 +       .udelay         = 80,
1331 +       .mdelay         = 80,
1332 +       .timeout        = HZ
1333 +};
1334 +
1335 +static struct i2c_adapter frodo_ops = {
1336 +       .owner                  = THIS_MODULE,
1337 +       .id                     = I2C_HW_B_FRODO,
1338 +       .algo_data              = &bit_frodo_data,
1339 +       .dev                    = {
1340 +               .name           = "Frodo adapter driver",
1341 +       },
1342 +};
1343 +
1344 +static int __init i2c_frodo_init (void)
1345 +{
1346 +       return i2c_bit_add_bus(&frodo_ops);
1347 +}
1348 +
1349 +static void __exit i2c_frodo_exit (void)
1350 +{
1351 +       i2c_bit_del_bus(&frodo_ops);
1352 +}
1353 +
1354 +MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
1355 +MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
1356 +MODULE_LICENSE ("GPL");
1357 +
1358 +module_init (i2c_frodo_init);
1359 +module_exit (i2c_frodo_exit);
1360 +
1361 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-i801.c i2c-2.5/drivers/i2c/busses/i2c-i801.c
1362 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-i801.c     Mon Sep  8 19:50:06 2003
1363 +++ i2c-2.5/drivers/i2c/busses/i2c-i801.c       Tue Sep 23 10:12:59 2003
1364 @@ -540,7 +540,6 @@
1365  
1366  static struct i2c_adapter i801_adapter = {
1367         .owner          = THIS_MODULE,
1368 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
1369         .class          = I2C_ADAP_CLASS_SMBUS,
1370         .algo           = &smbus_algorithm,
1371         .name           = "unset",
1372 @@ -598,7 +597,7 @@
1373         /* set up the driverfs linkage to our parent device */
1374         i801_adapter.dev.parent = &dev->dev;
1375  
1376 -       snprintf(i801_adapter.name, DEVICE_NAME_SIZE,
1377 +       snprintf(i801_adapter.name, I2C_NAME_SIZE,
1378                 "SMBus I801 adapter at %04x", i801_smba);
1379         return i2c_add_adapter(&i801_adapter);
1380  }
1381 @@ -617,7 +616,6 @@
1382  
1383  static int __init i2c_i801_init(void)
1384  {
1385 -       printk(KERN_INFO "i2c-i801 version %s (%s)\n", I2C_VERSION, I2C_DATE);
1386         return pci_module_init(&i801_driver);
1387  }
1388  
1389 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-i810.c i2c-2.5/drivers/i2c/busses/i2c-i810.c
1390 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-i810.c     Thu Jan  1 00:00:00 1970
1391 +++ i2c-2.5/drivers/i2c/busses/i2c-i810.c       Tue Sep 23 10:12:59 2003
1392 @@ -0,0 +1,256 @@
1393 +/*
1394 +    i2c-i810.c - Part of lm_sensors, Linux kernel modules for hardware
1395 +              monitoring
1396 +    Copyright (c) 1998, 1999, 2000  Frodo Looijaard <frodol@dds.nl>,
1397 +    Philip Edelbrock <phil@netroedge.com>,
1398 +    Ralph Metzler <rjkm@thp.uni-koeln.de>, and
1399 +    Mark D. Studebaker <mdsxyz123@yahoo.com>
1400 +    
1401 +    Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
1402 +    Simon Vogl
1403 +
1404 +    This program is free software; you can redistribute it and/or modify
1405 +    it under the terms of the GNU General Public License as published by
1406 +    the Free Software Foundation; either version 2 of the License, or
1407 +    (at your option) any later version.
1408 +
1409 +    This program is distributed in the hope that it will be useful,
1410 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
1411 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1412 +    GNU General Public License for more details.
1413 +
1414 +    You should have received a copy of the GNU General Public License
1415 +    along with this program; if not, write to the Free Software
1416 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1417 +*/
1418 +/*
1419 +   This interfaces to the I810/I815 to provide access to
1420 +   the DDC Bus and the I2C Bus.
1421 +
1422 +   SUPPORTED DEVICES   PCI ID
1423 +   i810AA              7121           
1424 +   i810AB              7123           
1425 +   i810E               7125           
1426 +   i815                        1132           
1427 +*/
1428 +
1429 +#include <linux/kernel.h>
1430 +#include <linux/module.h>
1431 +#include <linux/init.h>
1432 +#include <linux/pci.h>
1433 +#include <linux/i2c.h>
1434 +#include <linux/i2c-algo-bit.h>
1435 +
1436 +/* GPIO register locations */
1437 +#define I810_IOCONTROL_OFFSET  0x5000
1438 +#define I810_HVSYNC            0x00    /* not used */
1439 +#define I810_GPIOA             0x10
1440 +#define I810_GPIOB             0x14
1441 +
1442 +/* bit locations in the registers */
1443 +#define SCL_DIR_MASK           0x0001
1444 +#define SCL_DIR                        0x0002
1445 +#define SCL_VAL_MASK           0x0004
1446 +#define SCL_VAL_OUT            0x0008
1447 +#define SCL_VAL_IN             0x0010
1448 +#define SDA_DIR_MASK           0x0100
1449 +#define SDA_DIR                        0x0200
1450 +#define SDA_VAL_MASK           0x0400
1451 +#define SDA_VAL_OUT            0x0800
1452 +#define SDA_VAL_IN             0x1000
1453 +
1454 +/* initialization states */
1455 +#define INIT1                  0x1
1456 +#define INIT2                  0x2
1457 +#define INIT3                  0x4
1458 +
1459 +/* delays */
1460 +#define CYCLE_DELAY            10
1461 +#define TIMEOUT                        (HZ / 2)
1462 +
1463 +static void *ioaddr;
1464 +
1465 +/* The i810 GPIO registers have individual masks for each bit
1466 +   so we never have to read before writing. Nice. */
1467 +
1468 +static void bit_i810i2c_setscl(void *data, int val)
1469 +{
1470 +       writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
1471 +            ioaddr + I810_GPIOB);
1472 +       readl(ioaddr + I810_GPIOB);     /* flush posted write */
1473 +}
1474 +
1475 +static void bit_i810i2c_setsda(void *data, int val)
1476 +{
1477 +       writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
1478 +            ioaddr + I810_GPIOB);
1479 +       readl(ioaddr + I810_GPIOB);     /* flush posted write */
1480 +}
1481 +
1482 +/* The GPIO pins are open drain, so the pins could always remain outputs.
1483 +   However, some chip versions don't latch the inputs unless they
1484 +   are set as inputs.
1485 +   We rely on the i2c-algo-bit routines to set the pins high before
1486 +   reading the input from other chips. Following guidance in the 815
1487 +   prog. ref. guide, we do a "dummy write" of 0 to the register before
1488 +   reading which forces the input value to be latched. We presume this
1489 +   applies to the 810 as well; shouldn't hurt anyway. This is necessary to get
1490 +   i2c_algo_bit bit_test=1 to pass. */
1491 +
1492 +static int bit_i810i2c_getscl(void *data)
1493 +{
1494 +       writel(SCL_DIR_MASK, ioaddr + I810_GPIOB);
1495 +       writel(0, ioaddr + I810_GPIOB);
1496 +       return (0 != (readl(ioaddr + I810_GPIOB) & SCL_VAL_IN));
1497 +}
1498 +
1499 +static int bit_i810i2c_getsda(void *data)
1500 +{
1501 +       writel(SDA_DIR_MASK, ioaddr + I810_GPIOB);
1502 +       writel(0, ioaddr + I810_GPIOB);
1503 +       return (0 != (readl(ioaddr + I810_GPIOB) & SDA_VAL_IN));
1504 +}
1505 +
1506 +static void bit_i810ddc_setscl(void *data, int val)
1507 +{
1508 +       writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
1509 +            ioaddr + I810_GPIOA);
1510 +       readl(ioaddr + I810_GPIOA);     /* flush posted write */
1511 +}
1512 +
1513 +static void bit_i810ddc_setsda(void *data, int val)
1514 +{
1515 +       writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
1516 +            ioaddr + I810_GPIOA);
1517 +       readl(ioaddr + I810_GPIOA);     /* flush posted write */
1518 +}
1519 +
1520 +static int bit_i810ddc_getscl(void *data)
1521 +{
1522 +       writel(SCL_DIR_MASK, ioaddr + I810_GPIOA);
1523 +       writel(0, ioaddr + I810_GPIOA);
1524 +       return (0 != (readl(ioaddr + I810_GPIOA) & SCL_VAL_IN));
1525 +}
1526 +
1527 +static int bit_i810ddc_getsda(void *data)
1528 +{
1529 +       writel(SDA_DIR_MASK, ioaddr + I810_GPIOA);
1530 +       writel(0, ioaddr + I810_GPIOA);
1531 +       return (0 != (readl(ioaddr + I810_GPIOA) & SDA_VAL_IN));
1532 +}
1533 +
1534 +static int config_i810(struct pci_dev *dev)
1535 +{
1536 +       unsigned long cadr;
1537 +
1538 +       /* map I810 memory */
1539 +       cadr = dev->resource[1].start;
1540 +       cadr += I810_IOCONTROL_OFFSET;
1541 +       cadr &= PCI_BASE_ADDRESS_MEM_MASK;
1542 +       ioaddr = ioremap_nocache(cadr, 0x1000);
1543 +       if (ioaddr) {
1544 +               bit_i810i2c_setscl(NULL, 1);
1545 +               bit_i810i2c_setsda(NULL, 1);
1546 +               bit_i810ddc_setscl(NULL, 1);
1547 +               bit_i810ddc_setsda(NULL, 1);
1548 +               return 0;
1549 +       }
1550 +       return -ENODEV;
1551 +}
1552 +
1553 +static struct i2c_algo_bit_data i810_i2c_bit_data = {
1554 +       .setsda         = bit_i810i2c_setsda,
1555 +       .setscl         = bit_i810i2c_setscl,
1556 +       .getsda         = bit_i810i2c_getsda,
1557 +       .getscl         = bit_i810i2c_getscl,
1558 +       .udelay         = CYCLE_DELAY,
1559 +       .mdelay         = CYCLE_DELAY,
1560 +       .timeout        = TIMEOUT,
1561 +};
1562 +
1563 +static struct i2c_adapter i810_i2c_adapter = {
1564 +       .owner          = THIS_MODULE,
1565 +       .name           = "I810/I815 I2C Adapter",
1566 +       .algo_data      = &i810_i2c_bit_data,
1567 +};
1568 +
1569 +static struct i2c_algo_bit_data i810_ddc_bit_data = {
1570 +       .setsda         = bit_i810ddc_setsda,
1571 +       .setscl         = bit_i810ddc_setscl,
1572 +       .getsda         = bit_i810ddc_getsda,
1573 +       .getscl         = bit_i810ddc_getscl,
1574 +       .udelay         = CYCLE_DELAY,
1575 +       .mdelay         = CYCLE_DELAY,
1576 +       .timeout        = TIMEOUT,
1577 +};
1578 +
1579 +static struct i2c_adapter i810_ddc_adapter = {
1580 +       .owner          = THIS_MODULE,
1581 +       .name           = "I810/I815 DDC Adapter",
1582 +       .algo_data      = &i810_ddc_bit_data,
1583 +};
1584 +
1585 +static struct pci_device_id i810_ids[] __devinitdata = {
1586 +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG1) },
1587 +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG3) },
1588 +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810E_IG) },
1589 +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82815_CGC) },
1590 +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845G_IG) },
1591 +       { 0, },
1592 +};
1593 +
1594 +static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id *id)
1595 +{
1596 +       int retval;
1597 +
1598 +       retval = config_i810(dev);
1599 +       if (retval)
1600 +               return retval;
1601 +       dev_info(&dev->dev, "i810/i815 i2c device found.\n");
1602 +
1603 +       /* set up the sysfs linkage to our parent device */
1604 +       i810_i2c_adapter.dev.parent = &dev->dev;
1605 +       i810_ddc_adapter.dev.parent = &dev->dev;
1606 +
1607 +       retval = i2c_bit_add_bus(&i810_i2c_adapter);
1608 +       if (retval)
1609 +               return retval;
1610 +       retval = i2c_bit_add_bus(&i810_ddc_adapter);
1611 +       if (retval)
1612 +               i2c_bit_del_bus(&i810_i2c_adapter);
1613 +       return retval;
1614 +}
1615 +
1616 +static void __devexit i810_remove(struct pci_dev *dev)
1617 +{
1618 +       i2c_bit_del_bus(&i810_ddc_adapter);
1619 +       i2c_bit_del_bus(&i810_i2c_adapter);
1620 +       iounmap(ioaddr);
1621 +}
1622 +
1623 +static struct pci_driver i810_driver = {
1624 +       .name           = "i810 smbus",
1625 +       .id_table       = i810_ids,
1626 +       .probe          = i810_probe,
1627 +       .remove         = __devexit_p(i810_remove),
1628 +};
1629 +
1630 +static int __init i2c_i810_init(void)
1631 +{
1632 +       return pci_module_init(&i810_driver);
1633 +}
1634 +
1635 +static void __exit i2c_i810_exit(void)
1636 +{
1637 +       pci_unregister_driver(&i810_driver);
1638 +}
1639 +
1640 +MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
1641 +               "Philip Edelbrock <phil@netroedge.com>, "
1642 +               "Ralph Metzler <rjkm@thp.uni-koeln.de>, "
1643 +               "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
1644 +MODULE_DESCRIPTION("I810/I815 I2C/DDC driver");
1645 +MODULE_LICENSE("GPL");
1646 +
1647 +module_init(i2c_i810_init);
1648 +module_exit(i2c_i810_exit);
1649 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-ibm_iic.c i2c-2.5/drivers/i2c/busses/i2c-ibm_iic.c
1650 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-ibm_iic.c  Thu Jan  1 00:00:00 1970
1651 +++ i2c-2.5/drivers/i2c/busses/i2c-ibm_iic.c    Tue Sep 23 10:12:59 2003
1652 @@ -0,0 +1,729 @@
1653 +/*
1654 + * drivers/i2c/i2c-ibm_iic.c
1655 + *
1656 + * Support for the IIC peripheral on IBM PPC 4xx
1657 + *
1658 + * Copyright (c) 2003 Zultys Technologies.
1659 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
1660 + *
1661 + * Based on original work by 
1662 + *     Ian DaSilva  <idasilva@mvista.com>
1663 + *      Armin Kuster <akuster@mvista.com>
1664 + *     Matt Porter  <mporter@mvista.com>
1665 + *
1666 + *      Copyright 2000-2003 MontaVista Software Inc.
1667 + *
1668 + * Original driver version was highly leveraged from i2c-elektor.c
1669 + *
1670 + *     Copyright 1995-97 Simon G. Vogl
1671 + *                1998-99 Hans Berglund
1672 + *
1673 + *     With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> 
1674 + *     and even Frodo Looijaard <frodol@dds.nl>
1675 + *
1676 + * This program is free software; you can redistribute  it and/or modify it
1677 + * under  the terms of  the GNU General  Public License as published by the
1678 + * Free Software Foundation;  either version 2 of the  License, or (at your
1679 + * option) any later version.
1680 + *
1681 + */
1682 +#include <linux/module.h>
1683 +#include <linux/kernel.h>
1684 +#include <linux/ioport.h>
1685 +#include <linux/delay.h>
1686 +#include <linux/slab.h>
1687 +#include <linux/init.h>
1688 +#include <linux/interrupt.h>
1689 +#include <asm/irq.h>
1690 +#include <asm/io.h>
1691 +#include <linux/i2c.h>
1692 +#include <linux/i2c-id.h>
1693 +#include <asm/ocp.h>
1694 +#include <asm/ibm4xx.h>
1695 +
1696 +#include "i2c-ibm_iic.h"
1697 +
1698 +#define DRIVER_VERSION "2.0"
1699 +
1700 +MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
1701 +MODULE_LICENSE("GPL");
1702 +
1703 +static int iic_scan = 0;
1704 +MODULE_PARM(iic_scan, "i");
1705 +MODULE_PARM_DESC(iic_scan, "Scan for active chips on the bus");
1706 +
1707 +static int iic_force_poll = 0;
1708 +MODULE_PARM(iic_force_poll, "i");
1709 +MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
1710 +
1711 +static int iic_force_fast = 0;
1712 +MODULE_PARM(iic_force_fast, "i");
1713 +MODULE_PARM_DESC(iic_fast_poll, "Force fast mode (400 kHz)");
1714 +
1715 +#define DBG_LEVEL 0
1716 +
1717 +#ifdef DBG
1718 +#undef DBG
1719 +#endif
1720 +
1721 +#ifdef DBG2
1722 +#undef DBG2
1723 +#endif
1724 +
1725 +#if DBG_LEVEL > 0
1726 +#  define DBG(x...)    printk(KERN_DEBUG "ibm-iic" ##x)
1727 +#else
1728 +#  define DBG(x...)    ((void)0)
1729 +#endif
1730 +#if DBG_LEVEL > 1
1731 +#  define DBG2(x...)   DBG( ##x )
1732 +#else
1733 +#  define DBG2(x...)   ((void)0)
1734 +#endif
1735 +#if DBG_LEVEL > 2
1736 +static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
1737 +{
1738 +       volatile struct iic_regs *iic = dev->vaddr;
1739 +       printk(KERN_DEBUG "ibm-iic%d: %s\n", dev->idx, header);
1740 +       printk(KERN_DEBUG "  cntl     = 0x%02x, mdcntl = 0x%02x\n"
1741 +              KERN_DEBUG "  sts      = 0x%02x, extsts = 0x%02x\n"
1742 +              KERN_DEBUG "  clkdiv   = 0x%02x, xfrcnt = 0x%02x\n"
1743 +              KERN_DEBUG "  xtcntlss = 0x%02x, directcntl = 0x%02x\n",
1744 +               in_8(&iic->cntl), in_8(&iic->mdcntl), in_8(&iic->sts), 
1745 +               in_8(&iic->extsts), in_8(&iic->clkdiv), in_8(&iic->xfrcnt), 
1746 +               in_8(&iic->xtcntlss), in_8(&iic->directcntl));
1747 +}
1748 +#  define DUMP_REGS(h,dev)     dump_iic_regs((h),(dev))
1749 +#else
1750 +#  define DUMP_REGS(h,dev)     ((void)0)
1751 +#endif
1752 +
1753 +/* Enable/disable interrupt generation */
1754 +static inline void iic_interrupt_mode(struct ibm_iic_private* dev, int enable)
1755 +{
1756 +       out_8(&dev->vaddr->intmsk, enable ? INTRMSK_EIMTC : 0);
1757 +}
1758
1759 +/*
1760 + * Initialize IIC interface.
1761 + */
1762 +static void iic_dev_init(struct ibm_iic_private* dev)
1763 +{
1764 +       volatile struct iic_regs *iic = dev->vaddr;
1765 +
1766 +       DBG("%d: init\n", dev->idx);
1767 +       
1768 +       /* Clear master address */
1769 +       out_8(&iic->lmadr, 0);
1770 +       out_8(&iic->hmadr, 0);
1771 +
1772 +       /* Clear slave address */
1773 +       out_8(&iic->lsadr, 0);
1774 +       out_8(&iic->hsadr, 0);
1775 +
1776 +       /* Clear status & extended status */
1777 +       out_8(&iic->sts, STS_SCMP | STS_IRQA);
1778 +       out_8(&iic->extsts, EXTSTS_IRQP | EXTSTS_IRQD | EXTSTS_LA
1779 +                           | EXTSTS_ICT | EXTSTS_XFRA);
1780 +
1781 +       /* Set clock divider */
1782 +       out_8(&iic->clkdiv, dev->clckdiv);
1783 +
1784 +       /* Clear transfer count */
1785 +       out_8(&iic->xfrcnt, 0);
1786 +
1787 +       /* Clear extended control and status */
1788 +       out_8(&iic->xtcntlss, XTCNTLSS_SRC | XTCNTLSS_SRS | XTCNTLSS_SWC
1789 +                           | XTCNTLSS_SWS);
1790 +
1791 +       /* Clear control register */
1792 +       out_8(&iic->cntl, 0);
1793 +       
1794 +       /* Enable interrupts if possible */
1795 +       iic_interrupt_mode(dev, dev->irq >= 0);
1796 +
1797 +       /* Set mode control */
1798 +       out_8(&iic->mdcntl, MDCNTL_FMDB | MDCNTL_EINT | MDCNTL_EUBS
1799 +                           | (dev->fast_mode ? MDCNTL_FSM : 0));
1800 +
1801 +       DUMP_REGS("iic_init", dev);
1802 +}
1803 +
1804 +/* 
1805 + * Reset IIC interface
1806 + */
1807 +static void iic_dev_reset(struct ibm_iic_private* dev)
1808 +{
1809 +       volatile struct iic_regs *iic = dev->vaddr;
1810 +       int i;
1811 +       u8 dc;
1812 +       
1813 +       DBG("%d: soft reset\n", dev->idx);
1814 +       DUMP_REGS("reset", dev);
1815 +       
1816 +       /* Place chip in the reset state */
1817 +       out_8(&iic->xtcntlss, XTCNTLSS_SRST);
1818 +       
1819 +       /* Check if bus is free */
1820 +       dc = in_8(&iic->directcntl);    
1821 +       if (!DIRCTNL_FREE(dc)){
1822 +               DBG("%d: trying to regain bus control\n", dev->idx);
1823 +       
1824 +               /* Try to set bus free state */
1825 +               out_8(&iic->directcntl, DIRCNTL_SDAC | DIRCNTL_SCC);    
1826 +       
1827 +               /* Wait until we regain bus control */
1828 +               for (i = 0; i < 100; ++i){
1829 +                       dc = in_8(&iic->directcntl);
1830 +                       if (DIRCTNL_FREE(dc))
1831 +                               break;
1832 +                       
1833 +                       /* Toggle SCL line */
1834 +                       dc ^= DIRCNTL_SCC;
1835 +                       out_8(&iic->directcntl, dc);
1836 +                       udelay(10);
1837 +                       dc ^= DIRCNTL_SCC;
1838 +                       out_8(&iic->directcntl, dc);
1839 +                       
1840 +                       /* be nice */
1841 +                       cond_resched();
1842 +               }
1843 +       }
1844 +       
1845 +       /* Remove reset */
1846 +       out_8(&iic->xtcntlss, 0);
1847 +       
1848 +       /* Reinitialize interface */
1849 +       iic_dev_init(dev);
1850 +}
1851 +
1852 +/*
1853 + * IIC interrupt handler
1854 + */
1855 +static irqreturn_t iic_handler(int irq, void *dev_id, struct pt_regs *regs)
1856 +{
1857 +       struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
1858 +       volatile struct iic_regs* iic = dev->vaddr;
1859 +       
1860 +       DBG2("%d: irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n", 
1861 +            dev->idx, in_8(&iic->sts), in_8(&iic->extsts));
1862 +       
1863 +       /* Acknowledge IRQ and wakeup iic_wait_for_tc */
1864 +       out_8(&iic->sts, STS_IRQA | STS_SCMP);
1865 +       wake_up_interruptible(&dev->wq);
1866 +       
1867 +       return IRQ_HANDLED;
1868 +}
1869 +
1870 +/*
1871 + * Get master transfer result and clear errors if any.
1872 + * Returns the number of actually transferred bytes or error (<0)
1873 + */
1874 +static int iic_xfer_result(struct ibm_iic_private* dev)
1875 +{
1876 +       volatile struct iic_regs *iic = dev->vaddr;     
1877 +       
1878 +       if (unlikely(in_8(&iic->sts) & STS_ERR)){
1879 +               DBG("%d: xfer error, EXTSTS = 0x%02x\n", dev->idx, 
1880 +                       in_8(&iic->extsts));
1881 +                               
1882 +               /* Clear errors and possible pending IRQs */
1883 +               out_8(&iic->extsts, EXTSTS_IRQP | EXTSTS_IRQD | 
1884 +                       EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA);
1885 +                       
1886 +               /* Flush master data buffer */
1887 +               out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
1888 +               
1889 +               /* Is bus free?
1890 +                * If error happened during combined xfer
1891 +                * IIC interface is usually stuck in some strange
1892 +                * state, the only way out - soft reset.
1893 +                */
1894 +               if ((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE){
1895 +                       DBG("%d: bus is stuck, resetting\n", dev->idx);
1896 +                       iic_dev_reset(dev);
1897 +               }
1898 +               return -EREMOTEIO;
1899 +       }
1900 +       else
1901 +               return in_8(&iic->xfrcnt) & XFRCNT_MTC_MASK;
1902 +}
1903 +
1904 +/*
1905 + * Try to abort active transfer.
1906 + */
1907 +static void iic_abort_xfer(struct ibm_iic_private* dev)
1908 +{
1909 +       volatile struct iic_regs *iic = dev->vaddr;
1910 +       unsigned long x;
1911 +       
1912 +       DBG("%d: iic_abort_xfer\n", dev->idx);
1913 +       
1914 +       out_8(&iic->cntl, CNTL_HMT);
1915 +       
1916 +       /*
1917 +        * Wait for the abort command to complete.
1918 +        * It's not worth to be optimized, just poll (timeout >= 1 tick)
1919 +        */
1920 +       x = jiffies + 2;
1921 +       while ((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE){
1922 +               if (time_after(jiffies, x)){
1923 +                       DBG("%d: abort timeout, resetting...\n", dev->idx);
1924 +                       iic_dev_reset(dev);
1925 +                       return;
1926 +               }
1927 +               schedule();
1928 +       }
1929 +
1930 +       /* Just to clear errors */
1931 +       iic_xfer_result(dev);
1932 +}
1933 +
1934 +/*
1935 + * Wait for master transfer to complete.
1936 + * It puts current process to sleep until we get interrupt or timeout expires.
1937 + * Returns the number of transferred bytes or error (<0)
1938 + */
1939 +static int iic_wait_for_tc(struct ibm_iic_private* dev){
1940 +       
1941 +       volatile struct iic_regs *iic = dev->vaddr;
1942 +       int ret = 0;
1943 +       
1944 +       if (dev->irq >= 0){
1945 +               /* Interrupt mode */
1946 +               wait_queue_t wait;
1947 +               init_waitqueue_entry(&wait, current);
1948 +               
1949 +               add_wait_queue(&dev->wq, &wait);
1950 +               set_current_state(TASK_INTERRUPTIBLE);
1951 +               if (in_8(&iic->sts) & STS_PT)
1952 +                       schedule_timeout(dev->adap.timeout * HZ);
1953 +               set_current_state(TASK_RUNNING);
1954 +               remove_wait_queue(&dev->wq, &wait);
1955 +               
1956 +               if (unlikely(signal_pending(current))){
1957 +                       DBG("%d: wait interrupted\n", dev->idx);
1958 +                       ret = -ERESTARTSYS;
1959 +               } else if (unlikely(in_8(&iic->sts) & STS_PT)){
1960 +                       DBG("%d: wait timeout\n", dev->idx);
1961 +                       ret = -ETIMEDOUT;
1962 +               }
1963 +       }
1964 +       else {
1965 +               /* Polling mode */
1966 +               unsigned long x = jiffies + dev->adap.timeout * HZ;
1967 +               
1968 +               while (in_8(&iic->sts) & STS_PT){
1969 +                       if (unlikely(time_after(jiffies, x))){
1970 +                               DBG("%d: poll timeout\n", dev->idx);
1971 +                               ret = -ETIMEDOUT;
1972 +                               break;
1973 +                       }
1974 +               
1975 +                       if (unlikely(signal_pending(current))){
1976 +                               DBG("%d: poll interrupted\n", dev->idx);
1977 +                               ret = -ERESTARTSYS;
1978 +                               break;
1979 +                       }
1980 +                       schedule();
1981 +               }       
1982 +       }
1983 +       
1984 +       if (unlikely(ret < 0))
1985 +               iic_abort_xfer(dev);
1986 +       else
1987 +               ret = iic_xfer_result(dev);
1988 +       
1989 +       DBG2("%d: iic_wait_for_tc -> %d\n", dev->idx, ret);
1990 +       
1991 +       return ret;
1992 +}
1993 +
1994 +/*
1995 + * Low level master transfer routine
1996 + */
1997 +static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm, 
1998 +                         int combined_xfer)
1999 +{
2000 +       volatile struct iic_regs *iic = dev->vaddr;
2001 +       char* buf = pm->buf;
2002 +       int i, j, loops, ret = 0;
2003 +       int len = pm->len;
2004 +
2005 +       u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT;
2006 +       if (pm->flags & I2C_M_RD)
2007 +               cntl |= CNTL_RW;
2008 +       
2009 +       loops = (len + 3) / 4;
2010 +       for (i = 0; i < loops; ++i, len -= 4){
2011 +               int count = len > 4 ? 4 : len;
2012 +               u8 cmd = cntl | ((count - 1) << CNTL_TCT_SHIFT);
2013 +               
2014 +               if (!(cntl & CNTL_RW))
2015 +                       for (j = 0; j < count; ++j)
2016 +                               out_8((volatile u8*)&iic->mdbuf, *buf++);
2017 +               
2018 +               if (i < loops - 1)
2019 +                       cmd |= CNTL_CHT;
2020 +               else if (combined_xfer)
2021 +                       cmd |= CNTL_RPST;
2022 +               
2023 +               DBG2("%d: xfer_bytes, %d, CNTL = 0x%02x\n", dev->idx, count, cmd);
2024 +               
2025 +               /* Start transfer */
2026 +               out_8(&iic->cntl, cmd);
2027 +               
2028 +               /* Wait for completion */
2029 +               ret = iic_wait_for_tc(dev);
2030 +
2031 +               if (unlikely(ret < 0))
2032 +                       break;
2033 +               else if (unlikely(ret != count)){
2034 +                       DBG("%d: xfer_bytes, requested %d, transfered %d\n", 
2035 +                               dev->idx, count, ret);
2036 +                       
2037 +                       /* If it's not a last part of xfer, abort it */
2038 +                       if (combined_xfer || (i < loops - 1))
2039 +                               iic_abort_xfer(dev);
2040 +                               
2041 +                       ret = -EREMOTEIO;
2042 +                       break;                          
2043 +               }
2044 +               
2045 +               if (cntl & CNTL_RW)
2046 +                       for (j = 0; j < count; ++j)
2047 +                               *buf++ = in_8((volatile u8*)&iic->mdbuf);
2048 +       }
2049 +       
2050 +       return ret > 0 ? 0 : ret;
2051 +}
2052 +
2053 +/*
2054 + * Set target slave address for master transfer
2055 + */
2056 +static inline void iic_address(struct ibm_iic_private* dev, struct i2c_msg* msg)
2057 +{
2058 +       volatile struct iic_regs *iic = dev->vaddr;
2059 +       u16 addr = msg->addr;
2060 +       
2061 +       DBG2("%d: iic_address, 0x%03x (%d-bit)\n", dev->idx, 
2062 +               addr, msg->flags & I2C_M_TEN ? 10 : 7);
2063 +       
2064 +       if (msg->flags & I2C_M_TEN){
2065 +           out_8(&iic->cntl, CNTL_AMD);
2066 +           out_8(&iic->lmadr, addr);
2067 +           out_8(&iic->hmadr, 0xf0 | ((addr >> 7) & 0x06));
2068 +       }
2069 +       else {
2070 +           out_8(&iic->cntl, 0);
2071 +           out_8(&iic->lmadr, addr << 1);
2072 +       }
2073 +}
2074 +
2075 +static inline int iic_invalid_address(const struct i2c_msg* p)
2076 +{
2077 +       return (p->addr > 0x3ff) || (!(p->flags & I2C_M_TEN) && (p->addr > 0x7f));
2078 +}
2079 +
2080 +static inline int iic_address_neq(const struct i2c_msg* p1, 
2081 +                                 const struct i2c_msg* p2)
2082 +{
2083 +       return (p1->addr != p2->addr) 
2084 +               || ((p1->flags & I2C_M_TEN) != (p2->flags & I2C_M_TEN));
2085 +} 
2086 +
2087 +/*
2088 + * Generic master transfer entrypoint. 
2089 + * Returns the number of processed messages or error (<0)
2090 + */
2091 +static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
2092 +{
2093 +       struct ibm_iic_private* dev = (struct ibm_iic_private*)(i2c_get_adapdata(adap));
2094 +       volatile struct iic_regs *iic = dev->vaddr;
2095 +       int i, ret = 0;
2096 +       
2097 +       DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num);
2098 +       
2099 +       if (!num)
2100 +               return 0;
2101 +       
2102 +       /* Check the sanity of the passed messages.
2103 +        * Uhh, generic i2c layer is more suitable place for such code...
2104 +        */
2105 +       if (unlikely(iic_invalid_address(&msgs[0]))){
2106 +               DBG("%d: invalid address 0x%03x (%d-bit)\n", dev->idx, 
2107 +                       msgs[0].addr, msgs[0].flags & I2C_M_TEN ? 10 : 7);
2108 +               return -EINVAL;
2109 +       }               
2110 +       for (i = 0; i < num; ++i){
2111 +               if (unlikely(msgs[i].len <= 0)){
2112 +                       DBG("%d: invalid len %d in msg[%d]\n", dev->idx, 
2113 +                               msgs[i].len, i);
2114 +                       return -EINVAL;
2115 +               }
2116 +               if (unlikely(iic_address_neq(&msgs[0], &msgs[i]))){
2117 +                       DBG("%d: invalid addr in msg[%d]\n", dev->idx, i);
2118 +                       return -EINVAL;
2119 +               }
2120 +       }
2121 +       
2122 +       /* Check bus state */
2123 +       if (unlikely((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE)){
2124 +               DBG("%d: iic_xfer, bus is not free\n", dev->idx);
2125 +               
2126 +               /* Usually it means something serious has happend.
2127 +                * We *cannot* have unfinished previous transfer
2128 +                * so it doesn't make any sense to try to stop it.
2129 +                * Probably we were not able to recover from the 
2130 +                * previous error.
2131 +                * The only *reasonable* thing I can think of here
2132 +                * is soft reset.  --ebs
2133 +                */
2134 +               iic_dev_reset(dev);
2135 +               
2136 +               if ((in_8(&iic->extsts) & EXTSTS_BCS_MASK) != EXTSTS_BCS_FREE){
2137 +                       DBG("%d: iic_xfer, bus is still not free\n", dev->idx);
2138 +                       return -EREMOTEIO;
2139 +               }
2140 +       } 
2141 +       else {
2142 +               /* Flush master data buffer (just in case) */
2143 +               out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
2144 +       }
2145 +       
2146 +       /* Load slave address */
2147 +       iic_address(dev, &msgs[0]);
2148 +       
2149 +       /* Do real transfer */
2150 +       for (i = 0; i < num && !ret; ++i)
2151 +               ret = iic_xfer_bytes(dev, &msgs[i], i < num - 1);
2152 +
2153 +       return ret < 0 ? ret : num;
2154 +}
2155 +
2156 +static u32 iic_func(struct i2c_adapter *adap)
2157 +{
2158 +       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR;
2159 +}
2160 +
2161 +static struct i2c_algorithm iic_algo = {
2162 +       .name           = "IBM IIC algorithm",
2163 +       .id             = I2C_ALGO_OCP,
2164 +       .master_xfer    = iic_xfer,
2165 +       .smbus_xfer     = NULL,
2166 +       .slave_send     = NULL,
2167 +       .slave_recv     = NULL,
2168 +       .algo_control   = NULL,
2169 +       .functionality  = iic_func
2170 +};
2171 +
2172 +/*
2173 + * Scan bus for valid 7-bit addresses (ie things that ACK on 1 byte read)
2174 + * We only scan range [0x08 - 0x77], all other addresses are reserved anyway
2175 + */
2176 +static void __devinit iic_scan_bus(struct ibm_iic_private* dev)
2177 +{
2178 +       int found = 0;
2179 +       char dummy;
2180 +       struct i2c_msg msg = {
2181 +               .buf   = &dummy,
2182 +               .len   = sizeof(dummy),
2183 +               .flags = I2C_M_RD
2184 +       };
2185 +       
2186 +       printk(KERN_INFO "ibm-iic%d: scanning bus...\n" KERN_INFO, dev->idx);
2187 +       
2188 +       for (msg.addr = 8; msg.addr < 0x78; ++msg.addr)
2189 +               if (iic_xfer(&dev->adap, &msg, 1) == 1){
2190 +                       ++found;
2191 +                       printk(" 0x%02x", msg.addr);
2192 +               }
2193 +
2194 +       printk("%sibm-iic%d: %d device(s) detected\n", 
2195 +               found ? "\n" KERN_INFO : "", dev->idx, found);
2196 +}
2197 +
2198 +/*
2199 + * Calculates IICx_CLCKDIV value for a specific OPB clock frequency
2200 + */
2201 +static inline u8 iic_clckdiv(unsigned int opb)
2202 +{
2203 +       /* Compatibility kludge, should go away after all cards
2204 +        * are fixed to fill correct value for opbfreq.
2205 +        * Previous driver version used hardcoded divider value 4,
2206 +        * it corresponds to OPB frequency from the range (40, 50] MHz
2207 +        */
2208 +       if (!opb){
2209 +               printk(KERN_WARNING "ibm-iic: using compatibility value for OPB freq,"
2210 +                       " fix your board specific setup\n");
2211 +               opb = 50000000;
2212 +       }
2213 +
2214 +       /* Convert to MHz */
2215 +       opb /= 1000000;
2216 +       
2217 +       if (opb < 20 || opb > 150){
2218 +               printk(KERN_CRIT "ibm-iic: invalid OPB clock frequency %u MHz\n",
2219 +                       opb);
2220 +               opb = opb < 20 ? 20 : 150;
2221 +       }
2222 +       return (u8)((opb + 9) / 10 - 1);
2223 +}
2224 +
2225 +/*
2226 + * Register single IIC interface
2227 + */
2228 +static int __devinit iic_probe(struct ocp_device *ocp){
2229 +
2230 +       struct ibm_iic_private* dev;
2231 +       struct i2c_adapter* adap;
2232 +       int ret;
2233 +       bd_t* bd = (bd_t*)&__res;
2234 +       
2235 +       if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){
2236 +               printk(KERN_CRIT "ibm-iic: failed to allocate device data\n");
2237 +               return -ENOMEM;
2238 +       }
2239 +
2240 +       memset(dev, 0, sizeof(*dev));
2241 +       dev->idx = ocp->num;
2242 +       ocp_set_drvdata(ocp, dev);
2243 +       
2244 +       if (!(dev->vaddr = ioremap(ocp->paddr, sizeof(struct iic_regs)))){
2245 +               printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
2246 +                       dev->idx);
2247 +               ret = -ENXIO;
2248 +               goto fail2;
2249 +       }
2250 +       
2251 +       init_waitqueue_head(&dev->wq);
2252 +
2253 +       dev->irq = iic_force_poll ? -1 : ocp->irq;
2254 +       if (dev->irq >= 0){
2255 +               /* Disable interrupts until we finish intialization,
2256 +                  assumes level-sensitive IRQ setup...
2257 +                */
2258 +               iic_interrupt_mode(dev, 0);
2259 +               if (request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)){
2260 +                       printk(KERN_ERR "ibm-iic%d: request_irq %d failed\n", 
2261 +                               dev->idx, dev->irq);
2262 +                       /* Fallback to the polling mode */      
2263 +                       dev->irq = -1;
2264 +               }
2265 +       }
2266 +       
2267 +       if (dev->irq < 0)
2268 +               printk(KERN_WARNING "ibm-iic%d: using polling mode\n", 
2269 +                       dev->idx);
2270 +               
2271 +       /* Board specific settings */
2272 +       BUG_ON(dev->idx >= sizeof(bd->bi_iic_fast) / sizeof(bd->bi_iic_fast[0]));
2273 +       dev->fast_mode = iic_force_fast ? 1 : bd->bi_iic_fast[dev->idx];
2274 +       
2275 +       /* clckdiv is the same for *all* IIC interfaces, 
2276 +        * but I'd rather make a copy than introduce another global. --ebs
2277 +        */
2278 +       dev->clckdiv = iic_clckdiv(bd->bi_opb_busfreq);
2279 +       DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
2280 +       
2281 +       /* Initialize IIC interface */
2282 +       iic_dev_init(dev);
2283 +       
2284 +       /* Register it with i2c layer */
2285 +       adap = &dev->adap;
2286 +       strcpy(adap->dev.name, "IBM IIC");
2287 +       i2c_set_adapdata(adap, dev);
2288 +       adap->id = I2C_HW_OCP | iic_algo.id;
2289 +       adap->algo = &iic_algo;
2290 +       adap->client_register = NULL;
2291 +       adap->client_unregister = NULL;
2292 +       adap->timeout = 1;
2293 +       adap->retries = 1;
2294 +
2295 +       if ((ret = i2c_add_adapter(adap)) != 0){
2296 +               printk(KERN_CRIT "ibm-iic%d: failed to register i2c adapter\n",
2297 +                       dev->idx);
2298 +               goto fail;
2299 +       }
2300 +       
2301 +       printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
2302 +               dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
2303 +
2304 +       /* Scan bus if requested by user */
2305 +       if (iic_scan)
2306 +               iic_scan_bus(dev);
2307 +
2308 +       return 0;
2309 +
2310 +fail:  
2311 +       if (dev->irq >= 0){
2312 +               iic_interrupt_mode(dev, 0);
2313 +               free_irq(dev->irq, dev);
2314 +       }       
2315 +
2316 +       iounmap((void*)dev->vaddr);
2317 +fail2: 
2318 +       ocp_set_drvdata(ocp, 0);
2319 +       kfree(dev);     
2320 +       return ret;
2321 +}
2322 +
2323 +/*
2324 + * Cleanup initialized IIC interface
2325 + */
2326 +static void __devexit iic_remove(struct ocp_device *ocp)
2327 +{
2328 +       struct ibm_iic_private* dev = (struct ibm_iic_private*)ocp_get_drvdata(ocp);
2329 +       BUG_ON(dev == NULL);
2330 +       if (i2c_del_adapter(&dev->adap)){
2331 +               printk(KERN_CRIT "ibm-iic%d: failed to delete i2c adapter :(\n",
2332 +                       dev->idx);
2333 +               /* That's *very* bad, just shutdown IRQ ... */
2334 +               if (dev->irq >= 0){
2335 +                   iic_interrupt_mode(dev, 0); 
2336 +                   free_irq(dev->irq, dev);
2337 +                   dev->irq = -1;
2338 +               }
2339 +       } else {
2340 +               if (dev->irq >= 0){
2341 +                   iic_interrupt_mode(dev, 0); 
2342 +                   free_irq(dev->irq, dev);
2343 +               }
2344 +               iounmap((void*)dev->vaddr);
2345 +               kfree(dev);
2346 +       }
2347 +}
2348 +
2349 +static struct ocp_device_id ibm_iic_ids[] __devinitdata = 
2350 +{
2351 +       { .vendor = OCP_VENDOR_IBM, .device = OCP_FUNC_IIC },
2352 +       { .vendor = OCP_VENDOR_INVALID }
2353 +};
2354 +
2355 +MODULE_DEVICE_TABLE(ocp, ibm_iic_ids);
2356 +
2357 +static struct ocp_driver ibm_iic_driver =
2358 +{
2359 +       .name           = "ocp_iic",
2360 +       .id_table       = ibm_iic_ids,
2361 +       .probe          = iic_probe,
2362 +       .remove         = __devexit_p(iic_remove),
2363 +#if defined(CONFIG_PM)
2364 +       .suspend        = NULL,
2365 +       .resume         = NULL,
2366 +#endif
2367 +};
2368 +
2369 +static int __init iic_init(void)
2370 +{
2371 +       printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n");
2372 +       return ocp_module_init(&ibm_iic_driver);
2373 +}
2374 +
2375 +static void __exit iic_exit(void)
2376 +{
2377 +       ocp_unregister_driver(&ibm_iic_driver);
2378 +}
2379 +
2380 +module_init(iic_init);
2381 +module_exit(iic_exit);
2382 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-ibm_iic.h i2c-2.5/drivers/i2c/busses/i2c-ibm_iic.h
2383 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-ibm_iic.h  Thu Jan  1 00:00:00 1970
2384 +++ i2c-2.5/drivers/i2c/busses/i2c-ibm_iic.h    Tue Sep 23 10:12:59 2003
2385 @@ -0,0 +1,124 @@
2386 +/*
2387 + * drivers/i2c/i2c-ibm_iic.h
2388 + *
2389 + * Support for the IIC peripheral on IBM PPC 4xx
2390 + * 
2391 + * Copyright (c) 2003 Zultys Technologies.
2392 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
2393 + *
2394 + * Based on original work by 
2395 + *     Ian DaSilva  <idasilva@mvista.com>
2396 + *      Armin Kuster <akuster@mvista.com>
2397 + *     Matt Porter  <mporter@mvista.com>
2398 + *
2399 + *      Copyright 2000-2003 MontaVista Software Inc.
2400 + *
2401 + * This program is free software; you can redistribute  it and/or modify it
2402 + * under  the terms of  the GNU General  Public License as published by the
2403 + * Free Software Foundation;  either version 2 of the  License, or (at your
2404 + * option) any later version.
2405 + *
2406 + */
2407 +#ifndef __I2C_IBM_IIC_H_
2408 +#define __I2C_IBM_IIC_H_
2409 +
2410 +#include <linux/config.h>
2411 +#include <linux/i2c.h> 
2412 +
2413 +struct iic_regs {
2414 +       u16 mdbuf;
2415 +       u16 sbbuf;
2416 +       u8 lmadr;
2417 +       u8 hmadr;
2418 +       u8 cntl;
2419 +       u8 mdcntl;
2420 +       u8 sts;
2421 +       u8 extsts;
2422 +       u8 lsadr;
2423 +       u8 hsadr;
2424 +       u8 clkdiv;
2425 +       u8 intmsk;
2426 +       u8 xfrcnt;
2427 +       u8 xtcntlss;
2428 +       u8 directcntl;
2429 +};
2430 +
2431 +struct ibm_iic_private {
2432 +       struct i2c_adapter adap;
2433 +       volatile struct iic_regs *vaddr;
2434 +       wait_queue_head_t wq;
2435 +       int idx;
2436 +       int irq;
2437 +       int fast_mode;
2438 +       u8  clckdiv;
2439 +};
2440 +
2441 +/* IICx_CNTL register */
2442 +#define CNTL_HMT       0x80
2443 +#define CNTL_AMD       0x40
2444 +#define CNTL_TCT_MASK  0x30
2445 +#define CNTL_TCT_SHIFT 4
2446 +#define CNTL_RPST      0x08
2447 +#define CNTL_CHT       0x04 
2448 +#define CNTL_RW                0x02
2449 +#define CNTL_PT                0x01
2450 +
2451 +/* IICx_MDCNTL register */
2452 +#define MDCNTL_FSDB    0x80
2453 +#define MDCNTL_FMDB    0x40
2454 +#define MDCNTL_EGC     0x20
2455 +#define MDCNTL_FSM     0x10
2456 +#define MDCNTL_ESM     0x08
2457 +#define MDCNTL_EINT    0x04
2458 +#define MDCNTL_EUBS    0x02
2459 +#define MDCNTL_HSCL    0x01
2460 +
2461 +/* IICx_STS register */
2462 +#define STS_SSS                0x80
2463 +#define STS_SLPR       0x40
2464 +#define STS_MDBS       0x20
2465 +#define STS_MDBF       0x10
2466 +#define STS_SCMP       0x08
2467 +#define STS_ERR                0x04
2468 +#define STS_IRQA       0x02
2469 +#define STS_PT         0x01
2470 +
2471 +/* IICx_EXTSTS register */
2472 +#define EXTSTS_IRQP    0x80
2473 +#define EXTSTS_BCS_MASK        0x70
2474 +#define   EXTSTS_BCS_FREE  0x40
2475 +#define EXTSTS_IRQD    0x08
2476 +#define EXTSTS_LA      0x04
2477 +#define EXTSTS_ICT     0x02
2478 +#define EXTSTS_XFRA    0x01
2479 +
2480 +/* IICx_INTRMSK register */
2481 +#define INTRMSK_EIRC   0x80
2482 +#define INTRMSK_EIRS   0x40
2483 +#define INTRMSK_EIWC   0x20
2484 +#define INTRMSK_EIWS   0x10
2485 +#define INTRMSK_EIHE   0x08
2486 +#define INTRMSK_EIIC   0x04
2487 +#define INTRMSK_EITA   0x02
2488 +#define INTRMSK_EIMTC  0x01
2489 +
2490 +/* IICx_XFRCNT register */
2491 +#define XFRCNT_MTC_MASK        0x07
2492 +
2493 +/* IICx_XTCNTLSS register */
2494 +#define XTCNTLSS_SRC   0x80
2495 +#define XTCNTLSS_SRS   0x40
2496 +#define XTCNTLSS_SWC   0x20
2497 +#define XTCNTLSS_SWS   0x10
2498 +#define XTCNTLSS_SRST  0x01
2499 +
2500 +/* IICx_DIRECTCNTL register */
2501 +#define DIRCNTL_SDAC   0x08
2502 +#define DIRCNTL_SCC    0x04
2503 +#define DIRCNTL_MSDA   0x02
2504 +#define DIRCNTL_MSC    0x01
2505 +
2506 +/* Check if we really control the I2C bus and bus is free */
2507 +#define DIRCTNL_FREE(v)        (((v) & 0x0f) == 0x0f)
2508 +
2509 +#endif /* __I2C_IBM_IIC_H_ */
2510 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-iop3xx.c i2c-2.5/drivers/i2c/busses/i2c-iop3xx.c
2511 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-iop3xx.c   Thu Jan  1 00:00:00 1970
2512 +++ i2c-2.5/drivers/i2c/busses/i2c-iop3xx.c     Tue Sep 23 10:12:59 2003
2513 @@ -0,0 +1,536 @@
2514 +/* ------------------------------------------------------------------------- */
2515 +/* i2c-iop3xx.c i2c driver algorithms for Intel XScale IOP3xx                */
2516 +/* ------------------------------------------------------------------------- */
2517 +/*   Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd
2518 + *                      <Peter dot Milne at D hyphen TACQ dot com>
2519 +
2520 +    This program is free software; you can redistribute it and/or modify
2521 +    it under the terms of the GNU General Public License as published by
2522 +    the Free Software Foundation, version 2.
2523 +
2524 +
2525 +    This program is distributed in the hope that it will be useful,
2526 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
2527 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2528 +    GNU General Public License for more details.
2529 +
2530 +    You should have received a copy of the GNU General Public License
2531 +    along with this program; if not, write to the Free Software
2532 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
2533 +/* ------------------------------------------------------------------------- */
2534 +/*
2535 +   With acknowledgements to i2c-algo-ibm_ocp.c by 
2536 +   Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com
2537 +
2538 +   And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund:
2539 +
2540 +     Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund
2541 +   
2542 +   And which acknowledged Kyösti Mälkki <kmalkki@cc.hut.fi>,
2543 +   Frodo Looijaard <frodol@dds.nl>, Martin Bailey<mbailey@littlefeet-inc.com>
2544 +
2545 +  ---------------------------------------------------------------------------*/
2546 +
2547 +
2548 +#include <linux/interrupt.h>
2549 +#include <linux/kernel.h>
2550 +#include <linux/module.h>
2551 +#include <linux/delay.h>
2552 +#include <linux/slab.h>
2553 +#include <linux/init.h>
2554 +#include <linux/errno.h>
2555 +#include <linux/sched.h>
2556 +#include <linux/i2c.h>
2557 +
2558 +
2559 +#include <asm/arch-iop3xx/iop321.h>
2560 +#include <asm/arch-iop3xx/iop321-irqs.h>
2561 +#include "i2c-iop3xx.h"
2562 +
2563 +
2564 +/* ----- global defines ----------------------------------------------- */
2565 +#define PASSERT(x) do { if (!(x) ) \
2566 +               printk(KERN_CRIT "PASSERT %s in %s:%d\n", #x, __FILE__, __LINE__ );\
2567 +       } while (0)
2568 +
2569 +
2570 +/* ----- global variables ---------------------------------------------        */
2571 +
2572 +
2573 +static inline unsigned char iic_cook_addr(struct i2c_msg *msg) 
2574 +{
2575 +       unsigned char addr;
2576 +
2577 +       addr = (msg->addr << 1);
2578 +
2579 +       if (msg->flags & I2C_M_RD)
2580 +               addr |= 1;
2581 +
2582 +       /* PGM: what is M_REV_DIR_ADDR - do we need it ?? */
2583 +       if (msg->flags & I2C_M_REV_DIR_ADDR)
2584 +               addr ^= 1;
2585 +
2586 +       return addr;   
2587 +}
2588 +
2589 +
2590 +static inline void iop3xx_adap_reset(struct i2c_algo_iop3xx_data *iop3xx_adap)
2591 +{
2592 +       /* Follows devman 9.3 */
2593 +       *iop3xx_adap->biu->CR = IOP321_ICR_UNIT_RESET;
2594 +       *iop3xx_adap->biu->SR = IOP321_ISR_CLEARBITS;
2595 +       *iop3xx_adap->biu->CR = 0;
2596 +} 
2597 +
2598 +static inline void iop3xx_adap_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap)
2599 +{
2600 +       *iop3xx_adap->biu->SAR = MYSAR;
2601 +}
2602 +
2603 +static inline void iop3xx_adap_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
2604 +{
2605 +       u32 cr = IOP321_ICR_GCD|IOP321_ICR_SCLEN|IOP321_ICR_UE;
2606 +
2607 +       /* NB SR bits not same position as CR IE bits :-( */
2608 +       iop3xx_adap->biu->SR_enabled = 
2609 +               IOP321_ISR_ALD | IOP321_ISR_BERRD |
2610 +               IOP321_ISR_RXFULL | IOP321_ISR_TXEMPTY;
2611 +
2612 +       cr |= IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
2613 +               IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE;
2614 +
2615 +       *iop3xx_adap->biu->CR = cr;
2616 +}
2617 +
2618 +static void iop3xx_adap_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
2619 +{
2620 +       unsigned cr = *iop3xx_adap->biu->CR;
2621 +       
2622 +       cr &= ~(IOP321_ICR_MSTART | IOP321_ICR_TBYTE | 
2623 +               IOP321_ICR_MSTOP | IOP321_ICR_SCLEN);
2624 +       *iop3xx_adap->biu->CR = cr;
2625 +}
2626 +
2627 +static void iop3xx_adap_final_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
2628 +{
2629 +       unsigned cr = *iop3xx_adap->biu->CR;
2630 +       
2631 +       cr &= ~(IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
2632 +               IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE);
2633 +       iop3xx_adap->biu->SR_enabled = 0;
2634 +       *iop3xx_adap->biu->CR = cr;
2635 +}
2636 +
2637 +/* 
2638 + * NB: the handler has to clear the source of the interrupt! 
2639 + * Then it passes the SR flags of interest to BH via adap data
2640 + */
2641 +static void iop3xx_i2c_handler(int this_irq, 
2642 +                               void *dev_id, 
2643 +                               struct pt_regs *regs) 
2644 +{
2645 +       struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id;
2646 +
2647 +       u32 sr = *iop3xx_adap->biu->SR;
2648 +
2649 +       if ((sr &= iop3xx_adap->biu->SR_enabled)) {
2650 +               *iop3xx_adap->biu->SR = sr;
2651 +               iop3xx_adap->biu->SR_received |= sr;
2652 +               wake_up_interruptible(&iop3xx_adap->waitq);
2653 +       }
2654 +}
2655 +
2656 +/* check all error conditions, clear them , report most important */
2657 +static int iop3xx_adap_error(u32 sr)
2658 +{
2659 +       int rc = 0;
2660 +
2661 +       if ((sr&IOP321_ISR_BERRD)) {
2662 +               if ( !rc ) rc = -I2C_ERR_BERR;
2663 +       }
2664 +       if ((sr&IOP321_ISR_ALD)) {
2665 +               if ( !rc ) rc = -I2C_ERR_ALD;           
2666 +       }
2667 +       return rc;      
2668 +}
2669 +
2670 +static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap)
2671 +{
2672 +       unsigned long flags;
2673 +       u32 sr;
2674 +
2675 +       spin_lock_irqsave(&iop3xx_adap->lock, flags);
2676 +       sr = iop3xx_adap->biu->SR_received;
2677 +       iop3xx_adap->biu->SR_received = 0;
2678 +       spin_unlock_irqrestore(&iop3xx_adap->lock, flags);
2679 +
2680 +       return sr;
2681 +}
2682 +
2683 +/*
2684 + * sleep until interrupted, then recover and analyse the SR
2685 + * saved by handler
2686 + */
2687 +typedef int (* compare_func)(unsigned test, unsigned mask);
2688 +/* returns 1 on correct comparison */
2689 +
2690 +static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, 
2691 +                                 unsigned flags, unsigned* status,
2692 +                                 compare_func compare)
2693 +{
2694 +       unsigned sr = 0;
2695 +       int interrupted;
2696 +       int done;
2697 +       int rc;
2698 +
2699 +       do {
2700 +               interrupted = wait_event_interruptible_timeout (
2701 +                       iop3xx_adap->waitq,
2702 +                       (done = compare( sr = get_srstat(iop3xx_adap),flags )),
2703 +                       iop3xx_adap->timeout
2704 +                       );
2705 +               if ((rc = iop3xx_adap_error(sr)) < 0) {
2706 +                       *status = sr;
2707 +                       return rc;
2708 +               }else if (!interrupted) {
2709 +                       *status = sr;
2710 +                       return rc = -ETIMEDOUT;
2711 +               }
2712 +       } while(!done);
2713 +
2714 +       *status = sr;
2715 +
2716 +       return rc = 0;
2717 +}
2718 +
2719 +/*
2720 + * Concrete compare_funcs 
2721 + */
2722 +static int all_bits_clear(unsigned test, unsigned mask)
2723 +{
2724 +       return (test & mask) == 0;
2725 +}
2726 +static int any_bits_set(unsigned test, unsigned mask)
2727 +{
2728 +       return (test & mask) != 0;
2729 +}
2730 +
2731 +static int iop3xx_adap_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2732 +{
2733 +       return iop3xx_adap_wait_event( 
2734 +               iop3xx_adap, 
2735 +               IOP321_ISR_TXEMPTY|IOP321_ISR_ALD|IOP321_ISR_BERRD,
2736 +               status, any_bits_set);
2737 +}
2738 +
2739 +static int iop3xx_adap_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2740 +{
2741 +       return iop3xx_adap_wait_event( 
2742 +               iop3xx_adap, 
2743 +               IOP321_ISR_RXFULL|IOP321_ISR_ALD|IOP321_ISR_BERRD,
2744 +               status, any_bits_set);
2745 +}
2746 +
2747 +static int iop3xx_adap_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2748 +{
2749 +       return iop3xx_adap_wait_event( 
2750 +               iop3xx_adap, IOP321_ISR_UNITBUSY, status, all_bits_clear);
2751 +}
2752 +
2753 +/*
2754 + * Description: This performs the IOP3xx initialization sequence
2755 + * Valid for IOP321. Maybe valid for IOP310?.
2756 + */
2757 +static int iop3xx_adap_init (struct i2c_algo_iop3xx_data *iop3xx_adap)
2758 +{
2759 +       *IOP321_GPOD &= ~(iop3xx_adap->channel==0 ?
2760 +                         IOP321_GPOD_I2C0:
2761 +                         IOP321_GPOD_I2C1);
2762 +
2763 +       iop3xx_adap_reset(iop3xx_adap);
2764 +       iop3xx_adap_set_slave_addr(iop3xx_adap);
2765 +       iop3xx_adap_enable(iop3xx_adap);
2766 +       
2767 +        return 0;
2768 +}
2769 +
2770 +static int iop3xx_adap_send_target_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap,
2771 +                                             struct i2c_msg* msg)
2772 +{
2773 +       unsigned cr = *iop3xx_adap->biu->CR;
2774 +       int status;
2775 +       int rc;
2776 +
2777 +       *iop3xx_adap->biu->DBR = iic_cook_addr(msg);
2778 +       
2779 +       cr &= ~(IOP321_ICR_MSTOP | IOP321_ICR_NACK);
2780 +       cr |= IOP321_ICR_MSTART | IOP321_ICR_TBYTE;
2781 +
2782 +       *iop3xx_adap->biu->CR = cr;
2783 +       rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
2784 +       /* this assert fires every time, contrary to IOP manual 
2785 +       PASSERT((status&IOP321_ISR_UNITBUSY)!=0);
2786 +       */
2787 +       PASSERT((status&IOP321_ISR_RXREAD)==0);
2788 +            
2789 +       return rc;
2790 +}
2791 +
2792 +static int iop3xx_adap_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, int stop)
2793 +{
2794 +       unsigned cr = *iop3xx_adap->biu->CR;
2795 +       int status;
2796 +       int rc;
2797 +
2798 +       *iop3xx_adap->biu->DBR = byte;
2799 +       cr &= ~IOP321_ICR_MSTART;
2800 +       if (stop) {
2801 +               cr |= IOP321_ICR_MSTOP;
2802 +       } else {
2803 +               cr &= ~IOP321_ICR_MSTOP;
2804 +       }
2805 +       *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
2806 +       rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
2807 +
2808 +       return rc;
2809 +} 
2810 +
2811 +static int iop3xx_adap_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap,
2812 +                                char* byte, int stop)
2813 +{
2814 +       unsigned cr = *iop3xx_adap->biu->CR;
2815 +       int status;
2816 +       int rc;
2817 +
2818 +       cr &= ~IOP321_ICR_MSTART;
2819 +
2820 +       if (stop) {
2821 +               cr |= IOP321_ICR_MSTOP|IOP321_ICR_NACK;
2822 +       } else {
2823 +               cr &= ~(IOP321_ICR_MSTOP|IOP321_ICR_NACK);
2824 +       }
2825 +       *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
2826 +
2827 +       rc = iop3xx_adap_wait_rx_done(iop3xx_adap, &status);
2828 +
2829 +       *byte = *iop3xx_adap->biu->DBR;
2830 +
2831 +       return rc;
2832 +}
2833 +
2834 +static int iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap, 
2835 +                                const char *buf, int count)
2836 +{
2837 +       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2838 +       int ii;
2839 +       int rc = 0;
2840 +
2841 +       for (ii = 0; rc == 0 && ii != count; ++ii) {
2842 +               rc = iop3xx_adap_write_byte(iop3xx_adap, buf[ii], ii==count-1);
2843 +       }
2844 +       return rc;
2845 +}
2846 +
2847 +static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, 
2848 +                               char *buf, int count)
2849 +{
2850 +       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2851 +       int ii;
2852 +       int rc = 0;
2853 +
2854 +       for (ii = 0; rc == 0 && ii != count; ++ii) {
2855 +               rc = iop3xx_adap_read_byte(iop3xx_adap, &buf[ii], ii==count-1);
2856 +       }
2857 +       return rc;
2858 +}
2859 +
2860 +/*
2861 + * Description:  This function implements combined transactions.  Combined
2862 + * transactions consist of combinations of reading and writing blocks of data.
2863 + * FROM THE SAME ADDRESS
2864 + * Each transfer (i.e. a read or a write) is separated by a repeated start
2865 + * condition.
2866 + */
2867 +static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) 
2868 +{
2869 +       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2870 +       int rc;
2871 +
2872 +       rc = iop3xx_adap_send_target_slave_addr(iop3xx_adap, pmsg);
2873 +       if (rc < 0) {
2874 +               return rc;
2875 +       }
2876 +
2877 +       if ((pmsg->flags&I2C_M_RD)) {
2878 +               return iop3xx_i2c_readbytes(i2c_adap, pmsg->buf, pmsg->len);
2879 +       } else {
2880 +               return iop3xx_i2c_writebytes(i2c_adap, pmsg->buf, pmsg->len);
2881 +       }
2882 +}
2883 +
2884 +/*
2885 + * master_xfer() - main read/write entry
2886 + */
2887 +static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
2888 +{
2889 +       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2890 +       int im = 0;
2891 +       int ret = 0;
2892 +       int status;
2893 +
2894 +       iop3xx_adap_wait_idle(iop3xx_adap, &status);
2895 +       iop3xx_adap_reset(iop3xx_adap);
2896 +       iop3xx_adap_enable(iop3xx_adap);
2897 +
2898 +       for (im = 0; ret == 0 && im != num; ++im) {
2899 +               ret = iop3xx_handle_msg(i2c_adap, &msgs[im]);
2900 +       }
2901 +
2902 +       iop3xx_adap_transaction_cleanup(iop3xx_adap);
2903 +
2904 +       return ret;   
2905 +}
2906 +
2907 +static int algo_control(struct i2c_adapter *adapter, unsigned int cmd,
2908 +                       unsigned long arg)
2909 +{
2910 +       return 0;
2911 +}
2912 +
2913 +static u32 iic_func(struct i2c_adapter *adap)
2914 +{
2915 +       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
2916 +}
2917 +
2918 +
2919 +/* -----exported algorithm data: ------------------------------------- */
2920 +
2921 +static struct i2c_algorithm iic_algo = {
2922 +       .name           = "IOP3xx I2C algorithm",
2923 +       .id             = I2C_ALGO_OCP_IOP3XX,
2924 +       .master_xfer    = iop3xx_master_xfer,
2925 +       .algo_control   = algo_control,
2926 +       .functionality  = iic_func,
2927 +};
2928 +
2929 +/* 
2930 + * registering functions to load algorithms at runtime 
2931 + */
2932 +static int i2c_iop3xx_add_bus(struct i2c_adapter *iic_adap)
2933 +{
2934 +       struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
2935 +
2936 +       if (!request_region( REGION_START(iop3xx_adap), 
2937 +                             REGION_LENGTH(iop3xx_adap),
2938 +                             iic_adap->name)) {
2939 +               return -ENODEV;
2940 +       }
2941 +
2942 +       init_waitqueue_head(&iop3xx_adap->waitq);
2943 +       spin_lock_init(&iop3xx_adap->lock);
2944 +
2945 +       if (request_irq( 
2946 +                    iop3xx_adap->biu->irq,
2947 +                    iop3xx_i2c_handler,
2948 +                    /* SA_SAMPLE_RANDOM */ 0,
2949 +                    iic_adap->name,
2950 +                    iop3xx_adap)) {
2951 +               return -ENODEV;
2952 +       }                         
2953 +
2954 +       /* register new iic_adapter to i2c module... */
2955 +       iic_adap->id |= iic_algo.id;
2956 +       iic_adap->algo = &iic_algo;
2957 +
2958 +       iic_adap->timeout = 100;        /* default values, should */
2959 +       iic_adap->retries = 3;          /* be replaced by defines */
2960 +
2961 +       iop3xx_adap_init(iic_adap->algo_data);
2962 +       i2c_add_adapter(iic_adap);
2963 +       return 0;
2964 +}
2965 +
2966 +static int i2c_iop3xx_del_bus(struct i2c_adapter *iic_adap)
2967 +{
2968 +       struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
2969 +
2970 +       iop3xx_adap_final_cleanup(iop3xx_adap);
2971 +       free_irq(iop3xx_adap->biu->irq, iop3xx_adap);
2972 +
2973 +       release_region(REGION_START(iop3xx_adap), REGION_LENGTH(iop3xx_adap));
2974 +
2975 +       return i2c_del_adapter(iic_adap);
2976 +}
2977 +
2978 +#ifdef CONFIG_ARCH_IOP321
2979 +
2980 +static struct iop3xx_biu biu0 = {
2981 +       .CR     = IOP321_ICR0,
2982 +       .SR     = IOP321_ISR0,
2983 +       .SAR    = IOP321_ISAR0,
2984 +       .DBR    = IOP321_IDBR0,
2985 +       .BMR    = IOP321_IBMR0,
2986 +       .irq    = IRQ_IOP321_I2C_0,
2987 +};
2988 +
2989 +static struct iop3xx_biu biu1 = {
2990 +       .CR     = IOP321_ICR1,
2991 +       .SR     = IOP321_ISR1,
2992 +       .SAR    = IOP321_ISAR1,
2993 +       .DBR    = IOP321_IDBR1,
2994 +       .BMR    = IOP321_IBMR1,
2995 +       .irq    = IRQ_IOP321_I2C_1,
2996 +};
2997 +
2998 +#define ADAPTER_NAME_ROOT "IOP321 i2c biu adapter "
2999 +#else
3000 +#error Please define the BIU struct iop3xx_biu for your processor arch
3001 +#endif
3002 +
3003 +static struct i2c_algo_iop3xx_data algo_iop3xx_data0 = {
3004 +       .channel                = 0,
3005 +       .biu                    = &biu0,
3006 +       .timeout                = 1*HZ,
3007 +};
3008 +static struct i2c_algo_iop3xx_data algo_iop3xx_data1 = {
3009 +       .channel                = 1,
3010 +       .biu                    = &biu1,
3011 +       .timeout                = 1*HZ,
3012 +};
3013 +
3014 +static struct i2c_adapter iop3xx_ops0 = {
3015 +       .owner                  = THIS_MODULE,
3016 +       .name                   = ADAPTER_NAME_ROOT "0",
3017 +       .id                     = I2C_HW_IOP321,
3018 +       .algo_data              = &algo_iop3xx_data0,
3019 +};
3020 +static struct i2c_adapter iop3xx_ops1 = {
3021 +       .owner                  = THIS_MODULE,
3022 +       .name                   = ADAPTER_NAME_ROOT "1",
3023 +       .id                     = I2C_HW_IOP321,
3024 +       .algo_data              = &algo_iop3xx_data1,
3025 +};
3026 +
3027 +static int __init i2c_iop3xx_init (void)
3028 +{
3029 +       return i2c_iop3xx_add_bus(&iop3xx_ops0) ||
3030 +               i2c_iop3xx_add_bus(&iop3xx_ops1);
3031 +}
3032 +
3033 +static void __exit i2c_iop3xx_exit (void)
3034 +{
3035 +       i2c_iop3xx_del_bus(&iop3xx_ops0);
3036 +       i2c_iop3xx_del_bus(&iop3xx_ops1);
3037 +}
3038 +
3039 +module_init (i2c_iop3xx_init);
3040 +module_exit (i2c_iop3xx_exit);
3041 +
3042 +MODULE_AUTHOR("D-TACQ Solutions Ltd <www.d-tacq.com>");
3043 +MODULE_DESCRIPTION("IOP3xx iic algorithm and driver");
3044 +MODULE_LICENSE("GPL");
3045 +
3046 +MODULE_PARM(i2c_debug,"i");
3047 +
3048 +MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
3049 +
3050 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-iop3xx.h i2c-2.5/drivers/i2c/busses/i2c-iop3xx.h
3051 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-iop3xx.h   Thu Jan  1 00:00:00 1970
3052 +++ i2c-2.5/drivers/i2c/busses/i2c-iop3xx.h     Tue Sep 23 10:12:59 2003
3053 @@ -0,0 +1,118 @@
3054 +/* ------------------------------------------------------------------------- */
3055 +/* i2c-iop3xx.h algorithm driver definitions private to i2c-iop3xx.c         */
3056 +/* ------------------------------------------------------------------------- */
3057 +/*   Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd
3058 + *                      <Peter dot Milne at D hyphen TACQ dot com>
3059 +
3060 +    This program is free software; you can redistribute it and/or modify
3061 +    it under the terms of the GNU General Public License as published by
3062 +    the Free Software Foundation, version 2.
3063 +
3064 +    This program is distributed in the hope that it will be useful,
3065 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
3066 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3067 +    GNU General Public License for more details.
3068 +
3069 +    You should have received a copy of the GNU General Public License
3070 +    along with this program; if not, write to the Free Software
3071 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
3072 +/* ------------------------------------------------------------------------- */
3073 +
3074 +
3075 +#ifndef I2C_IOP3XX_H
3076 +#define I2C_IOP3XX_H 1
3077 +
3078 +/*
3079 + * iop321 hardware bit definitions
3080 + */
3081 +#define IOP321_ICR_FAST_MODE   0x8000  /* 1=400kBps, 0=100kBps */
3082 +#define IOP321_ICR_UNIT_RESET  0x4000  /* 1=RESET */
3083 +#define IOP321_ICR_SADIE       0x2000  /* 1=Slave Detect Interrupt Enable */
3084 +#define IOP321_ICR_ALDIE       0x1000  /* 1=Arb Loss Detect Interrupt Enable */
3085 +#define IOP321_ICR_SSDIE       0x0800  /* 1=Slave STOP Detect Interrupt Enable */
3086 +#define IOP321_ICR_BERRIE      0x0400  /* 1=Bus Error Interrupt Enable */
3087 +#define IOP321_ICR_RXFULLIE    0x0200  /* 1=Receive Full Interrupt Enable */
3088 +#define IOP321_ICR_TXEMPTYIE   0x0100  /* 1=Transmit Empty Interrupt Enable */
3089 +#define IOP321_ICR_GCD         0x0080  /* 1=General Call Disable */
3090 +/*
3091 + * IOP321_ICR_GCD: 1 disables response as slave. "This bit must be set
3092 + * when sending a master mode general call message from the I2C unit"
3093 + */
3094 +#define IOP321_ICR_UE          0x0040  /* 1=Unit Enable */
3095 +/*
3096 + * "NOTE: To avoid I2C bus integrity problems, 
3097 + * the user needs to ensure that the GPIO Output Data Register - 
3098 + * GPOD bits associated with an I2C port are cleared prior to setting 
3099 + * the enable bit for that I2C serial port. 
3100 + * The user prepares to enable I2C port 0 and 
3101 + * I2C port 1 by clearing GPOD bits 7:6 and GPOD bits 5:4, respectively.
3102 + */
3103 +#define IOP321_ICR_SCLEN       0x0020  /* 1=SCL enable for master mode */
3104 +#define IOP321_ICR_MABORT      0x0010  /* 1=Send a STOP with no data 
3105 +                                        * NB TBYTE must be clear */
3106 +#define IOP321_ICR_TBYTE       0x0008  /* 1=Send/Receive a byte. i2c clears */
3107 +#define IOP321_ICR_NACK                0x0004  /* 1=reply with NACK */
3108 +#define IOP321_ICR_MSTOP       0x0002  /* 1=send a STOP after next data byte */
3109 +#define IOP321_ICR_MSTART      0x0001  /* 1=initiate a START */
3110 +
3111 +
3112 +#define IOP321_ISR_BERRD       0x0400  /* 1=BUS ERROR Detected */
3113 +#define IOP321_ISR_SAD         0x0200  /* 1=Slave ADdress Detected */
3114 +#define IOP321_ISR_GCAD                0x0100  /* 1=General Call Address Detected */
3115 +#define IOP321_ISR_RXFULL      0x0080  /* 1=Receive Full */
3116 +#define IOP321_ISR_TXEMPTY     0x0040  /* 1=Transmit Empty */
3117 +#define IOP321_ISR_ALD         0x0020  /* 1=Arbitration Loss Detected */
3118 +#define IOP321_ISR_SSD         0x0010  /* 1=Slave STOP Detected */
3119 +#define IOP321_ISR_BBUSY       0x0008  /* 1=Bus BUSY */
3120 +#define IOP321_ISR_UNITBUSY    0x0004  /* 1=Unit Busy */
3121 +#define IOP321_ISR_NACK                0x0002  /* 1=Unit Rx or Tx a NACK */
3122 +#define IOP321_ISR_RXREAD      0x0001  /* 1=READ 0=WRITE (R/W bit of slave addr */
3123 +
3124 +#define IOP321_ISR_CLEARBITS   0x07f0
3125 +
3126 +#define IOP321_ISAR_SAMASK     0x007f
3127 +
3128 +#define IOP321_IDBR_MASK       0x00ff
3129 +
3130 +#define IOP321_IBMR_SCL                0x0002
3131 +#define IOP321_IBMR_SDA                0x0001
3132 +
3133 +#define IOP321_GPOD_I2C0       0x00c0  /* clear these bits to enable ch0 */
3134 +#define IOP321_GPOD_I2C1       0x0030  /* clear these bits to enable ch1 */
3135 +
3136 +#define MYSAR                  0x02    /* SWAG a suitable slave address */
3137 +
3138 +#define I2C_ERR                        321
3139 +#define I2C_ERR_BERR           (I2C_ERR+0)
3140 +#define I2C_ERR_ALD            (I2C_ERR+1)
3141 +
3142 +
3143 +struct iop3xx_biu {                /* Bus Interface Unit - the hardware */
3144 +/* physical hardware defs - regs*/
3145 +       u32 *CR;
3146 +       u32 *SR;
3147 +       u32 *SAR;
3148 +       u32 *DBR;
3149 +       u32 *BMR;
3150 +/* irq bit vector */
3151 +       u32 irq;
3152 +/* stored flags */
3153 +       u32 SR_enabled, SR_received;
3154 +};
3155 +
3156 +struct i2c_algo_iop3xx_data {
3157 +       int channel;
3158 +
3159 +       wait_queue_head_t waitq;
3160 +       spinlock_t lock;
3161 +       int timeout;
3162 +       struct iop3xx_biu* biu;
3163 +};
3164 +
3165 +#define REGION_START(adap)     ((u32)((adap)->biu->CR))
3166 +#define REGION_END(adap)       ((u32)((adap)->biu->BMR+1))
3167 +#define REGION_LENGTH(adap)    (REGION_END(adap)-REGION_START(adap))
3168 +
3169 +#define IRQ_STATUS_MASK(adap)  (1<<adap->biu->irq)
3170 +
3171 +#endif /* I2C_IOP3XX_H */
3172 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-isa.c i2c-2.5/drivers/i2c/busses/i2c-isa.c
3173 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-isa.c      Mon Sep  8 19:50:07 2003
3174 +++ i2c-2.5/drivers/i2c/busses/i2c-isa.c        Tue Sep 23 10:12:59 2003
3175 @@ -30,21 +30,29 @@
3176  #include <linux/errno.h>
3177  #include <linux/i2c.h>
3178  
3179 +static u32 isa_func(struct i2c_adapter *adapter);
3180 +
3181  /* This is the actual algorithm we define */
3182  static struct i2c_algorithm isa_algorithm = {
3183         .name           = "ISA bus algorithm",
3184         .id             = I2C_ALGO_ISA,
3185 +       .functionality  = isa_func,
3186  };
3187  
3188  /* There can only be one... */
3189  static struct i2c_adapter isa_adapter = {
3190         .owner          = THIS_MODULE,
3191 -       .id             = I2C_ALGO_ISA | I2C_HW_ISA,
3192         .class          = I2C_ADAP_CLASS_SMBUS,
3193         .algo           = &isa_algorithm,
3194         .name           = "ISA main adapter",
3195  };
3196  
3197 +/* We can't do a thing... */
3198 +static u32 isa_func(struct i2c_adapter *adapter)
3199 +{
3200 +       return 0;
3201 +}
3202 +
3203  static int __init i2c_isa_init(void)
3204  {
3205         return i2c_add_adapter(&isa_adapter);
3206 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-ite.c i2c-2.5/drivers/i2c/busses/i2c-ite.c
3207 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-ite.c      Thu Jan  1 00:00:00 1970
3208 +++ i2c-2.5/drivers/i2c/busses/i2c-ite.c        Tue Sep 23 10:12:59 2003
3209 @@ -0,0 +1,278 @@
3210 +/*
3211 +   -------------------------------------------------------------------------
3212 +   i2c-adap-ite.c i2c-hw access for the IIC peripheral on the ITE MIPS system
3213 +   -------------------------------------------------------------------------
3214 +   Hai-Pao Fan, MontaVista Software, Inc.
3215 +   hpfan@mvista.com or source@mvista.com
3216 +
3217 +   Copyright 2001 MontaVista Software Inc.
3218 +
3219 +   ----------------------------------------------------------------------------
3220 +   This file was highly leveraged from i2c-elektor.c, which was created
3221 +   by Simon G. Vogl and Hans Berglund:
3222 +
3223
3224 +     Copyright (C) 1995-97 Simon G. Vogl
3225 +                   1998-99 Hans Berglund
3226 +
3227 +    This program is free software; you can redistribute it and/or modify
3228 +    it under the terms of the GNU General Public License as published by
3229 +    the Free Software Foundation; either version 2 of the License, or
3230 +    (at your option) any later version.
3231 +
3232 +    This program is distributed in the hope that it will be useful,
3233 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
3234 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3235 +    GNU General Public License for more details.
3236 +
3237 +    You should have received a copy of the GNU General Public License
3238 +    along with this program; if not, write to the Free Software
3239 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
3240 +/* ------------------------------------------------------------------------- */
3241 +
3242 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
3243 +   Frodo Looijaard <frodol@dds.nl> */
3244 +
3245 +#include <linux/kernel.h>
3246 +#include <linux/ioport.h>
3247 +#include <linux/module.h>
3248 +#include <linux/delay.h>
3249 +#include <linux/slab.h>
3250 +#include <linux/init.h>
3251 +#include <asm/irq.h>
3252 +#include <asm/io.h>
3253 +
3254 +#include <linux/i2c.h>
3255 +#include <linux/i2c-algo-ite.h>
3256 +#include <linux/i2c-adap-ite.h>
3257 +#include "../i2c-ite.h"
3258 +
3259 +#define DEFAULT_BASE  0x14014030
3260 +#define ITE_IIC_IO_SIZE        0x40
3261 +#define DEFAULT_IRQ   0
3262 +#define DEFAULT_CLOCK 0x1b0e   /* default 16MHz/(27+14) = 400KHz */
3263 +#define DEFAULT_OWN   0x55
3264 +
3265 +static int base  = 0;
3266 +static int irq   = 0;
3267 +static int clock = 0;
3268 +static int own   = 0;
3269 +
3270 +static int i2c_debug=0;
3271 +static struct iic_ite gpi;
3272 +static wait_queue_head_t iic_wait;
3273 +static int iic_pending;
3274 +
3275 +/* ----- global defines -----------------------------------------------        */
3276 +#define DEB(x) if (i2c_debug>=1) x
3277 +#define DEB2(x) if (i2c_debug>=2) x
3278 +#define DEB3(x) if (i2c_debug>=3) x
3279 +#define DEBE(x)        x       /* error messages                               */
3280 +
3281 +
3282 +/* ----- local functions ----------------------------------------------        */
3283 +
3284 +static void iic_ite_setiic(void *data, int ctl, short val)
3285 +{
3286 +        unsigned long j = jiffies + 10;
3287 +
3288 +       DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
3289 +       DEB3({while (time_before(jiffies, j)) schedule();})
3290 +       outw(val,ctl);
3291 +}
3292 +
3293 +static short iic_ite_getiic(void *data, int ctl)
3294 +{
3295 +       short val;
3296 +
3297 +       val = inw(ctl);
3298 +       DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));  
3299 +       return (val);
3300 +}
3301 +
3302 +/* Return our slave address.  This is the address
3303 + * put on the I2C bus when another master on the bus wants to address us
3304 + * as a slave
3305 + */
3306 +static int iic_ite_getown(void *data)
3307 +{
3308 +       return (gpi.iic_own);
3309 +}
3310 +
3311 +
3312 +static int iic_ite_getclock(void *data)
3313 +{
3314 +       return (gpi.iic_clock);
3315 +}
3316 +
3317 +
3318 +#if 0
3319 +static void iic_ite_sleep(unsigned long timeout)
3320 +{
3321 +       schedule_timeout( timeout * HZ);
3322 +}
3323 +#endif
3324 +
3325 +
3326 +/* Put this process to sleep.  We will wake up when the
3327 + * IIC controller interrupts.
3328 + */
3329 +static void iic_ite_waitforpin(void) {
3330 +
3331 +   int timeout = 2;
3332 +
3333 +   /* If interrupts are enabled (which they are), then put the process to
3334 +    * sleep.  This process will be awakened by two events -- either the
3335 +    * the IIC peripheral interrupts or the timeout expires. 
3336 +    * If interrupts are not enabled then delay for a reasonable amount 
3337 +    * of time and return.
3338 +    */
3339 +   if (gpi.iic_irq > 0) {
3340 +       cli();
3341 +       if (iic_pending == 0) {
3342 +               interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
3343 +       } else
3344 +               iic_pending = 0;
3345 +       sti();
3346 +   } else {
3347 +      udelay(100);
3348 +   }
3349 +}
3350 +
3351 +
3352 +static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs) 
3353 +{
3354 +       
3355 +   iic_pending = 1;
3356 +
3357 +   DEB2(printk("iic_ite_handler: in interrupt handler\n"));
3358 +   wake_up_interruptible(&iic_wait);
3359 +}
3360 +
3361 +
3362 +/* Lock the region of memory where I/O registers exist.  Request our
3363 + * interrupt line and register its associated handler.
3364 + */
3365 +static int iic_hw_resrc_init(void)
3366 +{
3367 +       if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c"))
3368 +               return -ENODEV;
3369 +  
3370 +       if (gpi.iic_irq <= 0)
3371 +               return 0;
3372 +
3373 +       if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0)
3374 +               gpi.iic_irq = 0;
3375 +       else
3376 +               enable_irq(gpi.iic_irq);
3377 +
3378 +       return 0;
3379 +}
3380 +
3381 +
3382 +static void iic_ite_release(void)
3383 +{
3384 +       if (gpi.iic_irq > 0) {
3385 +               disable_irq(gpi.iic_irq);
3386 +               free_irq(gpi.iic_irq, 0);
3387 +       }
3388 +       release_region(gpi.iic_base , 2);
3389 +}
3390 +
3391 +/* ------------------------------------------------------------------------
3392 + * Encapsulate the above functions in the correct operations structure.
3393 + * This is only done when more than one hardware adapter is supported.
3394 + */
3395 +static struct i2c_algo_iic_data iic_ite_data = {
3396 +       NULL,
3397 +       iic_ite_setiic,
3398 +       iic_ite_getiic,
3399 +       iic_ite_getown,
3400 +       iic_ite_getclock,
3401 +       iic_ite_waitforpin,
3402 +       80, 80, 100,            /*      waits, timeout */
3403 +};
3404 +
3405 +static struct i2c_adapter iic_ite_ops = {
3406 +       .owner          = THIS_MODULE,
3407 +       .id             = I2C_HW_I_IIC,
3408 +       .algo_data      = &iic_ite_data,
3409 +       .dev            = {
3410 +               .name   = "ITE IIC adapter",
3411 +       },
3412 +};
3413 +
3414 +/* Called when the module is loaded.  This function starts the
3415 + * cascade of calls up through the hierarchy of i2c modules (i.e. up to the
3416 + *  algorithm layer and into to the core layer)
3417 + */
3418 +static int __init iic_ite_init(void) 
3419 +{
3420 +
3421 +       struct iic_ite *piic = &gpi;
3422 +
3423 +       printk(KERN_INFO "Initialize ITE IIC adapter module\n");
3424 +       if (base == 0)
3425 +               piic->iic_base = DEFAULT_BASE;
3426 +       else
3427 +               piic->iic_base = base;
3428 +
3429 +       if (irq == 0)
3430 +               piic->iic_irq = DEFAULT_IRQ;
3431 +       else
3432 +               piic->iic_irq = irq;
3433 +
3434 +       if (clock == 0)
3435 +               piic->iic_clock = DEFAULT_CLOCK;
3436 +       else
3437 +               piic->iic_clock = clock;
3438 +
3439 +       if (own == 0)
3440 +               piic->iic_own = DEFAULT_OWN;
3441 +       else
3442 +               piic->iic_own = own;
3443 +
3444 +       iic_ite_data.data = (void *)piic;
3445 +       init_waitqueue_head(&iic_wait);
3446 +       if (iic_hw_resrc_init() == 0) {
3447 +               if (i2c_iic_add_bus(&iic_ite_ops) < 0)
3448 +                       return -ENODEV;
3449 +       } else {
3450 +               return -ENODEV;
3451 +       }
3452 +       printk(KERN_INFO " found device at %#x irq %d.\n", 
3453 +               piic->iic_base, piic->iic_irq);
3454 +       return 0;
3455 +}
3456 +
3457 +
3458 +static void iic_ite_exit(void)
3459 +{
3460 +       i2c_iic_del_bus(&iic_ite_ops);
3461 +        iic_ite_release();
3462 +}
3463 +
3464 +/* If modules is NOT defined when this file is compiled, then the MODULE_*
3465 + * macros will resolve to nothing
3466 + */
3467 +MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
3468 +MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
3469 +MODULE_LICENSE("GPL");
3470 +
3471 +MODULE_PARM(base, "i");
3472 +MODULE_PARM(irq, "i");
3473 +MODULE_PARM(clock, "i");
3474 +MODULE_PARM(own, "i");
3475 +MODULE_PARM(i2c_debug,"i");
3476 +
3477 +
3478 +/* Called when module is loaded or when kernel is initialized.
3479 + * If MODULES is defined when this file is compiled, then this function will
3480 + * resolve to init_module (the function called when insmod is invoked for a
3481 + * module).  Otherwise, this function is called early in the boot, when the
3482 + * kernel is intialized.  Check out /include/init.h to see how this works.
3483 + */
3484 +module_init(iic_ite_init);
3485 +
3486 +/* Resolves to module_cleanup when MODULES is defined. */
3487 +module_exit(iic_ite_exit); 
3488 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-keywest.c i2c-2.5/drivers/i2c/busses/i2c-keywest.c
3489 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-keywest.c  Thu Jan  1 00:00:00 1970
3490 +++ i2c-2.5/drivers/i2c/busses/i2c-keywest.c    Tue Sep 23 10:12:59 2003
3491 @@ -0,0 +1,653 @@
3492 +/*
3493 +    i2c Support for Apple Keywest I2C Bus Controller
3494 +
3495 +    Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
3496 +
3497 +    Original work by
3498 +    
3499 +    Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
3500 +
3501 +    This program is free software; you can redistribute it and/or modify
3502 +    it under the terms of the GNU General Public License as published by
3503 +    the Free Software Foundation; either version 2 of the License, or
3504 +    (at your option) any later version.
3505 +
3506 +    This program is distributed in the hope that it will be useful,
3507 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
3508 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3509 +    GNU General Public License for more details.
3510 +
3511 +    You should have received a copy of the GNU General Public License
3512 +    along with this program; if not, write to the Free Software
3513 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3514 +
3515 +    Changes:
3516 +
3517 +    2001/12/13 BenH    New implementation
3518 +    2001/12/15 BenH    Add support for "byte" and "quick"
3519 +                        transfers. Add i2c_xfer routine.
3520 +
3521 +    My understanding of the various modes supported by keywest are:
3522 +
3523 +     - Dumb mode : not implemented, probably direct tweaking of lines
3524 +     - Standard mode : simple i2c transaction of type
3525 +         S Addr R/W A Data A Data ... T
3526 +     - Standard sub mode : combined 8 bit subaddr write with data read
3527 +         S Addr R/W A SubAddr A Data A Data ... T
3528 +     - Combined mode : Subaddress and Data sequences appended with no stop
3529 +         S Addr R/W A SubAddr S Addr R/W A Data A Data ... T
3530 +
3531 +    Currently, this driver uses only Standard mode for i2c xfer, and
3532 +    smbus byte & quick transfers ; and uses StandardSub mode for
3533 +    other smbus transfers instead of combined as we need that for the
3534 +    sound driver to be happy
3535 +*/
3536 +
3537 +#include <linux/module.h>
3538 +#include <linux/config.h>
3539 +#include <linux/kernel.h>
3540 +#include <linux/ioport.h>
3541 +#include <linux/pci.h>
3542 +#include <linux/types.h>
3543 +#include <linux/delay.h>
3544 +#include <linux/i2c.h>
3545 +#include <linux/init.h>
3546 +#include <linux/mm.h>
3547 +#include <linux/timer.h>
3548 +#include <linux/spinlock.h>
3549 +#include <linux/completion.h>
3550 +#include <linux/interrupt.h>
3551 +
3552 +#include <asm/io.h>
3553 +#include <asm/prom.h>
3554 +#include <asm/machdep.h>
3555 +#include <asm/pmac_feature.h>
3556 +
3557 +#include "i2c-keywest.h"
3558 +
3559 +#define DBG(x...) do {\
3560 +       if (debug > 0) \
3561 +               printk(KERN_DEBUG "KW:" x); \
3562 +       } while(0)
3563 +
3564 +
3565 +MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
3566 +MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
3567 +MODULE_LICENSE("GPL");
3568 +MODULE_PARM(probe, "i");
3569 +MODULE_PARM(debug, "i");
3570 +
3571 +int probe = 0;
3572 +int debug = 0;
3573 +
3574 +static void
3575 +do_stop(struct keywest_iface* iface, int result)
3576 +{
3577 +       write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_STOP);
3578 +       iface->state = state_stop;
3579 +       iface->result = result;
3580 +}
3581 +
3582 +/* Main state machine for standard & standard sub mode */
3583 +static int
3584 +handle_interrupt(struct keywest_iface *iface, u8 isr)
3585 +{
3586 +       int ack;
3587 +       int rearm_timer = 1;
3588 +       
3589 +       DBG("handle_interrupt(), got: %x, status: %x, state: %d\n",
3590 +               isr, read_reg(reg_status), iface->state);
3591 +       if (isr == 0 && iface->state != state_stop) {
3592 +               do_stop(iface, -1);
3593 +               return rearm_timer;
3594 +       }
3595 +       if (isr & KW_I2C_IRQ_STOP && iface->state != state_stop) {
3596 +               iface->result = -1;
3597 +               iface->state = state_stop;
3598 +       }
3599 +       switch(iface->state) {
3600 +       case state_addr:
3601 +               if (!(isr & KW_I2C_IRQ_ADDR)) {
3602 +                       do_stop(iface, -1);
3603 +                       break;
3604 +               }
3605 +               ack = read_reg(reg_status);
3606 +               DBG("ack on set address: %x\n", ack);
3607 +               if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
3608 +                       do_stop(iface, -1);
3609 +                       break;
3610 +               }
3611 +               /* Handle rw "quick" mode */
3612 +               if (iface->datalen == 0)
3613 +                       do_stop(iface, 0);
3614 +               else if (iface->read_write == I2C_SMBUS_READ) {
3615 +                       iface->state = state_read;
3616 +                       if (iface->datalen > 1)
3617 +                               write_reg(reg_control, read_reg(reg_control)
3618 +                                       | KW_I2C_CTL_AAK);
3619 +               } else {
3620 +                       iface->state = state_write;
3621 +                       DBG("write byte: %x\n", *(iface->data));
3622 +                       write_reg(reg_data, *(iface->data++));
3623 +                       iface->datalen--;
3624 +               }
3625 +               
3626 +               break;
3627 +       case state_read:
3628 +               if (!(isr & KW_I2C_IRQ_DATA)) {
3629 +                       do_stop(iface, -1);
3630 +                       break;
3631 +               }
3632 +               *(iface->data++) = read_reg(reg_data);
3633 +               DBG("read byte: %x\n", *(iface->data-1));
3634 +               iface->datalen--;
3635 +               if (iface->datalen == 0)
3636 +                       iface->state = state_stop;
3637 +               else
3638 +                       write_reg(reg_control, 0);
3639 +               break;
3640 +       case state_write:
3641 +               if (!(isr & KW_I2C_IRQ_DATA)) {
3642 +                       do_stop(iface, -1);
3643 +                       break;
3644 +               }
3645 +               /* Check ack status */
3646 +               ack = read_reg(reg_status);
3647 +               DBG("ack on data write: %x\n", ack);
3648 +               if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
3649 +                       do_stop(iface, -1);
3650 +                       break;
3651 +               }
3652 +               if (iface->datalen) {
3653 +                       DBG("write byte: %x\n", *(iface->data));
3654 +                       write_reg(reg_data, *(iface->data++));
3655 +                       iface->datalen--;
3656 +               } else
3657 +                       do_stop(iface, 0);
3658 +               break;
3659 +               
3660 +       case state_stop:
3661 +               if (!(isr & KW_I2C_IRQ_STOP) && (++iface->stopretry) < 10)
3662 +                       do_stop(iface, -1);
3663 +               else {
3664 +                       rearm_timer = 0;
3665 +                       iface->state = state_idle;
3666 +                       write_reg(reg_control, 0x00);
3667 +                       write_reg(reg_ier, 0x00);
3668 +                       complete(&iface->complete);
3669 +               }
3670 +               break;
3671 +       }
3672 +       
3673 +       write_reg(reg_isr, isr);
3674 +
3675 +       return rearm_timer;
3676 +}
3677 +
3678 +/* Interrupt handler */
3679 +static irqreturn_t
3680 +keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
3681 +{
3682 +       struct keywest_iface *iface = (struct keywest_iface *)dev_id;
3683 +
3684 +       spin_lock(&iface->lock);
3685 +       del_timer(&iface->timeout_timer);
3686 +       if (handle_interrupt(iface, read_reg(reg_isr)))
3687 +               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
3688 +       spin_unlock(&iface->lock);
3689 +       return IRQ_HANDLED;
3690 +}
3691 +
3692 +static void
3693 +keywest_timeout(unsigned long data)
3694 +{
3695 +       struct keywest_iface *iface = (struct keywest_iface *)data;
3696 +
3697 +       DBG("timeout !\n");
3698 +       spin_lock_irq(&iface->lock);
3699 +       if (handle_interrupt(iface, read_reg(reg_isr)))
3700 +               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
3701 +       spin_unlock(&iface->lock);
3702 +}
3703 +
3704 +/*
3705 + * SMBUS-type transfer entrypoint
3706 + */
3707 +static s32
3708 +keywest_smbus_xfer(    struct i2c_adapter*     adap,
3709 +                       u16                     addr,
3710 +                       unsigned short          flags,
3711 +                       char                    read_write,
3712 +                       u8                      command,
3713 +                       int                     size,
3714 +                       union i2c_smbus_data*   data)
3715 +{
3716 +       struct keywest_chan* chan = i2c_get_adapdata(adap);
3717 +       struct keywest_iface* iface = chan->iface;
3718 +       int len;
3719 +       u8* buffer;
3720 +       u16 cur_word;
3721 +       int rc = 0;
3722 +
3723 +       if (iface->state == state_dead)
3724 +               return -1;
3725 +               
3726 +       /* Prepare datas & select mode */
3727 +       iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
3728 +       switch (size) {
3729 +           case I2C_SMBUS_QUICK:
3730 +               len = 0;
3731 +               buffer = NULL;
3732 +               iface->cur_mode |= KW_I2C_MODE_STANDARD;
3733 +               break;
3734 +           case I2C_SMBUS_BYTE:
3735 +               len = 1;
3736 +               buffer = &data->byte;
3737 +               iface->cur_mode |= KW_I2C_MODE_STANDARD;
3738 +               break;
3739 +           case I2C_SMBUS_BYTE_DATA:
3740 +               len = 1;
3741 +               buffer = &data->byte;
3742 +               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3743 +               break;
3744 +           case I2C_SMBUS_WORD_DATA:
3745 +               len = 2;
3746 +               cur_word = cpu_to_le16(data->word);
3747 +               buffer = (u8 *)&cur_word;
3748 +               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3749 +               break;
3750 +           case I2C_SMBUS_BLOCK_DATA:
3751 +               len = data->block[0];
3752 +               buffer = &data->block[1];
3753 +               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3754 +               break;
3755 +           default:
3756 +               return -1;
3757 +       }
3758 +
3759 +       /* Original driver had this limitation */
3760 +       if (len > 32)
3761 +               len = 32;
3762 +
3763 +       down(&iface->sem);
3764 +
3765 +       DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
3766 +               chan->chan_no, addr, len, read_write == I2C_SMBUS_READ);
3767 +
3768 +       iface->data = buffer;
3769 +       iface->datalen = len;
3770 +       iface->state = state_addr;
3771 +       iface->result = 0;
3772 +       iface->stopretry = 0;
3773 +       iface->read_write = read_write;
3774 +       
3775 +       /* Setup channel & clear pending irqs */
3776 +       write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4));
3777 +       write_reg(reg_isr, read_reg(reg_isr));
3778 +       write_reg(reg_status, 0);
3779 +
3780 +       /* Set up address and r/w bit */
3781 +       write_reg(reg_addr,
3782 +               (addr << 1) | ((read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
3783 +
3784 +       /* Set up the sub address */
3785 +       if ((iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_STANDARDSUB
3786 +           || (iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_COMBINED)
3787 +               write_reg(reg_subaddr, command);
3788 +
3789 +       /* Arm timeout */
3790 +       mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
3791 +
3792 +       /* Start sending address & enable interrupt*/
3793 +       write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
3794 +       write_reg(reg_ier, KW_I2C_IRQ_MASK);
3795 +
3796 +       /* Wait interrupt operations completion */
3797 +       wait_for_completion(&iface->complete);  
3798 +
3799 +       rc = iface->result;     
3800 +       DBG("transfer done, result: %d\n", rc);
3801 +
3802 +       if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ)
3803 +               data->word = le16_to_cpu(cur_word);
3804 +       
3805 +       /* Release sem */
3806 +       up(&iface->sem);
3807 +       
3808 +       return rc;
3809 +}
3810 +
3811 +/*
3812 + * Generic i2c master transfer entrypoint
3813 + */
3814 +static int
3815 +keywest_xfer(  struct i2c_adapter *adap,
3816 +               struct i2c_msg msgs[], 
3817 +               int num)
3818 +{
3819 +       struct keywest_chan* chan = i2c_get_adapdata(adap);
3820 +       struct keywest_iface* iface = chan->iface;
3821 +       struct i2c_msg *pmsg;
3822 +       int i, completed;
3823 +       int rc = 0;
3824 +
3825 +       down(&iface->sem);
3826 +
3827 +       /* Set adapter to standard mode */
3828 +       iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
3829 +       iface->cur_mode |= KW_I2C_MODE_STANDARD;
3830 +
3831 +       completed = 0;
3832 +       for (i = 0; rc >= 0 && i < num;) {
3833 +               u8 addr;
3834 +               
3835 +               pmsg = &msgs[i++];
3836 +               addr = pmsg->addr;
3837 +               if (pmsg->flags & I2C_M_TEN) {
3838 +                       printk(KERN_ERR "i2c-keywest: 10 bits addr not supported !\n");
3839 +                       rc = -EINVAL;
3840 +                       break;
3841 +               }
3842 +               DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
3843 +                    chan->chan_no,
3844 +                    pmsg->flags & I2C_M_RD ? "read" : "write",
3845 +                     pmsg->len, addr, i, num);
3846 +    
3847 +               /* Setup channel & clear pending irqs */
3848 +               write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4));
3849 +               write_reg(reg_isr, read_reg(reg_isr));
3850 +               write_reg(reg_status, 0);
3851 +               
3852 +               iface->data = pmsg->buf;
3853 +               iface->datalen = pmsg->len;
3854 +               iface->state = state_addr;
3855 +               iface->result = 0;
3856 +               iface->stopretry = 0;
3857 +               if (pmsg->flags & I2C_M_RD)
3858 +                       iface->read_write = I2C_SMBUS_READ;
3859 +               else
3860 +                       iface->read_write = I2C_SMBUS_WRITE;
3861 +
3862 +               /* Set up address and r/w bit */
3863 +               if (pmsg->flags & I2C_M_REV_DIR_ADDR)
3864 +                       addr ^= 1;              
3865 +               write_reg(reg_addr,
3866 +                       (addr << 1) |
3867 +                       ((iface->read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
3868 +
3869 +               /* Arm timeout */
3870 +               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
3871 +
3872 +               /* Start sending address & enable interrupt*/
3873 +               write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
3874 +               write_reg(reg_ier, KW_I2C_IRQ_MASK);
3875 +
3876 +               /* Wait interrupt operations completion */
3877 +               wait_for_completion(&iface->complete);  
3878 +
3879 +               rc = iface->result;
3880 +               if (rc == 0)
3881 +                       completed++;
3882 +               DBG("transfer done, result: %d\n", rc);
3883 +       }
3884 +
3885 +       /* Release sem */
3886 +       up(&iface->sem);
3887 +
3888 +       return completed;
3889 +}
3890 +
3891 +static u32
3892 +keywest_func(struct i2c_adapter * adapter)
3893 +{
3894 +       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
3895 +              I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
3896 +              I2C_FUNC_SMBUS_BLOCK_DATA;
3897 +}
3898 +
3899 +/* For now, we only handle combined mode (smbus) */
3900 +static struct i2c_algorithm keywest_algorithm = {
3901 +       .name           = "Keywest i2c",
3902 +       .id             = I2C_ALGO_SMBUS,
3903 +       .smbus_xfer     = keywest_smbus_xfer,
3904 +       .master_xfer    = keywest_xfer,
3905 +       .functionality  = keywest_func,
3906 +};
3907 +
3908 +
3909 +static int
3910 +create_iface(struct device_node *np, struct device *dev)
3911 +{
3912 +       unsigned long steps, *psteps, *prate;
3913 +       unsigned bsteps, tsize, i, nchan, addroffset;
3914 +       struct keywest_iface* iface;
3915 +       int rc;
3916 +
3917 +       psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
3918 +       steps = psteps ? (*psteps) : 0x10;
3919 +
3920 +       /* Hrm... maybe we can be smarter here */
3921 +       for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
3922 +               steps >>= 1;
3923 +
3924 +       if (!strcmp(np->parent->name, "uni-n")) {
3925 +               nchan = 2;
3926 +               addroffset = 3;
3927 +       } else {
3928 +               addroffset = 0;
3929 +               nchan = 1;
3930 +       }
3931 +
3932 +       tsize = sizeof(struct keywest_iface) +
3933 +               (sizeof(struct keywest_chan) + 4) * nchan;
3934 +       iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL);
3935 +       if (iface == NULL) {
3936 +               printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n");
3937 +               return -ENOMEM;
3938 +       }
3939 +       memset(iface, 0, tsize);
3940 +       init_MUTEX(&iface->sem);
3941 +       spin_lock_init(&iface->lock);
3942 +       init_completion(&iface->complete);
3943 +       iface->bsteps = bsteps;
3944 +       iface->chan_count = nchan;
3945 +       iface->state = state_idle;
3946 +       iface->irq = np->intrs[0].line;
3947 +       iface->channels = (struct keywest_chan *)
3948 +               (((unsigned long)(iface + 1) + 3UL) & ~3UL);
3949 +       iface->base = (unsigned long)ioremap(np->addrs[0].address + addroffset,
3950 +                                               np->addrs[0].size);
3951 +       if (iface->base == 0) {
3952 +               printk(KERN_ERR "i2c-keywest: can't map inteface !\n");
3953 +               kfree(iface);
3954 +               return -ENOMEM;
3955 +       }
3956 +
3957 +       init_timer(&iface->timeout_timer);
3958 +       iface->timeout_timer.function = keywest_timeout;
3959 +       iface->timeout_timer.data = (unsigned long)iface;
3960 +
3961 +       /* Select interface rate */
3962 +       iface->cur_mode = KW_I2C_MODE_100KHZ;
3963 +       prate = (unsigned long *)get_property(np, "AAPL,i2c-rate", NULL);
3964 +       if (prate) switch(*prate) {
3965 +       case 100:
3966 +               iface->cur_mode = KW_I2C_MODE_100KHZ;
3967 +               break;
3968 +       case 50:
3969 +               iface->cur_mode = KW_I2C_MODE_50KHZ;
3970 +               break;
3971 +       case 25:
3972 +               iface->cur_mode = KW_I2C_MODE_25KHZ;
3973 +               break;
3974 +       default:
3975 +               printk(KERN_WARNING "i2c-keywest: unknown rate %ldKhz, using 100KHz\n",
3976 +                       *prate);
3977 +       }
3978 +       
3979 +       /* Select standard sub mode */
3980 +       iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3981 +       
3982 +       /* Write mode */
3983 +       write_reg(reg_mode, iface->cur_mode);
3984 +       
3985 +       /* Switch interrupts off & clear them*/
3986 +       write_reg(reg_ier, 0x00);
3987 +       write_reg(reg_isr, KW_I2C_IRQ_MASK);
3988 +
3989 +       /* Request chip interrupt */    
3990 +       rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
3991 +       if (rc) {
3992 +               printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
3993 +               iounmap((void *)iface->base);
3994 +               kfree(iface);
3995 +               return -ENODEV;
3996 +       }
3997 +
3998 +       dev_set_drvdata(dev, iface);
3999 +       
4000 +       for (i=0; i<nchan; i++) {
4001 +               struct keywest_chan* chan = &iface->channels[i];
4002 +               u8 addr;
4003 +               
4004 +               sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
4005 +               chan->iface = iface;
4006 +               chan->chan_no = i;
4007 +               chan->adapter.id = I2C_ALGO_SMBUS;
4008 +               chan->adapter.algo = &keywest_algorithm;
4009 +               chan->adapter.algo_data = NULL;
4010 +               chan->adapter.client_register = NULL;
4011 +               chan->adapter.client_unregister = NULL;
4012 +               i2c_set_adapdata(&chan->adapter, chan);
4013 +               chan->adapter.dev.parent = dev;
4014 +
4015 +               rc = i2c_add_adapter(&chan->adapter);
4016 +               if (rc) {
4017 +                       printk("i2c-keywest.c: Adapter %s registration failed\n",
4018 +                               chan->adapter.name);
4019 +                       i2c_set_adapdata(&chan->adapter, NULL);
4020 +               }
4021 +               if (probe) {
4022 +                       printk("Probe: ");
4023 +                       for (addr = 0x00; addr <= 0x7f; addr++) {
4024 +                               if (i2c_smbus_xfer(&chan->adapter,addr,
4025 +                                   0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
4026 +                                       printk("%02x ", addr);
4027 +                       }
4028 +                       printk("\n");
4029 +               }
4030 +       }
4031 +
4032 +       printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
4033 +               np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps);
4034 +               
4035 +       return 0;
4036 +}
4037 +
4038 +static int
4039 +dispose_iface(struct device *dev)
4040 +{
4041 +       struct keywest_iface *iface = dev_get_drvdata(dev);
4042 +       int i, rc;
4043 +       
4044 +       /* Make sure we stop all activity */
4045 +       down(&iface->sem);
4046 +
4047 +       spin_lock_irq(&iface->lock);
4048 +       while (iface->state != state_idle) {
4049 +               spin_unlock_irq(&iface->lock);
4050 +               set_task_state(current,TASK_UNINTERRUPTIBLE);
4051 +               schedule_timeout(HZ/10);
4052 +               spin_lock_irq(&iface->lock);
4053 +       }
4054 +       iface->state = state_dead;
4055 +       spin_unlock_irq(&iface->lock);
4056 +       free_irq(iface->irq, iface);
4057 +       up(&iface->sem);
4058 +
4059 +       /* Release all channels */
4060 +       for (i=0; i<iface->chan_count; i++) {
4061 +               struct keywest_chan* chan = &iface->channels[i];
4062 +               if (i2c_get_adapdata(&chan->adapter) == NULL)
4063 +                       continue;
4064 +               rc = i2c_del_adapter(&chan->adapter);
4065 +               i2c_set_adapdata(&chan->adapter, NULL);
4066 +               /* We aren't that prepared to deal with this... */
4067 +               if (rc)
4068 +                       printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
4069 +       }
4070 +       iounmap((void *)iface->base);
4071 +       dev_set_drvdata(dev, NULL);
4072 +       kfree(iface);
4073 +
4074 +       return 0;
4075 +}
4076 +
4077 +static int
4078 +create_iface_macio(struct macio_dev* dev, const struct of_match *match)
4079 +{
4080 +       return create_iface(dev->ofdev.node, &dev->ofdev.dev);
4081 +}
4082 +
4083 +static int
4084 +dispose_iface_macio(struct macio_dev* dev)
4085 +{
4086 +       return dispose_iface(&dev->ofdev.dev);
4087 +}
4088 +
4089 +static int
4090 +create_iface_of_platform(struct of_device* dev, const struct of_match *match)
4091 +{
4092 +       return create_iface(dev->node, &dev->dev);
4093 +}
4094 +
4095 +static int
4096 +dispose_iface_of_platform(struct of_device* dev)
4097 +{
4098 +       return dispose_iface(&dev->dev);
4099 +}
4100 +
4101 +static struct of_match i2c_keywest_match[] = 
4102 +{
4103 +       {
4104 +       .name           = OF_ANY_MATCH,
4105 +       .type           = "i2c",
4106 +       .compatible     = "keywest"
4107 +       },
4108 +       {},
4109 +};
4110 +
4111 +static struct macio_driver i2c_keywest_macio_driver = 
4112 +{
4113 +       .name           = "i2c-keywest",
4114 +       .match_table    = i2c_keywest_match,
4115 +       .probe          = create_iface_macio,
4116 +       .remove         = dispose_iface_macio
4117 +};
4118 +
4119 +static struct of_platform_driver i2c_keywest_of_platform_driver = 
4120 +{
4121 +       .name           = "i2c-keywest",
4122 +       .match_table    = i2c_keywest_match,
4123 +       .probe          = create_iface_of_platform,
4124 +       .remove         = dispose_iface_of_platform
4125 +};
4126 +
4127 +static int __init
4128 +i2c_keywest_init(void)
4129 +{
4130 +       macio_register_driver(&i2c_keywest_macio_driver);
4131 +       of_register_driver(&i2c_keywest_of_platform_driver);
4132 +
4133 +       return 0;
4134 +}
4135 +
4136 +static void __exit
4137 +i2c_keywest_cleanup(void)
4138 +{
4139 +       macio_unregister_driver(&i2c_keywest_macio_driver);
4140 +       of_unregister_driver(&i2c_keywest_of_platform_driver);
4141 +}
4142 +
4143 +module_init(i2c_keywest_init);
4144 +module_exit(i2c_keywest_cleanup);
4145 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-keywest.h i2c-2.5/drivers/i2c/busses/i2c-keywest.h
4146 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-keywest.h  Thu Jan  1 00:00:00 1970
4147 +++ i2c-2.5/drivers/i2c/busses/i2c-keywest.h    Tue Sep 23 10:12:59 2003
4148 @@ -0,0 +1,110 @@
4149 +#ifndef __I2C_KEYWEST_H__
4150 +#define __I2C_KEYWEST_H__
4151 +
4152 +/* The Tumbler audio equalizer can be really slow sometimes */
4153 +#define POLL_TIMEOUT           (2*HZ)
4154 +
4155 +/* Register indices */
4156 +typedef enum {
4157 +       reg_mode = 0,
4158 +       reg_control,
4159 +       reg_status,
4160 +       reg_isr,
4161 +       reg_ier,
4162 +       reg_addr,
4163 +       reg_subaddr,
4164 +       reg_data
4165 +} reg_t;
4166 +
4167 +
4168 +/* Mode register */
4169 +#define KW_I2C_MODE_100KHZ     0x00
4170 +#define KW_I2C_MODE_50KHZ      0x01
4171 +#define KW_I2C_MODE_25KHZ      0x02
4172 +#define KW_I2C_MODE_DUMB       0x00
4173 +#define KW_I2C_MODE_STANDARD   0x04
4174 +#define KW_I2C_MODE_STANDARDSUB        0x08
4175 +#define KW_I2C_MODE_COMBINED   0x0C
4176 +#define KW_I2C_MODE_MODE_MASK  0x0C
4177 +#define KW_I2C_MODE_CHAN_MASK  0xF0
4178 +
4179 +/* Control register */
4180 +#define KW_I2C_CTL_AAK         0x01
4181 +#define KW_I2C_CTL_XADDR       0x02
4182 +#define KW_I2C_CTL_STOP                0x04
4183 +#define KW_I2C_CTL_START       0x08
4184 +
4185 +/* Status register */
4186 +#define KW_I2C_STAT_BUSY       0x01
4187 +#define KW_I2C_STAT_LAST_AAK   0x02
4188 +#define KW_I2C_STAT_LAST_RW    0x04
4189 +#define KW_I2C_STAT_SDA                0x08
4190 +#define KW_I2C_STAT_SCL                0x10
4191 +
4192 +/* IER & ISR registers */
4193 +#define KW_I2C_IRQ_DATA                0x01
4194 +#define KW_I2C_IRQ_ADDR                0x02
4195 +#define KW_I2C_IRQ_STOP                0x04
4196 +#define KW_I2C_IRQ_START       0x08
4197 +#define KW_I2C_IRQ_MASK                0x0F
4198 +
4199 +/* Physical interface */
4200 +struct keywest_iface
4201 +{
4202 +       unsigned long           base;
4203 +       unsigned                bsteps;
4204 +       int                     irq;
4205 +       struct semaphore        sem;
4206 +       spinlock_t              lock;
4207 +       struct keywest_chan*    channels;
4208 +       unsigned                chan_count;
4209 +       u8                      cur_mode;
4210 +       char                    read_write;
4211 +       u8*                     data;
4212 +       unsigned                datalen;
4213 +       int                     state;
4214 +       int                     result;
4215 +       int                     stopretry;
4216 +       struct timer_list       timeout_timer;
4217 +       struct completion       complete;
4218 +};
4219 +
4220 +enum {
4221 +       state_idle,
4222 +       state_addr,
4223 +       state_read,
4224 +       state_write,
4225 +       state_stop,
4226 +       state_dead
4227 +};
4228 +
4229 +/* Channel on an interface */
4230 +struct keywest_chan
4231 +{
4232 +       struct i2c_adapter      adapter;
4233 +       struct keywest_iface*   iface;
4234 +       unsigned                chan_no;
4235 +};
4236 +
4237 +/* Register access */
4238 +
4239 +static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
4240 +{
4241 +       return in_8(((volatile u8 *)iface->base)
4242 +               + (((unsigned)reg) << iface->bsteps));
4243 +}
4244 +
4245 +static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
4246 +{
4247 +       out_8(((volatile u8 *)iface->base)
4248 +               + (((unsigned)reg) << iface->bsteps), val);
4249 +       (void)__read_reg(iface, reg);
4250 +       udelay(10);
4251 +}
4252 +
4253 +#define write_reg(reg, val)    __write_reg(iface, reg, val) 
4254 +#define read_reg(reg)          __read_reg(iface, reg) 
4255 +
4256 +
4257 +
4258 +#endif /* __I2C_KEYWEST_H__ */
4259 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-nforce2.c i2c-2.5/drivers/i2c/busses/i2c-nforce2.c
4260 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-nforce2.c  Mon Sep  8 19:49:54 2003
4261 +++ i2c-2.5/drivers/i2c/busses/i2c-nforce2.c    Tue Sep 23 10:12:59 2003
4262 @@ -118,7 +118,6 @@
4263  
4264  static struct i2c_adapter nforce2_adapter = {
4265         .owner          = THIS_MODULE,
4266 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_NFORCE2,
4267         .class          = I2C_ADAP_CLASS_SMBUS,
4268         .algo           = &smbus_algorithm,
4269         .name           = "unset",
4270 @@ -321,7 +320,7 @@
4271         smbus->adapter = nforce2_adapter;
4272         smbus->adapter.algo_data = smbus;
4273         smbus->adapter.dev.parent = &dev->dev;
4274 -       snprintf(smbus->adapter.name, DEVICE_NAME_SIZE,
4275 +       snprintf(smbus->adapter.name, I2C_NAME_SIZE,
4276                 "SMBus nForce2 adapter at %04x", smbus->base);
4277  
4278         error = i2c_add_adapter(&smbus->adapter);
4279 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-philips-par.c i2c-2.5/drivers/i2c/busses/i2c-philips-par.c
4280 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-philips-par.c      Thu Jan  1 00:00:00 1970
4281 +++ i2c-2.5/drivers/i2c/busses/i2c-philips-par.c        Tue Sep 23 10:12:59 2003
4282 @@ -0,0 +1,243 @@
4283 +/* ------------------------------------------------------------------------- */
4284 +/* i2c-philips-par.c i2c-hw access for philips style parallel port adapters  */
4285 +/* ------------------------------------------------------------------------- */
4286 +/*   Copyright (C) 1995-2000 Simon G. Vogl
4287 +
4288 +    This program is free software; you can redistribute it and/or modify
4289 +    it under the terms of the GNU General Public License as published by
4290 +    the Free Software Foundation; either version 2 of the License, or
4291 +    (at your option) any later version.
4292 +
4293 +    This program is distributed in the hope that it will be useful,
4294 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
4295 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4296 +    GNU General Public License for more details.
4297 +
4298 +    You should have received a copy of the GNU General Public License
4299 +    along with this program; if not, write to the Free Software
4300 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
4301 +/* ------------------------------------------------------------------------- */ 
4302 +
4303 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
4304 +   Frodo Looijaard <frodol@dds.nl> */
4305 +
4306 +/* $Id$ */
4307 +
4308 +#include <linux/kernel.h>
4309 +#include <linux/module.h>
4310 +#include <linux/init.h>
4311 +#include <linux/parport.h>
4312 +#include <linux/i2c.h>
4313 +#include <linux/i2c-algo-bit.h>
4314 +
4315 +static int type;
4316 +
4317 +struct i2c_par
4318 +{
4319 +       struct pardevice *pdev;
4320 +       struct i2c_adapter adapter;
4321 +       struct i2c_algo_bit_data bit_lp_data;
4322 +       struct i2c_par *next;
4323 +};
4324 +
4325 +static struct i2c_par *adapter_list;
4326 +
4327 +
4328 +/* ----- printer port defines ------------------------------------------*/
4329 +                                       /* Pin Port  Inverted   name    */
4330 +#define I2C_ON         0x20            /* 12 status N  paper           */
4331 +                                       /* ... only for phil. not used  */
4332 +#define I2C_SDA                0x80            /*  9 data   N  data7           */
4333 +#define I2C_SCL                0x08            /* 17 ctrl   N  dsel            */
4334 +
4335 +#define I2C_SDAIN      0x80            /* 11 stat   Y  busy            */
4336 +#define I2C_SCLIN      0x08            /* 15 stat   Y  enable          */
4337 +
4338 +#define I2C_DMASK      0x7f
4339 +#define I2C_CMASK      0xf7
4340 +
4341 +/* ----- local functions ----------------------------------------------        */
4342 +
4343 +static void bit_lp_setscl(void *data, int state)
4344 +{
4345 +       /*be cautious about state of the control register - 
4346 +               touch only the one bit needed*/
4347 +       if (state) {
4348 +               parport_write_control((struct parport *) data,
4349 +                     parport_read_control((struct parport *) data)|I2C_SCL);
4350 +       } else {
4351 +               parport_write_control((struct parport *) data,
4352 +                     parport_read_control((struct parport *) data)&I2C_CMASK);
4353 +       }
4354 +}
4355 +
4356 +static void bit_lp_setsda(void *data, int state)
4357 +{
4358 +       if (state) {
4359 +               parport_write_data((struct parport *) data, I2C_DMASK);
4360 +       } else {
4361 +               parport_write_data((struct parport *) data, I2C_SDA);
4362 +       }
4363 +}
4364 +
4365 +static int bit_lp_getscl(void *data)
4366 +{
4367 +       return parport_read_status((struct parport *) data) & I2C_SCLIN;
4368 +}
4369 +
4370 +static int bit_lp_getsda(void *data)
4371 +{
4372 +       return parport_read_status((struct parport *) data) & I2C_SDAIN;
4373 +}
4374 +
4375 +static void bit_lp_setscl2(void *data, int state)
4376 +{
4377 +       if (state) {
4378 +               parport_write_data((struct parport *) data,
4379 +                     parport_read_data((struct parport *) data)|0x1);
4380 +       } else {
4381 +               parport_write_data((struct parport *) data,
4382 +                     parport_read_data((struct parport *) data)&0xfe);
4383 +       }
4384 +}
4385 +
4386 +static void bit_lp_setsda2(void *data, int state)
4387 +{
4388 +       if (state) {
4389 +               parport_write_data((struct parport *) data,
4390 +                     parport_read_data((struct parport *) data)|0x2);
4391 +       } else {
4392 +               parport_write_data((struct parport *) data,
4393 +                     parport_read_data((struct parport *) data)&0xfd);
4394 +       }
4395 +}
4396 +
4397 +static int bit_lp_getsda2(void *data)
4398 +{
4399 +       return (parport_read_status((struct parport *) data) & 
4400 +                                    PARPORT_STATUS_BUSY) ? 0 : 1;
4401 +}
4402 +
4403 +/* ------------------------------------------------------------------------
4404 + * Encapsulate the above functions in the correct operations structure.
4405 + * This is only done when more than one hardware adapter is supported.
4406 + */
4407
4408 +static struct i2c_algo_bit_data bit_lp_data = {
4409 +       .setsda         = bit_lp_setsda,
4410 +       .setscl         = bit_lp_setscl,
4411 +       .getsda         = bit_lp_getsda,
4412 +       .getscl         = bit_lp_getscl,
4413 +       .udelay         = 80,
4414 +       .mdelay         = 80,
4415 +       .timeout        = HZ
4416 +}; 
4417 +
4418 +static struct i2c_algo_bit_data bit_lp_data2 = {
4419 +       .setsda         = bit_lp_setsda2,
4420 +       .setscl         = bit_lp_setscl2,
4421 +       .getsda         = bit_lp_getsda2,
4422 +       .udelay         = 80,
4423 +       .mdelay         = 80,
4424 +       .timeout        = HZ
4425 +}; 
4426 +
4427 +static struct i2c_adapter bit_lp_ops = {
4428 +       .owner          = THIS_MODULE,
4429 +       .id             = I2C_HW_B_LP,
4430 +       .name           = "Philips Parallel port adapter",
4431 +};
4432 +
4433 +static void i2c_parport_attach (struct parport *port)
4434 +{
4435 +       struct i2c_par *adapter = kmalloc(sizeof(struct i2c_par),
4436 +                                         GFP_KERNEL);
4437 +       if (!adapter) {
4438 +               printk(KERN_ERR "i2c-philips-par: Unable to malloc.\n");
4439 +               return;
4440 +       }
4441 +       memset (adapter, 0x00, sizeof(struct i2c_par));
4442 +
4443 +       /* printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name); */
4444 +
4445 +       adapter->pdev = parport_register_device(port, "i2c-philips-par",
4446 +                                               NULL, NULL, NULL, 
4447 +                                               PARPORT_FLAG_EXCL,
4448 +                                               NULL);
4449 +       if (!adapter->pdev) {
4450 +               printk(KERN_ERR "i2c-philips-par: Unable to register with parport.\n");
4451 +               kfree(adapter);
4452 +               return;
4453 +       }
4454 +
4455 +       adapter->adapter = bit_lp_ops;
4456 +       adapter->adapter.algo_data = &adapter->bit_lp_data;
4457 +       adapter->bit_lp_data = type ? bit_lp_data2 : bit_lp_data;
4458 +       adapter->bit_lp_data.data = port;
4459 +
4460 +       if (parport_claim_or_block(adapter->pdev) < 0 ) {
4461 +               printk(KERN_ERR "i2c-philips-par: Could not claim parallel port.\n");
4462 +               kfree(adapter);
4463 +               return;
4464 +       }
4465 +       /* reset hardware to sane state */
4466 +       bit_lp_setsda(port, 1);
4467 +       bit_lp_setscl(port, 1);
4468 +       parport_release(adapter->pdev);
4469 +
4470 +       if (i2c_bit_add_bus(&adapter->adapter) < 0) {
4471 +               printk(KERN_ERR "i2c-philips-par: Unable to register with I2C.\n");
4472 +               parport_unregister_device(adapter->pdev);
4473 +               kfree(adapter);
4474 +               return;         /* No good */
4475 +       }
4476 +
4477 +       adapter->next = adapter_list;
4478 +       adapter_list = adapter;
4479 +}
4480 +
4481 +static void i2c_parport_detach (struct parport *port)
4482 +{
4483 +       struct i2c_par *adapter, *prev = NULL;
4484 +
4485 +       for (adapter = adapter_list; adapter; adapter = adapter->next) {
4486 +               if (adapter->pdev->port == port) {
4487 +                       parport_unregister_device(adapter->pdev);
4488 +                       i2c_bit_del_bus(&adapter->adapter);
4489 +                       if (prev)
4490 +                               prev->next = adapter->next;
4491 +                       else
4492 +                               adapter_list = adapter->next;
4493 +                       kfree(adapter);
4494 +                       return;
4495 +               }
4496 +               prev = adapter;
4497 +       }
4498 +}
4499 +
4500 +static struct parport_driver i2c_driver = {
4501 +       .name =         "i2c-philips-par",
4502 +       .attach =       i2c_parport_attach,
4503 +       .detach =       i2c_parport_detach,
4504 +};
4505 +
4506 +int __init i2c_bitlp_init(void)
4507 +{
4508 +       printk(KERN_INFO "i2c Philips parallel port adapter driver\n");
4509 +
4510 +       return parport_register_driver(&i2c_driver);
4511 +}
4512 +
4513 +void __exit i2c_bitlp_exit(void)
4514 +{
4515 +       parport_unregister_driver(&i2c_driver);
4516 +}
4517 +
4518 +MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
4519 +MODULE_DESCRIPTION("I2C-Bus adapter routines for Philips parallel port adapter");
4520 +MODULE_LICENSE("GPL");
4521 +
4522 +MODULE_PARM(type, "i");
4523 +
4524 +module_init(i2c_bitlp_init);
4525 +module_exit(i2c_bitlp_exit);
4526 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-piix4.c i2c-2.5/drivers/i2c/busses/i2c-piix4.c
4527 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-piix4.c    Mon Sep  8 19:49:59 2003
4528 +++ i2c-2.5/drivers/i2c/busses/i2c-piix4.c      Tue Sep 23 10:12:59 2003
4529 @@ -395,7 +395,6 @@
4530  
4531  static struct i2c_adapter piix4_adapter = {
4532         .owner          = THIS_MODULE,
4533 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
4534         .class          = I2C_ADAP_CLASS_SMBUS,
4535         .algo           = &smbus_algorithm,
4536         .name           = "unset",
4537 @@ -451,7 +450,7 @@
4538         /* set up the driverfs linkage to our parent device */
4539         piix4_adapter.dev.parent = &dev->dev;
4540  
4541 -       snprintf(piix4_adapter.name, DEVICE_NAME_SIZE,
4542 +       snprintf(piix4_adapter.name, I2C_NAME_SIZE,
4543                 "SMBus PIIX4 adapter at %04x", piix4_smba);
4544  
4545         retval = i2c_add_adapter(&piix4_adapter);
4546 @@ -474,7 +473,6 @@
4547  
4548  static int __init i2c_piix4_init(void)
4549  {
4550 -       printk(KERN_INFO "i2c-piix4 version %s (%s)\n", I2C_VERSION, I2C_DATE);
4551         return pci_module_init(&piix4_driver);
4552  }
4553  
4554 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-prosavage.c i2c-2.5/drivers/i2c/busses/i2c-prosavage.c
4555 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-prosavage.c        Thu Jan  1 00:00:00 1970
4556 +++ i2c-2.5/drivers/i2c/busses/i2c-prosavage.c  Tue Sep 23 10:12:59 2003
4557 @@ -0,0 +1,338 @@
4558 +/*
4559 + *    kernel/busses/i2c-prosavage.c
4560 + *
4561 + *    i2c bus driver for S3/VIA 8365/8375 graphics processor.
4562 + *    Copyright (c) 2003 Henk Vergonet <henk@god.dyndns.org>
4563 + *    Based on code written by:
4564 + *     Frodo Looijaard <frodol@dds.nl>,
4565 + *     Philip Edelbrock <phil@netroedge.com>,
4566 + *     Ralph Metzler <rjkm@thp.uni-koeln.de>, and
4567 + *     Mark D. Studebaker <mdsxyz123@yahoo.com>
4568 + *     Simon Vogl
4569 + *     and others
4570 + *
4571 + *    Please read the lm_sensors documentation for details on use.
4572 + *
4573 + *    This program is free software; you can redistribute it and/or modify
4574 + *    it under the terms of the GNU General Public License as published by
4575 + *    the Free Software Foundation; either version 2 of the License, or
4576 + *    (at your option) any later version.
4577 + *
4578 + *    This program is distributed in the hope that it will be useful,
4579 + *    but WITHOUT ANY WARRANTY; without even the implied warranty of
4580 + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4581 + *    GNU General Public License for more details.
4582 + *
4583 + *    You should have received a copy of the GNU General Public License
4584 + *    along with this program; if not, write to the Free Software
4585 + *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4586 + *
4587 + */
4588 +/*  18-05-2003 HVE - created
4589 + *  14-06-2003 HVE - adapted for lm_sensors2
4590 + *  17-06-2003 HVE - linux 2.5.xx compatible
4591 + *  18-06-2003 HVE - codingstyle
4592 + *  21-06-2003 HVE - compatibility lm_sensors2 and linux 2.5.xx
4593 + *                  codingstyle, mmio enabled
4594 + *
4595 + *  This driver interfaces to the I2C bus of the VIA north bridge embedded
4596 + *  ProSavage4/8 devices. Usefull for gaining access to the TV Encoder chips.
4597 + *
4598 + *  Graphics cores:
4599 + *   S3/VIA KM266/VT8375 aka ProSavage8
4600 + *   S3/VIA KM133/VT8365 aka Savage4
4601 + *
4602 + *  Two serial busses are implemented:
4603 + *   SERIAL1 - I2C serial communications interface
4604 + *   SERIAL2 - DDC2 monitor communications interface
4605 + *
4606 + *  Tested on a FX41 mainboard, see http://www.shuttle.com
4607 + * 
4608 + *
4609 + *  TODO:
4610 + *  - integration with prosavage framebuffer device
4611 + *    (Additional documentation needed :(
4612 + */
4613 +
4614 +#include <linux/module.h>
4615 +#include <linux/init.h>
4616 +#include <linux/pci.h>
4617 +#include <linux/i2c.h>
4618 +#include <linux/i2c-algo-bit.h>
4619 +
4620 +
4621 +/*
4622 + * driver configuration
4623 + */
4624 +#define MAX_BUSSES     2
4625 +
4626 +struct s_i2c_bus {
4627 +       void    *mmvga;
4628 +       int     i2c_reg;
4629 +       int     adap_ok;
4630 +       struct i2c_adapter              adap;
4631 +       struct i2c_algo_bit_data        algo;
4632 +};
4633 +
4634 +struct s_i2c_chip {
4635 +       void    *mmio;
4636 +       struct s_i2c_bus        i2c_bus[MAX_BUSSES];
4637 +};
4638 +
4639 +
4640 +/*
4641 + * i2c configuration
4642 + */
4643 +#ifndef I2C_HW_B_S3VIA
4644 +#define I2C_HW_B_S3VIA 0x18    /* S3VIA ProSavage adapter              */
4645 +#endif
4646 +
4647 +/* delays */
4648 +#define CYCLE_DELAY    10
4649 +#define TIMEOUT                (HZ / 2)
4650 +
4651 +
4652 +/* 
4653 + * S3/VIA 8365/8375 registers
4654 + */
4655 +#ifndef PCI_DEVICE_ID_S3_SAVAGE4
4656 +#define PCI_DEVICE_ID_S3_SAVAGE4       0x8a25
4657 +#endif
4658 +#ifndef PCI_DEVICE_ID_S3_PROSAVAGE8
4659 +#define PCI_DEVICE_ID_S3_PROSAVAGE8    0x8d04
4660 +#endif
4661 +
4662 +#define VGA_CR_IX      0x3d4
4663 +#define VGA_CR_DATA    0x3d5
4664 +
4665 +#define CR_SERIAL1     0xa0    /* I2C serial communications interface */
4666 +#define MM_SERIAL1     0xff20
4667 +#define CR_SERIAL2     0xb1    /* DDC2 monitor communications interface */
4668 +
4669 +/* based on vt8365 documentation */
4670 +#define I2C_ENAB       0x10
4671 +#define I2C_SCL_OUT    0x01
4672 +#define I2C_SDA_OUT    0x02
4673 +#define I2C_SCL_IN     0x04
4674 +#define I2C_SDA_IN     0x08
4675 +
4676 +#define SET_CR_IX(p, val)      writeb((val), (p)->mmvga + VGA_CR_IX)
4677 +#define SET_CR_DATA(p, val)    writeb((val), (p)->mmvga + VGA_CR_DATA)
4678 +#define GET_CR_DATA(p)         readb((p)->mmvga + VGA_CR_DATA)
4679 +
4680 +
4681 +/*
4682 + * Serial bus line handling
4683 + *
4684 + * serial communications register as parameter in private data
4685 + *
4686 + * TODO: locks with other code sections accessing video registers?
4687 + */
4688 +static void bit_s3via_setscl(void *bus, int val)
4689 +{
4690 +       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4691 +       unsigned int r;
4692 +
4693 +       SET_CR_IX(p, p->i2c_reg);
4694 +       r = GET_CR_DATA(p);
4695 +       r |= I2C_ENAB;
4696 +       if (val) {
4697 +               r |= I2C_SCL_OUT;
4698 +       } else {
4699 +               r &= ~I2C_SCL_OUT;
4700 +       }
4701 +       SET_CR_DATA(p, r);
4702 +}
4703 +
4704 +static void bit_s3via_setsda(void *bus, int val)
4705 +{
4706 +       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4707 +       unsigned int r;
4708 +       
4709 +       SET_CR_IX(p, p->i2c_reg);
4710 +       r = GET_CR_DATA(p);
4711 +       r |= I2C_ENAB;
4712 +       if (val) {
4713 +               r |= I2C_SDA_OUT;
4714 +       } else {
4715 +               r &= ~I2C_SDA_OUT;
4716 +       }
4717 +       SET_CR_DATA(p, r);
4718 +}
4719 +
4720 +static int bit_s3via_getscl(void *bus)
4721 +{
4722 +       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4723 +
4724 +       SET_CR_IX(p, p->i2c_reg);
4725 +       return (0 != (GET_CR_DATA(p) & I2C_SCL_IN));
4726 +}
4727 +
4728 +static int bit_s3via_getsda(void *bus)
4729 +{
4730 +       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4731 +
4732 +       SET_CR_IX(p, p->i2c_reg);
4733 +       return (0 != (GET_CR_DATA(p) & I2C_SDA_IN));
4734 +}
4735 +
4736 +
4737 +/*
4738 + * adapter initialisation
4739 + */
4740 +static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
4741 +{
4742 +       int ret;
4743 +       p->adap.owner     = THIS_MODULE;
4744 +       p->adap.id        = I2C_HW_B_S3VIA;
4745 +       p->adap.algo_data = &p->algo;
4746 +       p->adap.dev.parent = &dev->dev;
4747 +       p->algo.setsda    = bit_s3via_setsda;
4748 +       p->algo.setscl    = bit_s3via_setscl;
4749 +       p->algo.getsda    = bit_s3via_getsda;
4750 +       p->algo.getscl    = bit_s3via_getscl;
4751 +       p->algo.udelay    = CYCLE_DELAY;
4752 +       p->algo.mdelay    = CYCLE_DELAY;
4753 +       p->algo.timeout   = TIMEOUT;
4754 +       p->algo.data      = p;
4755 +       p->mmvga          = mmvga;
4756 +       p->i2c_reg        = i2c_reg;
4757 +    
4758 +       ret = i2c_bit_add_bus(&p->adap);
4759 +       if (ret) {
4760 +               return ret;
4761 +       }
4762 +
4763 +       p->adap_ok = 1;
4764 +       return 0;
4765 +}
4766 +
4767 +
4768 +/*
4769 + * Cleanup stuff
4770 + */
4771 +static void __devexit prosavage_remove(struct pci_dev *dev)
4772 +{
4773 +       struct s_i2c_chip *chip;
4774 +       int i, ret;
4775 +
4776 +       chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
4777 +
4778 +       if (!chip) {
4779 +               return;
4780 +       }
4781 +       for (i = MAX_BUSSES - 1; i >= 0; i--) {
4782 +               if (chip->i2c_bus[i].adap_ok == 0)
4783 +                       continue;
4784 +
4785 +               ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
4786 +               if (ret) {
4787 +                       dev_err(&dev->dev, ": %s not removed\n",
4788 +                               chip->i2c_bus[i].adap.name);
4789 +               }
4790 +       }
4791 +       if (chip->mmio) {
4792 +               iounmap(chip->mmio);
4793 +       }
4794 +       kfree(chip);
4795 +}
4796 +
4797 +
4798 +/*
4799 + * Detect chip and initialize it
4800 + */
4801 +static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_device_id *id)
4802 +{
4803 +       int ret;
4804 +       unsigned long base, len;
4805 +       struct s_i2c_chip *chip;
4806 +       struct s_i2c_bus  *bus;
4807 +
4808 +        pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); 
4809 +       chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
4810 +       if (chip == NULL) {
4811 +               return -ENOMEM;
4812 +       }
4813 +
4814 +       memset(chip, 0, sizeof(struct s_i2c_chip));
4815 +
4816 +       base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK;
4817 +       len  = dev->resource[0].end - base + 1;
4818 +       chip->mmio = ioremap_nocache(base, len);
4819 +
4820 +       if (chip->mmio == NULL) {
4821 +               dev_err(&dev->dev, "ioremap failed\n");
4822 +               prosavage_remove(dev);
4823 +               return -ENODEV;
4824 +       }
4825 +
4826 +
4827 +       /*
4828 +        * Chip initialisation
4829 +        */
4830 +       /* Unlock Extended IO Space ??? */
4831 +
4832 +
4833 +       /*
4834 +        * i2c bus registration
4835 +        */
4836 +       bus = &chip->i2c_bus[0];
4837 +       snprintf(bus->adap.name, sizeof(bus->adap.name),
4838 +               "ProSavage I2C bus at %02x:%02x.%x",
4839 +               dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
4840 +       ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL1);
4841 +       if (ret) {
4842 +               goto err_adap;
4843 +       }
4844 +       /*
4845 +        * ddc bus registration
4846 +        */
4847 +       bus = &chip->i2c_bus[1];
4848 +       snprintf(bus->adap.name, sizeof(bus->adap.name),
4849 +               "ProSavage DDC bus at %02x:%02x.%x",
4850 +               dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
4851 +       ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL2);
4852 +       if (ret) {
4853 +               goto err_adap;
4854 +       }
4855 +       return 0;
4856 +err_adap:
4857 +       dev_err(&dev->dev, ": %s failed\n", bus->adap.name);
4858 +       prosavage_remove(dev);
4859 +       return ret;
4860 +}
4861 +
4862 +
4863 +/*
4864 + * Data for PCI driver interface
4865 + */
4866 +static struct pci_device_id prosavage_pci_tbl[] = {
4867 +       { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_SAVAGE4) },
4868 +       { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_PROSAVAGE8) },
4869 +       { 0, },
4870 +};
4871 +
4872 +static struct pci_driver prosavage_driver = {
4873 +       .name           =       "prosavage-smbus",
4874 +       .id_table       =       prosavage_pci_tbl,
4875 +       .probe          =       prosavage_probe,
4876 +       .remove         =       __devexit_p(prosavage_remove),
4877 +};
4878 +
4879 +static int __init i2c_prosavage_init(void)
4880 +{
4881 +       return pci_module_init(&prosavage_driver);
4882 +}
4883 +
4884 +static void __exit i2c_prosavage_exit(void)
4885 +{
4886 +       pci_unregister_driver(&prosavage_driver);
4887 +}
4888 +
4889 +MODULE_DEVICE_TABLE(pci, prosavage_pci_tbl);
4890 +MODULE_AUTHOR("Henk Vergonet");
4891 +MODULE_DESCRIPTION("ProSavage VIA 8365/8375 smbus driver");
4892 +MODULE_LICENSE("GPL");
4893 +
4894 +module_init (i2c_prosavage_init);
4895 +module_exit (i2c_prosavage_exit);
4896 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-rpx.c i2c-2.5/drivers/i2c/busses/i2c-rpx.c
4897 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-rpx.c      Thu Jan  1 00:00:00 1970
4898 +++ i2c-2.5/drivers/i2c/busses/i2c-rpx.c        Tue Sep 23 10:12:59 2003
4899 @@ -0,0 +1,103 @@
4900 +/*
4901 + * Embedded Planet RPX Lite MPC8xx CPM I2C interface.
4902 + * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
4903 + *
4904 + * moved into proper i2c interface;
4905 + * Brad Parker (brad@heeltoe.com)
4906 + *
4907 + * RPX lite specific parts of the i2c interface
4908 + * Update:  There actually isn't anything RPXLite-specific about this module.
4909 + * This should work for most any 8xx board.  The console messages have been 
4910 + * changed to eliminate RPXLite references.
4911 + */
4912 +
4913 +#include <linux/kernel.h>
4914 +#include <linux/ioport.h>
4915 +#include <linux/module.h>
4916 +#include <linux/init.h>
4917 +#include <linux/stddef.h>
4918 +#include <linux/parport.h>
4919 +#include <linux/i2c.h>
4920 +#include <linux/i2c-algo-8xx.h>
4921 +#include <asm/mpc8xx.h>
4922 +#include <asm/commproc.h>
4923 +
4924 +
4925 +static void
4926 +rpx_iic_init(struct i2c_algo_8xx_data *data)
4927 +{
4928 +       volatile cpm8xx_t *cp;
4929 +       volatile immap_t *immap;
4930 +
4931 +       cp = cpmp;      /* Get pointer to Communication Processor */
4932 +       immap = (immap_t *)IMAP_ADDR;   /* and to internal registers */
4933 +
4934 +       data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
4935 +
4936 +       /* Check for and use a microcode relocation patch.
4937 +       */
4938 +       if ((data->reloc = data->iip->iic_rpbase))
4939 +               data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
4940 +               
4941 +       data->i2c = (i2c8xx_t *)&(immap->im_i2c);
4942 +       data->cp = cp;
4943 +
4944 +       /* Initialize Port B IIC pins.
4945 +       */
4946 +       cp->cp_pbpar |= 0x00000030;
4947 +       cp->cp_pbdir |= 0x00000030;
4948 +       cp->cp_pbodr |= 0x00000030;
4949 +
4950 +       /* Allocate space for two transmit and two receive buffer
4951 +        * descriptors in the DP ram.
4952 +        */
4953 +       data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4);
4954 +
4955 +       /* ptr to i2c area */
4956 +       data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
4957 +}
4958 +
4959 +static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
4960 +{
4961 +       /* install interrupt handler */
4962 +       cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
4963 +
4964 +       return 0;
4965 +}
4966 +
4967 +static struct i2c_algo_8xx_data rpx_data = {
4968 +       .setisr = rpx_install_isr
4969 +};
4970 +
4971 +static struct i2c_adapter rpx_ops = {
4972 +       .owner          = THIS_MODULE,
4973 +       .name           = "m8xx",
4974 +       .id             = I2C_HW_MPC8XX_EPON,
4975 +       .algo_data      = &rpx_data,
4976 +};
4977 +
4978 +int __init i2c_rpx_init(void)
4979 +{
4980 +       printk(KERN_INFO "i2c-rpx: i2c MPC8xx driver\n");
4981 +
4982 +       /* reset hardware to sane state */
4983 +       rpx_iic_init(&rpx_data);
4984 +
4985 +       if (i2c_8xx_add_bus(&rpx_ops) < 0) {
4986 +               printk("i2c-rpx: Unable to register with I2C\n");
4987 +               return -ENODEV;
4988 +       }
4989 +
4990 +       return 0;
4991 +}
4992 +
4993 +void __exit i2c_rpx_exit(void)
4994 +{
4995 +       i2c_8xx_del_bus(&rpx_ops);
4996 +}
4997 +
4998 +MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
4999 +MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
5000 +
5001 +module_init(i2c_rpx_init);
5002 +module_exit(i2c_rpx_exit);
5003 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-savage4.c i2c-2.5/drivers/i2c/busses/i2c-savage4.c
5004 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-savage4.c  Thu Jan  1 00:00:00 1970
5005 +++ i2c-2.5/drivers/i2c/busses/i2c-savage4.c    Tue Sep 23 10:12:59 2003
5006 @@ -0,0 +1,205 @@
5007 +/*
5008 +    i2c-savage4.c - Part of lm_sensors, Linux kernel modules for hardware
5009 +              monitoring
5010 +    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>,
5011 +    Philip Edelbrock <phil@netroedge.com>,
5012 +    Ralph Metzler <rjkm@thp.uni-koeln.de>, and
5013 +    Mark D. Studebaker <mdsxyz123@yahoo.com>
5014 +    
5015 +    Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
5016 +    Simon Vogl
5017 +
5018 +    This program is free software; you can redistribute it and/or modify
5019 +    it under the terms of the GNU General Public License as published by
5020 +    the Free Software Foundation; either version 2 of the License, or
5021 +    (at your option) any later version.
5022 +
5023 +    This program is distributed in the hope that it will be useful,
5024 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
5025 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5026 +    GNU General Public License for more details.
5027 +
5028 +    You should have received a copy of the GNU General Public License
5029 +    along with this program; if not, write to the Free Software
5030 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5031 +*/
5032 +
5033 +/* This interfaces to the I2C bus of the Savage4 to gain access to
5034 +   the BT869 and possibly other I2C devices. The DDC bus is not
5035 +   yet supported because its register is not memory-mapped.
5036 +   However we leave the DDC code here, commented out, to make
5037 +   it easier to add later.
5038 +*/
5039 +
5040 +#include <linux/kernel.h>
5041 +#include <linux/module.h>
5042 +#include <linux/init.h>
5043 +#include <linux/pci.h>
5044 +#include <linux/i2c.h>
5045 +#include <linux/i2c-algo-bit.h>
5046 +
5047 +/* 3DFX defines */
5048 +#define PCI_CHIP_SAVAGE3D      0x8A20
5049 +#define PCI_CHIP_SAVAGE3D_MV   0x8A21
5050 +#define PCI_CHIP_SAVAGE4       0x8A22
5051 +#define PCI_CHIP_SAVAGE2000    0x9102
5052 +#define PCI_CHIP_PROSAVAGE_PM  0x8A25
5053 +#define PCI_CHIP_PROSAVAGE_KM  0x8A26
5054 +#define PCI_CHIP_SAVAGE_MX_MV  0x8c10
5055 +#define PCI_CHIP_SAVAGE_MX     0x8c11
5056 +#define PCI_CHIP_SAVAGE_IX_MV  0x8c12
5057 +#define PCI_CHIP_SAVAGE_IX     0x8c13
5058 +
5059 +#define REG                    0xff20  /* Serial Port 1 Register */
5060 +
5061 +/* bit locations in the register */
5062 +#define DDC_ENAB               0x00040000
5063 +#define DDC_SCL_OUT            0x00080000
5064 +#define DDC_SDA_OUT            0x00100000
5065 +#define DDC_SCL_IN             0x00200000
5066 +#define DDC_SDA_IN             0x00400000
5067 +#define I2C_ENAB               0x00000020
5068 +#define I2C_SCL_OUT            0x00000001
5069 +#define I2C_SDA_OUT            0x00000002
5070 +#define I2C_SCL_IN             0x00000008
5071 +#define I2C_SDA_IN             0x00000010
5072 +
5073 +/* initialization states */
5074 +#define INIT2                  0x20
5075 +#define INIT3                  0x04
5076 +
5077 +/* delays */
5078 +#define CYCLE_DELAY            10
5079 +#define TIMEOUT                        (HZ / 2)
5080 +
5081 +
5082 +static void *ioaddr;
5083 +
5084 +/* The sav GPIO registers don't have individual masks for each bit
5085 +   so we always have to read before writing. */
5086 +
5087 +static void bit_savi2c_setscl(void *data, int val)
5088 +{
5089 +       unsigned int r;
5090 +       r = readl(ioaddr + REG);
5091 +       if(val)
5092 +               r |= I2C_SCL_OUT;
5093 +       else
5094 +               r &= ~I2C_SCL_OUT;
5095 +       writel(r, ioaddr + REG);
5096 +       readl(ioaddr + REG);    /* flush posted write */
5097 +}
5098 +
5099 +static void bit_savi2c_setsda(void *data, int val)
5100 +{
5101 +       unsigned int r;
5102 +       r = readl(ioaddr + REG);
5103 +       if(val)
5104 +               r |= I2C_SDA_OUT;
5105 +       else
5106 +               r &= ~I2C_SDA_OUT;
5107 +       writel(r, ioaddr + REG);
5108 +       readl(ioaddr + REG);    /* flush posted write */
5109 +}
5110 +
5111 +/* The GPIO pins are open drain, so the pins always remain outputs.
5112 +   We rely on the i2c-algo-bit routines to set the pins high before
5113 +   reading the input from other chips. */
5114 +
5115 +static int bit_savi2c_getscl(void *data)
5116 +{
5117 +       return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
5118 +}
5119 +
5120 +static int bit_savi2c_getsda(void *data)
5121 +{
5122 +       return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
5123 +}
5124 +
5125 +/* Configures the chip */
5126 +
5127 +static int config_s4(struct pci_dev *dev)
5128 +{
5129 +       unsigned int cadr;
5130 +
5131 +       /* map memory */
5132 +       cadr = dev->resource[0].start;
5133 +       cadr &= PCI_BASE_ADDRESS_MEM_MASK;
5134 +       ioaddr = ioremap_nocache(cadr, 0x0080000);
5135 +       if (ioaddr) {
5136 +               /* writel(0x8160, ioaddr + REG2); */
5137 +               writel(0x00000020, ioaddr + REG);
5138 +               dev_info(&dev->dev, "Using Savage4 at %p\n", ioaddr);
5139 +               return 0;
5140 +       }
5141 +       return -ENODEV;
5142 +}
5143 +
5144 +static struct i2c_algo_bit_data sav_i2c_bit_data = {
5145 +       .setsda         = bit_savi2c_setsda,
5146 +       .setscl         = bit_savi2c_setscl,
5147 +       .getsda         = bit_savi2c_getsda,
5148 +       .getscl         = bit_savi2c_getscl,
5149 +       .udelay         = CYCLE_DELAY,
5150 +       .mdelay         = CYCLE_DELAY,
5151 +       .timeout        = TIMEOUT
5152 +};
5153 +
5154 +static struct i2c_adapter savage4_i2c_adapter = {
5155 +       .owner          = THIS_MODULE,
5156 +       .name           = "I2C Savage4 adapter",
5157 +       .algo_data      = &sav_i2c_bit_data,
5158 +};
5159 +
5160 +static struct pci_device_id savage4_ids[] __devinitdata = {
5161 +       { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE4) },
5162 +       { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE2000) },
5163 +       { 0, }
5164 +};
5165 +
5166 +static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_id *id)
5167 +{
5168 +       int retval;
5169 +
5170 +       retval = config_s4(dev);
5171 +       if (retval)
5172 +               return retval;
5173 +
5174 +       /* set up the sysfs linkage to our parent device */
5175 +       savage4_i2c_adapter.dev.parent = &dev->dev;
5176 +
5177 +       return i2c_bit_add_bus(&savage4_i2c_adapter);
5178 +}
5179 +
5180 +static void __devexit savage4_remove(struct pci_dev *dev)
5181 +{
5182 +       i2c_bit_del_bus(&savage4_i2c_adapter);
5183 +       iounmap(ioaddr);
5184 +}
5185 +
5186 +static struct pci_driver savage4_driver = {
5187 +       .name           = "savage4 smbus",
5188 +       .id_table       = savage4_ids,
5189 +       .probe          = savage4_probe,
5190 +       .remove         = __devexit_p(savage4_remove),
5191 +};
5192 +
5193 +static int __init i2c_savage4_init(void)
5194 +{
5195 +       return pci_module_init(&savage4_driver);
5196 +}
5197 +
5198 +static void __exit i2c_savage4_exit(void)
5199 +{
5200 +       pci_unregister_driver(&savage4_driver);
5201 +}
5202 +
5203 +MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
5204 +               "Philip Edelbrock <phil@netroedge.com>, "
5205 +               "Ralph Metzler <rjkm@thp.uni-koeln.de>, "
5206 +               "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
5207 +MODULE_DESCRIPTION("Savage4 I2C/SMBus driver");
5208 +MODULE_LICENSE("GPL");
5209 +
5210 +module_init(i2c_savage4_init);
5211 +module_exit(i2c_savage4_exit);
5212 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-sis5595.c i2c-2.5/drivers/i2c/busses/i2c-sis5595.c
5213 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-sis5595.c  Thu Jan  1 00:00:00 1970
5214 +++ i2c-2.5/drivers/i2c/busses/i2c-sis5595.c    Tue Sep 23 10:12:59 2003
5215 @@ -0,0 +1,416 @@
5216 +/*
5217 +    sis5595.c - Part of lm_sensors, Linux kernel modules for hardware
5218 +              monitoring
5219 +    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl> and
5220 +    Philip Edelbrock <phil@netroedge.com>
5221 +
5222 +    This program is free software; you can redistribute it and/or modify
5223 +    it under the terms of the GNU General Public License as published by
5224 +    the Free Software Foundation; either version 2 of the License, or
5225 +    (at your option) any later version.
5226 +
5227 +    This program is distributed in the hope that it will be useful,
5228 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
5229 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5230 +    GNU General Public License for more details.
5231 +
5232 +    You should have received a copy of the GNU General Public License
5233 +    along with this program; if not, write to the Free Software
5234 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5235 +*/
5236 +
5237 +/* Note: we assume there can only be one SIS5595 with one SMBus interface */
5238 +
5239 +/*
5240 +   Note: all have mfr. ID 0x1039.
5241 +   SUPPORTED           PCI ID          
5242 +       5595            0008
5243 +
5244 +   Note: these chips contain a 0008 device which is incompatible with the
5245 +         5595. We recognize these by the presence of the listed
5246 +         "blacklist" PCI ID and refuse to load.
5247 +
5248 +   NOT SUPPORTED       PCI ID          BLACKLIST PCI ID        
5249 +        540            0008            0540
5250 +        550            0008            0550
5251 +       5513            0008            5511
5252 +       5581            0008            5597
5253 +       5582            0008            5597
5254 +       5597            0008            5597
5255 +       5598            0008            5597/5598
5256 +        630            0008            0630
5257 +        645            0008            0645
5258 +        646            0008            0646
5259 +        648            0008            0648
5260 +        650            0008            0650
5261 +        651            0008            0651
5262 +        730            0008            0730
5263 +        735            0008            0735
5264 +        745            0008            0745
5265 +        746            0008            0746
5266 +*/
5267 +
5268 +/* TO DO: 
5269 + * Add Block Transfers (ugly, but supported by the adapter)
5270 + * Add adapter resets
5271 + */
5272 +
5273 +/* #define DEBUG 1 */
5274 +
5275 +#include <linux/kernel.h>
5276 +#include <linux/module.h>
5277 +#include <linux/pci.h>
5278 +#include <linux/ioport.h>
5279 +#include <linux/init.h>
5280 +#include <linux/i2c.h>
5281 +
5282 +static int blacklist[] = {
5283 +       PCI_DEVICE_ID_SI_540,
5284 +       PCI_DEVICE_ID_SI_550,
5285 +       PCI_DEVICE_ID_SI_630,
5286 +       PCI_DEVICE_ID_SI_645,
5287 +       PCI_DEVICE_ID_SI_646,
5288 +       PCI_DEVICE_ID_SI_648,
5289 +       PCI_DEVICE_ID_SI_650,
5290 +       PCI_DEVICE_ID_SI_651,
5291 +       PCI_DEVICE_ID_SI_730,
5292 +       PCI_DEVICE_ID_SI_735,
5293 +       PCI_DEVICE_ID_SI_745,
5294 +       PCI_DEVICE_ID_SI_746,
5295 +       PCI_DEVICE_ID_SI_5511,  /* 5513 chip has the 0008 device but that ID
5296 +                                  shows up in other chips so we use the 5511
5297 +                                  ID for recognition */
5298 +       PCI_DEVICE_ID_SI_5597,
5299 +       PCI_DEVICE_ID_SI_5598,
5300 +       0,                      /* terminates the list */
5301 +};
5302 +
5303 +/* Length of ISA address segment */
5304 +#define SIS5595_EXTENT         8
5305 +/* SIS5595 SMBus registers */
5306 +#define SMB_STS_LO             0x00
5307 +#define SMB_STS_HI             0x01
5308 +#define SMB_CTL_LO             0x02
5309 +#define SMB_CTL_HI             0x03
5310 +#define SMB_ADDR               0x04
5311 +#define SMB_CMD                        0x05
5312 +#define SMB_PCNT               0x06
5313 +#define SMB_CNT                        0x07
5314 +#define SMB_BYTE               0x08
5315 +#define SMB_DEV                        0x10
5316 +#define SMB_DB0                        0x11
5317 +#define SMB_DB1                        0x12
5318 +#define SMB_HAA                        0x13
5319 +
5320 +/* PCI Address Constants */
5321 +#define SMB_INDEX              0x38
5322 +#define SMB_DAT                        0x39
5323 +#define SIS5595_ENABLE_REG     0x40
5324 +#define ACPI_BASE              0x90
5325 +
5326 +/* Other settings */
5327 +#define MAX_TIMEOUT            500
5328 +
5329 +/* SIS5595 constants */
5330 +#define SIS5595_QUICK          0x00
5331 +#define SIS5595_BYTE           0x02
5332 +#define SIS5595_BYTE_DATA      0x04
5333 +#define SIS5595_WORD_DATA      0x06
5334 +#define SIS5595_PROC_CALL      0x08
5335 +#define SIS5595_BLOCK_DATA     0x0A
5336 +
5337 +/* insmod parameters */
5338 +
5339 +/* If force_addr is set to anything different from 0, we forcibly enable
5340 +   the device at the given address. */
5341 +static int force_addr = 0;
5342 +MODULE_PARM(force_addr, "i");
5343 +MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller");
5344 +
5345 +static unsigned short sis5595_base = 0;
5346 +
5347 +static u8 sis5595_read(u8 reg)
5348 +{
5349 +       outb(reg, sis5595_base + SMB_INDEX);
5350 +       return inb(sis5595_base + SMB_DAT);
5351 +}
5352 +
5353 +static void sis5595_write(u8 reg, u8 data)
5354 +{
5355 +       outb(reg, sis5595_base + SMB_INDEX);
5356 +       outb(data, sis5595_base + SMB_DAT);
5357 +}
5358 +
5359 +static int sis5595_setup(struct pci_dev *SIS5595_dev)
5360 +{
5361 +       u16 a;
5362 +       u8 val;
5363 +       int *i;
5364 +       int retval = -ENODEV;
5365 +
5366 +       /* Look for imposters */
5367 +       for (i = blacklist; *i != 0; i++) {
5368 +               struct pci_dev *dev;
5369 +               dev = pci_get_device(PCI_VENDOR_ID_SI, *i, NULL);
5370 +               if (dev) {
5371 +                       dev_err(&SIS5595_dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i);
5372 +                       pci_dev_put(dev);
5373 +                       return -ENODEV;
5374 +               }
5375 +       }
5376 +
5377 +       /* Determine the address of the SMBus areas */
5378 +       pci_read_config_word(SIS5595_dev, ACPI_BASE, &sis5595_base);
5379 +       if (sis5595_base == 0 && force_addr == 0) {
5380 +               dev_err(&SIS5595_dev->dev, "ACPI base address uninitialized - upgrade BIOS or use force_addr=0xaddr\n");
5381 +               return -ENODEV;
5382 +       }
5383 +
5384 +       if (force_addr)
5385 +               sis5595_base = force_addr & ~(SIS5595_EXTENT - 1);
5386 +       dev_dbg(&SIS5595_dev->dev, "ACPI Base address: %04x\n", sis5595_base);
5387 +
5388 +       /* NB: We grab just the two SMBus registers here, but this may still
5389 +        * interfere with ACPI :-(  */
5390 +       if (!request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus")) {
5391 +               dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n",
5392 +                       sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1);
5393 +               return -ENODEV;
5394 +       }
5395 +
5396 +       if (force_addr) {
5397 +               dev_info(&SIS5595_dev->dev, "forcing ISA address 0x%04X\n", sis5595_base);
5398 +               if (!pci_write_config_word(SIS5595_dev, ACPI_BASE, sis5595_base))
5399 +                       goto error;
5400 +               if (!pci_read_config_word(SIS5595_dev, ACPI_BASE, &a))
5401 +                       goto error;
5402 +               if ((a & ~(SIS5595_EXTENT - 1)) != sis5595_base) {
5403 +                       /* doesn't work for some chips! */
5404 +                       dev_err(&SIS5595_dev->dev, "force address failed - not supported?\n");
5405 +                       goto error;
5406 +               }
5407 +       }
5408 +
5409 +       if (!pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val))
5410 +               goto error;
5411 +       if ((val & 0x80) == 0) {
5412 +               dev_info(&SIS5595_dev->dev, "enabling ACPI\n");
5413 +               if (!pci_write_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, val | 0x80))
5414 +                       goto error;
5415 +               if (!pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val))
5416 +                       goto error;
5417 +               if ((val & 0x80) == 0) {
5418 +                       /* doesn't work for some chips? */
5419 +                       dev_err(&SIS5595_dev->dev, "ACPI enable failed - not supported?\n");
5420 +                       goto error;
5421 +               }
5422 +       }
5423 +
5424 +       /* Everything is happy */
5425 +       return 0;
5426 +
5427 +error:
5428 +       release_region(sis5595_base + SMB_INDEX, 2);
5429 +       return retval;
5430 +}
5431 +
5432 +static int sis5595_transaction(struct i2c_adapter *adap)
5433 +{
5434 +       int temp;
5435 +       int result = 0;
5436 +       int timeout = 0;
5437 +
5438 +       /* Make sure the SMBus host is ready to start transmitting */
5439 +       temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
5440 +       if (temp != 0x00) {
5441 +               dev_dbg(&adap->dev, "SMBus busy (%04x). Resetting... \n", temp);
5442 +               sis5595_write(SMB_STS_LO, temp & 0xff);
5443 +               sis5595_write(SMB_STS_HI, temp >> 8);
5444 +               if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
5445 +                       dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
5446 +                       return -1;
5447 +               } else {
5448 +                       dev_dbg(&adap->dev, "Successfull!\n");
5449 +               }
5450 +       }
5451 +
5452 +       /* start the transaction by setting bit 4 */
5453 +       sis5595_write(SMB_CTL_LO, sis5595_read(SMB_CTL_LO) | 0x10);
5454 +
5455 +       /* We will always wait for a fraction of a second! */
5456 +       do {
5457 +               i2c_delay(1);
5458 +               temp = sis5595_read(SMB_STS_LO);
5459 +       } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT));
5460 +
5461 +       /* If the SMBus is still busy, we give up */
5462 +       if (timeout >= MAX_TIMEOUT) {
5463 +               dev_dbg(&adap->dev, "SMBus Timeout!\n");
5464 +               result = -1;
5465 +       }
5466 +
5467 +       if (temp & 0x10) {
5468 +               dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
5469 +               result = -1;
5470 +       }
5471 +
5472 +       if (temp & 0x20) {
5473 +               dev_err(&adap->dev, "Bus collision! SMBus may be locked until "
5474 +                       "next hard reset (or not...)\n");
5475 +               /* Clock stops and slave is stuck in mid-transmission */
5476 +               result = -1;
5477 +       }
5478 +
5479 +       temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
5480 +       if (temp != 0x00) {
5481 +               sis5595_write(SMB_STS_LO, temp & 0xff);
5482 +               sis5595_write(SMB_STS_HI, temp >> 8);
5483 +       }
5484 +
5485 +       temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
5486 +       if (temp != 0x00)
5487 +               dev_dbg(&adap->dev, "Failed reset at end of transaction (%02x)\n", temp);
5488 +
5489 +       return result;
5490 +}
5491 +
5492 +/* Return -1 on error. */
5493 +static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
5494 +                         unsigned short flags, char read_write,
5495 +                         u8 command, int size, union i2c_smbus_data *data)
5496 +{
5497 +       switch (size) {
5498 +       case I2C_SMBUS_QUICK:
5499 +               sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5500 +               size = SIS5595_QUICK;
5501 +               break;
5502 +       case I2C_SMBUS_BYTE:
5503 +               sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5504 +               if (read_write == I2C_SMBUS_WRITE)
5505 +                       sis5595_write(SMB_CMD, command);
5506 +               size = SIS5595_BYTE;
5507 +               break;
5508 +       case I2C_SMBUS_BYTE_DATA:
5509 +               sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5510 +               sis5595_write(SMB_CMD, command);
5511 +               if (read_write == I2C_SMBUS_WRITE)
5512 +                       sis5595_write(SMB_BYTE, data->byte);
5513 +               size = SIS5595_BYTE_DATA;
5514 +               break;
5515 +       case I2C_SMBUS_PROC_CALL:
5516 +       case I2C_SMBUS_WORD_DATA:
5517 +               sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5518 +               sis5595_write(SMB_CMD, command);
5519 +               if (read_write == I2C_SMBUS_WRITE) {
5520 +                       sis5595_write(SMB_BYTE, data->word & 0xff);
5521 +                       sis5595_write(SMB_BYTE + 1,
5522 +                                     (data->word & 0xff00) >> 8);
5523 +               }
5524 +               size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA;
5525 +               break;
5526 +/*
5527 +       case I2C_SMBUS_BLOCK_DATA:
5528 +               printk("sis5595.o: Block data not yet implemented!\n");
5529 +               return -1;
5530 +               break;
5531 +*/
5532 +       default:
5533 +               printk
5534 +                   (KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size);
5535 +               return -1;
5536 +       }
5537 +
5538 +       sis5595_write(SMB_CTL_LO, ((size & 0x0E)));
5539 +
5540 +       if (sis5595_transaction(adap))
5541 +               return -1;
5542 +
5543 +       if ((size != SIS5595_PROC_CALL) &&
5544 +           ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK)))
5545 +               return 0;
5546 +
5547 +
5548 +       switch (size) {
5549 +       case SIS5595_BYTE:      /* Where is the result put? I assume here it is in
5550 +                                  SMB_DATA but it might just as well be in the
5551 +                                  SMB_CMD. No clue in the docs */
5552 +       case SIS5595_BYTE_DATA:
5553 +               data->byte = sis5595_read(SMB_BYTE);
5554 +               break;
5555 +       case SIS5595_WORD_DATA:
5556 +       case SIS5595_PROC_CALL:
5557 +               data->word = sis5595_read(SMB_BYTE) + (sis5595_read(SMB_BYTE + 1) << 8);
5558 +               break;
5559 +       }
5560 +       return 0;
5561 +}
5562 +
5563 +static u32 sis5595_func(struct i2c_adapter *adapter)
5564 +{
5565 +       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
5566 +           I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
5567 +           I2C_FUNC_SMBUS_PROC_CALL;
5568 +}
5569 +
5570 +static struct i2c_algorithm smbus_algorithm = {
5571 +       .name           = "Non-I2C SMBus adapter",
5572 +       .id             = I2C_ALGO_SMBUS,
5573 +       .smbus_xfer     = sis5595_access,
5574 +       .functionality  = sis5595_func,
5575 +};
5576 +
5577 +static struct i2c_adapter sis5595_adapter = {
5578 +       .owner          = THIS_MODULE,
5579 +       .name           = "unset",
5580 +       .algo           = &smbus_algorithm,
5581 +};
5582 +
5583 +static struct pci_device_id sis5595_ids[] __devinitdata = {
5584 +       { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 
5585 +       { 0, }
5586 +};
5587 +
5588 +static int __devinit sis5595_probe(struct pci_dev *dev, const struct pci_device_id *id)
5589 +{
5590 +       if (sis5595_setup(dev)) {
5591 +               dev_err(&dev->dev, "SIS5595 not detected, module not inserted.\n");
5592 +               return -ENODEV;
5593 +       }
5594 +
5595 +       /* set up the driverfs linkage to our parent device */
5596 +       sis5595_adapter.dev.parent = &dev->dev;
5597 +
5598 +       sprintf(sis5595_adapter.name, "SMBus SIS5595 adapter at %04x",
5599 +               sis5595_base + SMB_INDEX);
5600 +       return i2c_add_adapter(&sis5595_adapter);
5601 +}
5602 +
5603 +static void __devexit sis5595_remove(struct pci_dev *dev)
5604 +{
5605 +       i2c_del_adapter(&sis5595_adapter);
5606 +}
5607 +
5608 +static struct pci_driver sis5595_driver = {
5609 +       .name           = "sis5595 smbus",
5610 +       .id_table       = sis5595_ids,
5611 +       .probe          = sis5595_probe,
5612 +       .remove         = __devexit_p(sis5595_remove),
5613 +};
5614 +
5615 +static int __init i2c_sis5595_init(void)
5616 +{
5617 +       return pci_module_init(&sis5595_driver);
5618 +}
5619 +
5620 +static void __exit i2c_sis5595_exit(void)
5621 +{
5622 +       pci_unregister_driver(&sis5595_driver);
5623 +       release_region(sis5595_base + SMB_INDEX, 2);
5624 +}
5625 +
5626 +MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
5627 +MODULE_DESCRIPTION("SIS5595 SMBus driver");
5628 +MODULE_LICENSE("GPL");
5629 +
5630 +module_init(i2c_sis5595_init);
5631 +module_exit(i2c_sis5595_exit);
5632 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-sis630.c i2c-2.5/drivers/i2c/busses/i2c-sis630.c
5633 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-sis630.c   Thu Jan  1 00:00:00 1970
5634 +++ i2c-2.5/drivers/i2c/busses/i2c-sis630.c     Tue Sep 23 10:12:59 2003
5635 @@ -0,0 +1,493 @@
5636 +/*
5637 +    i2c-sis630.c - Part of lm_sensors, Linux kernel modules for hardware
5638 +              monitoring
5639 +
5640 +    Copyright (c) 2002,2003 Alexander Malysh <amalysh@web.de>
5641 +
5642 +    This program is free software; you can redistribute it and/or modify
5643 +    it under the terms of the GNU General Public License as published by
5644 +    the Free Software Foundation; either version 2 of the License, or
5645 +    (at your option) any later version.
5646 +
5647 +    This program is distributed in the hope that it will be useful,
5648 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
5649 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5650 +    GNU General Public License for more details.
5651 +
5652 +    You should have received a copy of the GNU General Public License
5653 +    along with this program; if not, write to the Free Software
5654 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
5655 +*/
5656 +
5657 +/*
5658 +   Changes:
5659 +   24.08.2002
5660 +       Fixed the typo in sis630_access (Thanks to Mark M. Hoffman)
5661 +       Changed sis630_transaction.(Thanks to Mark M. Hoffman)
5662 +   18.09.2002
5663 +       Added SIS730 as supported
5664 +   21.09.2002
5665 +       Added high_clock module option.If this option is set
5666 +       used Host Master Clock 56KHz (default 14KHz).For now we are save old Host
5667 +       Master Clock and after transaction completed restore (otherwise
5668 +       it's confuse BIOS and hung Machine).
5669 +   24.09.2002
5670 +       Fixed typo in sis630_access
5671 +       Fixed logical error by restoring of Host Master Clock
5672 +   31.07.2003
5673 +       Added block data read/write support.
5674 +*/
5675 +
5676 +/*
5677 +   Status: beta
5678 +
5679 +   Supports:
5680 +       SIS 630
5681 +       SIS 730
5682 +
5683 +   Note: we assume there can only be one device, with one SMBus interface.
5684 +*/
5685 +
5686 +/* #define DEBUG 1 */
5687 +
5688 +#include <linux/kernel.h>
5689 +#include <linux/module.h>
5690 +#include <linux/pci.h>
5691 +#include <linux/ioport.h>
5692 +#include <linux/init.h>
5693 +#include <linux/i2c.h>
5694 +
5695 +
5696 +/* SIS630 SMBus registers */
5697 +#define SMB_STS                        0x80    /* status */
5698 +#define SMB_EN                 0x81    /* status enable */
5699 +#define SMB_CNT                        0x82
5700 +#define SMBHOST_CNT            0x83
5701 +#define SMB_ADDR               0x84
5702 +#define SMB_CMD                        0x85
5703 +#define SMB_PCOUNT             0x86    /* processed count */
5704 +#define SMB_COUNT              0x87
5705 +#define SMB_BYTE               0x88    /* ~0x8F data byte field */
5706 +#define SMBDEV_ADDR            0x90
5707 +#define SMB_DB0                        0x91
5708 +#define SMB_DB1                        0x92
5709 +#define SMB_SAA                        0x93
5710 +
5711 +/* register count for request_region */
5712 +#define SIS630_SMB_IOREGION    20
5713 +
5714 +/* PCI address constants */
5715 +/* acpi base address register  */
5716 +#define SIS630_ACPI_BASE_REG   0x74
5717 +/* bios control register */
5718 +#define SIS630_BIOS_CTL_REG    0x40
5719 +
5720 +/* Other settings */
5721 +#define MAX_TIMEOUT            500
5722 +
5723 +/* SIS630 constants */
5724 +#define SIS630_QUICK           0x00
5725 +#define SIS630_BYTE            0x01
5726 +#define SIS630_BYTE_DATA       0x02
5727 +#define SIS630_WORD_DATA       0x03
5728 +#define SIS630_PCALL           0x04
5729 +#define SIS630_BLOCK_DATA      0x05
5730 +
5731 +/* insmod parameters */
5732 +static int high_clock = 0;
5733 +MODULE_PARM(high_clock, "i");
5734 +MODULE_PARM_DESC(high_clock, "Set Host Master Clock to 56KHz (default 14KHz).");
5735 +
5736 +
5737 +static unsigned short acpi_base = 0;
5738 +
5739 +static inline u8 sis630_read(u8 reg)
5740 +{
5741 +       return inb(acpi_base + reg);
5742 +}
5743 +
5744 +static inline void sis630_write(u8 reg, u8 data)
5745 +{
5746 +       outb(data, acpi_base + reg);
5747 +}
5748 +
5749 +static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldclock)
5750 +{
5751 +        int temp;
5752 +
5753 +       /* Make sure the SMBus host is ready to start transmitting. */
5754 +       if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) {
5755 +               dev_dbg(&adap->dev, "SMBus busy (%02x).Resetting...\n",temp);
5756 +               /* kill smbus transaction */
5757 +               sis630_write(SMBHOST_CNT, 0x20);
5758 +
5759 +               if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) {
5760 +                       dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
5761 +                       return -1;
5762 +                } else {
5763 +                       dev_dbg(&adap->dev, "Successfull!\n");
5764 +               }
5765 +        }
5766 +
5767 +       /* save old clock, so we can prevent machine for hung */
5768 +       *oldclock = sis630_read(SMB_CNT);
5769 +
5770 +       dev_dbg(&adap->dev, "saved clock 0x%02x\n", *oldclock);
5771 +
5772 +       /* disable timeout interrupt , set Host Master Clock to 56KHz if requested */
5773 +       if (high_clock > 0)
5774 +               sis630_write(SMB_CNT, 0x20);
5775 +       else
5776 +               sis630_write(SMB_CNT, (*oldclock & ~0x40));
5777 +
5778 +       /* clear all sticky bits */
5779 +       temp = sis630_read(SMB_STS);
5780 +       sis630_write(SMB_STS, temp & 0x1e);
5781 +
5782 +       /* start the transaction by setting bit 4 and size */
5783 +       sis630_write(SMBHOST_CNT,0x10 | (size & 0x07));
5784 +
5785 +       return 0;
5786 +}
5787 +
5788 +static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
5789 +{
5790 +       int temp, result = 0, timeout = 0;
5791 +
5792 +       /* We will always wait for a fraction of a second! */
5793 +       do {
5794 +               i2c_delay(1);
5795 +               temp = sis630_read(SMB_STS);
5796 +               /* check if block transmitted */
5797 +               if (size == SIS630_BLOCK_DATA && (temp & 0x10))
5798 +                       break;
5799 +       } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
5800 +
5801 +       /* If the SMBus is still busy, we give up */
5802 +       if (timeout >= MAX_TIMEOUT) {
5803 +               dev_dbg(&adap->dev, "SMBus Timeout!\n");
5804 +               result = -1;
5805 +       }
5806 +
5807 +       if (temp & 0x02) {
5808 +               dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
5809 +               result = -1;
5810 +       }
5811 +
5812 +       if (temp & 0x04) {
5813 +               dev_err(&adap->dev, "Bus collision!\n");
5814 +               result = -1;
5815 +               /*
5816 +                 TBD: Datasheet say:
5817 +                 the software should clear this bit and restart SMBUS operation.
5818 +                 Should we do it or user start request again?
5819 +               */
5820 +       }
5821 +
5822 +       return result;
5823 +}
5824 +
5825 +static void sis630_transaction_end(struct i2c_adapter *adap, u8 oldclock)
5826 +{
5827 +       int temp = 0;
5828 +
5829 +       /* clear all status "sticky" bits */
5830 +       sis630_write(SMB_STS, temp);
5831 +
5832 +       dev_dbg(&adap->dev, "SMB_CNT before clock restore 0x%02x\n", sis630_read(SMB_CNT));
5833 +
5834 +       /*
5835 +        * restore old Host Master Clock if high_clock is set
5836 +        * and oldclock was not 56KHz
5837 +        */
5838 +       if (high_clock > 0 && !(oldclock & 0x20))
5839 +               sis630_write(SMB_CNT,(sis630_read(SMB_CNT) & ~0x20));
5840 +
5841 +       dev_dbg(&adap->dev, "SMB_CNT after clock restore 0x%02x\n", sis630_read(SMB_CNT));
5842 +}
5843 +
5844 +static int sis630_transaction(struct i2c_adapter *adap, int size)
5845 +{
5846 +       int result = 0;
5847 +       u8 oldclock = 0;
5848 +
5849 +       result = sis630_transaction_start(adap, size, &oldclock);
5850 +       if (!result) {
5851 +               result = sis630_transaction_wait(adap, size);
5852 +               sis630_transaction_end(adap, oldclock);
5853 +       }
5854 +
5855 +       return result;
5856 +}
5857 +
5858 +static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *data, int read_write)
5859 +{
5860 +       int i, len = 0, rc = 0;
5861 +       u8 oldclock = 0;
5862 +
5863 +       if (read_write == I2C_SMBUS_WRITE) {
5864 +               len = data->block[0];
5865 +               if (len < 0)
5866 +                       len = 0;
5867 +               else if (len > 32)
5868 +                       len = 32;
5869 +               sis630_write(SMB_COUNT, len);
5870 +               for (i=1; i <= len; i++) {
5871 +                       dev_dbg(&adap->dev, "set data 0x%02x\n", data->block[i]);
5872 +                       /* set data */
5873 +                       sis630_write(SMB_BYTE+(i-1)%8, data->block[i]);
5874 +                       if (i==8 || (len<8 && i==len)) {
5875 +                               dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i);
5876 +                               /* first transaction */
5877 +                               if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock))
5878 +                                       return -1;
5879 +                       }
5880 +                       else if ((i-1)%8 == 7 || i==len) {
5881 +                               dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i);
5882 +                               if (i>8) {
5883 +                                       dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
5884 +                                       /*
5885 +                                          If this is not first transaction,
5886 +                                          we must clear sticky bit.
5887 +                                          clear SMBARY_STS
5888 +                                       */
5889 +                                       sis630_write(SMB_STS,0x10);
5890 +                               }
5891 +                               if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) {
5892 +                                       dev_dbg(&adap->dev, "trans_wait failed\n");
5893 +                                       rc = -1;
5894 +                                       break;
5895 +                               }
5896 +                       }
5897 +               }
5898 +       }
5899 +       else {
5900 +               /* read request */
5901 +               data->block[0] = len = 0;
5902 +               if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) {
5903 +                       return -1;
5904 +               }
5905 +               do {
5906 +                       if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) {
5907 +                               dev_dbg(&adap->dev, "trans_wait failed\n");
5908 +                               rc = -1;
5909 +                               break;
5910 +                       }
5911 +                       /* if this first transaction then read byte count */
5912 +                       if (len == 0)
5913 +                               data->block[0] = sis630_read(SMB_COUNT);
5914 +
5915 +                       dev_dbg(&adap->dev, "block data read len=0x%x\n", data->block[0]);
5916 +
5917 +                       for (i=0; i < 8 && len < data->block[0]; i++,len++) {
5918 +                               dev_dbg(&adap->dev, "read i=%d len=%d\n", i, len);
5919 +                               data->block[len+1] = sis630_read(SMB_BYTE+i);
5920 +                       }
5921 +
5922 +                       dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
5923 +
5924 +                       /* clear SMBARY_STS */
5925 +                       sis630_write(SMB_STS,0x10);
5926 +               } while(len < data->block[0]);
5927 +       }
5928 +
5929 +       sis630_transaction_end(adap, oldclock);
5930 +
5931 +       return rc;
5932 +}
5933 +
5934 +/* Return -1 on error. */
5935 +static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
5936 +                        unsigned short flags, char read_write,
5937 +                        u8 command, int size, union i2c_smbus_data *data)
5938 +{
5939 +       switch (size) {
5940 +               case I2C_SMBUS_QUICK:
5941 +                       sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5942 +                       size = SIS630_QUICK;
5943 +                       break;
5944 +               case I2C_SMBUS_BYTE:
5945 +                       sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5946 +                       if (read_write == I2C_SMBUS_WRITE)
5947 +                               sis630_write(SMB_CMD, command);
5948 +                       size = SIS630_BYTE;
5949 +                       break;
5950 +               case I2C_SMBUS_BYTE_DATA:
5951 +                       sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5952 +                       sis630_write(SMB_CMD, command);
5953 +                       if (read_write == I2C_SMBUS_WRITE)
5954 +                               sis630_write(SMB_BYTE, data->byte);
5955 +                       size = SIS630_BYTE_DATA;
5956 +                       break;
5957 +               case I2C_SMBUS_PROC_CALL:
5958 +               case I2C_SMBUS_WORD_DATA:
5959 +                       sis630_write(SMB_ADDR,((addr & 0x7f) << 1) | (read_write & 0x01));
5960 +                       sis630_write(SMB_CMD, command);
5961 +                       if (read_write == I2C_SMBUS_WRITE) {
5962 +                               sis630_write(SMB_BYTE, data->word & 0xff);
5963 +                               sis630_write(SMB_BYTE + 1,(data->word & 0xff00) >> 8);
5964 +                       }
5965 +                       size = (size == I2C_SMBUS_PROC_CALL ? SIS630_PCALL : SIS630_WORD_DATA);
5966 +                       break;
5967 +               case I2C_SMBUS_BLOCK_DATA:
5968 +                       sis630_write(SMB_ADDR,((addr & 0x7f) << 1) | (read_write & 0x01));
5969 +                       sis630_write(SMB_CMD, command);
5970 +                       size = SIS630_BLOCK_DATA;
5971 +                       return sis630_block_data(adap, data, read_write);
5972 +               default:
5973 +                       printk("Unsupported I2C size\n");
5974 +                       return -1;
5975 +                       break;
5976 +       }
5977 +
5978 +       if (sis630_transaction(adap, size))
5979 +               return -1;
5980 +
5981 +       if ((size != SIS630_PCALL) &&
5982 +               ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) {
5983 +               return 0;
5984 +       }
5985 +
5986 +       switch(size) {
5987 +               case SIS630_BYTE:
5988 +               case SIS630_BYTE_DATA:
5989 +                       data->byte = sis630_read(SMB_BYTE);
5990 +                       break;
5991 +               case SIS630_PCALL:
5992 +               case SIS630_WORD_DATA:
5993 +                       data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
5994 +                       break;
5995 +               default:
5996 +                       return -1;
5997 +                       break;
5998 +       }
5999 +
6000 +       return 0;
6001 +}
6002 +
6003 +static u32 sis630_func(struct i2c_adapter *adapter)
6004 +{
6005 +       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
6006 +               I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL |
6007 +               I2C_FUNC_SMBUS_BLOCK_DATA;
6008 +}
6009 +
6010 +static int sis630_setup(struct pci_dev *dummy)
6011 +{
6012 +       unsigned char b;
6013 +       struct pci_dev *sis630_dev = NULL;
6014 +       int retval = -ENODEV;
6015 +
6016 +       /* We need ISA bridge and not pci device passed in.  */
6017 +       sis630_dev = pci_get_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, sis630_dev);
6018 +       if (!sis630_dev) {
6019 +               dev_err(&dummy->dev, "Error: Can't detect 85C503/5513 ISA bridge!\n");
6020 +               return -ENODEV;
6021 +       }
6022 +
6023 +       /*
6024 +          Enable ACPI first , so we can accsess reg 74-75
6025 +          in acpi io space and read acpi base addr
6026 +       */
6027 +       if (!pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) {
6028 +               dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n");
6029 +               goto exit;
6030 +       }
6031 +
6032 +       /* if ACPI already enabled , do nothing */
6033 +       if (!(b & 0x80) &&
6034 +           !pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) {
6035 +               dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n");
6036 +               goto exit;
6037 +       }
6038 +       /* Determine the ACPI base address */
6039 +       if (!pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) {
6040 +               dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n");
6041 +               goto exit;
6042 +       }
6043 +
6044 +       dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
6045 +
6046 +       /* Everything is happy, let's grab the memory and set things up. */
6047 +       if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")) {
6048 +               dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already "
6049 +                       "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA);
6050 +               goto exit;
6051 +       }
6052 +
6053 +       retval = 0;
6054 +
6055 +exit:
6056 +       pci_dev_put(sis630_dev);
6057 +       return retval;
6058 +}
6059 +
6060 +
6061 +static struct i2c_algorithm smbus_algorithm = {
6062 +       .name           = "Non-I2C SMBus adapter",
6063 +       .id             = I2C_ALGO_SMBUS,
6064 +       .smbus_xfer     = sis630_access,
6065 +       .functionality  = sis630_func,
6066 +};
6067 +
6068 +static struct i2c_adapter sis630_adapter = {
6069 +       .owner          = THIS_MODULE,
6070 +       .name           = "unset",
6071 +       .algo           = &smbus_algorithm,
6072 +};
6073 +
6074 +static struct pci_device_id sis630_ids[] __devinitdata = {
6075 +       { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630) },
6076 +       { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_730) },
6077 +       { 0, }
6078 +};
6079 +
6080 +static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
6081 +{
6082 +
6083 +       if (sis630_setup(dev)) {
6084 +               dev_err(&dev->dev, "SIS630 comp. bus not detected, module not inserted.\n");
6085 +               return -ENODEV;
6086 +       }
6087 +
6088 +       /* set up the driverfs linkage to our parent device */
6089 +       sis630_adapter.dev.parent = &dev->dev;
6090 +
6091 +       sprintf(sis630_adapter.name, "SMBus SIS630 adapter at %04x",
6092 +               acpi_base + SMB_STS);
6093 +
6094 +       return i2c_add_adapter(&sis630_adapter);
6095 +}
6096 +
6097 +static void __devexit sis630_remove(struct pci_dev *dev)
6098 +{
6099 +       i2c_del_adapter(&sis630_adapter);
6100 +}
6101 +
6102 +
6103 +static struct pci_driver sis630_driver = {
6104 +       .name           = "sis630 smbus",
6105 +       .id_table       = sis630_ids,
6106 +       .probe          = sis630_probe,
6107 +       .remove         = __devexit_p(sis630_remove),
6108 +};
6109 +
6110 +static int __init i2c_sis630_init(void)
6111 +{
6112 +       return pci_module_init(&sis630_driver);
6113 +}
6114 +
6115 +
6116 +static void __exit i2c_sis630_exit(void)
6117 +{
6118 +       pci_unregister_driver(&sis630_driver);
6119 +       release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION);
6120 +}
6121 +
6122 +
6123 +MODULE_LICENSE("GPL");
6124 +MODULE_AUTHOR("Alexander Malysh <amalysh@web.de>");
6125 +MODULE_DESCRIPTION("SIS630 SMBus driver");
6126 +
6127 +module_init(i2c_sis630_init);
6128 +module_exit(i2c_sis630_exit);
6129 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-sis96x.c i2c-2.5/drivers/i2c/busses/i2c-sis96x.c
6130 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-sis96x.c   Mon Sep  8 19:49:59 2003
6131 +++ i2c-2.5/drivers/i2c/busses/i2c-sis96x.c     Tue Sep 23 10:12:59 2003
6132 @@ -261,7 +261,6 @@
6133  
6134  static struct i2c_adapter sis96x_adapter = {
6135         .owner          = THIS_MODULE,
6136 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_SIS96X,
6137         .class          = I2C_ADAP_CLASS_SMBUS,
6138         .algo           = &smbus_algorithm,
6139         .name           = "unset",
6140 @@ -318,7 +317,7 @@
6141         /* set up the driverfs linkage to our parent device */
6142         sis96x_adapter.dev.parent = &dev->dev;
6143  
6144 -       snprintf(sis96x_adapter.name, DEVICE_NAME_SIZE,
6145 +       snprintf(sis96x_adapter.name, I2C_NAME_SIZE,
6146                 "SiS96x SMBus adapter at 0x%04x", sis96x_smbus_base);
6147  
6148         if ((retval = i2c_add_adapter(&sis96x_adapter))) {
6149 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-velleman.c i2c-2.5/drivers/i2c/busses/i2c-velleman.c
6150 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-velleman.c Thu Jan  1 00:00:00 1970
6151 +++ i2c-2.5/drivers/i2c/busses/i2c-velleman.c   Tue Sep 23 10:12:59 2003
6152 @@ -0,0 +1,160 @@
6153 +/* ------------------------------------------------------------------------- */
6154 +/* i2c-velleman.c i2c-hw access for Velleman K9000 adapters                 */
6155 +/* ------------------------------------------------------------------------- */
6156 +/*   Copyright (C) 1995-96, 2000 Simon G. Vogl
6157 +
6158 +    This program is free software; you can redistribute it and/or modify
6159 +    it under the terms of the GNU General Public License as published by
6160 +    the Free Software Foundation; either version 2 of the License, or
6161 +    (at your option) any later version.
6162 +
6163 +    This program is distributed in the hope that it will be useful,
6164 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
6165 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6166 +    GNU General Public License for more details.
6167 +
6168 +    You should have received a copy of the GNU General Public License
6169 +    along with this program; if not, write to the Free Software
6170 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
6171 +/* ------------------------------------------------------------------------- */
6172 +
6173 +/* $Id$ */
6174 +
6175 +#include <linux/kernel.h>
6176 +#include <linux/ioport.h>
6177 +#include <linux/module.h>
6178 +#include <linux/init.h>
6179 +#include <linux/delay.h>
6180 +#include <linux/i2c.h>
6181 +#include <linux/i2c-algo-bit.h>
6182 +#include <asm/io.h>
6183 +
6184 +/* ----- global defines -----------------------------------------------        */
6185 +#define DEB(x)         /* should be reasonable open, close &c.         */
6186 +#define DEB2(x)        /* low level debugging - very slow              */
6187 +#define DEBE(x)        x       /* error messages                               */
6188 +
6189 +                                       /* Pin Port  Inverted   name    */
6190 +#define I2C_SDA                0x02            /*  ctrl bit 1  (inv)   */
6191 +#define I2C_SCL                0x08            /*  ctrl bit 3  (inv)   */
6192 +
6193 +#define I2C_SDAIN      0x10            /* stat bit 4           */
6194 +#define I2C_SCLIN      0x08            /* ctrl bit 3 (inv)(reads own output)*/
6195 +
6196 +#define I2C_DMASK      0xfd
6197 +#define I2C_CMASK      0xf7
6198 +
6199 +
6200 +/* --- Convenience defines for the parallel port:                      */
6201 +#define BASE   (unsigned int)(data)
6202 +#define DATA   BASE                    /* Centronics data port         */
6203 +#define STAT   (BASE+1)                /* Centronics status port       */
6204 +#define CTRL   (BASE+2)                /* Centronics control port      */
6205 +
6206 +#define DEFAULT_BASE 0x378
6207 +static int base=0;
6208 +
6209 +/* ----- local functions --------------------------------------------------- */
6210 +
6211 +static void bit_velle_setscl(void *data, int state)
6212 +{
6213 +       if (state) {
6214 +               outb(inb(CTRL) & I2C_CMASK,   CTRL);
6215 +       } else {
6216 +               outb(inb(CTRL) | I2C_SCL, CTRL);
6217 +       }
6218 +       
6219 +}
6220 +
6221 +static void bit_velle_setsda(void *data, int state)
6222 +{
6223 +       if (state) {
6224 +               outb(inb(CTRL) & I2C_DMASK , CTRL);
6225 +       } else {
6226 +               outb(inb(CTRL) | I2C_SDA, CTRL);
6227 +       }
6228 +       
6229 +} 
6230 +
6231 +static int bit_velle_getscl(void *data)
6232 +{
6233 +       return ( 0 == ( (inb(CTRL)) & I2C_SCLIN ) );
6234 +}
6235 +
6236 +static int bit_velle_getsda(void *data)
6237 +{
6238 +       return ( 0 != ( (inb(STAT)) & I2C_SDAIN ) );
6239 +}
6240 +
6241 +static int bit_velle_init(void)
6242 +{
6243 +       if (!request_region(base, (base == 0x3bc) ? 3 : 8, 
6244 +                       "i2c (Vellemann adapter)"))
6245 +               return -ENODEV;
6246 +
6247 +       bit_velle_setsda((void*)base,1);
6248 +       bit_velle_setscl((void*)base,1);
6249 +       return 0;
6250 +}
6251 +
6252 +/* ------------------------------------------------------------------------
6253 + * Encapsulate the above functions in the correct operations structure.
6254 + * This is only done when more than one hardware adapter is supported.
6255 + */
6256 +
6257 +static struct i2c_algo_bit_data bit_velle_data = {
6258 +       .setsda         = bit_velle_setsda,
6259 +       .setscl         = bit_velle_setscl,
6260 +       .getsda         = bit_velle_getsda,
6261 +       .getscl         = bit_velle_getscl,
6262 +       .udelay         = 10,
6263 +       .mdelay         = 10,
6264 +       .timeout        = HZ
6265 +};
6266 +
6267 +static struct i2c_adapter bit_velle_ops = {
6268 +       .owner          = THIS_MODULE,
6269 +       .algo_data      = &bit_velle_data,
6270 +       .name           = "Velleman K8000",
6271 +};
6272 +
6273 +static int __init i2c_bitvelle_init(void)
6274 +{
6275 +       printk(KERN_INFO "i2c-velleman: i2c Velleman K8000 driver\n");
6276 +       if (base==0) {
6277 +               /* probe some values */
6278 +               base=DEFAULT_BASE;
6279 +               bit_velle_data.data=(void*)DEFAULT_BASE;
6280 +               if (bit_velle_init()==0) {
6281 +                       if(i2c_bit_add_bus(&bit_velle_ops) < 0)
6282 +                               return -ENODEV;
6283 +               } else {
6284 +                       return -ENODEV;
6285 +               }
6286 +       } else {
6287 +               bit_velle_data.data=(void*)base;
6288 +               if (bit_velle_init()==0) {
6289 +                       if(i2c_bit_add_bus(&bit_velle_ops) < 0)
6290 +                               return -ENODEV;
6291 +               } else {
6292 +                       return -ENODEV;
6293 +               }
6294 +       }
6295 +       printk(KERN_DEBUG "i2c-velleman: found device at %#x.\n",base);
6296 +       return 0;
6297 +}
6298 +
6299 +static void __exit i2c_bitvelle_exit(void)
6300 +{      
6301 +       i2c_bit_del_bus(&bit_velle_ops);
6302 +       release_region(base, (base == 0x3bc) ? 3 : 8);
6303 +}
6304 +
6305 +MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
6306 +MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter");
6307 +MODULE_LICENSE("GPL");
6308 +
6309 +MODULE_PARM(base, "i");
6310 +
6311 +module_init(i2c_bitvelle_init);
6312 +module_exit(i2c_bitvelle_exit);
6313 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-via.c i2c-2.5/drivers/i2c/busses/i2c-via.c
6314 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-via.c      Thu Jan  1 00:00:00 1970
6315 +++ i2c-2.5/drivers/i2c/busses/i2c-via.c        Tue Sep 23 10:12:59 2003
6316 @@ -0,0 +1,182 @@
6317 +/*
6318 +    i2c-via.c - Part of lm_sensors,  Linux kernel modules
6319 +                for hardware monitoring
6320 +
6321 +    i2c Support for Via Technologies 82C586B South Bridge
6322 +
6323 +    Copyright (c) 1998, 1999 Kyösti Mälkki <kmalkki@cc.hut.fi>
6324 +
6325 +    This program is free software; you can redistribute it and/or modify
6326 +    it under the terms of the GNU General Public License as published by
6327 +    the Free Software Foundation; either version 2 of the License, or
6328 +    (at your option) any later version.
6329 +
6330 +    This program is distributed in the hope that it will be useful,
6331 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
6332 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6333 +    GNU General Public License for more details.
6334 +
6335 +    You should have received a copy of the GNU General Public License
6336 +    along with this program; if not, write to the Free Software
6337 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6338 +*/
6339 +
6340 +#define DEBUG
6341 +
6342 +#include <linux/kernel.h>
6343 +#include <linux/module.h>
6344 +#include <linux/pci.h>
6345 +#include <linux/ioport.h>
6346 +#include <linux/init.h>
6347 +#include <linux/i2c.h>
6348 +#include <linux/i2c-algo-bit.h>
6349 +
6350 +/* Power management registers */
6351 +#define PM_CFG_REVID   0x08    /* silicon revision code */
6352 +#define PM_CFG_IOBASE0 0x20
6353 +#define PM_CFG_IOBASE1 0x48
6354 +
6355 +#define I2C_DIR                (pm_io_base+0x40)
6356 +#define I2C_OUT                (pm_io_base+0x42)
6357 +#define I2C_IN         (pm_io_base+0x44)
6358 +#define I2C_SCL                0x02    /* clock bit in DIR/OUT/IN register */
6359 +#define I2C_SDA                0x04
6360 +
6361 +/* io-region reservation */
6362 +#define IOSPACE                0x06
6363 +#define IOTEXT         "via-i2c"
6364 +
6365 +static u16 pm_io_base = 0;
6366 +
6367 +/*
6368 +   It does not appear from the datasheet that the GPIO pins are
6369 +   open drain. So a we set a low value by setting the direction to
6370 +   output and a high value by setting the direction to input and
6371 +   relying on the required I2C pullup. The data value is initialized
6372 +   to 0 in via_init() and never changed.
6373 +*/
6374 +static void bit_via_setscl(void *data, int state)
6375 +{
6376 +       outb(state ? inb(I2C_DIR) & ~I2C_SCL : inb(I2C_DIR) | I2C_SCL, I2C_DIR);
6377 +}
6378 +
6379 +static void bit_via_setsda(void *data, int state)
6380 +{
6381 +       outb(state ? inb(I2C_DIR) & ~I2C_SDA : inb(I2C_DIR) | I2C_SDA, I2C_DIR);
6382 +}
6383 +
6384 +static int bit_via_getscl(void *data)
6385 +{
6386 +       return (0 != (inb(I2C_IN) & I2C_SCL));
6387 +}
6388 +
6389 +static int bit_via_getsda(void *data)
6390 +{
6391 +       return (0 != (inb(I2C_IN) & I2C_SDA));
6392 +}
6393 +
6394 +
6395 +static struct i2c_algo_bit_data bit_data = {
6396 +       .setsda         = bit_via_setsda,
6397 +       .setscl         = bit_via_setscl,
6398 +       .getsda         = bit_via_getsda,
6399 +       .getscl         = bit_via_getscl,
6400 +       .udelay         = 5,
6401 +       .mdelay         = 5,
6402 +       .timeout        = HZ
6403 +};
6404 +
6405 +static struct i2c_adapter vt586b_adapter = {
6406 +       .owner          = THIS_MODULE,
6407 +       .name           = "VIA i2c",
6408 +       .algo_data      = &bit_data,
6409 +};
6410 +
6411 +
6412 +static struct pci_device_id vt586b_ids[] __devinitdata = {
6413 +       { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3) },
6414 +       { 0, }
6415 +};
6416 +
6417 +static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_id *id)
6418 +{
6419 +       u16 base;
6420 +       u8 rev;
6421 +       int res;
6422 +
6423 +       if (pm_io_base) {
6424 +               dev_err(&dev->dev, "i2c-via: Will only support one host\n");
6425 +               return -ENODEV;
6426 +       }
6427 +
6428 +       pci_read_config_byte(dev, PM_CFG_REVID, &rev);
6429 +
6430 +       switch (rev) {
6431 +       case 0x00:
6432 +               base = PM_CFG_IOBASE0;
6433 +               break;
6434 +       case 0x01:
6435 +       case 0x10:
6436 +               base = PM_CFG_IOBASE1;
6437 +               break;
6438 +
6439 +       default:
6440 +               base = PM_CFG_IOBASE1;
6441 +               /* later revision */
6442 +       }
6443 +
6444 +       pci_read_config_word(dev, base, &pm_io_base);
6445 +       pm_io_base &= (0xff << 8);
6446 +
6447 +       if (!request_region(I2C_DIR, IOSPACE, IOTEXT)) {
6448 +               dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE);
6449 +               return -ENODEV;
6450 +       }
6451 +
6452 +       outb(inb(I2C_DIR) & ~(I2C_SDA | I2C_SCL), I2C_DIR);
6453 +       outb(inb(I2C_OUT) & ~(I2C_SDA | I2C_SCL), I2C_OUT);
6454 +
6455 +       /* set up the driverfs linkage to our parent device */
6456 +       vt586b_adapter.dev.parent = &dev->dev;
6457 +
6458 +       res = i2c_bit_add_bus(&vt586b_adapter);
6459 +       if ( res < 0 ) {
6460 +               release_region(I2C_DIR, IOSPACE);
6461 +               pm_io_base = 0;
6462 +               return res;
6463 +       }
6464 +       return 0;
6465 +}
6466 +
6467 +static void __devexit vt586b_remove(struct pci_dev *dev)
6468 +{
6469 +       i2c_bit_del_bus(&vt586b_adapter);
6470 +       release_region(I2C_DIR, IOSPACE);
6471 +       pm_io_base = 0;
6472 +}
6473 +
6474 +
6475 +static struct pci_driver vt586b_driver = {
6476 +       .name           = "vt586b smbus",
6477 +       .id_table       = vt586b_ids,
6478 +       .probe          = vt586b_probe,
6479 +       .remove         = __devexit_p(vt586b_remove),
6480 +};
6481 +
6482 +static int __init i2c_vt586b_init(void)
6483 +{
6484 +       return pci_module_init(&vt586b_driver);
6485 +}
6486 +
6487 +static void __exit i2c_vt586b_exit(void)
6488 +{
6489 +       pci_unregister_driver(&vt586b_driver);
6490 +}
6491 +
6492 +
6493 +MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>");
6494 +MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge");
6495 +MODULE_LICENSE("GPL");
6496 +
6497 +module_init(i2c_vt586b_init);
6498 +module_exit(i2c_vt586b_exit);
6499 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-viapro.c i2c-2.5/drivers/i2c/busses/i2c-viapro.c
6500 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-viapro.c   Mon Sep  8 19:50:18 2003
6501 +++ i2c-2.5/drivers/i2c/busses/i2c-viapro.c     Tue Sep 23 10:12:59 2003
6502 @@ -287,7 +287,6 @@
6503  
6504  static struct i2c_adapter vt596_adapter = {
6505         .owner          = THIS_MODULE,
6506 -       .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
6507         .class          = I2C_ADAP_CLASS_SMBUS,
6508         .algo           = &smbus_algorithm,
6509         .name           = "unset",
6510 @@ -376,7 +375,7 @@
6511         dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
6512  
6513         vt596_adapter.dev.parent = &pdev->dev;
6514 -       snprintf(vt596_adapter.name, DEVICE_NAME_SIZE,
6515 +       snprintf(vt596_adapter.name, I2C_NAME_SIZE,
6516                         "SMBus Via Pro adapter at %04x", vt596_smba);
6517         
6518         return i2c_add_adapter(&vt596_adapter);
6519 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/i2c-voodoo3.c i2c-2.5/drivers/i2c/busses/i2c-voodoo3.c
6520 --- linux-2.6.0-test5/drivers/i2c/busses/i2c-voodoo3.c  Thu Jan  1 00:00:00 1970
6521 +++ i2c-2.5/drivers/i2c/busses/i2c-voodoo3.c    Tue Sep 23 10:12:59 2003
6522 @@ -0,0 +1,248 @@
6523 +/*
6524 +    voodoo3.c - Part of lm_sensors, Linux kernel modules for hardware
6525 +              monitoring
6526 +    Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>,
6527 +    Philip Edelbrock <phil@netroedge.com>,
6528 +    Ralph Metzler <rjkm@thp.uni-koeln.de>, and
6529 +    Mark D. Studebaker <mdsxyz123@yahoo.com>
6530 +    
6531 +    Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
6532 +    Simon Vogl
6533 +
6534 +    This program is free software; you can redistribute it and/or modify
6535 +    it under the terms of the GNU General Public License as published by
6536 +    the Free Software Foundation; either version 2 of the License, or
6537 +    (at your option) any later version.
6538 +
6539 +    This program is distributed in the hope that it will be useful,
6540 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
6541 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6542 +    GNU General Public License for more details.
6543 +
6544 +    You should have received a copy of the GNU General Public License
6545 +    along with this program; if not, write to the Free Software
6546 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6547 +*/
6548 +
6549 +/* This interfaces to the I2C bus of the Voodoo3 to gain access to
6550 +    the BT869 and possibly other I2C devices. */
6551 +
6552 +#include <linux/kernel.h>
6553 +#include <linux/module.h>
6554 +#include <linux/init.h>
6555 +#include <linux/pci.h>
6556 +#include <linux/i2c.h>
6557 +#include <linux/i2c-algo-bit.h>
6558 +
6559 +/* the only registers we use */
6560 +#define REG            0x78
6561 +#define REG2           0x70
6562 +
6563 +/* bit locations in the register */
6564 +#define DDC_ENAB       0x00040000
6565 +#define DDC_SCL_OUT    0x00080000
6566 +#define DDC_SDA_OUT    0x00100000
6567 +#define DDC_SCL_IN     0x00200000
6568 +#define DDC_SDA_IN     0x00400000
6569 +#define I2C_ENAB       0x00800000
6570 +#define I2C_SCL_OUT    0x01000000
6571 +#define I2C_SDA_OUT    0x02000000
6572 +#define I2C_SCL_IN     0x04000000
6573 +#define I2C_SDA_IN     0x08000000
6574 +
6575 +/* initialization states */
6576 +#define INIT2          0x2
6577 +#define INIT3          0x4
6578 +
6579 +/* delays */
6580 +#define CYCLE_DELAY    10
6581 +#define TIMEOUT                (HZ / 2)
6582 +
6583 +
6584 +static void *ioaddr;
6585 +
6586 +/* The voo GPIO registers don't have individual masks for each bit
6587 +   so we always have to read before writing. */
6588 +
6589 +static void bit_vooi2c_setscl(void *data, int val)
6590 +{
6591 +       unsigned int r;
6592 +       r = readl(ioaddr + REG);
6593 +       if (val)
6594 +               r |= I2C_SCL_OUT;
6595 +       else
6596 +               r &= ~I2C_SCL_OUT;
6597 +       writel(r, ioaddr + REG);
6598 +       readl(ioaddr + REG);    /* flush posted write */
6599 +}
6600 +
6601 +static void bit_vooi2c_setsda(void *data, int val)
6602 +{
6603 +       unsigned int r;
6604 +       r = readl(ioaddr + REG);
6605 +       if (val)
6606 +               r |= I2C_SDA_OUT;
6607 +       else
6608 +               r &= ~I2C_SDA_OUT;
6609 +       writel(r, ioaddr + REG);
6610 +       readl(ioaddr + REG);    /* flush posted write */
6611 +}
6612 +
6613 +/* The GPIO pins are open drain, so the pins always remain outputs.
6614 +   We rely on the i2c-algo-bit routines to set the pins high before
6615 +   reading the input from other chips. */
6616 +
6617 +static int bit_vooi2c_getscl(void *data)
6618 +{
6619 +       return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
6620 +}
6621 +
6622 +static int bit_vooi2c_getsda(void *data)
6623 +{
6624 +       return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
6625 +}
6626 +
6627 +static void bit_vooddc_setscl(void *data, int val)
6628 +{
6629 +       unsigned int r;
6630 +       r = readl(ioaddr + REG);
6631 +       if (val)
6632 +               r |= DDC_SCL_OUT;
6633 +       else
6634 +               r &= ~DDC_SCL_OUT;
6635 +       writel(r, ioaddr + REG);
6636 +       readl(ioaddr + REG);    /* flush posted write */
6637 +}
6638 +
6639 +static void bit_vooddc_setsda(void *data, int val)
6640 +{
6641 +       unsigned int r;
6642 +       r = readl(ioaddr + REG);
6643 +       if (val)
6644 +               r |= DDC_SDA_OUT;
6645 +       else
6646 +               r &= ~DDC_SDA_OUT;
6647 +       writel(r, ioaddr + REG);
6648 +       readl(ioaddr + REG);    /* flush posted write */
6649 +}
6650 +
6651 +static int bit_vooddc_getscl(void *data)
6652 +{
6653 +       return (0 != (readl(ioaddr + REG) & DDC_SCL_IN));
6654 +}
6655 +
6656 +static int bit_vooddc_getsda(void *data)
6657 +{
6658 +       return (0 != (readl(ioaddr + REG) & DDC_SDA_IN));
6659 +}
6660 +
6661 +static int config_v3(struct pci_dev *dev)
6662 +{
6663 +       unsigned int cadr;
6664 +
6665 +       /* map Voodoo3 memory */
6666 +       cadr = dev->resource[0].start;
6667 +       cadr &= PCI_BASE_ADDRESS_MEM_MASK;
6668 +       ioaddr = ioremap_nocache(cadr, 0x1000);
6669 +       if (ioaddr) {
6670 +               writel(0x8160, ioaddr + REG2);
6671 +               writel(0xcffc0020, ioaddr + REG);
6672 +               dev_info(&dev->dev, "Using Banshee/Voodoo3 I2C device at %p\n", ioaddr);
6673 +               return 0;
6674 +       }
6675 +       return -ENODEV;
6676 +}
6677 +
6678 +static struct i2c_algo_bit_data voo_i2c_bit_data = {
6679 +       .setsda         = bit_vooi2c_setsda,
6680 +       .setscl         = bit_vooi2c_setscl,
6681 +       .getsda         = bit_vooi2c_getsda,
6682 +       .getscl         = bit_vooi2c_getscl,
6683 +       .udelay         = CYCLE_DELAY,
6684 +       .mdelay         = CYCLE_DELAY,
6685 +       .timeout        = TIMEOUT
6686 +};
6687 +
6688 +static struct i2c_adapter voodoo3_i2c_adapter = {
6689 +       .owner          = THIS_MODULE,
6690 +       .name           = "I2C Voodoo3/Banshee adapter",
6691 +       .algo_data      = &voo_i2c_bit_data,
6692 +};
6693 +
6694 +static struct i2c_algo_bit_data voo_ddc_bit_data = {
6695 +       .setsda         = bit_vooddc_setsda,
6696 +       .setscl         = bit_vooddc_setscl,
6697 +       .getsda         = bit_vooddc_getsda,
6698 +       .getscl         = bit_vooddc_getscl,
6699 +       .udelay         = CYCLE_DELAY,
6700 +       .mdelay         = CYCLE_DELAY,
6701 +       .timeout        = TIMEOUT
6702 +};
6703 +
6704 +static struct i2c_adapter voodoo3_ddc_adapter = {
6705 +       .owner          = THIS_MODULE,
6706 +       .name           = "DDC Voodoo3/Banshee adapter",
6707 +       .algo_data      = &voo_ddc_bit_data,
6708 +};
6709 +
6710 +static struct pci_device_id voodoo3_ids[] __devinitdata = {
6711 +       { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3) },
6712 +       { PCI_DEVICE(PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE) },
6713 +       { 0, }
6714 +};
6715 +
6716 +static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_id *id)
6717 +{
6718 +       int retval;
6719 +
6720 +       retval = config_v3(dev);
6721 +       if (retval)
6722 +               return retval;
6723 +
6724 +       /* set up the sysfs linkage to our parent device */
6725 +       voodoo3_i2c_adapter.dev.parent = &dev->dev;
6726 +       voodoo3_ddc_adapter.dev.parent = &dev->dev;
6727 +
6728 +       retval = i2c_bit_add_bus(&voodoo3_i2c_adapter);
6729 +       if (retval)
6730 +               return retval;
6731 +       retval = i2c_bit_add_bus(&voodoo3_ddc_adapter);
6732 +       if (retval)
6733 +               i2c_bit_del_bus(&voodoo3_i2c_adapter);
6734 +       return retval;
6735 +}
6736 +
6737 +static void __devexit voodoo3_remove(struct pci_dev *dev)
6738 +{
6739 +       i2c_bit_del_bus(&voodoo3_i2c_adapter);
6740 +       i2c_bit_del_bus(&voodoo3_ddc_adapter);
6741 +       iounmap(ioaddr);
6742 +}
6743 +
6744 +static struct pci_driver voodoo3_driver = {
6745 +       .name           = "voodoo3 smbus",
6746 +       .id_table       = voodoo3_ids,
6747 +       .probe          = voodoo3_probe,
6748 +       .remove         = __devexit_p(voodoo3_remove),
6749 +};
6750 +
6751 +static int __init i2c_voodoo3_init(void)
6752 +{
6753 +       return pci_module_init(&voodoo3_driver);
6754 +}
6755 +
6756 +static void __exit i2c_voodoo3_exit(void)
6757 +{
6758 +       pci_unregister_driver(&voodoo3_driver);
6759 +}
6760 +
6761 +
6762 +MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
6763 +               "Philip Edelbrock <phil@netroedge.com>, "
6764 +               "Ralph Metzler <rjkm@thp.uni-koeln.de>, "
6765 +               "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
6766 +MODULE_DESCRIPTION("Voodoo3 I2C/SMBus driver");
6767 +MODULE_LICENSE("GPL");
6768 +
6769 +module_init(i2c_voodoo3_init);
6770 +module_exit(i2c_voodoo3_exit);
6771 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/scx200_acb.c i2c-2.5/drivers/i2c/busses/scx200_acb.c
6772 --- linux-2.6.0-test5/drivers/i2c/busses/scx200_acb.c   Thu Jan  1 00:00:00 1970
6773 +++ i2c-2.5/drivers/i2c/busses/scx200_acb.c     Tue Sep 23 10:12:59 2003
6774 @@ -0,0 +1,553 @@
6775 +/*  linux/drivers/i2c/scx200_acb.c 
6776 +
6777 +    Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
6778 +
6779 +    National Semiconductor SCx200 ACCESS.bus support
6780 +    
6781 +    Based on i2c-keywest.c which is:
6782 +        Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
6783 +        Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
6784 +    
6785 +    This program is free software; you can redistribute it and/or
6786 +    modify it under the terms of the GNU General Public License as
6787 +    published by the Free Software Foundation; either version 2 of the
6788 +    License, or (at your option) any later version.
6789 +   
6790 +    This program is distributed in the hope that it will be useful,
6791 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
6792 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6793 +    General Public License for more details.
6794 +   
6795 +    You should have received a copy of the GNU General Public License
6796 +    along with this program; if not, write to the Free Software
6797 +    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6798 +
6799 +*/
6800 +
6801 +#include <linux/config.h>
6802 +#include <linux/module.h>
6803 +#include <linux/errno.h>
6804 +#include <linux/kernel.h>
6805 +#include <linux/init.h>
6806 +#include <linux/i2c.h>
6807 +#include <linux/smp_lock.h>
6808 +#include <linux/pci.h>
6809 +#include <asm/io.h>
6810 +
6811 +#include <linux/scx200.h>
6812 +
6813 +#define NAME "scx200_acb"
6814 +
6815 +MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
6816 +MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver");
6817 +MODULE_LICENSE("GPL");
6818 +
6819 +#define MAX_DEVICES 4
6820 +static int base[MAX_DEVICES] = { 0x840 };
6821 +MODULE_PARM(base, "1-4i");
6822 +MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
6823 +
6824 +#define DEBUG 0
6825 +
6826 +#if DEBUG
6827 +#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
6828 +#else
6829 +#define DBG(x...)
6830 +#endif
6831 +
6832 +/* The hardware supports interrupt driven mode too, but I haven't
6833 +   implemented that. */
6834 +#define POLLED_MODE 1
6835 +#define POLL_TIMEOUT (HZ)
6836 +
6837 +enum scx200_acb_state {
6838 +       state_idle,
6839 +       state_address,
6840 +       state_command,
6841 +       state_repeat_start,
6842 +       state_quick,
6843 +       state_read,
6844 +       state_write,
6845 +};
6846 +
6847 +static const char *scx200_acb_state_name[] = {
6848 +       "idle",
6849 +       "address",
6850 +       "command",
6851 +       "repeat_start",
6852 +       "quick",
6853 +       "read",
6854 +       "write",
6855 +};
6856 +
6857 +/* Physical interface */
6858 +struct scx200_acb_iface
6859 +{
6860 +       struct scx200_acb_iface *next;
6861 +       struct i2c_adapter adapter;
6862 +       unsigned base;
6863 +       struct semaphore sem;
6864 +
6865 +       /* State machine data */
6866 +       enum scx200_acb_state state;
6867 +       int result;
6868 +       u8 address_byte;
6869 +       u8 command;
6870 +       u8 *ptr;
6871 +       char needs_reset;
6872 +       unsigned len;
6873 +};
6874 +
6875 +/* Register Definitions */
6876 +#define ACBSDA         (iface->base + 0)
6877 +#define ACBST          (iface->base + 1)
6878 +#define    ACBST_SDAST         0x40 /* SDA Status */
6879 +#define    ACBST_BER           0x20 
6880 +#define    ACBST_NEGACK                0x10 /* Negative Acknowledge */
6881 +#define    ACBST_STASTR                0x08 /* Stall After Start */
6882 +#define    ACBST_MASTER                0x02
6883 +#define ACBCST         (iface->base + 2)
6884 +#define    ACBCST_BB           0x02
6885 +#define ACBCTL1                (iface->base + 3)
6886 +#define    ACBCTL1_STASTRE     0x80
6887 +#define    ACBCTL1_NMINTE      0x40
6888 +#define           ACBCTL1_ACK          0x10
6889 +#define           ACBCTL1_STOP         0x02
6890 +#define           ACBCTL1_START        0x01
6891 +#define ACBADDR                (iface->base + 4)
6892 +#define ACBCTL2                (iface->base + 5)
6893 +#define    ACBCTL2_ENABLE      0x01
6894 +
6895 +/************************************************************************/
6896 +
6897 +static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
6898 +{
6899 +       const char *errmsg;
6900 +
6901 +       DBG("state %s, status = 0x%02x\n", 
6902 +           scx200_acb_state_name[iface->state], status);
6903 +
6904 +       if (status & ACBST_BER) {
6905 +               errmsg = "bus error";
6906 +               goto error;
6907 +       }
6908 +       if (!(status & ACBST_MASTER)) {
6909 +               errmsg = "not master";
6910 +               goto error;
6911 +       }
6912 +       if (status & ACBST_NEGACK)
6913 +               goto negack;
6914 +
6915 +       switch (iface->state) {
6916 +       case state_idle:
6917 +               dev_warn(&iface->adapter.dev, "interrupt in idle state\n");
6918 +               break;
6919 +
6920 +       case state_address:
6921 +               /* Do a pointer write first */
6922 +               outb(iface->address_byte & ~1, ACBSDA);
6923 +
6924 +               iface->state = state_command;
6925 +               break;
6926 +
6927 +       case state_command:
6928 +               outb(iface->command, ACBSDA);
6929 +
6930 +               if (iface->address_byte & 1)
6931 +                       iface->state = state_repeat_start;
6932 +               else
6933 +                       iface->state = state_write;
6934 +               break;
6935 +
6936 +       case state_repeat_start:
6937 +               outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
6938 +               /* fallthrough */
6939 +               
6940 +       case state_quick:
6941 +               if (iface->address_byte & 1) {
6942 +                       if (iface->len == 1) 
6943 +                               outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
6944 +                       else
6945 +                               outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
6946 +                       outb(iface->address_byte, ACBSDA);
6947 +
6948 +                       iface->state = state_read;
6949 +               } else {
6950 +                       outb(iface->address_byte, ACBSDA);
6951 +
6952 +                       iface->state = state_write;
6953 +               }
6954 +               break;
6955 +
6956 +       case state_read:
6957 +               /* Set ACK if receiving the last byte */
6958 +               if (iface->len == 1)
6959 +                       outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
6960 +               else
6961 +                       outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
6962 +
6963 +               *iface->ptr++ = inb(ACBSDA);
6964 +               --iface->len;
6965 +
6966 +               if (iface->len == 0) {
6967 +                       iface->result = 0;
6968 +                       iface->state = state_idle;
6969 +                       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6970 +               }
6971 +
6972 +               break;
6973 +
6974 +       case state_write:
6975 +               if (iface->len == 0) {
6976 +                       iface->result = 0;
6977 +                       iface->state = state_idle;
6978 +                       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6979 +                       break;
6980 +               }
6981 +               
6982 +               outb(*iface->ptr++, ACBSDA);
6983 +               --iface->len;
6984 +               
6985 +               break;
6986 +       }
6987 +
6988 +       return;
6989 +
6990 + negack:
6991 +       DBG("negative acknowledge in state %s\n", 
6992 +           scx200_acb_state_name[iface->state]);
6993 +
6994 +       iface->state = state_idle;
6995 +       iface->result = -ENXIO;
6996 +
6997 +       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6998 +       outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
6999 +       return;
7000 +
7001 + error:
7002 +       dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
7003 +               scx200_acb_state_name[iface->state]);
7004 +
7005 +       iface->state = state_idle;
7006 +       iface->result = -EIO;
7007 +       iface->needs_reset = 1;
7008 +}
7009 +
7010 +static void scx200_acb_timeout(struct scx200_acb_iface *iface) 
7011 +{
7012 +       dev_err(&iface->adapter.dev, "timeout in state %s\n",
7013 +               scx200_acb_state_name[iface->state]);
7014 +
7015 +       iface->state = state_idle;
7016 +       iface->result = -EIO;
7017 +       iface->needs_reset = 1;
7018 +}
7019 +
7020 +#ifdef POLLED_MODE
7021 +static void scx200_acb_poll(struct scx200_acb_iface *iface)
7022 +{
7023 +       u8 status = 0;
7024 +       unsigned long timeout;
7025 +
7026 +       timeout = jiffies + POLL_TIMEOUT;
7027 +       while (time_before(jiffies, timeout)) {
7028 +               status = inb(ACBST);
7029 +               if ((status & (ACBST_SDAST|ACBST_BER|ACBST_NEGACK)) != 0) {
7030 +                       scx200_acb_machine(iface, status);
7031 +                       return;
7032 +               }
7033 +               schedule_timeout(HZ/100+1);
7034 +       }
7035 +
7036 +       scx200_acb_timeout(iface);
7037 +}
7038 +#endif /* POLLED_MODE */
7039 +
7040 +static void scx200_acb_reset(struct scx200_acb_iface *iface)
7041 +{
7042 +       /* Disable the ACCESS.bus device and Configure the SCL
7043 +           frequency: 16 clock cycles */
7044 +       outb(0x70, ACBCTL2);
7045 +       /* Polling mode */
7046 +       outb(0, ACBCTL1);
7047 +       /* Disable slave address */
7048 +       outb(0, ACBADDR);
7049 +       /* Enable the ACCESS.bus device */
7050 +       outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
7051 +       /* Free STALL after START */
7052 +       outb(inb(ACBCTL1) & ~(ACBCTL1_STASTRE | ACBCTL1_NMINTE), ACBCTL1);
7053 +       /* Send a STOP */
7054 +       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
7055 +       /* Clear BER, NEGACK and STASTR bits */
7056 +       outb(ACBST_BER | ACBST_NEGACK | ACBST_STASTR, ACBST);
7057 +       /* Clear BB bit */
7058 +       outb(inb(ACBCST) | ACBCST_BB, ACBCST);
7059 +}
7060 +
7061 +static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
7062 +                               u16 address, unsigned short flags,      
7063 +                               char rw, u8 command, int size, 
7064 +                               union i2c_smbus_data *data)
7065 +{
7066 +       struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
7067 +       int len;
7068 +       u8 *buffer;
7069 +       u16 cur_word;
7070 +       int rc;
7071 +
7072 +       switch (size) {
7073 +       case I2C_SMBUS_QUICK:
7074 +               len = 0;
7075 +               buffer = NULL;
7076 +               break;
7077 +       case I2C_SMBUS_BYTE:
7078 +               if (rw == I2C_SMBUS_READ) {
7079 +                       len = 1;
7080 +                       buffer = &data->byte;
7081 +               } else {
7082 +                       len = 1;
7083 +                       buffer = &command;
7084 +               }
7085 +               break;
7086 +       case I2C_SMBUS_BYTE_DATA:
7087 +               len = 1;
7088 +               buffer = &data->byte;
7089 +               break;
7090 +       case I2C_SMBUS_WORD_DATA:
7091 +               len = 2;
7092 +               cur_word = cpu_to_le16(data->word);
7093 +               buffer = (u8 *)&cur_word;
7094 +               break;
7095 +       case I2C_SMBUS_BLOCK_DATA:
7096 +               len = data->block[0];
7097 +               buffer = &data->block[1];
7098 +               break;
7099 +       default:
7100 +               return -EINVAL;
7101 +       }
7102 +
7103 +       DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
7104 +           size, address, command, len, rw == I2C_SMBUS_READ);
7105 +
7106 +       if (!len && rw == I2C_SMBUS_READ) {
7107 +               dev_warn(&adapter->dev, "zero length read\n");
7108 +               return -EINVAL;
7109 +       }
7110 +
7111 +       if (len && !buffer) {
7112 +               dev_warn(&adapter->dev, "nonzero length but no buffer\n");
7113 +               return -EFAULT;
7114 +       }
7115 +
7116 +       down(&iface->sem);
7117 +
7118 +       iface->address_byte = address<<1;
7119 +       if (rw == I2C_SMBUS_READ)
7120 +               iface->address_byte |= 1;
7121 +       iface->command = command;
7122 +       iface->ptr = buffer;
7123 +       iface->len = len;
7124 +       iface->result = -EINVAL;
7125 +       iface->needs_reset = 0;
7126 +
7127 +       outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
7128 +
7129 +       if (size == I2C_SMBUS_QUICK || size == I2C_SMBUS_BYTE)
7130 +               iface->state = state_quick;
7131 +       else
7132 +               iface->state = state_address;
7133 +
7134 +#ifdef POLLED_MODE
7135 +       while (iface->state != state_idle)
7136 +               scx200_acb_poll(iface);
7137 +#else /* POLLED_MODE */
7138 +#error Interrupt driven mode not implemented
7139 +#endif /* POLLED_MODE */       
7140 +
7141 +       if (iface->needs_reset)
7142 +               scx200_acb_reset(iface);
7143 +
7144 +       rc = iface->result;
7145 +
7146 +       up(&iface->sem);
7147 +
7148 +       if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
7149 +               data->word = le16_to_cpu(cur_word);
7150 +
7151 +#if DEBUG
7152 +       printk(KERN_DEBUG NAME ": transfer done, result: %d", rc);
7153 +       if (buffer) {
7154 +               int i;
7155 +               printk(" data:");
7156 +               for (i = 0; i < len; ++i)
7157 +                       printk(" %02x", buffer[i]);
7158 +       }
7159 +       printk("\n");
7160 +#endif
7161 +
7162 +       return rc;
7163 +}
7164 +
7165 +static u32 scx200_acb_func(struct i2c_adapter *adapter)
7166 +{
7167 +       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
7168 +              I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
7169 +              I2C_FUNC_SMBUS_BLOCK_DATA;
7170 +}
7171 +
7172 +/* For now, we only handle combined mode (smbus) */
7173 +static struct i2c_algorithm scx200_acb_algorithm = {
7174 +       .name           = "NatSemi SCx200 ACCESS.bus",
7175 +       .id             = I2C_ALGO_SMBUS,
7176 +       .smbus_xfer     = scx200_acb_smbus_xfer,
7177 +       .functionality  = scx200_acb_func,
7178 +};
7179 +
7180 +struct scx200_acb_iface *scx200_acb_list;
7181 +
7182 +int scx200_acb_probe(struct scx200_acb_iface *iface)
7183 +{
7184 +       u8 val;
7185 +
7186 +       /* Disable the ACCESS.bus device and Configure the SCL
7187 +           frequency: 16 clock cycles */
7188 +       outb(0x70, ACBCTL2);
7189 +
7190 +       if (inb(ACBCTL2) != 0x70) {
7191 +               DBG("ACBCTL2 readback failed\n");
7192 +               return -ENXIO;
7193 +       }
7194 +
7195 +       outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
7196 +
7197 +       val = inb(ACBCTL1);
7198 +       if (val) {
7199 +               DBG("disabled, but ACBCTL1=0x%02x\n", val);
7200 +               return -ENXIO;
7201 +       }
7202 +
7203 +       outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
7204 +
7205 +       outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
7206 +
7207 +       val = inb(ACBCTL1);
7208 +       if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) {
7209 +               DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val);
7210 +               return -ENXIO;
7211 +       }
7212 +
7213 +       return 0;
7214 +}
7215 +
7216 +static int  __init scx200_acb_create(int base, int index)
7217 +{
7218 +       struct scx200_acb_iface *iface;
7219 +       struct i2c_adapter *adapter;
7220 +       int rc = 0;
7221 +       char description[64];
7222 +
7223 +       iface = kmalloc(sizeof(*iface), GFP_KERNEL);
7224 +       if (!iface) {
7225 +               printk(KERN_ERR NAME ": can't allocate memory\n");
7226 +               rc = -ENOMEM;
7227 +               goto errout;
7228 +       }
7229 +
7230 +       memset(iface, 0, sizeof(*iface));
7231 +       adapter = &iface->adapter;
7232 +       i2c_set_adapdata(adapter, iface);
7233 +       snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
7234 +       adapter->owner = THIS_MODULE;
7235 +       adapter->id = I2C_ALGO_SMBUS;
7236 +       adapter->algo = &scx200_acb_algorithm;
7237 +
7238 +       init_MUTEX(&iface->sem);
7239 +
7240 +       snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name);
7241 +       if (request_region(base, 8, description) == 0) {
7242 +               dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n",
7243 +                       base, base + 8-1);
7244 +               rc = -EBUSY;
7245 +               goto errout;
7246 +       }
7247 +       iface->base = base;
7248 +
7249 +       rc = scx200_acb_probe(iface);
7250 +       if (rc) {
7251 +               dev_warn(&adapter->dev, "probe failed\n");
7252 +               goto errout;
7253 +       }
7254 +
7255 +       scx200_acb_reset(iface);
7256 +
7257 +       if (i2c_add_adapter(adapter) < 0) {
7258 +               dev_err(&adapter->dev, "failed to register\n");
7259 +               rc = -ENODEV;
7260 +               goto errout;
7261 +       }
7262 +
7263 +       lock_kernel();
7264 +       iface->next = scx200_acb_list;
7265 +       scx200_acb_list = iface;
7266 +       unlock_kernel();
7267 +
7268 +       return 0;
7269 +
7270 + errout:
7271 +       if (iface) {
7272 +               if (iface->base)
7273 +                       release_region(iface->base, 8);
7274 +               kfree(iface);
7275 +       }
7276 +       return rc;
7277 +}
7278 +
7279 +static int __init scx200_acb_init(void)
7280 +{
7281 +       int i;
7282 +       int rc;
7283 +
7284 +       printk(KERN_DEBUG NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
7285 +
7286 +       /* Verify that this really is a SCx200 processor */
7287 +       if (pci_find_device(PCI_VENDOR_ID_NS,
7288 +                           PCI_DEVICE_ID_NS_SCx200_BRIDGE,
7289 +                           NULL) == NULL)
7290 +               return -ENODEV;
7291 +
7292 +       rc = -ENXIO;
7293 +       for (i = 0; i < MAX_DEVICES; ++i) {
7294 +               if (base[i] > 0)
7295 +                       rc = scx200_acb_create(base[i], i);
7296 +       }
7297 +       if (scx200_acb_list)
7298 +               return 0;
7299 +       return rc;
7300 +}
7301 +
7302 +static void __exit scx200_acb_cleanup(void)
7303 +{
7304 +       struct scx200_acb_iface *iface;
7305 +       lock_kernel();
7306 +       while ((iface = scx200_acb_list) != NULL) {
7307 +               scx200_acb_list = iface->next;
7308 +               unlock_kernel();
7309 +
7310 +               i2c_del_adapter(&iface->adapter);
7311 +               release_region(iface->base, 8);
7312 +               kfree(iface);
7313 +               lock_kernel();
7314 +       }
7315 +       unlock_kernel();
7316 +}
7317 +
7318 +module_init(scx200_acb_init);
7319 +module_exit(scx200_acb_cleanup);
7320 +
7321 +/*
7322 +    Local variables:
7323 +        compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
7324 +        c-basic-offset: 8
7325 +    End:
7326 +*/
7327 +
7328 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/busses/scx200_i2c.c i2c-2.5/drivers/i2c/busses/scx200_i2c.c
7329 --- linux-2.6.0-test5/drivers/i2c/busses/scx200_i2c.c   Thu Jan  1 00:00:00 1970
7330 +++ i2c-2.5/drivers/i2c/busses/scx200_i2c.c     Tue Sep 23 10:12:59 2003
7331 @@ -0,0 +1,132 @@
7332 +/* linux/drivers/i2c/scx200_i2c.c 
7333 +
7334 +   Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
7335 +
7336 +   National Semiconductor SCx200 I2C bus on GPIO pins
7337 +
7338 +   Based on i2c-velleman.c Copyright (C) 1995-96, 2000 Simon G. Vogl
7339 +
7340 +   This program is free software; you can redistribute it and/or modify
7341 +   it under the terms of the GNU General Public License as published by
7342 +   the Free Software Foundation; either version 2 of the License, or
7343 +   (at your option) any later version.
7344 +   
7345 +   This program is distributed in the hope that it will be useful,
7346 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
7347 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7348 +   GNU General Public License for more details.
7349 +   
7350 +   You should have received a copy of the GNU General Public License
7351 +   along with this program; if not, write to the Free Software
7352 +   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                
7353 +*/
7354 +
7355 +#include <linux/config.h>
7356 +#include <linux/module.h>
7357 +#include <linux/errno.h>
7358 +#include <linux/kernel.h>
7359 +#include <linux/init.h>
7360 +#include <linux/i2c.h>
7361 +#include <linux/i2c-algo-bit.h>
7362 +#include <asm/io.h>
7363 +
7364 +#include <linux/scx200_gpio.h>
7365 +
7366 +#define NAME "scx200_i2c"
7367 +
7368 +MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
7369 +MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver");
7370 +MODULE_LICENSE("GPL");
7371 +
7372 +MODULE_PARM(scl, "i");
7373 +MODULE_PARM_DESC(scl, "GPIO line for SCL");
7374 +MODULE_PARM(sda, "i");
7375 +MODULE_PARM_DESC(sda, "GPIO line for SDA");
7376 +
7377 +static int scl = CONFIG_SCx200_I2C_SCL;
7378 +static int sda = CONFIG_SCx200_I2C_SDA;
7379 +
7380 +static void scx200_i2c_setscl(void *data, int state)
7381 +{
7382 +       scx200_gpio_set(scl, state);
7383 +}
7384 +
7385 +static void scx200_i2c_setsda(void *data, int state)
7386 +{
7387 +       scx200_gpio_set(sda, state);
7388 +} 
7389 +
7390 +static int scx200_i2c_getscl(void *data)
7391 +{
7392 +       return scx200_gpio_get(scl);
7393 +}
7394 +
7395 +static int scx200_i2c_getsda(void *data)
7396 +{
7397 +       return scx200_gpio_get(sda);
7398 +}
7399 +
7400 +/* ------------------------------------------------------------------------
7401 + * Encapsulate the above functions in the correct operations structure.
7402 + * This is only done when more than one hardware adapter is supported.
7403 + */
7404 +
7405 +static struct i2c_algo_bit_data scx200_i2c_data = {
7406 +       NULL,
7407 +       scx200_i2c_setsda,
7408 +       scx200_i2c_setscl,
7409 +       scx200_i2c_getsda,
7410 +       scx200_i2c_getscl,
7411 +       10, 10, 100,            /* waits, timeout */
7412 +};
7413 +
7414 +static struct i2c_adapter scx200_i2c_ops = {
7415 +       .owner             = THIS_MODULE,
7416 +       .algo_data         = &scx200_i2c_data,
7417 +       .name   = "NatSemi SCx200 I2C",
7418 +};
7419 +
7420 +int scx200_i2c_init(void)
7421 +{
7422 +       printk(KERN_DEBUG NAME ": NatSemi SCx200 I2C Driver\n");
7423 +
7424 +       if (!scx200_gpio_present()) {
7425 +               printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");
7426 +               return -ENODEV;
7427 +       }
7428 +
7429 +       printk(KERN_DEBUG NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", 
7430 +              scl, sda);
7431 +
7432 +       if (scl == -1 || sda == -1 || scl == sda) {
7433 +               printk(KERN_ERR NAME ": scl and sda must be specified\n");
7434 +               return -EINVAL;
7435 +       }
7436 +
7437 +       /* Configure GPIOs as open collector outputs */
7438 +       scx200_gpio_configure(scl, ~2, 5);
7439 +       scx200_gpio_configure(sda, ~2, 5);
7440 +
7441 +       if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) {
7442 +               printk(KERN_ERR NAME ": adapter %s registration failed\n", 
7443 +                      scx200_i2c_ops.name);
7444 +               return -ENODEV;
7445 +       }
7446 +       
7447 +       return 0;
7448 +}
7449 +
7450 +void scx200_i2c_cleanup(void)
7451 +{
7452 +       i2c_bit_del_bus(&scx200_i2c_ops);
7453 +}
7454 +
7455 +module_init(scx200_i2c_init);
7456 +module_exit(scx200_i2c_cleanup);
7457 +
7458 +/*
7459 +    Local variables:
7460 +        compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
7461 +        c-basic-offset: 8
7462 +    End:
7463 +*/
7464 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/Kconfig i2c-2.5/drivers/i2c/chips/Kconfig
7465 --- linux-2.6.0-test5/drivers/i2c/chips/Kconfig Mon Sep  8 19:50:06 2003
7466 +++ i2c-2.5/drivers/i2c/chips/Kconfig   Tue Sep 23 10:12:59 2003
7467 @@ -1,112 +1,93 @@
7468  #
7469 -# Sensor device configuration
7470 -# All depend on EXPERIMENTAL and I2C
7471 +# I2C Sensor device configuration
7472  #
7473  
7474  menu "I2C Hardware Sensors Chip support"
7475  
7476 +config I2C_SENSOR
7477 +       tristate
7478 +       default n
7479 +
7480  config SENSORS_ADM1021
7481 -       tristate "  Analog Devices ADM1021 and compatibles"
7482 +       tristate "Analog Devices ADM1021 and compatibles"
7483         depends on I2C && EXPERIMENTAL
7484 +       select I2C_SENSOR
7485         help
7486           If you say yes here you get support for Analog Devices ADM1021 
7487           and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
7488           Genesys Logic GL523SM, National Semi LM84, TI THMC10,
7489 -         and the XEON processor built-in sensor. This can also 
7490 -         be built as a module which can be inserted and removed while the 
7491 -         kernel is running.
7492 +         and the XEON processor built-in sensor.
7493  
7494 -         The module will be called adm1021.
7495 -         
7496 -         You will also need the latest user-space utilties: you can find them
7497 -         in the lm_sensors package, which you can download at 
7498 -         http://www.lm-sensors.nu
7499 +         This driver can also be built as a module.  If so, the module
7500 +         will be called adm1021.
7501  
7502  config SENSORS_IT87
7503 -       tristate "  National Semiconductors IT87 and compatibles"
7504 +       tristate "National Semiconductors IT87 and compatibles"
7505         depends on I2C && EXPERIMENTAL
7506 +       select I2C_SENSOR
7507         help
7508 -         The module will be called it87.
7509 +         If you say yes here you get support for National Semiconductor IT87
7510 +         sensor chips and clones: IT8705F, IT8712F and SiS960.
7511  
7512 -         You will also need the latest user-space utilties: you can find them
7513 -         in the lm_sensors package, which you can download at 
7514 -         http://www.lm-sensors.nu
7515 +         This driver can also be built as a module.  If so, the module
7516 +         will be called it87.
7517  
7518  config SENSORS_LM75
7519 -       tristate "  National Semiconductors LM75 and compatibles"
7520 +       tristate "National Semiconductors LM75 and compatibles"
7521         depends on I2C && EXPERIMENTAL
7522 +       select I2C_SENSOR
7523         help
7524           If you say yes here you get support for National Semiconductor LM75
7525           sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon
7526 -         TCN75, and National Semi LM77. This can also be built as a module
7527 -         which can be inserted and removed while the kernel is running.
7528 -
7529 -         The module will be called lm75.
7530 -
7531 -         You will also need the latest user-space utilties: you can find them
7532 -         in the lm_sensors package, which you can download at 
7533 -         http://www.lm-sensors.nu
7534 -         
7535 -config SENSORS_LM85
7536 -       tristate "  National Semiconductors LM85 and compatibles"
7537 -       depends on I2C && EXPERIMENTAL
7538 -       help
7539 -         If you say yes here you get support for National Semiconductor LM85
7540 -         sensor chips and clones: ADT7463 and ADM1027.
7541 -         This can also be built as a module which can be inserted and
7542 -         removed while the kernel is running.
7543 +         TCN75, and National Semi LM77.
7544  
7545 -         The module will be called lm85.
7546 +         This driver can also be built as a module.  If so, the module
7547 +         will be called lm75.
7548  
7549 -         You will also need the latest user-space utilties: you can find them
7550 -         in the lm_sensors package, which you can download at 
7551 -         http://www.lm-sensors.nu
7552 -         
7553  config SENSORS_LM78
7554 -       tristate "  National Semiconductors LM78 and compatibles"
7555 +       tristate "National Semiconductors LM78 and compatibles"
7556         depends on I2C && EXPERIMENTAL
7557 +       select I2C_SENSOR
7558         help
7559           If you say yes here you get support for National Semiconductor LM78,
7560           LM78-J and LM79.  This can also be built as a module which can be
7561           inserted and removed while the kernel is running.
7562  
7563 -         The module will be called lm78.
7564 +         This driver can also be built as a module.  If so, the module
7565 +         will be called lm78.
7566 +
7567 +config SENSORS_LM85
7568 +       tristate "National Semiconductors LM85 and compatibles"
7569 +       depends on I2C && EXPERIMENTAL
7570 +       select I2C_SENSOR
7571 +       help
7572 +         If you say yes here you get support for National Semiconductor LM85
7573 +         sensor chips and clones: ADT7463 and ADM1027.
7574 +
7575 +         This driver can also be built as a module.  If so, the module
7576 +         will be called lm85.
7577  
7578 -         You will also need the latest user-space utilties: you can find them
7579 -         in the lm_sensors package, which you can download at 
7580 -         http://www.lm-sensors.nu
7581 -         
7582  config SENSORS_VIA686A
7583 -       tristate "  VIA686A"
7584 +       tristate "VIA686A"
7585         depends on I2C && EXPERIMENTAL
7586 +       select I2C_SENSOR
7587         help
7588 -         support for via686a
7589           If you say yes here you get support for the integrated sensors in
7590 -         Via 686A/B South Bridges. This can also be built as a module
7591 -         which can be inserted and removed while the kernel is running.
7592 +         Via 686A/B South Bridges.
7593  
7594 -         You will also need the latest user-space utilties: you can find them
7595 -         in the lm_sensors package, which you can download at
7596 -         http://www.lm-sensors.nu
7597 +         This driver can also be built as a module.  If so, the module
7598 +         will be called via686a.
7599  
7600  config SENSORS_W83781D
7601 -       tristate "  Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
7602 +       tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
7603         depends on I2C && EXPERIMENTAL
7604 +       select I2C_SENSOR
7605         help
7606           If you say yes here you get support for the Winbond W8378x series
7607           of sensor chips: the W83781D, W83782D, W83783S and W83682HF,
7608 -         and the similar Asus AS99127F. This
7609 -         can also be built as a module which can be inserted and removed
7610 -         while the kernel is running.
7611 +         and the similar Asus AS99127F.
7612           
7613 -         You will also need the latest user-space utilties: you can find them
7614 -         in the lm_sensors package, which you can download at
7615 -         http://www.lm-sensors.nu
7616 -
7617 -config I2C_SENSOR
7618 -       tristate
7619 -       default y if SENSORS_ADM1021=y || SENSORS_IT87=y || SENSORS_LM75=y || SENSORS_VIA686A=y || SENSORS_W83781D=y || SENSORS_LM85=y
7620 -       default m if SENSORS_ADM1021=m || SENSORS_IT87=m || SENSORS_LM75=m || SENSORS_VIA686A=m || SENSORS_W83781D=m || SENSORS_LM85=m
7621 -       default n
7622 +         This driver can also be built as a module.  If so, the module
7623 +         will be called w83781d.
7624  
7625  endmenu
7626 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/adm1021.c i2c-2.5/drivers/i2c/chips/adm1021.c
7627 --- linux-2.6.0-test5/drivers/i2c/chips/adm1021.c       Mon Sep  8 19:49:51 2003
7628 +++ i2c-2.5/drivers/i2c/chips/adm1021.c Tue Sep 23 10:12:59 2003
7629 @@ -225,7 +225,6 @@
7630         struct adm1021_data *data;
7631         int err = 0;
7632         const char *type_name = "";
7633 -       const char *client_name = "";
7634  
7635         /* Make sure we aren't probing the ISA bus!! This is just a safety check
7636            at this moment; i2c_detect really won't call us. */
7637 @@ -291,28 +290,20 @@
7638  
7639         if (kind == max1617) {
7640                 type_name = "max1617";
7641 -               client_name = "MAX1617 chip";
7642         } else if (kind == max1617a) {
7643                 type_name = "max1617a";
7644 -               client_name = "MAX1617A chip";
7645         } else if (kind == adm1021) {
7646                 type_name = "adm1021";
7647 -               client_name = "ADM1021 chip";
7648         } else if (kind == adm1023) {
7649                 type_name = "adm1023";
7650 -               client_name = "ADM1023 chip";
7651         } else if (kind == thmc10) {
7652                 type_name = "thmc10";
7653 -               client_name = "THMC10 chip";
7654         } else if (kind == lm84) {
7655                 type_name = "lm84";
7656 -               client_name = "LM84 chip";
7657         } else if (kind == gl523sm) {
7658                 type_name = "gl523sm";
7659 -               client_name = "GL523SM chip";
7660         } else if (kind == mc1066) {
7661                 type_name = "mc1066";
7662 -               client_name = "MC1066 chip";
7663         } else {
7664                 dev_err(&adapter->dev, "Internal error: unknown kind (%d)?!?",
7665                         kind);
7666 @@ -320,7 +311,7 @@
7667         }
7668  
7669         /* Fill in the remaining client fields and put it into the global list */
7670 -       strlcpy(new_client->name, client_name, DEVICE_NAME_SIZE);
7671 +       strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
7672         data->type = kind;
7673  
7674         new_client->id = adm1021_id++;
7675 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/it87.c i2c-2.5/drivers/i2c/chips/it87.c
7676 --- linux-2.6.0-test5/drivers/i2c/chips/it87.c  Mon Sep  8 19:50:21 2003
7677 +++ i2c-2.5/drivers/i2c/chips/it87.c    Tue Sep 23 10:12:59 2003
7678 @@ -592,7 +592,6 @@
7679         struct it87_data *data;
7680         int err = 0;
7681         const char *name = "";
7682 -       const char *client_name = "";
7683         int is_isa = i2c_is_isa_adapter(adapter);
7684  
7685         if (!is_isa && 
7686 @@ -681,10 +680,8 @@
7687  
7688         if (kind == it87) {
7689                 name = "it87";
7690 -               client_name = "IT87 chip";
7691         } /* else if (kind == it8712) {
7692                 name = "it8712";
7693 -               client_name = "IT87-J chip";
7694         } */ else {
7695                 dev_dbg(&adapter->dev, "Internal error: unknown kind (%d)?!?",
7696                         kind);
7697 @@ -692,7 +689,7 @@
7698         }
7699  
7700         /* Fill in the remaining client fields and put it into the global list */
7701 -       strlcpy(new_client->name, name, DEVICE_NAME_SIZE);
7702 +       strlcpy(new_client->name, name, I2C_NAME_SIZE);
7703  
7704         data->type = kind;
7705  
7706 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/lm75.c i2c-2.5/drivers/i2c/chips/lm75.c
7707 --- linux-2.6.0-test5/drivers/i2c/chips/lm75.c  Mon Sep  8 19:49:51 2003
7708 +++ i2c-2.5/drivers/i2c/chips/lm75.c    Tue Sep 23 10:12:59 2003
7709 @@ -194,7 +194,7 @@
7710         }
7711  
7712         /* Fill in the remaining client fields and put it into the global list */
7713 -       strlcpy(new_client->name, name, DEVICE_NAME_SIZE);
7714 +       strlcpy(new_client->name, name, I2C_NAME_SIZE);
7715  
7716         new_client->id = lm75_id++;
7717         data->valid = 0;
7718 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/lm78.c i2c-2.5/drivers/i2c/chips/lm78.c
7719 --- linux-2.6.0-test5/drivers/i2c/chips/lm78.c  Mon Sep  8 19:50:22 2003
7720 +++ i2c-2.5/drivers/i2c/chips/lm78.c    Tue Sep 23 10:12:59 2003
7721 @@ -625,11 +625,11 @@
7722         }
7723  
7724         if (kind == lm78) {
7725 -               client_name = "LM78 chip";
7726 +               client_name = "lm78";
7727         } else if (kind == lm78j) {
7728 -               client_name = "LM78-J chip";
7729 +               client_name = "lm78-j";
7730         } else if (kind == lm79) {
7731 -               client_name = "LM79 chip";
7732 +               client_name = "lm79";
7733         } else {
7734                 dev_dbg(&adapter->dev, "Internal error: unknown kind (%d)?!?",
7735                         kind);
7736 @@ -638,7 +638,7 @@
7737         }
7738  
7739         /* Fill in the remaining client fields and put into the global list */
7740 -       strlcpy(new_client->name, client_name, DEVICE_NAME_SIZE);
7741 +       strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
7742         data->type = kind;
7743  
7744         data->valid = 0;
7745 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/lm85.c i2c-2.5/drivers/i2c/chips/lm85.c
7746 --- linux-2.6.0-test5/drivers/i2c/chips/lm85.c  Mon Sep  8 19:50:01 2003
7747 +++ i2c-2.5/drivers/i2c/chips/lm85.c    Tue Sep 23 10:12:59 2003
7748 @@ -853,24 +853,20 @@
7749         /* Fill in the chip specific driver values */
7750         if ( kind == any_chip ) {
7751                 type_name = "lm85";
7752 -               strlcpy(new_client->name, "Generic LM85", DEVICE_NAME_SIZE);
7753         } else if ( kind == lm85b ) {
7754                 type_name = "lm85b";
7755 -               strlcpy(new_client->name, "National LM85-B", DEVICE_NAME_SIZE);
7756         } else if ( kind == lm85c ) {
7757                 type_name = "lm85c";
7758 -               strlcpy(new_client->name, "National LM85-C", DEVICE_NAME_SIZE);
7759         } else if ( kind == adm1027 ) {
7760                 type_name = "adm1027";
7761 -               strlcpy(new_client->name, "Analog Devices ADM1027", DEVICE_NAME_SIZE);
7762         } else if ( kind == adt7463 ) {
7763                 type_name = "adt7463";
7764 -               strlcpy(new_client->name, "Analog Devices ADT7463", DEVICE_NAME_SIZE);
7765         } else {
7766                 dev_dbg(&adapter->dev, "Internal error, invalid kind (%d)!", kind);
7767                 err = -EFAULT ;
7768                 goto ERROR1;
7769         }
7770 +       strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
7771  
7772         /* Fill in the remaining client fields */
7773         new_client->id = lm85_id++;
7774 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/via686a.c i2c-2.5/drivers/i2c/chips/via686a.c
7775 --- linux-2.6.0-test5/drivers/i2c/chips/via686a.c       Mon Sep  8 19:49:53 2003
7776 +++ i2c-2.5/drivers/i2c/chips/via686a.c Tue Sep 23 10:12:59 2003
7777 @@ -671,7 +671,7 @@
7778         struct i2c_client *new_client;
7779         struct via686a_data *data;
7780         int err = 0;
7781 -       const char client_name[] = "via686a chip";
7782 +       const char client_name[] = "via686a";
7783         u16 val;
7784  
7785         /* Make sure we are probing the ISA bus!!  */
7786 @@ -727,7 +727,7 @@
7787         new_client->dev.parent = &adapter->dev;
7788  
7789         /* Fill in the remaining client fields and put into the global list */
7790 -       snprintf(new_client->name, DEVICE_NAME_SIZE, client_name);
7791 +       snprintf(new_client->name, I2C_NAME_SIZE, client_name);
7792  
7793         data->valid = 0;
7794         init_MUTEX(&data->update_lock);
7795 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/chips/w83781d.c i2c-2.5/drivers/i2c/chips/w83781d.c
7796 --- linux-2.6.0-test5/drivers/i2c/chips/w83781d.c       Mon Sep  8 19:49:50 2003
7797 +++ i2c-2.5/drivers/i2c/chips/w83781d.c Tue Sep 23 10:12:59 2003
7798 @@ -378,8 +378,8 @@
7799         struct w83781d_data *data = i2c_get_clientdata(client); \
7800         u32 val; \
7801          \
7802 -       val = simple_strtoul(buf, NULL, 10); \
7803 -       data->in_##reg[nr] = (IN_TO_REG(val) / 10); \
7804 +       val = simple_strtoul(buf, NULL, 10) / 10; \
7805 +       data->in_##reg[nr] = IN_TO_REG(val); \
7806         w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \
7807          \
7808         return count; \
7809 @@ -1098,15 +1098,15 @@
7810         }
7811  
7812         if (kind == w83781d)
7813 -               client_name = "W83781D subclient";
7814 +               client_name = "w83781d subclient";
7815         else if (kind == w83782d)
7816 -               client_name = "W83782D subclient";
7817 +               client_name = "w83782d subclient";
7818         else if (kind == w83783s)
7819 -               client_name = "W83783S subclient";
7820 +               client_name = "w83783s subclient";
7821         else if (kind == w83627hf)
7822 -               client_name = "W83627HF subclient";
7823 +               client_name = "w83627hf subclient";
7824         else if (kind == as99127f)
7825 -               client_name = "AS99127F subclient";
7826 +               client_name = "as99127f subclient";
7827         else
7828                 client_name = "unknown subclient?";
7829  
7830 @@ -1117,7 +1117,7 @@
7831                 data->lm75[i]->driver = &w83781d_driver;
7832                 data->lm75[i]->flags = 0;
7833                 strlcpy(data->lm75[i]->name, client_name,
7834 -                       DEVICE_NAME_SIZE);
7835 +                       I2C_NAME_SIZE);
7836                 if ((err = i2c_attach_client(data->lm75[i]))) {
7837                         dev_err(&new_client->dev, "Subclient %d "
7838                                 "registration at address 0x%x "
7839 @@ -1304,20 +1304,20 @@
7840         }
7841  
7842         if (kind == w83781d) {
7843 -               client_name = "W83781D chip";
7844 +               client_name = "w83781d";
7845         } else if (kind == w83782d) {
7846 -               client_name = "W83782D chip";
7847 +               client_name = "w83782d";
7848         } else if (kind == w83783s) {
7849 -               client_name = "W83783S chip";
7850 +               client_name = "w83783s";
7851         } else if (kind == w83627hf) {
7852                 if (val1 == 0x90)
7853 -                       client_name = "W83627THF chip";
7854 +                       client_name = "w83627thf";
7855                 else
7856 -                       client_name = "W83627HF chip";
7857 +                       client_name = "w83627hf";
7858         } else if (kind == as99127f) {
7859 -               client_name = "AS99127F chip";
7860 +               client_name = "as99127f";
7861         } else if (kind == w83697hf) {
7862 -               client_name = "W83697HF chip";
7863 +               client_name = "w83697hf";
7864         } else {
7865                 dev_err(&new_client->dev, "Internal error: unknown "
7866                                                 "kind (%d)?!?", kind);
7867 @@ -1326,7 +1326,7 @@
7868         }
7869  
7870         /* Fill in the remaining client fields and put into the global list */
7871 -       strlcpy(new_client->name, client_name, DEVICE_NAME_SIZE);
7872 +       strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
7873         data->type = kind;
7874  
7875         data->valid = 0;
7876 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-adap-ite.c i2c-2.5/drivers/i2c/i2c-adap-ite.c
7877 --- linux-2.6.0-test5/drivers/i2c/i2c-adap-ite.c        Mon Sep  8 19:49:58 2003
7878 +++ i2c-2.5/drivers/i2c/i2c-adap-ite.c  Thu Jan  1 00:00:00 1970
7879 @@ -1,279 +0,0 @@
7880 -/*
7881 -   -------------------------------------------------------------------------
7882 -   i2c-adap-ite.c i2c-hw access for the IIC peripheral on the ITE MIPS system
7883 -   -------------------------------------------------------------------------
7884 -   Hai-Pao Fan, MontaVista Software, Inc.
7885 -   hpfan@mvista.com or source@mvista.com
7886 -
7887 -   Copyright 2001 MontaVista Software Inc.
7888 -
7889 -   ----------------------------------------------------------------------------
7890 -   This file was highly leveraged from i2c-elektor.c, which was created
7891 -   by Simon G. Vogl and Hans Berglund:
7892 -
7893
7894 -     Copyright (C) 1995-97 Simon G. Vogl
7895 -                   1998-99 Hans Berglund
7896 -
7897 -    This program is free software; you can redistribute it and/or modify
7898 -    it under the terms of the GNU General Public License as published by
7899 -    the Free Software Foundation; either version 2 of the License, or
7900 -    (at your option) any later version.
7901 -
7902 -    This program is distributed in the hope that it will be useful,
7903 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
7904 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7905 -    GNU General Public License for more details.
7906 -
7907 -    You should have received a copy of the GNU General Public License
7908 -    along with this program; if not, write to the Free Software
7909 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
7910 -/* ------------------------------------------------------------------------- */
7911 -
7912 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
7913 -   Frodo Looijaard <frodol@dds.nl> */
7914 -
7915 -#include <linux/kernel.h>
7916 -#include <linux/ioport.h>
7917 -#include <linux/module.h>
7918 -#include <linux/delay.h>
7919 -#include <linux/slab.h>
7920 -#include <linux/version.h>
7921 -#include <linux/init.h>
7922 -#include <asm/irq.h>
7923 -#include <asm/io.h>
7924 -
7925 -#include <linux/i2c.h>
7926 -#include <linux/i2c-algo-ite.h>
7927 -#include <linux/i2c-adap-ite.h>
7928 -#include "i2c-ite.h"
7929 -
7930 -#define DEFAULT_BASE  0x14014030
7931 -#define ITE_IIC_IO_SIZE        0x40
7932 -#define DEFAULT_IRQ   0
7933 -#define DEFAULT_CLOCK 0x1b0e   /* default 16MHz/(27+14) = 400KHz */
7934 -#define DEFAULT_OWN   0x55
7935 -
7936 -static int base  = 0;
7937 -static int irq   = 0;
7938 -static int clock = 0;
7939 -static int own   = 0;
7940 -
7941 -static int i2c_debug=0;
7942 -static struct iic_ite gpi;
7943 -static wait_queue_head_t iic_wait;
7944 -static int iic_pending;
7945 -
7946 -/* ----- global defines -----------------------------------------------        */
7947 -#define DEB(x) if (i2c_debug>=1) x
7948 -#define DEB2(x) if (i2c_debug>=2) x
7949 -#define DEB3(x) if (i2c_debug>=3) x
7950 -#define DEBE(x)        x       /* error messages                               */
7951 -
7952 -
7953 -/* ----- local functions ----------------------------------------------        */
7954 -
7955 -static void iic_ite_setiic(void *data, int ctl, short val)
7956 -{
7957 -        unsigned long j = jiffies + 10;
7958 -
7959 -       DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
7960 -       DEB3({while (time_before(jiffies, j)) schedule();})
7961 -       outw(val,ctl);
7962 -}
7963 -
7964 -static short iic_ite_getiic(void *data, int ctl)
7965 -{
7966 -       short val;
7967 -
7968 -       val = inw(ctl);
7969 -       DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));  
7970 -       return (val);
7971 -}
7972 -
7973 -/* Return our slave address.  This is the address
7974 - * put on the I2C bus when another master on the bus wants to address us
7975 - * as a slave
7976 - */
7977 -static int iic_ite_getown(void *data)
7978 -{
7979 -       return (gpi.iic_own);
7980 -}
7981 -
7982 -
7983 -static int iic_ite_getclock(void *data)
7984 -{
7985 -       return (gpi.iic_clock);
7986 -}
7987 -
7988 -
7989 -#if 0
7990 -static void iic_ite_sleep(unsigned long timeout)
7991 -{
7992 -       schedule_timeout( timeout * HZ);
7993 -}
7994 -#endif
7995 -
7996 -
7997 -/* Put this process to sleep.  We will wake up when the
7998 - * IIC controller interrupts.
7999 - */
8000 -static void iic_ite_waitforpin(void) {
8001 -
8002 -   int timeout = 2;
8003 -
8004 -   /* If interrupts are enabled (which they are), then put the process to
8005 -    * sleep.  This process will be awakened by two events -- either the
8006 -    * the IIC peripheral interrupts or the timeout expires. 
8007 -    * If interrupts are not enabled then delay for a reasonable amount 
8008 -    * of time and return.
8009 -    */
8010 -   if (gpi.iic_irq > 0) {
8011 -       cli();
8012 -       if (iic_pending == 0) {
8013 -               interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
8014 -       } else
8015 -               iic_pending = 0;
8016 -       sti();
8017 -   } else {
8018 -      udelay(100);
8019 -   }
8020 -}
8021 -
8022 -
8023 -static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs) 
8024 -{
8025 -       
8026 -   iic_pending = 1;
8027 -
8028 -   DEB2(printk("iic_ite_handler: in interrupt handler\n"));
8029 -   wake_up_interruptible(&iic_wait);
8030 -}
8031 -
8032 -
8033 -/* Lock the region of memory where I/O registers exist.  Request our
8034 - * interrupt line and register its associated handler.
8035 - */
8036 -static int iic_hw_resrc_init(void)
8037 -{
8038 -       if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c"))
8039 -               return -ENODEV;
8040 -  
8041 -       if (gpi.iic_irq <= 0)
8042 -               return 0;
8043 -
8044 -       if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0)
8045 -               gpi.iic_irq = 0;
8046 -       else
8047 -               enable_irq(gpi.iic_irq);
8048 -
8049 -       return 0;
8050 -}
8051 -
8052 -
8053 -static void iic_ite_release(void)
8054 -{
8055 -       if (gpi.iic_irq > 0) {
8056 -               disable_irq(gpi.iic_irq);
8057 -               free_irq(gpi.iic_irq, 0);
8058 -       }
8059 -       release_region(gpi.iic_base , 2);
8060 -}
8061 -
8062 -/* ------------------------------------------------------------------------
8063 - * Encapsulate the above functions in the correct operations structure.
8064 - * This is only done when more than one hardware adapter is supported.
8065 - */
8066 -static struct i2c_algo_iic_data iic_ite_data = {
8067 -       NULL,
8068 -       iic_ite_setiic,
8069 -       iic_ite_getiic,
8070 -       iic_ite_getown,
8071 -       iic_ite_getclock,
8072 -       iic_ite_waitforpin,
8073 -       80, 80, 100,            /*      waits, timeout */
8074 -};
8075 -
8076 -static struct i2c_adapter iic_ite_ops = {
8077 -       .owner          = THIS_MODULE,
8078 -       .id             = I2C_HW_I_IIC,
8079 -       .algo_data      = &iic_ite_data,
8080 -       .dev            = {
8081 -               .name   = "ITE IIC adapter",
8082 -       },
8083 -};
8084 -
8085 -/* Called when the module is loaded.  This function starts the
8086 - * cascade of calls up through the hierarchy of i2c modules (i.e. up to the
8087 - *  algorithm layer and into to the core layer)
8088 - */
8089 -static int __init iic_ite_init(void) 
8090 -{
8091 -
8092 -       struct iic_ite *piic = &gpi;
8093 -
8094 -       printk(KERN_INFO "Initialize ITE IIC adapter module\n");
8095 -       if (base == 0)
8096 -               piic->iic_base = DEFAULT_BASE;
8097 -       else
8098 -               piic->iic_base = base;
8099 -
8100 -       if (irq == 0)
8101 -               piic->iic_irq = DEFAULT_IRQ;
8102 -       else
8103 -               piic->iic_irq = irq;
8104 -
8105 -       if (clock == 0)
8106 -               piic->iic_clock = DEFAULT_CLOCK;
8107 -       else
8108 -               piic->iic_clock = clock;
8109 -
8110 -       if (own == 0)
8111 -               piic->iic_own = DEFAULT_OWN;
8112 -       else
8113 -               piic->iic_own = own;
8114 -
8115 -       iic_ite_data.data = (void *)piic;
8116 -       init_waitqueue_head(&iic_wait);
8117 -       if (iic_hw_resrc_init() == 0) {
8118 -               if (i2c_iic_add_bus(&iic_ite_ops) < 0)
8119 -                       return -ENODEV;
8120 -       } else {
8121 -               return -ENODEV;
8122 -       }
8123 -       printk(KERN_INFO " found device at %#x irq %d.\n", 
8124 -               piic->iic_base, piic->iic_irq);
8125 -       return 0;
8126 -}
8127 -
8128 -
8129 -static void iic_ite_exit(void)
8130 -{
8131 -       i2c_iic_del_bus(&iic_ite_ops);
8132 -        iic_ite_release();
8133 -}
8134 -
8135 -/* If modules is NOT defined when this file is compiled, then the MODULE_*
8136 - * macros will resolve to nothing
8137 - */
8138 -MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
8139 -MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
8140 -MODULE_LICENSE("GPL");
8141 -
8142 -MODULE_PARM(base, "i");
8143 -MODULE_PARM(irq, "i");
8144 -MODULE_PARM(clock, "i");
8145 -MODULE_PARM(own, "i");
8146 -MODULE_PARM(i2c_debug,"i");
8147 -
8148 -
8149 -/* Called when module is loaded or when kernel is initialized.
8150 - * If MODULES is defined when this file is compiled, then this function will
8151 - * resolve to init_module (the function called when insmod is invoked for a
8152 - * module).  Otherwise, this function is called early in the boot, when the
8153 - * kernel is intialized.  Check out /include/init.h to see how this works.
8154 - */
8155 -module_init(iic_ite_init);
8156 -
8157 -/* Resolves to module_cleanup when MODULES is defined. */
8158 -module_exit(iic_ite_exit); 
8159 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-algo-ibm_ocp.c i2c-2.5/drivers/i2c/i2c-algo-ibm_ocp.c
8160 --- linux-2.6.0-test5/drivers/i2c/i2c-algo-ibm_ocp.c    Mon Sep  8 19:50:12 2003
8161 +++ i2c-2.5/drivers/i2c/i2c-algo-ibm_ocp.c      Thu Jan  1 00:00:00 1970
8162 @@ -1,900 +0,0 @@
8163 -/*
8164 -   -------------------------------------------------------------------------
8165 -   i2c-algo-ibm_ocp.c i2c driver algorithms for IBM PPC 405 adapters       
8166 -   -------------------------------------------------------------------------
8167 -      
8168 -   Ian DaSilva, MontaVista Software, Inc.
8169 -   idasilva@mvista.com or source@mvista.com
8170 -
8171 -   Copyright 2000 MontaVista Software Inc.
8172 -
8173 -   Changes made to support the IIC peripheral on the IBM PPC 405
8174 -
8175 -
8176 -   ---------------------------------------------------------------------------
8177 -   This file was highly leveraged from i2c-algo-pcf.c, which was created
8178 -   by Simon G. Vogl and Hans Berglund:
8179 -
8180 -
8181 -     Copyright (C) 1995-1997 Simon G. Vogl
8182 -                   1998-2000 Hans Berglund
8183 -
8184 -   With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and 
8185 -   Frodo Looijaard <frodol@dds.nl> ,and also from Martin Bailey
8186 -   <mbailey@littlefeet-inc.com>
8187 -
8188 -
8189 -    This program is free software; you can redistribute it and/or modify
8190 -    it under the terms of the GNU General Public License as published by
8191 -    the Free Software Foundation; either version 2 of the License, or
8192 -    (at your option) any later version.
8193 -
8194 -    This program is distributed in the hope that it will be useful,
8195 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
8196 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8197 -    GNU General Public License for more details.
8198 -
8199 -    You should have received a copy of the GNU General Public License
8200 -    along with this program; if not, write to the Free Software
8201 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
8202 -   ---------------------------------------------------------------------------
8203 -
8204 -   History: 01/20/12 - Armin
8205 -       akuster@mvista.com
8206 -       ported up to 2.4.16+    
8207 -
8208 -   Version 02/03/25 - Armin
8209 -       converted to ocp format
8210 -       removed commented out or #if 0 code
8211 -       added Gérard Basler's fix to iic_combined_transaction() such that it 
8212 -       returns the number of successfully completed transfers .
8213 -*/
8214 -
8215 -
8216 -#include <linux/kernel.h>
8217 -#include <linux/module.h>
8218 -#include <linux/delay.h>
8219 -#include <linux/slab.h>
8220 -#include <linux/init.h>
8221 -#include <linux/errno.h>
8222 -#include <linux/sched.h>
8223 -#include <linux/i2c.h>
8224 -#include <linux/i2c-algo-ibm_ocp.h>
8225 -#include <asm/ocp.h>
8226 -
8227 -
8228 -/* ----- global defines ----------------------------------------------- */
8229 -#define DEB(x) if (i2c_debug>=1) x
8230 -#define DEB2(x) if (i2c_debug>=2) x
8231 -#define DEB3(x) if (i2c_debug>=3) x /* print several statistical values*/
8232 -#define DEBPROTO(x) if (i2c_debug>=9) x;
8233 -       /* debug the protocol by showing transferred bits */
8234 -#define DEF_TIMEOUT 5
8235 -
8236 -
8237 -/* ----- global variables ---------------------------------------------        */
8238 -
8239 -
8240 -/* module parameters:
8241 - */
8242 -static int i2c_debug=0;
8243 -
8244 -/* --- setting states on the bus with the right timing: ---------------        */
8245 -
8246 -#define iic_outb(adap, reg, val) adap->setiic(adap->data, (int) &(reg), val)
8247 -#define iic_inb(adap, reg) adap->getiic(adap->data, (int) &(reg))
8248 -
8249 -#define IICO_I2C_SDAHIGH       0x0780
8250 -#define IICO_I2C_SDALOW                0x0781
8251 -#define IICO_I2C_SCLHIGH       0x0782
8252 -#define IICO_I2C_SCLLOW                0x0783
8253 -#define IICO_I2C_LINEREAD      0x0784
8254 -
8255 -#define IIC_SINGLE_XFER                0
8256 -#define IIC_COMBINED_XFER      1
8257 -
8258 -#define IIC_ERR_LOST_ARB        -2
8259 -#define IIC_ERR_INCOMPLETE_XFR  -3
8260 -#define IIC_ERR_NACK            -1
8261 -
8262 -/* --- other auxiliary functions --------------------------------------        */
8263 -
8264 -
8265 -//
8266 -// Description: Puts this process to sleep for a period equal to timeout 
8267 -//
8268 -static inline void iic_sleep(unsigned long timeout)
8269 -{
8270 -       schedule_timeout( timeout * HZ);
8271 -}
8272 -
8273 -
8274 -//
8275 -// Description: This performs the IBM PPC 405 IIC initialization sequence
8276 -// as described in the PPC405GP data book.
8277 -//
8278 -static int iic_init (struct i2c_algo_iic_data *adap)
8279 -{
8280 -       struct iic_regs *iic;   
8281 -       struct iic_ibm *adap_priv_data = adap->data;
8282 -       unsigned short  retval;
8283 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8284 -
8285 -        /* Clear master low master address */
8286 -        iic_outb(adap,iic->lmadr, 0);
8287 -
8288 -        /* Clear high master address */
8289 -        iic_outb(adap,iic->hmadr, 0);
8290 -
8291 -        /* Clear low slave address */
8292 -        iic_outb(adap,iic->lsadr, 0);
8293 -
8294 -        /* Clear high slave address */
8295 -        iic_outb(adap,iic->hsadr, 0);
8296 -
8297 -        /* Clear status */
8298 -        iic_outb(adap,iic->sts, 0x0a);
8299 -
8300 -        /* Clear extended status */
8301 -        iic_outb(adap,iic->extsts, 0x8f);
8302 -
8303 -        /* Set clock division */
8304 -        iic_outb(adap,iic->clkdiv, 0x04);
8305 -
8306 -       retval = iic_inb(adap, iic->clkdiv);
8307 -       DEB(printk("iic_init: CLKDIV register = %x\n", retval));
8308 -
8309 -        /* Enable interrupts on Requested Master Transfer Complete */
8310 -        iic_outb(adap,iic->intmsk, 0x01);
8311 -
8312 -        /* Clear transfer count */
8313 -        iic_outb(adap,iic->xfrcnt, 0x0);
8314 -
8315 -        /* Clear extended control and status */
8316 -        iic_outb(adap,iic->xtcntlss, 0xf0);
8317 -
8318 -        /* Set mode control (flush master data buf, enable hold SCL, exit */
8319 -        /* unknown state.                                                 */
8320 -        iic_outb(adap,iic->mdcntl, 0x47);
8321 -
8322 -        /* Clear control register */
8323 -        iic_outb(adap,iic->cntl, 0x0);
8324 -
8325 -        DEB2(printk(KERN_DEBUG "iic_init: Initialized IIC on PPC 405\n"));
8326 -        return 0;
8327 -}
8328 -
8329 -
8330 -//
8331 -// Description: After we issue a transaction on the IIC bus, this function
8332 -// is called.  It puts this process to sleep until we get an interrupt from
8333 -// from the controller telling us that the transaction we requested in complete.
8334 -//
8335 -static int wait_for_pin(struct i2c_algo_iic_data *adap, int *status) 
8336 -{
8337 -
8338 -       int timeout = DEF_TIMEOUT;
8339 -       int retval;
8340 -       struct iic_regs *iic;
8341 -       struct iic_ibm *adap_priv_data = adap->data;
8342 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8343 -
8344 -
8345 -       *status = iic_inb(adap, iic->sts);
8346 -#ifndef STUB_I2C
8347 -
8348 -       while (timeout-- && (*status & 0x01)) {
8349 -          adap->waitforpin(adap->data);
8350 -          *status = iic_inb(adap, iic->sts);
8351 -       }
8352 -#endif
8353 -       if (timeout <= 0) {
8354 -          /* Issue stop signal on the bus, and force an interrupt */
8355 -           retval = iic_inb(adap, iic->cntl);
8356 -           iic_outb(adap, iic->cntl, retval | 0x80);
8357 -           /* Clear status register */
8358 -          iic_outb(adap, iic->sts, 0x0a);
8359 -          /* Exit unknown bus state */
8360 -          retval = iic_inb(adap, iic->mdcntl);
8361 -          iic_outb(adap, iic->mdcntl, (retval | 0x02));
8362 -
8363 -          // Check the status of the controller.  Does it still see a
8364 -          // pending transfer, even though we've tried to stop any
8365 -          // ongoing transaction?
8366 -           retval = iic_inb(adap, iic->sts);
8367 -           retval = retval & 0x01;
8368 -           if(retval) {
8369 -             // The iic controller is hosed.  It is not responding to any
8370 -             // of our commands.  We have already tried to force it into
8371 -             // a known state, but it has not worked.  Our only choice now
8372 -             // is a soft reset, which will clear all registers, and force
8373 -             // us to re-initialize the controller.
8374 -             /* Soft reset */
8375 -              iic_outb(adap, iic->xtcntlss, 0x01);
8376 -              udelay(500);
8377 -              iic_init(adap);
8378 -             /* Is the pending transfer bit in the sts reg finally cleared? */
8379 -              retval = iic_inb(adap, iic->sts);
8380 -              retval = retval & 0x01;
8381 -              if(retval) {
8382 -                 printk(KERN_CRIT "The IIC Controller is hosed.  A processor reset is required\n");
8383 -              }
8384 -             // For some reason, even though the interrupt bit in this
8385 -             // register was set during iic_init, it didn't take.  We
8386 -             // need to set it again.  Don't ask me why....this is just what
8387 -             // I saw when testing timeouts.
8388 -              iic_outb(adap, iic->intmsk, 0x01);
8389 -           }
8390 -          return(-1);
8391 -       }
8392 -       else
8393 -          return(0);
8394 -}
8395 -
8396 -
8397 -//------------------------------------
8398 -// Utility functions
8399 -//
8400 -
8401 -
8402 -//
8403 -// Description: Look at the status register to see if there was an error
8404 -// in the requested transaction.  If there is, look at the extended status
8405 -// register and determine the exact cause.
8406 -//
8407 -int analyze_status(struct i2c_algo_iic_data *adap, int *error_code)
8408 -{
8409 -   int ret;
8410 -   struct iic_regs *iic;
8411 -   struct iic_ibm *adap_priv_data = adap->data;
8412 -   iic = (struct iic_regs *) adap_priv_data->iic_base;
8413 -
8414 -       
8415 -   ret = iic_inb(adap, iic->sts);
8416 -   if(ret & 0x04) {
8417 -      // Error occurred
8418 -      ret = iic_inb(adap, iic->extsts);
8419 -      if(ret & 0x04) {
8420 -         // Lost arbitration
8421 -         *error_code =  IIC_ERR_LOST_ARB;
8422 -      }
8423 -      if(ret & 0x02) {
8424 -         // Incomplete transfer
8425 -         *error_code = IIC_ERR_INCOMPLETE_XFR;
8426 -      }
8427 -      if(ret & 0x01) {
8428 -         // Master transfer aborted by a NACK during the transfer of the 
8429 -        // address byte
8430 -         *error_code = IIC_ERR_NACK;
8431 -      }
8432 -      return -1;
8433 -   }
8434 -   return 0;
8435 -}
8436 -
8437 -
8438 -//
8439 -// Description: This function is called by the upper layers to do the
8440 -// grunt work for a master send transaction
8441 -//
8442 -static int iic_sendbytes(struct i2c_adapter *i2c_adap,const char *buf,
8443 -                         int count, int xfer_flag)
8444 -{
8445 -       struct iic_regs *iic;
8446 -       struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
8447 -       struct iic_ibm *adap_priv_data = adap->data;
8448 -       int wrcount, status, timeout;
8449 -       int loops, remainder, i, j;
8450 -       int ret, error_code;
8451 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8452 -
8453
8454 -       if( count == 0 ) return 0;
8455 -       wrcount = 0;
8456 -       loops =  count / 4;
8457 -       remainder = count % 4;
8458 -
8459 -       if((loops > 1) && (remainder == 0)) {
8460 -          for(i=0; i<(loops-1); i++) {
8461 -                     //
8462 -             // Write four bytes to master data buffer
8463 -             //
8464 -             for(j=0; j<4; j++) {
8465 -                iic_outb(adap, iic->mdbuf, 
8466 -                buf[wrcount++]);
8467 -             }
8468 -             //
8469 -             // Issue command to IICO device to begin transmission
8470 -             //
8471 -             iic_outb(adap, iic->cntl, 0x35);
8472 -             //
8473 -             // Wait for transmission to complete.  When it does, 
8474 -             //loop to the top of the for statement and write the 
8475 -             // next four bytes.
8476 -             //
8477 -             timeout = wait_for_pin(adap, &status);
8478 -             if(timeout < 0) {
8479 -                //
8480 -                // Error handling
8481 -                //
8482 -                 //printk(KERN_ERR "Error: write timeout\n");
8483 -                 return wrcount;
8484 -             }
8485 -             ret = analyze_status(adap, &error_code);
8486 -             if(ret < 0) {
8487 -                 if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8488 -                    // Return the number of bytes transferred
8489 -                    ret = iic_inb(adap, iic->xfrcnt);
8490 -                    ret = ret & 0x07;
8491 -                    return (wrcount-4+ret);
8492 -                 }
8493 -                 else return error_code;
8494 -              }
8495 -           }
8496 -       }
8497 -       else if((loops >= 1) && (remainder > 0)){
8498 -          //printk(KERN_DEBUG "iic_sendbytes: (loops >= 1)\n");
8499 -          for(i=0; i<loops; i++) {
8500 -              //
8501 -              // Write four bytes to master data buffer
8502 -              //
8503 -              for(j=0; j<4; j++) {
8504 -                 iic_outb(adap, iic->mdbuf,
8505 -                 buf[wrcount++]);
8506 -              }
8507 -              //
8508 -              // Issue command to IICO device to begin transmission
8509 -              //
8510 -              iic_outb(adap, iic->cntl, 0x35);
8511 -              //
8512 -              // Wait for transmission to complete.  When it does,
8513 -              //loop to the top of the for statement and write the
8514 -              // next four bytes.
8515 -              //
8516 -              timeout = wait_for_pin(adap, &status);
8517 -              if(timeout < 0) {
8518 -                 //
8519 -                 // Error handling
8520 -                 //
8521 -                 //printk(KERN_ERR "Error: write timeout\n");
8522 -                 return wrcount;
8523 -              }
8524 -              ret = analyze_status(adap, &error_code);
8525 -              if(ret < 0) {
8526 -                 if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8527 -                    // Return the number of bytes transferred
8528 -                    ret = iic_inb(adap, iic->xfrcnt);
8529 -                    ret = ret & 0x07;
8530 -                    return (wrcount-4+ret);
8531 -                 }
8532 -                 else return error_code;
8533 -              }
8534 -           }
8535 -        }
8536 -
8537 -       //printk(KERN_DEBUG "iic_sendbytes: expedite write\n");
8538 -       if(remainder == 0) remainder = 4;
8539 -       // remainder = remainder - 1;
8540 -       //
8541 -       // Write the remaining bytes (less than or equal to 4)
8542 -       //
8543 -       for(i=0; i<remainder; i++) {
8544 -          iic_outb(adap, iic->mdbuf, buf[wrcount++]);
8545 -          //printk(KERN_DEBUG "iic_sendbytes:  data transferred = %x, wrcount = %d\n", buf[wrcount-1], (wrcount-1));
8546 -       }
8547 -        //printk(KERN_DEBUG "iic_sendbytes: Issuing write\n");
8548 -
8549 -        if(xfer_flag == IIC_COMBINED_XFER) {
8550 -           iic_outb(adap, iic->cntl, (0x09 | ((remainder-1) << 4)));
8551 -        }
8552 -       else {
8553 -           iic_outb(adap, iic->cntl, (0x01 | ((remainder-1) << 4)));
8554 -        }
8555 -       DEB2(printk(KERN_DEBUG "iic_sendbytes: Waiting for interrupt\n"));
8556 -       timeout = wait_for_pin(adap, &status);
8557 -        if(timeout < 0) {
8558 -                  //
8559 -           // Error handling
8560 -           //
8561 -           //printk(KERN_ERR "Error: write timeout\n");
8562 -           return wrcount;
8563 -        }
8564 -        ret = analyze_status(adap, &error_code);
8565 -        if(ret < 0) {
8566 -           if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8567 -              // Return the number of bytes transferred
8568 -              ret = iic_inb(adap, iic->xfrcnt);
8569 -              ret = ret & 0x07;
8570 -              return (wrcount-4+ret);
8571 -           }
8572 -           else return error_code;
8573 -        }
8574 -       DEB2(printk(KERN_DEBUG "iic_sendbytes: Got interrupt\n"));
8575 -       return wrcount;
8576 -}
8577 -
8578 -
8579 -//
8580 -// Description: Called by the upper layers to do the grunt work for
8581 -// a master read transaction.
8582 -//
8583 -static int iic_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count, int xfer_type)
8584 -{
8585 -       struct iic_regs *iic;
8586 -       int rdcount=0, i, status, timeout;
8587 -       struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
8588 -       struct iic_ibm *adap_priv_data = adap->data;
8589 -       int loops, remainder, j;
8590 -        int ret, error_code;
8591 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8592 -
8593 -       if(count == 0) return 0;
8594 -       loops = count / 4;
8595 -       remainder = count % 4;
8596 -
8597 -       //printk(KERN_DEBUG "iic_readbytes: loops = %d, remainder = %d\n", loops, remainder);
8598 -
8599 -       if((loops > 1) && (remainder == 0)) {
8600 -       //printk(KERN_DEBUG "iic_readbytes: (loops > 1) && (remainder == 0)\n");
8601 -          for(i=0; i<(loops-1); i++) {
8602 -             //
8603 -              // Issue command to begin master read (4 bytes maximum)
8604 -              //
8605 -             //printk(KERN_DEBUG "--->Issued read command\n");
8606 -             iic_outb(adap, iic->cntl, 0x37);
8607 -             //
8608 -              // Wait for transmission to complete.  When it does,
8609 -              // loop to the top of the for statement and write the
8610 -              // next four bytes.
8611 -              //
8612 -             //printk(KERN_DEBUG "--->Waiting for interrupt\n");
8613 -              timeout = wait_for_pin(adap, &status);
8614 -              if(timeout < 0) {
8615 -                // Error Handler
8616 -                //printk(KERN_ERR "Error: read timed out\n");
8617 -                 return rdcount;
8618 -             }
8619 -              //printk(KERN_DEBUG "--->Got interrupt\n");
8620 -
8621 -              ret = analyze_status(adap, &error_code);
8622 -             if(ret < 0) {
8623 -                 if(error_code == IIC_ERR_INCOMPLETE_XFR)
8624 -                    return rdcount;
8625 -                 else
8626 -                    return error_code;
8627 -              }
8628 -
8629 -             for(j=0; j<4; j++) {
8630 -                 // Wait for data to shuffle to top of data buffer
8631 -                 // This value needs to optimized.
8632 -                udelay(1);
8633 -                buf[rdcount] = iic_inb(adap, iic->mdbuf);
8634 -                rdcount++;
8635 -                //printk(KERN_DEBUG "--->Read one byte\n");
8636 -              }
8637 -           }
8638 -       }
8639 -
8640 -       else if((loops >= 1) && (remainder > 0)){
8641 -       //printk(KERN_DEBUG "iic_readbytes: (loops >=1) && (remainder > 0)\n");
8642 -          for(i=0; i<loops; i++) {
8643 -              //
8644 -              // Issue command to begin master read (4 bytes maximum)
8645 -              //
8646 -              //printk(KERN_DEBUG "--->Issued read command\n");
8647 -              iic_outb(adap, iic->cntl, 0x37);
8648 -              //
8649 -              // Wait for transmission to complete.  When it does,
8650 -              // loop to the top of the for statement and write the
8651 -              // next four bytes.
8652 -              //
8653 -              //printk(KERN_DEBUG "--->Waiting for interrupt\n");
8654 -              timeout = wait_for_pin(adap, &status);
8655 -              if(timeout < 0) {
8656 -                 // Error Handler
8657 -                 //printk(KERN_ERR "Error: read timed out\n");
8658 -                 return rdcount;
8659 -              }
8660 -              //printk(KERN_DEBUG "--->Got interrupt\n");
8661 -
8662 -              ret = analyze_status(adap, &error_code);
8663 -              if(ret < 0) {
8664 -                 if(error_code == IIC_ERR_INCOMPLETE_XFR)
8665 -                    return rdcount;
8666 -                 else
8667 -                    return error_code;
8668 -              }
8669 -
8670 -              for(j=0; j<4; j++) {
8671 -                 // Wait for data to shuffle to top of data buffer
8672 -                 // This value needs to optimized.
8673 -                 udelay(1);
8674 -                 buf[rdcount] = iic_inb(adap, iic->mdbuf);
8675 -                 rdcount++;
8676 -                 //printk(KERN_DEBUG "--->Read one byte\n");
8677 -              }
8678 -           }
8679 -        }
8680 -
8681 -       //printk(KERN_DEBUG "iic_readbytes: expedite read\n");
8682 -       if(remainder == 0) remainder = 4;
8683 -       DEB2(printk(KERN_DEBUG "iic_readbytes: writing %x to IICO_CNTL\n", (0x03 | ((remainder-1) << 4))));
8684 -
8685 -       if(xfer_type == IIC_COMBINED_XFER) {
8686 -          iic_outb(adap, iic->cntl, (0x0b | ((remainder-1) << 4)));
8687 -        }
8688 -        else {
8689 -          iic_outb(adap, iic->cntl, (0x03 | ((remainder-1) << 4)));
8690 -        }
8691 -       DEB2(printk(KERN_DEBUG "iic_readbytes: Wait for pin\n"));
8692 -        timeout = wait_for_pin(adap, &status);
8693 -       DEB2(printk(KERN_DEBUG "iic_readbytes: Got the interrupt\n"));
8694 -        if(timeout < 0) {
8695 -           // Error Handler
8696 -          //printk(KERN_ERR "Error: read timed out\n");
8697 -           return rdcount;
8698 -        }
8699 -
8700 -        ret = analyze_status(adap, &error_code);
8701 -        if(ret < 0) {
8702 -           if(error_code == IIC_ERR_INCOMPLETE_XFR)
8703 -              return rdcount;
8704 -           else
8705 -              return error_code;
8706 -        }
8707 -
8708 -       //printk(KERN_DEBUG "iic_readbyte: Begin reading data buffer\n");
8709 -       for(i=0; i<remainder; i++) {
8710 -          buf[rdcount] = iic_inb(adap, iic->mdbuf);
8711 -          // printk(KERN_DEBUG "iic_readbytes:  Character read = %x\n", buf[rdcount]);
8712 -           rdcount++;
8713 -       }
8714 -
8715 -       return rdcount;
8716 -}
8717 -
8718 -
8719 -//
8720 -// Description:  This function implements combined transactions.  Combined
8721 -// transactions consist of combinations of reading and writing blocks of data.
8722 -// Each transfer (i.e. a read or a write) is separated by a repeated start
8723 -// condition.
8724 -//
8725 -static int iic_combined_transaction(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) 
8726 -{
8727 -   int i;
8728 -   struct i2c_msg *pmsg;
8729 -   int ret;
8730 -
8731 -   DEB2(printk(KERN_DEBUG "Beginning combined transaction\n"));
8732 -       for(i=0; i < num; i++) {
8733 -               pmsg = &msgs[i];
8734 -               if(pmsg->flags & I2C_M_RD) {
8735 -
8736 -                       // Last read or write segment needs to be terminated with a stop
8737 -                       if(i < num-1) {
8738 -                               DEB2(printk(KERN_DEBUG "This one is a read\n"));
8739 -                       }
8740 -                       else {
8741 -                               DEB2(printk(KERN_DEBUG "Doing the last read\n"));
8742 -                       }
8743 -                       ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, (i < num-1) ? IIC_COMBINED_XFER : IIC_SINGLE_XFER);
8744 -
8745 -                       if (ret != pmsg->len) {
8746 -                               DEB2(printk("i2c-algo-ppc405.o: fail: "
8747 -                                                       "only read %d bytes.\n",ret));
8748 -                               return i;
8749 -                       }
8750 -                       else {
8751 -                               DEB2(printk("i2c-algo-ppc405.o: read %d bytes.\n",ret));
8752 -                       }
8753 -               }
8754 -               else if(!(pmsg->flags & I2C_M_RD)) {
8755 -
8756 -                       // Last read or write segment needs to be terminated with a stop
8757 -                       if(i < num-1) {
8758 -                               DEB2(printk(KERN_DEBUG "This one is a write\n"));
8759 -                       }
8760 -                       else {
8761 -                               DEB2(printk(KERN_DEBUG "Doing the last write\n"));
8762 -                       }
8763 -                       ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, (i < num-1) ? IIC_COMBINED_XFER : IIC_SINGLE_XFER);
8764 -
8765 -                       if (ret != pmsg->len) {
8766 -                               DEB2(printk("i2c-algo-ppc405.o: fail: "
8767 -                                                       "only wrote %d bytes.\n",ret));
8768 -                               return i;
8769 -                       }
8770 -                       else {
8771 -                               DEB2(printk("i2c-algo-ppc405.o: wrote %d bytes.\n",ret));
8772 -                       }
8773 -               }
8774 -       }
8775
8776 -       return num;
8777 -}
8778 -
8779 -
8780 -//
8781 -// Description: Whenever we initiate a transaction, the first byte clocked
8782 -// onto the bus after the start condition is the address (7 bit) of the
8783 -// device we want to talk to.  This function manipulates the address specified
8784 -// so that it makes sense to the hardware when written to the IIC peripheral.
8785 -//
8786 -// Note: 10 bit addresses are not supported in this driver, although they are
8787 -// supported by the hardware.  This functionality needs to be implemented.
8788 -//
8789 -static inline int iic_doAddress(struct i2c_algo_iic_data *adap,
8790 -                                struct i2c_msg *msg, int retries) 
8791 -{
8792 -       struct iic_regs *iic;
8793 -       unsigned short flags = msg->flags;
8794 -       unsigned char addr;
8795 -       struct iic_ibm *adap_priv_data = adap->data;
8796 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8797 -
8798 -//
8799 -// The following segment for 10 bit addresses needs to be ported
8800 -//
8801 -/* Ten bit addresses not supported right now
8802 -       if ( (flags & I2C_M_TEN)  ) { 
8803 -               // a ten bit address
8804 -               addr = 0xf0 | (( msg->addr >> 7) & 0x03);
8805 -               DEB2(printk(KERN_DEBUG "addr0: %d\n",addr));
8806 -               // try extended address code...
8807 -               ret = try_address(adap, addr, retries);
8808 -               if (ret!=1) {
8809 -                       printk(KERN_ERR "iic_doAddress: died at extended address code.\n");
8810 -                       return -EREMOTEIO;
8811 -               }
8812 -               // the remaining 8 bit address
8813 -               iic_outb(adap,msg->addr & 0x7f);
8814 -               // Status check comes here
8815 -               if (ret != 1) {
8816 -                       printk(KERN_ERR "iic_doAddress: died at 2nd address code.\n");
8817 -                       return -EREMOTEIO;
8818 -               }
8819 -               if ( flags & I2C_M_RD ) {
8820 -                       i2c_repstart(adap);
8821 -                       // okay, now switch into reading mode
8822 -                       addr |= 0x01;
8823 -                       ret = try_address(adap, addr, retries);
8824 -                       if (ret!=1) {
8825 -                               printk(KERN_ERR "iic_doAddress: died at extended address code.\n");
8826 -                               return -EREMOTEIO;
8827 -                       }
8828 -               }
8829 -       } else ----------> // normal 7 bit address
8830 -
8831 -Ten bit addresses not supported yet */
8832 -
8833 -       addr = ( msg->addr << 1 );
8834 -       if (flags & I2C_M_RD )
8835 -               addr |= 1;
8836 -       if (flags & I2C_M_REV_DIR_ADDR )
8837 -               addr ^= 1;
8838 -       //
8839 -       // Write to the low slave address
8840 -       //
8841 -       iic_outb(adap, iic->lmadr, addr);
8842 -       //
8843 -       // Write zero to the high slave register since we are
8844 -       // only using 7 bit addresses
8845 -       //
8846 -       iic_outb(adap, iic->hmadr, 0);
8847 -
8848 -       return 0;
8849 -}
8850 -
8851 -
8852 -//
8853 -// Description: Prepares the controller for a transaction (clearing status
8854 -// registers, data buffers, etc), and then calls either iic_readbytes or
8855 -// iic_sendbytes to do the actual transaction.
8856 -//
8857 -static int iic_xfer(struct i2c_adapter *i2c_adap,
8858 -                   struct i2c_msg msgs[], 
8859 -                   int num)
8860 -{
8861 -       struct iic_regs *iic;
8862 -       struct i2c_algo_iic_data *adap = i2c_adap->algo_data;
8863 -       struct iic_ibm *adap_priv_data = adap->data;
8864 -       struct i2c_msg *pmsg;
8865 -       int i = 0;
8866 -       int ret;
8867 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8868 -
8869 -       pmsg = &msgs[i];
8870 -
8871 -       //
8872 -       // Clear status register
8873 -       //
8874 -       DEB2(printk(KERN_DEBUG "iic_xfer: iic_xfer: Clearing status register\n"));
8875 -       iic_outb(adap, iic->sts, 0x0a);
8876 -
8877 -       //
8878 -       // Wait for any pending transfers to complete
8879 -       //
8880 -       DEB2(printk(KERN_DEBUG "iic_xfer: Waiting for any pending transfers to complete\n"));
8881 -       while((ret = iic_inb(adap, iic->sts)) == 0x01) {
8882 -               ;
8883 -       }
8884 -
8885 -       //
8886 -       // Flush master data buf
8887 -       //
8888 -       DEB2(printk(KERN_DEBUG "iic_xfer: Clearing master data buffer\n"));             
8889 -       ret = iic_inb(adap, iic->mdcntl);
8890 -       iic_outb(adap, iic->mdcntl, ret | 0x40);
8891 -
8892 -       //
8893 -       // Load slave address
8894 -       //
8895 -       DEB2(printk(KERN_DEBUG "iic_xfer: Loading slave address\n"));
8896 -       ret = iic_doAddress(adap, pmsg, i2c_adap->retries);
8897 -
8898 -        //
8899 -        // Check to see if the bus is busy
8900 -        //
8901 -        ret = iic_inb(adap, iic->extsts);
8902 -        // Mask off the irrelevent bits
8903 -        ret = ret & 0x70;
8904 -        // When the bus is free, the BCS bits in the EXTSTS register are 0b100
8905 -        if(ret != 0x40) return IIC_ERR_LOST_ARB;
8906 -
8907 -       //
8908 -       // Combined transaction (read and write)
8909 -       //
8910 -       if(num > 1) {
8911 -           DEB2(printk(KERN_DEBUG "iic_xfer: Call combined transaction\n"));
8912 -           ret = iic_combined_transaction(i2c_adap, msgs, num);
8913 -        }
8914 -       //
8915 -       // Read only
8916 -       //
8917 -       else if((num == 1) && (pmsg->flags & I2C_M_RD)) {
8918 -          //
8919 -          // Tell device to begin reading data from the  master data 
8920 -          //
8921 -          DEB2(printk(KERN_DEBUG "iic_xfer: Call adapter's read\n"));
8922 -          ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
8923 -       } 
8924 -        //
8925 -       // Write only
8926 -       //
8927 -       else if((num == 1 ) && (!(pmsg->flags & I2C_M_RD))) {
8928 -          //
8929 -          // Write data to master data buffers and tell our device
8930 -          // to begin transmitting
8931 -          //
8932 -          DEB2(printk(KERN_DEBUG "iic_xfer: Call adapter's write\n"));
8933 -          ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, IIC_SINGLE_XFER);
8934 -       }       
8935 -
8936 -       return ret;   
8937 -}
8938 -
8939 -
8940 -//
8941 -// Description: Implements device specific ioctls.  Higher level ioctls can
8942 -// be found in i2c-core.c and are typical of any i2c controller (specifying
8943 -// slave address, timeouts, etc).  These ioctls take advantage of any hardware
8944 -// features built into the controller for which this algorithm-adapter set
8945 -// was written.  These ioctls allow you to take control of the data and clock
8946 -// lines on the IBM PPC 405 IIC controller and set the either high or low,
8947 -// similar to a GPIO pin.
8948 -//
8949 -static int algo_control(struct i2c_adapter *adapter, 
8950 -       unsigned int cmd, unsigned long arg)
8951 -{
8952 -       struct iic_regs *iic;
8953 -       struct i2c_algo_iic_data *adap = adapter->algo_data;
8954 -       struct iic_ibm *adap_priv_data = adap->data;
8955 -       int ret=0;
8956 -       int lines;
8957 -       iic = (struct iic_regs *) adap_priv_data->iic_base;
8958 -
8959 -       lines = iic_inb(adap, iic->directcntl);
8960 -
8961 -       if (cmd == IICO_I2C_SDAHIGH) {
8962 -             lines = lines & 0x01;
8963 -             if( lines ) lines = 0x04;
8964 -             else lines = 0;
8965 -             iic_outb(adap, iic->directcntl,(0x08|lines));
8966 -       }
8967 -       else if (cmd == IICO_I2C_SDALOW) {
8968 -             lines = lines & 0x01;
8969 -             if( lines ) lines = 0x04;
8970 -              else lines = 0;
8971 -              iic_outb(adap, iic->directcntl,(0x00|lines));
8972 -       }
8973 -       else if (cmd == IICO_I2C_SCLHIGH) {
8974 -              lines = lines & 0x02;
8975 -              if( lines ) lines = 0x08;
8976 -              else lines = 0;
8977 -              iic_outb(adap, iic->directcntl,(0x04|lines));
8978 -       }
8979 -       else if (cmd == IICO_I2C_SCLLOW) {
8980 -              lines = lines & 0x02;
8981 -             if( lines ) lines = 0x08;
8982 -              else lines = 0;
8983 -              iic_outb(adap, iic->directcntl,(0x00|lines));
8984 -       }
8985 -       else if (cmd == IICO_I2C_LINEREAD) {
8986 -             ret = lines;
8987 -       }
8988 -       return ret;
8989 -}
8990 -
8991 -
8992 -static u32 iic_func(struct i2c_adapter *adap)
8993 -{
8994 -       return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 
8995 -              I2C_FUNC_PROTOCOL_MANGLING; 
8996 -}
8997 -
8998 -
8999 -/* -----exported algorithm data: ------------------------------------- */
9000 -
9001 -static struct i2c_algorithm iic_algo = {
9002 -       .name           = "IBM on-chip IIC algorithm",
9003 -       .id             = I2C_ALGO_OCP,
9004 -       .master_xfer    = iic_xfer,
9005 -       .algo_control   = algo_control,
9006 -       .functionality  = iic_func,
9007 -};
9008 -
9009 -/* 
9010 - * registering functions to load algorithms at runtime 
9011 - */
9012 -
9013 -
9014 -//
9015 -// Description: Register bus structure
9016 -//
9017 -int i2c_ocp_add_bus(struct i2c_adapter *adap)
9018 -{
9019 -       struct i2c_algo_iic_data *iic_adap = adap->algo_data;
9020 -
9021 -       DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: hw routines for %s registered.\n",
9022 -                   adap->name));
9023 -
9024 -       /* register new adapter to i2c module... */
9025 -
9026 -       adap->id |= iic_algo.id;
9027 -       adap->algo = &iic_algo;
9028 -
9029 -       adap->timeout = 100;    /* default values, should       */
9030 -       adap->retries = 3;              /* be replaced by defines       */
9031 -
9032 -       iic_init(iic_adap);
9033 -       i2c_add_adapter(adap);
9034 -       return 0;
9035 -}
9036 -
9037 -
9038 -//
9039 -// Done
9040 -//
9041 -int i2c_ocp_del_bus(struct i2c_adapter *adap)
9042 -{
9043 -       return i2c_del_adapter(adap);
9044 -}
9045 -
9046 -
9047 -EXPORT_SYMBOL(i2c_ocp_add_bus);
9048 -EXPORT_SYMBOL(i2c_ocp_del_bus);
9049 -
9050 -//
9051 -// The MODULE_* macros resolve to nothing if MODULES is not defined
9052 -// when this file is compiled.
9053 -//
9054 -MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
9055 -MODULE_DESCRIPTION("PPC 405 iic algorithm");
9056 -MODULE_LICENSE("GPL");
9057 -
9058 -MODULE_PARM(i2c_debug,"i");
9059 -
9060 -MODULE_PARM_DESC(i2c_debug,
9061 -        "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
9062 -
9063 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-algo-ibm_ocp.h i2c-2.5/drivers/i2c/i2c-algo-ibm_ocp.h
9064 --- linux-2.6.0-test5/drivers/i2c/i2c-algo-ibm_ocp.h    Mon Sep  8 19:50:06 2003
9065 +++ i2c-2.5/drivers/i2c/i2c-algo-ibm_ocp.h      Thu Jan  1 00:00:00 1970
9066 @@ -1,55 +0,0 @@
9067 -/* ------------------------------------------------------------------------- */
9068 -/* i2c-algo-ibm_ocp.h i2c driver algorithms for IBM PPC 405 IIC adapters         */
9069 -/* ------------------------------------------------------------------------- */
9070 -/*   Copyright (C) 1995-97 Simon G. Vogl
9071 -                   1998-99 Hans Berglund
9072 -
9073 -    This program is free software; you can redistribute it and/or modify
9074 -    it under the terms of the GNU General Public License as published by
9075 -    the Free Software Foundation; either version 2 of the License, or
9076 -    (at your option) any later version.
9077 -
9078 -    This program is distributed in the hope that it will be useful,
9079 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
9080 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9081 -    GNU General Public License for more details.
9082 -
9083 -    You should have received a copy of the GNU General Public License
9084 -    along with this program; if not, write to the Free Software
9085 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
9086 -/* ------------------------------------------------------------------------- */
9087 -
9088 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9089 -   Frodo Looijaard <frodol@dds.nl> */
9090 -
9091 -/* Modifications by MontaVista Software, August 2000
9092 -   Changes made to support the IIC peripheral on the IBM PPC 405 */
9093 -
9094 -#ifndef I2C_ALGO_IIC_H
9095 -#define I2C_ALGO_IIC_H 1
9096 -
9097 -/* --- Defines for pcf-adapters ---------------------------------------        */
9098 -#include <linux/i2c.h>
9099 -
9100 -struct i2c_algo_iic_data {
9101 -       struct iic_regs *data;          /* private data for lolevel routines    */
9102 -       void (*setiic) (void *data, int ctl, int val);
9103 -       int  (*getiic) (void *data, int ctl);
9104 -       int  (*getown) (void *data);
9105 -       int  (*getclock) (void *data);
9106 -       void (*waitforpin) (void *data);     
9107 -
9108 -       /* local settings */
9109 -       int udelay;
9110 -       int mdelay;
9111 -       int timeout;
9112 -};
9113 -
9114 -
9115 -#define I2C_IIC_ADAP_MAX       16
9116 -
9117 -
9118 -int i2c_ocp_add_bus(struct i2c_adapter *);
9119 -int i2c_ocp_del_bus(struct i2c_adapter *);
9120 -
9121 -#endif /* I2C_ALGO_IIC_H */
9122 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-algo-ite.c i2c-2.5/drivers/i2c/i2c-algo-ite.c
9123 --- linux-2.6.0-test5/drivers/i2c/i2c-algo-ite.c        Mon Sep  8 19:50:24 2003
9124 +++ i2c-2.5/drivers/i2c/i2c-algo-ite.c  Tue Sep 23 10:12:58 2003
9125 @@ -38,7 +38,6 @@
9126  #include <linux/module.h>
9127  #include <linux/delay.h>
9128  #include <linux/slab.h>
9129 -#include <linux/version.h>
9130  #include <linux/init.h>
9131  #include <asm/uaccess.h>
9132  #include <linux/ioport.h>
9133 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-core.c i2c-2.5/drivers/i2c/i2c-core.c
9134 --- linux-2.6.0-test5/drivers/i2c/i2c-core.c    Mon Sep  8 19:49:53 2003
9135 +++ i2c-2.5/drivers/i2c/i2c-core.c      Tue Sep 23 10:12:58 2003
9136 @@ -581,8 +581,7 @@
9137                  */
9138                 return (ret == 1 )? count : ret;
9139         } else {
9140 -               printk(KERN_ERR "i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n",
9141 -                      client->adapter->id);
9142 +               dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
9143                 return -ENOSYS;
9144         }
9145  }
9146 @@ -614,8 +613,7 @@
9147                 */
9148                 return (ret == 1 )? count : ret;
9149         } else {
9150 -               printk(KERN_DEBUG "i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n",
9151 -                      client->adapter->id);
9152 +               dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
9153                 return -ENOSYS;
9154         }
9155  }
9156 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-dev.c i2c-2.5/drivers/i2c/i2c-dev.c
9157 --- linux-2.6.0-test5/drivers/i2c/i2c-dev.c     Mon Sep  8 19:50:21 2003
9158 +++ i2c-2.5/drivers/i2c/i2c-dev.c       Tue Sep 23 10:12:58 2003
9159 @@ -505,8 +505,7 @@
9160  {
9161         int res;
9162  
9163 -       printk(KERN_INFO "i2c /dev entries driver module version %s (%s)\n",
9164 -               I2C_VERSION, I2C_DATE);
9165 +       printk(KERN_INFO "i2c /dev entries driver\n");
9166  
9167         if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) {
9168                 printk(KERN_ERR "i2c-dev.o: unable to get major %d for i2c bus\n",
9169 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-elektor.c i2c-2.5/drivers/i2c/i2c-elektor.c
9170 --- linux-2.6.0-test5/drivers/i2c/i2c-elektor.c Mon Sep  8 19:49:51 2003
9171 +++ i2c-2.5/drivers/i2c/i2c-elektor.c   Thu Jan  1 00:00:00 1970
9172 @@ -1,287 +0,0 @@
9173 -/* ------------------------------------------------------------------------- */
9174 -/* i2c-elektor.c i2c-hw access for PCF8584 style isa bus adaptes             */
9175 -/* ------------------------------------------------------------------------- */
9176 -/*   Copyright (C) 1995-97 Simon G. Vogl
9177 -                   1998-99 Hans Berglund
9178 -
9179 -    This program is free software; you can redistribute it and/or modify
9180 -    it under the terms of the GNU General Public License as published by
9181 -    the Free Software Foundation; either version 2 of the License, or
9182 -    (at your option) any later version.
9183 -
9184 -    This program is distributed in the hope that it will be useful,
9185 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
9186 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9187 -    GNU General Public License for more details.
9188 -
9189 -    You should have received a copy of the GNU General Public License
9190 -    along with this program; if not, write to the Free Software
9191 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
9192 -/* ------------------------------------------------------------------------- */
9193 -
9194 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9195 -   Frodo Looijaard <frodol@dds.nl> */
9196 -
9197 -/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 
9198 -   for Alpha Processor Inc. UP-2000(+) boards */
9199 -
9200 -#include <linux/kernel.h>
9201 -#include <linux/ioport.h>
9202 -#include <linux/module.h>
9203 -#include <linux/delay.h>
9204 -#include <linux/slab.h>
9205 -#include <linux/version.h>
9206 -#include <linux/init.h>
9207 -#include <linux/interrupt.h>
9208 -#include <linux/pci.h>
9209 -#include <linux/wait.h>
9210 -
9211 -#include <linux/i2c.h>
9212 -#include <linux/i2c-algo-pcf.h>
9213 -
9214 -#include <asm/io.h>
9215 -#include <asm/irq.h>
9216 -
9217 -#include "i2c-pcf8584.h"
9218 -
9219 -#define DEFAULT_BASE 0x330
9220 -
9221 -static int base;
9222 -static int irq;
9223 -static int clock  = 0x1c;
9224 -static int own    = 0x55;
9225 -static int mmapped;
9226 -static int i2c_debug;
9227 -
9228 -/* vdovikin: removed static struct i2c_pcf_isa gpi; code - 
9229 -  this module in real supports only one device, due to missing arguments
9230 -  in some functions, called from the algo-pcf module. Sometimes it's
9231 -  need to be rewriten - but for now just remove this for simpler reading */
9232 -
9233 -static wait_queue_head_t pcf_wait;
9234 -static int pcf_pending;
9235 -
9236 -/* ----- global defines -----------------------------------------------        */
9237 -#define DEB(x) if (i2c_debug>=1) x
9238 -#define DEB2(x) if (i2c_debug>=2) x
9239 -#define DEB3(x) if (i2c_debug>=3) x
9240 -#define DEBE(x)        x       /* error messages                               */
9241 -
9242 -/* ----- local functions ----------------------------------------------        */
9243 -
9244 -static void pcf_isa_setbyte(void *data, int ctl, int val)
9245 -{
9246 -       int address = ctl ? (base + 1) : base;
9247 -
9248 -       /* enable irq if any specified for serial operation */
9249 -       if (ctl && irq && (val & I2C_PCF_ESO)) {
9250 -               val |= I2C_PCF_ENI;
9251 -       }
9252 -
9253 -       DEB3(printk(KERN_DEBUG "i2c-elektor.o: Write 0x%X 0x%02X\n", address, val & 255));
9254 -
9255 -       switch (mmapped) {
9256 -       case 0: /* regular I/O */
9257 -               outb(val, address);
9258 -               break;
9259 -       case 2: /* double mapped I/O needed for UP2000 board,
9260 -                   I don't know why this... */
9261 -               writeb(val, address);
9262 -               /* fall */
9263 -       case 1: /* memory mapped I/O */
9264 -               writeb(val, address);
9265 -               break;
9266 -       }
9267 -}
9268 -
9269 -static int pcf_isa_getbyte(void *data, int ctl)
9270 -{
9271 -       int address = ctl ? (base + 1) : base;
9272 -       int val = mmapped ? readb(address) : inb(address);
9273 -
9274 -       DEB3(printk(KERN_DEBUG "i2c-elektor.o: Read 0x%X 0x%02X\n", address, val));
9275 -
9276 -       return (val);
9277 -}
9278 -
9279 -static int pcf_isa_getown(void *data)
9280 -{
9281 -       return (own);
9282 -}
9283 -
9284 -
9285 -static int pcf_isa_getclock(void *data)
9286 -{
9287 -       return (clock);
9288 -}
9289 -
9290 -static void pcf_isa_waitforpin(void) {
9291 -
9292 -       int timeout = 2;
9293 -
9294 -       if (irq > 0) {
9295 -               cli();
9296 -               if (pcf_pending == 0) {
9297 -                       interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
9298 -               } else
9299 -                       pcf_pending = 0;
9300 -               sti();
9301 -       } else {
9302 -               udelay(100);
9303 -       }
9304 -}
9305 -
9306 -
9307 -static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
9308 -       pcf_pending = 1;
9309 -       wake_up_interruptible(&pcf_wait);
9310 -       return IRQ_HANDLED;
9311 -}
9312 -
9313 -
9314 -static int pcf_isa_init(void)
9315 -{
9316 -       if (!mmapped) {
9317 -               if (!request_region(base, 2, "i2c (isa bus adapter)")) {
9318 -                       printk(KERN_ERR
9319 -                              "i2c-elektor.o: requested I/O region (0x%X:2) "
9320 -                              "is in use.\n", base);
9321 -                       return -ENODEV;
9322 -               }
9323 -       }
9324 -       if (irq > 0) {
9325 -               if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", 0) < 0) {
9326 -                       printk(KERN_ERR "i2c-elektor.o: Request irq%d failed\n", irq);
9327 -                       irq = 0;
9328 -               } else
9329 -                       enable_irq(irq);
9330 -       }
9331 -       return 0;
9332 -}
9333 -
9334 -/* ------------------------------------------------------------------------
9335 - * Encapsulate the above functions in the correct operations structure.
9336 - * This is only done when more than one hardware adapter is supported.
9337 - */
9338 -static struct i2c_algo_pcf_data pcf_isa_data = {
9339 -       .setpcf     = pcf_isa_setbyte,
9340 -       .getpcf     = pcf_isa_getbyte,
9341 -       .getown     = pcf_isa_getown,
9342 -       .getclock   = pcf_isa_getclock,
9343 -       .waitforpin = pcf_isa_waitforpin,
9344 -       .udelay     = 10,
9345 -       .mdelay     = 10,
9346 -       .timeout    = 100,
9347 -};
9348 -
9349 -static struct i2c_adapter pcf_isa_ops = {
9350 -       .owner          = THIS_MODULE,
9351 -       .id             = I2C_HW_P_ELEK,
9352 -       .algo_data      = &pcf_isa_data,
9353 -       .name           = "PCF8584 ISA adapter",
9354 -};
9355 -
9356 -static int __init i2c_pcfisa_init(void) 
9357 -{
9358 -#ifdef __alpha__
9359 -       /* check to see we have memory mapped PCF8584 connected to the 
9360 -       Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
9361 -       if (base == 0) {
9362 -               
9363 -               struct pci_dev *cy693_dev =
9364 -                    pci_find_device(PCI_VENDOR_ID_CONTAQ, 
9365 -                                   PCI_DEVICE_ID_CONTAQ_82C693, NULL);
9366 -
9367 -               if (cy693_dev) {
9368 -                       char config;
9369 -                       /* yeap, we've found cypress, let's check config */
9370 -                       if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
9371 -                               
9372 -                               DEB3(printk(KERN_DEBUG "i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config));
9373 -
9374 -                               /* UP2000 board has this register set to 0xe1,
9375 -                                   but the most significant bit as seems can be 
9376 -                                  reset during the proper initialisation
9377 -                                   sequence if guys from API decides to do that
9378 -                                   (so, we can even enable Tsunami Pchip
9379 -                                   window for the upper 1 Gb) */
9380 -
9381 -                               /* so just check for ROMCS at 0xe0000,
9382 -                                   ROMCS enabled for writes
9383 -                                  and external XD Bus buffer in use. */
9384 -                               if ((config & 0x7f) == 0x61) {
9385 -                                       /* seems to be UP2000 like board */
9386 -                                       base = 0xe0000;
9387 -                                        /* I don't know why we need to
9388 -                                           write twice */
9389 -                                       mmapped = 2;
9390 -                                        /* UP2000 drives ISA with
9391 -                                          8.25 MHz (PCI/4) clock
9392 -                                          (this can be read from cypress) */
9393 -                                       clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
9394 -                                       printk(KERN_INFO "i2c-elektor.o: found API UP2000 like board, will probe PCF8584 later.\n");
9395 -                               }
9396 -                       }
9397 -               }
9398 -       }
9399 -#endif
9400 -
9401 -       /* sanity checks for mmapped I/O */
9402 -       if (mmapped && base < 0xc8000) {
9403 -               printk(KERN_ERR "i2c-elektor.o: incorrect base address (0x%0X) specified for mmapped I/O.\n", base);
9404 -               return -ENODEV;
9405 -       }
9406 -
9407 -       printk(KERN_INFO "i2c-elektor.o: i2c pcf8584-isa adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
9408 -
9409 -       if (base == 0) {
9410 -               base = DEFAULT_BASE;
9411 -       }
9412 -
9413 -       init_waitqueue_head(&pcf_wait);
9414 -       if (pcf_isa_init())
9415 -               return -ENODEV;
9416 -       if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
9417 -               goto fail;
9418 -       
9419 -       printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base);
9420 -
9421 -       return 0;
9422 -
9423 - fail:
9424 -       if (irq > 0) {
9425 -               disable_irq(irq);
9426 -               free_irq(irq, 0);
9427 -       }
9428 -
9429 -       if (!mmapped)
9430 -               release_region(base , 2);
9431 -       return -ENODEV;
9432 -}
9433 -
9434 -static void i2c_pcfisa_exit(void)
9435 -{
9436 -       i2c_pcf_del_bus(&pcf_isa_ops);
9437 -
9438 -       if (irq > 0) {
9439 -               disable_irq(irq);
9440 -               free_irq(irq, 0);
9441 -       }
9442 -
9443 -       if (!mmapped)
9444 -               release_region(base , 2);
9445 -}
9446 -
9447 -MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
9448 -MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
9449 -MODULE_LICENSE("GPL");
9450 -
9451 -MODULE_PARM(base, "i");
9452 -MODULE_PARM(irq, "i");
9453 -MODULE_PARM(clock, "i");
9454 -MODULE_PARM(own, "i");
9455 -MODULE_PARM(mmapped, "i");
9456 -MODULE_PARM(i2c_debug, "i");
9457 -
9458 -module_init(i2c_pcfisa_init);
9459 -module_exit(i2c_pcfisa_exit);
9460 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-elv.c i2c-2.5/drivers/i2c/i2c-elv.c
9461 --- linux-2.6.0-test5/drivers/i2c/i2c-elv.c     Mon Sep  8 19:50:21 2003
9462 +++ i2c-2.5/drivers/i2c/i2c-elv.c       Thu Jan  1 00:00:00 1970
9463 @@ -1,176 +0,0 @@
9464 -/* ------------------------------------------------------------------------- */
9465 -/* i2c-elv.c i2c-hw access for philips style parallel port adapters         */
9466 -/* ------------------------------------------------------------------------- */
9467 -/*   Copyright (C) 1995-2000 Simon G. Vogl
9468 -
9469 -    This program is free software; you can redistribute it and/or modify
9470 -    it under the terms of the GNU General Public License as published by
9471 -    the Free Software Foundation; either version 2 of the License, or
9472 -    (at your option) any later version.
9473 -
9474 -    This program is distributed in the hope that it will be useful,
9475 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
9476 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9477 -    GNU General Public License for more details.
9478 -
9479 -    You should have received a copy of the GNU General Public License
9480 -    along with this program; if not, write to the Free Software
9481 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
9482 -/* ------------------------------------------------------------------------- */
9483 -
9484 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9485 -   Frodo Looijaard <frodol@dds.nl> */
9486 -
9487 -/* $Id$ */
9488 -
9489 -#include <linux/kernel.h>
9490 -#include <linux/module.h>
9491 -#include <linux/delay.h>
9492 -#include <linux/slab.h>
9493 -#include <linux/init.h>
9494 -#include <linux/ioport.h>
9495 -#include <linux/errno.h>
9496 -#include <linux/i2c.h>
9497 -#include <linux/i2c-algo-bit.h>
9498 -#include <asm/io.h>
9499 -
9500 -#define DEFAULT_BASE 0x378
9501 -static int base=0;
9502 -static unsigned char PortData = 0;
9503 -
9504 -/* ----- global defines -----------------------------------------------        */
9505 -#define DEB(x)         /* should be reasonable open, close &c.         */
9506 -#define DEB2(x)        /* low level debugging - very slow              */
9507 -#define DEBE(x)        x       /* error messages                               */
9508 -#define DEBINIT(x) x   /* detection status messages                    */
9509 -
9510 -/* --- Convenience defines for the parallel port:                      */
9511 -#define BASE   (unsigned int)(data)
9512 -#define DATA   BASE                    /* Centronics data port         */
9513 -#define STAT   (BASE+1)                /* Centronics status port       */
9514 -#define CTRL   (BASE+2)                /* Centronics control port      */
9515 -
9516 -
9517 -/* ----- local functions ----------------------------------------------        */
9518 -
9519 -
9520 -static void bit_elv_setscl(void *data, int state)
9521 -{
9522 -       if (state) {
9523 -               PortData &= 0xfe;
9524 -       } else {
9525 -               PortData |=1;
9526 -       }
9527 -       outb(PortData, DATA);
9528 -}
9529 -
9530 -static void bit_elv_setsda(void *data, int state)
9531 -{
9532 -       if (state) {
9533 -               PortData &=0xfd;
9534 -       } else {
9535 -               PortData |=2;
9536 -       }
9537 -       outb(PortData, DATA);
9538 -} 
9539 -
9540 -static int bit_elv_getscl(void *data)
9541 -{
9542 -       return ( 0 == ( (inb_p(STAT)) & 0x08 ) );
9543 -}
9544 -
9545 -static int bit_elv_getsda(void *data)
9546 -{
9547 -       return ( 0 == ( (inb_p(STAT)) & 0x40 ) );
9548 -}
9549 -
9550 -static int bit_elv_init(void)
9551 -{
9552 -       if (!request_region(base, (base == 0x3bc) ? 3 : 8,
9553 -                               "i2c (ELV adapter)"))
9554 -               return -ENODEV;
9555 -
9556 -       if (inb(base+1) & 0x80) {       /* BUSY should be high  */
9557 -               DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n"));
9558 -               goto fail;
9559 -       } 
9560 -
9561 -       outb(0x0c,base+2);      /* SLCT auf low         */
9562 -       udelay(400);
9563 -       if (!(inb(base+1) && 0x10)) {
9564 -               outb(0x04,base+2);
9565 -               DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n"));
9566 -               goto fail;
9567 -       }
9568 -
9569 -       PortData = 0;
9570 -       bit_elv_setsda((void*)base,1);
9571 -       bit_elv_setscl((void*)base,1);
9572 -       return 0;
9573 -
9574 -fail:
9575 -       release_region(base , (base == 0x3bc) ? 3 : 8);
9576 -       return -ENODEV;
9577 -}
9578 -
9579 -/* ------------------------------------------------------------------------
9580 - * Encapsulate the above functions in the correct operations structure.
9581 - * This is only done when more than one hardware adapter is supported.
9582 - */
9583 -static struct i2c_algo_bit_data bit_elv_data = {
9584 -       .setsda         = bit_elv_setsda,
9585 -       .setscl         = bit_elv_setscl,
9586 -       .getsda         = bit_elv_getsda,
9587 -       .getscl         = bit_elv_getscl,
9588 -       .udelay         = 80,
9589 -       .mdelay         = 80,
9590 -       .timeout        = HZ
9591 -};
9592 -
9593 -static struct i2c_adapter bit_elv_ops = {
9594 -       .owner          = THIS_MODULE,
9595 -       .id             = I2C_HW_B_ELV,
9596 -       .algo_data      = &bit_elv_data,
9597 -       .name           = "ELV Parallel port adaptor",
9598 -};
9599 -
9600 -static int __init i2c_bitelv_init(void)
9601 -{
9602 -       printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
9603 -       if (base==0) {
9604 -               /* probe some values */
9605 -               base=DEFAULT_BASE;
9606 -               bit_elv_data.data=(void*)DEFAULT_BASE;
9607 -               if (bit_elv_init()==0) {
9608 -                       if(i2c_bit_add_bus(&bit_elv_ops) < 0)
9609 -                               return -ENODEV;
9610 -               } else {
9611 -                       return -ENODEV;
9612 -               }
9613 -       } else {
9614 -               i2c_set_adapdata(&bit_elv_ops, (void *)base);
9615 -               if (bit_elv_init()==0) {
9616 -                       if(i2c_bit_add_bus(&bit_elv_ops) < 0)
9617 -                               return -ENODEV;
9618 -               } else {
9619 -                       return -ENODEV;
9620 -               }
9621 -       }
9622 -       printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base);
9623 -       return 0;
9624 -}
9625 -
9626 -static void __exit i2c_bitelv_exit(void)
9627 -{
9628 -       i2c_bit_del_bus(&bit_elv_ops);
9629 -       release_region(base , (base == 0x3bc) ? 3 : 8);
9630 -}
9631 -
9632 -MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
9633 -MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter");
9634 -MODULE_LICENSE("GPL");
9635 -
9636 -MODULE_PARM(base, "i");
9637 -
9638 -module_init(i2c_bitelv_init);
9639 -module_exit(i2c_bitelv_exit);
9640 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-frodo.c i2c-2.5/drivers/i2c/i2c-frodo.c
9641 --- linux-2.6.0-test5/drivers/i2c/i2c-frodo.c   Mon Sep  8 19:49:50 2003
9642 +++ i2c-2.5/drivers/i2c/i2c-frodo.c     Thu Jan  1 00:00:00 1970
9643 @@ -1,85 +0,0 @@
9644 -
9645 -/*
9646 - * linux/drivers/i2c/i2c-frodo.c
9647 - *
9648 - * Author: Abraham van der Merwe <abraham@2d3d.co.za>
9649 - *
9650 - * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
9651 - * Development board (Frodo).
9652 - *
9653 - * This source code is free software; you can redistribute it and/or
9654 - * modify it under the terms of the GNU General Public License
9655 - * version 2 as published by the Free Software Foundation.
9656 - */
9657 -
9658 -#include <linux/module.h>
9659 -#include <linux/kernel.h>
9660 -#include <linux/init.h>
9661 -#include <linux/delay.h>
9662 -#include <linux/i2c.h>
9663 -#include <linux/i2c-algo-bit.h>
9664 -#include <asm/hardware.h>
9665 -
9666 -
9667 -static void frodo_setsda (void *data,int state)
9668 -{
9669 -       if (state)
9670 -               FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
9671 -       else
9672 -               FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
9673 -}
9674 -
9675 -static void frodo_setscl (void *data,int state)
9676 -{
9677 -       if (state)
9678 -               FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
9679 -       else
9680 -               FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
9681 -}
9682 -
9683 -static int frodo_getsda (void *data)
9684 -{
9685 -       return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
9686 -}
9687 -
9688 -static int frodo_getscl (void *data)
9689 -{
9690 -       return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
9691 -}
9692 -
9693 -static struct i2c_algo_bit_data bit_frodo_data = {
9694 -       .setsda         = frodo_setsda,
9695 -       .setscl         = frodo_setscl,
9696 -       .getsda         = frodo_getsda,
9697 -       .getscl         = frodo_getscl,
9698 -       .udelay         = 80,
9699 -       .mdelay         = 80,
9700 -       .timeout        = HZ
9701 -};
9702 -
9703 -static struct i2c_adapter frodo_ops = {
9704 -       .owner                  = THIS_MODULE,
9705 -       .id                     = I2C_HW_B_FRODO,
9706 -       .algo_data              = &bit_frodo_data,
9707 -       .dev                    = {
9708 -               .name           = "Frodo adapter driver",
9709 -       },
9710 -};
9711 -
9712 -static int __init i2c_frodo_init (void)
9713 -{
9714 -       return i2c_bit_add_bus(&frodo_ops);
9715 -}
9716 -
9717 -static void __exit i2c_frodo_exit (void)
9718 -{
9719 -       i2c_bit_del_bus(&frodo_ops);
9720 -}
9721 -
9722 -MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
9723 -MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
9724 -MODULE_LICENSE ("GPL");
9725 -
9726 -module_init (i2c_frodo_init);
9727 -module_exit (i2c_frodo_exit);
9728 -
9729 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-iop3xx.c i2c-2.5/drivers/i2c/i2c-iop3xx.c
9730 --- linux-2.6.0-test5/drivers/i2c/i2c-iop3xx.c  Mon Sep  8 19:50:06 2003
9731 +++ i2c-2.5/drivers/i2c/i2c-iop3xx.c    Thu Jan  1 00:00:00 1970
9732 @@ -1,536 +0,0 @@
9733 -/* ------------------------------------------------------------------------- */
9734 -/* i2c-iop3xx.c i2c driver algorithms for Intel XScale IOP3xx                */
9735 -/* ------------------------------------------------------------------------- */
9736 -/*   Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd
9737 - *                      <Peter dot Milne at D hyphen TACQ dot com>
9738 -
9739 -    This program is free software; you can redistribute it and/or modify
9740 -    it under the terms of the GNU General Public License as published by
9741 -    the Free Software Foundation, version 2.
9742 -
9743 -
9744 -    This program is distributed in the hope that it will be useful,
9745 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
9746 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9747 -    GNU General Public License for more details.
9748 -
9749 -    You should have received a copy of the GNU General Public License
9750 -    along with this program; if not, write to the Free Software
9751 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
9752 -/* ------------------------------------------------------------------------- */
9753 -/*
9754 -   With acknowledgements to i2c-algo-ibm_ocp.c by 
9755 -   Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com
9756 -
9757 -   And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund:
9758 -
9759 -     Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund
9760 -   
9761 -   And which acknowledged Kyösti Mälkki <kmalkki@cc.hut.fi>,
9762 -   Frodo Looijaard <frodol@dds.nl>, Martin Bailey<mbailey@littlefeet-inc.com>
9763 -
9764 -  ---------------------------------------------------------------------------*/
9765 -
9766 -
9767 -#include <linux/interrupt.h>
9768 -#include <linux/kernel.h>
9769 -#include <linux/module.h>
9770 -#include <linux/delay.h>
9771 -#include <linux/slab.h>
9772 -#include <linux/init.h>
9773 -#include <linux/errno.h>
9774 -#include <linux/sched.h>
9775 -#include <linux/i2c.h>
9776 -
9777 -
9778 -#include <asm/arch-iop3xx/iop321.h>
9779 -#include <asm/arch-iop3xx/iop321-irqs.h>
9780 -#include "i2c-iop3xx.h"
9781 -
9782 -
9783 -/* ----- global defines ----------------------------------------------- */
9784 -#define PASSERT(x) do { if (!(x) ) \
9785 -               printk(KERN_CRIT "PASSERT %s in %s:%d\n", #x, __FILE__, __LINE__ );\
9786 -       } while (0)
9787 -
9788 -
9789 -/* ----- global variables ---------------------------------------------        */
9790 -
9791 -
9792 -static inline unsigned char iic_cook_addr(struct i2c_msg *msg) 
9793 -{
9794 -       unsigned char addr;
9795 -
9796 -       addr = (msg->addr << 1);
9797 -
9798 -       if (msg->flags & I2C_M_RD)
9799 -               addr |= 1;
9800 -
9801 -       /* PGM: what is M_REV_DIR_ADDR - do we need it ?? */
9802 -       if (msg->flags & I2C_M_REV_DIR_ADDR)
9803 -               addr ^= 1;
9804 -
9805 -       return addr;   
9806 -}
9807 -
9808 -
9809 -static inline void iop3xx_adap_reset(struct i2c_algo_iop3xx_data *iop3xx_adap)
9810 -{
9811 -       /* Follows devman 9.3 */
9812 -       *iop3xx_adap->biu->CR = IOP321_ICR_UNIT_RESET;
9813 -       *iop3xx_adap->biu->SR = IOP321_ISR_CLEARBITS;
9814 -       *iop3xx_adap->biu->CR = 0;
9815 -} 
9816 -
9817 -static inline void iop3xx_adap_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap)
9818 -{
9819 -       *iop3xx_adap->biu->SAR = MYSAR;
9820 -}
9821 -
9822 -static inline void iop3xx_adap_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
9823 -{
9824 -       u32 cr = IOP321_ICR_GCD|IOP321_ICR_SCLEN|IOP321_ICR_UE;
9825 -
9826 -       /* NB SR bits not same position as CR IE bits :-( */
9827 -       iop3xx_adap->biu->SR_enabled = 
9828 -               IOP321_ISR_ALD | IOP321_ISR_BERRD |
9829 -               IOP321_ISR_RXFULL | IOP321_ISR_TXEMPTY;
9830 -
9831 -       cr |= IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
9832 -               IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE;
9833 -
9834 -       *iop3xx_adap->biu->CR = cr;
9835 -}
9836 -
9837 -static void iop3xx_adap_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
9838 -{
9839 -       unsigned cr = *iop3xx_adap->biu->CR;
9840 -       
9841 -       cr &= ~(IOP321_ICR_MSTART | IOP321_ICR_TBYTE | 
9842 -               IOP321_ICR_MSTOP | IOP321_ICR_SCLEN);
9843 -       *iop3xx_adap->biu->CR = cr;
9844 -}
9845 -
9846 -static void iop3xx_adap_final_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
9847 -{
9848 -       unsigned cr = *iop3xx_adap->biu->CR;
9849 -       
9850 -       cr &= ~(IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
9851 -               IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE);
9852 -       iop3xx_adap->biu->SR_enabled = 0;
9853 -       *iop3xx_adap->biu->CR = cr;
9854 -}
9855 -
9856 -/* 
9857 - * NB: the handler has to clear the source of the interrupt! 
9858 - * Then it passes the SR flags of interest to BH via adap data
9859 - */
9860 -static void iop3xx_i2c_handler(int this_irq, 
9861 -                               void *dev_id, 
9862 -                               struct pt_regs *regs) 
9863 -{
9864 -       struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id;
9865 -
9866 -       u32 sr = *iop3xx_adap->biu->SR;
9867 -
9868 -       if ((sr &= iop3xx_adap->biu->SR_enabled)) {
9869 -               *iop3xx_adap->biu->SR = sr;
9870 -               iop3xx_adap->biu->SR_received |= sr;
9871 -               wake_up_interruptible(&iop3xx_adap->waitq);
9872 -       }
9873 -}
9874 -
9875 -/* check all error conditions, clear them , report most important */
9876 -static int iop3xx_adap_error(u32 sr)
9877 -{
9878 -       int rc = 0;
9879 -
9880 -       if ((sr&IOP321_ISR_BERRD)) {
9881 -               if ( !rc ) rc = -I2C_ERR_BERR;
9882 -       }
9883 -       if ((sr&IOP321_ISR_ALD)) {
9884 -               if ( !rc ) rc = -I2C_ERR_ALD;           
9885 -       }
9886 -       return rc;      
9887 -}
9888 -
9889 -static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap)
9890 -{
9891 -       unsigned long flags;
9892 -       u32 sr;
9893 -
9894 -       spin_lock_irqsave(&iop3xx_adap->lock, flags);
9895 -       sr = iop3xx_adap->biu->SR_received;
9896 -       iop3xx_adap->biu->SR_received = 0;
9897 -       spin_unlock_irqrestore(&iop3xx_adap->lock, flags);
9898 -
9899 -       return sr;
9900 -}
9901 -
9902 -/*
9903 - * sleep until interrupted, then recover and analyse the SR
9904 - * saved by handler
9905 - */
9906 -typedef int (* compare_func)(unsigned test, unsigned mask);
9907 -/* returns 1 on correct comparison */
9908 -
9909 -static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap, 
9910 -                                 unsigned flags, unsigned* status,
9911 -                                 compare_func compare)
9912 -{
9913 -       unsigned sr = 0;
9914 -       int interrupted;
9915 -       int done;
9916 -       int rc;
9917 -
9918 -       do {
9919 -               interrupted = wait_event_interruptible_timeout (
9920 -                       iop3xx_adap->waitq,
9921 -                       (done = compare( sr = get_srstat(iop3xx_adap),flags )),
9922 -                       iop3xx_adap->timeout
9923 -                       );
9924 -               if ((rc = iop3xx_adap_error(sr)) < 0) {
9925 -                       *status = sr;
9926 -                       return rc;
9927 -               }else if (!interrupted) {
9928 -                       *status = sr;
9929 -                       return rc = -ETIMEDOUT;
9930 -               }
9931 -       } while(!done);
9932 -
9933 -       *status = sr;
9934 -
9935 -       return rc = 0;
9936 -}
9937 -
9938 -/*
9939 - * Concrete compare_funcs 
9940 - */
9941 -static int all_bits_clear(unsigned test, unsigned mask)
9942 -{
9943 -       return (test & mask) == 0;
9944 -}
9945 -static int any_bits_set(unsigned test, unsigned mask)
9946 -{
9947 -       return (test & mask) != 0;
9948 -}
9949 -
9950 -static int iop3xx_adap_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9951 -{
9952 -       return iop3xx_adap_wait_event( 
9953 -               iop3xx_adap, 
9954 -               IOP321_ISR_TXEMPTY|IOP321_ISR_ALD|IOP321_ISR_BERRD,
9955 -               status, any_bits_set);
9956 -}
9957 -
9958 -static int iop3xx_adap_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9959 -{
9960 -       return iop3xx_adap_wait_event( 
9961 -               iop3xx_adap, 
9962 -               IOP321_ISR_RXFULL|IOP321_ISR_ALD|IOP321_ISR_BERRD,
9963 -               status, any_bits_set);
9964 -}
9965 -
9966 -static int iop3xx_adap_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9967 -{
9968 -       return iop3xx_adap_wait_event( 
9969 -               iop3xx_adap, IOP321_ISR_UNITBUSY, status, all_bits_clear);
9970 -}
9971 -
9972 -/*
9973 - * Description: This performs the IOP3xx initialization sequence
9974 - * Valid for IOP321. Maybe valid for IOP310?.
9975 - */
9976 -static int iop3xx_adap_init (struct i2c_algo_iop3xx_data *iop3xx_adap)
9977 -{
9978 -       *IOP321_GPOD &= ~(iop3xx_adap->channel==0 ?
9979 -                         IOP321_GPOD_I2C0:
9980 -                         IOP321_GPOD_I2C1);
9981 -
9982 -       iop3xx_adap_reset(iop3xx_adap);
9983 -       iop3xx_adap_set_slave_addr(iop3xx_adap);
9984 -       iop3xx_adap_enable(iop3xx_adap);
9985 -       
9986 -        return 0;
9987 -}
9988 -
9989 -static int iop3xx_adap_send_target_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap,
9990 -                                             struct i2c_msg* msg)
9991 -{
9992 -       unsigned cr = *iop3xx_adap->biu->CR;
9993 -       int status;
9994 -       int rc;
9995 -
9996 -       *iop3xx_adap->biu->DBR = iic_cook_addr(msg);
9997 -       
9998 -       cr &= ~(IOP321_ICR_MSTOP | IOP321_ICR_NACK);
9999 -       cr |= IOP321_ICR_MSTART | IOP321_ICR_TBYTE;
10000 -
10001 -       *iop3xx_adap->biu->CR = cr;
10002 -       rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
10003 -       /* this assert fires every time, contrary to IOP manual 
10004 -       PASSERT((status&IOP321_ISR_UNITBUSY)!=0);
10005 -       */
10006 -       PASSERT((status&IOP321_ISR_RXREAD)==0);
10007 -            
10008 -       return rc;
10009 -}
10010 -
10011 -static int iop3xx_adap_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, int stop)
10012 -{
10013 -       unsigned cr = *iop3xx_adap->biu->CR;
10014 -       int status;
10015 -       int rc;
10016 -
10017 -       *iop3xx_adap->biu->DBR = byte;
10018 -       cr &= ~IOP321_ICR_MSTART;
10019 -       if (stop) {
10020 -               cr |= IOP321_ICR_MSTOP;
10021 -       } else {
10022 -               cr &= ~IOP321_ICR_MSTOP;
10023 -       }
10024 -       *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
10025 -       rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
10026 -
10027 -       return rc;
10028 -} 
10029 -
10030 -static int iop3xx_adap_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap,
10031 -                                char* byte, int stop)
10032 -{
10033 -       unsigned cr = *iop3xx_adap->biu->CR;
10034 -       int status;
10035 -       int rc;
10036 -
10037 -       cr &= ~IOP321_ICR_MSTART;
10038 -
10039 -       if (stop) {
10040 -               cr |= IOP321_ICR_MSTOP|IOP321_ICR_NACK;
10041 -       } else {
10042 -               cr &= ~(IOP321_ICR_MSTOP|IOP321_ICR_NACK);
10043 -       }
10044 -       *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
10045 -
10046 -       rc = iop3xx_adap_wait_rx_done(iop3xx_adap, &status);
10047 -
10048 -       *byte = *iop3xx_adap->biu->DBR;
10049 -
10050 -       return rc;
10051 -}
10052 -
10053 -static int iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap, 
10054 -                                const char *buf, int count)
10055 -{
10056 -       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10057 -       int ii;
10058 -       int rc = 0;
10059 -
10060 -       for (ii = 0; rc == 0 && ii != count; ++ii) {
10061 -               rc = iop3xx_adap_write_byte(iop3xx_adap, buf[ii], ii==count-1);
10062 -       }
10063 -       return rc;
10064 -}
10065 -
10066 -static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap, 
10067 -                               char *buf, int count)
10068 -{
10069 -       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10070 -       int ii;
10071 -       int rc = 0;
10072 -
10073 -       for (ii = 0; rc == 0 && ii != count; ++ii) {
10074 -               rc = iop3xx_adap_read_byte(iop3xx_adap, &buf[ii], ii==count-1);
10075 -       }
10076 -       return rc;
10077 -}
10078 -
10079 -/*
10080 - * Description:  This function implements combined transactions.  Combined
10081 - * transactions consist of combinations of reading and writing blocks of data.
10082 - * FROM THE SAME ADDRESS
10083 - * Each transfer (i.e. a read or a write) is separated by a repeated start
10084 - * condition.
10085 - */
10086 -static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg) 
10087 -{
10088 -       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10089 -       int rc;
10090 -
10091 -       rc = iop3xx_adap_send_target_slave_addr(iop3xx_adap, pmsg);
10092 -       if (rc < 0) {
10093 -               return rc;
10094 -       }
10095 -
10096 -       if ((pmsg->flags&I2C_M_RD)) {
10097 -               return iop3xx_i2c_readbytes(i2c_adap, pmsg->buf, pmsg->len);
10098 -       } else {
10099 -               return iop3xx_i2c_writebytes(i2c_adap, pmsg->buf, pmsg->len);
10100 -       }
10101 -}
10102 -
10103 -/*
10104 - * master_xfer() - main read/write entry
10105 - */
10106 -static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
10107 -{
10108 -       struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10109 -       int im = 0;
10110 -       int ret = 0;
10111 -       int status;
10112 -
10113 -       iop3xx_adap_wait_idle(iop3xx_adap, &status);
10114 -       iop3xx_adap_reset(iop3xx_adap);
10115 -       iop3xx_adap_enable(iop3xx_adap);
10116 -
10117 -       for (im = 0; ret == 0 && im != num; ++im) {
10118 -               ret = iop3xx_handle_msg(i2c_adap, &msgs[im]);
10119 -       }
10120 -
10121 -       iop3xx_adap_transaction_cleanup(iop3xx_adap);
10122 -
10123 -       return ret;   
10124 -}
10125 -
10126 -static int algo_control(struct i2c_adapter *adapter, unsigned int cmd,
10127 -                       unsigned long arg)
10128 -{
10129 -       return 0;
10130 -}
10131 -
10132 -static u32 iic_func(struct i2c_adapter *adap)
10133 -{
10134 -       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
10135 -}
10136 -
10137 -
10138 -/* -----exported algorithm data: ------------------------------------- */
10139 -
10140 -static struct i2c_algorithm iic_algo = {
10141 -       .name           = "IOP3xx I2C algorithm",
10142 -       .id             = I2C_ALGO_OCP_IOP3XX,
10143 -       .master_xfer    = iop3xx_master_xfer,
10144 -       .algo_control   = algo_control,
10145 -       .functionality  = iic_func,
10146 -};
10147 -
10148 -/* 
10149 - * registering functions to load algorithms at runtime 
10150 - */
10151 -static int i2c_iop3xx_add_bus(struct i2c_adapter *iic_adap)
10152 -{
10153 -       struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
10154 -
10155 -       if (!request_region( REGION_START(iop3xx_adap), 
10156 -                             REGION_LENGTH(iop3xx_adap),
10157 -                             iic_adap->name)) {
10158 -               return -ENODEV;
10159 -       }
10160 -
10161 -       init_waitqueue_head(&iop3xx_adap->waitq);
10162 -       spin_lock_init(&iop3xx_adap->lock);
10163 -
10164 -       if (request_irq( 
10165 -                    iop3xx_adap->biu->irq,
10166 -                    iop3xx_i2c_handler,
10167 -                    /* SA_SAMPLE_RANDOM */ 0,
10168 -                    iic_adap->name,
10169 -                    iop3xx_adap)) {
10170 -               return -ENODEV;
10171 -       }                         
10172 -
10173 -       /* register new iic_adapter to i2c module... */
10174 -       iic_adap->id |= iic_algo.id;
10175 -       iic_adap->algo = &iic_algo;
10176 -
10177 -       iic_adap->timeout = 100;        /* default values, should */
10178 -       iic_adap->retries = 3;          /* be replaced by defines */
10179 -
10180 -       iop3xx_adap_init(iic_adap->algo_data);
10181 -       i2c_add_adapter(iic_adap);
10182 -       return 0;
10183 -}
10184 -
10185 -static int i2c_iop3xx_del_bus(struct i2c_adapter *iic_adap)
10186 -{
10187 -       struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
10188 -
10189 -       iop3xx_adap_final_cleanup(iop3xx_adap);
10190 -       free_irq(iop3xx_adap->biu->irq, iop3xx_adap);
10191 -
10192 -       release_region(REGION_START(iop3xx_adap), REGION_LENGTH(iop3xx_adap));
10193 -
10194 -       return i2c_del_adapter(iic_adap);
10195 -}
10196 -
10197 -#ifdef CONFIG_ARCH_IOP321
10198 -
10199 -static struct iop3xx_biu biu0 = {
10200 -       .CR     = IOP321_ICR0,
10201 -       .SR     = IOP321_ISR0,
10202 -       .SAR    = IOP321_ISAR0,
10203 -       .DBR    = IOP321_IDBR0,
10204 -       .BMR    = IOP321_IBMR0,
10205 -       .irq    = IRQ_IOP321_I2C_0,
10206 -};
10207 -
10208 -static struct iop3xx_biu biu1 = {
10209 -       .CR     = IOP321_ICR1,
10210 -       .SR     = IOP321_ISR1,
10211 -       .SAR    = IOP321_ISAR1,
10212 -       .DBR    = IOP321_IDBR1,
10213 -       .BMR    = IOP321_IBMR1,
10214 -       .irq    = IRQ_IOP321_I2C_1,
10215 -};
10216 -
10217 -#define ADAPTER_NAME_ROOT "IOP321 i2c biu adapter "
10218 -#else
10219 -#error Please define the BIU struct iop3xx_biu for your processor arch
10220 -#endif
10221 -
10222 -static struct i2c_algo_iop3xx_data algo_iop3xx_data0 = {
10223 -       .channel                = 0,
10224 -       .biu                    = &biu0,
10225 -       .timeout                = 1*HZ,
10226 -};
10227 -static struct i2c_algo_iop3xx_data algo_iop3xx_data1 = {
10228 -       .channel                = 1,
10229 -       .biu                    = &biu1,
10230 -       .timeout                = 1*HZ,
10231 -};
10232 -
10233 -static struct i2c_adapter iop3xx_ops0 = {
10234 -       .owner                  = THIS_MODULE,
10235 -       .name                   = ADAPTER_NAME_ROOT "0",
10236 -       .id                     = I2C_HW_IOP321,
10237 -       .algo_data              = &algo_iop3xx_data0,
10238 -};
10239 -static struct i2c_adapter iop3xx_ops1 = {
10240 -       .owner                  = THIS_MODULE,
10241 -       .name                   = ADAPTER_NAME_ROOT "1",
10242 -       .id                     = I2C_HW_IOP321,
10243 -       .algo_data              = &algo_iop3xx_data1,
10244 -};
10245 -
10246 -static int __init i2c_iop3xx_init (void)
10247 -{
10248 -       return i2c_iop3xx_add_bus(&iop3xx_ops0) ||
10249 -               i2c_iop3xx_add_bus(&iop3xx_ops1);
10250 -}
10251 -
10252 -static void __exit i2c_iop3xx_exit (void)
10253 -{
10254 -       i2c_iop3xx_del_bus(&iop3xx_ops0);
10255 -       i2c_iop3xx_del_bus(&iop3xx_ops1);
10256 -}
10257 -
10258 -module_init (i2c_iop3xx_init);
10259 -module_exit (i2c_iop3xx_exit);
10260 -
10261 -MODULE_AUTHOR("D-TACQ Solutions Ltd <www.d-tacq.com>");
10262 -MODULE_DESCRIPTION("IOP3xx iic algorithm and driver");
10263 -MODULE_LICENSE("GPL");
10264 -
10265 -MODULE_PARM(i2c_debug,"i");
10266 -
10267 -MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
10268 -
10269 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-iop3xx.h i2c-2.5/drivers/i2c/i2c-iop3xx.h
10270 --- linux-2.6.0-test5/drivers/i2c/i2c-iop3xx.h  Mon Sep  8 19:49:50 2003
10271 +++ i2c-2.5/drivers/i2c/i2c-iop3xx.h    Thu Jan  1 00:00:00 1970
10272 @@ -1,118 +0,0 @@
10273 -/* ------------------------------------------------------------------------- */
10274 -/* i2c-iop3xx.h algorithm driver definitions private to i2c-iop3xx.c         */
10275 -/* ------------------------------------------------------------------------- */
10276 -/*   Copyright (C) 2003 Peter Milne, D-TACQ Solutions Ltd
10277 - *                      <Peter dot Milne at D hyphen TACQ dot com>
10278 -
10279 -    This program is free software; you can redistribute it and/or modify
10280 -    it under the terms of the GNU General Public License as published by
10281 -    the Free Software Foundation, version 2.
10282 -
10283 -    This program is distributed in the hope that it will be useful,
10284 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
10285 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10286 -    GNU General Public License for more details.
10287 -
10288 -    You should have received a copy of the GNU General Public License
10289 -    along with this program; if not, write to the Free Software
10290 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
10291 -/* ------------------------------------------------------------------------- */
10292 -
10293 -
10294 -#ifndef I2C_IOP3XX_H
10295 -#define I2C_IOP3XX_H 1
10296 -
10297 -/*
10298 - * iop321 hardware bit definitions
10299 - */
10300 -#define IOP321_ICR_FAST_MODE   0x8000  /* 1=400kBps, 0=100kBps */
10301 -#define IOP321_ICR_UNIT_RESET  0x4000  /* 1=RESET */
10302 -#define IOP321_ICR_SADIE       0x2000  /* 1=Slave Detect Interrupt Enable */
10303 -#define IOP321_ICR_ALDIE       0x1000  /* 1=Arb Loss Detect Interrupt Enable */
10304 -#define IOP321_ICR_SSDIE       0x0800  /* 1=Slave STOP Detect Interrupt Enable */
10305 -#define IOP321_ICR_BERRIE      0x0400  /* 1=Bus Error Interrupt Enable */
10306 -#define IOP321_ICR_RXFULLIE    0x0200  /* 1=Receive Full Interrupt Enable */
10307 -#define IOP321_ICR_TXEMPTYIE   0x0100  /* 1=Transmit Empty Interrupt Enable */
10308 -#define IOP321_ICR_GCD         0x0080  /* 1=General Call Disable */
10309 -/*
10310 - * IOP321_ICR_GCD: 1 disables response as slave. "This bit must be set
10311 - * when sending a master mode general call message from the I2C unit"
10312 - */
10313 -#define IOP321_ICR_UE          0x0040  /* 1=Unit Enable */
10314 -/*
10315 - * "NOTE: To avoid I2C bus integrity problems, 
10316 - * the user needs to ensure that the GPIO Output Data Register - 
10317 - * GPOD bits associated with an I2C port are cleared prior to setting 
10318 - * the enable bit for that I2C serial port. 
10319 - * The user prepares to enable I2C port 0 and 
10320 - * I2C port 1 by clearing GPOD bits 7:6 and GPOD bits 5:4, respectively.
10321 - */
10322 -#define IOP321_ICR_SCLEN       0x0020  /* 1=SCL enable for master mode */
10323 -#define IOP321_ICR_MABORT      0x0010  /* 1=Send a STOP with no data 
10324 -                                        * NB TBYTE must be clear */
10325 -#define IOP321_ICR_TBYTE       0x0008  /* 1=Send/Receive a byte. i2c clears */
10326 -#define IOP321_ICR_NACK                0x0004  /* 1=reply with NACK */
10327 -#define IOP321_ICR_MSTOP       0x0002  /* 1=send a STOP after next data byte */
10328 -#define IOP321_ICR_MSTART      0x0001  /* 1=initiate a START */
10329 -
10330 -
10331 -#define IOP321_ISR_BERRD       0x0400  /* 1=BUS ERROR Detected */
10332 -#define IOP321_ISR_SAD         0x0200  /* 1=Slave ADdress Detected */
10333 -#define IOP321_ISR_GCAD                0x0100  /* 1=General Call Address Detected */
10334 -#define IOP321_ISR_RXFULL      0x0080  /* 1=Receive Full */
10335 -#define IOP321_ISR_TXEMPTY     0x0040  /* 1=Transmit Empty */
10336 -#define IOP321_ISR_ALD         0x0020  /* 1=Arbitration Loss Detected */
10337 -#define IOP321_ISR_SSD         0x0010  /* 1=Slave STOP Detected */
10338 -#define IOP321_ISR_BBUSY       0x0008  /* 1=Bus BUSY */
10339 -#define IOP321_ISR_UNITBUSY    0x0004  /* 1=Unit Busy */
10340 -#define IOP321_ISR_NACK                0x0002  /* 1=Unit Rx or Tx a NACK */
10341 -#define IOP321_ISR_RXREAD      0x0001  /* 1=READ 0=WRITE (R/W bit of slave addr */
10342 -
10343 -#define IOP321_ISR_CLEARBITS   0x07f0
10344 -
10345 -#define IOP321_ISAR_SAMASK     0x007f
10346 -
10347 -#define IOP321_IDBR_MASK       0x00ff
10348 -
10349 -#define IOP321_IBMR_SCL                0x0002
10350 -#define IOP321_IBMR_SDA                0x0001
10351 -
10352 -#define IOP321_GPOD_I2C0       0x00c0  /* clear these bits to enable ch0 */
10353 -#define IOP321_GPOD_I2C1       0x0030  /* clear these bits to enable ch1 */
10354 -
10355 -#define MYSAR                  0x02    /* SWAG a suitable slave address */
10356 -
10357 -#define I2C_ERR                        321
10358 -#define I2C_ERR_BERR           (I2C_ERR+0)
10359 -#define I2C_ERR_ALD            (I2C_ERR+1)
10360 -
10361 -
10362 -struct iop3xx_biu {                /* Bus Interface Unit - the hardware */
10363 -/* physical hardware defs - regs*/
10364 -       u32 *CR;
10365 -       u32 *SR;
10366 -       u32 *SAR;
10367 -       u32 *DBR;
10368 -       u32 *BMR;
10369 -/* irq bit vector */
10370 -       u32 irq;
10371 -/* stored flags */
10372 -       u32 SR_enabled, SR_received;
10373 -};
10374 -
10375 -struct i2c_algo_iop3xx_data {
10376 -       int channel;
10377 -
10378 -       wait_queue_head_t waitq;
10379 -       spinlock_t lock;
10380 -       int timeout;
10381 -       struct iop3xx_biu* biu;
10382 -};
10383 -
10384 -#define REGION_START(adap)     ((u32)((adap)->biu->CR))
10385 -#define REGION_END(adap)       ((u32)((adap)->biu->BMR+1))
10386 -#define REGION_LENGTH(adap)    (REGION_END(adap)-REGION_START(adap))
10387 -
10388 -#define IRQ_STATUS_MASK(adap)  (1<<adap->biu->irq)
10389 -
10390 -#endif /* I2C_IOP3XX_H */
10391 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-keywest.c i2c-2.5/drivers/i2c/i2c-keywest.c
10392 --- linux-2.6.0-test5/drivers/i2c/i2c-keywest.c Mon Sep  8 19:50:16 2003
10393 +++ i2c-2.5/drivers/i2c/i2c-keywest.c   Thu Jan  1 00:00:00 1970
10394 @@ -1,654 +0,0 @@
10395 -/*
10396 -    i2c Support for Apple Keywest I2C Bus Controller
10397 -
10398 -    Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
10399 -
10400 -    Original work by
10401 -    
10402 -    Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
10403 -
10404 -    This program is free software; you can redistribute it and/or modify
10405 -    it under the terms of the GNU General Public License as published by
10406 -    the Free Software Foundation; either version 2 of the License, or
10407 -    (at your option) any later version.
10408 -
10409 -    This program is distributed in the hope that it will be useful,
10410 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
10411 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10412 -    GNU General Public License for more details.
10413 -
10414 -    You should have received a copy of the GNU General Public License
10415 -    along with this program; if not, write to the Free Software
10416 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10417 -
10418 -    Changes:
10419 -
10420 -    2001/12/13 BenH    New implementation
10421 -    2001/12/15 BenH    Add support for "byte" and "quick"
10422 -                        transfers. Add i2c_xfer routine.
10423 -
10424 -    My understanding of the various modes supported by keywest are:
10425 -
10426 -     - Dumb mode : not implemented, probably direct tweaking of lines
10427 -     - Standard mode : simple i2c transaction of type
10428 -         S Addr R/W A Data A Data ... T
10429 -     - Standard sub mode : combined 8 bit subaddr write with data read
10430 -         S Addr R/W A SubAddr A Data A Data ... T
10431 -     - Combined mode : Subaddress and Data sequences appended with no stop
10432 -         S Addr R/W A SubAddr S Addr R/W A Data A Data ... T
10433 -
10434 -    Currently, this driver uses only Standard mode for i2c xfer, and
10435 -    smbus byte & quick transfers ; and uses StandardSub mode for
10436 -    other smbus transfers instead of combined as we need that for the
10437 -    sound driver to be happy
10438 -*/
10439 -
10440 -#include <linux/module.h>
10441 -#include <linux/config.h>
10442 -#include <linux/version.h>
10443 -#include <linux/kernel.h>
10444 -#include <linux/ioport.h>
10445 -#include <linux/pci.h>
10446 -#include <linux/types.h>
10447 -#include <linux/delay.h>
10448 -#include <linux/i2c.h>
10449 -#include <linux/init.h>
10450 -#include <linux/mm.h>
10451 -#include <linux/timer.h>
10452 -#include <linux/spinlock.h>
10453 -#include <linux/completion.h>
10454 -#include <linux/interrupt.h>
10455 -
10456 -#include <asm/io.h>
10457 -#include <asm/prom.h>
10458 -#include <asm/machdep.h>
10459 -#include <asm/pmac_feature.h>
10460 -
10461 -#include "i2c-keywest.h"
10462 -
10463 -#define DBG(x...) do {\
10464 -       if (debug > 0) \
10465 -               printk(KERN_DEBUG "KW:" x); \
10466 -       } while(0)
10467 -
10468 -
10469 -MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
10470 -MODULE_DESCRIPTION("I2C driver for Apple's Keywest");
10471 -MODULE_LICENSE("GPL");
10472 -MODULE_PARM(probe, "i");
10473 -MODULE_PARM(debug, "i");
10474 -
10475 -int probe = 0;
10476 -int debug = 0;
10477 -
10478 -static void
10479 -do_stop(struct keywest_iface* iface, int result)
10480 -{
10481 -       write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_STOP);
10482 -       iface->state = state_stop;
10483 -       iface->result = result;
10484 -}
10485 -
10486 -/* Main state machine for standard & standard sub mode */
10487 -static int
10488 -handle_interrupt(struct keywest_iface *iface, u8 isr)
10489 -{
10490 -       int ack;
10491 -       int rearm_timer = 1;
10492 -       
10493 -       DBG("handle_interrupt(), got: %x, status: %x, state: %d\n",
10494 -               isr, read_reg(reg_status), iface->state);
10495 -       if (isr == 0 && iface->state != state_stop) {
10496 -               do_stop(iface, -1);
10497 -               return rearm_timer;
10498 -       }
10499 -       if (isr & KW_I2C_IRQ_STOP && iface->state != state_stop) {
10500 -               iface->result = -1;
10501 -               iface->state = state_stop;
10502 -       }
10503 -       switch(iface->state) {
10504 -       case state_addr:
10505 -               if (!(isr & KW_I2C_IRQ_ADDR)) {
10506 -                       do_stop(iface, -1);
10507 -                       break;
10508 -               }
10509 -               ack = read_reg(reg_status);
10510 -               DBG("ack on set address: %x\n", ack);
10511 -               if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
10512 -                       do_stop(iface, -1);
10513 -                       break;
10514 -               }
10515 -               /* Handle rw "quick" mode */
10516 -               if (iface->datalen == 0)
10517 -                       do_stop(iface, 0);
10518 -               else if (iface->read_write == I2C_SMBUS_READ) {
10519 -                       iface->state = state_read;
10520 -                       if (iface->datalen > 1)
10521 -                               write_reg(reg_control, read_reg(reg_control)
10522 -                                       | KW_I2C_CTL_AAK);
10523 -               } else {
10524 -                       iface->state = state_write;
10525 -                       DBG("write byte: %x\n", *(iface->data));
10526 -                       write_reg(reg_data, *(iface->data++));
10527 -                       iface->datalen--;
10528 -               }
10529 -               
10530 -               break;
10531 -       case state_read:
10532 -               if (!(isr & KW_I2C_IRQ_DATA)) {
10533 -                       do_stop(iface, -1);
10534 -                       break;
10535 -               }
10536 -               *(iface->data++) = read_reg(reg_data);
10537 -               DBG("read byte: %x\n", *(iface->data-1));
10538 -               iface->datalen--;
10539 -               if (iface->datalen == 0)
10540 -                       iface->state = state_stop;
10541 -               else
10542 -                       write_reg(reg_control, 0);
10543 -               break;
10544 -       case state_write:
10545 -               if (!(isr & KW_I2C_IRQ_DATA)) {
10546 -                       do_stop(iface, -1);
10547 -                       break;
10548 -               }
10549 -               /* Check ack status */
10550 -               ack = read_reg(reg_status);
10551 -               DBG("ack on data write: %x\n", ack);
10552 -               if ((ack & KW_I2C_STAT_LAST_AAK) == 0) {
10553 -                       do_stop(iface, -1);
10554 -                       break;
10555 -               }
10556 -               if (iface->datalen) {
10557 -                       DBG("write byte: %x\n", *(iface->data));
10558 -                       write_reg(reg_data, *(iface->data++));
10559 -                       iface->datalen--;
10560 -               } else
10561 -                       do_stop(iface, 0);
10562 -               break;
10563 -               
10564 -       case state_stop:
10565 -               if (!(isr & KW_I2C_IRQ_STOP) && (++iface->stopretry) < 10)
10566 -                       do_stop(iface, -1);
10567 -               else {
10568 -                       rearm_timer = 0;
10569 -                       iface->state = state_idle;
10570 -                       write_reg(reg_control, 0x00);
10571 -                       write_reg(reg_ier, 0x00);
10572 -                       complete(&iface->complete);
10573 -               }
10574 -               break;
10575 -       }
10576 -       
10577 -       write_reg(reg_isr, isr);
10578 -
10579 -       return rearm_timer;
10580 -}
10581 -
10582 -/* Interrupt handler */
10583 -static irqreturn_t
10584 -keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
10585 -{
10586 -       struct keywest_iface *iface = (struct keywest_iface *)dev_id;
10587 -
10588 -       spin_lock(&iface->lock);
10589 -       del_timer(&iface->timeout_timer);
10590 -       if (handle_interrupt(iface, read_reg(reg_isr)))
10591 -               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
10592 -       spin_unlock(&iface->lock);
10593 -       return IRQ_HANDLED;
10594 -}
10595 -
10596 -static void
10597 -keywest_timeout(unsigned long data)
10598 -{
10599 -       struct keywest_iface *iface = (struct keywest_iface *)data;
10600 -
10601 -       DBG("timeout !\n");
10602 -       spin_lock_irq(&iface->lock);
10603 -       if (handle_interrupt(iface, read_reg(reg_isr)))
10604 -               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
10605 -       spin_unlock(&iface->lock);
10606 -}
10607 -
10608 -/*
10609 - * SMBUS-type transfer entrypoint
10610 - */
10611 -static s32
10612 -keywest_smbus_xfer(    struct i2c_adapter*     adap,
10613 -                       u16                     addr,
10614 -                       unsigned short          flags,
10615 -                       char                    read_write,
10616 -                       u8                      command,
10617 -                       int                     size,
10618 -                       union i2c_smbus_data*   data)
10619 -{
10620 -       struct keywest_chan* chan = i2c_get_adapdata(adap);
10621 -       struct keywest_iface* iface = chan->iface;
10622 -       int len;
10623 -       u8* buffer;
10624 -       u16 cur_word;
10625 -       int rc = 0;
10626 -
10627 -       if (iface->state == state_dead)
10628 -               return -1;
10629 -               
10630 -       /* Prepare datas & select mode */
10631 -       iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
10632 -       switch (size) {
10633 -           case I2C_SMBUS_QUICK:
10634 -               len = 0;
10635 -               buffer = NULL;
10636 -               iface->cur_mode |= KW_I2C_MODE_STANDARD;
10637 -               break;
10638 -           case I2C_SMBUS_BYTE:
10639 -               len = 1;
10640 -               buffer = &data->byte;
10641 -               iface->cur_mode |= KW_I2C_MODE_STANDARD;
10642 -               break;
10643 -           case I2C_SMBUS_BYTE_DATA:
10644 -               len = 1;
10645 -               buffer = &data->byte;
10646 -               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10647 -               break;
10648 -           case I2C_SMBUS_WORD_DATA:
10649 -               len = 2;
10650 -               cur_word = cpu_to_le16(data->word);
10651 -               buffer = (u8 *)&cur_word;
10652 -               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10653 -               break;
10654 -           case I2C_SMBUS_BLOCK_DATA:
10655 -               len = data->block[0];
10656 -               buffer = &data->block[1];
10657 -               iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10658 -               break;
10659 -           default:
10660 -               return -1;
10661 -       }
10662 -
10663 -       /* Original driver had this limitation */
10664 -       if (len > 32)
10665 -               len = 32;
10666 -
10667 -       down(&iface->sem);
10668 -
10669 -       DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
10670 -               chan->chan_no, addr, len, read_write == I2C_SMBUS_READ);
10671 -
10672 -       iface->data = buffer;
10673 -       iface->datalen = len;
10674 -       iface->state = state_addr;
10675 -       iface->result = 0;
10676 -       iface->stopretry = 0;
10677 -       iface->read_write = read_write;
10678 -       
10679 -       /* Setup channel & clear pending irqs */
10680 -       write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4));
10681 -       write_reg(reg_isr, read_reg(reg_isr));
10682 -       write_reg(reg_status, 0);
10683 -
10684 -       /* Set up address and r/w bit */
10685 -       write_reg(reg_addr,
10686 -               (addr << 1) | ((read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
10687 -
10688 -       /* Set up the sub address */
10689 -       if ((iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_STANDARDSUB
10690 -           || (iface->cur_mode & KW_I2C_MODE_MODE_MASK) == KW_I2C_MODE_COMBINED)
10691 -               write_reg(reg_subaddr, command);
10692 -
10693 -       /* Arm timeout */
10694 -       mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
10695 -
10696 -       /* Start sending address & enable interrupt*/
10697 -       write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
10698 -       write_reg(reg_ier, KW_I2C_IRQ_MASK);
10699 -
10700 -       /* Wait interrupt operations completion */
10701 -       wait_for_completion(&iface->complete);  
10702 -
10703 -       rc = iface->result;     
10704 -       DBG("transfer done, result: %d\n", rc);
10705 -
10706 -       if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ)
10707 -               data->word = le16_to_cpu(cur_word);
10708 -       
10709 -       /* Release sem */
10710 -       up(&iface->sem);
10711 -       
10712 -       return rc;
10713 -}
10714 -
10715 -/*
10716 - * Generic i2c master transfer entrypoint
10717 - */
10718 -static int
10719 -keywest_xfer(  struct i2c_adapter *adap,
10720 -               struct i2c_msg msgs[], 
10721 -               int num)
10722 -{
10723 -       struct keywest_chan* chan = i2c_get_adapdata(adap);
10724 -       struct keywest_iface* iface = chan->iface;
10725 -       struct i2c_msg *pmsg;
10726 -       int i, completed;
10727 -       int rc = 0;
10728 -
10729 -       down(&iface->sem);
10730 -
10731 -       /* Set adapter to standard mode */
10732 -       iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
10733 -       iface->cur_mode |= KW_I2C_MODE_STANDARD;
10734 -
10735 -       completed = 0;
10736 -       for (i = 0; rc >= 0 && i < num;) {
10737 -               u8 addr;
10738 -               
10739 -               pmsg = &msgs[i++];
10740 -               addr = pmsg->addr;
10741 -               if (pmsg->flags & I2C_M_TEN) {
10742 -                       printk(KERN_ERR "i2c-keywest: 10 bits addr not supported !\n");
10743 -                       rc = -EINVAL;
10744 -                       break;
10745 -               }
10746 -               DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
10747 -                    chan->chan_no,
10748 -                    pmsg->flags & I2C_M_RD ? "read" : "write",
10749 -                     pmsg->len, addr, i, num);
10750 -    
10751 -               /* Setup channel & clear pending irqs */
10752 -               write_reg(reg_mode, iface->cur_mode | (chan->chan_no << 4));
10753 -               write_reg(reg_isr, read_reg(reg_isr));
10754 -               write_reg(reg_status, 0);
10755 -               
10756 -               iface->data = pmsg->buf;
10757 -               iface->datalen = pmsg->len;
10758 -               iface->state = state_addr;
10759 -               iface->result = 0;
10760 -               iface->stopretry = 0;
10761 -               if (pmsg->flags & I2C_M_RD)
10762 -                       iface->read_write = I2C_SMBUS_READ;
10763 -               else
10764 -                       iface->read_write = I2C_SMBUS_WRITE;
10765 -
10766 -               /* Set up address and r/w bit */
10767 -               if (pmsg->flags & I2C_M_REV_DIR_ADDR)
10768 -                       addr ^= 1;              
10769 -               write_reg(reg_addr,
10770 -                       (addr << 1) |
10771 -                       ((iface->read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
10772 -
10773 -               /* Arm timeout */
10774 -               mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
10775 -
10776 -               /* Start sending address & enable interrupt*/
10777 -               write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_XADDR);
10778 -               write_reg(reg_ier, KW_I2C_IRQ_MASK);
10779 -
10780 -               /* Wait interrupt operations completion */
10781 -               wait_for_completion(&iface->complete);  
10782 -
10783 -               rc = iface->result;
10784 -               if (rc == 0)
10785 -                       completed++;
10786 -               DBG("transfer done, result: %d\n", rc);
10787 -       }
10788 -
10789 -       /* Release sem */
10790 -       up(&iface->sem);
10791 -
10792 -       return completed;
10793 -}
10794 -
10795 -static u32
10796 -keywest_func(struct i2c_adapter * adapter)
10797 -{
10798 -       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
10799 -              I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
10800 -              I2C_FUNC_SMBUS_BLOCK_DATA;
10801 -}
10802 -
10803 -/* For now, we only handle combined mode (smbus) */
10804 -static struct i2c_algorithm keywest_algorithm = {
10805 -       .name           = "Keywest i2c",
10806 -       .id             = I2C_ALGO_SMBUS,
10807 -       .smbus_xfer     = keywest_smbus_xfer,
10808 -       .master_xfer    = keywest_xfer,
10809 -       .functionality  = keywest_func,
10810 -};
10811 -
10812 -
10813 -static int
10814 -create_iface(struct device_node *np, struct device *dev)
10815 -{
10816 -       unsigned long steps, *psteps, *prate;
10817 -       unsigned bsteps, tsize, i, nchan, addroffset;
10818 -       struct keywest_iface* iface;
10819 -       int rc;
10820 -
10821 -       psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
10822 -       steps = psteps ? (*psteps) : 0x10;
10823 -
10824 -       /* Hrm... maybe we can be smarter here */
10825 -       for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
10826 -               steps >>= 1;
10827 -
10828 -       if (!strcmp(np->parent->name, "uni-n")) {
10829 -               nchan = 2;
10830 -               addroffset = 3;
10831 -       } else {
10832 -               addroffset = 0;
10833 -               nchan = 1;
10834 -       }
10835 -
10836 -       tsize = sizeof(struct keywest_iface) +
10837 -               (sizeof(struct keywest_chan) + 4) * nchan;
10838 -       iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL);
10839 -       if (iface == NULL) {
10840 -               printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n");
10841 -               return -ENOMEM;
10842 -       }
10843 -       memset(iface, 0, tsize);
10844 -       init_MUTEX(&iface->sem);
10845 -       spin_lock_init(&iface->lock);
10846 -       init_completion(&iface->complete);
10847 -       iface->bsteps = bsteps;
10848 -       iface->chan_count = nchan;
10849 -       iface->state = state_idle;
10850 -       iface->irq = np->intrs[0].line;
10851 -       iface->channels = (struct keywest_chan *)
10852 -               (((unsigned long)(iface + 1) + 3UL) & ~3UL);
10853 -       iface->base = (unsigned long)ioremap(np->addrs[0].address + addroffset,
10854 -                                               np->addrs[0].size);
10855 -       if (iface->base == 0) {
10856 -               printk(KERN_ERR "i2c-keywest: can't map inteface !\n");
10857 -               kfree(iface);
10858 -               return -ENOMEM;
10859 -       }
10860 -
10861 -       init_timer(&iface->timeout_timer);
10862 -       iface->timeout_timer.function = keywest_timeout;
10863 -       iface->timeout_timer.data = (unsigned long)iface;
10864 -
10865 -       /* Select interface rate */
10866 -       iface->cur_mode = KW_I2C_MODE_100KHZ;
10867 -       prate = (unsigned long *)get_property(np, "AAPL,i2c-rate", NULL);
10868 -       if (prate) switch(*prate) {
10869 -       case 100:
10870 -               iface->cur_mode = KW_I2C_MODE_100KHZ;
10871 -               break;
10872 -       case 50:
10873 -               iface->cur_mode = KW_I2C_MODE_50KHZ;
10874 -               break;
10875 -       case 25:
10876 -               iface->cur_mode = KW_I2C_MODE_25KHZ;
10877 -               break;
10878 -       default:
10879 -               printk(KERN_WARNING "i2c-keywest: unknown rate %ldKhz, using 100KHz\n",
10880 -                       *prate);
10881 -       }
10882 -       
10883 -       /* Select standard sub mode */
10884 -       iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10885 -       
10886 -       /* Write mode */
10887 -       write_reg(reg_mode, iface->cur_mode);
10888 -       
10889 -       /* Switch interrupts off & clear them*/
10890 -       write_reg(reg_ier, 0x00);
10891 -       write_reg(reg_isr, KW_I2C_IRQ_MASK);
10892 -
10893 -       /* Request chip interrupt */    
10894 -       rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
10895 -       if (rc) {
10896 -               printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
10897 -               iounmap((void *)iface->base);
10898 -               kfree(iface);
10899 -               return -ENODEV;
10900 -       }
10901 -
10902 -       dev_set_drvdata(dev, iface);
10903 -       
10904 -       for (i=0; i<nchan; i++) {
10905 -               struct keywest_chan* chan = &iface->channels[i];
10906 -               u8 addr;
10907 -               
10908 -               sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
10909 -               chan->iface = iface;
10910 -               chan->chan_no = i;
10911 -               chan->adapter.id = I2C_ALGO_SMBUS;
10912 -               chan->adapter.algo = &keywest_algorithm;
10913 -               chan->adapter.algo_data = NULL;
10914 -               chan->adapter.client_register = NULL;
10915 -               chan->adapter.client_unregister = NULL;
10916 -               i2c_set_adapdata(&chan->adapter, chan);
10917 -               chan->adapter.dev.parent = dev;
10918 -
10919 -               rc = i2c_add_adapter(&chan->adapter);
10920 -               if (rc) {
10921 -                       printk("i2c-keywest.c: Adapter %s registration failed\n",
10922 -                               chan->adapter.name);
10923 -                       i2c_set_adapdata(&chan->adapter, NULL);
10924 -               }
10925 -               if (probe) {
10926 -                       printk("Probe: ");
10927 -                       for (addr = 0x00; addr <= 0x7f; addr++) {
10928 -                               if (i2c_smbus_xfer(&chan->adapter,addr,
10929 -                                   0,0,0,I2C_SMBUS_QUICK,NULL) >= 0)
10930 -                                       printk("%02x ", addr);
10931 -                       }
10932 -                       printk("\n");
10933 -               }
10934 -       }
10935 -
10936 -       printk(KERN_INFO "Found KeyWest i2c on \"%s\", %d channel%s, stepping: %d bits\n",
10937 -               np->parent->name, nchan, nchan > 1 ? "s" : "", bsteps);
10938 -               
10939 -       return 0;
10940 -}
10941 -
10942 -static int
10943 -dispose_iface(struct device *dev)
10944 -{
10945 -       struct keywest_iface *iface = dev_get_drvdata(dev);
10946 -       int i, rc;
10947 -       
10948 -       /* Make sure we stop all activity */
10949 -       down(&iface->sem);
10950 -
10951 -       spin_lock_irq(&iface->lock);
10952 -       while (iface->state != state_idle) {
10953 -               spin_unlock_irq(&iface->lock);
10954 -               set_task_state(current,TASK_UNINTERRUPTIBLE);
10955 -               schedule_timeout(HZ/10);
10956 -               spin_lock_irq(&iface->lock);
10957 -       }
10958 -       iface->state = state_dead;
10959 -       spin_unlock_irq(&iface->lock);
10960 -       free_irq(iface->irq, iface);
10961 -       up(&iface->sem);
10962 -
10963 -       /* Release all channels */
10964 -       for (i=0; i<iface->chan_count; i++) {
10965 -               struct keywest_chan* chan = &iface->channels[i];
10966 -               if (i2c_get_adapdata(&chan->adapter) == NULL)
10967 -                       continue;
10968 -               rc = i2c_del_adapter(&chan->adapter);
10969 -               i2c_set_adapdata(&chan->adapter, NULL);
10970 -               /* We aren't that prepared to deal with this... */
10971 -               if (rc)
10972 -                       printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
10973 -       }
10974 -       iounmap((void *)iface->base);
10975 -       dev_set_drvdata(dev, NULL);
10976 -       kfree(iface);
10977 -
10978 -       return 0;
10979 -}
10980 -
10981 -static int
10982 -create_iface_macio(struct macio_dev* dev, const struct of_match *match)
10983 -{
10984 -       return create_iface(dev->ofdev.node, &dev->ofdev.dev);
10985 -}
10986 -
10987 -static int
10988 -dispose_iface_macio(struct macio_dev* dev)
10989 -{
10990 -       return dispose_iface(&dev->ofdev.dev);
10991 -}
10992 -
10993 -static int
10994 -create_iface_of_platform(struct of_device* dev, const struct of_match *match)
10995 -{
10996 -       return create_iface(dev->node, &dev->dev);
10997 -}
10998 -
10999 -static int
11000 -dispose_iface_of_platform(struct of_device* dev)
11001 -{
11002 -       return dispose_iface(&dev->dev);
11003 -}
11004 -
11005 -static struct of_match i2c_keywest_match[] = 
11006 -{
11007 -       {
11008 -       .name           = OF_ANY_MATCH,
11009 -       .type           = "i2c",
11010 -       .compatible     = "keywest"
11011 -       },
11012 -       {},
11013 -};
11014 -
11015 -static struct macio_driver i2c_keywest_macio_driver = 
11016 -{
11017 -       .name           = "i2c-keywest",
11018 -       .match_table    = i2c_keywest_match,
11019 -       .probe          = create_iface_macio,
11020 -       .remove         = dispose_iface_macio
11021 -};
11022 -
11023 -static struct of_platform_driver i2c_keywest_of_platform_driver = 
11024 -{
11025 -       .name           = "i2c-keywest",
11026 -       .match_table    = i2c_keywest_match,
11027 -       .probe          = create_iface_of_platform,
11028 -       .remove         = dispose_iface_of_platform
11029 -};
11030 -
11031 -static int __init
11032 -i2c_keywest_init(void)
11033 -{
11034 -       macio_register_driver(&i2c_keywest_macio_driver);
11035 -       of_register_driver(&i2c_keywest_of_platform_driver);
11036 -
11037 -       return 0;
11038 -}
11039 -
11040 -static void __exit
11041 -i2c_keywest_cleanup(void)
11042 -{
11043 -       macio_unregister_driver(&i2c_keywest_macio_driver);
11044 -       of_unregister_driver(&i2c_keywest_of_platform_driver);
11045 -}
11046 -
11047 -module_init(i2c_keywest_init);
11048 -module_exit(i2c_keywest_cleanup);
11049 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-keywest.h i2c-2.5/drivers/i2c/i2c-keywest.h
11050 --- linux-2.6.0-test5/drivers/i2c/i2c-keywest.h Mon Sep  8 19:50:23 2003
11051 +++ i2c-2.5/drivers/i2c/i2c-keywest.h   Thu Jan  1 00:00:00 1970
11052 @@ -1,110 +0,0 @@
11053 -#ifndef __I2C_KEYWEST_H__
11054 -#define __I2C_KEYWEST_H__
11055 -
11056 -/* The Tumbler audio equalizer can be really slow sometimes */
11057 -#define POLL_TIMEOUT           (2*HZ)
11058 -
11059 -/* Register indices */
11060 -typedef enum {
11061 -       reg_mode = 0,
11062 -       reg_control,
11063 -       reg_status,
11064 -       reg_isr,
11065 -       reg_ier,
11066 -       reg_addr,
11067 -       reg_subaddr,
11068 -       reg_data
11069 -} reg_t;
11070 -
11071 -
11072 -/* Mode register */
11073 -#define KW_I2C_MODE_100KHZ     0x00
11074 -#define KW_I2C_MODE_50KHZ      0x01
11075 -#define KW_I2C_MODE_25KHZ      0x02
11076 -#define KW_I2C_MODE_DUMB       0x00
11077 -#define KW_I2C_MODE_STANDARD   0x04
11078 -#define KW_I2C_MODE_STANDARDSUB        0x08
11079 -#define KW_I2C_MODE_COMBINED   0x0C
11080 -#define KW_I2C_MODE_MODE_MASK  0x0C
11081 -#define KW_I2C_MODE_CHAN_MASK  0xF0
11082 -
11083 -/* Control register */
11084 -#define KW_I2C_CTL_AAK         0x01
11085 -#define KW_I2C_CTL_XADDR       0x02
11086 -#define KW_I2C_CTL_STOP                0x04
11087 -#define KW_I2C_CTL_START       0x08
11088 -
11089 -/* Status register */
11090 -#define KW_I2C_STAT_BUSY       0x01
11091 -#define KW_I2C_STAT_LAST_AAK   0x02
11092 -#define KW_I2C_STAT_LAST_RW    0x04
11093 -#define KW_I2C_STAT_SDA                0x08
11094 -#define KW_I2C_STAT_SCL                0x10
11095 -
11096 -/* IER & ISR registers */
11097 -#define KW_I2C_IRQ_DATA                0x01
11098 -#define KW_I2C_IRQ_ADDR                0x02
11099 -#define KW_I2C_IRQ_STOP                0x04
11100 -#define KW_I2C_IRQ_START       0x08
11101 -#define KW_I2C_IRQ_MASK                0x0F
11102 -
11103 -/* Physical interface */
11104 -struct keywest_iface
11105 -{
11106 -       unsigned long           base;
11107 -       unsigned                bsteps;
11108 -       int                     irq;
11109 -       struct semaphore        sem;
11110 -       spinlock_t              lock;
11111 -       struct keywest_chan*    channels;
11112 -       unsigned                chan_count;
11113 -       u8                      cur_mode;
11114 -       char                    read_write;
11115 -       u8*                     data;
11116 -       unsigned                datalen;
11117 -       int                     state;
11118 -       int                     result;
11119 -       int                     stopretry;
11120 -       struct timer_list       timeout_timer;
11121 -       struct completion       complete;
11122 -};
11123 -
11124 -enum {
11125 -       state_idle,
11126 -       state_addr,
11127 -       state_read,
11128 -       state_write,
11129 -       state_stop,
11130 -       state_dead
11131 -};
11132 -
11133 -/* Channel on an interface */
11134 -struct keywest_chan
11135 -{
11136 -       struct i2c_adapter      adapter;
11137 -       struct keywest_iface*   iface;
11138 -       unsigned                chan_no;
11139 -};
11140 -
11141 -/* Register access */
11142 -
11143 -static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
11144 -{
11145 -       return in_8(((volatile u8 *)iface->base)
11146 -               + (((unsigned)reg) << iface->bsteps));
11147 -}
11148 -
11149 -static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
11150 -{
11151 -       out_8(((volatile u8 *)iface->base)
11152 -               + (((unsigned)reg) << iface->bsteps), val);
11153 -       (void)__read_reg(iface, reg);
11154 -       udelay(10);
11155 -}
11156 -
11157 -#define write_reg(reg, val)    __write_reg(iface, reg, val) 
11158 -#define read_reg(reg)          __read_reg(iface, reg) 
11159 -
11160 -
11161 -
11162 -#endif /* __I2C_KEYWEST_H__ */
11163 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-philips-par.c i2c-2.5/drivers/i2c/i2c-philips-par.c
11164 --- linux-2.6.0-test5/drivers/i2c/i2c-philips-par.c     Mon Sep  8 19:49:53 2003
11165 +++ i2c-2.5/drivers/i2c/i2c-philips-par.c       Thu Jan  1 00:00:00 1970
11166 @@ -1,256 +0,0 @@
11167 -/* ------------------------------------------------------------------------- */
11168 -/* i2c-philips-par.c i2c-hw access for philips style parallel port adapters  */
11169 -/* ------------------------------------------------------------------------- */
11170 -/*   Copyright (C) 1995-2000 Simon G. Vogl
11171 -
11172 -    This program is free software; you can redistribute it and/or modify
11173 -    it under the terms of the GNU General Public License as published by
11174 -    the Free Software Foundation; either version 2 of the License, or
11175 -    (at your option) any later version.
11176 -
11177 -    This program is distributed in the hope that it will be useful,
11178 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
11179 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11180 -    GNU General Public License for more details.
11181 -
11182 -    You should have received a copy of the GNU General Public License
11183 -    along with this program; if not, write to the Free Software
11184 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
11185 -/* ------------------------------------------------------------------------- */ 
11186 -
11187 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
11188 -   Frodo Looijaard <frodol@dds.nl> */
11189 -
11190 -/* $Id$ */
11191 -
11192 -#include <linux/kernel.h>
11193 -#include <linux/ioport.h>
11194 -#include <linux/module.h>
11195 -#include <linux/init.h>
11196 -#include <linux/stddef.h>
11197 -#include <linux/parport.h>
11198 -#include <linux/i2c.h>
11199 -#include <linux/i2c-algo-bit.h>
11200 -
11201 -static int type;
11202 -
11203 -struct i2c_par
11204 -{
11205 -       struct pardevice *pdev;
11206 -       struct i2c_adapter adapter;
11207 -       struct i2c_algo_bit_data bit_lp_data;
11208 -       struct i2c_par *next;
11209 -};
11210 -
11211 -static struct i2c_par *adapter_list;
11212 -
11213 -
11214 -/* ----- global defines -----------------------------------------------        */
11215 -#define DEB(x)         /* should be reasonable open, close &c.         */
11216 -#define DEB2(x)        /* low level debugging - very slow              */
11217 -#define DEBE(x)        x       /* error messages                               */
11218 -
11219 -/* ----- printer port defines ------------------------------------------*/
11220 -                                       /* Pin Port  Inverted   name    */
11221 -#define I2C_ON         0x20            /* 12 status N  paper           */
11222 -                                       /* ... only for phil. not used  */
11223 -#define I2C_SDA                0x80            /*  9 data   N  data7           */
11224 -#define I2C_SCL                0x08            /* 17 ctrl   N  dsel            */
11225 -
11226 -#define I2C_SDAIN      0x80            /* 11 stat   Y  busy            */
11227 -#define I2C_SCLIN      0x08            /* 15 stat   Y  enable          */
11228 -
11229 -#define I2C_DMASK      0x7f
11230 -#define I2C_CMASK      0xf7
11231 -
11232 -/* ----- local functions ----------------------------------------------        */
11233 -
11234 -static void bit_lp_setscl(void *data, int state)
11235 -{
11236 -       /*be cautious about state of the control register - 
11237 -               touch only the one bit needed*/
11238 -       if (state) {
11239 -               parport_write_control((struct parport *) data,
11240 -                     parport_read_control((struct parport *) data)|I2C_SCL);
11241 -       } else {
11242 -               parport_write_control((struct parport *) data,
11243 -                     parport_read_control((struct parport *) data)&I2C_CMASK);
11244 -       }
11245 -}
11246 -
11247 -static void bit_lp_setsda(void *data, int state)
11248 -{
11249 -       if (state) {
11250 -               parport_write_data((struct parport *) data, I2C_DMASK);
11251 -       } else {
11252 -               parport_write_data((struct parport *) data, I2C_SDA);
11253 -       }
11254 -}
11255 -
11256 -static int bit_lp_getscl(void *data)
11257 -{
11258 -       return parport_read_status((struct parport *) data) & I2C_SCLIN;
11259 -}
11260 -
11261 -static int bit_lp_getsda(void *data)
11262 -{
11263 -       return parport_read_status((struct parport *) data) & I2C_SDAIN;
11264 -}
11265 -
11266 -static void bit_lp_setscl2(void *data, int state)
11267 -{
11268 -       if (state) {
11269 -               parport_write_data((struct parport *) data,
11270 -                     parport_read_data((struct parport *) data)|0x1);
11271 -       } else {
11272 -               parport_write_data((struct parport *) data,
11273 -                     parport_read_data((struct parport *) data)&0xfe);
11274 -       }
11275 -}
11276 -
11277 -static void bit_lp_setsda2(void *data, int state)
11278 -{
11279 -       if (state) {
11280 -               parport_write_data((struct parport *) data,
11281 -                     parport_read_data((struct parport *) data)|0x2);
11282 -       } else {
11283 -               parport_write_data((struct parport *) data,
11284 -                     parport_read_data((struct parport *) data)&0xfd);
11285 -       }
11286 -}
11287 -
11288 -static int bit_lp_getsda2(void *data)
11289 -{
11290 -       return (parport_read_status((struct parport *) data) & 
11291 -                                    PARPORT_STATUS_BUSY) ? 0 : 1;
11292 -}
11293 -
11294 -/* ------------------------------------------------------------------------
11295 - * Encapsulate the above functions in the correct operations structure.
11296 - * This is only done when more than one hardware adapter is supported.
11297 - */
11298
11299 -static struct i2c_algo_bit_data bit_lp_data = {
11300 -       .setsda         = bit_lp_setsda,
11301 -       .setscl         = bit_lp_setscl,
11302 -       .getsda         = bit_lp_getsda,
11303 -       .getscl         = bit_lp_getscl,
11304 -       .udelay         = 80,
11305 -       .mdelay         = 80,
11306 -       .timeout        = HZ
11307 -}; 
11308 -
11309 -static struct i2c_algo_bit_data bit_lp_data2 = {
11310 -       .setsda         = bit_lp_setsda2,
11311 -       .setscl         = bit_lp_setscl2,
11312 -       .getsda         = bit_lp_getsda2,
11313 -       .udelay         = 80,
11314 -       .mdelay         = 80,
11315 -       .timeout        = HZ
11316 -}; 
11317 -
11318 -static struct i2c_adapter bit_lp_ops = {
11319 -       .owner          = THIS_MODULE,
11320 -       .id             = I2C_HW_B_LP,
11321 -       .name           = "Philips Parallel port adapter",
11322 -};
11323 -
11324 -static void i2c_parport_attach (struct parport *port)
11325 -{
11326 -       struct i2c_par *adapter = kmalloc(sizeof(struct i2c_par),
11327 -                                         GFP_KERNEL);
11328 -       if (!adapter) {
11329 -               printk(KERN_ERR "i2c-philips-par: Unable to malloc.\n");
11330 -               return;
11331 -       }
11332 -
11333 -       printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name);
11334 -
11335 -       adapter->pdev = parport_register_device(port, "i2c-philips-par",
11336 -                                               NULL, NULL, NULL, 
11337 -                                               PARPORT_FLAG_EXCL,
11338 -                                               NULL);
11339 -       if (!adapter->pdev) {
11340 -               printk(KERN_ERR "i2c-philips-par: Unable to register with parport.\n");
11341 -               kfree(adapter);
11342 -               return;
11343 -       }
11344 -
11345 -       adapter->adapter = bit_lp_ops;
11346 -       adapter->adapter.algo_data = &adapter->bit_lp_data;
11347 -       adapter->bit_lp_data = type ? bit_lp_data2 : bit_lp_data;
11348 -       adapter->bit_lp_data.data = port;
11349 -
11350 -       if (parport_claim_or_block(adapter->pdev) < 0 ) {
11351 -               printk(KERN_ERR "i2c-philips-par: Could not claim parallel port.\n");
11352 -               kfree(adapter);
11353 -               return;
11354 -       }
11355 -       /* reset hardware to sane state */
11356 -       bit_lp_setsda(port, 1);
11357 -       bit_lp_setscl(port, 1);
11358 -       parport_release(adapter->pdev);
11359 -
11360 -       if (i2c_bit_add_bus(&adapter->adapter) < 0)
11361 -       {
11362 -               printk(KERN_ERR "i2c-philips-par: Unable to register with I2C.\n");
11363 -               parport_unregister_device(adapter->pdev);
11364 -               kfree(adapter);
11365 -               return;         /* No good */
11366 -       }
11367 -
11368 -       adapter->next = adapter_list;
11369 -       adapter_list = adapter;
11370 -}
11371 -
11372 -static void i2c_parport_detach (struct parport *port)
11373 -{
11374 -       struct i2c_par *adapter, *prev = NULL;
11375 -
11376 -       for (adapter = adapter_list; adapter; adapter = adapter->next)
11377 -       {
11378 -               if (adapter->pdev->port == port)
11379 -               {
11380 -                       parport_unregister_device(adapter->pdev);
11381 -                       i2c_bit_del_bus(&adapter->adapter);
11382 -                       if (prev)
11383 -                               prev->next = adapter->next;
11384 -                       else
11385 -                               adapter_list = adapter->next;
11386 -                       kfree(adapter);
11387 -                       return;
11388 -               }
11389 -               prev = adapter;
11390 -       }
11391 -}
11392 -
11393 -
11394 -static struct parport_driver i2c_driver = {
11395 -       "i2c-philips-par",
11396 -       i2c_parport_attach,
11397 -       i2c_parport_detach,
11398 -       NULL
11399 -};
11400 -
11401 -int __init i2c_bitlp_init(void)
11402 -{
11403 -       printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
11404 -
11405 -       parport_register_driver(&i2c_driver);
11406 -       
11407 -       return 0;
11408 -}
11409 -
11410 -void __exit i2c_bitlp_exit(void)
11411 -{
11412 -       parport_unregister_driver(&i2c_driver);
11413 -}
11414 -
11415 -MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
11416 -MODULE_DESCRIPTION("I2C-Bus adapter routines for Philips parallel port adapter");
11417 -MODULE_LICENSE("GPL");
11418 -
11419 -MODULE_PARM(type, "i");
11420 -
11421 -module_init(i2c_bitlp_init);
11422 -module_exit(i2c_bitlp_exit);
11423 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-prosavage.c i2c-2.5/drivers/i2c/i2c-prosavage.c
11424 --- linux-2.6.0-test5/drivers/i2c/i2c-prosavage.c       Mon Sep  8 19:50:01 2003
11425 +++ i2c-2.5/drivers/i2c/i2c-prosavage.c Thu Jan  1 00:00:00 1970
11426 @@ -1,357 +0,0 @@
11427 -/*
11428 - *    kernel/busses/i2c-prosavage.c
11429 - *
11430 - *    i2c bus driver for S3/VIA 8365/8375 graphics processor.
11431 - *    Copyright (c) 2003 Henk Vergonet <henk@god.dyndns.org>
11432 - *    Based on code written by:
11433 - *     Frodo Looijaard <frodol@dds.nl>,
11434 - *     Philip Edelbrock <phil@netroedge.com>,
11435 - *     Ralph Metzler <rjkm@thp.uni-koeln.de>, and
11436 - *     Mark D. Studebaker <mdsxyz123@yahoo.com>
11437 - *     Simon Vogl
11438 - *     and others
11439 - *
11440 - *    Please read the lm_sensors documentation for details on use.
11441 - *
11442 - *    This program is free software; you can redistribute it and/or modify
11443 - *    it under the terms of the GNU General Public License as published by
11444 - *    the Free Software Foundation; either version 2 of the License, or
11445 - *    (at your option) any later version.
11446 - *
11447 - *    This program is distributed in the hope that it will be useful,
11448 - *    but WITHOUT ANY WARRANTY; without even the implied warranty of
11449 - *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11450 - *    GNU General Public License for more details.
11451 - *
11452 - *    You should have received a copy of the GNU General Public License
11453 - *    along with this program; if not, write to the Free Software
11454 - *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11455 - *
11456 - */
11457 -/*  18-05-2003 HVE - created
11458 - *  14-06-2003 HVE - adapted for lm_sensors2
11459 - *  17-06-2003 HVE - linux 2.5.xx compatible
11460 - *  18-06-2003 HVE - codingstyle
11461 - *  21-06-2003 HVE - compatibility lm_sensors2 and linux 2.5.xx
11462 - *                  codingstyle, mmio enabled
11463 - *
11464 - *  This driver interfaces to the I2C bus of the VIA north bridge embedded
11465 - *  ProSavage4/8 devices. Usefull for gaining access to the TV Encoder chips.
11466 - *
11467 - *  Graphics cores:
11468 - *   S3/VIA KM266/VT8375 aka ProSavage8
11469 - *   S3/VIA KM133/VT8365 aka Savage4
11470 - *
11471 - *  Two serial busses are implemented:
11472 - *   SERIAL1 - I2C serial communications interface
11473 - *   SERIAL2 - DDC2 monitor communications interface
11474 - *
11475 - *  Tested on a FX41 mainboard, see http://www.shuttle.com
11476 - * 
11477 - *
11478 - *  TODO:
11479 - *  - integration with prosavage framebuffer device
11480 - *    (Additional documentation needed :(
11481 - */
11482 -
11483 -#include <linux/version.h>
11484 -#include <linux/module.h>
11485 -#include <linux/init.h>
11486 -#include <linux/pci.h>
11487 -#include <linux/i2c.h>
11488 -#include <linux/i2c-algo-bit.h>
11489 -
11490 -#include <asm/io.h>
11491 -
11492 -
11493 -/*
11494 - * driver configuration
11495 - */
11496 -#define        DRIVER_ID       "i2c-prosavage"
11497 -#define        DRIVER_VERSION  "20030621"
11498 -
11499 -#define ADAPTER_NAME(x) (x).name
11500 -
11501 -#define MAX_BUSSES     2
11502 -
11503 -struct s_i2c_bus {
11504 -       u8      *mmvga;
11505 -       int     i2c_reg;
11506 -       int     adap_ok;
11507 -       struct i2c_adapter              adap;
11508 -       struct i2c_algo_bit_data        algo;
11509 -};
11510 -
11511 -struct s_i2c_chip {
11512 -       u8      *mmio;
11513 -       struct s_i2c_bus        i2c_bus[MAX_BUSSES];
11514 -};
11515 -
11516 -
11517 -/*
11518 - * i2c configuration
11519 - */
11520 -#ifndef I2C_HW_B_S3VIA
11521 -#define I2C_HW_B_S3VIA 0x18    /* S3VIA ProSavage adapter              */
11522 -#endif
11523 -
11524 -/* delays */
11525 -#define CYCLE_DELAY    10
11526 -#define TIMEOUT                (HZ / 2)
11527 -
11528 -
11529 -/* 
11530 - * S3/VIA 8365/8375 registers
11531 - */
11532 -#ifndef PCI_VENDOR_ID_S3
11533 -#define PCI_VENDOR_ID_S3               0x5333
11534 -#endif
11535 -#ifndef PCI_DEVICE_ID_S3_SAVAGE4
11536 -#define PCI_DEVICE_ID_S3_SAVAGE4       0x8a25
11537 -#endif
11538 -#ifndef PCI_DEVICE_ID_S3_PROSAVAGE8
11539 -#define PCI_DEVICE_ID_S3_PROSAVAGE8    0x8d04
11540 -#endif
11541 -
11542 -#define VGA_CR_IX      0x3d4
11543 -#define VGA_CR_DATA    0x3d5
11544 -
11545 -#define CR_SERIAL1     0xa0    /* I2C serial communications interface */
11546 -#define MM_SERIAL1     0xff20
11547 -#define CR_SERIAL2     0xb1    /* DDC2 monitor communications interface */
11548 -
11549 -/* based on vt8365 documentation */
11550 -#define I2C_ENAB       0x10
11551 -#define I2C_SCL_OUT    0x01
11552 -#define I2C_SDA_OUT    0x02
11553 -#define I2C_SCL_IN     0x04
11554 -#define I2C_SDA_IN     0x08
11555 -
11556 -#define SET_CR_IX(p, val)      *((p)->mmvga + VGA_CR_IX) = (u8)(val)
11557 -#define SET_CR_DATA(p, val)    *((p)->mmvga + VGA_CR_DATA) = (u8)(val)
11558 -#define GET_CR_DATA(p)         *((p)->mmvga + VGA_CR_DATA)
11559 -
11560 -
11561 -/*
11562 - * Serial bus line handling
11563 - *
11564 - * serial communications register as parameter in private data
11565 - *
11566 - * TODO: locks with other code sections accessing video registers?
11567 - */
11568 -static void bit_s3via_setscl(void *bus, int val)
11569 -{
11570 -       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11571 -       unsigned int r;
11572 -
11573 -       SET_CR_IX(p, p->i2c_reg);
11574 -       r = GET_CR_DATA(p);
11575 -       r |= I2C_ENAB;
11576 -       if (val) {
11577 -               r |= I2C_SCL_OUT;
11578 -       } else {
11579 -               r &= ~I2C_SCL_OUT;
11580 -       }
11581 -       SET_CR_DATA(p, r);
11582 -}
11583 -
11584 -static void bit_s3via_setsda(void *bus, int val)
11585 -{
11586 -       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11587 -       unsigned int r;
11588 -       
11589 -       SET_CR_IX(p, p->i2c_reg);
11590 -       r = GET_CR_DATA(p);
11591 -       r |= I2C_ENAB;
11592 -       if (val) {
11593 -               r |= I2C_SDA_OUT;
11594 -       } else {
11595 -               r &= ~I2C_SDA_OUT;
11596 -       }
11597 -       SET_CR_DATA(p, r);
11598 -}
11599 -
11600 -static int bit_s3via_getscl(void *bus)
11601 -{
11602 -       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11603 -
11604 -       SET_CR_IX(p, p->i2c_reg);
11605 -       return (0 != (GET_CR_DATA(p) & I2C_SCL_IN));
11606 -}
11607 -
11608 -static int bit_s3via_getsda(void *bus)
11609 -{
11610 -       struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11611 -
11612 -       SET_CR_IX(p, p->i2c_reg);
11613 -       return (0 != (GET_CR_DATA(p) & I2C_SDA_IN));
11614 -}
11615 -
11616 -
11617 -/*
11618 - * adapter initialisation
11619 - */
11620 -static int i2c_register_bus(struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
11621 -{
11622 -       int ret;
11623 -       p->adap.owner     = THIS_MODULE;
11624 -       p->adap.id        = I2C_HW_B_S3VIA;
11625 -       p->adap.algo_data = &p->algo;
11626 -       p->algo.setsda    = bit_s3via_setsda;
11627 -       p->algo.setscl    = bit_s3via_setscl;
11628 -       p->algo.getsda    = bit_s3via_getsda;
11629 -       p->algo.getscl    = bit_s3via_getscl;
11630 -       p->algo.udelay    = CYCLE_DELAY;
11631 -       p->algo.mdelay    = CYCLE_DELAY;
11632 -       p->algo.timeout   = TIMEOUT;
11633 -       p->algo.data      = p;
11634 -       p->mmvga          = mmvga;
11635 -       p->i2c_reg        = i2c_reg;
11636 -    
11637 -       ret = i2c_bit_add_bus(&p->adap);
11638 -       if (ret) {
11639 -               return ret;
11640 -       }
11641 -
11642 -       p->adap_ok = 1;
11643 -       return 0;
11644 -}
11645 -
11646 -
11647 -/*
11648 - * Cleanup stuff
11649 - */
11650 -static void __devexit prosavage_remove(struct pci_dev *dev)
11651 -{
11652 -       struct s_i2c_chip *chip;
11653 -       int i, ret;
11654 -
11655 -       chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
11656 -
11657 -       if (!chip) {
11658 -               return;
11659 -       }
11660 -       for (i = MAX_BUSSES - 1; i >= 0; i--) {
11661 -               if (chip->i2c_bus[i].adap_ok == 0)
11662 -                       continue;
11663 -
11664 -               ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
11665 -               if (ret) {
11666 -                       printk(DRIVER_ID ": %s not removed\n",
11667 -                               ADAPTER_NAME(chip->i2c_bus[i].adap));
11668 -               }
11669 -       }
11670 -       if (chip->mmio) {
11671 -               iounmap(chip->mmio);
11672 -       }
11673 -       kfree(chip);
11674 -}
11675 -
11676 -
11677 -/*
11678 - * Detect chip and initialize it
11679 - */
11680 -static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_device_id *id)
11681 -{
11682 -       int ret;
11683 -       unsigned long base, len;
11684 -       struct s_i2c_chip *chip;
11685 -       struct s_i2c_bus  *bus;
11686 -
11687 -        pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); 
11688 -       chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
11689 -       if (chip == NULL) {
11690 -               return -ENOMEM;
11691 -       }
11692 -
11693 -       memset(chip, 0, sizeof(struct s_i2c_chip));
11694 -
11695 -       base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK;
11696 -       len  = dev->resource[0].end - base + 1;
11697 -       chip->mmio = ioremap_nocache(base, len);
11698 -
11699 -       if (chip->mmio == NULL) {
11700 -               printk (DRIVER_ID ": ioremap failed\n");
11701 -               prosavage_remove(dev);
11702 -               return -ENODEV;
11703 -       }
11704 -
11705 -
11706 -       /*
11707 -        * Chip initialisation
11708 -        */
11709 -       /* Unlock Extended IO Space ??? */
11710 -
11711 -
11712 -       /*
11713 -        * i2c bus registration
11714 -        */
11715 -       bus = &chip->i2c_bus[0];
11716 -       snprintf(ADAPTER_NAME(bus->adap), sizeof(ADAPTER_NAME(bus->adap)),
11717 -               "ProSavage I2C bus at %02x:%02x.%x",
11718 -               dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
11719 -       ret = i2c_register_bus(bus, chip->mmio + 0x8000, CR_SERIAL1);
11720 -       if (ret) {
11721 -               goto err_adap;
11722 -       }
11723 -       /*
11724 -        * ddc bus registration
11725 -        */
11726 -       bus = &chip->i2c_bus[1];
11727 -       snprintf(ADAPTER_NAME(bus->adap), sizeof(ADAPTER_NAME(bus->adap)),
11728 -               "ProSavage DDC bus at %02x:%02x.%x",
11729 -               dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
11730 -       ret = i2c_register_bus(bus, chip->mmio + 0x8000, CR_SERIAL2);
11731 -       if (ret) {
11732 -               goto err_adap;
11733 -       }
11734 -       return 0;
11735 -err_adap:
11736 -       printk (DRIVER_ID ": %s failed\n", ADAPTER_NAME(bus->adap));
11737 -       prosavage_remove(dev);
11738 -       return ret;
11739 -}
11740 -
11741 -
11742 -/*
11743 - * Data for PCI driver interface
11744 - */
11745 -static struct pci_device_id prosavage_pci_tbl[] = {
11746 -   {
11747 -       .vendor         =       PCI_VENDOR_ID_S3,
11748 -       .device         =       PCI_DEVICE_ID_S3_SAVAGE4,
11749 -       .subvendor      =       PCI_ANY_ID,
11750 -       .subdevice      =       PCI_ANY_ID,
11751 -   },{
11752 -       .vendor         =       PCI_VENDOR_ID_S3,
11753 -       .device         =       PCI_DEVICE_ID_S3_PROSAVAGE8,
11754 -       .subvendor      =       PCI_ANY_ID,
11755 -       .subdevice      =       PCI_ANY_ID,
11756 -   },{ 0, }
11757 -};
11758 -
11759 -static struct pci_driver prosavage_driver = {
11760 -       .name           =       "prosavage-smbus",
11761 -       .id_table       =       prosavage_pci_tbl,
11762 -       .probe          =       prosavage_probe,
11763 -       .remove         =       __devexit_p(prosavage_remove),
11764 -};
11765 -
11766 -static int __init i2c_prosavage_init(void)
11767 -{
11768 -       printk(DRIVER_ID " version %s (%s)\n", I2C_VERSION, DRIVER_VERSION);
11769 -       return pci_module_init(&prosavage_driver);
11770 -}
11771 -
11772 -static void __exit i2c_prosavage_exit(void)
11773 -{
11774 -       pci_unregister_driver(&prosavage_driver);
11775 -}
11776 -
11777 -MODULE_DEVICE_TABLE(pci, prosavage_pci_tbl);
11778 -MODULE_AUTHOR("Henk Vergonet");
11779 -MODULE_DESCRIPTION("ProSavage VIA 8365/8375 smbus driver");
11780 -MODULE_LICENSE("GPL");
11781 -
11782 -module_init (i2c_prosavage_init);
11783 -module_exit (i2c_prosavage_exit);
11784 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-rpx.c i2c-2.5/drivers/i2c/i2c-rpx.c
11785 --- linux-2.6.0-test5/drivers/i2c/i2c-rpx.c     Mon Sep  8 19:50:33 2003
11786 +++ i2c-2.5/drivers/i2c/i2c-rpx.c       Thu Jan  1 00:00:00 1970
11787 @@ -1,103 +0,0 @@
11788 -/*
11789 - * Embedded Planet RPX Lite MPC8xx CPM I2C interface.
11790 - * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
11791 - *
11792 - * moved into proper i2c interface;
11793 - * Brad Parker (brad@heeltoe.com)
11794 - *
11795 - * RPX lite specific parts of the i2c interface
11796 - * Update:  There actually isn't anything RPXLite-specific about this module.
11797 - * This should work for most any 8xx board.  The console messages have been 
11798 - * changed to eliminate RPXLite references.
11799 - */
11800 -
11801 -#include <linux/kernel.h>
11802 -#include <linux/ioport.h>
11803 -#include <linux/module.h>
11804 -#include <linux/init.h>
11805 -#include <linux/stddef.h>
11806 -#include <linux/parport.h>
11807 -#include <linux/i2c.h>
11808 -#include <linux/i2c-algo-8xx.h>
11809 -#include <asm/mpc8xx.h>
11810 -#include <asm/commproc.h>
11811 -
11812 -
11813 -static void
11814 -rpx_iic_init(struct i2c_algo_8xx_data *data)
11815 -{
11816 -       volatile cpm8xx_t *cp;
11817 -       volatile immap_t *immap;
11818 -
11819 -       cp = cpmp;      /* Get pointer to Communication Processor */
11820 -       immap = (immap_t *)IMAP_ADDR;   /* and to internal registers */
11821 -
11822 -       data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
11823 -
11824 -       /* Check for and use a microcode relocation patch.
11825 -       */
11826 -       if ((data->reloc = data->iip->iic_rpbase))
11827 -               data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
11828 -               
11829 -       data->i2c = (i2c8xx_t *)&(immap->im_i2c);
11830 -       data->cp = cp;
11831 -
11832 -       /* Initialize Port B IIC pins.
11833 -       */
11834 -       cp->cp_pbpar |= 0x00000030;
11835 -       cp->cp_pbdir |= 0x00000030;
11836 -       cp->cp_pbodr |= 0x00000030;
11837 -
11838 -       /* Allocate space for two transmit and two receive buffer
11839 -        * descriptors in the DP ram.
11840 -        */
11841 -       data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4);
11842 -
11843 -       /* ptr to i2c area */
11844 -       data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
11845 -}
11846 -
11847 -static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
11848 -{
11849 -       /* install interrupt handler */
11850 -       cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
11851 -
11852 -       return 0;
11853 -}
11854 -
11855 -static struct i2c_algo_8xx_data rpx_data = {
11856 -       .setisr = rpx_install_isr
11857 -};
11858 -
11859 -static struct i2c_adapter rpx_ops = {
11860 -       .owner          = THIS_MODULE,
11861 -       .name           = "m8xx",
11862 -       .id             = I2C_HW_MPC8XX_EPON,
11863 -       .algo_data      = &rpx_data,
11864 -};
11865 -
11866 -int __init i2c_rpx_init(void)
11867 -{
11868 -       printk("i2c-rpx.o: i2c MPC8xx module version %s (%s)\n", I2C_VERSION, I2C_DATE);
11869 -
11870 -       /* reset hardware to sane state */
11871 -       rpx_iic_init(&rpx_data);
11872 -
11873 -       if (i2c_8xx_add_bus(&rpx_ops) < 0) {
11874 -               printk("i2c-rpx: Unable to register with I2C\n");
11875 -               return -ENODEV;
11876 -       }
11877 -
11878 -       return 0;
11879 -}
11880 -
11881 -void __exit i2c_rpx_exit(void)
11882 -{
11883 -       i2c_8xx_del_bus(&rpx_ops);
11884 -}
11885 -
11886 -MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
11887 -MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
11888 -
11889 -module_init(i2c_rpx_init);
11890 -module_exit(i2c_rpx_exit);
11891 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-sensor.c i2c-2.5/drivers/i2c/i2c-sensor.c
11892 --- linux-2.6.0-test5/drivers/i2c/i2c-sensor.c  Mon Sep  8 19:50:06 2003
11893 +++ i2c-2.5/drivers/i2c/i2c-sensor.c    Tue Sep 23 10:12:59 2003
11894 @@ -50,8 +50,9 @@
11895                 return -1;
11896  
11897         for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
11898 -               /* XXX: WTF is going on here??? */
11899 -               if ((is_isa && check_region(addr, 1)) ||
11900 +               void *region_used = request_region(addr, 1, "foo");
11901 +               release_region(addr, 1);
11902 +               if ((is_isa && (region_used == NULL)) ||
11903                     (!is_isa && i2c_check_addr(adapter, addr)))
11904                         continue;
11905  
11906 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/i2c-velleman.c i2c-2.5/drivers/i2c/i2c-velleman.c
11907 --- linux-2.6.0-test5/drivers/i2c/i2c-velleman.c        Mon Sep  8 19:50:21 2003
11908 +++ i2c-2.5/drivers/i2c/i2c-velleman.c  Thu Jan  1 00:00:00 1970
11909 @@ -1,161 +0,0 @@
11910 -/* ------------------------------------------------------------------------- */
11911 -/* i2c-velleman.c i2c-hw access for Velleman K9000 adapters                 */
11912 -/* ------------------------------------------------------------------------- */
11913 -/*   Copyright (C) 1995-96, 2000 Simon G. Vogl
11914 -
11915 -    This program is free software; you can redistribute it and/or modify
11916 -    it under the terms of the GNU General Public License as published by
11917 -    the Free Software Foundation; either version 2 of the License, or
11918 -    (at your option) any later version.
11919 -
11920 -    This program is distributed in the hope that it will be useful,
11921 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
11922 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11923 -    GNU General Public License for more details.
11924 -
11925 -    You should have received a copy of the GNU General Public License
11926 -    along with this program; if not, write to the Free Software
11927 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
11928 -/* ------------------------------------------------------------------------- */
11929 -
11930 -/* $Id$ */
11931 -
11932 -#include <linux/kernel.h>
11933 -#include <linux/ioport.h>
11934 -#include <linux/module.h>
11935 -#include <linux/init.h>
11936 -#include <linux/delay.h>
11937 -#include <linux/i2c.h>
11938 -#include <linux/i2c-algo-bit.h>
11939 -#include <asm/io.h>
11940 -
11941 -/* ----- global defines -----------------------------------------------        */
11942 -#define DEB(x)         /* should be reasonable open, close &c.         */
11943 -#define DEB2(x)        /* low level debugging - very slow              */
11944 -#define DEBE(x)        x       /* error messages                               */
11945 -
11946 -                                       /* Pin Port  Inverted   name    */
11947 -#define I2C_SDA                0x02            /*  ctrl bit 1  (inv)   */
11948 -#define I2C_SCL                0x08            /*  ctrl bit 3  (inv)   */
11949 -
11950 -#define I2C_SDAIN      0x10            /* stat bit 4           */
11951 -#define I2C_SCLIN      0x08            /* ctrl bit 3 (inv)(reads own output)*/
11952 -
11953 -#define I2C_DMASK      0xfd
11954 -#define I2C_CMASK      0xf7
11955 -
11956 -
11957 -/* --- Convenience defines for the parallel port:                      */
11958 -#define BASE   (unsigned int)(data)
11959 -#define DATA   BASE                    /* Centronics data port         */
11960 -#define STAT   (BASE+1)                /* Centronics status port       */
11961 -#define CTRL   (BASE+2)                /* Centronics control port      */
11962 -
11963 -#define DEFAULT_BASE 0x378
11964 -static int base=0;
11965 -
11966 -/* ----- local functions --------------------------------------------------- */
11967 -
11968 -static void bit_velle_setscl(void *data, int state)
11969 -{
11970 -       if (state) {
11971 -               outb(inb(CTRL) & I2C_CMASK,   CTRL);
11972 -       } else {
11973 -               outb(inb(CTRL) | I2C_SCL, CTRL);
11974 -       }
11975 -       
11976 -}
11977 -
11978 -static void bit_velle_setsda(void *data, int state)
11979 -{
11980 -       if (state) {
11981 -               outb(inb(CTRL) & I2C_DMASK , CTRL);
11982 -       } else {
11983 -               outb(inb(CTRL) | I2C_SDA, CTRL);
11984 -       }
11985 -       
11986 -} 
11987 -
11988 -static int bit_velle_getscl(void *data)
11989 -{
11990 -       return ( 0 == ( (inb(CTRL)) & I2C_SCLIN ) );
11991 -}
11992 -
11993 -static int bit_velle_getsda(void *data)
11994 -{
11995 -       return ( 0 != ( (inb(STAT)) & I2C_SDAIN ) );
11996 -}
11997 -
11998 -static int bit_velle_init(void)
11999 -{
12000 -       if (!request_region(base, (base == 0x3bc) ? 3 : 8, 
12001 -                       "i2c (Vellemann adapter)"))
12002 -               return -ENODEV;
12003 -
12004 -       bit_velle_setsda((void*)base,1);
12005 -       bit_velle_setscl((void*)base,1);
12006 -       return 0;
12007 -}
12008 -
12009 -/* ------------------------------------------------------------------------
12010 - * Encapsulate the above functions in the correct operations structure.
12011 - * This is only done when more than one hardware adapter is supported.
12012 - */
12013 -
12014 -static struct i2c_algo_bit_data bit_velle_data = {
12015 -       .setsda         = bit_velle_setsda,
12016 -       .setscl         = bit_velle_setscl,
12017 -       .getsda         = bit_velle_getsda,
12018 -       .getscl         = bit_velle_getscl,
12019 -       .udelay         = 10,
12020 -       .mdelay         = 10,
12021 -       .timeout        = HZ
12022 -};
12023 -
12024 -static struct i2c_adapter bit_velle_ops = {
12025 -       .owner          = THIS_MODULE,
12026 -       .id             = I2C_HW_B_VELLE,
12027 -       .algo_data      = &bit_velle_data,
12028 -       .name           = "Velleman K8000",
12029 -};
12030 -
12031 -static int __init i2c_bitvelle_init(void)
12032 -{
12033 -       printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
12034 -       if (base==0) {
12035 -               /* probe some values */
12036 -               base=DEFAULT_BASE;
12037 -               bit_velle_data.data=(void*)DEFAULT_BASE;
12038 -               if (bit_velle_init()==0) {
12039 -                       if(i2c_bit_add_bus(&bit_velle_ops) < 0)
12040 -                               return -ENODEV;
12041 -               } else {
12042 -                       return -ENODEV;
12043 -               }
12044 -       } else {
12045 -               bit_velle_data.data=(void*)base;
12046 -               if (bit_velle_init()==0) {
12047 -                       if(i2c_bit_add_bus(&bit_velle_ops) < 0)
12048 -                               return -ENODEV;
12049 -               } else {
12050 -                       return -ENODEV;
12051 -               }
12052 -       }
12053 -       printk(KERN_DEBUG "i2c-velleman.o: found device at %#x.\n",base);
12054 -       return 0;
12055 -}
12056 -
12057 -static void __exit i2c_bitvelle_exit(void)
12058 -{      
12059 -       i2c_bit_del_bus(&bit_velle_ops);
12060 -       release_region(base, (base == 0x3bc) ? 3 : 8);
12061 -}
12062 -
12063 -MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
12064 -MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter");
12065 -MODULE_LICENSE("GPL");
12066 -
12067 -MODULE_PARM(base, "i");
12068 -
12069 -module_init(i2c_bitvelle_init);
12070 -module_exit(i2c_bitvelle_exit);
12071 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/scx200_acb.c i2c-2.5/drivers/i2c/scx200_acb.c
12072 --- linux-2.6.0-test5/drivers/i2c/scx200_acb.c  Mon Sep  8 19:50:04 2003
12073 +++ i2c-2.5/drivers/i2c/scx200_acb.c    Thu Jan  1 00:00:00 1970
12074 @@ -1,553 +0,0 @@
12075 -/*  linux/drivers/i2c/scx200_acb.c 
12076 -
12077 -    Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
12078 -
12079 -    National Semiconductor SCx200 ACCESS.bus support
12080 -    
12081 -    Based on i2c-keywest.c which is:
12082 -        Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
12083 -        Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
12084 -    
12085 -    This program is free software; you can redistribute it and/or
12086 -    modify it under the terms of the GNU General Public License as
12087 -    published by the Free Software Foundation; either version 2 of the
12088 -    License, or (at your option) any later version.
12089 -   
12090 -    This program is distributed in the hope that it will be useful,
12091 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
12092 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12093 -    General Public License for more details.
12094 -   
12095 -    You should have received a copy of the GNU General Public License
12096 -    along with this program; if not, write to the Free Software
12097 -    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
12098 -
12099 -*/
12100 -
12101 -#include <linux/config.h>
12102 -#include <linux/module.h>
12103 -#include <linux/errno.h>
12104 -#include <linux/kernel.h>
12105 -#include <linux/init.h>
12106 -#include <linux/i2c.h>
12107 -#include <linux/smp_lock.h>
12108 -#include <linux/pci.h>
12109 -#include <asm/io.h>
12110 -
12111 -#include <linux/scx200.h>
12112 -
12113 -#define NAME "scx200_acb"
12114 -
12115 -MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
12116 -MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver");
12117 -MODULE_LICENSE("GPL");
12118 -
12119 -#define MAX_DEVICES 4
12120 -static int base[MAX_DEVICES] = { 0x840 };
12121 -MODULE_PARM(base, "1-4i");
12122 -MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
12123 -
12124 -#define DEBUG 0
12125 -
12126 -#if DEBUG
12127 -#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
12128 -#else
12129 -#define DBG(x...)
12130 -#endif
12131 -
12132 -/* The hardware supports interrupt driven mode too, but I haven't
12133 -   implemented that. */
12134 -#define POLLED_MODE 1
12135 -#define POLL_TIMEOUT (HZ)
12136 -
12137 -enum scx200_acb_state {
12138 -       state_idle,
12139 -       state_address,
12140 -       state_command,
12141 -       state_repeat_start,
12142 -       state_quick,
12143 -       state_read,
12144 -       state_write,
12145 -};
12146 -
12147 -static const char *scx200_acb_state_name[] = {
12148 -       "idle",
12149 -       "address",
12150 -       "command",
12151 -       "repeat_start",
12152 -       "quick",
12153 -       "read",
12154 -       "write",
12155 -};
12156 -
12157 -/* Physical interface */
12158 -struct scx200_acb_iface
12159 -{
12160 -       struct scx200_acb_iface *next;
12161 -       struct i2c_adapter adapter;
12162 -       unsigned base;
12163 -       struct semaphore sem;
12164 -
12165 -       /* State machine data */
12166 -       enum scx200_acb_state state;
12167 -       int result;
12168 -       u8 address_byte;
12169 -       u8 command;
12170 -       u8 *ptr;
12171 -       char needs_reset;
12172 -       unsigned len;
12173 -};
12174 -
12175 -/* Register Definitions */
12176 -#define ACBSDA         (iface->base + 0)
12177 -#define ACBST          (iface->base + 1)
12178 -#define    ACBST_SDAST         0x40 /* SDA Status */
12179 -#define    ACBST_BER           0x20 
12180 -#define    ACBST_NEGACK                0x10 /* Negative Acknowledge */
12181 -#define    ACBST_STASTR                0x08 /* Stall After Start */
12182 -#define    ACBST_MASTER                0x02
12183 -#define ACBCST         (iface->base + 2)
12184 -#define    ACBCST_BB           0x02
12185 -#define ACBCTL1                (iface->base + 3)
12186 -#define    ACBCTL1_STASTRE     0x80
12187 -#define    ACBCTL1_NMINTE      0x40
12188 -#define           ACBCTL1_ACK          0x10
12189 -#define           ACBCTL1_STOP         0x02
12190 -#define           ACBCTL1_START        0x01
12191 -#define ACBADDR                (iface->base + 4)
12192 -#define ACBCTL2                (iface->base + 5)
12193 -#define    ACBCTL2_ENABLE      0x01
12194 -
12195 -/************************************************************************/
12196 -
12197 -static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
12198 -{
12199 -       const char *errmsg;
12200 -
12201 -       DBG("state %s, status = 0x%02x\n", 
12202 -           scx200_acb_state_name[iface->state], status);
12203 -
12204 -       if (status & ACBST_BER) {
12205 -               errmsg = "bus error";
12206 -               goto error;
12207 -       }
12208 -       if (!(status & ACBST_MASTER)) {
12209 -               errmsg = "not master";
12210 -               goto error;
12211 -       }
12212 -       if (status & ACBST_NEGACK)
12213 -               goto negack;
12214 -
12215 -       switch (iface->state) {
12216 -       case state_idle:
12217 -               dev_warn(&iface->adapter.dev, "interrupt in idle state\n");
12218 -               break;
12219 -
12220 -       case state_address:
12221 -               /* Do a pointer write first */
12222 -               outb(iface->address_byte & ~1, ACBSDA);
12223 -
12224 -               iface->state = state_command;
12225 -               break;
12226 -
12227 -       case state_command:
12228 -               outb(iface->command, ACBSDA);
12229 -
12230 -               if (iface->address_byte & 1)
12231 -                       iface->state = state_repeat_start;
12232 -               else
12233 -                       iface->state = state_write;
12234 -               break;
12235 -
12236 -       case state_repeat_start:
12237 -               outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
12238 -               /* fallthrough */
12239 -               
12240 -       case state_quick:
12241 -               if (iface->address_byte & 1) {
12242 -                       if (iface->len == 1) 
12243 -                               outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
12244 -                       else
12245 -                               outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
12246 -                       outb(iface->address_byte, ACBSDA);
12247 -
12248 -                       iface->state = state_read;
12249 -               } else {
12250 -                       outb(iface->address_byte, ACBSDA);
12251 -
12252 -                       iface->state = state_write;
12253 -               }
12254 -               break;
12255 -
12256 -       case state_read:
12257 -               /* Set ACK if receiving the last byte */
12258 -               if (iface->len == 1)
12259 -                       outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
12260 -               else
12261 -                       outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
12262 -
12263 -               *iface->ptr++ = inb(ACBSDA);
12264 -               --iface->len;
12265 -
12266 -               if (iface->len == 0) {
12267 -                       iface->result = 0;
12268 -                       iface->state = state_idle;
12269 -                       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
12270 -               }
12271 -
12272 -               break;
12273 -
12274 -       case state_write:
12275 -               if (iface->len == 0) {
12276 -                       iface->result = 0;
12277 -                       iface->state = state_idle;
12278 -                       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
12279 -                       break;
12280 -               }
12281 -               
12282 -               outb(*iface->ptr++, ACBSDA);
12283 -               --iface->len;
12284 -               
12285 -               break;
12286 -       }
12287 -
12288 -       return;
12289 -
12290 - negack:
12291 -       DBG("negative acknowledge in state %s\n", 
12292 -           scx200_acb_state_name[iface->state]);
12293 -
12294 -       iface->state = state_idle;
12295 -       iface->result = -ENXIO;
12296 -
12297 -       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
12298 -       outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
12299 -       return;
12300 -
12301 - error:
12302 -       dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
12303 -               scx200_acb_state_name[iface->state]);
12304 -
12305 -       iface->state = state_idle;
12306 -       iface->result = -EIO;
12307 -       iface->needs_reset = 1;
12308 -}
12309 -
12310 -static void scx200_acb_timeout(struct scx200_acb_iface *iface) 
12311 -{
12312 -       dev_err(&iface->adapter.dev, "timeout in state %s\n",
12313 -               scx200_acb_state_name[iface->state]);
12314 -
12315 -       iface->state = state_idle;
12316 -       iface->result = -EIO;
12317 -       iface->needs_reset = 1;
12318 -}
12319 -
12320 -#ifdef POLLED_MODE
12321 -static void scx200_acb_poll(struct scx200_acb_iface *iface)
12322 -{
12323 -       u8 status = 0;
12324 -       unsigned long timeout;
12325 -
12326 -       timeout = jiffies + POLL_TIMEOUT;
12327 -       while (time_before(jiffies, timeout)) {
12328 -               status = inb(ACBST);
12329 -               if ((status & (ACBST_SDAST|ACBST_BER|ACBST_NEGACK)) != 0) {
12330 -                       scx200_acb_machine(iface, status);
12331 -                       return;
12332 -               }
12333 -               schedule_timeout(HZ/100+1);
12334 -       }
12335 -
12336 -       scx200_acb_timeout(iface);
12337 -}
12338 -#endif /* POLLED_MODE */
12339 -
12340 -static void scx200_acb_reset(struct scx200_acb_iface *iface)
12341 -{
12342 -       /* Disable the ACCESS.bus device and Configure the SCL
12343 -           frequency: 16 clock cycles */
12344 -       outb(0x70, ACBCTL2);
12345 -       /* Polling mode */
12346 -       outb(0, ACBCTL1);
12347 -       /* Disable slave address */
12348 -       outb(0, ACBADDR);
12349 -       /* Enable the ACCESS.bus device */
12350 -       outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
12351 -       /* Free STALL after START */
12352 -       outb(inb(ACBCTL1) & ~(ACBCTL1_STASTRE | ACBCTL1_NMINTE), ACBCTL1);
12353 -       /* Send a STOP */
12354 -       outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
12355 -       /* Clear BER, NEGACK and STASTR bits */
12356 -       outb(ACBST_BER | ACBST_NEGACK | ACBST_STASTR, ACBST);
12357 -       /* Clear BB bit */
12358 -       outb(inb(ACBCST) | ACBCST_BB, ACBCST);
12359 -}
12360 -
12361 -static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
12362 -                               u16 address, unsigned short flags,      
12363 -                               char rw, u8 command, int size, 
12364 -                               union i2c_smbus_data *data)
12365 -{
12366 -       struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
12367 -       int len;
12368 -       u8 *buffer;
12369 -       u16 cur_word;
12370 -       int rc;
12371 -
12372 -       switch (size) {
12373 -       case I2C_SMBUS_QUICK:
12374 -               len = 0;
12375 -               buffer = NULL;
12376 -               break;
12377 -       case I2C_SMBUS_BYTE:
12378 -               if (rw == I2C_SMBUS_READ) {
12379 -                       len = 1;
12380 -                       buffer = &data->byte;
12381 -               } else {
12382 -                       len = 1;
12383 -                       buffer = &command;
12384 -               }
12385 -               break;
12386 -       case I2C_SMBUS_BYTE_DATA:
12387 -               len = 1;
12388 -               buffer = &data->byte;
12389 -               break;
12390 -       case I2C_SMBUS_WORD_DATA:
12391 -               len = 2;
12392 -               cur_word = cpu_to_le16(data->word);
12393 -               buffer = (u8 *)&cur_word;
12394 -               break;
12395 -       case I2C_SMBUS_BLOCK_DATA:
12396 -               len = data->block[0];
12397 -               buffer = &data->block[1];
12398 -               break;
12399 -       default:
12400 -               return -EINVAL;
12401 -       }
12402 -
12403 -       DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
12404 -           size, address, command, len, rw == I2C_SMBUS_READ);
12405 -
12406 -       if (!len && rw == I2C_SMBUS_READ) {
12407 -               dev_warn(&adapter->dev, "zero length read\n");
12408 -               return -EINVAL;
12409 -       }
12410 -
12411 -       if (len && !buffer) {
12412 -               dev_warn(&adapter->dev, "nonzero length but no buffer\n");
12413 -               return -EFAULT;
12414 -       }
12415 -
12416 -       down(&iface->sem);
12417 -
12418 -       iface->address_byte = address<<1;
12419 -       if (rw == I2C_SMBUS_READ)
12420 -               iface->address_byte |= 1;
12421 -       iface->command = command;
12422 -       iface->ptr = buffer;
12423 -       iface->len = len;
12424 -       iface->result = -EINVAL;
12425 -       iface->needs_reset = 0;
12426 -
12427 -       outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
12428 -
12429 -       if (size == I2C_SMBUS_QUICK || size == I2C_SMBUS_BYTE)
12430 -               iface->state = state_quick;
12431 -       else
12432 -               iface->state = state_address;
12433 -
12434 -#ifdef POLLED_MODE
12435 -       while (iface->state != state_idle)
12436 -               scx200_acb_poll(iface);
12437 -#else /* POLLED_MODE */
12438 -#error Interrupt driven mode not implemented
12439 -#endif /* POLLED_MODE */       
12440 -
12441 -       if (iface->needs_reset)
12442 -               scx200_acb_reset(iface);
12443 -
12444 -       rc = iface->result;
12445 -
12446 -       up(&iface->sem);
12447 -
12448 -       if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
12449 -               data->word = le16_to_cpu(cur_word);
12450 -
12451 -#if DEBUG
12452 -       printk(KERN_DEBUG NAME ": transfer done, result: %d", rc);
12453 -       if (buffer) {
12454 -               int i;
12455 -               printk(" data:");
12456 -               for (i = 0; i < len; ++i)
12457 -                       printk(" %02x", buffer[i]);
12458 -       }
12459 -       printk("\n");
12460 -#endif
12461 -
12462 -       return rc;
12463 -}
12464 -
12465 -static u32 scx200_acb_func(struct i2c_adapter *adapter)
12466 -{
12467 -       return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
12468 -              I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
12469 -              I2C_FUNC_SMBUS_BLOCK_DATA;
12470 -}
12471 -
12472 -/* For now, we only handle combined mode (smbus) */
12473 -static struct i2c_algorithm scx200_acb_algorithm = {
12474 -       .name           = "NatSemi SCx200 ACCESS.bus",
12475 -       .id             = I2C_ALGO_SMBUS,
12476 -       .smbus_xfer     = scx200_acb_smbus_xfer,
12477 -       .functionality  = scx200_acb_func,
12478 -};
12479 -
12480 -struct scx200_acb_iface *scx200_acb_list;
12481 -
12482 -int scx200_acb_probe(struct scx200_acb_iface *iface)
12483 -{
12484 -       u8 val;
12485 -
12486 -       /* Disable the ACCESS.bus device and Configure the SCL
12487 -           frequency: 16 clock cycles */
12488 -       outb(0x70, ACBCTL2);
12489 -
12490 -       if (inb(ACBCTL2) != 0x70) {
12491 -               DBG("ACBCTL2 readback failed\n");
12492 -               return -ENXIO;
12493 -       }
12494 -
12495 -       outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
12496 -
12497 -       val = inb(ACBCTL1);
12498 -       if (val) {
12499 -               DBG("disabled, but ACBCTL1=0x%02x\n", val);
12500 -               return -ENXIO;
12501 -       }
12502 -
12503 -       outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
12504 -
12505 -       outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
12506 -
12507 -       val = inb(ACBCTL1);
12508 -       if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) {
12509 -               DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val);
12510 -               return -ENXIO;
12511 -       }
12512 -
12513 -       return 0;
12514 -}
12515 -
12516 -static int  __init scx200_acb_create(int base, int index)
12517 -{
12518 -       struct scx200_acb_iface *iface;
12519 -       struct i2c_adapter *adapter;
12520 -       int rc = 0;
12521 -       char description[64];
12522 -
12523 -       iface = kmalloc(sizeof(*iface), GFP_KERNEL);
12524 -       if (!iface) {
12525 -               printk(KERN_ERR NAME ": can't allocate memory\n");
12526 -               rc = -ENOMEM;
12527 -               goto errout;
12528 -       }
12529 -
12530 -       memset(iface, 0, sizeof(*iface));
12531 -       adapter = &iface->adapter;
12532 -       i2c_set_adapdata(adapter, iface);
12533 -       snprintf(adapter->name, DEVICE_NAME_SIZE, "SCx200 ACB%d", index);
12534 -       adapter->owner = THIS_MODULE;
12535 -       adapter->id = I2C_ALGO_SMBUS;
12536 -       adapter->algo = &scx200_acb_algorithm;
12537 -
12538 -       init_MUTEX(&iface->sem);
12539 -
12540 -       snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name);
12541 -       if (request_region(base, 8, description) == 0) {
12542 -               dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n",
12543 -                       base, base + 8-1);
12544 -               rc = -EBUSY;
12545 -               goto errout;
12546 -       }
12547 -       iface->base = base;
12548 -
12549 -       rc = scx200_acb_probe(iface);
12550 -       if (rc) {
12551 -               dev_warn(&adapter->dev, "probe failed\n");
12552 -               goto errout;
12553 -       }
12554 -
12555 -       scx200_acb_reset(iface);
12556 -
12557 -       if (i2c_add_adapter(adapter) < 0) {
12558 -               dev_err(&adapter->dev, "failed to register\n");
12559 -               rc = -ENODEV;
12560 -               goto errout;
12561 -       }
12562 -
12563 -       lock_kernel();
12564 -       iface->next = scx200_acb_list;
12565 -       scx200_acb_list = iface;
12566 -       unlock_kernel();
12567 -
12568 -       return 0;
12569 -
12570 - errout:
12571 -       if (iface) {
12572 -               if (iface->base)
12573 -                       release_region(iface->base, 8);
12574 -               kfree(iface);
12575 -       }
12576 -       return rc;
12577 -}
12578 -
12579 -static int __init scx200_acb_init(void)
12580 -{
12581 -       int i;
12582 -       int rc;
12583 -
12584 -       printk(KERN_DEBUG NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
12585 -
12586 -       /* Verify that this really is a SCx200 processor */
12587 -       if (pci_find_device(PCI_VENDOR_ID_NS,
12588 -                           PCI_DEVICE_ID_NS_SCx200_BRIDGE,
12589 -                           NULL) == NULL)
12590 -               return -ENODEV;
12591 -
12592 -       rc = -ENXIO;
12593 -       for (i = 0; i < MAX_DEVICES; ++i) {
12594 -               if (base[i] > 0)
12595 -                       rc = scx200_acb_create(base[i], i);
12596 -       }
12597 -       if (scx200_acb_list)
12598 -               return 0;
12599 -       return rc;
12600 -}
12601 -
12602 -static void __exit scx200_acb_cleanup(void)
12603 -{
12604 -       struct scx200_acb_iface *iface;
12605 -       lock_kernel();
12606 -       while ((iface = scx200_acb_list) != NULL) {
12607 -               scx200_acb_list = iface->next;
12608 -               unlock_kernel();
12609 -
12610 -               i2c_del_adapter(&iface->adapter);
12611 -               release_region(iface->base, 8);
12612 -               kfree(iface);
12613 -               lock_kernel();
12614 -       }
12615 -       unlock_kernel();
12616 -}
12617 -
12618 -module_init(scx200_acb_init);
12619 -module_exit(scx200_acb_cleanup);
12620 -
12621 -/*
12622 -    Local variables:
12623 -        compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
12624 -        c-basic-offset: 8
12625 -    End:
12626 -*/
12627 -
12628 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/i2c/scx200_i2c.c i2c-2.5/drivers/i2c/scx200_i2c.c
12629 --- linux-2.6.0-test5/drivers/i2c/scx200_i2c.c  Mon Sep  8 19:50:03 2003
12630 +++ i2c-2.5/drivers/i2c/scx200_i2c.c    Thu Jan  1 00:00:00 1970
12631 @@ -1,133 +0,0 @@
12632 -/* linux/drivers/i2c/scx200_i2c.c 
12633 -
12634 -   Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
12635 -
12636 -   National Semiconductor SCx200 I2C bus on GPIO pins
12637 -
12638 -   Based on i2c-velleman.c Copyright (C) 1995-96, 2000 Simon G. Vogl
12639 -
12640 -   This program is free software; you can redistribute it and/or modify
12641 -   it under the terms of the GNU General Public License as published by
12642 -   the Free Software Foundation; either version 2 of the License, or
12643 -   (at your option) any later version.
12644 -   
12645 -   This program is distributed in the hope that it will be useful,
12646 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
12647 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12648 -   GNU General Public License for more details.
12649 -   
12650 -   You should have received a copy of the GNU General Public License
12651 -   along with this program; if not, write to the Free Software
12652 -   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                
12653 -*/
12654 -
12655 -#include <linux/config.h>
12656 -#include <linux/module.h>
12657 -#include <linux/errno.h>
12658 -#include <linux/kernel.h>
12659 -#include <linux/init.h>
12660 -#include <linux/i2c.h>
12661 -#include <linux/i2c-algo-bit.h>
12662 -#include <asm/io.h>
12663 -
12664 -#include <linux/scx200_gpio.h>
12665 -
12666 -#define NAME "scx200_i2c"
12667 -
12668 -MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
12669 -MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver");
12670 -MODULE_LICENSE("GPL");
12671 -
12672 -MODULE_PARM(scl, "i");
12673 -MODULE_PARM_DESC(scl, "GPIO line for SCL");
12674 -MODULE_PARM(sda, "i");
12675 -MODULE_PARM_DESC(sda, "GPIO line for SDA");
12676 -
12677 -static int scl = CONFIG_SCx200_I2C_SCL;
12678 -static int sda = CONFIG_SCx200_I2C_SDA;
12679 -
12680 -static void scx200_i2c_setscl(void *data, int state)
12681 -{
12682 -       scx200_gpio_set(scl, state);
12683 -}
12684 -
12685 -static void scx200_i2c_setsda(void *data, int state)
12686 -{
12687 -       scx200_gpio_set(sda, state);
12688 -} 
12689 -
12690 -static int scx200_i2c_getscl(void *data)
12691 -{
12692 -       return scx200_gpio_get(scl);
12693 -}
12694 -
12695 -static int scx200_i2c_getsda(void *data)
12696 -{
12697 -       return scx200_gpio_get(sda);
12698 -}
12699 -
12700 -/* ------------------------------------------------------------------------
12701 - * Encapsulate the above functions in the correct operations structure.
12702 - * This is only done when more than one hardware adapter is supported.
12703 - */
12704 -
12705 -static struct i2c_algo_bit_data scx200_i2c_data = {
12706 -       NULL,
12707 -       scx200_i2c_setsda,
12708 -       scx200_i2c_setscl,
12709 -       scx200_i2c_getsda,
12710 -       scx200_i2c_getscl,
12711 -       10, 10, 100,            /* waits, timeout */
12712 -};
12713 -
12714 -static struct i2c_adapter scx200_i2c_ops = {
12715 -       .owner             = THIS_MODULE,
12716 -       .id                = I2C_HW_B_VELLE,
12717 -       .algo_data         = &scx200_i2c_data,
12718 -       .name   = "NatSemi SCx200 I2C",
12719 -};
12720 -
12721 -int scx200_i2c_init(void)
12722 -{
12723 -       printk(KERN_DEBUG NAME ": NatSemi SCx200 I2C Driver\n");
12724 -
12725 -       if (!scx200_gpio_present()) {
12726 -               printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");
12727 -               return -ENODEV;
12728 -       }
12729 -
12730 -       printk(KERN_DEBUG NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", 
12731 -              scl, sda);
12732 -
12733 -       if (scl == -1 || sda == -1 || scl == sda) {
12734 -               printk(KERN_ERR NAME ": scl and sda must be specified\n");
12735 -               return -EINVAL;
12736 -       }
12737 -
12738 -       /* Configure GPIOs as open collector outputs */
12739 -       scx200_gpio_configure(scl, ~2, 5);
12740 -       scx200_gpio_configure(sda, ~2, 5);
12741 -
12742 -       if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) {
12743 -               printk(KERN_ERR NAME ": adapter %s registration failed\n", 
12744 -                      scx200_i2c_ops.name);
12745 -               return -ENODEV;
12746 -       }
12747 -       
12748 -       return 0;
12749 -}
12750 -
12751 -void scx200_i2c_cleanup(void)
12752 -{
12753 -       i2c_bit_del_bus(&scx200_i2c_ops);
12754 -}
12755 -
12756 -module_init(scx200_i2c_init);
12757 -module_exit(scx200_i2c_cleanup);
12758 -
12759 -/*
12760 -    Local variables:
12761 -        compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
12762 -        c-basic-offset: 8
12763 -    End:
12764 -*/
12765 diff -Nur --exclude SCCS linux-2.6.0-test5/drivers/ide/pci/siimage.c i2c-2.5/drivers/ide/pci/siimage.c
12766 --- linux-2.6.0-test5/drivers/ide/pci/siimage.c Tue Sep 23 10:23:56 2003
12767 +++ i2c-2.5/drivers/ide/pci/siimage.c   Tue Sep 23 10:13:01 2003
12768 @@ -1065,8 +1065,8 @@
12769         hwif->hwif_data = 0;
12770  
12771         hwif->rqsize = 128;
12772 -//     if (is_sata(hwif))
12773 -//             hwif->rqsize = 15;
12774 +       if (is_sata(hwif))
12775 +               hwif->rqsize = 15;
12776  
12777         if (pci_get_drvdata(dev) == NULL)
12778                 return;
12779 diff -Nur --exclude SCCS linux-2.6.0-test5/include/linux/i2c-id.h i2c-2.5/include/linux/i2c-id.h
12780 --- linux-2.6.0-test5/include/linux/i2c-id.h    Mon Sep  8 19:49:52 2003
12781 +++ i2c-2.5/include/linux/i2c-id.h      Tue Sep 23 10:15:09 2003
12782 @@ -100,7 +100,7 @@
12783  #define I2C_DRIVERID_STM41T00  52      /* real time clock              */
12784  #define I2C_DRIVERID_UDA1342   53      /* UDA1342 audio codec          */
12785  #define I2C_DRIVERID_ADV7170   54      /* video encoder                */
12786 -
12787 +#define I2C_DRIVERID_RADEON    55      /* I2C bus on Radeon boards     */
12788  
12789  
12790  #define I2C_DRIVERID_EXP0      0xF0    /* experimental use id's        */
12791 diff -Nur --exclude SCCS linux-2.6.0-test5/include/linux/i2c.h i2c-2.5/include/linux/i2c.h
12792 --- linux-2.6.0-test5/include/linux/i2c.h       Mon Sep  8 19:49:54 2003
12793 +++ i2c-2.5/include/linux/i2c.h Tue Sep 23 10:15:09 2003
12794 @@ -28,9 +28,6 @@
12795  #ifndef _LINUX_I2C_H
12796  #define _LINUX_I2C_H
12797  
12798 -#define I2C_DATE "20021208"
12799 -#define I2C_VERSION "2.7.0"
12800 -
12801  #include <linux/module.h>
12802  #include <linux/types.h>
12803  #include <linux/i2c-id.h>
12804 @@ -146,6 +143,8 @@
12805  
12806  extern struct bus_type i2c_bus_type;
12807  
12808 +#define I2C_NAME_SIZE  50
12809 +
12810  /*
12811   * i2c_client identifies a single device (i.e. chip) that is connected to an 
12812   * i2c bus. The behaviour is defined by the routines of the driver. This
12813 @@ -166,7 +165,7 @@
12814                                         /* to the client                */
12815         struct device dev;              /* the device structure         */
12816         struct list_head list;
12817 -       char name[DEVICE_NAME_SIZE];
12818 +       char name[I2C_NAME_SIZE];
12819         struct completion released;
12820  };
12821  #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
12822 @@ -253,7 +252,7 @@
12823         int nr;
12824         struct list_head clients;
12825         struct list_head list;
12826 -       char name[DEVICE_NAME_SIZE];
12827 +       char name[I2C_NAME_SIZE];
12828         struct completion dev_released;
12829         struct completion class_dev_released;
12830  };
This page took 1.056327 seconds and 3 git commands to generate.