aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-11 20:09:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-11 20:09:24 -0400
commit57014123512633ab0c38a4fea4140bf156f6a3a0 (patch)
treea46e864f9c508d8228e79928519742af6a42b7e4
parentc3921ab71507b108d51a0f1ee960f80cd668a93d (diff)
parentae429083efe996ca2c569c44fd6fea440676dc33 (diff)
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: i2c: Convert some more new-style drivers to use module aliasing i2c: Match dummy devices by type i2c-sibyte: Mark i2c_sibyte_add_bus() as static i2c-sibyte: Correct a comment about frequency i2c: Improve the functionality documentation i2c: Improve smbus-protocol documentation i2c-piix4: Blacklist two mainboards i2c-piix4: Increase the intitial delay for the ServerWorks CSB5 i2c-mpc: Compare to NO_IRQ instead of zero
-rw-r--r--Documentation/i2c/functionality95
-rw-r--r--Documentation/i2c/smbus-protocol81
-rw-r--r--drivers/i2c/busses/i2c-mpc.c16
-rw-r--r--drivers/i2c/busses/i2c-piix4.c47
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c6
-rw-r--r--drivers/i2c/i2c-core.c14
-rw-r--r--drivers/media/video/tcm825x.c7
-rw-r--r--drivers/media/video/tlv320aic23b.c6
-rw-r--r--drivers/media/video/tvaudio.c13
-rw-r--r--drivers/rtc/rtc-s35390a.c2
-rw-r--r--include/linux/i2c.h2
-rw-r--r--include/media/v4l2-i2c-drv-legacy.h2
-rw-r--r--include/media/v4l2-i2c-drv.h2
13 files changed, 189 insertions, 104 deletions
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index 60cca249e452..42c17c1fb3cd 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -51,26 +51,38 @@ A few combinations of the above flags are also defined for your convenience:
51 the transparent emulation layer) 51 the transparent emulation layer)
52 52
53 53
54ALGORITHM/ADAPTER IMPLEMENTATION 54ADAPTER IMPLEMENTATION
55-------------------------------- 55----------------------
56 56
57When you write a new algorithm driver, you will have to implement a 57When you write a new adapter driver, you will have to implement a
58function callback `functionality', that gets an i2c_adapter structure 58function callback `functionality'. Typical implementations are given
59pointer as its only parameter: 59below.
60 60
61 struct i2c_algorithm { 61A typical SMBus-only adapter would list all the SMBus transactions it
62 /* Many other things of course; check <linux/i2c.h>! */ 62supports. This example comes from the i2c-piix4 driver:
63 u32 (*functionality) (struct i2c_adapter *); 63
64 static u32 piix4_func(struct i2c_adapter *adapter)
65 {
66 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
67 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
68 I2C_FUNC_SMBUS_BLOCK_DATA;
64 } 69 }
65 70
66A typically implementation is given below, from i2c-algo-bit.c: 71A typical full-I2C adapter would use the following (from the i2c-pxa
72driver):
67 73
68 static u32 bit_func(struct i2c_adapter *adap) 74 static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
69 { 75 {
70 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 76 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
71 I2C_FUNC_PROTOCOL_MANGLING;
72 } 77 }
73 78
79I2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the
80addition of I2C block transactions) which i2c-core can emulate using
81I2C_FUNC_I2C without any help from the adapter driver. The idea is
82to let the client drivers check for the support of SMBus functions
83without having to care whether the said functions are implemented in
84hardware by the adapter, or emulated in software by i2c-core on top
85of an I2C adapter.
74 86
75 87
76CLIENT CHECKING 88CLIENT CHECKING
@@ -78,36 +90,33 @@ CLIENT CHECKING
78 90
79Before a client tries to attach to an adapter, or even do tests to check 91Before a client tries to attach to an adapter, or even do tests to check
80whether one of the devices it supports is present on an adapter, it should 92whether one of the devices it supports is present on an adapter, it should
81check whether the needed functionality is present. There are two functions 93check whether the needed functionality is present. The typical way to do
82defined which should be used instead of calling the functionality hook 94this is (from the lm75 driver):
83in the algorithm structure directly:
84
85 /* Return the functionality mask */
86 extern u32 i2c_get_functionality (struct i2c_adapter *adap);
87
88 /* Return 1 if adapter supports everything we need, 0 if not. */
89 extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func);
90 95
91This is a typical way to use these functions (from the writing-clients 96 static int lm75_detect(...)
92document):
93 int foo_detect_client(struct i2c_adapter *adapter, int address,
94 unsigned short flags, int kind)
95 { 97 {
96 /* Define needed variables */ 98 (...)
97 99 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
98 /* As the very first action, we check whether the adapter has the 100 I2C_FUNC_SMBUS_WORD_DATA))
99 needed functionality: we need the SMBus read_word_data, 101 goto exit;
100 write_word_data and write_byte functions in this example. */ 102 (...)
101 if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA |
102 I2C_FUNC_SMBUS_WRITE_BYTE))
103 goto ERROR0;
104
105 /* Now we can do the real detection */
106
107 ERROR0:
108 /* Return an error */
109 } 103 }
110 104
105Here, the lm75 driver checks if the adapter can do both SMBus byte data
106and SMBus word data transactions. If not, then the driver won't work on
107this adapter and there's no point in going on. If the check above is
108successful, then the driver knows that it can call the following
109functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(),
110i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of
111thumb, the functionality constants you test for with
112i2c_check_functionality() should match exactly the i2c_smbus_* functions
113which you driver is calling.
114
115Note that the check above doesn't tell whether the functionalities are
116implemented in hardware by the underlying adapter or emulated in
117software by i2c-core. Client drivers don't have to care about this, as
118i2c-core will transparently implement SMBus transactions on top of I2C
119adapters.
111 120
112 121
113CHECKING THROUGH /DEV 122CHECKING THROUGH /DEV
@@ -116,19 +125,19 @@ CHECKING THROUGH /DEV
116If you try to access an adapter from a userspace program, you will have 125If you try to access an adapter from a userspace program, you will have
117to use the /dev interface. You will still have to check whether the 126to use the /dev interface. You will still have to check whether the
118functionality you need is supported, of course. This is done using 127functionality you need is supported, of course. This is done using
119the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect 128the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is
120program, is below: 129below:
121 130
122 int file; 131 int file;
123 if (file = open("/dev/i2c-0",O_RDWR) < 0) { 132 if (file = open("/dev/i2c-0", O_RDWR) < 0) {
124 /* Some kind of error handling */ 133 /* Some kind of error handling */
125 exit(1); 134 exit(1);
126 } 135 }
127 if (ioctl(file,I2C_FUNCS,&funcs) < 0) { 136 if (ioctl(file, I2C_FUNCS, &funcs) < 0) {
128 /* Some kind of error handling */ 137 /* Some kind of error handling */
129 exit(1); 138 exit(1);
130 } 139 }
131 if (! (funcs & I2C_FUNC_SMBUS_QUICK)) { 140 if (!(funcs & I2C_FUNC_SMBUS_QUICK)) {
132 /* Oops, the needed functionality (SMBus write_quick function) is 141 /* Oops, the needed functionality (SMBus write_quick function) is
133 not available! */ 142 not available! */
134 exit(1); 143 exit(1);
diff --git a/Documentation/i2c/smbus-protocol b/Documentation/i2c/smbus-protocol
index 8a653c60d25a..03f08fb491cc 100644
--- a/Documentation/i2c/smbus-protocol
+++ b/Documentation/i2c/smbus-protocol
@@ -1,5 +1,6 @@
1SMBus Protocol Summary 1SMBus Protocol Summary
2====================== 2======================
3
3The following is a summary of the SMBus protocol. It applies to 4The following is a summary of the SMBus protocol. It applies to
4all revisions of the protocol (1.0, 1.1, and 2.0). 5all revisions of the protocol (1.0, 1.1, and 2.0).
5Certain protocol features which are not supported by 6Certain protocol features which are not supported by
@@ -8,6 +9,7 @@ this package are briefly described at the end of this document.
8Some adapters understand only the SMBus (System Management Bus) protocol, 9Some adapters understand only the SMBus (System Management Bus) protocol,
9which is a subset from the I2C protocol. Fortunately, many devices use 10which is a subset from the I2C protocol. Fortunately, many devices use
10only the same subset, which makes it possible to put them on an SMBus. 11only the same subset, which makes it possible to put them on an SMBus.
12
11If you write a driver for some I2C device, please try to use the SMBus 13If you write a driver for some I2C device, please try to use the SMBus
12commands if at all possible (if the device uses only that subset of the 14commands if at all possible (if the device uses only that subset of the
13I2C protocol). This makes it possible to use the device driver on both 15I2C protocol). This makes it possible to use the device driver on both
@@ -15,7 +17,12 @@ SMBus adapters and I2C adapters (the SMBus command set is automatically
15translated to I2C on I2C adapters, but plain I2C commands can not be 17translated to I2C on I2C adapters, but plain I2C commands can not be
16handled at all on most pure SMBus adapters). 18handled at all on most pure SMBus adapters).
17 19
18Below is a list of SMBus commands. 20Below is a list of SMBus protocol operations, and the functions executing
21them. Note that the names used in the SMBus protocol specifications usually
22don't match these function names. For some of the operations which pass a
23single data byte, the functions using SMBus protocol operation names execute
24a different protocol operation entirely.
25
19 26
20Key to symbols 27Key to symbols
21============== 28==============
@@ -35,17 +42,16 @@ Count (8 bits): A data byte containing the length of a block operation.
35[..]: Data sent by I2C device, as opposed to data sent by the host adapter. 42[..]: Data sent by I2C device, as opposed to data sent by the host adapter.
36 43
37 44
38SMBus Write Quick 45SMBus Quick Command: i2c_smbus_write_quick()
39================= 46=============================================
40 47
41This sends a single bit to the device, at the place of the Rd/Wr bit. 48This sends a single bit to the device, at the place of the Rd/Wr bit.
42There is no equivalent Read Quick command.
43 49
44A Addr Rd/Wr [A] P 50A Addr Rd/Wr [A] P
45 51
46 52
47SMBus Read Byte 53SMBus Receive Byte: i2c_smbus_read_byte()
48=============== 54==========================================
49 55
50This reads a single byte from a device, without specifying a device 56This reads a single byte from a device, without specifying a device
51register. Some devices are so simple that this interface is enough; for 57register. Some devices are so simple that this interface is enough; for
@@ -55,17 +61,17 @@ the previous SMBus command.
55S Addr Rd [A] [Data] NA P 61S Addr Rd [A] [Data] NA P
56 62
57 63
58SMBus Write Byte 64SMBus Send Byte: i2c_smbus_write_byte()
59================ 65========================================
60 66
61This is the reverse of Read Byte: it sends a single byte to a device. 67This operation is the reverse of Receive Byte: it sends a single byte
62See Read Byte for more information. 68to a device. See Receive Byte for more information.
63 69
64S Addr Wr [A] Data [A] P 70S Addr Wr [A] Data [A] P
65 71
66 72
67SMBus Read Byte Data 73SMBus Read Byte: i2c_smbus_read_byte_data()
68==================== 74============================================
69 75
70This reads a single byte from a device, from a designated register. 76This reads a single byte from a device, from a designated register.
71The register is specified through the Comm byte. 77The register is specified through the Comm byte.
@@ -73,30 +79,30 @@ The register is specified through the Comm byte.
73S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P 79S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
74 80
75 81
76SMBus Read Word Data 82SMBus Read Word: i2c_smbus_read_word_data()
77==================== 83============================================
78 84
79This command is very like Read Byte Data; again, data is read from a 85This operation is very like Read Byte; again, data is read from a
80device, from a designated register that is specified through the Comm 86device, from a designated register that is specified through the Comm
81byte. But this time, the data is a complete word (16 bits). 87byte. But this time, the data is a complete word (16 bits).
82 88
83S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P 89S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
84 90
85 91
86SMBus Write Byte Data 92SMBus Write Byte: i2c_smbus_write_byte_data()
87===================== 93==============================================
88 94
89This writes a single byte to a device, to a designated register. The 95This writes a single byte to a device, to a designated register. The
90register is specified through the Comm byte. This is the opposite of 96register is specified through the Comm byte. This is the opposite of
91the Read Byte Data command. 97the Read Byte operation.
92 98
93S Addr Wr [A] Comm [A] Data [A] P 99S Addr Wr [A] Comm [A] Data [A] P
94 100
95 101
96SMBus Write Word Data 102SMBus Write Word: i2c_smbus_write_word_data()
97===================== 103==============================================
98 104
99This is the opposite operation of the Read Word Data command. 16 bits 105This is the opposite of the Read Word operation. 16 bits
100of data is written to a device, to the designated register that is 106of data is written to a device, to the designated register that is
101specified through the Comm byte. 107specified through the Comm byte.
102 108
@@ -113,8 +119,8 @@ S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
113 S Addr Rd [A] [DataLow] A [DataHigh] NA P 119 S Addr Rd [A] [DataLow] A [DataHigh] NA P
114 120
115 121
116SMBus Block Read 122SMBus Block Read: i2c_smbus_read_block_data()
117================ 123==============================================
118 124
119This command reads a block of up to 32 bytes from a device, from a 125This command reads a block of up to 32 bytes from a device, from a
120designated register that is specified through the Comm byte. The amount 126designated register that is specified through the Comm byte. The amount
@@ -124,8 +130,8 @@ S Addr Wr [A] Comm [A]
124 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P 130 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
125 131
126 132
127SMBus Block Write 133SMBus Block Write: i2c_smbus_write_block_data()
128================= 134================================================
129 135
130The opposite of the Block Read command, this writes up to 32 bytes to 136The opposite of the Block Read command, this writes up to 32 bytes to
131a device, to a designated register that is specified through the 137a device, to a designated register that is specified through the
@@ -134,10 +140,11 @@ Comm byte. The amount of data is specified in the Count byte.
134S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P 140S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
135 141
136 142
137SMBus Block Process Call 143SMBus Block Write - Block Read Process Call
138======================== 144===========================================
139 145
140SMBus Block Process Call was introduced in Revision 2.0 of the specification. 146SMBus Block Write - Block Read Process Call was introduced in
147Revision 2.0 of the specification.
141 148
142This command selects a device register (through the Comm byte), sends 149This command selects a device register (through the Comm byte), sends
1431 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. 1501 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.
@@ -159,13 +166,16 @@ alerting device's address.
159 166
160Packet Error Checking (PEC) 167Packet Error Checking (PEC)
161=========================== 168===========================
169
162Packet Error Checking was introduced in Revision 1.1 of the specification. 170Packet Error Checking was introduced in Revision 1.1 of the specification.
163 171
164PEC adds a CRC-8 error-checking byte to all transfers. 172PEC adds a CRC-8 error-checking byte to transfers using it, immediately
173before the terminating STOP.
165 174
166 175
167Address Resolution Protocol (ARP) 176Address Resolution Protocol (ARP)
168================================= 177=================================
178
169The Address Resolution Protocol was introduced in Revision 2.0 of 179The Address Resolution Protocol was introduced in Revision 2.0 of
170the specification. It is a higher-layer protocol which uses the 180the specification. It is a higher-layer protocol which uses the
171messages above. 181messages above.
@@ -177,14 +187,17 @@ require PEC checksums.
177 187
178I2C Block Transactions 188I2C Block Transactions
179====================== 189======================
190
180The following I2C block transactions are supported by the 191The following I2C block transactions are supported by the
181SMBus layer and are described here for completeness. 192SMBus layer and are described here for completeness.
193They are *NOT* defined by the SMBus specification.
194
182I2C block transactions do not limit the number of bytes transferred 195I2C block transactions do not limit the number of bytes transferred
183but the SMBus layer places a limit of 32 bytes. 196but the SMBus layer places a limit of 32 bytes.
184 197
185 198
186I2C Block Read 199I2C Block Read: i2c_smbus_read_i2c_block_data()
187============== 200================================================
188 201
189This command reads a block of bytes from a device, from a 202This command reads a block of bytes from a device, from a
190designated register that is specified through the Comm byte. 203designated register that is specified through the Comm byte.
@@ -203,8 +216,8 @@ S Addr Wr [A] Comm1 [A] Comm2 [A]
203 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 216 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
204 217
205 218
206I2C Block Write 219I2C Block Write: i2c_smbus_write_i2c_block_data()
207=============== 220==================================================
208 221
209The opposite of the Block Read command, this writes bytes to 222The opposite of the Block Read command, this writes bytes to
210a device, to a designated register that is specified through the 223a device, to a designated register that is specified through the
@@ -212,5 +225,3 @@ Comm byte. Note that command lengths of 0, 2, or more bytes are
212supported as they are indistinguishable from data. 225supported as they are indistinguishable from data.
213 226
214S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P 227S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
215
216
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 18beb0ad7bf3..a076129de7e8 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -99,7 +99,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
99 u32 x; 99 u32 x;
100 int result = 0; 100 int result = 0;
101 101
102 if (i2c->irq == 0) 102 if (i2c->irq == NO_IRQ)
103 { 103 {
104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { 104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
105 schedule(); 105 schedule();
@@ -329,10 +329,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
329 return -ENOMEM; 329 return -ENOMEM;
330 330
331 i2c->irq = platform_get_irq(pdev, 0); 331 i2c->irq = platform_get_irq(pdev, 0);
332 if (i2c->irq < 0) { 332 if (i2c->irq < 0)
333 result = -ENXIO; 333 i2c->irq = NO_IRQ; /* Use polling */
334 goto fail_get_irq; 334
335 }
336 i2c->flags = pdata->device_flags; 335 i2c->flags = pdata->device_flags;
337 init_waitqueue_head(&i2c->queue); 336 init_waitqueue_head(&i2c->queue);
338 337
@@ -344,7 +343,7 @@ static int fsl_i2c_probe(struct platform_device *pdev)
344 goto fail_map; 343 goto fail_map;
345 } 344 }
346 345
347 if (i2c->irq != 0) 346 if (i2c->irq != NO_IRQ)
348 if ((result = request_irq(i2c->irq, mpc_i2c_isr, 347 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
349 IRQF_SHARED, "i2c-mpc", i2c)) < 0) { 348 IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
350 printk(KERN_ERR 349 printk(KERN_ERR
@@ -367,12 +366,11 @@ static int fsl_i2c_probe(struct platform_device *pdev)
367 return result; 366 return result;
368 367
369 fail_add: 368 fail_add:
370 if (i2c->irq != 0) 369 if (i2c->irq != NO_IRQ)
371 free_irq(i2c->irq, i2c); 370 free_irq(i2c->irq, i2c);
372 fail_irq: 371 fail_irq:
373 iounmap(i2c->base); 372 iounmap(i2c->base);
374 fail_map: 373 fail_map:
375 fail_get_irq:
376 kfree(i2c); 374 kfree(i2c);
377 return result; 375 return result;
378}; 376};
@@ -384,7 +382,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
384 i2c_del_adapter(&i2c->adap); 382 i2c_del_adapter(&i2c->adap);
385 platform_set_drvdata(pdev, NULL); 383 platform_set_drvdata(pdev, NULL);
386 384
387 if (i2c->irq != 0) 385 if (i2c->irq != NO_IRQ)
388 free_irq(i2c->irq, i2c); 386 free_irq(i2c->irq, i2c);
389 387
390 iounmap(i2c->base); 388 iounmap(i2c->base);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index fdc9ad805e35..ac9165968587 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -104,10 +104,31 @@ MODULE_PARM_DESC(force_addr,
104static int piix4_transaction(void); 104static int piix4_transaction(void);
105 105
106static unsigned short piix4_smba; 106static unsigned short piix4_smba;
107static int srvrworks_csb5_delay;
107static struct pci_driver piix4_driver; 108static struct pci_driver piix4_driver;
108static struct i2c_adapter piix4_adapter; 109static struct i2c_adapter piix4_adapter;
109 110
110static struct dmi_system_id __devinitdata piix4_dmi_table[] = { 111static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = {
112 {
113 .ident = "Sapphire AM2RD790",
114 .matches = {
115 DMI_MATCH(DMI_BOARD_VENDOR, "SAPPHIRE Inc."),
116 DMI_MATCH(DMI_BOARD_NAME, "PC-AM2RD790"),
117 },
118 },
119 {
120 .ident = "DFI Lanparty UT 790FX",
121 .matches = {
122 DMI_MATCH(DMI_BOARD_VENDOR, "DFI Inc."),
123 DMI_MATCH(DMI_BOARD_NAME, "LP UT 790FX"),
124 },
125 },
126 { }
127};
128
129/* The IBM entry is in a separate table because we only check it
130 on Intel-based systems */
131static struct dmi_system_id __devinitdata piix4_dmi_ibm[] = {
111 { 132 {
112 .ident = "IBM", 133 .ident = "IBM",
113 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), }, 134 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },
@@ -122,8 +143,20 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
122 143
123 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev)); 144 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));
124 145
146 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
147 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
148 srvrworks_csb5_delay = 1;
149
150 /* On some motherboards, it was reported that accessing the SMBus
151 caused severe hardware problems */
152 if (dmi_check_system(piix4_dmi_blacklist)) {
153 dev_err(&PIIX4_dev->dev,
154 "Accessing the SMBus on this system is unsafe!\n");
155 return -EPERM;
156 }
157
125 /* Don't access SMBus on IBM systems which get corrupted eeproms */ 158 /* Don't access SMBus on IBM systems which get corrupted eeproms */
126 if (dmi_check_system(piix4_dmi_table) && 159 if (dmi_check_system(piix4_dmi_ibm) &&
127 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) { 160 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
128 dev_err(&PIIX4_dev->dev, "IBM system detected; this module " 161 dev_err(&PIIX4_dev->dev, "IBM system detected; this module "
129 "may corrupt your serial eeprom! Refusing to load " 162 "may corrupt your serial eeprom! Refusing to load "
@@ -230,10 +263,14 @@ static int piix4_transaction(void)
230 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 263 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
231 264
232 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ 265 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
233 do { 266 if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
267 msleep(2);
268 else
269 msleep(1);
270
271 while ((timeout++ < MAX_TIMEOUT) &&
272 ((temp = inb_p(SMBHSTSTS)) & 0x01))
234 msleep(1); 273 msleep(1);
235 temp = inb_p(SMBHSTSTS);
236 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
237 274
238 /* If the SMBus is still busy, we give up */ 275 /* If the SMBus is still busy, we give up */
239 if (timeout >= MAX_TIMEOUT) { 276 if (timeout >= MAX_TIMEOUT) {
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 8fbbdb4c2f35..114634da6c6e 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -132,14 +132,14 @@ static const struct i2c_algorithm i2c_sibyte_algo = {
132/* 132/*
133 * registering functions to load algorithms at runtime 133 * registering functions to load algorithms at runtime
134 */ 134 */
135int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) 135static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
136{ 136{
137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; 137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
138 138
139 /* register new adapter to i2c module... */ 139 /* Register new adapter to i2c module... */
140 i2c_adap->algo = &i2c_sibyte_algo; 140 i2c_adap->algo = &i2c_sibyte_algo;
141 141
142 /* Set the frequency to 100 kHz */ 142 /* Set the requested frequency. */
143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); 143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); 144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
145 145
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 26384daccb96..c99ebeadb558 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -327,6 +327,11 @@ void i2c_unregister_device(struct i2c_client *client)
327EXPORT_SYMBOL_GPL(i2c_unregister_device); 327EXPORT_SYMBOL_GPL(i2c_unregister_device);
328 328
329 329
330static const struct i2c_device_id dummy_id[] = {
331 { "dummy", 0 },
332 { },
333};
334
330static int dummy_probe(struct i2c_client *client, 335static int dummy_probe(struct i2c_client *client,
331 const struct i2c_device_id *id) 336 const struct i2c_device_id *id)
332{ 337{
@@ -342,13 +347,13 @@ static struct i2c_driver dummy_driver = {
342 .driver.name = "dummy", 347 .driver.name = "dummy",
343 .probe = dummy_probe, 348 .probe = dummy_probe,
344 .remove = dummy_remove, 349 .remove = dummy_remove,
350 .id_table = dummy_id,
345}; 351};
346 352
347/** 353/**
348 * i2c_new_dummy - return a new i2c device bound to a dummy driver 354 * i2c_new_dummy - return a new i2c device bound to a dummy driver
349 * @adapter: the adapter managing the device 355 * @adapter: the adapter managing the device
350 * @address: seven bit address to be used 356 * @address: seven bit address to be used
351 * @type: optional label used for i2c_client.name
352 * Context: can sleep 357 * Context: can sleep
353 * 358 *
354 * This returns an I2C client bound to the "dummy" driver, intended for use 359 * This returns an I2C client bound to the "dummy" driver, intended for use
@@ -364,15 +369,12 @@ static struct i2c_driver dummy_driver = {
364 * i2c_unregister_device(); or NULL to indicate an error. 369 * i2c_unregister_device(); or NULL to indicate an error.
365 */ 370 */
366struct i2c_client * 371struct i2c_client *
367i2c_new_dummy(struct i2c_adapter *adapter, u16 address, const char *type) 372i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
368{ 373{
369 struct i2c_board_info info = { 374 struct i2c_board_info info = {
370 .driver_name = "dummy", 375 I2C_BOARD_INFO("dummy", address),
371 .addr = address,
372 }; 376 };
373 377
374 if (type)
375 strlcpy(info.type, type, sizeof info.type);
376 return i2c_new_device(adapter, &info); 378 return i2c_new_device(adapter, &info);
377} 379}
378EXPORT_SYMBOL_GPL(i2c_new_dummy); 380EXPORT_SYMBOL_GPL(i2c_new_dummy);
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c
index e57a64605778..8f0100f67a91 100644
--- a/drivers/media/video/tcm825x.c
+++ b/drivers/media/video/tcm825x.c
@@ -885,12 +885,19 @@ static int __exit tcm825x_remove(struct i2c_client *client)
885 return 0; 885 return 0;
886} 886}
887 887
888static const struct i2c_device_id tcm825x_id[] = {
889 { "tcm825x", 0 },
890 { }
891};
892MODULE_DEVICE_TABLE(i2c, tcm825x_id);
893
888static struct i2c_driver tcm825x_i2c_driver = { 894static struct i2c_driver tcm825x_i2c_driver = {
889 .driver = { 895 .driver = {
890 .name = TCM825X_NAME, 896 .name = TCM825X_NAME,
891 }, 897 },
892 .probe = tcm825x_probe, 898 .probe = tcm825x_probe,
893 .remove = __exit_p(tcm825x_remove), 899 .remove = __exit_p(tcm825x_remove),
900 .id_table = tcm825x_id,
894}; 901};
895 902
896static struct tcm825x_sensor tcm825x = { 903static struct tcm825x_sensor tcm825x = {
diff --git a/drivers/media/video/tlv320aic23b.c b/drivers/media/video/tlv320aic23b.c
index f1db54202dea..28ab9f9d760a 100644
--- a/drivers/media/video/tlv320aic23b.c
+++ b/drivers/media/video/tlv320aic23b.c
@@ -168,6 +168,11 @@ static int tlv320aic23b_remove(struct i2c_client *client)
168 168
169/* ----------------------------------------------------------------------- */ 169/* ----------------------------------------------------------------------- */
170 170
171static const struct i2c_device_id tlv320aic23b_id[] = {
172 { "tlv320aic23b", 0 },
173 { }
174};
175MODULE_DEVICE_TABLE(i2c, tlv320aic23b_id);
171 176
172static struct v4l2_i2c_driver_data v4l2_i2c_data = { 177static struct v4l2_i2c_driver_data v4l2_i2c_data = {
173 .name = "tlv320aic23b", 178 .name = "tlv320aic23b",
@@ -175,4 +180,5 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
175 .command = tlv320aic23b_command, 180 .command = tlv320aic23b_command,
176 .probe = tlv320aic23b_probe, 181 .probe = tlv320aic23b_probe,
177 .remove = tlv320aic23b_remove, 182 .remove = tlv320aic23b_remove,
183 .id_table = tlv320aic23b_id,
178}; 184};
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 6f9945b04e1f..c77914d99d15 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1505,7 +1505,8 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1505 } 1505 }
1506 1506
1507 /* fill required data structures */ 1507 /* fill required data structures */
1508 strcpy(client->name, desc->name); 1508 if (!id)
1509 strlcpy(client->name, desc->name, I2C_NAME_SIZE);
1509 chip->type = desc-chiplist; 1510 chip->type = desc-chiplist;
1510 chip->shadow.count = desc->registers+1; 1511 chip->shadow.count = desc->registers+1;
1511 chip->prevmode = -1; 1512 chip->prevmode = -1;
@@ -1830,6 +1831,15 @@ static int chip_legacy_probe(struct i2c_adapter *adap)
1830 return 0; 1831 return 0;
1831} 1832}
1832 1833
1834/* This driver supports many devices and the idea is to let the driver
1835 detect which device is present. So rather than listing all supported
1836 devices here, we pretend to support a single, fake device type. */
1837static const struct i2c_device_id chip_id[] = {
1838 { "tvaudio", 0 },
1839 { }
1840};
1841MODULE_DEVICE_TABLE(i2c, chip_id);
1842
1833static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1843static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1834 .name = "tvaudio", 1844 .name = "tvaudio",
1835 .driverid = I2C_DRIVERID_TVAUDIO, 1845 .driverid = I2C_DRIVERID_TVAUDIO,
@@ -1837,6 +1847,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1837 .probe = chip_probe, 1847 .probe = chip_probe,
1838 .remove = chip_remove, 1848 .remove = chip_remove,
1839 .legacy_probe = chip_legacy_probe, 1849 .legacy_probe = chip_legacy_probe,
1850 .id_table = chip_id,
1840}; 1851};
1841 1852
1842/* 1853/*
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 29f47bacfc77..a6fa1f2f2ca6 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -227,7 +227,7 @@ static int s35390a_probe(struct i2c_client *client,
227 /* This chip uses multiple addresses, use dummy devices for them */ 227 /* This chip uses multiple addresses, use dummy devices for them */
228 for (i = 1; i < 8; ++i) { 228 for (i = 1; i < 8; ++i) {
229 s35390a->client[i] = i2c_new_dummy(client->adapter, 229 s35390a->client[i] = i2c_new_dummy(client->adapter,
230 client->addr + i, "rtc-s35390a"); 230 client->addr + i);
231 if (!s35390a->client[i]) { 231 if (!s35390a->client[i]) {
232 dev_err(&client->dev, "Address %02x unavailable\n", 232 dev_err(&client->dev, "Address %02x unavailable\n",
233 client->addr + i); 233 client->addr + i);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index cb63da5c2139..6716ec808c5e 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -262,7 +262,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
262 * client handles for the extra addresses. 262 * client handles for the extra addresses.
263 */ 263 */
264extern struct i2c_client * 264extern struct i2c_client *
265i2c_new_dummy(struct i2c_adapter *adap, u16 address, const char *type); 265i2c_new_dummy(struct i2c_adapter *adap, u16 address);
266 266
267extern void i2c_unregister_device(struct i2c_client *); 267extern void i2c_unregister_device(struct i2c_client *);
268 268
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h
index 347b6f8beb23..878562278b67 100644
--- a/include/media/v4l2-i2c-drv-legacy.h
+++ b/include/media/v4l2-i2c-drv-legacy.h
@@ -31,6 +31,7 @@ struct v4l2_i2c_driver_data {
31 int (*resume)(struct i2c_client *client); 31 int (*resume)(struct i2c_client *client);
32 int (*legacy_probe)(struct i2c_adapter *adapter); 32 int (*legacy_probe)(struct i2c_adapter *adapter);
33 int legacy_class; 33 int legacy_class;
34 const struct i2c_device_id *id_table;
34}; 35};
35 36
36static struct v4l2_i2c_driver_data v4l2_i2c_data; 37static struct v4l2_i2c_driver_data v4l2_i2c_data;
@@ -124,6 +125,7 @@ static int __init v4l2_i2c_drv_init(void)
124 v4l2_i2c_driver.command = v4l2_i2c_data.command; 125 v4l2_i2c_driver.command = v4l2_i2c_data.command;
125 v4l2_i2c_driver.probe = v4l2_i2c_data.probe; 126 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
126 v4l2_i2c_driver.remove = v4l2_i2c_data.remove; 127 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
128 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
127 err = i2c_add_driver(&v4l2_i2c_driver); 129 err = i2c_add_driver(&v4l2_i2c_driver);
128 if (err) 130 if (err)
129 i2c_del_driver(&v4l2_i2c_driver_legacy); 131 i2c_del_driver(&v4l2_i2c_driver_legacy);
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
index 7b6f06be7950..40ecef29801d 100644
--- a/include/media/v4l2-i2c-drv.h
+++ b/include/media/v4l2-i2c-drv.h
@@ -36,6 +36,7 @@ struct v4l2_i2c_driver_data {
36 int (*resume)(struct i2c_client *client); 36 int (*resume)(struct i2c_client *client);
37 int (*legacy_probe)(struct i2c_adapter *adapter); 37 int (*legacy_probe)(struct i2c_adapter *adapter);
38 int legacy_class; 38 int legacy_class;
39 const struct i2c_device_id *id_table;
39}; 40};
40 41
41static struct v4l2_i2c_driver_data v4l2_i2c_data; 42static struct v4l2_i2c_driver_data v4l2_i2c_data;
@@ -53,6 +54,7 @@ static int __init v4l2_i2c_drv_init(void)
53 v4l2_i2c_driver.remove = v4l2_i2c_data.remove; 54 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
54 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend; 55 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend;
55 v4l2_i2c_driver.resume = v4l2_i2c_data.resume; 56 v4l2_i2c_driver.resume = v4l2_i2c_data.resume;
57 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
56 return i2c_add_driver(&v4l2_i2c_driver); 58 return i2c_add_driver(&v4l2_i2c_driver);
57} 59}
58 60