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
5 If you want I2C support, you should say Y here and also to the
6 specific driver for your bus adapter(s) below.
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.
16 + tristate "I2C device interface"
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>.
24 + This support is also available as a module. If so, the module
25 + will be called i2c-dev.
28 tristate "I2C bit-banging interfaces"
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.
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.
39 - tristate "S3/VIA (Pro)Savage"
40 - depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
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.
46 - S3/VIA KM266/VT8375 aka ProSavage8
47 - S3/VIA KM133/VT8365 aka Savage4
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.
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
58 -config I2C_PHILIPSPAR
59 - tristate "Philips style parallel port adapter"
60 - depends on I2C_ALGOBIT && PARPORT
62 - This supports parallel-port I2C adapters made by Philips. Say Y if
63 - you own such an adapter.
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.
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.
74 - tristate "ELV adapter"
75 - depends on I2C_ALGOBIT && ISA
77 - This supports parallel-port I2C adapters called ELV. Say Y if you
78 - own such an adapter.
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.
86 - tristate "Velleman K9000 adapter"
87 - depends on I2C_ALGOBIT && ISA
89 - This supports the Velleman K9000 parallel-port I2C adapter. Say Y
90 - if you own such an adapter.
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.
98 - tristate "NatSemi SCx200 I2C using GPIO pins"
99 - depends on SCx200 && I2C_ALGOBIT
101 - Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
103 - If you don't know what to do here, say N.
105 - If compiled as a module, it will be called scx200_i2c.
107 -config SCx200_I2C_SCL
108 - int "GPIO pin used for SCL"
109 - depends on SCx200_I2C
112 - Enter the GPIO pin number used for the SCL signal. This value can
113 - also be specified with a module parameter.
115 -config SCx200_I2C_SDA
116 - int "GPIO pin used for SDA"
117 - depends on SCx200_I2C
120 - Enter the GPIO pin number used for the SSA signal. This value can
121 - also be specified with a module parameter.
124 - tristate "NatSemi SCx200 ACCESS.bus"
125 - depends on I2C_ALGOBIT!=n && I2C
127 - Enable the use of the ACCESS.bus controllers of a SCx200 processor.
129 - If you don't know what to do here, say N.
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.
136 tristate "I2C PCF 8584 interfaces"
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.
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.
147 - tristate "Elektor ISA card"
148 - depends on I2C_ALGOPCF && BROKEN_ON_SMP
150 - This supports the PCF8584 ISA bus I2C adapter. Say Y if you own
152 + This support is also available as a module. If so, the module
153 + will be called i2c-algo-pcf.
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.
161 - tristate "Powermac Keywest I2C interface"
162 - depends on I2C && PPC_PMAC
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.
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.
173 tristate "ITE I2C Algorithm"
174 depends on MIPS_ITE8172 && I2C
177 systems. Say Y if you have one of these. You should also say Y for
178 the ITE I2C peripheral driver support below.
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.
185 - tristate "ITE I2C Adapter"
186 - depends on ITE_I2C_ALGO
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.
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.
199 tristate "MPC8xx CPM I2C interface"
200 depends on 8xx && I2C
203 - tristate "Embedded Planet RPX Lite/Classic suppoort"
204 - depends on (RPXLITE || RPXCLASSIC) && I2C_ALGO8XX
206 -config I2C_IBM_OCP_ALGO
207 - tristate "IBM on-chip I2C Algorithm"
208 - depends on IBM_OCP && I2C
210 -config I2C_IBM_OCP_ADAP
211 - tristate "IBM on-chip I2C Adapter"
212 - depends on I2C_IBM_OCP_ALGO
215 - tristate "Intel XScale IOP3xx on-chip I2C interface"
216 - depends on ARCH_IOP3XX && I2C
219 - tristate "I2C device interface"
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>.
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.
232 source drivers/i2c/busses/Kconfig
233 source drivers/i2c/chips/Kconfig
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
240 -# Makefile for the kernel i2c bus driver.
241 +# Makefile for the i2c core.
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
267 # Sensor device configuration
270 -menu "I2C Hardware Sensors Mainboard support"
271 +menu "I2C Hardware Bus support"
274 - tristate " ALI 1535"
275 + tristate "ALI 1535"
276 depends on I2C && PCI && EXPERIMENTAL
278 If you say yes to this option, support will be included for the SMB
280 controller is part of the 7101 device, which is an ACPI-compliant
281 Power Management Unit (PMU).
283 - This can also be built as a module. If so, the module will be
284 - called i2c-ali1535.
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.
293 - tristate " ALI 15x3"
294 + tristate "ALI 15x3"
295 depends on I2C && PCI && EXPERIMENTAL
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.
300 - This can also be built as a module. If so, the module will be
301 - called i2c-ali15x3.
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.
310 - tristate " AMD 756/766"
311 + tristate "AMD 756/766"
312 depends on I2C && EXPERIMENTAL
314 If you say yes to this option, support will be included for the AMD
315 756/766/768 mainboard I2C interfaces.
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>.
321 - The module will be called i2c-amd756.
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.
330 - tristate " AMD 8111"
331 + tristate "AMD 8111"
332 depends on I2C && EXPERIMENTAL
334 If you say yes to this option, support will be included for the AMD
335 8111 mainboard I2C interfaces.
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>.
341 - The module will be called i2c-amd8111.
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.
350 + tristate "Elektor ISA card"
351 + depends on I2C_ALGOPCF && BROKEN_ON_SMP
353 + This supports the PCF8584 ISA bus I2C adapter. Say Y if you own
356 + This support is also available as a module. If so, the module
357 + will be called i2c-elektor.
360 + tristate "ELV adapter"
361 + depends on I2C_ALGOBIT && ISA
363 + This supports parallel-port I2C adapters called ELV. Say Y if you
364 + own such an adapter.
366 + This support is also available as a module. If so, the module
367 + will be called i2c-elv.
370 - tristate " Intel 801"
371 + tristate "Intel 801"
372 depends on I2C && PCI && EXPERIMENTAL
374 If you say yes to this option, support will be included for the Intel
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>.
383 - The module will be called i2c-i801.
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.
392 + tristate "Intel 810/815"
393 + depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
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:
403 + This driver can also be built as a module. If so, the module
404 + will be called i2c-i810.
407 + tristate "IBM IIC I2C"
408 + depends on IBM_OCP && I2C
411 + tristate "Intel XScale IOP3xx on-chip I2C interface"
412 + depends on ARCH_IOP3XX && I2C
415 - tristate " ISA Bus support"
416 + tristate "ISA Bus support"
417 depends on I2C && ISA && EXPERIMENTAL
419 If you say yes to this option, support will be included for i2c
420 interfaces that are on the ISA bus.
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>.
426 - The module will be called i2c-isa.
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.
435 + tristate "ITE I2C Adapter"
436 + depends on I2C_ALGOITE
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.
442 + This support is also available as a module. If so, the module
443 + will be called i2c-ite.
446 + tristate "Powermac Keywest I2C interface"
447 + depends on I2C && PPC_PMAC
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.
452 + This support is also available as a module. If so, the module
453 + will be called i2c-keywest.
456 - tristate " Nvidia Nforce2"
457 + tristate "Nvidia Nforce2"
458 depends on I2C && PCI && EXPERIMENTAL
460 If you say yes to this option, support will be included for the Nvidia
461 Nforce2 family of mainboard I2C interfaces.
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>.
467 - The module will be called i2c-nforce2.
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.
475 +config I2C_PHILIPSPAR
476 + tristate "Philips style parallel port adapter"
477 + depends on I2C_ALGOBIT && PARPORT
479 + This supports parallel-port I2C adapters made by Philips.
481 + This support is also available as a module. If so, the module
482 + will be called i2c-philips-par.
485 - tristate " Intel PIIX4"
486 + tristate "Intel PIIX4"
487 depends on I2C && PCI && EXPERIMENTAL
489 If you say yes to this option, support will be included for the Intel
490 @@ -139,19 +168,97 @@
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>.
498 - The module will be called i2c-piix4.
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.
506 +config I2C_PROSAVAGE
507 + tristate "S3/VIA (Pro)Savage"
508 + depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
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
517 + This support is also available as a module. If so, the module
518 + will be called i2c-prosavage.
521 + tristate "Embedded Planet RPX Lite/Classic suppoort"
522 + depends on (RPXLITE || RPXCLASSIC) && I2C_ALGO8XX
525 + tristate "S3 Savage 4"
526 + depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
528 + If you say yes to this option, support will be included for the
529 + S3 Savage 4 I2C interface.
531 + This driver can also be built as a module. If so, the module
532 + will be called i2c-savage4.
535 + tristate "NatSemi SCx200 I2C using GPIO pins"
536 + depends on SCx200 && I2C_ALGOBIT
538 + Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
540 + If you don't know what to do here, say N.
542 + This support is also available as a module. If so, the module
543 + will be called scx200_i2c.
545 +config SCx200_I2C_SCL
546 + int "GPIO pin used for SCL"
547 + depends on SCx200_I2C
550 + Enter the GPIO pin number used for the SCL signal. This value can
551 + also be specified with a module parameter.
553 +config SCx200_I2C_SDA
554 + int "GPIO pin used for SDA"
555 + depends on SCx200_I2C
558 + Enter the GPIO pin number used for the SSA signal. This value can
559 + also be specified with a module parameter.
562 + tristate "NatSemi SCx200 ACCESS.bus"
563 + depends on I2C_ALGOBIT!=n && I2C
565 + Enable the use of the ACCESS.bus controllers of a SCx200 processor.
567 + If you don't know what to do here, say N.
569 + This support is also available as a module. If so, the module
570 + will be called scx200_acb.
573 + tristate "SiS 5595"
574 + depends on I2C && PCI && EXPERIMENTAL
576 + If you say yes to this option, support will be included for the
577 + SiS5595 SMBus (a subset of I2C) interface.
579 + This driver can also be built as a module. If so, the module
580 + will be called i2c-sis5595.
584 + depends on I2C && PCI && EXPERIMENTAL
586 + If you say yes to this option, support will be included for the
587 + SiS630 SMBus (a subset of I2C) interface.
589 + This driver can also be built as a module. If so, the module
590 + will be called i2c-sis630.
593 - tristate " SiS 96x"
595 depends on I2C && PCI && EXPERIMENTAL
597 If you say yes to this option, support will be included for the SiS
598 @@ -164,19 +271,32 @@
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>.
606 - The module will be called i2c-sis96x.
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.
615 + tristate "Velleman K9000 adapter"
616 + depends on I2C_ALGOBIT && ISA
618 + This supports the Velleman K9000 parallel-port I2C adapter. Say Y
619 + if you own such an adapter.
621 + This support is also available as a module. If so, the module
622 + will be called i2c-velleman.
625 + tristate "VIA 82C58B"
626 + depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
629 + If you say yes to this option, support will be included for the VIA
630 + 82C586B I2C interface
632 + This driver can also be built as a module. If so, the module
633 + will be called i2c-via.
636 - tristate " VIA 82C596/82C686/823x"
637 + tristate "VIA 82C596/82C686/823x"
638 depends on I2C && PCI && EXPERIMENTAL
641 @@ -190,15 +310,18 @@
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>.
649 - The module will be called i2c-viapro.
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.
659 + tristate "Voodoo 3"
660 + depends on I2C_ALGOBIT && PCI && EXPERIMENTAL
663 + If you say yes to this option, support will be included for the
664 + Voodoo 3 I2C interface.
666 + This driver can also be built as a module. If so, the module
667 + will be called i2c-voodoo3.
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
675 -# Makefile for the kernel hardware sensors bus drivers.
676 +# Makefile for the i2c bus drivers.
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
712 static struct i2c_adapter ali1535_adapter = {
713 .owner = THIS_MODULE,
714 - .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI1535,
715 .algo = &smbus_algorithm,
719 /* set up the driverfs linkage to our parent device */
720 ali1535_adapter.dev.parent = &dev->dev;
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);
729 static int __init i2c_ali1535_init(void)
731 - printk(KERN_INFO "i2c-ali1535 version %s (%s)\n", I2C_VERSION, I2C_DATE);
732 return pci_module_init(&ali1535_driver);
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
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,
747 /* set up the driverfs linkage to our parent device */
748 ali15x3_adapter.dev.parent = &dev->dev;
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);
757 static int __init i2c_ali15x3_init(void)
759 - printk("i2c-ali15x3.o version %s (%s)\n", I2C_VERSION, I2C_DATE);
760 return pci_module_init(&ali15x3_driver);
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
768 /* #define DEBUG 1 */
770 -#include <linux/version.h>
771 #include <linux/module.h>
772 #include <linux/pci.h>
773 #include <linux/kernel.h>
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,
783 /* set up the driverfs linkage to our parent device */
784 amd756_adapter.dev.parent = &pdev->dev;
786 - snprintf(amd756_adapter.name, DEVICE_NAME_SIZE,
787 + snprintf(amd756_adapter.name, I2C_NAME_SIZE,
788 "SMBus AMD75x adapter at %04x", amd756_ioport);
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
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
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
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.
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.
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 +/* ------------------------------------------------------------------------- */
830 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
831 + Frodo Looijaard <frodol@dds.nl> */
833 +/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of
834 + for Alpha Processor Inc. UP-2000(+) boards */
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>
846 +#include <linux/i2c.h>
847 +#include <linux/i2c-algo-pcf.h>
850 +#include <asm/irq.h>
852 +#include "../i2c-pcf8584.h"
854 +#define DEFAULT_BASE 0x330
858 +static int clock = 0x1c;
859 +static int own = 0x55;
861 +static int i2c_debug;
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 */
868 +static wait_queue_head_t pcf_wait;
869 +static int pcf_pending;
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 */
877 +/* ----- local functions ---------------------------------------------- */
879 +static void pcf_isa_setbyte(void *data, int ctl, int val)
881 + int address = ctl ? (base + 1) : base;
883 + /* enable irq if any specified for serial operation */
884 + if (ctl && irq && (val & I2C_PCF_ESO)) {
885 + val |= I2C_PCF_ENI;
888 + DEB3(printk(KERN_DEBUG "i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255));
891 + case 0: /* regular I/O */
892 + outb(val, address);
894 + case 2: /* double mapped I/O needed for UP2000 board,
895 + I don't know why this... */
896 + writeb(val, address);
898 + case 1: /* memory mapped I/O */
899 + writeb(val, address);
904 +static int pcf_isa_getbyte(void *data, int ctl)
906 + int address = ctl ? (base + 1) : base;
907 + int val = mmapped ? readb(address) : inb(address);
909 + DEB3(printk(KERN_DEBUG "i2c-elektor: Read 0x%X 0x%02X\n", address, val));
914 +static int pcf_isa_getown(void *data)
920 +static int pcf_isa_getclock(void *data)
925 +static void pcf_isa_waitforpin(void) {
931 + if (pcf_pending == 0) {
932 + interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
942 +static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
944 + wake_up_interruptible(&pcf_wait);
945 + return IRQ_HANDLED;
949 +static int pcf_isa_init(void)
952 + if (!request_region(base, 2, "i2c (isa bus adapter)")) {
954 + "i2c-elektor: requested I/O region (0x%X:2) "
955 + "is in use.\n", base);
960 + if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", 0) < 0) {
961 + printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq);
969 +/* ------------------------------------------------------------------------
970 + * Encapsulate the above functions in the correct operations structure.
971 + * This is only done when more than one hardware adapter is supported.
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,
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",
991 +static int __init i2c_pcfisa_init(void)
994 + /* check to see we have memory mapped PCF8584 connected to the
995 + Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
998 + struct pci_dev *cy693_dev =
999 + pci_find_device(PCI_VENDOR_ID_CONTAQ,
1000 + PCI_DEVICE_ID_CONTAQ_82C693, NULL);
1004 + /* yeap, we've found cypress, let's check config */
1005 + if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
1007 + DEB3(printk(KERN_DEBUG "i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config));
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) */
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 */
1022 + /* I don't know why we need to
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");
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);
1042 + printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n");
1045 + base = DEFAULT_BASE;
1048 + init_waitqueue_head(&pcf_wait);
1049 + if (pcf_isa_init())
1051 + if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
1054 + printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base);
1065 + release_region(base , 2);
1069 +static void i2c_pcfisa_exit(void)
1071 + i2c_pcf_del_bus(&pcf_isa_ops);
1079 + release_region(base , 2);
1082 +MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
1083 +MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
1084 +MODULE_LICENSE("GPL");
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");
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
1099 +/* ------------------------------------------------------------------------- */
1100 +/* i2c-elv.c i2c-hw access for philips style parallel port adapters */
1101 +/* ------------------------------------------------------------------------- */
1102 +/* Copyright (C) 1995-2000 Simon G. Vogl
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.
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.
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 +/* ------------------------------------------------------------------------- */
1119 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
1120 + Frodo Looijaard <frodol@dds.nl> */
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>
1133 +#define DEFAULT_BASE 0x378
1135 +static unsigned char port_data = 0;
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 */
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 */
1150 +/* ----- local functions ---------------------------------------------- */
1153 +static void bit_elv_setscl(void *data, int state)
1156 + port_data &= 0xfe;
1160 + outb(port_data, DATA);
1163 +static void bit_elv_setsda(void *data, int state)
1170 + outb(port_data, DATA);
1173 +static int bit_elv_getscl(void *data)
1175 + return ( 0 == ( (inb_p(STAT)) & 0x08 ) );
1178 +static int bit_elv_getsda(void *data)
1180 + return ( 0 == ( (inb_p(STAT)) & 0x40 ) );
1183 +static int bit_elv_init(void)
1185 + if (!request_region(base, (base == 0x3bc) ? 3 : 8,
1186 + "i2c (ELV adapter)"))
1189 + if (inb(base+1) & 0x80) { /* BUSY should be high */
1190 + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n"));
1194 + outb(0x0c,base+2); /* SLCT auf low */
1196 + if (!(inb(base+1) && 0x10)) {
1197 + outb(0x04,base+2);
1198 + DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n"));
1203 + bit_elv_setsda((void*)base,1);
1204 + bit_elv_setscl((void*)base,1);
1208 + release_region(base , (base == 0x3bc) ? 3 : 8);
1212 +/* ------------------------------------------------------------------------
1213 + * Encapsulate the above functions in the correct operations structure.
1214 + * This is only done when more than one hardware adapter is supported.
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,
1226 +static struct i2c_adapter bit_elv_ops = {
1227 + .owner = THIS_MODULE,
1228 + .algo_data = &bit_elv_data,
1229 + .name = "ELV Parallel port adaptor",
1232 +static int __init i2c_bitelv_init(void)
1234 + printk(KERN_INFO "i2c ELV parallel port adapter driver\n");
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)
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)
1254 + printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base);
1258 +static void __exit i2c_bitelv_exit(void)
1260 + i2c_bit_del_bus(&bit_elv_ops);
1261 + release_region(base , (base == 0x3bc) ? 3 : 8);
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");
1268 +MODULE_PARM(base, "i");
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
1278 + * linux/drivers/i2c/i2c-frodo.c
1280 + * Author: Abraham van der Merwe <abraham@2d3d.co.za>
1282 + * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
1283 + * Development board (Frodo).
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.
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>
1299 +static void frodo_setsda (void *data,int state)
1302 + FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
1304 + FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
1307 +static void frodo_setscl (void *data,int state)
1310 + FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
1312 + FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
1315 +static int frodo_getsda (void *data)
1317 + return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
1320 +static int frodo_getscl (void *data)
1322 + return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
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,
1335 +static struct i2c_adapter frodo_ops = {
1336 + .owner = THIS_MODULE,
1337 + .id = I2C_HW_B_FRODO,
1338 + .algo_data = &bit_frodo_data,
1340 + .name = "Frodo adapter driver",
1344 +static int __init i2c_frodo_init (void)
1346 + return i2c_bit_add_bus(&frodo_ops);
1349 +static void __exit i2c_frodo_exit (void)
1351 + i2c_bit_del_bus(&frodo_ops);
1354 +MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
1355 +MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
1356 +MODULE_LICENSE ("GPL");
1358 +module_init (i2c_frodo_init);
1359 +module_exit (i2c_frodo_exit);
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
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,
1373 /* set up the driverfs linkage to our parent device */
1374 i801_adapter.dev.parent = &dev->dev;
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);
1383 static int __init i2c_i801_init(void)
1385 - printk(KERN_INFO "i2c-i801 version %s (%s)\n", I2C_VERSION, I2C_DATE);
1386 return pci_module_init(&i801_driver);
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
1394 + i2c-i810.c - Part of lm_sensors, Linux kernel modules for hardware
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>
1401 + Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
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.
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.
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.
1419 + This interfaces to the I810/I815 to provide access to
1420 + the DDC Bus and the I2C Bus.
1422 + SUPPORTED DEVICES PCI ID
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>
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
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
1454 +/* initialization states */
1460 +#define CYCLE_DELAY 10
1461 +#define TIMEOUT (HZ / 2)
1463 +static void *ioaddr;
1465 +/* The i810 GPIO registers have individual masks for each bit
1466 + so we never have to read before writing. Nice. */
1468 +static void bit_i810i2c_setscl(void *data, int val)
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 */
1475 +static void bit_i810i2c_setsda(void *data, int val)
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 */
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. */
1492 +static int bit_i810i2c_getscl(void *data)
1494 + writel(SCL_DIR_MASK, ioaddr + I810_GPIOB);
1495 + writel(0, ioaddr + I810_GPIOB);
1496 + return (0 != (readl(ioaddr + I810_GPIOB) & SCL_VAL_IN));
1499 +static int bit_i810i2c_getsda(void *data)
1501 + writel(SDA_DIR_MASK, ioaddr + I810_GPIOB);
1502 + writel(0, ioaddr + I810_GPIOB);
1503 + return (0 != (readl(ioaddr + I810_GPIOB) & SDA_VAL_IN));
1506 +static void bit_i810ddc_setscl(void *data, int val)
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 */
1513 +static void bit_i810ddc_setsda(void *data, int val)
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 */
1520 +static int bit_i810ddc_getscl(void *data)
1522 + writel(SCL_DIR_MASK, ioaddr + I810_GPIOA);
1523 + writel(0, ioaddr + I810_GPIOA);
1524 + return (0 != (readl(ioaddr + I810_GPIOA) & SCL_VAL_IN));
1527 +static int bit_i810ddc_getsda(void *data)
1529 + writel(SDA_DIR_MASK, ioaddr + I810_GPIOA);
1530 + writel(0, ioaddr + I810_GPIOA);
1531 + return (0 != (readl(ioaddr + I810_GPIOA) & SDA_VAL_IN));
1534 +static int config_i810(struct pci_dev *dev)
1536 + unsigned long cadr;
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);
1544 + bit_i810i2c_setscl(NULL, 1);
1545 + bit_i810i2c_setsda(NULL, 1);
1546 + bit_i810ddc_setscl(NULL, 1);
1547 + bit_i810ddc_setsda(NULL, 1);
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,
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,
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,
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,
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) },
1594 +static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id *id)
1598 + retval = config_i810(dev);
1601 + dev_info(&dev->dev, "i810/i815 i2c device found.\n");
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;
1607 + retval = i2c_bit_add_bus(&i810_i2c_adapter);
1610 + retval = i2c_bit_add_bus(&i810_ddc_adapter);
1612 + i2c_bit_del_bus(&i810_i2c_adapter);
1616 +static void __devexit i810_remove(struct pci_dev *dev)
1618 + i2c_bit_del_bus(&i810_ddc_adapter);
1619 + i2c_bit_del_bus(&i810_i2c_adapter);
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),
1630 +static int __init i2c_i810_init(void)
1632 + return pci_module_init(&i810_driver);
1635 +static void __exit i2c_i810_exit(void)
1637 + pci_unregister_driver(&i810_driver);
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");
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
1654 + * drivers/i2c/i2c-ibm_iic.c
1656 + * Support for the IIC peripheral on IBM PPC 4xx
1658 + * Copyright (c) 2003 Zultys Technologies.
1659 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
1661 + * Based on original work by
1662 + * Ian DaSilva <idasilva@mvista.com>
1663 + * Armin Kuster <akuster@mvista.com>
1664 + * Matt Porter <mporter@mvista.com>
1666 + * Copyright 2000-2003 MontaVista Software Inc.
1668 + * Original driver version was highly leveraged from i2c-elektor.c
1670 + * Copyright 1995-97 Simon G. Vogl
1671 + * 1998-99 Hans Berglund
1673 + * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>
1674 + * and even Frodo Looijaard <frodol@dds.nl>
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.
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>
1696 +#include "i2c-ibm_iic.h"
1698 +#define DRIVER_VERSION "2.0"
1700 +MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
1701 +MODULE_LICENSE("GPL");
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");
1707 +static int iic_force_poll = 0;
1708 +MODULE_PARM(iic_force_poll, "i");
1709 +MODULE_PARM_DESC(iic_force_poll, "Force polling mode");
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)");
1715 +#define DBG_LEVEL 0
1726 +# define DBG(x...) printk(KERN_DEBUG "ibm-iic" ##x)
1728 +# define DBG(x...) ((void)0)
1731 +# define DBG2(x...) DBG( ##x )
1733 +# define DBG2(x...) ((void)0)
1736 +static void dump_iic_regs(const char* header, struct ibm_iic_private* dev)
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));
1748 +# define DUMP_REGS(h,dev) dump_iic_regs((h),(dev))
1750 +# define DUMP_REGS(h,dev) ((void)0)
1753 +/* Enable/disable interrupt generation */
1754 +static inline void iic_interrupt_mode(struct ibm_iic_private* dev, int enable)
1756 + out_8(&dev->vaddr->intmsk, enable ? INTRMSK_EIMTC : 0);
1760 + * Initialize IIC interface.
1762 +static void iic_dev_init(struct ibm_iic_private* dev)
1764 + volatile struct iic_regs *iic = dev->vaddr;
1766 + DBG("%d: init\n", dev->idx);
1768 + /* Clear master address */
1769 + out_8(&iic->lmadr, 0);
1770 + out_8(&iic->hmadr, 0);
1772 + /* Clear slave address */
1773 + out_8(&iic->lsadr, 0);
1774 + out_8(&iic->hsadr, 0);
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);
1781 + /* Set clock divider */
1782 + out_8(&iic->clkdiv, dev->clckdiv);
1784 + /* Clear transfer count */
1785 + out_8(&iic->xfrcnt, 0);
1787 + /* Clear extended control and status */
1788 + out_8(&iic->xtcntlss, XTCNTLSS_SRC | XTCNTLSS_SRS | XTCNTLSS_SWC
1791 + /* Clear control register */
1792 + out_8(&iic->cntl, 0);
1794 + /* Enable interrupts if possible */
1795 + iic_interrupt_mode(dev, dev->irq >= 0);
1797 + /* Set mode control */
1798 + out_8(&iic->mdcntl, MDCNTL_FMDB | MDCNTL_EINT | MDCNTL_EUBS
1799 + | (dev->fast_mode ? MDCNTL_FSM : 0));
1801 + DUMP_REGS("iic_init", dev);
1805 + * Reset IIC interface
1807 +static void iic_dev_reset(struct ibm_iic_private* dev)
1809 + volatile struct iic_regs *iic = dev->vaddr;
1813 + DBG("%d: soft reset\n", dev->idx);
1814 + DUMP_REGS("reset", dev);
1816 + /* Place chip in the reset state */
1817 + out_8(&iic->xtcntlss, XTCNTLSS_SRST);
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);
1824 + /* Try to set bus free state */
1825 + out_8(&iic->directcntl, DIRCNTL_SDAC | DIRCNTL_SCC);
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))
1833 + /* Toggle SCL line */
1834 + dc ^= DIRCNTL_SCC;
1835 + out_8(&iic->directcntl, dc);
1837 + dc ^= DIRCNTL_SCC;
1838 + out_8(&iic->directcntl, dc);
1845 + /* Remove reset */
1846 + out_8(&iic->xtcntlss, 0);
1848 + /* Reinitialize interface */
1849 + iic_dev_init(dev);
1853 + * IIC interrupt handler
1855 +static irqreturn_t iic_handler(int irq, void *dev_id, struct pt_regs *regs)
1857 + struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
1858 + volatile struct iic_regs* iic = dev->vaddr;
1860 + DBG2("%d: irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n",
1861 + dev->idx, in_8(&iic->sts), in_8(&iic->extsts));
1863 + /* Acknowledge IRQ and wakeup iic_wait_for_tc */
1864 + out_8(&iic->sts, STS_IRQA | STS_SCMP);
1865 + wake_up_interruptible(&dev->wq);
1867 + return IRQ_HANDLED;
1871 + * Get master transfer result and clear errors if any.
1872 + * Returns the number of actually transferred bytes or error (<0)
1874 +static int iic_xfer_result(struct ibm_iic_private* dev)
1876 + volatile struct iic_regs *iic = dev->vaddr;
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));
1882 + /* Clear errors and possible pending IRQs */
1883 + out_8(&iic->extsts, EXTSTS_IRQP | EXTSTS_IRQD |
1884 + EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA);
1886 + /* Flush master data buffer */
1887 + out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
1890 + * If error happened during combined xfer
1891 + * IIC interface is usually stuck in some strange
1892 + * state, the only way out - soft reset.
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);
1898 + return -EREMOTEIO;
1901 + return in_8(&iic->xfrcnt) & XFRCNT_MTC_MASK;
1905 + * Try to abort active transfer.
1907 +static void iic_abort_xfer(struct ibm_iic_private* dev)
1909 + volatile struct iic_regs *iic = dev->vaddr;
1912 + DBG("%d: iic_abort_xfer\n", dev->idx);
1914 + out_8(&iic->cntl, CNTL_HMT);
1917 + * Wait for the abort command to complete.
1918 + * It's not worth to be optimized, just poll (timeout >= 1 tick)
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);
1930 + /* Just to clear errors */
1931 + iic_xfer_result(dev);
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)
1939 +static int iic_wait_for_tc(struct ibm_iic_private* dev){
1941 + volatile struct iic_regs *iic = dev->vaddr;
1944 + if (dev->irq >= 0){
1945 + /* Interrupt mode */
1946 + wait_queue_t wait;
1947 + init_waitqueue_entry(&wait, current);
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);
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);
1965 + /* Polling mode */
1966 + unsigned long x = jiffies + dev->adap.timeout * HZ;
1968 + while (in_8(&iic->sts) & STS_PT){
1969 + if (unlikely(time_after(jiffies, x))){
1970 + DBG("%d: poll timeout\n", dev->idx);
1975 + if (unlikely(signal_pending(current))){
1976 + DBG("%d: poll interrupted\n", dev->idx);
1977 + ret = -ERESTARTSYS;
1984 + if (unlikely(ret < 0))
1985 + iic_abort_xfer(dev);
1987 + ret = iic_xfer_result(dev);
1989 + DBG2("%d: iic_wait_for_tc -> %d\n", dev->idx, ret);
1995 + * Low level master transfer routine
1997 +static int iic_xfer_bytes(struct ibm_iic_private* dev, struct i2c_msg* pm,
1998 + int combined_xfer)
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;
2005 + u8 cntl = (in_8(&iic->cntl) & CNTL_AMD) | CNTL_PT;
2006 + if (pm->flags & I2C_M_RD)
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);
2014 + if (!(cntl & CNTL_RW))
2015 + for (j = 0; j < count; ++j)
2016 + out_8((volatile u8*)&iic->mdbuf, *buf++);
2018 + if (i < loops - 1)
2020 + else if (combined_xfer)
2023 + DBG2("%d: xfer_bytes, %d, CNTL = 0x%02x\n", dev->idx, count, cmd);
2025 + /* Start transfer */
2026 + out_8(&iic->cntl, cmd);
2028 + /* Wait for completion */
2029 + ret = iic_wait_for_tc(dev);
2031 + if (unlikely(ret < 0))
2033 + else if (unlikely(ret != count)){
2034 + DBG("%d: xfer_bytes, requested %d, transfered %d\n",
2035 + dev->idx, count, ret);
2037 + /* If it's not a last part of xfer, abort it */
2038 + if (combined_xfer || (i < loops - 1))
2039 + iic_abort_xfer(dev);
2045 + if (cntl & CNTL_RW)
2046 + for (j = 0; j < count; ++j)
2047 + *buf++ = in_8((volatile u8*)&iic->mdbuf);
2050 + return ret > 0 ? 0 : ret;
2054 + * Set target slave address for master transfer
2056 +static inline void iic_address(struct ibm_iic_private* dev, struct i2c_msg* msg)
2058 + volatile struct iic_regs *iic = dev->vaddr;
2059 + u16 addr = msg->addr;
2061 + DBG2("%d: iic_address, 0x%03x (%d-bit)\n", dev->idx,
2062 + addr, msg->flags & I2C_M_TEN ? 10 : 7);
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));
2070 + out_8(&iic->cntl, 0);
2071 + out_8(&iic->lmadr, addr << 1);
2075 +static inline int iic_invalid_address(const struct i2c_msg* p)
2077 + return (p->addr > 0x3ff) || (!(p->flags & I2C_M_TEN) && (p->addr > 0x7f));
2080 +static inline int iic_address_neq(const struct i2c_msg* p1,
2081 + const struct i2c_msg* p2)
2083 + return (p1->addr != p2->addr)
2084 + || ((p1->flags & I2C_M_TEN) != (p2->flags & I2C_M_TEN));
2088 + * Generic master transfer entrypoint.
2089 + * Returns the number of processed messages or error (<0)
2091 +static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
2093 + struct ibm_iic_private* dev = (struct ibm_iic_private*)(i2c_get_adapdata(adap));
2094 + volatile struct iic_regs *iic = dev->vaddr;
2097 + DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num);
2102 + /* Check the sanity of the passed messages.
2103 + * Uhh, generic i2c layer is more suitable place for such code...
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);
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,
2116 + if (unlikely(iic_address_neq(&msgs[0], &msgs[i]))){
2117 + DBG("%d: invalid addr in msg[%d]\n", dev->idx, i);
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);
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
2131 + * The only *reasonable* thing I can think of here
2132 + * is soft reset. --ebs
2134 + iic_dev_reset(dev);
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;
2142 + /* Flush master data buffer (just in case) */
2143 + out_8(&iic->mdcntl, in_8(&iic->mdcntl) | MDCNTL_FMDB);
2146 + /* Load slave address */
2147 + iic_address(dev, &msgs[0]);
2149 + /* Do real transfer */
2150 + for (i = 0; i < num && !ret; ++i)
2151 + ret = iic_xfer_bytes(dev, &msgs[i], i < num - 1);
2153 + return ret < 0 ? ret : num;
2156 +static u32 iic_func(struct i2c_adapter *adap)
2158 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR;
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
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
2176 +static void __devinit iic_scan_bus(struct ibm_iic_private* dev)
2180 + struct i2c_msg msg = {
2182 + .len = sizeof(dummy),
2186 + printk(KERN_INFO "ibm-iic%d: scanning bus...\n" KERN_INFO, dev->idx);
2188 + for (msg.addr = 8; msg.addr < 0x78; ++msg.addr)
2189 + if (iic_xfer(&dev->adap, &msg, 1) == 1){
2191 + printk(" 0x%02x", msg.addr);
2194 + printk("%sibm-iic%d: %d device(s) detected\n",
2195 + found ? "\n" KERN_INFO : "", dev->idx, found);
2199 + * Calculates IICx_CLCKDIV value for a specific OPB clock frequency
2201 +static inline u8 iic_clckdiv(unsigned int opb)
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
2209 + printk(KERN_WARNING "ibm-iic: using compatibility value for OPB freq,"
2210 + " fix your board specific setup\n");
2214 + /* Convert to MHz */
2217 + if (opb < 20 || opb > 150){
2218 + printk(KERN_CRIT "ibm-iic: invalid OPB clock frequency %u MHz\n",
2220 + opb = opb < 20 ? 20 : 150;
2222 + return (u8)((opb + 9) / 10 - 1);
2226 + * Register single IIC interface
2228 +static int __devinit iic_probe(struct ocp_device *ocp){
2230 + struct ibm_iic_private* dev;
2231 + struct i2c_adapter* adap;
2233 + bd_t* bd = (bd_t*)&__res;
2235 + if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){
2236 + printk(KERN_CRIT "ibm-iic: failed to allocate device data\n");
2240 + memset(dev, 0, sizeof(*dev));
2241 + dev->idx = ocp->num;
2242 + ocp_set_drvdata(ocp, dev);
2244 + if (!(dev->vaddr = ioremap(ocp->paddr, sizeof(struct iic_regs)))){
2245 + printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
2251 + init_waitqueue_head(&dev->wq);
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...
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 */
2268 + printk(KERN_WARNING "ibm-iic%d: using polling mode\n",
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];
2275 + /* clckdiv is the same for *all* IIC interfaces,
2276 + * but I'd rather make a copy than introduce another global. --ebs
2278 + dev->clckdiv = iic_clckdiv(bd->bi_opb_busfreq);
2279 + DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
2281 + /* Initialize IIC interface */
2282 + iic_dev_init(dev);
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;
2295 + if ((ret = i2c_add_adapter(adap)) != 0){
2296 + printk(KERN_CRIT "ibm-iic%d: failed to register i2c adapter\n",
2301 + printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
2302 + dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
2304 + /* Scan bus if requested by user */
2306 + iic_scan_bus(dev);
2311 + if (dev->irq >= 0){
2312 + iic_interrupt_mode(dev, 0);
2313 + free_irq(dev->irq, dev);
2316 + iounmap((void*)dev->vaddr);
2318 + ocp_set_drvdata(ocp, 0);
2324 + * Cleanup initialized IIC interface
2326 +static void __devexit iic_remove(struct ocp_device *ocp)
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",
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);
2340 + if (dev->irq >= 0){
2341 + iic_interrupt_mode(dev, 0);
2342 + free_irq(dev->irq, dev);
2344 + iounmap((void*)dev->vaddr);
2349 +static struct ocp_device_id ibm_iic_ids[] __devinitdata =
2351 + { .vendor = OCP_VENDOR_IBM, .device = OCP_FUNC_IIC },
2352 + { .vendor = OCP_VENDOR_INVALID }
2355 +MODULE_DEVICE_TABLE(ocp, ibm_iic_ids);
2357 +static struct ocp_driver ibm_iic_driver =
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)
2369 +static int __init iic_init(void)
2371 + printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n");
2372 + return ocp_module_init(&ibm_iic_driver);
2375 +static void __exit iic_exit(void)
2377 + ocp_unregister_driver(&ibm_iic_driver);
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
2387 + * drivers/i2c/i2c-ibm_iic.h
2389 + * Support for the IIC peripheral on IBM PPC 4xx
2391 + * Copyright (c) 2003 Zultys Technologies.
2392 + * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
2394 + * Based on original work by
2395 + * Ian DaSilva <idasilva@mvista.com>
2396 + * Armin Kuster <akuster@mvista.com>
2397 + * Matt Porter <mporter@mvista.com>
2399 + * Copyright 2000-2003 MontaVista Software Inc.
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.
2407 +#ifndef __I2C_IBM_IIC_H_
2408 +#define __I2C_IBM_IIC_H_
2410 +#include <linux/config.h>
2411 +#include <linux/i2c.h>
2431 +struct ibm_iic_private {
2432 + struct i2c_adapter adap;
2433 + volatile struct iic_regs *vaddr;
2434 + wait_queue_head_t wq;
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
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
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
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
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
2490 +/* IICx_XFRCNT register */
2491 +#define XFRCNT_MTC_MASK 0x07
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
2500 +/* IICx_DIRECTCNTL register */
2501 +#define DIRCNTL_SDAC 0x08
2502 +#define DIRCNTL_SCC 0x04
2503 +#define DIRCNTL_MSDA 0x02
2504 +#define DIRCNTL_MSC 0x01
2506 +/* Check if we really control the I2C bus and bus is free */
2507 +#define DIRCTNL_FREE(v) (((v) & 0x0f) == 0x0f)
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
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>
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.
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.
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 +/* ------------------------------------------------------------------------- */
2535 + With acknowledgements to i2c-algo-ibm_ocp.c by
2536 + Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com
2538 + And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund:
2540 + Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund
2542 + And which acknowledged Kyösti Mälkki <kmalkki@cc.hut.fi>,
2543 + Frodo Looijaard <frodol@dds.nl>, Martin Bailey<mbailey@littlefeet-inc.com>
2545 + ---------------------------------------------------------------------------*/
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>
2559 +#include <asm/arch-iop3xx/iop321.h>
2560 +#include <asm/arch-iop3xx/iop321-irqs.h>
2561 +#include "i2c-iop3xx.h"
2564 +/* ----- global defines ----------------------------------------------- */
2565 +#define PASSERT(x) do { if (!(x) ) \
2566 + printk(KERN_CRIT "PASSERT %s in %s:%d\n", #x, __FILE__, __LINE__ );\
2570 +/* ----- global variables --------------------------------------------- */
2573 +static inline unsigned char iic_cook_addr(struct i2c_msg *msg)
2575 + unsigned char addr;
2577 + addr = (msg->addr << 1);
2579 + if (msg->flags & I2C_M_RD)
2582 + /* PGM: what is M_REV_DIR_ADDR - do we need it ?? */
2583 + if (msg->flags & I2C_M_REV_DIR_ADDR)
2590 +static inline void iop3xx_adap_reset(struct i2c_algo_iop3xx_data *iop3xx_adap)
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;
2598 +static inline void iop3xx_adap_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap)
2600 + *iop3xx_adap->biu->SAR = MYSAR;
2603 +static inline void iop3xx_adap_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
2605 + u32 cr = IOP321_ICR_GCD|IOP321_ICR_SCLEN|IOP321_ICR_UE;
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;
2612 + cr |= IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
2613 + IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE;
2615 + *iop3xx_adap->biu->CR = cr;
2618 +static void iop3xx_adap_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
2620 + unsigned cr = *iop3xx_adap->biu->CR;
2622 + cr &= ~(IOP321_ICR_MSTART | IOP321_ICR_TBYTE |
2623 + IOP321_ICR_MSTOP | IOP321_ICR_SCLEN);
2624 + *iop3xx_adap->biu->CR = cr;
2627 +static void iop3xx_adap_final_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
2629 + unsigned cr = *iop3xx_adap->biu->CR;
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;
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
2641 +static void iop3xx_i2c_handler(int this_irq,
2643 + struct pt_regs *regs)
2645 + struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id;
2647 + u32 sr = *iop3xx_adap->biu->SR;
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);
2656 +/* check all error conditions, clear them , report most important */
2657 +static int iop3xx_adap_error(u32 sr)
2661 + if ((sr&IOP321_ISR_BERRD)) {
2662 + if ( !rc ) rc = -I2C_ERR_BERR;
2664 + if ((sr&IOP321_ISR_ALD)) {
2665 + if ( !rc ) rc = -I2C_ERR_ALD;
2670 +static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap)
2672 + unsigned long flags;
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);
2684 + * sleep until interrupted, then recover and analyse the SR
2685 + * saved by handler
2687 +typedef int (* compare_func)(unsigned test, unsigned mask);
2688 +/* returns 1 on correct comparison */
2690 +static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap,
2691 + unsigned flags, unsigned* status,
2692 + compare_func compare)
2700 + interrupted = wait_event_interruptible_timeout (
2701 + iop3xx_adap->waitq,
2702 + (done = compare( sr = get_srstat(iop3xx_adap),flags )),
2703 + iop3xx_adap->timeout
2705 + if ((rc = iop3xx_adap_error(sr)) < 0) {
2708 + }else if (!interrupted) {
2710 + return rc = -ETIMEDOUT;
2720 + * Concrete compare_funcs
2722 +static int all_bits_clear(unsigned test, unsigned mask)
2724 + return (test & mask) == 0;
2726 +static int any_bits_set(unsigned test, unsigned mask)
2728 + return (test & mask) != 0;
2731 +static int iop3xx_adap_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2733 + return iop3xx_adap_wait_event(
2735 + IOP321_ISR_TXEMPTY|IOP321_ISR_ALD|IOP321_ISR_BERRD,
2736 + status, any_bits_set);
2739 +static int iop3xx_adap_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2741 + return iop3xx_adap_wait_event(
2743 + IOP321_ISR_RXFULL|IOP321_ISR_ALD|IOP321_ISR_BERRD,
2744 + status, any_bits_set);
2747 +static int iop3xx_adap_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
2749 + return iop3xx_adap_wait_event(
2750 + iop3xx_adap, IOP321_ISR_UNITBUSY, status, all_bits_clear);
2754 + * Description: This performs the IOP3xx initialization sequence
2755 + * Valid for IOP321. Maybe valid for IOP310?.
2757 +static int iop3xx_adap_init (struct i2c_algo_iop3xx_data *iop3xx_adap)
2759 + *IOP321_GPOD &= ~(iop3xx_adap->channel==0 ?
2761 + IOP321_GPOD_I2C1);
2763 + iop3xx_adap_reset(iop3xx_adap);
2764 + iop3xx_adap_set_slave_addr(iop3xx_adap);
2765 + iop3xx_adap_enable(iop3xx_adap);
2770 +static int iop3xx_adap_send_target_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap,
2771 + struct i2c_msg* msg)
2773 + unsigned cr = *iop3xx_adap->biu->CR;
2777 + *iop3xx_adap->biu->DBR = iic_cook_addr(msg);
2779 + cr &= ~(IOP321_ICR_MSTOP | IOP321_ICR_NACK);
2780 + cr |= IOP321_ICR_MSTART | IOP321_ICR_TBYTE;
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);
2787 + PASSERT((status&IOP321_ISR_RXREAD)==0);
2792 +static int iop3xx_adap_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, int stop)
2794 + unsigned cr = *iop3xx_adap->biu->CR;
2798 + *iop3xx_adap->biu->DBR = byte;
2799 + cr &= ~IOP321_ICR_MSTART;
2801 + cr |= IOP321_ICR_MSTOP;
2803 + cr &= ~IOP321_ICR_MSTOP;
2805 + *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
2806 + rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
2811 +static int iop3xx_adap_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap,
2812 + char* byte, int stop)
2814 + unsigned cr = *iop3xx_adap->biu->CR;
2818 + cr &= ~IOP321_ICR_MSTART;
2821 + cr |= IOP321_ICR_MSTOP|IOP321_ICR_NACK;
2823 + cr &= ~(IOP321_ICR_MSTOP|IOP321_ICR_NACK);
2825 + *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
2827 + rc = iop3xx_adap_wait_rx_done(iop3xx_adap, &status);
2829 + *byte = *iop3xx_adap->biu->DBR;
2834 +static int iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap,
2835 + const char *buf, int count)
2837 + struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2841 + for (ii = 0; rc == 0 && ii != count; ++ii) {
2842 + rc = iop3xx_adap_write_byte(iop3xx_adap, buf[ii], ii==count-1);
2847 +static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap,
2848 + char *buf, int count)
2850 + struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2854 + for (ii = 0; rc == 0 && ii != count; ++ii) {
2855 + rc = iop3xx_adap_read_byte(iop3xx_adap, &buf[ii], ii==count-1);
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
2867 +static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg)
2869 + struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2872 + rc = iop3xx_adap_send_target_slave_addr(iop3xx_adap, pmsg);
2877 + if ((pmsg->flags&I2C_M_RD)) {
2878 + return iop3xx_i2c_readbytes(i2c_adap, pmsg->buf, pmsg->len);
2880 + return iop3xx_i2c_writebytes(i2c_adap, pmsg->buf, pmsg->len);
2885 + * master_xfer() - main read/write entry
2887 +static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
2889 + struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
2894 + iop3xx_adap_wait_idle(iop3xx_adap, &status);
2895 + iop3xx_adap_reset(iop3xx_adap);
2896 + iop3xx_adap_enable(iop3xx_adap);
2898 + for (im = 0; ret == 0 && im != num; ++im) {
2899 + ret = iop3xx_handle_msg(i2c_adap, &msgs[im]);
2902 + iop3xx_adap_transaction_cleanup(iop3xx_adap);
2907 +static int algo_control(struct i2c_adapter *adapter, unsigned int cmd,
2908 + unsigned long arg)
2913 +static u32 iic_func(struct i2c_adapter *adap)
2915 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
2919 +/* -----exported algorithm data: ------------------------------------- */
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,
2930 + * registering functions to load algorithms at runtime
2932 +static int i2c_iop3xx_add_bus(struct i2c_adapter *iic_adap)
2934 + struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
2936 + if (!request_region( REGION_START(iop3xx_adap),
2937 + REGION_LENGTH(iop3xx_adap),
2938 + iic_adap->name)) {
2942 + init_waitqueue_head(&iop3xx_adap->waitq);
2943 + spin_lock_init(&iop3xx_adap->lock);
2946 + iop3xx_adap->biu->irq,
2947 + iop3xx_i2c_handler,
2948 + /* SA_SAMPLE_RANDOM */ 0,
2954 + /* register new iic_adapter to i2c module... */
2955 + iic_adap->id |= iic_algo.id;
2956 + iic_adap->algo = &iic_algo;
2958 + iic_adap->timeout = 100; /* default values, should */
2959 + iic_adap->retries = 3; /* be replaced by defines */
2961 + iop3xx_adap_init(iic_adap->algo_data);
2962 + i2c_add_adapter(iic_adap);
2966 +static int i2c_iop3xx_del_bus(struct i2c_adapter *iic_adap)
2968 + struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
2970 + iop3xx_adap_final_cleanup(iop3xx_adap);
2971 + free_irq(iop3xx_adap->biu->irq, iop3xx_adap);
2973 + release_region(REGION_START(iop3xx_adap), REGION_LENGTH(iop3xx_adap));
2975 + return i2c_del_adapter(iic_adap);
2978 +#ifdef CONFIG_ARCH_IOP321
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,
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,
2998 +#define ADAPTER_NAME_ROOT "IOP321 i2c biu adapter "
3000 +#error Please define the BIU struct iop3xx_biu for your processor arch
3003 +static struct i2c_algo_iop3xx_data algo_iop3xx_data0 = {
3008 +static struct i2c_algo_iop3xx_data algo_iop3xx_data1 = {
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,
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,
3027 +static int __init i2c_iop3xx_init (void)
3029 + return i2c_iop3xx_add_bus(&iop3xx_ops0) ||
3030 + i2c_iop3xx_add_bus(&iop3xx_ops1);
3033 +static void __exit i2c_iop3xx_exit (void)
3035 + i2c_iop3xx_del_bus(&iop3xx_ops0);
3036 + i2c_iop3xx_del_bus(&iop3xx_ops1);
3039 +module_init (i2c_iop3xx_init);
3040 +module_exit (i2c_iop3xx_exit);
3042 +MODULE_AUTHOR("D-TACQ Solutions Ltd <www.d-tacq.com>");
3043 +MODULE_DESCRIPTION("IOP3xx iic algorithm and driver");
3044 +MODULE_LICENSE("GPL");
3046 +MODULE_PARM(i2c_debug,"i");
3048 +MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
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
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>
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.
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.
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 +/* ------------------------------------------------------------------------- */
3075 +#ifndef I2C_IOP3XX_H
3076 +#define I2C_IOP3XX_H 1
3079 + * iop321 hardware bit definitions
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 */
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"
3094 +#define IOP321_ICR_UE 0x0040 /* 1=Unit Enable */
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.
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 */
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 */
3124 +#define IOP321_ISR_CLEARBITS 0x07f0
3126 +#define IOP321_ISAR_SAMASK 0x007f
3128 +#define IOP321_IDBR_MASK 0x00ff
3130 +#define IOP321_IBMR_SCL 0x0002
3131 +#define IOP321_IBMR_SDA 0x0001
3133 +#define IOP321_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */
3134 +#define IOP321_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */
3136 +#define MYSAR 0x02 /* SWAG a suitable slave address */
3138 +#define I2C_ERR 321
3139 +#define I2C_ERR_BERR (I2C_ERR+0)
3140 +#define I2C_ERR_ALD (I2C_ERR+1)
3143 +struct iop3xx_biu { /* Bus Interface Unit - the hardware */
3144 +/* physical hardware defs - regs*/
3150 +/* irq bit vector */
3153 + u32 SR_enabled, SR_received;
3156 +struct i2c_algo_iop3xx_data {
3159 + wait_queue_head_t waitq;
3162 + struct iop3xx_biu* biu;
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))
3169 +#define IRQ_STATUS_MASK(adap) (1<<adap->biu->irq)
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
3176 #include <linux/errno.h>
3177 #include <linux/i2c.h>
3179 +static u32 isa_func(struct i2c_adapter *adapter);
3181 /* This is the actual algorithm we define */
3182 static struct i2c_algorithm isa_algorithm = {
3183 .name = "ISA bus algorithm",
3185 + .functionality = isa_func,
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",
3197 +/* We can't do a thing... */
3198 +static u32 isa_func(struct i2c_adapter *adapter)
3203 static int __init i2c_isa_init(void)
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
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
3217 + Copyright 2001 MontaVista Software Inc.
3219 + ----------------------------------------------------------------------------
3220 + This file was highly leveraged from i2c-elektor.c, which was created
3221 + by Simon G. Vogl and Hans Berglund:
3224 + Copyright (C) 1995-97 Simon G. Vogl
3225 + 1998-99 Hans Berglund
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.
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.
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 +/* ------------------------------------------------------------------------- */
3242 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
3243 + Frodo Looijaard <frodol@dds.nl> */
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>
3254 +#include <linux/i2c.h>
3255 +#include <linux/i2c-algo-ite.h>
3256 +#include <linux/i2c-adap-ite.h>
3257 +#include "../i2c-ite.h"
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
3265 +static int base = 0;
3266 +static int irq = 0;
3267 +static int clock = 0;
3268 +static int own = 0;
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;
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 */
3282 +/* ----- local functions ---------------------------------------------- */
3284 +static void iic_ite_setiic(void *data, int ctl, short val)
3286 + unsigned long j = jiffies + 10;
3288 + DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
3289 + DEB3({while (time_before(jiffies, j)) schedule();})
3293 +static short iic_ite_getiic(void *data, int ctl)
3298 + DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));
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
3306 +static int iic_ite_getown(void *data)
3308 + return (gpi.iic_own);
3312 +static int iic_ite_getclock(void *data)
3314 + return (gpi.iic_clock);
3319 +static void iic_ite_sleep(unsigned long timeout)
3321 + schedule_timeout( timeout * HZ);
3326 +/* Put this process to sleep. We will wake up when the
3327 + * IIC controller interrupts.
3329 +static void iic_ite_waitforpin(void) {
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.
3339 + if (gpi.iic_irq > 0) {
3341 + if (iic_pending == 0) {
3342 + interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
3352 +static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs)
3357 + DEB2(printk("iic_ite_handler: in interrupt handler\n"));
3358 + wake_up_interruptible(&iic_wait);
3362 +/* Lock the region of memory where I/O registers exist. Request our
3363 + * interrupt line and register its associated handler.
3365 +static int iic_hw_resrc_init(void)
3367 + if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c"))
3370 + if (gpi.iic_irq <= 0)
3373 + if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0)
3376 + enable_irq(gpi.iic_irq);
3382 +static void iic_ite_release(void)
3384 + if (gpi.iic_irq > 0) {
3385 + disable_irq(gpi.iic_irq);
3386 + free_irq(gpi.iic_irq, 0);
3388 + release_region(gpi.iic_base , 2);
3391 +/* ------------------------------------------------------------------------
3392 + * Encapsulate the above functions in the correct operations structure.
3393 + * This is only done when more than one hardware adapter is supported.
3395 +static struct i2c_algo_iic_data iic_ite_data = {
3401 + iic_ite_waitforpin,
3402 + 80, 80, 100, /* waits, timeout */
3405 +static struct i2c_adapter iic_ite_ops = {
3406 + .owner = THIS_MODULE,
3407 + .id = I2C_HW_I_IIC,
3408 + .algo_data = &iic_ite_data,
3410 + .name = "ITE IIC adapter",
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)
3418 +static int __init iic_ite_init(void)
3421 + struct iic_ite *piic = &gpi;
3423 + printk(KERN_INFO "Initialize ITE IIC adapter module\n");
3425 + piic->iic_base = DEFAULT_BASE;
3427 + piic->iic_base = base;
3430 + piic->iic_irq = DEFAULT_IRQ;
3432 + piic->iic_irq = irq;
3435 + piic->iic_clock = DEFAULT_CLOCK;
3437 + piic->iic_clock = clock;
3440 + piic->iic_own = DEFAULT_OWN;
3442 + piic->iic_own = own;
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)
3452 + printk(KERN_INFO " found device at %#x irq %d.\n",
3453 + piic->iic_base, piic->iic_irq);
3458 +static void iic_ite_exit(void)
3460 + i2c_iic_del_bus(&iic_ite_ops);
3461 + iic_ite_release();
3464 +/* If modules is NOT defined when this file is compiled, then the MODULE_*
3465 + * macros will resolve to nothing
3467 +MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
3468 +MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
3469 +MODULE_LICENSE("GPL");
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");
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.
3484 +module_init(iic_ite_init);
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
3493 + i2c Support for Apple Keywest I2C Bus Controller
3495 + Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
3499 + Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
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.
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.
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.
3517 + 2001/12/13 BenH New implementation
3518 + 2001/12/15 BenH Add support for "byte" and "quick"
3519 + transfers. Add i2c_xfer routine.
3521 + My understanding of the various modes supported by keywest are:
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
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
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>
3552 +#include <asm/io.h>
3553 +#include <asm/prom.h>
3554 +#include <asm/machdep.h>
3555 +#include <asm/pmac_feature.h>
3557 +#include "i2c-keywest.h"
3559 +#define DBG(x...) do {\
3561 + printk(KERN_DEBUG "KW:" x); \
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");
3575 +do_stop(struct keywest_iface* iface, int result)
3577 + write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_STOP);
3578 + iface->state = state_stop;
3579 + iface->result = result;
3582 +/* Main state machine for standard & standard sub mode */
3584 +handle_interrupt(struct keywest_iface *iface, u8 isr)
3587 + int rearm_timer = 1;
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;
3595 + if (isr & KW_I2C_IRQ_STOP && iface->state != state_stop) {
3596 + iface->result = -1;
3597 + iface->state = state_stop;
3599 + switch(iface->state) {
3601 + if (!(isr & KW_I2C_IRQ_ADDR)) {
3602 + do_stop(iface, -1);
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);
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);
3620 + iface->state = state_write;
3621 + DBG("write byte: %x\n", *(iface->data));
3622 + write_reg(reg_data, *(iface->data++));
3628 + if (!(isr & KW_I2C_IRQ_DATA)) {
3629 + do_stop(iface, -1);
3632 + *(iface->data++) = read_reg(reg_data);
3633 + DBG("read byte: %x\n", *(iface->data-1));
3635 + if (iface->datalen == 0)
3636 + iface->state = state_stop;
3638 + write_reg(reg_control, 0);
3641 + if (!(isr & KW_I2C_IRQ_DATA)) {
3642 + do_stop(iface, -1);
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);
3652 + if (iface->datalen) {
3653 + DBG("write byte: %x\n", *(iface->data));
3654 + write_reg(reg_data, *(iface->data++));
3657 + do_stop(iface, 0);
3661 + if (!(isr & KW_I2C_IRQ_STOP) && (++iface->stopretry) < 10)
3662 + do_stop(iface, -1);
3665 + iface->state = state_idle;
3666 + write_reg(reg_control, 0x00);
3667 + write_reg(reg_ier, 0x00);
3668 + complete(&iface->complete);
3673 + write_reg(reg_isr, isr);
3675 + return rearm_timer;
3678 +/* Interrupt handler */
3680 +keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
3682 + struct keywest_iface *iface = (struct keywest_iface *)dev_id;
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;
3693 +keywest_timeout(unsigned long data)
3695 + struct keywest_iface *iface = (struct keywest_iface *)data;
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);
3705 + * SMBUS-type transfer entrypoint
3708 +keywest_smbus_xfer( struct i2c_adapter* adap,
3710 + unsigned short flags,
3714 + union i2c_smbus_data* data)
3716 + struct keywest_chan* chan = i2c_get_adapdata(adap);
3717 + struct keywest_iface* iface = chan->iface;
3723 + if (iface->state == state_dead)
3726 + /* Prepare datas & select mode */
3727 + iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
3729 + case I2C_SMBUS_QUICK:
3732 + iface->cur_mode |= KW_I2C_MODE_STANDARD;
3734 + case I2C_SMBUS_BYTE:
3736 + buffer = &data->byte;
3737 + iface->cur_mode |= KW_I2C_MODE_STANDARD;
3739 + case I2C_SMBUS_BYTE_DATA:
3741 + buffer = &data->byte;
3742 + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3744 + case I2C_SMBUS_WORD_DATA:
3746 + cur_word = cpu_to_le16(data->word);
3747 + buffer = (u8 *)&cur_word;
3748 + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3750 + case I2C_SMBUS_BLOCK_DATA:
3751 + len = data->block[0];
3752 + buffer = &data->block[1];
3753 + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3759 + /* Original driver had this limitation */
3763 + down(&iface->sem);
3765 + DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
3766 + chan->chan_no, addr, len, read_write == I2C_SMBUS_READ);
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;
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);
3780 + /* Set up address and r/w bit */
3781 + write_reg(reg_addr,
3782 + (addr << 1) | ((read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
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);
3790 + mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
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);
3796 + /* Wait interrupt operations completion */
3797 + wait_for_completion(&iface->complete);
3799 + rc = iface->result;
3800 + DBG("transfer done, result: %d\n", rc);
3802 + if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ)
3803 + data->word = le16_to_cpu(cur_word);
3812 + * Generic i2c master transfer entrypoint
3815 +keywest_xfer( struct i2c_adapter *adap,
3816 + struct i2c_msg msgs[],
3819 + struct keywest_chan* chan = i2c_get_adapdata(adap);
3820 + struct keywest_iface* iface = chan->iface;
3821 + struct i2c_msg *pmsg;
3825 + down(&iface->sem);
3827 + /* Set adapter to standard mode */
3828 + iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
3829 + iface->cur_mode |= KW_I2C_MODE_STANDARD;
3832 + for (i = 0; rc >= 0 && i < num;) {
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");
3842 + DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
3844 + pmsg->flags & I2C_M_RD ? "read" : "write",
3845 + pmsg->len, addr, i, num);
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);
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;
3860 + iface->read_write = I2C_SMBUS_WRITE;
3862 + /* Set up address and r/w bit */
3863 + if (pmsg->flags & I2C_M_REV_DIR_ADDR)
3865 + write_reg(reg_addr,
3867 + ((iface->read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
3870 + mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
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);
3876 + /* Wait interrupt operations completion */
3877 + wait_for_completion(&iface->complete);
3879 + rc = iface->result;
3882 + DBG("transfer done, result: %d\n", rc);
3892 +keywest_func(struct i2c_adapter * adapter)
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;
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,
3910 +create_iface(struct device_node *np, struct device *dev)
3912 + unsigned long steps, *psteps, *prate;
3913 + unsigned bsteps, tsize, i, nchan, addroffset;
3914 + struct keywest_iface* iface;
3917 + psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
3918 + steps = psteps ? (*psteps) : 0x10;
3920 + /* Hrm... maybe we can be smarter here */
3921 + for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
3924 + if (!strcmp(np->parent->name, "uni-n")) {
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");
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");
3957 + init_timer(&iface->timeout_timer);
3958 + iface->timeout_timer.function = keywest_timeout;
3959 + iface->timeout_timer.data = (unsigned long)iface;
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) {
3966 + iface->cur_mode = KW_I2C_MODE_100KHZ;
3969 + iface->cur_mode = KW_I2C_MODE_50KHZ;
3972 + iface->cur_mode = KW_I2C_MODE_25KHZ;
3975 + printk(KERN_WARNING "i2c-keywest: unknown rate %ldKhz, using 100KHz\n",
3979 + /* Select standard sub mode */
3980 + iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
3983 + write_reg(reg_mode, iface->cur_mode);
3985 + /* Switch interrupts off & clear them*/
3986 + write_reg(reg_ier, 0x00);
3987 + write_reg(reg_isr, KW_I2C_IRQ_MASK);
3989 + /* Request chip interrupt */
3990 + rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
3992 + printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
3993 + iounmap((void *)iface->base);
3998 + dev_set_drvdata(dev, iface);
4000 + for (i=0; i<nchan; i++) {
4001 + struct keywest_chan* chan = &iface->channels[i];
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;
4015 + rc = i2c_add_adapter(&chan->adapter);
4017 + printk("i2c-keywest.c: Adapter %s registration failed\n",
4018 + chan->adapter.name);
4019 + i2c_set_adapdata(&chan->adapter, NULL);
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);
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);
4039 +dispose_iface(struct device *dev)
4041 + struct keywest_iface *iface = dev_get_drvdata(dev);
4044 + /* Make sure we stop all activity */
4045 + down(&iface->sem);
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);
4054 + iface->state = state_dead;
4055 + spin_unlock_irq(&iface->lock);
4056 + free_irq(iface->irq, iface);
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)
4064 + rc = i2c_del_adapter(&chan->adapter);
4065 + i2c_set_adapdata(&chan->adapter, NULL);
4066 + /* We aren't that prepared to deal with this... */
4068 + printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
4070 + iounmap((void *)iface->base);
4071 + dev_set_drvdata(dev, NULL);
4078 +create_iface_macio(struct macio_dev* dev, const struct of_match *match)
4080 + return create_iface(dev->ofdev.node, &dev->ofdev.dev);
4084 +dispose_iface_macio(struct macio_dev* dev)
4086 + return dispose_iface(&dev->ofdev.dev);
4090 +create_iface_of_platform(struct of_device* dev, const struct of_match *match)
4092 + return create_iface(dev->node, &dev->dev);
4096 +dispose_iface_of_platform(struct of_device* dev)
4098 + return dispose_iface(&dev->dev);
4101 +static struct of_match i2c_keywest_match[] =
4104 + .name = OF_ANY_MATCH,
4106 + .compatible = "keywest"
4111 +static struct macio_driver i2c_keywest_macio_driver =
4113 + .name = "i2c-keywest",
4114 + .match_table = i2c_keywest_match,
4115 + .probe = create_iface_macio,
4116 + .remove = dispose_iface_macio
4119 +static struct of_platform_driver i2c_keywest_of_platform_driver =
4121 + .name = "i2c-keywest",
4122 + .match_table = i2c_keywest_match,
4123 + .probe = create_iface_of_platform,
4124 + .remove = dispose_iface_of_platform
4128 +i2c_keywest_init(void)
4130 + macio_register_driver(&i2c_keywest_macio_driver);
4131 + of_register_driver(&i2c_keywest_of_platform_driver);
4137 +i2c_keywest_cleanup(void)
4139 + macio_unregister_driver(&i2c_keywest_macio_driver);
4140 + of_unregister_driver(&i2c_keywest_of_platform_driver);
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
4149 +#ifndef __I2C_KEYWEST_H__
4150 +#define __I2C_KEYWEST_H__
4152 +/* The Tumbler audio equalizer can be really slow sometimes */
4153 +#define POLL_TIMEOUT (2*HZ)
4155 +/* Register indices */
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
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
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
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
4199 +/* Physical interface */
4200 +struct keywest_iface
4202 + unsigned long base;
4205 + struct semaphore sem;
4207 + struct keywest_chan* channels;
4208 + unsigned chan_count;
4216 + struct timer_list timeout_timer;
4217 + struct completion complete;
4229 +/* Channel on an interface */
4230 +struct keywest_chan
4232 + struct i2c_adapter adapter;
4233 + struct keywest_iface* iface;
4237 +/* Register access */
4239 +static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
4241 + return in_8(((volatile u8 *)iface->base)
4242 + + (((unsigned)reg) << iface->bsteps));
4245 +static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
4247 + out_8(((volatile u8 *)iface->base)
4248 + + (((unsigned)reg) << iface->bsteps), val);
4249 + (void)__read_reg(iface, reg);
4253 +#define write_reg(reg, val) __write_reg(iface, reg, val)
4254 +#define read_reg(reg) __read_reg(iface, reg)
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
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,
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);
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
4283 +/* ------------------------------------------------------------------------- */
4284 +/* i2c-philips-par.c i2c-hw access for philips style parallel port adapters */
4285 +/* ------------------------------------------------------------------------- */
4286 +/* Copyright (C) 1995-2000 Simon G. Vogl
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.
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.
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 +/* ------------------------------------------------------------------------- */
4303 +/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
4304 + Frodo Looijaard <frodol@dds.nl> */
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>
4319 + struct pardevice *pdev;
4320 + struct i2c_adapter adapter;
4321 + struct i2c_algo_bit_data bit_lp_data;
4322 + struct i2c_par *next;
4325 +static struct i2c_par *adapter_list;
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 */
4335 +#define I2C_SDAIN 0x80 /* 11 stat Y busy */
4336 +#define I2C_SCLIN 0x08 /* 15 stat Y enable */
4338 +#define I2C_DMASK 0x7f
4339 +#define I2C_CMASK 0xf7
4341 +/* ----- local functions ---------------------------------------------- */
4343 +static void bit_lp_setscl(void *data, int state)
4345 + /*be cautious about state of the control register -
4346 + touch only the one bit needed*/
4348 + parport_write_control((struct parport *) data,
4349 + parport_read_control((struct parport *) data)|I2C_SCL);
4351 + parport_write_control((struct parport *) data,
4352 + parport_read_control((struct parport *) data)&I2C_CMASK);
4356 +static void bit_lp_setsda(void *data, int state)
4359 + parport_write_data((struct parport *) data, I2C_DMASK);
4361 + parport_write_data((struct parport *) data, I2C_SDA);
4365 +static int bit_lp_getscl(void *data)
4367 + return parport_read_status((struct parport *) data) & I2C_SCLIN;
4370 +static int bit_lp_getsda(void *data)
4372 + return parport_read_status((struct parport *) data) & I2C_SDAIN;
4375 +static void bit_lp_setscl2(void *data, int state)
4378 + parport_write_data((struct parport *) data,
4379 + parport_read_data((struct parport *) data)|0x1);
4381 + parport_write_data((struct parport *) data,
4382 + parport_read_data((struct parport *) data)&0xfe);
4386 +static void bit_lp_setsda2(void *data, int state)
4389 + parport_write_data((struct parport *) data,
4390 + parport_read_data((struct parport *) data)|0x2);
4392 + parport_write_data((struct parport *) data,
4393 + parport_read_data((struct parport *) data)&0xfd);
4397 +static int bit_lp_getsda2(void *data)
4399 + return (parport_read_status((struct parport *) data) &
4400 + PARPORT_STATUS_BUSY) ? 0 : 1;
4403 +/* ------------------------------------------------------------------------
4404 + * Encapsulate the above functions in the correct operations structure.
4405 + * This is only done when more than one hardware adapter is supported.
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,
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,
4427 +static struct i2c_adapter bit_lp_ops = {
4428 + .owner = THIS_MODULE,
4429 + .id = I2C_HW_B_LP,
4430 + .name = "Philips Parallel port adapter",
4433 +static void i2c_parport_attach (struct parport *port)
4435 + struct i2c_par *adapter = kmalloc(sizeof(struct i2c_par),
4438 + printk(KERN_ERR "i2c-philips-par: Unable to malloc.\n");
4441 + memset (adapter, 0x00, sizeof(struct i2c_par));
4443 + /* printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name); */
4445 + adapter->pdev = parport_register_device(port, "i2c-philips-par",
4447 + PARPORT_FLAG_EXCL,
4449 + if (!adapter->pdev) {
4450 + printk(KERN_ERR "i2c-philips-par: Unable to register with parport.\n");
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;
4460 + if (parport_claim_or_block(adapter->pdev) < 0 ) {
4461 + printk(KERN_ERR "i2c-philips-par: Could not claim parallel port.\n");
4465 + /* reset hardware to sane state */
4466 + bit_lp_setsda(port, 1);
4467 + bit_lp_setscl(port, 1);
4468 + parport_release(adapter->pdev);
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);
4474 + return; /* No good */
4477 + adapter->next = adapter_list;
4478 + adapter_list = adapter;
4481 +static void i2c_parport_detach (struct parport *port)
4483 + struct i2c_par *adapter, *prev = NULL;
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);
4490 + prev->next = adapter->next;
4492 + adapter_list = adapter->next;
4500 +static struct parport_driver i2c_driver = {
4501 + .name = "i2c-philips-par",
4502 + .attach = i2c_parport_attach,
4503 + .detach = i2c_parport_detach,
4506 +int __init i2c_bitlp_init(void)
4508 + printk(KERN_INFO "i2c Philips parallel port adapter driver\n");
4510 + return parport_register_driver(&i2c_driver);
4513 +void __exit i2c_bitlp_exit(void)
4515 + parport_unregister_driver(&i2c_driver);
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");
4522 +MODULE_PARM(type, "i");
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
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,
4538 /* set up the driverfs linkage to our parent device */
4539 piix4_adapter.dev.parent = &dev->dev;
4541 - snprintf(piix4_adapter.name, DEVICE_NAME_SIZE,
4542 + snprintf(piix4_adapter.name, I2C_NAME_SIZE,
4543 "SMBus PIIX4 adapter at %04x", piix4_smba);
4545 retval = i2c_add_adapter(&piix4_adapter);
4548 static int __init i2c_piix4_init(void)
4550 - printk(KERN_INFO "i2c-piix4 version %s (%s)\n", I2C_VERSION, I2C_DATE);
4551 return pci_module_init(&piix4_driver);
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
4559 + * kernel/busses/i2c-prosavage.c
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>
4571 + * Please read the lm_sensors documentation for details on use.
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.
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.
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.
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
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.
4599 + * S3/VIA KM266/VT8375 aka ProSavage8
4600 + * S3/VIA KM133/VT8365 aka Savage4
4602 + * Two serial busses are implemented:
4603 + * SERIAL1 - I2C serial communications interface
4604 + * SERIAL2 - DDC2 monitor communications interface
4606 + * Tested on a FX41 mainboard, see http://www.shuttle.com
4610 + * - integration with prosavage framebuffer device
4611 + * (Additional documentation needed :(
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>
4622 + * driver configuration
4624 +#define MAX_BUSSES 2
4630 + struct i2c_adapter adap;
4631 + struct i2c_algo_bit_data algo;
4634 +struct s_i2c_chip {
4636 + struct s_i2c_bus i2c_bus[MAX_BUSSES];
4641 + * i2c configuration
4643 +#ifndef I2C_HW_B_S3VIA
4644 +#define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */
4648 +#define CYCLE_DELAY 10
4649 +#define TIMEOUT (HZ / 2)
4653 + * S3/VIA 8365/8375 registers
4655 +#ifndef PCI_DEVICE_ID_S3_SAVAGE4
4656 +#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25
4658 +#ifndef PCI_DEVICE_ID_S3_PROSAVAGE8
4659 +#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04
4662 +#define VGA_CR_IX 0x3d4
4663 +#define VGA_CR_DATA 0x3d5
4665 +#define CR_SERIAL1 0xa0 /* I2C serial communications interface */
4666 +#define MM_SERIAL1 0xff20
4667 +#define CR_SERIAL2 0xb1 /* DDC2 monitor communications interface */
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
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)
4682 + * Serial bus line handling
4684 + * serial communications register as parameter in private data
4686 + * TODO: locks with other code sections accessing video registers?
4688 +static void bit_s3via_setscl(void *bus, int val)
4690 + struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4693 + SET_CR_IX(p, p->i2c_reg);
4694 + r = GET_CR_DATA(p);
4699 + r &= ~I2C_SCL_OUT;
4701 + SET_CR_DATA(p, r);
4704 +static void bit_s3via_setsda(void *bus, int val)
4706 + struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4709 + SET_CR_IX(p, p->i2c_reg);
4710 + r = GET_CR_DATA(p);
4715 + r &= ~I2C_SDA_OUT;
4717 + SET_CR_DATA(p, r);
4720 +static int bit_s3via_getscl(void *bus)
4722 + struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4724 + SET_CR_IX(p, p->i2c_reg);
4725 + return (0 != (GET_CR_DATA(p) & I2C_SCL_IN));
4728 +static int bit_s3via_getsda(void *bus)
4730 + struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
4732 + SET_CR_IX(p, p->i2c_reg);
4733 + return (0 != (GET_CR_DATA(p) & I2C_SDA_IN));
4738 + * adapter initialisation
4740 +static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
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;
4756 + p->i2c_reg = i2c_reg;
4758 + ret = i2c_bit_add_bus(&p->adap);
4771 +static void __devexit prosavage_remove(struct pci_dev *dev)
4773 + struct s_i2c_chip *chip;
4776 + chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
4781 + for (i = MAX_BUSSES - 1; i >= 0; i--) {
4782 + if (chip->i2c_bus[i].adap_ok == 0)
4785 + ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
4787 + dev_err(&dev->dev, ": %s not removed\n",
4788 + chip->i2c_bus[i].adap.name);
4792 + iounmap(chip->mmio);
4799 + * Detect chip and initialize it
4801 +static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_device_id *id)
4804 + unsigned long base, len;
4805 + struct s_i2c_chip *chip;
4806 + struct s_i2c_bus *bus;
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) {
4814 + memset(chip, 0, sizeof(struct s_i2c_chip));
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);
4820 + if (chip->mmio == NULL) {
4821 + dev_err(&dev->dev, "ioremap failed\n");
4822 + prosavage_remove(dev);
4828 + * Chip initialisation
4830 + /* Unlock Extended IO Space ??? */
4834 + * i2c bus registration
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);
4845 + * ddc bus registration
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);
4857 + dev_err(&dev->dev, ": %s failed\n", bus->adap.name);
4858 + prosavage_remove(dev);
4864 + * Data for PCI driver interface
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) },
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),
4879 +static int __init i2c_prosavage_init(void)
4881 + return pci_module_init(&prosavage_driver);
4884 +static void __exit i2c_prosavage_exit(void)
4886 + pci_unregister_driver(&prosavage_driver);
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");
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
4901 + * Embedded Planet RPX Lite MPC8xx CPM I2C interface.
4902 + * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
4904 + * moved into proper i2c interface;
4905 + * Brad Parker (brad@heeltoe.com)
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.
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>
4926 +rpx_iic_init(struct i2c_algo_8xx_data *data)
4928 + volatile cpm8xx_t *cp;
4929 + volatile immap_t *immap;
4931 + cp = cpmp; /* Get pointer to Communication Processor */
4932 + immap = (immap_t *)IMAP_ADDR; /* and to internal registers */
4934 + data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
4936 + /* Check for and use a microcode relocation patch.
4938 + if ((data->reloc = data->iip->iic_rpbase))
4939 + data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
4941 + data->i2c = (i2c8xx_t *)&(immap->im_i2c);
4944 + /* Initialize Port B IIC pins.
4946 + cp->cp_pbpar |= 0x00000030;
4947 + cp->cp_pbdir |= 0x00000030;
4948 + cp->cp_pbodr |= 0x00000030;
4950 + /* Allocate space for two transmit and two receive buffer
4951 + * descriptors in the DP ram.
4953 + data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4);
4955 + /* ptr to i2c area */
4956 + data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
4959 +static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
4961 + /* install interrupt handler */
4962 + cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
4967 +static struct i2c_algo_8xx_data rpx_data = {
4968 + .setisr = rpx_install_isr
4971 +static struct i2c_adapter rpx_ops = {
4972 + .owner = THIS_MODULE,
4974 + .id = I2C_HW_MPC8XX_EPON,
4975 + .algo_data = &rpx_data,
4978 +int __init i2c_rpx_init(void)
4980 + printk(KERN_INFO "i2c-rpx: i2c MPC8xx driver\n");
4982 + /* reset hardware to sane state */
4983 + rpx_iic_init(&rpx_data);
4985 + if (i2c_8xx_add_bus(&rpx_ops) < 0) {
4986 + printk("i2c-rpx: Unable to register with I2C\n");
4993 +void __exit i2c_rpx_exit(void)
4995 + i2c_8xx_del_bus(&rpx_ops);
4998 +MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
4999 +MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
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
5008 + i2c-savage4.c - Part of lm_sensors, Linux kernel modules for hardware
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>
5015 + Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
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.
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.
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.
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.
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>
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
5059 +#define REG 0xff20 /* Serial Port 1 Register */
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
5073 +/* initialization states */
5078 +#define CYCLE_DELAY 10
5079 +#define TIMEOUT (HZ / 2)
5082 +static void *ioaddr;
5084 +/* The sav GPIO registers don't have individual masks for each bit
5085 + so we always have to read before writing. */
5087 +static void bit_savi2c_setscl(void *data, int val)
5090 + r = readl(ioaddr + REG);
5094 + r &= ~I2C_SCL_OUT;
5095 + writel(r, ioaddr + REG);
5096 + readl(ioaddr + REG); /* flush posted write */
5099 +static void bit_savi2c_setsda(void *data, int val)
5102 + r = readl(ioaddr + REG);
5106 + r &= ~I2C_SDA_OUT;
5107 + writel(r, ioaddr + REG);
5108 + readl(ioaddr + REG); /* flush posted write */
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. */
5115 +static int bit_savi2c_getscl(void *data)
5117 + return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
5120 +static int bit_savi2c_getsda(void *data)
5122 + return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
5125 +/* Configures the chip */
5127 +static int config_s4(struct pci_dev *dev)
5129 + unsigned int cadr;
5132 + cadr = dev->resource[0].start;
5133 + cadr &= PCI_BASE_ADDRESS_MEM_MASK;
5134 + ioaddr = ioremap_nocache(cadr, 0x0080000);
5136 + /* writel(0x8160, ioaddr + REG2); */
5137 + writel(0x00000020, ioaddr + REG);
5138 + dev_info(&dev->dev, "Using Savage4 at %p\n", ioaddr);
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
5154 +static struct i2c_adapter savage4_i2c_adapter = {
5155 + .owner = THIS_MODULE,
5156 + .name = "I2C Savage4 adapter",
5157 + .algo_data = &sav_i2c_bit_data,
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) },
5166 +static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_id *id)
5170 + retval = config_s4(dev);
5174 + /* set up the sysfs linkage to our parent device */
5175 + savage4_i2c_adapter.dev.parent = &dev->dev;
5177 + return i2c_bit_add_bus(&savage4_i2c_adapter);
5180 +static void __devexit savage4_remove(struct pci_dev *dev)
5182 + i2c_bit_del_bus(&savage4_i2c_adapter);
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),
5193 +static int __init i2c_savage4_init(void)
5195 + return pci_module_init(&savage4_driver);
5198 +static void __exit i2c_savage4_exit(void)
5200 + pci_unregister_driver(&savage4_driver);
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");
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
5217 + sis5595.c - Part of lm_sensors, Linux kernel modules for hardware
5219 + Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
5220 + Philip Edelbrock <phil@netroedge.com>
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.
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.
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.
5237 +/* Note: we assume there can only be one SIS5595 with one SMBus interface */
5240 + Note: all have mfr. ID 0x1039.
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.
5248 + NOT SUPPORTED PCI ID BLACKLIST PCI ID
5255 + 5598 0008 5597/5598
5269 + * Add Block Transfers (ugly, but supported by the adapter)
5270 + * Add adapter resets
5273 +/* #define DEBUG 1 */
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>
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 */
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
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
5326 +/* Other settings */
5327 +#define MAX_TIMEOUT 500
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
5337 +/* insmod parameters */
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");
5345 +static unsigned short sis5595_base = 0;
5347 +static u8 sis5595_read(u8 reg)
5349 + outb(reg, sis5595_base + SMB_INDEX);
5350 + return inb(sis5595_base + SMB_DAT);
5353 +static void sis5595_write(u8 reg, u8 data)
5355 + outb(reg, sis5595_base + SMB_INDEX);
5356 + outb(data, sis5595_base + SMB_DAT);
5359 +static int sis5595_setup(struct pci_dev *SIS5595_dev)
5364 + int retval = -ENODEV;
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);
5371 + dev_err(&SIS5595_dev->dev, "Looked for SIS5595 but found unsupported device %.4x\n", *i);
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");
5385 + sis5595_base = force_addr & ~(SIS5595_EXTENT - 1);
5386 + dev_dbg(&SIS5595_dev->dev, "ACPI Base address: %04x\n", sis5595_base);
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);
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))
5400 + if (!pci_read_config_word(SIS5595_dev, ACPI_BASE, &a))
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");
5409 + if (!pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val))
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))
5415 + if (!pci_read_config_byte(SIS5595_dev, SIS5595_ENABLE_REG, &val))
5417 + if ((val & 0x80) == 0) {
5418 + /* doesn't work for some chips? */
5419 + dev_err(&SIS5595_dev->dev, "ACPI enable failed - not supported?\n");
5424 + /* Everything is happy */
5428 + release_region(sis5595_base + SMB_INDEX, 2);
5432 +static int sis5595_transaction(struct i2c_adapter *adap)
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);
5448 + dev_dbg(&adap->dev, "Successfull!\n");
5452 + /* start the transaction by setting bit 4 */
5453 + sis5595_write(SMB_CTL_LO, sis5595_read(SMB_CTL_LO) | 0x10);
5455 + /* We will always wait for a fraction of a second! */
5458 + temp = sis5595_read(SMB_STS_LO);
5459 + } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT));
5461 + /* If the SMBus is still busy, we give up */
5462 + if (timeout >= MAX_TIMEOUT) {
5463 + dev_dbg(&adap->dev, "SMBus Timeout!\n");
5467 + if (temp & 0x10) {
5468 + dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
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 */
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);
5485 + temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
5487 + dev_dbg(&adap->dev, "Failed reset at end of transaction (%02x)\n", temp);
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)
5498 + case I2C_SMBUS_QUICK:
5499 + sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5500 + size = SIS5595_QUICK;
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;
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;
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);
5524 + size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA;
5527 + case I2C_SMBUS_BLOCK_DATA:
5528 + printk("sis5595.o: Block data not yet implemented!\n");
5534 + (KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size);
5538 + sis5595_write(SMB_CTL_LO, ((size & 0x0E)));
5540 + if (sis5595_transaction(adap))
5543 + if ((size != SIS5595_PROC_CALL) &&
5544 + ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK)))
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);
5555 + case SIS5595_WORD_DATA:
5556 + case SIS5595_PROC_CALL:
5557 + data->word = sis5595_read(SMB_BYTE) + (sis5595_read(SMB_BYTE + 1) << 8);
5563 +static u32 sis5595_func(struct i2c_adapter *adapter)
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;
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,
5577 +static struct i2c_adapter sis5595_adapter = {
5578 + .owner = THIS_MODULE,
5580 + .algo = &smbus_algorithm,
5583 +static struct pci_device_id sis5595_ids[] __devinitdata = {
5584 + { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
5588 +static int __devinit sis5595_probe(struct pci_dev *dev, const struct pci_device_id *id)
5590 + if (sis5595_setup(dev)) {
5591 + dev_err(&dev->dev, "SIS5595 not detected, module not inserted.\n");
5595 + /* set up the driverfs linkage to our parent device */
5596 + sis5595_adapter.dev.parent = &dev->dev;
5598 + sprintf(sis5595_adapter.name, "SMBus SIS5595 adapter at %04x",
5599 + sis5595_base + SMB_INDEX);
5600 + return i2c_add_adapter(&sis5595_adapter);
5603 +static void __devexit sis5595_remove(struct pci_dev *dev)
5605 + i2c_del_adapter(&sis5595_adapter);
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),
5615 +static int __init i2c_sis5595_init(void)
5617 + return pci_module_init(&sis5595_driver);
5620 +static void __exit i2c_sis5595_exit(void)
5622 + pci_unregister_driver(&sis5595_driver);
5623 + release_region(sis5595_base + SMB_INDEX, 2);
5626 +MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
5627 +MODULE_DESCRIPTION("SIS5595 SMBus driver");
5628 +MODULE_LICENSE("GPL");
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
5637 + i2c-sis630.c - Part of lm_sensors, Linux kernel modules for hardware
5640 + Copyright (c) 2002,2003 Alexander Malysh <amalysh@web.de>
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.
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.
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.
5660 + Fixed the typo in sis630_access (Thanks to Mark M. Hoffman)
5661 + Changed sis630_transaction.(Thanks to Mark M. Hoffman)
5663 + Added SIS730 as supported
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).
5670 + Fixed typo in sis630_access
5671 + Fixed logical error by restoring of Host Master Clock
5673 + Added block data read/write support.
5683 + Note: we assume there can only be one device, with one SMBus interface.
5686 +/* #define DEBUG 1 */
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>
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
5711 +/* register count for request_region */
5712 +#define SIS630_SMB_IOREGION 20
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
5720 +/* Other settings */
5721 +#define MAX_TIMEOUT 500
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
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).");
5737 +static unsigned short acpi_base = 0;
5739 +static inline u8 sis630_read(u8 reg)
5741 + return inb(acpi_base + reg);
5744 +static inline void sis630_write(u8 reg, u8 data)
5746 + outb(data, acpi_base + reg);
5749 +static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldclock)
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);
5759 + if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) {
5760 + dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
5763 + dev_dbg(&adap->dev, "Successfull!\n");
5767 + /* save old clock, so we can prevent machine for hung */
5768 + *oldclock = sis630_read(SMB_CNT);
5770 + dev_dbg(&adap->dev, "saved clock 0x%02x\n", *oldclock);
5772 + /* disable timeout interrupt , set Host Master Clock to 56KHz if requested */
5773 + if (high_clock > 0)
5774 + sis630_write(SMB_CNT, 0x20);
5776 + sis630_write(SMB_CNT, (*oldclock & ~0x40));
5778 + /* clear all sticky bits */
5779 + temp = sis630_read(SMB_STS);
5780 + sis630_write(SMB_STS, temp & 0x1e);
5782 + /* start the transaction by setting bit 4 and size */
5783 + sis630_write(SMBHOST_CNT,0x10 | (size & 0x07));
5788 +static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
5790 + int temp, result = 0, timeout = 0;
5792 + /* We will always wait for a fraction of a second! */
5795 + temp = sis630_read(SMB_STS);
5796 + /* check if block transmitted */
5797 + if (size == SIS630_BLOCK_DATA && (temp & 0x10))
5799 + } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
5801 + /* If the SMBus is still busy, we give up */
5802 + if (timeout >= MAX_TIMEOUT) {
5803 + dev_dbg(&adap->dev, "SMBus Timeout!\n");
5807 + if (temp & 0x02) {
5808 + dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
5812 + if (temp & 0x04) {
5813 + dev_err(&adap->dev, "Bus collision!\n");
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?
5825 +static void sis630_transaction_end(struct i2c_adapter *adap, u8 oldclock)
5829 + /* clear all status "sticky" bits */
5830 + sis630_write(SMB_STS, temp);
5832 + dev_dbg(&adap->dev, "SMB_CNT before clock restore 0x%02x\n", sis630_read(SMB_CNT));
5835 + * restore old Host Master Clock if high_clock is set
5836 + * and oldclock was not 56KHz
5838 + if (high_clock > 0 && !(oldclock & 0x20))
5839 + sis630_write(SMB_CNT,(sis630_read(SMB_CNT) & ~0x20));
5841 + dev_dbg(&adap->dev, "SMB_CNT after clock restore 0x%02x\n", sis630_read(SMB_CNT));
5844 +static int sis630_transaction(struct i2c_adapter *adap, int size)
5849 + result = sis630_transaction_start(adap, size, &oldclock);
5851 + result = sis630_transaction_wait(adap, size);
5852 + sis630_transaction_end(adap, oldclock);
5858 +static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *data, int read_write)
5860 + int i, len = 0, rc = 0;
5863 + if (read_write == I2C_SMBUS_WRITE) {
5864 + len = data->block[0];
5867 + else if (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]);
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))
5880 + else if ((i-1)%8 == 7 || i==len) {
5881 + dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i);
5883 + dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
5885 + If this is not first transaction,
5886 + we must clear sticky bit.
5889 + sis630_write(SMB_STS,0x10);
5891 + if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) {
5892 + dev_dbg(&adap->dev, "trans_wait failed\n");
5900 + /* read request */
5901 + data->block[0] = len = 0;
5902 + if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) {
5906 + if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) {
5907 + dev_dbg(&adap->dev, "trans_wait failed\n");
5911 + /* if this first transaction then read byte count */
5913 + data->block[0] = sis630_read(SMB_COUNT);
5915 + dev_dbg(&adap->dev, "block data read len=0x%x\n", data->block[0]);
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);
5922 + dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
5924 + /* clear SMBARY_STS */
5925 + sis630_write(SMB_STS,0x10);
5926 + } while(len < data->block[0]);
5929 + sis630_transaction_end(adap, oldclock);
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)
5940 + case I2C_SMBUS_QUICK:
5941 + sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
5942 + size = SIS630_QUICK;
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;
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;
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);
5965 + size = (size == I2C_SMBUS_PROC_CALL ? SIS630_PCALL : SIS630_WORD_DATA);
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);
5973 + printk("Unsupported I2C size\n");
5978 + if (sis630_transaction(adap, size))
5981 + if ((size != SIS630_PCALL) &&
5982 + ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) {
5988 + case SIS630_BYTE_DATA:
5989 + data->byte = sis630_read(SMB_BYTE);
5991 + case SIS630_PCALL:
5992 + case SIS630_WORD_DATA:
5993 + data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
6003 +static u32 sis630_func(struct i2c_adapter *adapter)
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;
6010 +static int sis630_setup(struct pci_dev *dummy)
6013 + struct pci_dev *sis630_dev = NULL;
6014 + int retval = -ENODEV;
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");
6024 + Enable ACPI first , so we can accsess reg 74-75
6025 + in acpi io space and read acpi base addr
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");
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");
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");
6044 + dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
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);
6056 + pci_dev_put(sis630_dev);
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,
6068 +static struct i2c_adapter sis630_adapter = {
6069 + .owner = THIS_MODULE,
6071 + .algo = &smbus_algorithm,
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) },
6080 +static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
6083 + if (sis630_setup(dev)) {
6084 + dev_err(&dev->dev, "SIS630 comp. bus not detected, module not inserted.\n");
6088 + /* set up the driverfs linkage to our parent device */
6089 + sis630_adapter.dev.parent = &dev->dev;
6091 + sprintf(sis630_adapter.name, "SMBus SIS630 adapter at %04x",
6092 + acpi_base + SMB_STS);
6094 + return i2c_add_adapter(&sis630_adapter);
6097 +static void __devexit sis630_remove(struct pci_dev *dev)
6099 + i2c_del_adapter(&sis630_adapter);
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),
6110 +static int __init i2c_sis630_init(void)
6112 + return pci_module_init(&sis630_driver);
6116 +static void __exit i2c_sis630_exit(void)
6118 + pci_unregister_driver(&sis630_driver);
6119 + release_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION);
6123 +MODULE_LICENSE("GPL");
6124 +MODULE_AUTHOR("Alexander Malysh <amalysh@web.de>");
6125 +MODULE_DESCRIPTION("SIS630 SMBus driver");
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
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,
6141 /* set up the driverfs linkage to our parent device */
6142 sis96x_adapter.dev.parent = &dev->dev;
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);
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
6153 +/* ------------------------------------------------------------------------- */
6154 +/* i2c-velleman.c i2c-hw access for Velleman K9000 adapters */
6155 +/* ------------------------------------------------------------------------- */
6156 +/* Copyright (C) 1995-96, 2000 Simon G. Vogl
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.
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.
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 +/* ------------------------------------------------------------------------- */
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>
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 */
6189 + /* Pin Port Inverted name */
6190 +#define I2C_SDA 0x02 /* ctrl bit 1 (inv) */
6191 +#define I2C_SCL 0x08 /* ctrl bit 3 (inv) */
6193 +#define I2C_SDAIN 0x10 /* stat bit 4 */
6194 +#define I2C_SCLIN 0x08 /* ctrl bit 3 (inv)(reads own output)*/
6196 +#define I2C_DMASK 0xfd
6197 +#define I2C_CMASK 0xf7
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 */
6206 +#define DEFAULT_BASE 0x378
6209 +/* ----- local functions --------------------------------------------------- */
6211 +static void bit_velle_setscl(void *data, int state)
6214 + outb(inb(CTRL) & I2C_CMASK, CTRL);
6216 + outb(inb(CTRL) | I2C_SCL, CTRL);
6221 +static void bit_velle_setsda(void *data, int state)
6224 + outb(inb(CTRL) & I2C_DMASK , CTRL);
6226 + outb(inb(CTRL) | I2C_SDA, CTRL);
6231 +static int bit_velle_getscl(void *data)
6233 + return ( 0 == ( (inb(CTRL)) & I2C_SCLIN ) );
6236 +static int bit_velle_getsda(void *data)
6238 + return ( 0 != ( (inb(STAT)) & I2C_SDAIN ) );
6241 +static int bit_velle_init(void)
6243 + if (!request_region(base, (base == 0x3bc) ? 3 : 8,
6244 + "i2c (Vellemann adapter)"))
6247 + bit_velle_setsda((void*)base,1);
6248 + bit_velle_setscl((void*)base,1);
6252 +/* ------------------------------------------------------------------------
6253 + * Encapsulate the above functions in the correct operations structure.
6254 + * This is only done when more than one hardware adapter is supported.
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,
6267 +static struct i2c_adapter bit_velle_ops = {
6268 + .owner = THIS_MODULE,
6269 + .algo_data = &bit_velle_data,
6270 + .name = "Velleman K8000",
6273 +static int __init i2c_bitvelle_init(void)
6275 + printk(KERN_INFO "i2c-velleman: i2c Velleman K8000 driver\n");
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)
6287 + bit_velle_data.data=(void*)base;
6288 + if (bit_velle_init()==0) {
6289 + if(i2c_bit_add_bus(&bit_velle_ops) < 0)
6295 + printk(KERN_DEBUG "i2c-velleman: found device at %#x.\n",base);
6299 +static void __exit i2c_bitvelle_exit(void)
6301 + i2c_bit_del_bus(&bit_velle_ops);
6302 + release_region(base, (base == 0x3bc) ? 3 : 8);
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");
6309 +MODULE_PARM(base, "i");
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
6318 + i2c-via.c - Part of lm_sensors, Linux kernel modules
6319 + for hardware monitoring
6321 + i2c Support for Via Technologies 82C586B South Bridge
6323 + Copyright (c) 1998, 1999 Kyösti Mälkki <kmalkki@cc.hut.fi>
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.
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.
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.
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>
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
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
6361 +/* io-region reservation */
6362 +#define IOSPACE 0x06
6363 +#define IOTEXT "via-i2c"
6365 +static u16 pm_io_base = 0;
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.
6374 +static void bit_via_setscl(void *data, int state)
6376 + outb(state ? inb(I2C_DIR) & ~I2C_SCL : inb(I2C_DIR) | I2C_SCL, I2C_DIR);
6379 +static void bit_via_setsda(void *data, int state)
6381 + outb(state ? inb(I2C_DIR) & ~I2C_SDA : inb(I2C_DIR) | I2C_SDA, I2C_DIR);
6384 +static int bit_via_getscl(void *data)
6386 + return (0 != (inb(I2C_IN) & I2C_SCL));
6389 +static int bit_via_getsda(void *data)
6391 + return (0 != (inb(I2C_IN) & I2C_SDA));
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,
6405 +static struct i2c_adapter vt586b_adapter = {
6406 + .owner = THIS_MODULE,
6407 + .name = "VIA i2c",
6408 + .algo_data = &bit_data,
6412 +static struct pci_device_id vt586b_ids[] __devinitdata = {
6413 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3) },
6417 +static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_id *id)
6424 + dev_err(&dev->dev, "i2c-via: Will only support one host\n");
6428 + pci_read_config_byte(dev, PM_CFG_REVID, &rev);
6432 + base = PM_CFG_IOBASE0;
6436 + base = PM_CFG_IOBASE1;
6440 + base = PM_CFG_IOBASE1;
6441 + /* later revision */
6444 + pci_read_config_word(dev, base, &pm_io_base);
6445 + pm_io_base &= (0xff << 8);
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);
6452 + outb(inb(I2C_DIR) & ~(I2C_SDA | I2C_SCL), I2C_DIR);
6453 + outb(inb(I2C_OUT) & ~(I2C_SDA | I2C_SCL), I2C_OUT);
6455 + /* set up the driverfs linkage to our parent device */
6456 + vt586b_adapter.dev.parent = &dev->dev;
6458 + res = i2c_bit_add_bus(&vt586b_adapter);
6460 + release_region(I2C_DIR, IOSPACE);
6467 +static void __devexit vt586b_remove(struct pci_dev *dev)
6469 + i2c_bit_del_bus(&vt586b_adapter);
6470 + release_region(I2C_DIR, IOSPACE);
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),
6482 +static int __init i2c_vt586b_init(void)
6484 + return pci_module_init(&vt586b_driver);
6487 +static void __exit i2c_vt586b_exit(void)
6489 + pci_unregister_driver(&vt586b_driver);
6493 +MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>");
6494 +MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge");
6495 +MODULE_LICENSE("GPL");
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
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,
6511 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
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);
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
6524 + voodoo3.c - Part of lm_sensors, Linux kernel modules for hardware
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>
6531 + Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
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.
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.
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.
6549 +/* This interfaces to the I2C bus of the Voodoo3 to gain access to
6550 + the BT869 and possibly other I2C devices. */
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>
6559 +/* the only registers we use */
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
6575 +/* initialization states */
6580 +#define CYCLE_DELAY 10
6581 +#define TIMEOUT (HZ / 2)
6584 +static void *ioaddr;
6586 +/* The voo GPIO registers don't have individual masks for each bit
6587 + so we always have to read before writing. */
6589 +static void bit_vooi2c_setscl(void *data, int val)
6592 + r = readl(ioaddr + REG);
6596 + r &= ~I2C_SCL_OUT;
6597 + writel(r, ioaddr + REG);
6598 + readl(ioaddr + REG); /* flush posted write */
6601 +static void bit_vooi2c_setsda(void *data, int val)
6604 + r = readl(ioaddr + REG);
6608 + r &= ~I2C_SDA_OUT;
6609 + writel(r, ioaddr + REG);
6610 + readl(ioaddr + REG); /* flush posted write */
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. */
6617 +static int bit_vooi2c_getscl(void *data)
6619 + return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
6622 +static int bit_vooi2c_getsda(void *data)
6624 + return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
6627 +static void bit_vooddc_setscl(void *data, int val)
6630 + r = readl(ioaddr + REG);
6634 + r &= ~DDC_SCL_OUT;
6635 + writel(r, ioaddr + REG);
6636 + readl(ioaddr + REG); /* flush posted write */
6639 +static void bit_vooddc_setsda(void *data, int val)
6642 + r = readl(ioaddr + REG);
6646 + r &= ~DDC_SDA_OUT;
6647 + writel(r, ioaddr + REG);
6648 + readl(ioaddr + REG); /* flush posted write */
6651 +static int bit_vooddc_getscl(void *data)
6653 + return (0 != (readl(ioaddr + REG) & DDC_SCL_IN));
6656 +static int bit_vooddc_getsda(void *data)
6658 + return (0 != (readl(ioaddr + REG) & DDC_SDA_IN));
6661 +static int config_v3(struct pci_dev *dev)
6663 + unsigned int cadr;
6665 + /* map Voodoo3 memory */
6666 + cadr = dev->resource[0].start;
6667 + cadr &= PCI_BASE_ADDRESS_MEM_MASK;
6668 + ioaddr = ioremap_nocache(cadr, 0x1000);
6670 + writel(0x8160, ioaddr + REG2);
6671 + writel(0xcffc0020, ioaddr + REG);
6672 + dev_info(&dev->dev, "Using Banshee/Voodoo3 I2C device at %p\n", ioaddr);
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
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,
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
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,
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) },
6716 +static int __devinit voodoo3_probe(struct pci_dev *dev, const struct pci_device_id *id)
6720 + retval = config_v3(dev);
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;
6728 + retval = i2c_bit_add_bus(&voodoo3_i2c_adapter);
6731 + retval = i2c_bit_add_bus(&voodoo3_ddc_adapter);
6733 + i2c_bit_del_bus(&voodoo3_i2c_adapter);
6737 +static void __devexit voodoo3_remove(struct pci_dev *dev)
6739 + i2c_bit_del_bus(&voodoo3_i2c_adapter);
6740 + i2c_bit_del_bus(&voodoo3_ddc_adapter);
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),
6751 +static int __init i2c_voodoo3_init(void)
6753 + return pci_module_init(&voodoo3_driver);
6756 +static void __exit i2c_voodoo3_exit(void)
6758 + pci_unregister_driver(&voodoo3_driver);
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");
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
6775 +/* linux/drivers/i2c/scx200_acb.c
6777 + Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
6779 + National Semiconductor SCx200 ACCESS.bus support
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>
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.
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.
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.
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>
6811 +#include <linux/scx200.h>
6813 +#define NAME "scx200_acb"
6815 +MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
6816 +MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver");
6817 +MODULE_LICENSE("GPL");
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");
6827 +#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
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)
6837 +enum scx200_acb_state {
6841 + state_repeat_start,
6847 +static const char *scx200_acb_state_name[] = {
6857 +/* Physical interface */
6858 +struct scx200_acb_iface
6860 + struct scx200_acb_iface *next;
6861 + struct i2c_adapter adapter;
6863 + struct semaphore sem;
6865 + /* State machine data */
6866 + enum scx200_acb_state state;
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
6895 +/************************************************************************/
6897 +static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
6899 + const char *errmsg;
6901 + DBG("state %s, status = 0x%02x\n",
6902 + scx200_acb_state_name[iface->state], status);
6904 + if (status & ACBST_BER) {
6905 + errmsg = "bus error";
6908 + if (!(status & ACBST_MASTER)) {
6909 + errmsg = "not master";
6912 + if (status & ACBST_NEGACK)
6915 + switch (iface->state) {
6917 + dev_warn(&iface->adapter.dev, "interrupt in idle state\n");
6920 + case state_address:
6921 + /* Do a pointer write first */
6922 + outb(iface->address_byte & ~1, ACBSDA);
6924 + iface->state = state_command;
6927 + case state_command:
6928 + outb(iface->command, ACBSDA);
6930 + if (iface->address_byte & 1)
6931 + iface->state = state_repeat_start;
6933 + iface->state = state_write;
6936 + case state_repeat_start:
6937 + outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
6941 + if (iface->address_byte & 1) {
6942 + if (iface->len == 1)
6943 + outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
6945 + outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
6946 + outb(iface->address_byte, ACBSDA);
6948 + iface->state = state_read;
6950 + outb(iface->address_byte, ACBSDA);
6952 + iface->state = state_write;
6957 + /* Set ACK if receiving the last byte */
6958 + if (iface->len == 1)
6959 + outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
6961 + outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
6963 + *iface->ptr++ = inb(ACBSDA);
6966 + if (iface->len == 0) {
6967 + iface->result = 0;
6968 + iface->state = state_idle;
6969 + outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6975 + if (iface->len == 0) {
6976 + iface->result = 0;
6977 + iface->state = state_idle;
6978 + outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6982 + outb(*iface->ptr++, ACBSDA);
6991 + DBG("negative acknowledge in state %s\n",
6992 + scx200_acb_state_name[iface->state]);
6994 + iface->state = state_idle;
6995 + iface->result = -ENXIO;
6997 + outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
6998 + outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
7002 + dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
7003 + scx200_acb_state_name[iface->state]);
7005 + iface->state = state_idle;
7006 + iface->result = -EIO;
7007 + iface->needs_reset = 1;
7010 +static void scx200_acb_timeout(struct scx200_acb_iface *iface)
7012 + dev_err(&iface->adapter.dev, "timeout in state %s\n",
7013 + scx200_acb_state_name[iface->state]);
7015 + iface->state = state_idle;
7016 + iface->result = -EIO;
7017 + iface->needs_reset = 1;
7021 +static void scx200_acb_poll(struct scx200_acb_iface *iface)
7024 + unsigned long timeout;
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);
7033 + schedule_timeout(HZ/100+1);
7036 + scx200_acb_timeout(iface);
7038 +#endif /* POLLED_MODE */
7040 +static void scx200_acb_reset(struct scx200_acb_iface *iface)
7042 + /* Disable the ACCESS.bus device and Configure the SCL
7043 + frequency: 16 clock cycles */
7044 + outb(0x70, ACBCTL2);
7045 + /* Polling mode */
7047 + /* Disable slave address */
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);
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);
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)
7066 + struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
7073 + case I2C_SMBUS_QUICK:
7077 + case I2C_SMBUS_BYTE:
7078 + if (rw == I2C_SMBUS_READ) {
7080 + buffer = &data->byte;
7083 + buffer = &command;
7086 + case I2C_SMBUS_BYTE_DATA:
7088 + buffer = &data->byte;
7090 + case I2C_SMBUS_WORD_DATA:
7092 + cur_word = cpu_to_le16(data->word);
7093 + buffer = (u8 *)&cur_word;
7095 + case I2C_SMBUS_BLOCK_DATA:
7096 + len = data->block[0];
7097 + buffer = &data->block[1];
7103 + DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
7104 + size, address, command, len, rw == I2C_SMBUS_READ);
7106 + if (!len && rw == I2C_SMBUS_READ) {
7107 + dev_warn(&adapter->dev, "zero length read\n");
7111 + if (len && !buffer) {
7112 + dev_warn(&adapter->dev, "nonzero length but no buffer\n");
7116 + down(&iface->sem);
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;
7124 + iface->result = -EINVAL;
7125 + iface->needs_reset = 0;
7127 + outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
7129 + if (size == I2C_SMBUS_QUICK || size == I2C_SMBUS_BYTE)
7130 + iface->state = state_quick;
7132 + iface->state = state_address;
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 */
7141 + if (iface->needs_reset)
7142 + scx200_acb_reset(iface);
7144 + rc = iface->result;
7148 + if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
7149 + data->word = le16_to_cpu(cur_word);
7152 + printk(KERN_DEBUG NAME ": transfer done, result: %d", rc);
7156 + for (i = 0; i < len; ++i)
7157 + printk(" %02x", buffer[i]);
7165 +static u32 scx200_acb_func(struct i2c_adapter *adapter)
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;
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,
7180 +struct scx200_acb_iface *scx200_acb_list;
7182 +int scx200_acb_probe(struct scx200_acb_iface *iface)
7186 + /* Disable the ACCESS.bus device and Configure the SCL
7187 + frequency: 16 clock cycles */
7188 + outb(0x70, ACBCTL2);
7190 + if (inb(ACBCTL2) != 0x70) {
7191 + DBG("ACBCTL2 readback failed\n");
7195 + outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
7197 + val = inb(ACBCTL1);
7199 + DBG("disabled, but ACBCTL1=0x%02x\n", val);
7203 + outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
7205 + outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
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);
7216 +static int __init scx200_acb_create(int base, int index)
7218 + struct scx200_acb_iface *iface;
7219 + struct i2c_adapter *adapter;
7221 + char description[64];
7223 + iface = kmalloc(sizeof(*iface), GFP_KERNEL);
7225 + printk(KERN_ERR NAME ": can't allocate memory\n");
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;
7238 + init_MUTEX(&iface->sem);
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);
7247 + iface->base = base;
7249 + rc = scx200_acb_probe(iface);
7251 + dev_warn(&adapter->dev, "probe failed\n");
7255 + scx200_acb_reset(iface);
7257 + if (i2c_add_adapter(adapter) < 0) {
7258 + dev_err(&adapter->dev, "failed to register\n");
7264 + iface->next = scx200_acb_list;
7265 + scx200_acb_list = iface;
7273 + release_region(iface->base, 8);
7279 +static int __init scx200_acb_init(void)
7284 + printk(KERN_DEBUG NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
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,
7293 + for (i = 0; i < MAX_DEVICES; ++i) {
7295 + rc = scx200_acb_create(base[i], i);
7297 + if (scx200_acb_list)
7302 +static void __exit scx200_acb_cleanup(void)
7304 + struct scx200_acb_iface *iface;
7306 + while ((iface = scx200_acb_list) != NULL) {
7307 + scx200_acb_list = iface->next;
7310 + i2c_del_adapter(&iface->adapter);
7311 + release_region(iface->base, 8);
7318 +module_init(scx200_acb_init);
7319 +module_exit(scx200_acb_cleanup);
7323 + compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
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
7332 +/* linux/drivers/i2c/scx200_i2c.c
7334 + Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
7336 + National Semiconductor SCx200 I2C bus on GPIO pins
7338 + Based on i2c-velleman.c Copyright (C) 1995-96, 2000 Simon G. Vogl
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.
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.
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.
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>
7364 +#include <linux/scx200_gpio.h>
7366 +#define NAME "scx200_i2c"
7368 +MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
7369 +MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver");
7370 +MODULE_LICENSE("GPL");
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");
7377 +static int scl = CONFIG_SCx200_I2C_SCL;
7378 +static int sda = CONFIG_SCx200_I2C_SDA;
7380 +static void scx200_i2c_setscl(void *data, int state)
7382 + scx200_gpio_set(scl, state);
7385 +static void scx200_i2c_setsda(void *data, int state)
7387 + scx200_gpio_set(sda, state);
7390 +static int scx200_i2c_getscl(void *data)
7392 + return scx200_gpio_get(scl);
7395 +static int scx200_i2c_getsda(void *data)
7397 + return scx200_gpio_get(sda);
7400 +/* ------------------------------------------------------------------------
7401 + * Encapsulate the above functions in the correct operations structure.
7402 + * This is only done when more than one hardware adapter is supported.
7405 +static struct i2c_algo_bit_data scx200_i2c_data = {
7407 + scx200_i2c_setsda,
7408 + scx200_i2c_setscl,
7409 + scx200_i2c_getsda,
7410 + scx200_i2c_getscl,
7411 + 10, 10, 100, /* waits, timeout */
7414 +static struct i2c_adapter scx200_i2c_ops = {
7415 + .owner = THIS_MODULE,
7416 + .algo_data = &scx200_i2c_data,
7417 + .name = "NatSemi SCx200 I2C",
7420 +int scx200_i2c_init(void)
7422 + printk(KERN_DEBUG NAME ": NatSemi SCx200 I2C Driver\n");
7424 + if (!scx200_gpio_present()) {
7425 + printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");
7429 + printk(KERN_DEBUG NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n",
7432 + if (scl == -1 || sda == -1 || scl == sda) {
7433 + printk(KERN_ERR NAME ": scl and sda must be specified\n");
7437 + /* Configure GPIOs as open collector outputs */
7438 + scx200_gpio_configure(scl, ~2, 5);
7439 + scx200_gpio_configure(sda, ~2, 5);
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);
7450 +void scx200_i2c_cleanup(void)
7452 + i2c_bit_del_bus(&scx200_i2c_ops);
7455 +module_init(scx200_i2c_init);
7456 +module_exit(scx200_i2c_cleanup);
7460 + compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
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
7469 -# Sensor device configuration
7470 -# All depend on EXPERIMENTAL and I2C
7471 +# I2C Sensor device configuration
7474 menu "I2C Hardware Sensors Chip support"
7480 config SENSORS_ADM1021
7481 - tristate " Analog Devices ADM1021 and compatibles"
7482 + tristate "Analog Devices ADM1021 and compatibles"
7483 depends on I2C && EXPERIMENTAL
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.
7494 - The module will be called adm1021.
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.
7503 - tristate " National Semiconductors IT87 and compatibles"
7504 + tristate "National Semiconductors IT87 and compatibles"
7505 depends on I2C && EXPERIMENTAL
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.
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.
7519 - tristate " National Semiconductors LM75 and compatibles"
7520 + tristate "National Semiconductors LM75 and compatibles"
7521 depends on I2C && EXPERIMENTAL
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.
7529 - The module will be called lm75.
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
7535 -config SENSORS_LM85
7536 - tristate " National Semiconductors LM85 and compatibles"
7537 - depends on I2C && EXPERIMENTAL
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.
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.
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
7554 - tristate " National Semiconductors LM78 and compatibles"
7555 + tristate "National Semiconductors LM78 and compatibles"
7556 depends on I2C && EXPERIMENTAL
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.
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.
7567 +config SENSORS_LM85
7568 + tristate "National Semiconductors LM85 and compatibles"
7569 + depends on I2C && EXPERIMENTAL
7572 + If you say yes here you get support for National Semiconductor LM85
7573 + sensor chips and clones: ADT7463 and ADM1027.
7575 + This driver can also be built as a module. If so, the module
7576 + will be called lm85.
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
7582 config SENSORS_VIA686A
7583 - tristate " VIA686A"
7584 + tristate "VIA686A"
7585 depends on I2C && EXPERIMENTAL
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.
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.
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
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.
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
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
7622 + This driver can also be built as a module. If so, the module
7623 + will be called w83781d.
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
7630 struct adm1021_data *data;
7632 const char *type_name = "";
7633 - const char *client_name = "";
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 @@
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) {
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";
7664 dev_err(&adapter->dev, "Internal error: unknown kind (%d)?!?",
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);
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
7679 struct it87_data *data;
7681 const char *name = "";
7682 - const char *client_name = "";
7683 int is_isa = i2c_is_isa_adapter(adapter);
7686 @@ -681,10 +680,8 @@
7690 - client_name = "IT87 chip";
7691 } /* else if (kind == it8712) {
7693 - client_name = "IT87-J chip";
7695 dev_dbg(&adapter->dev, "Internal error: unknown kind (%d)?!?",
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);
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
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);
7716 new_client->id = lm75_id++;
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 @@
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";
7734 dev_dbg(&adapter->dev, "Internal error: unknown kind (%d)?!?",
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);
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 ) {
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);
7766 dev_dbg(&adapter->dev, "Internal error, invalid kind (%d)!", kind);
7770 + strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
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
7778 struct i2c_client *new_client;
7779 struct via686a_data *data;
7781 - const char client_name[] = "via686a chip";
7782 + const char client_name[] = "via686a";
7785 /* Make sure we are probing the ISA bus!! */
7787 new_client->dev.parent = &adapter->dev;
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);
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
7799 struct w83781d_data *data = i2c_get_clientdata(client); \
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]); \
7809 @@ -1098,15 +1098,15 @@
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";
7828 client_name = "unknown subclient?";
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);
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 @@
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) {
7853 - client_name = "W83627THF chip";
7854 + client_name = "w83627thf";
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";
7865 dev_err(&new_client->dev, "Internal error: unknown "
7866 "kind (%d)?!?", kind);
7867 @@ -1326,7 +1326,7 @@
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);
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
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
7887 - Copyright 2001 MontaVista Software Inc.
7889 - ----------------------------------------------------------------------------
7890 - This file was highly leveraged from i2c-elektor.c, which was created
7891 - by Simon G. Vogl and Hans Berglund:
7894 - Copyright (C) 1995-97 Simon G. Vogl
7895 - 1998-99 Hans Berglund
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.
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.
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 -/* ------------------------------------------------------------------------- */
7912 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
7913 - Frodo Looijaard <frodol@dds.nl> */
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>
7925 -#include <linux/i2c.h>
7926 -#include <linux/i2c-algo-ite.h>
7927 -#include <linux/i2c-adap-ite.h>
7928 -#include "i2c-ite.h"
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
7936 -static int base = 0;
7937 -static int irq = 0;
7938 -static int clock = 0;
7939 -static int own = 0;
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;
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 */
7953 -/* ----- local functions ---------------------------------------------- */
7955 -static void iic_ite_setiic(void *data, int ctl, short val)
7957 - unsigned long j = jiffies + 10;
7959 - DEB3(printk(" Write 0x%02x to 0x%x\n",(unsigned short)val, ctl&0xff));
7960 - DEB3({while (time_before(jiffies, j)) schedule();})
7964 -static short iic_ite_getiic(void *data, int ctl)
7969 - DEB3(printk("Read 0x%02x from 0x%x\n",(unsigned short)val, ctl&0xff));
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
7977 -static int iic_ite_getown(void *data)
7979 - return (gpi.iic_own);
7983 -static int iic_ite_getclock(void *data)
7985 - return (gpi.iic_clock);
7990 -static void iic_ite_sleep(unsigned long timeout)
7992 - schedule_timeout( timeout * HZ);
7997 -/* Put this process to sleep. We will wake up when the
7998 - * IIC controller interrupts.
8000 -static void iic_ite_waitforpin(void) {
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.
8010 - if (gpi.iic_irq > 0) {
8012 - if (iic_pending == 0) {
8013 - interruptible_sleep_on_timeout(&iic_wait, timeout*HZ );
8023 -static void iic_ite_handler(int this_irq, void *dev_id, struct pt_regs *regs)
8028 - DEB2(printk("iic_ite_handler: in interrupt handler\n"));
8029 - wake_up_interruptible(&iic_wait);
8033 -/* Lock the region of memory where I/O registers exist. Request our
8034 - * interrupt line and register its associated handler.
8036 -static int iic_hw_resrc_init(void)
8038 - if (!request_region(gpi.iic_base, ITE_IIC_IO_SIZE, "i2c"))
8041 - if (gpi.iic_irq <= 0)
8044 - if (request_irq(gpi.iic_irq, iic_ite_handler, 0, "ITE IIC", 0) < 0)
8047 - enable_irq(gpi.iic_irq);
8053 -static void iic_ite_release(void)
8055 - if (gpi.iic_irq > 0) {
8056 - disable_irq(gpi.iic_irq);
8057 - free_irq(gpi.iic_irq, 0);
8059 - release_region(gpi.iic_base , 2);
8062 -/* ------------------------------------------------------------------------
8063 - * Encapsulate the above functions in the correct operations structure.
8064 - * This is only done when more than one hardware adapter is supported.
8066 -static struct i2c_algo_iic_data iic_ite_data = {
8072 - iic_ite_waitforpin,
8073 - 80, 80, 100, /* waits, timeout */
8076 -static struct i2c_adapter iic_ite_ops = {
8077 - .owner = THIS_MODULE,
8078 - .id = I2C_HW_I_IIC,
8079 - .algo_data = &iic_ite_data,
8081 - .name = "ITE IIC adapter",
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)
8089 -static int __init iic_ite_init(void)
8092 - struct iic_ite *piic = &gpi;
8094 - printk(KERN_INFO "Initialize ITE IIC adapter module\n");
8096 - piic->iic_base = DEFAULT_BASE;
8098 - piic->iic_base = base;
8101 - piic->iic_irq = DEFAULT_IRQ;
8103 - piic->iic_irq = irq;
8106 - piic->iic_clock = DEFAULT_CLOCK;
8108 - piic->iic_clock = clock;
8111 - piic->iic_own = DEFAULT_OWN;
8113 - piic->iic_own = own;
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)
8123 - printk(KERN_INFO " found device at %#x irq %d.\n",
8124 - piic->iic_base, piic->iic_irq);
8129 -static void iic_ite_exit(void)
8131 - i2c_iic_del_bus(&iic_ite_ops);
8132 - iic_ite_release();
8135 -/* If modules is NOT defined when this file is compiled, then the MODULE_*
8136 - * macros will resolve to nothing
8138 -MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
8139 -MODULE_DESCRIPTION("I2C-Bus adapter routines for ITE IIC bus adapter");
8140 -MODULE_LICENSE("GPL");
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");
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.
8155 -module_init(iic_ite_init);
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
8164 - -------------------------------------------------------------------------
8165 - i2c-algo-ibm_ocp.c i2c driver algorithms for IBM PPC 405 adapters
8166 - -------------------------------------------------------------------------
8168 - Ian DaSilva, MontaVista Software, Inc.
8169 - idasilva@mvista.com or source@mvista.com
8171 - Copyright 2000 MontaVista Software Inc.
8173 - Changes made to support the IIC peripheral on the IBM PPC 405
8176 - ---------------------------------------------------------------------------
8177 - This file was highly leveraged from i2c-algo-pcf.c, which was created
8178 - by Simon G. Vogl and Hans Berglund:
8181 - Copyright (C) 1995-1997 Simon G. Vogl
8182 - 1998-2000 Hans Berglund
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>
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.
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.
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 - ---------------------------------------------------------------------------
8204 - History: 01/20/12 - Armin
8205 - akuster@mvista.com
8206 - ported up to 2.4.16+
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 .
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>
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
8237 -/* ----- global variables --------------------------------------------- */
8240 -/* module parameters:
8242 -static int i2c_debug=0;
8244 -/* --- setting states on the bus with the right timing: --------------- */
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))
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
8255 -#define IIC_SINGLE_XFER 0
8256 -#define IIC_COMBINED_XFER 1
8258 -#define IIC_ERR_LOST_ARB -2
8259 -#define IIC_ERR_INCOMPLETE_XFR -3
8260 -#define IIC_ERR_NACK -1
8262 -/* --- other auxiliary functions -------------------------------------- */
8266 -// Description: Puts this process to sleep for a period equal to timeout
8268 -static inline void iic_sleep(unsigned long timeout)
8270 - schedule_timeout( timeout * HZ);
8275 -// Description: This performs the IBM PPC 405 IIC initialization sequence
8276 -// as described in the PPC405GP data book.
8278 -static int iic_init (struct i2c_algo_iic_data *adap)
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;
8285 - /* Clear master low master address */
8286 - iic_outb(adap,iic->lmadr, 0);
8288 - /* Clear high master address */
8289 - iic_outb(adap,iic->hmadr, 0);
8291 - /* Clear low slave address */
8292 - iic_outb(adap,iic->lsadr, 0);
8294 - /* Clear high slave address */
8295 - iic_outb(adap,iic->hsadr, 0);
8297 - /* Clear status */
8298 - iic_outb(adap,iic->sts, 0x0a);
8300 - /* Clear extended status */
8301 - iic_outb(adap,iic->extsts, 0x8f);
8303 - /* Set clock division */
8304 - iic_outb(adap,iic->clkdiv, 0x04);
8306 - retval = iic_inb(adap, iic->clkdiv);
8307 - DEB(printk("iic_init: CLKDIV register = %x\n", retval));
8309 - /* Enable interrupts on Requested Master Transfer Complete */
8310 - iic_outb(adap,iic->intmsk, 0x01);
8312 - /* Clear transfer count */
8313 - iic_outb(adap,iic->xfrcnt, 0x0);
8315 - /* Clear extended control and status */
8316 - iic_outb(adap,iic->xtcntlss, 0xf0);
8318 - /* Set mode control (flush master data buf, enable hold SCL, exit */
8319 - /* unknown state. */
8320 - iic_outb(adap,iic->mdcntl, 0x47);
8322 - /* Clear control register */
8323 - iic_outb(adap,iic->cntl, 0x0);
8325 - DEB2(printk(KERN_DEBUG "iic_init: Initialized IIC on PPC 405\n"));
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.
8335 -static int wait_for_pin(struct i2c_algo_iic_data *adap, int *status)
8338 - int timeout = DEF_TIMEOUT;
8340 - struct iic_regs *iic;
8341 - struct iic_ibm *adap_priv_data = adap->data;
8342 - iic = (struct iic_regs *) adap_priv_data->iic_base;
8345 - *status = iic_inb(adap, iic->sts);
8348 - while (timeout-- && (*status & 0x01)) {
8349 - adap->waitforpin(adap->data);
8350 - *status = iic_inb(adap, iic->sts);
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));
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;
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.
8375 - iic_outb(adap, iic->xtcntlss, 0x01);
8378 - /* Is the pending transfer bit in the sts reg finally cleared? */
8379 - retval = iic_inb(adap, iic->sts);
8380 - retval = retval & 0x01;
8382 - printk(KERN_CRIT "The IIC Controller is hosed. A processor reset is required\n");
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);
8397 -//------------------------------------
8398 -// Utility functions
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.
8407 -int analyze_status(struct i2c_algo_iic_data *adap, int *error_code)
8410 - struct iic_regs *iic;
8411 - struct iic_ibm *adap_priv_data = adap->data;
8412 - iic = (struct iic_regs *) adap_priv_data->iic_base;
8415 - ret = iic_inb(adap, iic->sts);
8418 - ret = iic_inb(adap, iic->extsts);
8420 - // Lost arbitration
8421 - *error_code = IIC_ERR_LOST_ARB;
8424 - // Incomplete transfer
8425 - *error_code = IIC_ERR_INCOMPLETE_XFR;
8428 - // Master transfer aborted by a NACK during the transfer of the
8430 - *error_code = IIC_ERR_NACK;
8439 -// Description: This function is called by the upper layers to do the
8440 -// grunt work for a master send transaction
8442 -static int iic_sendbytes(struct i2c_adapter *i2c_adap,const char *buf,
8443 - int count, int xfer_flag)
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;
8454 - if( count == 0 ) return 0;
8456 - loops = count / 4;
8457 - remainder = count % 4;
8459 - if((loops > 1) && (remainder == 0)) {
8460 - for(i=0; i<(loops-1); i++) {
8462 - // Write four bytes to master data buffer
8464 - for(j=0; j<4; j++) {
8465 - iic_outb(adap, iic->mdbuf,
8469 - // Issue command to IICO device to begin transmission
8471 - iic_outb(adap, iic->cntl, 0x35);
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.
8477 - timeout = wait_for_pin(adap, &status);
8482 - //printk(KERN_ERR "Error: write timeout\n");
8485 - ret = analyze_status(adap, &error_code);
8487 - if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8488 - // Return the number of bytes transferred
8489 - ret = iic_inb(adap, iic->xfrcnt);
8491 - return (wrcount-4+ret);
8493 - else return error_code;
8497 - else if((loops >= 1) && (remainder > 0)){
8498 - //printk(KERN_DEBUG "iic_sendbytes: (loops >= 1)\n");
8499 - for(i=0; i<loops; i++) {
8501 - // Write four bytes to master data buffer
8503 - for(j=0; j<4; j++) {
8504 - iic_outb(adap, iic->mdbuf,
8508 - // Issue command to IICO device to begin transmission
8510 - iic_outb(adap, iic->cntl, 0x35);
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.
8516 - timeout = wait_for_pin(adap, &status);
8521 - //printk(KERN_ERR "Error: write timeout\n");
8524 - ret = analyze_status(adap, &error_code);
8526 - if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8527 - // Return the number of bytes transferred
8528 - ret = iic_inb(adap, iic->xfrcnt);
8530 - return (wrcount-4+ret);
8532 - else return error_code;
8537 - //printk(KERN_DEBUG "iic_sendbytes: expedite write\n");
8538 - if(remainder == 0) remainder = 4;
8539 - // remainder = remainder - 1;
8541 - // Write the remaining bytes (less than or equal to 4)
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));
8547 - //printk(KERN_DEBUG "iic_sendbytes: Issuing write\n");
8549 - if(xfer_flag == IIC_COMBINED_XFER) {
8550 - iic_outb(adap, iic->cntl, (0x09 | ((remainder-1) << 4)));
8553 - iic_outb(adap, iic->cntl, (0x01 | ((remainder-1) << 4)));
8555 - DEB2(printk(KERN_DEBUG "iic_sendbytes: Waiting for interrupt\n"));
8556 - timeout = wait_for_pin(adap, &status);
8561 - //printk(KERN_ERR "Error: write timeout\n");
8564 - ret = analyze_status(adap, &error_code);
8566 - if(error_code == IIC_ERR_INCOMPLETE_XFR) {
8567 - // Return the number of bytes transferred
8568 - ret = iic_inb(adap, iic->xfrcnt);
8570 - return (wrcount-4+ret);
8572 - else return error_code;
8574 - DEB2(printk(KERN_DEBUG "iic_sendbytes: Got interrupt\n"));
8580 -// Description: Called by the upper layers to do the grunt work for
8581 -// a master read transaction.
8583 -static int iic_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count, int xfer_type)
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;
8593 - if(count == 0) return 0;
8594 - loops = count / 4;
8595 - remainder = count % 4;
8597 - //printk(KERN_DEBUG "iic_readbytes: loops = %d, remainder = %d\n", loops, remainder);
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++) {
8603 - // Issue command to begin master read (4 bytes maximum)
8605 - //printk(KERN_DEBUG "--->Issued read command\n");
8606 - iic_outb(adap, iic->cntl, 0x37);
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.
8612 - //printk(KERN_DEBUG "--->Waiting for interrupt\n");
8613 - timeout = wait_for_pin(adap, &status);
8616 - //printk(KERN_ERR "Error: read timed out\n");
8619 - //printk(KERN_DEBUG "--->Got interrupt\n");
8621 - ret = analyze_status(adap, &error_code);
8623 - if(error_code == IIC_ERR_INCOMPLETE_XFR)
8626 - return error_code;
8629 - for(j=0; j<4; j++) {
8630 - // Wait for data to shuffle to top of data buffer
8631 - // This value needs to optimized.
8633 - buf[rdcount] = iic_inb(adap, iic->mdbuf);
8635 - //printk(KERN_DEBUG "--->Read one byte\n");
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++) {
8644 - // Issue command to begin master read (4 bytes maximum)
8646 - //printk(KERN_DEBUG "--->Issued read command\n");
8647 - iic_outb(adap, iic->cntl, 0x37);
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.
8653 - //printk(KERN_DEBUG "--->Waiting for interrupt\n");
8654 - timeout = wait_for_pin(adap, &status);
8657 - //printk(KERN_ERR "Error: read timed out\n");
8660 - //printk(KERN_DEBUG "--->Got interrupt\n");
8662 - ret = analyze_status(adap, &error_code);
8664 - if(error_code == IIC_ERR_INCOMPLETE_XFR)
8667 - return error_code;
8670 - for(j=0; j<4; j++) {
8671 - // Wait for data to shuffle to top of data buffer
8672 - // This value needs to optimized.
8674 - buf[rdcount] = iic_inb(adap, iic->mdbuf);
8676 - //printk(KERN_DEBUG "--->Read one byte\n");
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))));
8685 - if(xfer_type == IIC_COMBINED_XFER) {
8686 - iic_outb(adap, iic->cntl, (0x0b | ((remainder-1) << 4)));
8689 - iic_outb(adap, iic->cntl, (0x03 | ((remainder-1) << 4)));
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"));
8696 - //printk(KERN_ERR "Error: read timed out\n");
8700 - ret = analyze_status(adap, &error_code);
8702 - if(error_code == IIC_ERR_INCOMPLETE_XFR)
8705 - return error_code;
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]);
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
8725 -static int iic_combined_transaction(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
8728 - struct i2c_msg *pmsg;
8731 - DEB2(printk(KERN_DEBUG "Beginning combined transaction\n"));
8732 - for(i=0; i < num; i++) {
8734 - if(pmsg->flags & I2C_M_RD) {
8736 - // Last read or write segment needs to be terminated with a stop
8738 - DEB2(printk(KERN_DEBUG "This one is a read\n"));
8741 - DEB2(printk(KERN_DEBUG "Doing the last read\n"));
8743 - ret = iic_readbytes(i2c_adap, pmsg->buf, pmsg->len, (i < num-1) ? IIC_COMBINED_XFER : IIC_SINGLE_XFER);
8745 - if (ret != pmsg->len) {
8746 - DEB2(printk("i2c-algo-ppc405.o: fail: "
8747 - "only read %d bytes.\n",ret));
8751 - DEB2(printk("i2c-algo-ppc405.o: read %d bytes.\n",ret));
8754 - else if(!(pmsg->flags & I2C_M_RD)) {
8756 - // Last read or write segment needs to be terminated with a stop
8758 - DEB2(printk(KERN_DEBUG "This one is a write\n"));
8761 - DEB2(printk(KERN_DEBUG "Doing the last write\n"));
8763 - ret = iic_sendbytes(i2c_adap, pmsg->buf, pmsg->len, (i < num-1) ? IIC_COMBINED_XFER : IIC_SINGLE_XFER);
8765 - if (ret != pmsg->len) {
8766 - DEB2(printk("i2c-algo-ppc405.o: fail: "
8767 - "only wrote %d bytes.\n",ret));
8771 - DEB2(printk("i2c-algo-ppc405.o: wrote %d bytes.\n",ret));
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.
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.
8789 -static inline int iic_doAddress(struct i2c_algo_iic_data *adap,
8790 - struct i2c_msg *msg, int retries)
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;
8799 -// The following segment for 10 bit addresses needs to be ported
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);
8809 - printk(KERN_ERR "iic_doAddress: died at extended address code.\n");
8810 - return -EREMOTEIO;
8812 - // the remaining 8 bit address
8813 - iic_outb(adap,msg->addr & 0x7f);
8814 - // Status check comes here
8816 - printk(KERN_ERR "iic_doAddress: died at 2nd address code.\n");
8817 - return -EREMOTEIO;
8819 - if ( flags & I2C_M_RD ) {
8820 - i2c_repstart(adap);
8821 - // okay, now switch into reading mode
8823 - ret = try_address(adap, addr, retries);
8825 - printk(KERN_ERR "iic_doAddress: died at extended address code.\n");
8826 - return -EREMOTEIO;
8829 - } else ----------> // normal 7 bit address
8831 -Ten bit addresses not supported yet */
8833 - addr = ( msg->addr << 1 );
8834 - if (flags & I2C_M_RD )
8836 - if (flags & I2C_M_REV_DIR_ADDR )
8839 - // Write to the low slave address
8841 - iic_outb(adap, iic->lmadr, addr);
8843 - // Write zero to the high slave register since we are
8844 - // only using 7 bit addresses
8846 - iic_outb(adap, iic->hmadr, 0);
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.
8857 -static int iic_xfer(struct i2c_adapter *i2c_adap,
8858 - struct i2c_msg msgs[],
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;
8867 - iic = (struct iic_regs *) adap_priv_data->iic_base;
8872 - // Clear status register
8874 - DEB2(printk(KERN_DEBUG "iic_xfer: iic_xfer: Clearing status register\n"));
8875 - iic_outb(adap, iic->sts, 0x0a);
8878 - // Wait for any pending transfers to complete
8880 - DEB2(printk(KERN_DEBUG "iic_xfer: Waiting for any pending transfers to complete\n"));
8881 - while((ret = iic_inb(adap, iic->sts)) == 0x01) {
8886 - // Flush master data buf
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);
8893 - // Load slave address
8895 - DEB2(printk(KERN_DEBUG "iic_xfer: Loading slave address\n"));
8896 - ret = iic_doAddress(adap, pmsg, i2c_adap->retries);
8899 - // Check to see if the bus is busy
8901 - ret = iic_inb(adap, iic->extsts);
8902 - // Mask off the irrelevent bits
8904 - // When the bus is free, the BCS bits in the EXTSTS register are 0b100
8905 - if(ret != 0x40) return IIC_ERR_LOST_ARB;
8908 - // Combined transaction (read and write)
8911 - DEB2(printk(KERN_DEBUG "iic_xfer: Call combined transaction\n"));
8912 - ret = iic_combined_transaction(i2c_adap, msgs, num);
8917 - else if((num == 1) && (pmsg->flags & I2C_M_RD)) {
8919 - // Tell device to begin reading data from the master data
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);
8927 - else if((num == 1 ) && (!(pmsg->flags & I2C_M_RD))) {
8929 - // Write data to master data buffers and tell our device
8930 - // to begin transmitting
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);
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.
8949 -static int algo_control(struct i2c_adapter *adapter,
8950 - unsigned int cmd, unsigned long arg)
8952 - struct iic_regs *iic;
8953 - struct i2c_algo_iic_data *adap = adapter->algo_data;
8954 - struct iic_ibm *adap_priv_data = adap->data;
8957 - iic = (struct iic_regs *) adap_priv_data->iic_base;
8959 - lines = iic_inb(adap, iic->directcntl);
8961 - if (cmd == IICO_I2C_SDAHIGH) {
8962 - lines = lines & 0x01;
8963 - if( lines ) lines = 0x04;
8965 - iic_outb(adap, iic->directcntl,(0x08|lines));
8967 - else if (cmd == IICO_I2C_SDALOW) {
8968 - lines = lines & 0x01;
8969 - if( lines ) lines = 0x04;
8971 - iic_outb(adap, iic->directcntl,(0x00|lines));
8973 - else if (cmd == IICO_I2C_SCLHIGH) {
8974 - lines = lines & 0x02;
8975 - if( lines ) lines = 0x08;
8977 - iic_outb(adap, iic->directcntl,(0x04|lines));
8979 - else if (cmd == IICO_I2C_SCLLOW) {
8980 - lines = lines & 0x02;
8981 - if( lines ) lines = 0x08;
8983 - iic_outb(adap, iic->directcntl,(0x00|lines));
8985 - else if (cmd == IICO_I2C_LINEREAD) {
8992 -static u32 iic_func(struct i2c_adapter *adap)
8994 - return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |
8995 - I2C_FUNC_PROTOCOL_MANGLING;
8999 -/* -----exported algorithm data: ------------------------------------- */
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,
9010 - * registering functions to load algorithms at runtime
9015 -// Description: Register bus structure
9017 -int i2c_ocp_add_bus(struct i2c_adapter *adap)
9019 - struct i2c_algo_iic_data *iic_adap = adap->algo_data;
9021 - DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: hw routines for %s registered.\n",
9024 - /* register new adapter to i2c module... */
9026 - adap->id |= iic_algo.id;
9027 - adap->algo = &iic_algo;
9029 - adap->timeout = 100; /* default values, should */
9030 - adap->retries = 3; /* be replaced by defines */
9032 - iic_init(iic_adap);
9033 - i2c_add_adapter(adap);
9041 -int i2c_ocp_del_bus(struct i2c_adapter *adap)
9043 - return i2c_del_adapter(adap);
9047 -EXPORT_SYMBOL(i2c_ocp_add_bus);
9048 -EXPORT_SYMBOL(i2c_ocp_del_bus);
9051 -// The MODULE_* macros resolve to nothing if MODULES is not defined
9052 -// when this file is compiled.
9054 -MODULE_AUTHOR("MontaVista Software <www.mvista.com>");
9055 -MODULE_DESCRIPTION("PPC 405 iic algorithm");
9056 -MODULE_LICENSE("GPL");
9058 -MODULE_PARM(i2c_debug,"i");
9060 -MODULE_PARM_DESC(i2c_debug,
9061 - "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
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
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
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.
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.
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 -/* ------------------------------------------------------------------------- */
9088 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9089 - Frodo Looijaard <frodol@dds.nl> */
9091 -/* Modifications by MontaVista Software, August 2000
9092 - Changes made to support the IIC peripheral on the IBM PPC 405 */
9094 -#ifndef I2C_ALGO_IIC_H
9095 -#define I2C_ALGO_IIC_H 1
9097 -/* --- Defines for pcf-adapters --------------------------------------- */
9098 -#include <linux/i2c.h>
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);
9108 - /* local settings */
9115 -#define I2C_IIC_ADAP_MAX 16
9118 -int i2c_ocp_add_bus(struct i2c_adapter *);
9119 -int i2c_ocp_del_bus(struct i2c_adapter *);
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
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
9138 return (ret == 1 )? count : ret;
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");
9148 return (ret == 1 )? count : ret;
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");
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
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");
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
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
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.
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.
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 -/* ------------------------------------------------------------------------- */
9194 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9195 - Frodo Looijaard <frodol@dds.nl> */
9197 -/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of
9198 - for Alpha Processor Inc. UP-2000(+) boards */
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>
9211 -#include <linux/i2c.h>
9212 -#include <linux/i2c-algo-pcf.h>
9214 -#include <asm/io.h>
9215 -#include <asm/irq.h>
9217 -#include "i2c-pcf8584.h"
9219 -#define DEFAULT_BASE 0x330
9223 -static int clock = 0x1c;
9224 -static int own = 0x55;
9225 -static int mmapped;
9226 -static int i2c_debug;
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 */
9233 -static wait_queue_head_t pcf_wait;
9234 -static int pcf_pending;
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 */
9242 -/* ----- local functions ---------------------------------------------- */
9244 -static void pcf_isa_setbyte(void *data, int ctl, int val)
9246 - int address = ctl ? (base + 1) : base;
9248 - /* enable irq if any specified for serial operation */
9249 - if (ctl && irq && (val & I2C_PCF_ESO)) {
9250 - val |= I2C_PCF_ENI;
9253 - DEB3(printk(KERN_DEBUG "i2c-elektor.o: Write 0x%X 0x%02X\n", address, val & 255));
9255 - switch (mmapped) {
9256 - case 0: /* regular I/O */
9257 - outb(val, address);
9259 - case 2: /* double mapped I/O needed for UP2000 board,
9260 - I don't know why this... */
9261 - writeb(val, address);
9263 - case 1: /* memory mapped I/O */
9264 - writeb(val, address);
9269 -static int pcf_isa_getbyte(void *data, int ctl)
9271 - int address = ctl ? (base + 1) : base;
9272 - int val = mmapped ? readb(address) : inb(address);
9274 - DEB3(printk(KERN_DEBUG "i2c-elektor.o: Read 0x%X 0x%02X\n", address, val));
9279 -static int pcf_isa_getown(void *data)
9285 -static int pcf_isa_getclock(void *data)
9290 -static void pcf_isa_waitforpin(void) {
9296 - if (pcf_pending == 0) {
9297 - interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
9307 -static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) {
9309 - wake_up_interruptible(&pcf_wait);
9310 - return IRQ_HANDLED;
9314 -static int pcf_isa_init(void)
9317 - if (!request_region(base, 2, "i2c (isa bus adapter)")) {
9319 - "i2c-elektor.o: requested I/O region (0x%X:2) "
9320 - "is in use.\n", base);
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);
9334 -/* ------------------------------------------------------------------------
9335 - * Encapsulate the above functions in the correct operations structure.
9336 - * This is only done when more than one hardware adapter is supported.
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,
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",
9356 -static int __init i2c_pcfisa_init(void)
9359 - /* check to see we have memory mapped PCF8584 connected to the
9360 - Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
9363 - struct pci_dev *cy693_dev =
9364 - pci_find_device(PCI_VENDOR_ID_CONTAQ,
9365 - PCI_DEVICE_ID_CONTAQ_82C693, NULL);
9369 - /* yeap, we've found cypress, let's check config */
9370 - if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
9372 - DEB3(printk(KERN_DEBUG "i2c-elektor.o: found cy82c693, config register 0x47 = 0x%02x.\n", config));
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) */
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 */
9387 - /* I don't know why we need to
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");
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);
9407 - printk(KERN_INFO "i2c-elektor.o: i2c pcf8584-isa adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
9410 - base = DEFAULT_BASE;
9413 - init_waitqueue_head(&pcf_wait);
9414 - if (pcf_isa_init())
9416 - if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
9419 - printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base);
9430 - release_region(base , 2);
9434 -static void i2c_pcfisa_exit(void)
9436 - i2c_pcf_del_bus(&pcf_isa_ops);
9444 - release_region(base , 2);
9447 -MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
9448 -MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
9449 -MODULE_LICENSE("GPL");
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");
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
9464 -/* ------------------------------------------------------------------------- */
9465 -/* i2c-elv.c i2c-hw access for philips style parallel port adapters */
9466 -/* ------------------------------------------------------------------------- */
9467 -/* Copyright (C) 1995-2000 Simon G. Vogl
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.
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.
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 -/* ------------------------------------------------------------------------- */
9484 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
9485 - Frodo Looijaard <frodol@dds.nl> */
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>
9500 -#define DEFAULT_BASE 0x378
9502 -static unsigned char PortData = 0;
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 */
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 */
9517 -/* ----- local functions ---------------------------------------------- */
9520 -static void bit_elv_setscl(void *data, int state)
9527 - outb(PortData, DATA);
9530 -static void bit_elv_setsda(void *data, int state)
9537 - outb(PortData, DATA);
9540 -static int bit_elv_getscl(void *data)
9542 - return ( 0 == ( (inb_p(STAT)) & 0x08 ) );
9545 -static int bit_elv_getsda(void *data)
9547 - return ( 0 == ( (inb_p(STAT)) & 0x40 ) );
9550 -static int bit_elv_init(void)
9552 - if (!request_region(base, (base == 0x3bc) ? 3 : 8,
9553 - "i2c (ELV adapter)"))
9556 - if (inb(base+1) & 0x80) { /* BUSY should be high */
9557 - DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n"));
9561 - outb(0x0c,base+2); /* SLCT auf low */
9563 - if (!(inb(base+1) && 0x10)) {
9564 - outb(0x04,base+2);
9565 - DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n"));
9570 - bit_elv_setsda((void*)base,1);
9571 - bit_elv_setscl((void*)base,1);
9575 - release_region(base , (base == 0x3bc) ? 3 : 8);
9579 -/* ------------------------------------------------------------------------
9580 - * Encapsulate the above functions in the correct operations structure.
9581 - * This is only done when more than one hardware adapter is supported.
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,
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",
9600 -static int __init i2c_bitelv_init(void)
9602 - printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
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)
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)
9622 - printk(KERN_DEBUG "i2c-elv.o: found device at %#x.\n",base);
9626 -static void __exit i2c_bitelv_exit(void)
9628 - i2c_bit_del_bus(&bit_elv_ops);
9629 - release_region(base , (base == 0x3bc) ? 3 : 8);
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");
9636 -MODULE_PARM(base, "i");
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
9646 - * linux/drivers/i2c/i2c-frodo.c
9648 - * Author: Abraham van der Merwe <abraham@2d3d.co.za>
9650 - * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
9651 - * Development board (Frodo).
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.
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>
9667 -static void frodo_setsda (void *data,int state)
9670 - FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
9672 - FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
9675 -static void frodo_setscl (void *data,int state)
9678 - FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
9680 - FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
9683 -static int frodo_getsda (void *data)
9685 - return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
9688 -static int frodo_getscl (void *data)
9690 - return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
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,
9703 -static struct i2c_adapter frodo_ops = {
9704 - .owner = THIS_MODULE,
9705 - .id = I2C_HW_B_FRODO,
9706 - .algo_data = &bit_frodo_data,
9708 - .name = "Frodo adapter driver",
9712 -static int __init i2c_frodo_init (void)
9714 - return i2c_bit_add_bus(&frodo_ops);
9717 -static void __exit i2c_frodo_exit (void)
9719 - i2c_bit_del_bus(&frodo_ops);
9722 -MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
9723 -MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
9724 -MODULE_LICENSE ("GPL");
9726 -module_init (i2c_frodo_init);
9727 -module_exit (i2c_frodo_exit);
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
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>
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.
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.
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 -/* ------------------------------------------------------------------------- */
9754 - With acknowledgements to i2c-algo-ibm_ocp.c by
9755 - Ian DaSilva, MontaVista Software, Inc. idasilva@mvista.com
9757 - And i2c-algo-pcf.c, which was created by Simon G. Vogl and Hans Berglund:
9759 - Copyright (C) 1995-1997 Simon G. Vogl, 1998-2000 Hans Berglund
9761 - And which acknowledged Kyösti Mälkki <kmalkki@cc.hut.fi>,
9762 - Frodo Looijaard <frodol@dds.nl>, Martin Bailey<mbailey@littlefeet-inc.com>
9764 - ---------------------------------------------------------------------------*/
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>
9778 -#include <asm/arch-iop3xx/iop321.h>
9779 -#include <asm/arch-iop3xx/iop321-irqs.h>
9780 -#include "i2c-iop3xx.h"
9783 -/* ----- global defines ----------------------------------------------- */
9784 -#define PASSERT(x) do { if (!(x) ) \
9785 - printk(KERN_CRIT "PASSERT %s in %s:%d\n", #x, __FILE__, __LINE__ );\
9789 -/* ----- global variables --------------------------------------------- */
9792 -static inline unsigned char iic_cook_addr(struct i2c_msg *msg)
9794 - unsigned char addr;
9796 - addr = (msg->addr << 1);
9798 - if (msg->flags & I2C_M_RD)
9801 - /* PGM: what is M_REV_DIR_ADDR - do we need it ?? */
9802 - if (msg->flags & I2C_M_REV_DIR_ADDR)
9809 -static inline void iop3xx_adap_reset(struct i2c_algo_iop3xx_data *iop3xx_adap)
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;
9817 -static inline void iop3xx_adap_set_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap)
9819 - *iop3xx_adap->biu->SAR = MYSAR;
9822 -static inline void iop3xx_adap_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
9824 - u32 cr = IOP321_ICR_GCD|IOP321_ICR_SCLEN|IOP321_ICR_UE;
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;
9831 - cr |= IOP321_ICR_ALDIE | IOP321_ICR_BERRIE |
9832 - IOP321_ICR_RXFULLIE | IOP321_ICR_TXEMPTYIE;
9834 - *iop3xx_adap->biu->CR = cr;
9837 -static void iop3xx_adap_transaction_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
9839 - unsigned cr = *iop3xx_adap->biu->CR;
9841 - cr &= ~(IOP321_ICR_MSTART | IOP321_ICR_TBYTE |
9842 - IOP321_ICR_MSTOP | IOP321_ICR_SCLEN);
9843 - *iop3xx_adap->biu->CR = cr;
9846 -static void iop3xx_adap_final_cleanup(struct i2c_algo_iop3xx_data *iop3xx_adap)
9848 - unsigned cr = *iop3xx_adap->biu->CR;
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;
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
9860 -static void iop3xx_i2c_handler(int this_irq,
9862 - struct pt_regs *regs)
9864 - struct i2c_algo_iop3xx_data *iop3xx_adap = dev_id;
9866 - u32 sr = *iop3xx_adap->biu->SR;
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);
9875 -/* check all error conditions, clear them , report most important */
9876 -static int iop3xx_adap_error(u32 sr)
9880 - if ((sr&IOP321_ISR_BERRD)) {
9881 - if ( !rc ) rc = -I2C_ERR_BERR;
9883 - if ((sr&IOP321_ISR_ALD)) {
9884 - if ( !rc ) rc = -I2C_ERR_ALD;
9889 -static inline u32 get_srstat(struct i2c_algo_iop3xx_data *iop3xx_adap)
9891 - unsigned long flags;
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);
9903 - * sleep until interrupted, then recover and analyse the SR
9904 - * saved by handler
9906 -typedef int (* compare_func)(unsigned test, unsigned mask);
9907 -/* returns 1 on correct comparison */
9909 -static int iop3xx_adap_wait_event(struct i2c_algo_iop3xx_data *iop3xx_adap,
9910 - unsigned flags, unsigned* status,
9911 - compare_func compare)
9919 - interrupted = wait_event_interruptible_timeout (
9920 - iop3xx_adap->waitq,
9921 - (done = compare( sr = get_srstat(iop3xx_adap),flags )),
9922 - iop3xx_adap->timeout
9924 - if ((rc = iop3xx_adap_error(sr)) < 0) {
9927 - }else if (!interrupted) {
9929 - return rc = -ETIMEDOUT;
9939 - * Concrete compare_funcs
9941 -static int all_bits_clear(unsigned test, unsigned mask)
9943 - return (test & mask) == 0;
9945 -static int any_bits_set(unsigned test, unsigned mask)
9947 - return (test & mask) != 0;
9950 -static int iop3xx_adap_wait_tx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9952 - return iop3xx_adap_wait_event(
9954 - IOP321_ISR_TXEMPTY|IOP321_ISR_ALD|IOP321_ISR_BERRD,
9955 - status, any_bits_set);
9958 -static int iop3xx_adap_wait_rx_done(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9960 - return iop3xx_adap_wait_event(
9962 - IOP321_ISR_RXFULL|IOP321_ISR_ALD|IOP321_ISR_BERRD,
9963 - status, any_bits_set);
9966 -static int iop3xx_adap_wait_idle(struct i2c_algo_iop3xx_data *iop3xx_adap, int *status)
9968 - return iop3xx_adap_wait_event(
9969 - iop3xx_adap, IOP321_ISR_UNITBUSY, status, all_bits_clear);
9973 - * Description: This performs the IOP3xx initialization sequence
9974 - * Valid for IOP321. Maybe valid for IOP310?.
9976 -static int iop3xx_adap_init (struct i2c_algo_iop3xx_data *iop3xx_adap)
9978 - *IOP321_GPOD &= ~(iop3xx_adap->channel==0 ?
9980 - IOP321_GPOD_I2C1);
9982 - iop3xx_adap_reset(iop3xx_adap);
9983 - iop3xx_adap_set_slave_addr(iop3xx_adap);
9984 - iop3xx_adap_enable(iop3xx_adap);
9989 -static int iop3xx_adap_send_target_slave_addr(struct i2c_algo_iop3xx_data *iop3xx_adap,
9990 - struct i2c_msg* msg)
9992 - unsigned cr = *iop3xx_adap->biu->CR;
9996 - *iop3xx_adap->biu->DBR = iic_cook_addr(msg);
9998 - cr &= ~(IOP321_ICR_MSTOP | IOP321_ICR_NACK);
9999 - cr |= IOP321_ICR_MSTART | IOP321_ICR_TBYTE;
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);
10006 - PASSERT((status&IOP321_ISR_RXREAD)==0);
10011 -static int iop3xx_adap_write_byte(struct i2c_algo_iop3xx_data *iop3xx_adap, char byte, int stop)
10013 - unsigned cr = *iop3xx_adap->biu->CR;
10017 - *iop3xx_adap->biu->DBR = byte;
10018 - cr &= ~IOP321_ICR_MSTART;
10020 - cr |= IOP321_ICR_MSTOP;
10022 - cr &= ~IOP321_ICR_MSTOP;
10024 - *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
10025 - rc = iop3xx_adap_wait_tx_done(iop3xx_adap, &status);
10030 -static int iop3xx_adap_read_byte(struct i2c_algo_iop3xx_data *iop3xx_adap,
10031 - char* byte, int stop)
10033 - unsigned cr = *iop3xx_adap->biu->CR;
10037 - cr &= ~IOP321_ICR_MSTART;
10040 - cr |= IOP321_ICR_MSTOP|IOP321_ICR_NACK;
10042 - cr &= ~(IOP321_ICR_MSTOP|IOP321_ICR_NACK);
10044 - *iop3xx_adap->biu->CR = cr |= IOP321_ICR_TBYTE;
10046 - rc = iop3xx_adap_wait_rx_done(iop3xx_adap, &status);
10048 - *byte = *iop3xx_adap->biu->DBR;
10053 -static int iop3xx_i2c_writebytes(struct i2c_adapter *i2c_adap,
10054 - const char *buf, int count)
10056 - struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10060 - for (ii = 0; rc == 0 && ii != count; ++ii) {
10061 - rc = iop3xx_adap_write_byte(iop3xx_adap, buf[ii], ii==count-1);
10066 -static int iop3xx_i2c_readbytes(struct i2c_adapter *i2c_adap,
10067 - char *buf, int count)
10069 - struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10073 - for (ii = 0; rc == 0 && ii != count; ++ii) {
10074 - rc = iop3xx_adap_read_byte(iop3xx_adap, &buf[ii], ii==count-1);
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
10086 -static int iop3xx_handle_msg(struct i2c_adapter *i2c_adap, struct i2c_msg* pmsg)
10088 - struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10091 - rc = iop3xx_adap_send_target_slave_addr(iop3xx_adap, pmsg);
10096 - if ((pmsg->flags&I2C_M_RD)) {
10097 - return iop3xx_i2c_readbytes(i2c_adap, pmsg->buf, pmsg->len);
10099 - return iop3xx_i2c_writebytes(i2c_adap, pmsg->buf, pmsg->len);
10104 - * master_xfer() - main read/write entry
10106 -static int iop3xx_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
10108 - struct i2c_algo_iop3xx_data *iop3xx_adap = i2c_adap->algo_data;
10113 - iop3xx_adap_wait_idle(iop3xx_adap, &status);
10114 - iop3xx_adap_reset(iop3xx_adap);
10115 - iop3xx_adap_enable(iop3xx_adap);
10117 - for (im = 0; ret == 0 && im != num; ++im) {
10118 - ret = iop3xx_handle_msg(i2c_adap, &msgs[im]);
10121 - iop3xx_adap_transaction_cleanup(iop3xx_adap);
10126 -static int algo_control(struct i2c_adapter *adapter, unsigned int cmd,
10127 - unsigned long arg)
10132 -static u32 iic_func(struct i2c_adapter *adap)
10134 - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
10138 -/* -----exported algorithm data: ------------------------------------- */
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,
10149 - * registering functions to load algorithms at runtime
10151 -static int i2c_iop3xx_add_bus(struct i2c_adapter *iic_adap)
10153 - struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
10155 - if (!request_region( REGION_START(iop3xx_adap),
10156 - REGION_LENGTH(iop3xx_adap),
10157 - iic_adap->name)) {
10161 - init_waitqueue_head(&iop3xx_adap->waitq);
10162 - spin_lock_init(&iop3xx_adap->lock);
10165 - iop3xx_adap->biu->irq,
10166 - iop3xx_i2c_handler,
10167 - /* SA_SAMPLE_RANDOM */ 0,
10173 - /* register new iic_adapter to i2c module... */
10174 - iic_adap->id |= iic_algo.id;
10175 - iic_adap->algo = &iic_algo;
10177 - iic_adap->timeout = 100; /* default values, should */
10178 - iic_adap->retries = 3; /* be replaced by defines */
10180 - iop3xx_adap_init(iic_adap->algo_data);
10181 - i2c_add_adapter(iic_adap);
10185 -static int i2c_iop3xx_del_bus(struct i2c_adapter *iic_adap)
10187 - struct i2c_algo_iop3xx_data *iop3xx_adap = iic_adap->algo_data;
10189 - iop3xx_adap_final_cleanup(iop3xx_adap);
10190 - free_irq(iop3xx_adap->biu->irq, iop3xx_adap);
10192 - release_region(REGION_START(iop3xx_adap), REGION_LENGTH(iop3xx_adap));
10194 - return i2c_del_adapter(iic_adap);
10197 -#ifdef CONFIG_ARCH_IOP321
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,
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,
10217 -#define ADAPTER_NAME_ROOT "IOP321 i2c biu adapter "
10219 -#error Please define the BIU struct iop3xx_biu for your processor arch
10222 -static struct i2c_algo_iop3xx_data algo_iop3xx_data0 = {
10227 -static struct i2c_algo_iop3xx_data algo_iop3xx_data1 = {
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,
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,
10246 -static int __init i2c_iop3xx_init (void)
10248 - return i2c_iop3xx_add_bus(&iop3xx_ops0) ||
10249 - i2c_iop3xx_add_bus(&iop3xx_ops1);
10252 -static void __exit i2c_iop3xx_exit (void)
10254 - i2c_iop3xx_del_bus(&iop3xx_ops0);
10255 - i2c_iop3xx_del_bus(&iop3xx_ops1);
10258 -module_init (i2c_iop3xx_init);
10259 -module_exit (i2c_iop3xx_exit);
10261 -MODULE_AUTHOR("D-TACQ Solutions Ltd <www.d-tacq.com>");
10262 -MODULE_DESCRIPTION("IOP3xx iic algorithm and driver");
10263 -MODULE_LICENSE("GPL");
10265 -MODULE_PARM(i2c_debug,"i");
10267 -MODULE_PARM_DESC(i2c_debug, "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol");
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
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>
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.
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.
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 -/* ------------------------------------------------------------------------- */
10294 -#ifndef I2C_IOP3XX_H
10295 -#define I2C_IOP3XX_H 1
10298 - * iop321 hardware bit definitions
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 */
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"
10313 -#define IOP321_ICR_UE 0x0040 /* 1=Unit Enable */
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.
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 */
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 */
10343 -#define IOP321_ISR_CLEARBITS 0x07f0
10345 -#define IOP321_ISAR_SAMASK 0x007f
10347 -#define IOP321_IDBR_MASK 0x00ff
10349 -#define IOP321_IBMR_SCL 0x0002
10350 -#define IOP321_IBMR_SDA 0x0001
10352 -#define IOP321_GPOD_I2C0 0x00c0 /* clear these bits to enable ch0 */
10353 -#define IOP321_GPOD_I2C1 0x0030 /* clear these bits to enable ch1 */
10355 -#define MYSAR 0x02 /* SWAG a suitable slave address */
10357 -#define I2C_ERR 321
10358 -#define I2C_ERR_BERR (I2C_ERR+0)
10359 -#define I2C_ERR_ALD (I2C_ERR+1)
10362 -struct iop3xx_biu { /* Bus Interface Unit - the hardware */
10363 -/* physical hardware defs - regs*/
10369 -/* irq bit vector */
10371 -/* stored flags */
10372 - u32 SR_enabled, SR_received;
10375 -struct i2c_algo_iop3xx_data {
10378 - wait_queue_head_t waitq;
10381 - struct iop3xx_biu* biu;
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))
10388 -#define IRQ_STATUS_MASK(adap) (1<<adap->biu->irq)
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
10396 - i2c Support for Apple Keywest I2C Bus Controller
10398 - Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
10402 - Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
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.
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.
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.
10420 - 2001/12/13 BenH New implementation
10421 - 2001/12/15 BenH Add support for "byte" and "quick"
10422 - transfers. Add i2c_xfer routine.
10424 - My understanding of the various modes supported by keywest are:
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
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
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>
10456 -#include <asm/io.h>
10457 -#include <asm/prom.h>
10458 -#include <asm/machdep.h>
10459 -#include <asm/pmac_feature.h>
10461 -#include "i2c-keywest.h"
10463 -#define DBG(x...) do {\
10465 - printk(KERN_DEBUG "KW:" x); \
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");
10479 -do_stop(struct keywest_iface* iface, int result)
10481 - write_reg(reg_control, read_reg(reg_control) | KW_I2C_CTL_STOP);
10482 - iface->state = state_stop;
10483 - iface->result = result;
10486 -/* Main state machine for standard & standard sub mode */
10488 -handle_interrupt(struct keywest_iface *iface, u8 isr)
10491 - int rearm_timer = 1;
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;
10499 - if (isr & KW_I2C_IRQ_STOP && iface->state != state_stop) {
10500 - iface->result = -1;
10501 - iface->state = state_stop;
10503 - switch(iface->state) {
10505 - if (!(isr & KW_I2C_IRQ_ADDR)) {
10506 - do_stop(iface, -1);
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);
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);
10524 - iface->state = state_write;
10525 - DBG("write byte: %x\n", *(iface->data));
10526 - write_reg(reg_data, *(iface->data++));
10527 - iface->datalen--;
10532 - if (!(isr & KW_I2C_IRQ_DATA)) {
10533 - do_stop(iface, -1);
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;
10542 - write_reg(reg_control, 0);
10544 - case state_write:
10545 - if (!(isr & KW_I2C_IRQ_DATA)) {
10546 - do_stop(iface, -1);
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);
10556 - if (iface->datalen) {
10557 - DBG("write byte: %x\n", *(iface->data));
10558 - write_reg(reg_data, *(iface->data++));
10559 - iface->datalen--;
10561 - do_stop(iface, 0);
10565 - if (!(isr & KW_I2C_IRQ_STOP) && (++iface->stopretry) < 10)
10566 - do_stop(iface, -1);
10569 - iface->state = state_idle;
10570 - write_reg(reg_control, 0x00);
10571 - write_reg(reg_ier, 0x00);
10572 - complete(&iface->complete);
10577 - write_reg(reg_isr, isr);
10579 - return rearm_timer;
10582 -/* Interrupt handler */
10583 -static irqreturn_t
10584 -keywest_irq(int irq, void *dev_id, struct pt_regs *regs)
10586 - struct keywest_iface *iface = (struct keywest_iface *)dev_id;
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;
10597 -keywest_timeout(unsigned long data)
10599 - struct keywest_iface *iface = (struct keywest_iface *)data;
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);
10609 - * SMBUS-type transfer entrypoint
10612 -keywest_smbus_xfer( struct i2c_adapter* adap,
10614 - unsigned short flags,
10618 - union i2c_smbus_data* data)
10620 - struct keywest_chan* chan = i2c_get_adapdata(adap);
10621 - struct keywest_iface* iface = chan->iface;
10627 - if (iface->state == state_dead)
10630 - /* Prepare datas & select mode */
10631 - iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
10633 - case I2C_SMBUS_QUICK:
10636 - iface->cur_mode |= KW_I2C_MODE_STANDARD;
10638 - case I2C_SMBUS_BYTE:
10640 - buffer = &data->byte;
10641 - iface->cur_mode |= KW_I2C_MODE_STANDARD;
10643 - case I2C_SMBUS_BYTE_DATA:
10645 - buffer = &data->byte;
10646 - iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10648 - case I2C_SMBUS_WORD_DATA:
10650 - cur_word = cpu_to_le16(data->word);
10651 - buffer = (u8 *)&cur_word;
10652 - iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10654 - case I2C_SMBUS_BLOCK_DATA:
10655 - len = data->block[0];
10656 - buffer = &data->block[1];
10657 - iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10663 - /* Original driver had this limitation */
10667 - down(&iface->sem);
10669 - DBG("chan: %d, addr: 0x%x, transfer len: %d, read: %d\n",
10670 - chan->chan_no, addr, len, read_write == I2C_SMBUS_READ);
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;
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);
10684 - /* Set up address and r/w bit */
10685 - write_reg(reg_addr,
10686 - (addr << 1) | ((read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
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);
10693 - /* Arm timeout */
10694 - mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
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);
10700 - /* Wait interrupt operations completion */
10701 - wait_for_completion(&iface->complete);
10703 - rc = iface->result;
10704 - DBG("transfer done, result: %d\n", rc);
10706 - if (rc == 0 && size == I2C_SMBUS_WORD_DATA && read_write == I2C_SMBUS_READ)
10707 - data->word = le16_to_cpu(cur_word);
10709 - /* Release sem */
10716 - * Generic i2c master transfer entrypoint
10719 -keywest_xfer( struct i2c_adapter *adap,
10720 - struct i2c_msg msgs[],
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;
10729 - down(&iface->sem);
10731 - /* Set adapter to standard mode */
10732 - iface->cur_mode &= ~KW_I2C_MODE_MODE_MASK;
10733 - iface->cur_mode |= KW_I2C_MODE_STANDARD;
10736 - for (i = 0; rc >= 0 && i < num;) {
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");
10746 - DBG("xfer: chan: %d, doing %s %d bytes to 0x%02x - %d of %d messages\n",
10748 - pmsg->flags & I2C_M_RD ? "read" : "write",
10749 - pmsg->len, addr, i, num);
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);
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;
10764 - iface->read_write = I2C_SMBUS_WRITE;
10766 - /* Set up address and r/w bit */
10767 - if (pmsg->flags & I2C_M_REV_DIR_ADDR)
10769 - write_reg(reg_addr,
10771 - ((iface->read_write == I2C_SMBUS_READ) ? 0x01 : 0x00));
10773 - /* Arm timeout */
10774 - mod_timer(&iface->timeout_timer, jiffies + POLL_TIMEOUT);
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);
10780 - /* Wait interrupt operations completion */
10781 - wait_for_completion(&iface->complete);
10783 - rc = iface->result;
10786 - DBG("transfer done, result: %d\n", rc);
10789 - /* Release sem */
10792 - return completed;
10796 -keywest_func(struct i2c_adapter * adapter)
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;
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,
10814 -create_iface(struct device_node *np, struct device *dev)
10816 - unsigned long steps, *psteps, *prate;
10817 - unsigned bsteps, tsize, i, nchan, addroffset;
10818 - struct keywest_iface* iface;
10821 - psteps = (unsigned long *)get_property(np, "AAPL,address-step", NULL);
10822 - steps = psteps ? (*psteps) : 0x10;
10824 - /* Hrm... maybe we can be smarter here */
10825 - for (bsteps = 0; (steps & 0x01) == 0; bsteps++)
10828 - if (!strcmp(np->parent->name, "uni-n")) {
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");
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");
10861 - init_timer(&iface->timeout_timer);
10862 - iface->timeout_timer.function = keywest_timeout;
10863 - iface->timeout_timer.data = (unsigned long)iface;
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) {
10870 - iface->cur_mode = KW_I2C_MODE_100KHZ;
10873 - iface->cur_mode = KW_I2C_MODE_50KHZ;
10876 - iface->cur_mode = KW_I2C_MODE_25KHZ;
10879 - printk(KERN_WARNING "i2c-keywest: unknown rate %ldKhz, using 100KHz\n",
10883 - /* Select standard sub mode */
10884 - iface->cur_mode |= KW_I2C_MODE_STANDARDSUB;
10887 - write_reg(reg_mode, iface->cur_mode);
10889 - /* Switch interrupts off & clear them*/
10890 - write_reg(reg_ier, 0x00);
10891 - write_reg(reg_isr, KW_I2C_IRQ_MASK);
10893 - /* Request chip interrupt */
10894 - rc = request_irq(iface->irq, keywest_irq, 0, "keywest i2c", iface);
10896 - printk(KERN_ERR "i2c-keywest: can't get IRQ %d !\n", iface->irq);
10897 - iounmap((void *)iface->base);
10902 - dev_set_drvdata(dev, iface);
10904 - for (i=0; i<nchan; i++) {
10905 - struct keywest_chan* chan = &iface->channels[i];
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;
10919 - rc = i2c_add_adapter(&chan->adapter);
10921 - printk("i2c-keywest.c: Adapter %s registration failed\n",
10922 - chan->adapter.name);
10923 - i2c_set_adapdata(&chan->adapter, NULL);
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);
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);
10943 -dispose_iface(struct device *dev)
10945 - struct keywest_iface *iface = dev_get_drvdata(dev);
10948 - /* Make sure we stop all activity */
10949 - down(&iface->sem);
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);
10958 - iface->state = state_dead;
10959 - spin_unlock_irq(&iface->lock);
10960 - free_irq(iface->irq, iface);
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)
10968 - rc = i2c_del_adapter(&chan->adapter);
10969 - i2c_set_adapdata(&chan->adapter, NULL);
10970 - /* We aren't that prepared to deal with this... */
10972 - printk("i2c-keywest.c: i2c_del_adapter failed, that's bad !\n");
10974 - iounmap((void *)iface->base);
10975 - dev_set_drvdata(dev, NULL);
10982 -create_iface_macio(struct macio_dev* dev, const struct of_match *match)
10984 - return create_iface(dev->ofdev.node, &dev->ofdev.dev);
10988 -dispose_iface_macio(struct macio_dev* dev)
10990 - return dispose_iface(&dev->ofdev.dev);
10994 -create_iface_of_platform(struct of_device* dev, const struct of_match *match)
10996 - return create_iface(dev->node, &dev->dev);
11000 -dispose_iface_of_platform(struct of_device* dev)
11002 - return dispose_iface(&dev->dev);
11005 -static struct of_match i2c_keywest_match[] =
11008 - .name = OF_ANY_MATCH,
11010 - .compatible = "keywest"
11015 -static struct macio_driver i2c_keywest_macio_driver =
11017 - .name = "i2c-keywest",
11018 - .match_table = i2c_keywest_match,
11019 - .probe = create_iface_macio,
11020 - .remove = dispose_iface_macio
11023 -static struct of_platform_driver i2c_keywest_of_platform_driver =
11025 - .name = "i2c-keywest",
11026 - .match_table = i2c_keywest_match,
11027 - .probe = create_iface_of_platform,
11028 - .remove = dispose_iface_of_platform
11032 -i2c_keywest_init(void)
11034 - macio_register_driver(&i2c_keywest_macio_driver);
11035 - of_register_driver(&i2c_keywest_of_platform_driver);
11040 -static void __exit
11041 -i2c_keywest_cleanup(void)
11043 - macio_unregister_driver(&i2c_keywest_macio_driver);
11044 - of_unregister_driver(&i2c_keywest_of_platform_driver);
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
11053 -#ifndef __I2C_KEYWEST_H__
11054 -#define __I2C_KEYWEST_H__
11056 -/* The Tumbler audio equalizer can be really slow sometimes */
11057 -#define POLL_TIMEOUT (2*HZ)
11059 -/* Register indices */
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
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
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
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
11103 -/* Physical interface */
11104 -struct keywest_iface
11106 - unsigned long base;
11109 - struct semaphore sem;
11111 - struct keywest_chan* channels;
11112 - unsigned chan_count;
11116 - unsigned datalen;
11120 - struct timer_list timeout_timer;
11121 - struct completion complete;
11133 -/* Channel on an interface */
11134 -struct keywest_chan
11136 - struct i2c_adapter adapter;
11137 - struct keywest_iface* iface;
11138 - unsigned chan_no;
11141 -/* Register access */
11143 -static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
11145 - return in_8(((volatile u8 *)iface->base)
11146 - + (((unsigned)reg) << iface->bsteps));
11149 -static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
11151 - out_8(((volatile u8 *)iface->base)
11152 - + (((unsigned)reg) << iface->bsteps), val);
11153 - (void)__read_reg(iface, reg);
11157 -#define write_reg(reg, val) __write_reg(iface, reg, val)
11158 -#define read_reg(reg) __read_reg(iface, reg)
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
11167 -/* ------------------------------------------------------------------------- */
11168 -/* i2c-philips-par.c i2c-hw access for philips style parallel port adapters */
11169 -/* ------------------------------------------------------------------------- */
11170 -/* Copyright (C) 1995-2000 Simon G. Vogl
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.
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.
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 -/* ------------------------------------------------------------------------- */
11187 -/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
11188 - Frodo Looijaard <frodol@dds.nl> */
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>
11205 - struct pardevice *pdev;
11206 - struct i2c_adapter adapter;
11207 - struct i2c_algo_bit_data bit_lp_data;
11208 - struct i2c_par *next;
11211 -static struct i2c_par *adapter_list;
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 */
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 */
11226 -#define I2C_SDAIN 0x80 /* 11 stat Y busy */
11227 -#define I2C_SCLIN 0x08 /* 15 stat Y enable */
11229 -#define I2C_DMASK 0x7f
11230 -#define I2C_CMASK 0xf7
11232 -/* ----- local functions ---------------------------------------------- */
11234 -static void bit_lp_setscl(void *data, int state)
11236 - /*be cautious about state of the control register -
11237 - touch only the one bit needed*/
11239 - parport_write_control((struct parport *) data,
11240 - parport_read_control((struct parport *) data)|I2C_SCL);
11242 - parport_write_control((struct parport *) data,
11243 - parport_read_control((struct parport *) data)&I2C_CMASK);
11247 -static void bit_lp_setsda(void *data, int state)
11250 - parport_write_data((struct parport *) data, I2C_DMASK);
11252 - parport_write_data((struct parport *) data, I2C_SDA);
11256 -static int bit_lp_getscl(void *data)
11258 - return parport_read_status((struct parport *) data) & I2C_SCLIN;
11261 -static int bit_lp_getsda(void *data)
11263 - return parport_read_status((struct parport *) data) & I2C_SDAIN;
11266 -static void bit_lp_setscl2(void *data, int state)
11269 - parport_write_data((struct parport *) data,
11270 - parport_read_data((struct parport *) data)|0x1);
11272 - parport_write_data((struct parport *) data,
11273 - parport_read_data((struct parport *) data)&0xfe);
11277 -static void bit_lp_setsda2(void *data, int state)
11280 - parport_write_data((struct parport *) data,
11281 - parport_read_data((struct parport *) data)|0x2);
11283 - parport_write_data((struct parport *) data,
11284 - parport_read_data((struct parport *) data)&0xfd);
11288 -static int bit_lp_getsda2(void *data)
11290 - return (parport_read_status((struct parport *) data) &
11291 - PARPORT_STATUS_BUSY) ? 0 : 1;
11294 -/* ------------------------------------------------------------------------
11295 - * Encapsulate the above functions in the correct operations structure.
11296 - * This is only done when more than one hardware adapter is supported.
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,
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,
11318 -static struct i2c_adapter bit_lp_ops = {
11319 - .owner = THIS_MODULE,
11320 - .id = I2C_HW_B_LP,
11321 - .name = "Philips Parallel port adapter",
11324 -static void i2c_parport_attach (struct parport *port)
11326 - struct i2c_par *adapter = kmalloc(sizeof(struct i2c_par),
11329 - printk(KERN_ERR "i2c-philips-par: Unable to malloc.\n");
11333 - printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name);
11335 - adapter->pdev = parport_register_device(port, "i2c-philips-par",
11336 - NULL, NULL, NULL,
11337 - PARPORT_FLAG_EXCL,
11339 - if (!adapter->pdev) {
11340 - printk(KERN_ERR "i2c-philips-par: Unable to register with parport.\n");
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;
11350 - if (parport_claim_or_block(adapter->pdev) < 0 ) {
11351 - printk(KERN_ERR "i2c-philips-par: Could not claim parallel port.\n");
11355 - /* reset hardware to sane state */
11356 - bit_lp_setsda(port, 1);
11357 - bit_lp_setscl(port, 1);
11358 - parport_release(adapter->pdev);
11360 - if (i2c_bit_add_bus(&adapter->adapter) < 0)
11362 - printk(KERN_ERR "i2c-philips-par: Unable to register with I2C.\n");
11363 - parport_unregister_device(adapter->pdev);
11365 - return; /* No good */
11368 - adapter->next = adapter_list;
11369 - adapter_list = adapter;
11372 -static void i2c_parport_detach (struct parport *port)
11374 - struct i2c_par *adapter, *prev = NULL;
11376 - for (adapter = adapter_list; adapter; adapter = adapter->next)
11378 - if (adapter->pdev->port == port)
11380 - parport_unregister_device(adapter->pdev);
11381 - i2c_bit_del_bus(&adapter->adapter);
11383 - prev->next = adapter->next;
11385 - adapter_list = adapter->next;
11394 -static struct parport_driver i2c_driver = {
11395 - "i2c-philips-par",
11396 - i2c_parport_attach,
11397 - i2c_parport_detach,
11401 -int __init i2c_bitlp_init(void)
11403 - printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
11405 - parport_register_driver(&i2c_driver);
11410 -void __exit i2c_bitlp_exit(void)
11412 - parport_unregister_driver(&i2c_driver);
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");
11419 -MODULE_PARM(type, "i");
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
11428 - * kernel/busses/i2c-prosavage.c
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>
11440 - * Please read the lm_sensors documentation for details on use.
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.
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.
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.
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
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.
11467 - * Graphics cores:
11468 - * S3/VIA KM266/VT8375 aka ProSavage8
11469 - * S3/VIA KM133/VT8365 aka Savage4
11471 - * Two serial busses are implemented:
11472 - * SERIAL1 - I2C serial communications interface
11473 - * SERIAL2 - DDC2 monitor communications interface
11475 - * Tested on a FX41 mainboard, see http://www.shuttle.com
11479 - * - integration with prosavage framebuffer device
11480 - * (Additional documentation needed :(
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>
11490 -#include <asm/io.h>
11494 - * driver configuration
11496 -#define DRIVER_ID "i2c-prosavage"
11497 -#define DRIVER_VERSION "20030621"
11499 -#define ADAPTER_NAME(x) (x).name
11501 -#define MAX_BUSSES 2
11503 -struct s_i2c_bus {
11507 - struct i2c_adapter adap;
11508 - struct i2c_algo_bit_data algo;
11511 -struct s_i2c_chip {
11513 - struct s_i2c_bus i2c_bus[MAX_BUSSES];
11518 - * i2c configuration
11520 -#ifndef I2C_HW_B_S3VIA
11521 -#define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */
11525 -#define CYCLE_DELAY 10
11526 -#define TIMEOUT (HZ / 2)
11530 - * S3/VIA 8365/8375 registers
11532 -#ifndef PCI_VENDOR_ID_S3
11533 -#define PCI_VENDOR_ID_S3 0x5333
11535 -#ifndef PCI_DEVICE_ID_S3_SAVAGE4
11536 -#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25
11538 -#ifndef PCI_DEVICE_ID_S3_PROSAVAGE8
11539 -#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04
11542 -#define VGA_CR_IX 0x3d4
11543 -#define VGA_CR_DATA 0x3d5
11545 -#define CR_SERIAL1 0xa0 /* I2C serial communications interface */
11546 -#define MM_SERIAL1 0xff20
11547 -#define CR_SERIAL2 0xb1 /* DDC2 monitor communications interface */
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
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)
11562 - * Serial bus line handling
11564 - * serial communications register as parameter in private data
11566 - * TODO: locks with other code sections accessing video registers?
11568 -static void bit_s3via_setscl(void *bus, int val)
11570 - struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11573 - SET_CR_IX(p, p->i2c_reg);
11574 - r = GET_CR_DATA(p);
11577 - r |= I2C_SCL_OUT;
11579 - r &= ~I2C_SCL_OUT;
11581 - SET_CR_DATA(p, r);
11584 -static void bit_s3via_setsda(void *bus, int val)
11586 - struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11589 - SET_CR_IX(p, p->i2c_reg);
11590 - r = GET_CR_DATA(p);
11593 - r |= I2C_SDA_OUT;
11595 - r &= ~I2C_SDA_OUT;
11597 - SET_CR_DATA(p, r);
11600 -static int bit_s3via_getscl(void *bus)
11602 - struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11604 - SET_CR_IX(p, p->i2c_reg);
11605 - return (0 != (GET_CR_DATA(p) & I2C_SCL_IN));
11608 -static int bit_s3via_getsda(void *bus)
11610 - struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
11612 - SET_CR_IX(p, p->i2c_reg);
11613 - return (0 != (GET_CR_DATA(p) & I2C_SDA_IN));
11618 - * adapter initialisation
11620 -static int i2c_register_bus(struct s_i2c_bus *p, u8 *mmvga, u32 i2c_reg)
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;
11637 - ret = i2c_bit_add_bus(&p->adap);
11650 -static void __devexit prosavage_remove(struct pci_dev *dev)
11652 - struct s_i2c_chip *chip;
11655 - chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
11660 - for (i = MAX_BUSSES - 1; i >= 0; i--) {
11661 - if (chip->i2c_bus[i].adap_ok == 0)
11664 - ret = i2c_bit_del_bus(&chip->i2c_bus[i].adap);
11666 - printk(DRIVER_ID ": %s not removed\n",
11667 - ADAPTER_NAME(chip->i2c_bus[i].adap));
11670 - if (chip->mmio) {
11671 - iounmap(chip->mmio);
11678 - * Detect chip and initialize it
11680 -static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_device_id *id)
11683 - unsigned long base, len;
11684 - struct s_i2c_chip *chip;
11685 - struct s_i2c_bus *bus;
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) {
11693 - memset(chip, 0, sizeof(struct s_i2c_chip));
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);
11699 - if (chip->mmio == NULL) {
11700 - printk (DRIVER_ID ": ioremap failed\n");
11701 - prosavage_remove(dev);
11707 - * Chip initialisation
11709 - /* Unlock Extended IO Space ??? */
11713 - * i2c bus registration
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);
11724 - * ddc bus registration
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);
11736 - printk (DRIVER_ID ": %s failed\n", ADAPTER_NAME(bus->adap));
11737 - prosavage_remove(dev);
11743 - * Data for PCI driver interface
11745 -static struct pci_device_id prosavage_pci_tbl[] = {
11747 - .vendor = PCI_VENDOR_ID_S3,
11748 - .device = PCI_DEVICE_ID_S3_SAVAGE4,
11749 - .subvendor = PCI_ANY_ID,
11750 - .subdevice = PCI_ANY_ID,
11752 - .vendor = PCI_VENDOR_ID_S3,
11753 - .device = PCI_DEVICE_ID_S3_PROSAVAGE8,
11754 - .subvendor = PCI_ANY_ID,
11755 - .subdevice = PCI_ANY_ID,
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),
11766 -static int __init i2c_prosavage_init(void)
11768 - printk(DRIVER_ID " version %s (%s)\n", I2C_VERSION, DRIVER_VERSION);
11769 - return pci_module_init(&prosavage_driver);
11772 -static void __exit i2c_prosavage_exit(void)
11774 - pci_unregister_driver(&prosavage_driver);
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");
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
11789 - * Embedded Planet RPX Lite MPC8xx CPM I2C interface.
11790 - * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
11792 - * moved into proper i2c interface;
11793 - * Brad Parker (brad@heeltoe.com)
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.
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>
11814 -rpx_iic_init(struct i2c_algo_8xx_data *data)
11816 - volatile cpm8xx_t *cp;
11817 - volatile immap_t *immap;
11819 - cp = cpmp; /* Get pointer to Communication Processor */
11820 - immap = (immap_t *)IMAP_ADDR; /* and to internal registers */
11822 - data->iip = (iic_t *)&cp->cp_dparam[PROFF_IIC];
11824 - /* Check for and use a microcode relocation patch.
11826 - if ((data->reloc = data->iip->iic_rpbase))
11827 - data->iip = (iic_t *)&cp->cp_dpmem[data->iip->iic_rpbase];
11829 - data->i2c = (i2c8xx_t *)&(immap->im_i2c);
11832 - /* Initialize Port B IIC pins.
11834 - cp->cp_pbpar |= 0x00000030;
11835 - cp->cp_pbdir |= 0x00000030;
11836 - cp->cp_pbodr |= 0x00000030;
11838 - /* Allocate space for two transmit and two receive buffer
11839 - * descriptors in the DP ram.
11841 - data->dp_addr = m8xx_cpm_dpalloc(sizeof(cbd_t) * 4);
11843 - /* ptr to i2c area */
11844 - data->i2c = (i2c8xx_t *)&(((immap_t *)IMAP_ADDR)->im_i2c);
11847 -static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data)
11849 - /* install interrupt handler */
11850 - cpm_install_handler(irq, (void (*)(void *, struct pt_regs *)) func, data);
11855 -static struct i2c_algo_8xx_data rpx_data = {
11856 - .setisr = rpx_install_isr
11859 -static struct i2c_adapter rpx_ops = {
11860 - .owner = THIS_MODULE,
11862 - .id = I2C_HW_MPC8XX_EPON,
11863 - .algo_data = &rpx_data,
11866 -int __init i2c_rpx_init(void)
11868 - printk("i2c-rpx.o: i2c MPC8xx module version %s (%s)\n", I2C_VERSION, I2C_DATE);
11870 - /* reset hardware to sane state */
11871 - rpx_iic_init(&rpx_data);
11873 - if (i2c_8xx_add_bus(&rpx_ops) < 0) {
11874 - printk("i2c-rpx: Unable to register with I2C\n");
11881 -void __exit i2c_rpx_exit(void)
11883 - i2c_8xx_del_bus(&rpx_ops);
11886 -MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>");
11887 -MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards");
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
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)))
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
11910 -/* ------------------------------------------------------------------------- */
11911 -/* i2c-velleman.c i2c-hw access for Velleman K9000 adapters */
11912 -/* ------------------------------------------------------------------------- */
11913 -/* Copyright (C) 1995-96, 2000 Simon G. Vogl
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.
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.
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 -/* ------------------------------------------------------------------------- */
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>
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 */
11946 - /* Pin Port Inverted name */
11947 -#define I2C_SDA 0x02 /* ctrl bit 1 (inv) */
11948 -#define I2C_SCL 0x08 /* ctrl bit 3 (inv) */
11950 -#define I2C_SDAIN 0x10 /* stat bit 4 */
11951 -#define I2C_SCLIN 0x08 /* ctrl bit 3 (inv)(reads own output)*/
11953 -#define I2C_DMASK 0xfd
11954 -#define I2C_CMASK 0xf7
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 */
11963 -#define DEFAULT_BASE 0x378
11964 -static int base=0;
11966 -/* ----- local functions --------------------------------------------------- */
11968 -static void bit_velle_setscl(void *data, int state)
11971 - outb(inb(CTRL) & I2C_CMASK, CTRL);
11973 - outb(inb(CTRL) | I2C_SCL, CTRL);
11978 -static void bit_velle_setsda(void *data, int state)
11981 - outb(inb(CTRL) & I2C_DMASK , CTRL);
11983 - outb(inb(CTRL) | I2C_SDA, CTRL);
11988 -static int bit_velle_getscl(void *data)
11990 - return ( 0 == ( (inb(CTRL)) & I2C_SCLIN ) );
11993 -static int bit_velle_getsda(void *data)
11995 - return ( 0 != ( (inb(STAT)) & I2C_SDAIN ) );
11998 -static int bit_velle_init(void)
12000 - if (!request_region(base, (base == 0x3bc) ? 3 : 8,
12001 - "i2c (Vellemann adapter)"))
12004 - bit_velle_setsda((void*)base,1);
12005 - bit_velle_setscl((void*)base,1);
12009 -/* ------------------------------------------------------------------------
12010 - * Encapsulate the above functions in the correct operations structure.
12011 - * This is only done when more than one hardware adapter is supported.
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,
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",
12031 -static int __init i2c_bitvelle_init(void)
12033 - printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
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)
12045 - bit_velle_data.data=(void*)base;
12046 - if (bit_velle_init()==0) {
12047 - if(i2c_bit_add_bus(&bit_velle_ops) < 0)
12053 - printk(KERN_DEBUG "i2c-velleman.o: found device at %#x.\n",base);
12057 -static void __exit i2c_bitvelle_exit(void)
12059 - i2c_bit_del_bus(&bit_velle_ops);
12060 - release_region(base, (base == 0x3bc) ? 3 : 8);
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");
12067 -MODULE_PARM(base, "i");
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
12075 -/* linux/drivers/i2c/scx200_acb.c
12077 - Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
12079 - National Semiconductor SCx200 ACCESS.bus support
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>
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.
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.
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.
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>
12111 -#include <linux/scx200.h>
12113 -#define NAME "scx200_acb"
12115 -MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
12116 -MODULE_DESCRIPTION("NatSemi SCx200 ACCESS.bus Driver");
12117 -MODULE_LICENSE("GPL");
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");
12127 -#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
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)
12137 -enum scx200_acb_state {
12141 - state_repeat_start,
12147 -static const char *scx200_acb_state_name[] = {
12157 -/* Physical interface */
12158 -struct scx200_acb_iface
12160 - struct scx200_acb_iface *next;
12161 - struct i2c_adapter adapter;
12163 - struct semaphore sem;
12165 - /* State machine data */
12166 - enum scx200_acb_state state;
12171 - char needs_reset;
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
12195 -/************************************************************************/
12197 -static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
12199 - const char *errmsg;
12201 - DBG("state %s, status = 0x%02x\n",
12202 - scx200_acb_state_name[iface->state], status);
12204 - if (status & ACBST_BER) {
12205 - errmsg = "bus error";
12208 - if (!(status & ACBST_MASTER)) {
12209 - errmsg = "not master";
12212 - if (status & ACBST_NEGACK)
12215 - switch (iface->state) {
12217 - dev_warn(&iface->adapter.dev, "interrupt in idle state\n");
12220 - case state_address:
12221 - /* Do a pointer write first */
12222 - outb(iface->address_byte & ~1, ACBSDA);
12224 - iface->state = state_command;
12227 - case state_command:
12228 - outb(iface->command, ACBSDA);
12230 - if (iface->address_byte & 1)
12231 - iface->state = state_repeat_start;
12233 - iface->state = state_write;
12236 - case state_repeat_start:
12237 - outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
12238 - /* fallthrough */
12240 - case state_quick:
12241 - if (iface->address_byte & 1) {
12242 - if (iface->len == 1)
12243 - outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
12245 - outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
12246 - outb(iface->address_byte, ACBSDA);
12248 - iface->state = state_read;
12250 - outb(iface->address_byte, ACBSDA);
12252 - iface->state = state_write;
12257 - /* Set ACK if receiving the last byte */
12258 - if (iface->len == 1)
12259 - outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
12261 - outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
12263 - *iface->ptr++ = inb(ACBSDA);
12266 - if (iface->len == 0) {
12267 - iface->result = 0;
12268 - iface->state = state_idle;
12269 - outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
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);
12282 - outb(*iface->ptr++, ACBSDA);
12291 - DBG("negative acknowledge in state %s\n",
12292 - scx200_acb_state_name[iface->state]);
12294 - iface->state = state_idle;
12295 - iface->result = -ENXIO;
12297 - outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
12298 - outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
12302 - dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
12303 - scx200_acb_state_name[iface->state]);
12305 - iface->state = state_idle;
12306 - iface->result = -EIO;
12307 - iface->needs_reset = 1;
12310 -static void scx200_acb_timeout(struct scx200_acb_iface *iface)
12312 - dev_err(&iface->adapter.dev, "timeout in state %s\n",
12313 - scx200_acb_state_name[iface->state]);
12315 - iface->state = state_idle;
12316 - iface->result = -EIO;
12317 - iface->needs_reset = 1;
12320 -#ifdef POLLED_MODE
12321 -static void scx200_acb_poll(struct scx200_acb_iface *iface)
12324 - unsigned long timeout;
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);
12333 - schedule_timeout(HZ/100+1);
12336 - scx200_acb_timeout(iface);
12338 -#endif /* POLLED_MODE */
12340 -static void scx200_acb_reset(struct scx200_acb_iface *iface)
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);
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)
12366 - struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
12373 - case I2C_SMBUS_QUICK:
12377 - case I2C_SMBUS_BYTE:
12378 - if (rw == I2C_SMBUS_READ) {
12380 - buffer = &data->byte;
12383 - buffer = &command;
12386 - case I2C_SMBUS_BYTE_DATA:
12388 - buffer = &data->byte;
12390 - case I2C_SMBUS_WORD_DATA:
12392 - cur_word = cpu_to_le16(data->word);
12393 - buffer = (u8 *)&cur_word;
12395 - case I2C_SMBUS_BLOCK_DATA:
12396 - len = data->block[0];
12397 - buffer = &data->block[1];
12403 - DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
12404 - size, address, command, len, rw == I2C_SMBUS_READ);
12406 - if (!len && rw == I2C_SMBUS_READ) {
12407 - dev_warn(&adapter->dev, "zero length read\n");
12411 - if (len && !buffer) {
12412 - dev_warn(&adapter->dev, "nonzero length but no buffer\n");
12416 - down(&iface->sem);
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;
12427 - outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
12429 - if (size == I2C_SMBUS_QUICK || size == I2C_SMBUS_BYTE)
12430 - iface->state = state_quick;
12432 - iface->state = state_address;
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 */
12441 - if (iface->needs_reset)
12442 - scx200_acb_reset(iface);
12444 - rc = iface->result;
12448 - if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
12449 - data->word = le16_to_cpu(cur_word);
12452 - printk(KERN_DEBUG NAME ": transfer done, result: %d", rc);
12455 - printk(" data:");
12456 - for (i = 0; i < len; ++i)
12457 - printk(" %02x", buffer[i]);
12465 -static u32 scx200_acb_func(struct i2c_adapter *adapter)
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;
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,
12480 -struct scx200_acb_iface *scx200_acb_list;
12482 -int scx200_acb_probe(struct scx200_acb_iface *iface)
12486 - /* Disable the ACCESS.bus device and Configure the SCL
12487 - frequency: 16 clock cycles */
12488 - outb(0x70, ACBCTL2);
12490 - if (inb(ACBCTL2) != 0x70) {
12491 - DBG("ACBCTL2 readback failed\n");
12495 - outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
12497 - val = inb(ACBCTL1);
12499 - DBG("disabled, but ACBCTL1=0x%02x\n", val);
12503 - outb(inb(ACBCTL2) | ACBCTL2_ENABLE, ACBCTL2);
12505 - outb(inb(ACBCTL1) | ACBCTL1_NMINTE, ACBCTL1);
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);
12516 -static int __init scx200_acb_create(int base, int index)
12518 - struct scx200_acb_iface *iface;
12519 - struct i2c_adapter *adapter;
12521 - char description[64];
12523 - iface = kmalloc(sizeof(*iface), GFP_KERNEL);
12525 - printk(KERN_ERR NAME ": can't allocate memory\n");
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;
12538 - init_MUTEX(&iface->sem);
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);
12547 - iface->base = base;
12549 - rc = scx200_acb_probe(iface);
12551 - dev_warn(&adapter->dev, "probe failed\n");
12555 - scx200_acb_reset(iface);
12557 - if (i2c_add_adapter(adapter) < 0) {
12558 - dev_err(&adapter->dev, "failed to register\n");
12564 - iface->next = scx200_acb_list;
12565 - scx200_acb_list = iface;
12573 - release_region(iface->base, 8);
12579 -static int __init scx200_acb_init(void)
12584 - printk(KERN_DEBUG NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
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,
12593 - for (i = 0; i < MAX_DEVICES; ++i) {
12595 - rc = scx200_acb_create(base[i], i);
12597 - if (scx200_acb_list)
12602 -static void __exit scx200_acb_cleanup(void)
12604 - struct scx200_acb_iface *iface;
12606 - while ((iface = scx200_acb_list) != NULL) {
12607 - scx200_acb_list = iface->next;
12610 - i2c_del_adapter(&iface->adapter);
12611 - release_region(iface->base, 8);
12618 -module_init(scx200_acb_init);
12619 -module_exit(scx200_acb_cleanup);
12623 - compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
12624 - c-basic-offset: 8
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
12632 -/* linux/drivers/i2c/scx200_i2c.c
12634 - Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
12636 - National Semiconductor SCx200 I2C bus on GPIO pins
12638 - Based on i2c-velleman.c Copyright (C) 1995-96, 2000 Simon G. Vogl
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.
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.
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.
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>
12664 -#include <linux/scx200_gpio.h>
12666 -#define NAME "scx200_i2c"
12668 -MODULE_AUTHOR("Christer Weinigel <wingel@nano-system.com>");
12669 -MODULE_DESCRIPTION("NatSemi SCx200 I2C Driver");
12670 -MODULE_LICENSE("GPL");
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");
12677 -static int scl = CONFIG_SCx200_I2C_SCL;
12678 -static int sda = CONFIG_SCx200_I2C_SDA;
12680 -static void scx200_i2c_setscl(void *data, int state)
12682 - scx200_gpio_set(scl, state);
12685 -static void scx200_i2c_setsda(void *data, int state)
12687 - scx200_gpio_set(sda, state);
12690 -static int scx200_i2c_getscl(void *data)
12692 - return scx200_gpio_get(scl);
12695 -static int scx200_i2c_getsda(void *data)
12697 - return scx200_gpio_get(sda);
12700 -/* ------------------------------------------------------------------------
12701 - * Encapsulate the above functions in the correct operations structure.
12702 - * This is only done when more than one hardware adapter is supported.
12705 -static struct i2c_algo_bit_data scx200_i2c_data = {
12707 - scx200_i2c_setsda,
12708 - scx200_i2c_setscl,
12709 - scx200_i2c_getsda,
12710 - scx200_i2c_getscl,
12711 - 10, 10, 100, /* waits, timeout */
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",
12721 -int scx200_i2c_init(void)
12723 - printk(KERN_DEBUG NAME ": NatSemi SCx200 I2C Driver\n");
12725 - if (!scx200_gpio_present()) {
12726 - printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");
12730 - printk(KERN_DEBUG NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n",
12733 - if (scl == -1 || sda == -1 || scl == sda) {
12734 - printk(KERN_ERR NAME ": scl and sda must be specified\n");
12738 - /* Configure GPIOs as open collector outputs */
12739 - scx200_gpio_configure(scl, ~2, 5);
12740 - scx200_gpio_configure(sda, ~2, 5);
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);
12751 -void scx200_i2c_cleanup(void)
12753 - i2c_bit_del_bus(&scx200_i2c_ops);
12756 -module_init(scx200_i2c_init);
12757 -module_exit(scx200_i2c_cleanup);
12761 - compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
12762 - c-basic-offset: 8
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;
12771 hwif->rqsize = 128;
12772 -// if (is_sata(hwif))
12773 -// hwif->rqsize = 15;
12774 + if (is_sata(hwif))
12775 + hwif->rqsize = 15;
12777 if (pci_get_drvdata(dev) == NULL)
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 */
12787 +#define I2C_DRIVERID_RADEON 55 /* I2C bus on Radeon boards */
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
12795 #ifndef _LINUX_I2C_H
12796 #define _LINUX_I2C_H
12798 -#define I2C_DATE "20021208"
12799 -#define I2C_VERSION "2.7.0"
12801 #include <linux/module.h>
12802 #include <linux/types.h>
12803 #include <linux/i2c-id.h>
12804 @@ -146,6 +143,8 @@
12806 extern struct bus_type i2c_bus_type;
12808 +#define I2C_NAME_SIZE 50
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;
12821 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
12822 @@ -253,7 +252,7 @@
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;