diff options
Diffstat (limited to 'drivers/i2c/algos')
-rw-r--r-- | drivers/i2c/algos/Kconfig | 6 | ||||
-rw-r--r-- | drivers/i2c/algos/Makefile | 1 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 23 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-pca.c | 2 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-pcf.c | 2 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-sgi.c | 2 | ||||
-rw-r--r-- | drivers/i2c/algos/i2c-algo-sibyte.c | 215 |
7 files changed, 12 insertions, 239 deletions
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig index 30408015d231..c034820615bb 100644 --- a/drivers/i2c/algos/Kconfig +++ b/drivers/i2c/algos/Kconfig | |||
@@ -53,12 +53,6 @@ config I2C_ALGO8XX | |||
53 | tristate "MPC8xx CPM I2C interface" | 53 | tristate "MPC8xx CPM I2C interface" |
54 | depends on 8xx && I2C | 54 | depends on 8xx && I2C |
55 | 55 | ||
56 | config I2C_ALGO_SIBYTE | ||
57 | tristate "SiByte SMBus interface" | ||
58 | depends on SIBYTE_SB1xxx_SOC && I2C | ||
59 | help | ||
60 | Supports the SiByte SOC on-chip I2C interfaces (2 channels). | ||
61 | |||
62 | config I2C_ALGO_SGI | 56 | config I2C_ALGO_SGI |
63 | tristate "I2C SGI interfaces" | 57 | tristate "I2C SGI interfaces" |
64 | depends on I2C && (SGI_IP22 || SGI_IP32 || X86_VISWS) | 58 | depends on I2C && (SGI_IP22 || SGI_IP32 || X86_VISWS) |
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile index 867fe1f67401..208be04a3dbd 100644 --- a/drivers/i2c/algos/Makefile +++ b/drivers/i2c/algos/Makefile | |||
@@ -6,7 +6,6 @@ obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o | |||
6 | obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o | 6 | obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o |
7 | obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o | 7 | obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o |
8 | obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o | 8 | obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o |
9 | obj-$(CONFIG_I2C_ALGO_SIBYTE) += i2c-algo-sibyte.o | ||
10 | obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o | 9 | obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o |
11 | 10 | ||
12 | ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) | 11 | ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) |
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index ab230c033f99..21c36bfb5e6b 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -76,17 +76,15 @@ static inline void scllo(struct i2c_algo_bit_data *adap) | |||
76 | * Raise scl line, and do checking for delays. This is necessary for slower | 76 | * Raise scl line, and do checking for delays. This is necessary for slower |
77 | * devices. | 77 | * devices. |
78 | */ | 78 | */ |
79 | static inline int sclhi(struct i2c_algo_bit_data *adap) | 79 | static int sclhi(struct i2c_algo_bit_data *adap) |
80 | { | 80 | { |
81 | unsigned long start; | 81 | unsigned long start; |
82 | 82 | ||
83 | setscl(adap,1); | 83 | setscl(adap,1); |
84 | 84 | ||
85 | /* Not all adapters have scl sense line... */ | 85 | /* Not all adapters have scl sense line... */ |
86 | if (adap->getscl == NULL ) { | 86 | if (!adap->getscl) |
87 | udelay(adap->udelay); | 87 | goto done; |
88 | return 0; | ||
89 | } | ||
90 | 88 | ||
91 | start=jiffies; | 89 | start=jiffies; |
92 | while (! getscl(adap) ) { | 90 | while (! getscl(adap) ) { |
@@ -101,6 +99,8 @@ static inline int sclhi(struct i2c_algo_bit_data *adap) | |||
101 | cond_resched(); | 99 | cond_resched(); |
102 | } | 100 | } |
103 | DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); | 101 | DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); |
102 | |||
103 | done: | ||
104 | udelay(adap->udelay); | 104 | udelay(adap->udelay); |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
@@ -121,7 +121,6 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap) | |||
121 | DEBPROTO(printk(" Sr ")); | 121 | DEBPROTO(printk(" Sr ")); |
122 | setsda(adap,1); | 122 | setsda(adap,1); |
123 | sclhi(adap); | 123 | sclhi(adap); |
124 | udelay(adap->udelay); | ||
125 | 124 | ||
126 | sdalo(adap); | 125 | sdalo(adap); |
127 | scllo(adap); | 126 | scllo(adap); |
@@ -306,7 +305,7 @@ bailout: | |||
306 | * 0 chip did not answer | 305 | * 0 chip did not answer |
307 | * -x transmission error | 306 | * -x transmission error |
308 | */ | 307 | */ |
309 | static inline int try_address(struct i2c_adapter *i2c_adap, | 308 | static int try_address(struct i2c_adapter *i2c_adap, |
310 | unsigned char addr, int retries) | 309 | unsigned char addr, int retries) |
311 | { | 310 | { |
312 | struct i2c_algo_bit_data *adap = i2c_adap->algo_data; | 311 | struct i2c_algo_bit_data *adap = i2c_adap->algo_data; |
@@ -354,15 +353,11 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
354 | return (retval<0)? retval : -EFAULT; | 353 | return (retval<0)? retval : -EFAULT; |
355 | /* got a better one ?? */ | 354 | /* got a better one ?? */ |
356 | } | 355 | } |
357 | #if 0 | ||
358 | /* from asm/delay.h */ | ||
359 | __delay(adap->mdelay * (loops_per_sec / 1000) ); | ||
360 | #endif | ||
361 | } | 356 | } |
362 | return wrcount; | 357 | return wrcount; |
363 | } | 358 | } |
364 | 359 | ||
365 | static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | 360 | static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) |
366 | { | 361 | { |
367 | int inval; | 362 | int inval; |
368 | int rdcount=0; /* counts bytes read */ | 363 | int rdcount=0; /* counts bytes read */ |
@@ -412,7 +407,7 @@ static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
412 | * -x an error occurred (like: -EREMOTEIO if the device did not answer, or | 407 | * -x an error occurred (like: -EREMOTEIO if the device did not answer, or |
413 | * -ETIMEDOUT, for example if the lines are stuck...) | 408 | * -ETIMEDOUT, for example if the lines are stuck...) |
414 | */ | 409 | */ |
415 | static inline int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | 410 | static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) |
416 | { | 411 | { |
417 | unsigned short flags = msg->flags; | 412 | unsigned short flags = msg->flags; |
418 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; | 413 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; |
@@ -517,7 +512,7 @@ static u32 bit_func(struct i2c_adapter *adap) | |||
517 | 512 | ||
518 | /* -----exported algorithm data: ------------------------------------- */ | 513 | /* -----exported algorithm data: ------------------------------------- */ |
519 | 514 | ||
520 | static struct i2c_algorithm i2c_bit_algo = { | 515 | static const struct i2c_algorithm i2c_bit_algo = { |
521 | .master_xfer = bit_xfer, | 516 | .master_xfer = bit_xfer, |
522 | .functionality = bit_func, | 517 | .functionality = bit_func, |
523 | }; | 518 | }; |
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c index b88a6fcf7bd0..9081c9fbcd29 100644 --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c | |||
@@ -355,7 +355,7 @@ static int pca_init(struct i2c_algo_pca_data *adap) | |||
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | 357 | ||
358 | static struct i2c_algorithm pca_algo = { | 358 | static const struct i2c_algorithm pca_algo = { |
359 | .master_xfer = pca_xfer, | 359 | .master_xfer = pca_xfer, |
360 | .functionality = pca_func, | 360 | .functionality = pca_func, |
361 | }; | 361 | }; |
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c index 5b24930adb5a..3b2003398966 100644 --- a/drivers/i2c/algos/i2c-algo-pcf.c +++ b/drivers/i2c/algos/i2c-algo-pcf.c | |||
@@ -458,7 +458,7 @@ static u32 pcf_func(struct i2c_adapter *adap) | |||
458 | 458 | ||
459 | /* -----exported algorithm data: ------------------------------------- */ | 459 | /* -----exported algorithm data: ------------------------------------- */ |
460 | 460 | ||
461 | static struct i2c_algorithm pcf_algo = { | 461 | static const struct i2c_algorithm pcf_algo = { |
462 | .master_xfer = pcf_xfer, | 462 | .master_xfer = pcf_xfer, |
463 | .functionality = pcf_func, | 463 | .functionality = pcf_func, |
464 | }; | 464 | }; |
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c index 932c4fa86c73..490d99997fd0 100644 --- a/drivers/i2c/algos/i2c-algo-sgi.c +++ b/drivers/i2c/algos/i2c-algo-sgi.c | |||
@@ -157,7 +157,7 @@ static u32 sgi_func(struct i2c_adapter *adap) | |||
157 | return I2C_FUNC_SMBUS_EMUL; | 157 | return I2C_FUNC_SMBUS_EMUL; |
158 | } | 158 | } |
159 | 159 | ||
160 | static struct i2c_algorithm sgi_algo = { | 160 | static const struct i2c_algorithm sgi_algo = { |
161 | .master_xfer = sgi_xfer, | 161 | .master_xfer = sgi_xfer, |
162 | .functionality = sgi_func, | 162 | .functionality = sgi_func, |
163 | }; | 163 | }; |
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c deleted file mode 100644 index 32d41c6fac0f..000000000000 --- a/drivers/i2c/algos/i2c-algo-sibyte.c +++ /dev/null | |||
@@ -1,215 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* i2c-algo-sibyte.c i2c driver algorithms for bit-shift adapters */ | ||
3 | /* ------------------------------------------------------------------------- */ | ||
4 | /* Copyright (C) 2001,2002,2003 Broadcom Corporation | ||
5 | Copyright (C) 1995-2000 Simon G. Vogl | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
20 | /* ------------------------------------------------------------------------- */ | ||
21 | |||
22 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even | ||
23 | Frodo Looijaard <frodol@dds.nl>. */ | ||
24 | |||
25 | /* Ported for SiByte SOCs by Broadcom Corporation. */ | ||
26 | |||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/init.h> | ||
30 | |||
31 | #include <asm/io.h> | ||
32 | #include <asm/sibyte/sb1250_regs.h> | ||
33 | #include <asm/sibyte/sb1250_smbus.h> | ||
34 | |||
35 | #include <linux/i2c.h> | ||
36 | #include <linux/i2c-algo-sibyte.h> | ||
37 | |||
38 | /* ----- global defines ----------------------------------------------- */ | ||
39 | #define SMB_CSR(a,r) ((long)(a->reg_base + r)) | ||
40 | |||
41 | /* ----- global variables --------------------------------------------- */ | ||
42 | |||
43 | /* module parameters: | ||
44 | */ | ||
45 | static int bit_scan; /* have a look at what's hanging 'round */ | ||
46 | |||
47 | |||
48 | static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, | ||
49 | unsigned short flags, char read_write, | ||
50 | u8 command, int size, union i2c_smbus_data * data) | ||
51 | { | ||
52 | struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; | ||
53 | int data_bytes = 0; | ||
54 | int error; | ||
55 | |||
56 | while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY) | ||
57 | ; | ||
58 | |||
59 | switch (size) { | ||
60 | case I2C_SMBUS_QUICK: | ||
61 | csr_out32((V_SMB_ADDR(addr) | (read_write == I2C_SMBUS_READ ? M_SMB_QDATA : 0) | | ||
62 | V_SMB_TT_QUICKCMD), SMB_CSR(adap, R_SMB_START)); | ||
63 | break; | ||
64 | case I2C_SMBUS_BYTE: | ||
65 | if (read_write == I2C_SMBUS_READ) { | ||
66 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_RD1BYTE), | ||
67 | SMB_CSR(adap, R_SMB_START)); | ||
68 | data_bytes = 1; | ||
69 | } else { | ||
70 | csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); | ||
71 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR1BYTE), | ||
72 | SMB_CSR(adap, R_SMB_START)); | ||
73 | } | ||
74 | break; | ||
75 | case I2C_SMBUS_BYTE_DATA: | ||
76 | csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); | ||
77 | if (read_write == I2C_SMBUS_READ) { | ||
78 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD1BYTE), | ||
79 | SMB_CSR(adap, R_SMB_START)); | ||
80 | data_bytes = 1; | ||
81 | } else { | ||
82 | csr_out32(V_SMB_LB(data->byte), SMB_CSR(adap, R_SMB_DATA)); | ||
83 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE), | ||
84 | SMB_CSR(adap, R_SMB_START)); | ||
85 | } | ||
86 | break; | ||
87 | case I2C_SMBUS_WORD_DATA: | ||
88 | csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD)); | ||
89 | if (read_write == I2C_SMBUS_READ) { | ||
90 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD2BYTE), | ||
91 | SMB_CSR(adap, R_SMB_START)); | ||
92 | data_bytes = 2; | ||
93 | } else { | ||
94 | csr_out32(V_SMB_LB(data->word & 0xff), SMB_CSR(adap, R_SMB_DATA)); | ||
95 | csr_out32(V_SMB_MB(data->word >> 8), SMB_CSR(adap, R_SMB_DATA)); | ||
96 | csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE), | ||
97 | SMB_CSR(adap, R_SMB_START)); | ||
98 | } | ||
99 | break; | ||
100 | default: | ||
101 | return -1; /* XXXKW better error code? */ | ||
102 | } | ||
103 | |||
104 | while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY) | ||
105 | ; | ||
106 | |||
107 | error = csr_in32(SMB_CSR(adap, R_SMB_STATUS)); | ||
108 | if (error & M_SMB_ERROR) { | ||
109 | /* Clear error bit by writing a 1 */ | ||
110 | csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS)); | ||
111 | return -1; /* XXXKW better error code? */ | ||
112 | } | ||
113 | |||
114 | if (data_bytes == 1) | ||
115 | data->byte = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xff; | ||
116 | if (data_bytes == 2) | ||
117 | data->word = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xffff; | ||
118 | |||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static int algo_control(struct i2c_adapter *adapter, | ||
123 | unsigned int cmd, unsigned long arg) | ||
124 | { | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static u32 bit_func(struct i2c_adapter *adap) | ||
129 | { | ||
130 | return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | | ||
131 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA); | ||
132 | } | ||
133 | |||
134 | |||
135 | /* -----exported algorithm data: ------------------------------------- */ | ||
136 | |||
137 | static struct i2c_algorithm i2c_sibyte_algo = { | ||
138 | .smbus_xfer = smbus_xfer, | ||
139 | .algo_control = algo_control, /* ioctl */ | ||
140 | .functionality = bit_func, | ||
141 | }; | ||
142 | |||
143 | /* | ||
144 | * registering functions to load algorithms at runtime | ||
145 | */ | ||
146 | int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) | ||
147 | { | ||
148 | int i; | ||
149 | struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; | ||
150 | |||
151 | /* register new adapter to i2c module... */ | ||
152 | i2c_adap->algo = &i2c_sibyte_algo; | ||
153 | |||
154 | /* Set the frequency to 100 kHz */ | ||
155 | csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); | ||
156 | csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); | ||
157 | |||
158 | /* scan bus */ | ||
159 | if (bit_scan) { | ||
160 | union i2c_smbus_data data; | ||
161 | int rc; | ||
162 | printk(KERN_INFO " i2c-algo-sibyte.o: scanning bus %s.\n", | ||
163 | i2c_adap->name); | ||
164 | for (i = 0x00; i < 0x7f; i++) { | ||
165 | /* XXXKW is this a realistic probe? */ | ||
166 | rc = smbus_xfer(i2c_adap, i, 0, I2C_SMBUS_READ, 0, | ||
167 | I2C_SMBUS_BYTE_DATA, &data); | ||
168 | if (!rc) { | ||
169 | printk("(%02x)",i); | ||
170 | } else | ||
171 | printk("."); | ||
172 | } | ||
173 | printk("\n"); | ||
174 | } | ||
175 | |||
176 | return i2c_add_adapter(i2c_adap); | ||
177 | } | ||
178 | |||
179 | |||
180 | int i2c_sibyte_del_bus(struct i2c_adapter *adap) | ||
181 | { | ||
182 | int res; | ||
183 | |||
184 | if ((res = i2c_del_adapter(adap)) < 0) | ||
185 | return res; | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | int __init i2c_algo_sibyte_init (void) | ||
191 | { | ||
192 | printk("i2c-algo-sibyte.o: i2c SiByte algorithm module\n"); | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | |||
197 | EXPORT_SYMBOL(i2c_sibyte_add_bus); | ||
198 | EXPORT_SYMBOL(i2c_sibyte_del_bus); | ||
199 | |||
200 | #ifdef MODULE | ||
201 | MODULE_AUTHOR("Kip Walker, Broadcom Corp."); | ||
202 | MODULE_DESCRIPTION("SiByte I2C-Bus algorithm"); | ||
203 | module_param(bit_scan, int, 0); | ||
204 | MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus"); | ||
205 | MODULE_LICENSE("GPL"); | ||
206 | |||
207 | int init_module(void) | ||
208 | { | ||
209 | return i2c_algo_sibyte_init(); | ||
210 | } | ||
211 | |||
212 | void cleanup_module(void) | ||
213 | { | ||
214 | } | ||
215 | #endif | ||