| 1 | /* ------------------------------------------------------------------------- */ |
|---|
| 2 | /* i2c-core.c - a device driver for the iic-bus interface */ |
|---|
| 3 | /* ------------------------------------------------------------------------- */ |
|---|
| 4 | /* Copyright (C) 1995-99 Simon G. Vogl |
|---|
| 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | This program is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | GNU General Public License for more details. |
|---|
| 15 | |
|---|
| 16 | You should have received a copy of the GNU General Public License |
|---|
| 17 | along with this program; if not, write to the Free Software |
|---|
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
|---|
| 19 | /* ------------------------------------------------------------------------- */ |
|---|
| 20 | #define RCSID "$Id$" |
|---|
| 21 | /* ------------------------------------------------------------------------- */ |
|---|
| 22 | |
|---|
| 23 | /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. |
|---|
| 24 | All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> */ |
|---|
| 25 | |
|---|
| 26 | #include <linux/module.h> |
|---|
| 27 | #include <linux/kernel.h> |
|---|
| 28 | #include <linux/errno.h> |
|---|
| 29 | #include <linux/malloc.h> |
|---|
| 30 | #if LINUX_VERSION_CODE >= 0x020135 |
|---|
| 31 | #include <linux/init.h> |
|---|
| 32 | #else |
|---|
| 33 | #define __init |
|---|
| 34 | #endif |
|---|
| 35 | |
|---|
| 36 | #include "i2c.h" |
|---|
| 37 | |
|---|
| 38 | /* ----- compatibility stuff ----------------------------------------------- */ |
|---|
| 39 | #if LINUX_VERSION_CODE < 0x020301 |
|---|
| 40 | #define init_MUTEX(s) do { *(s) = MUTEX; } while(0) |
|---|
| 41 | #endif |
|---|
| 42 | |
|---|
| 43 | /* ----- global defines ---------------------------------------------------- */ |
|---|
| 44 | |
|---|
| 45 | /* exclusive access to the bus */ |
|---|
| 46 | #define I2C_LOCK(adap) down(&adap->lock) |
|---|
| 47 | #define I2C_UNLOCK(adap) up(&adap->lock) |
|---|
| 48 | |
|---|
| 49 | #define DEB(x) if (i2c_debug>=1) x; |
|---|
| 50 | #define DEB2(x) if (i2c_debug>=2) x; |
|---|
| 51 | |
|---|
| 52 | /* ----- global variables -------------------------------------------------- */ |
|---|
| 53 | |
|---|
| 54 | /**** algorithm list */ |
|---|
| 55 | static struct i2c_algorithm *algorithms[I2C_ALGO_MAX]; |
|---|
| 56 | static int algo_count; |
|---|
| 57 | |
|---|
| 58 | /**** adapter list */ |
|---|
| 59 | static struct i2c_adapter *adapters[I2C_ADAP_MAX]; |
|---|
| 60 | static int adap_count; |
|---|
| 61 | |
|---|
| 62 | /**** drivers list */ |
|---|
| 63 | static struct i2c_driver *drivers[I2C_DRIVER_MAX]; |
|---|
| 64 | static int driver_count; |
|---|
| 65 | |
|---|
| 66 | /**** debug level */ |
|---|
| 67 | static int i2c_debug=1; |
|---|
| 68 | |
|---|
| 69 | /* --------------------------------------------------- |
|---|
| 70 | * registering functions |
|---|
| 71 | * --------------------------------------------------- |
|---|
| 72 | */ |
|---|
| 73 | |
|---|
| 74 | /* ----- |
|---|
| 75 | * Algorithms - used to access groups of similar hw adapters or |
|---|
| 76 | * specific interfaces like the PCF8584 et al. |
|---|
| 77 | */ |
|---|
| 78 | int i2c_add_algorithm(struct i2c_algorithm *algo) |
|---|
| 79 | { |
|---|
| 80 | int i; |
|---|
| 81 | |
|---|
| 82 | for (i = 0; i < I2C_ALGO_MAX; i++) |
|---|
| 83 | if (NULL == algorithms[i]) |
|---|
| 84 | break; |
|---|
| 85 | if (I2C_ALGO_MAX == i) { |
|---|
| 86 | printk(KERN_WARNING |
|---|
| 87 | " i2c: register_algorithm(%s) - enlarge I2C_ALGO_MAX.\n", |
|---|
| 88 | algo->name); |
|---|
| 89 | return -ENOMEM; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | algorithms[i] = algo; |
|---|
| 93 | algo_count++; |
|---|
| 94 | |
|---|
| 95 | DEB(printk("i2c: algorithm %s registered.\n",algo->name)); |
|---|
| 96 | return 0; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | int i2c_del_algorithm(struct i2c_algorithm *algo) |
|---|
| 101 | { |
|---|
| 102 | int i; |
|---|
| 103 | |
|---|
| 104 | for (i = 0; i < I2C_ALGO_MAX; i++) |
|---|
| 105 | if (algo == algorithms[i]) |
|---|
| 106 | break; |
|---|
| 107 | if (I2C_ALGO_MAX == i) { |
|---|
| 108 | printk(KERN_WARNING |
|---|
| 109 | " i2c: unregister_algorithm: [%s] not found.\n", |
|---|
| 110 | algo->name); |
|---|
| 111 | return -ENODEV; |
|---|
| 112 | } |
|---|
| 113 | algorithms[i] = NULL; |
|---|
| 114 | algo_count--; |
|---|
| 115 | |
|---|
| 116 | DEB(printk("i2c: algorithm unregistered: %s\n",algo->name)); |
|---|
| 117 | return 0; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | /* ----- |
|---|
| 122 | * i2c_add_adapter is called from within the algorithm layer, |
|---|
| 123 | * when a new hw adapter registers. A new device is register to be |
|---|
| 124 | * available for clients. |
|---|
| 125 | */ |
|---|
| 126 | int i2c_add_adapter(struct i2c_adapter *adap) |
|---|
| 127 | { |
|---|
| 128 | int i; |
|---|
| 129 | |
|---|
| 130 | for (i = 0; i < I2C_ADAP_MAX; i++) |
|---|
| 131 | if (NULL == adapters[i]) |
|---|
| 132 | break; |
|---|
| 133 | if (I2C_ADAP_MAX == i) { |
|---|
| 134 | printk(KERN_WARNING |
|---|
| 135 | " i2c: register_adapter(%s) - enlarge I2C_ADAP_MAX.\n", |
|---|
| 136 | adap->name); |
|---|
| 137 | return -ENOMEM; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | adapters[i] = adap; |
|---|
| 142 | adap_count++; |
|---|
| 143 | |
|---|
| 144 | /* init data types */ |
|---|
| 145 | init_MUTEX(&adap->lock); |
|---|
| 146 | |
|---|
| 147 | /* inform drivers of new adapters */ |
|---|
| 148 | for (i=0;i<I2C_DRIVER_MAX;i++) |
|---|
| 149 | if (drivers[i]!=NULL && drivers[i]->flags&DF_NOTIFY) |
|---|
| 150 | drivers[i]->attach_adapter(adap); |
|---|
| 151 | |
|---|
| 152 | DEB(printk("i2c: adapter %s registered.\n",adap->name)); |
|---|
| 153 | return 0; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | int i2c_del_adapter(struct i2c_adapter *adap) |
|---|
| 157 | { |
|---|
| 158 | int i,j; |
|---|
| 159 | |
|---|
| 160 | for (i = 0; i < I2C_ADAP_MAX; i++) |
|---|
| 161 | if (adap == adapters[i]) |
|---|
| 162 | break; |
|---|
| 163 | if (I2C_ADAP_MAX == i) { |
|---|
| 164 | printk(KERN_WARNING |
|---|
| 165 | " i2c: unregister_adapter adap [%s] not found.\n", |
|---|
| 166 | adap->name); |
|---|
| 167 | return -ENODEV; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | /* detach any active clients */ |
|---|
| 171 | for (j=0;j<I2C_CLIENT_MAX;j++) { |
|---|
| 172 | struct i2c_client *client = adap->clients[j]; |
|---|
| 173 | if ( (client!=NULL) |
|---|
| 174 | /* && (client->driver->flags & DF_NOTIFY) */ ) |
|---|
| 175 | /* detaching devices is unconditional of the set notify |
|---|
| 176 | * flag, as _all_ clients that reside on the adapter |
|---|
| 177 | * must be deleted, as this would cause invalid states. |
|---|
| 178 | */ |
|---|
| 179 | client->driver->detach_client(client); |
|---|
| 180 | /* i2c_detach_client(client); --- frodo */ |
|---|
| 181 | } |
|---|
| 182 | /* all done, now unregister */ |
|---|
| 183 | adapters[i] = NULL; |
|---|
| 184 | adap_count--; |
|---|
| 185 | |
|---|
| 186 | DEB(printk("i2c: adapter unregistered: %s\n",adap->name)); |
|---|
| 187 | return 0; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | /* ----- |
|---|
| 191 | * What follows is the "upwards" interface: commands for talking to clients, |
|---|
| 192 | * which implement the functions to access the physical information of the |
|---|
| 193 | * chips. |
|---|
| 194 | */ |
|---|
| 195 | |
|---|
| 196 | int i2c_add_driver(struct i2c_driver *driver) |
|---|
| 197 | { |
|---|
| 198 | int i; |
|---|
| 199 | |
|---|
| 200 | for (i = 0; i < I2C_DRIVER_MAX; i++) |
|---|
| 201 | if (NULL == drivers[i]) |
|---|
| 202 | break; |
|---|
| 203 | if (I2C_DRIVER_MAX == i) { |
|---|
| 204 | printk(KERN_WARNING |
|---|
| 205 | " i2c: register_driver(%s) - enlarge I2C_DRIVER_MAX.\n", |
|---|
| 206 | driver->name); |
|---|
| 207 | return -ENOMEM; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | drivers[i] = driver; |
|---|
| 211 | driver_count++; |
|---|
| 212 | |
|---|
| 213 | DEB(printk("i2c: driver %s registered.\n",driver->name)); |
|---|
| 214 | |
|---|
| 215 | /* now look for instances of driver on our adapters |
|---|
| 216 | */ |
|---|
| 217 | if ( driver->flags&DF_NOTIFY ) |
|---|
| 218 | for (i=0;i<I2C_ADAP_MAX;i++) |
|---|
| 219 | if (adapters[i]!=NULL) |
|---|
| 220 | driver->attach_adapter(adapters[i]); |
|---|
| 221 | |
|---|
| 222 | return 0; |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | int i2c_del_driver(struct i2c_driver *driver) |
|---|
| 226 | { |
|---|
| 227 | int i,j,k; |
|---|
| 228 | |
|---|
| 229 | for (i = 0; i < I2C_DRIVER_MAX; i++) |
|---|
| 230 | if (driver == drivers[i]) |
|---|
| 231 | break; |
|---|
| 232 | if (I2C_DRIVER_MAX == i) { |
|---|
| 233 | printk(KERN_WARNING " i2c: unregister_driver: [%s] not found\n", |
|---|
| 234 | driver->name); |
|---|
| 235 | return -ENODEV; |
|---|
| 236 | } |
|---|
| 237 | /* Have a look at each adapter, if clients of this driver are still |
|---|
| 238 | * attached. If so, detach them to be able to kill the driver afterwards. |
|---|
| 239 | */ |
|---|
| 240 | DEB2(printk("i2c: unregister_driver - looking for clients.\n")); |
|---|
| 241 | /* removing clients does not depend on the notify flag, else |
|---|
| 242 | * invalid operation might (will!) result, when using stale client |
|---|
| 243 | * pointers. |
|---|
| 244 | */ |
|---|
| 245 | for (k=0;k<I2C_ADAP_MAX;k++) { |
|---|
| 246 | struct i2c_adapter *adap = adapters[k]; |
|---|
| 247 | if (adap == NULL) /* skip empty entries. */ |
|---|
| 248 | continue; |
|---|
| 249 | DEB2(printk("i2c: examining adapter %s:\n",adap->name)); |
|---|
| 250 | for (j=0;j<I2C_CLIENT_MAX;j++) { |
|---|
| 251 | struct i2c_client *client = adap->clients[j]; |
|---|
| 252 | if (client != NULL && client->driver == driver) { |
|---|
| 253 | DEB2(printk("i2c: detaching client %s:\n", |
|---|
| 254 | client->name)); |
|---|
| 255 | /*i2c_detach_client(client);*/ |
|---|
| 256 | driver->detach_client(client); |
|---|
| 257 | } |
|---|
| 258 | } |
|---|
| 259 | } |
|---|
| 260 | drivers[i] = NULL; |
|---|
| 261 | driver_count--; |
|---|
| 262 | |
|---|
| 263 | DEB(printk("i2c: driver unregistered: %s\n",driver->name)); |
|---|
| 264 | return 0; |
|---|
| 265 | } |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | int i2c_attach_client(struct i2c_client *client) |
|---|
| 269 | { |
|---|
| 270 | struct i2c_adapter *adapter = client->adapter; |
|---|
| 271 | struct i2c_algorithm *algo = adapter->algo; |
|---|
| 272 | int i; |
|---|
| 273 | |
|---|
| 274 | for (i = 0; i < I2C_CLIENT_MAX; i++) |
|---|
| 275 | if (NULL == adapter->clients[i]) |
|---|
| 276 | break; |
|---|
| 277 | if (I2C_CLIENT_MAX == i) { |
|---|
| 278 | printk(KERN_WARNING |
|---|
| 279 | " i2c: attach_client(%s) - enlarge I2C_CLIENT_MAX.\n", |
|---|
| 280 | client->name); |
|---|
| 281 | return -ENOMEM; |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | adapter->clients[i] = client; |
|---|
| 285 | adapter->client_count++; |
|---|
| 286 | if (algo->client_register != NULL) |
|---|
| 287 | algo->client_register(client); |
|---|
| 288 | DEB(printk("i2c: client [%s] registered to adapter [%s](pos. %d).\n", |
|---|
| 289 | client->name, adapter->name,i)); |
|---|
| 290 | return 0; |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | int i2c_detach_client(struct i2c_client *client) |
|---|
| 295 | { |
|---|
| 296 | struct i2c_adapter *adapter = client->adapter; |
|---|
| 297 | struct i2c_algorithm *algo = adapter->algo; |
|---|
| 298 | int i; |
|---|
| 299 | |
|---|
| 300 | for (i = 0; i < I2C_CLIENT_MAX; i++) |
|---|
| 301 | if (client == adapter->clients[i]) |
|---|
| 302 | break; |
|---|
| 303 | if (I2C_CLIENT_MAX == i) { |
|---|
| 304 | printk(KERN_WARNING " i2c: unregister_client [%s] not found\n", |
|---|
| 305 | client->name); |
|---|
| 306 | return -ENODEV; |
|---|
| 307 | } |
|---|
| 308 | |
|---|
| 309 | if (algo->client_unregister != NULL) |
|---|
| 310 | algo->client_unregister(client); |
|---|
| 311 | /* client->driver->detach_client(client);*/ |
|---|
| 312 | adapter->clients[i] = NULL; |
|---|
| 313 | adapter->client_count--; |
|---|
| 314 | DEB(printk("i2c: client [%s] unregistered.\n",client->name)); |
|---|
| 315 | return 0; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | void i2c_inc_use_client(struct i2c_client *client) |
|---|
| 319 | { |
|---|
| 320 | |
|---|
| 321 | if (client->driver->inc_use != NULL) |
|---|
| 322 | client->driver->inc_use(client); |
|---|
| 323 | |
|---|
| 324 | if (client->adapter->inc_use != NULL) |
|---|
| 325 | client->adapter->inc_use(client->adapter); |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | void i2c_dec_use_client(struct i2c_client *client) |
|---|
| 329 | { |
|---|
| 330 | |
|---|
| 331 | if (client->driver->dec_use != NULL) |
|---|
| 332 | client->driver->dec_use(client); |
|---|
| 333 | |
|---|
| 334 | if (client->adapter->dec_use != NULL) |
|---|
| 335 | client->adapter->dec_use(client->adapter); |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | /* ---------------------------------------------------- |
|---|
| 339 | * the functional interface to the i2c busses. |
|---|
| 340 | * ---------------------------------------------------- |
|---|
| 341 | */ |
|---|
| 342 | |
|---|
| 343 | int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num) |
|---|
| 344 | { |
|---|
| 345 | int ret; |
|---|
| 346 | |
|---|
| 347 | if (adap->algo->master_xfer) { |
|---|
| 348 | DEB(printk("master_xfer: %s with %d msgs.\n",adap->name,num)); |
|---|
| 349 | |
|---|
| 350 | I2C_LOCK(adap); |
|---|
| 351 | ret = adap->algo->master_xfer(adap,msgs,num); |
|---|
| 352 | I2C_UNLOCK(adap); |
|---|
| 353 | |
|---|
| 354 | return ret; |
|---|
| 355 | } else { |
|---|
| 356 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 357 | adap->id); |
|---|
| 358 | return 0; |
|---|
| 359 | } |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | int i2c_master_send(struct i2c_client *client,const char *buf ,int count) |
|---|
| 363 | { |
|---|
| 364 | int ret; |
|---|
| 365 | struct i2c_adapter *adap=client->adapter; |
|---|
| 366 | struct i2c_msg msg; |
|---|
| 367 | |
|---|
| 368 | if (client->adapter->algo->master_xfer) { |
|---|
| 369 | msg.addr = client->addr; |
|---|
| 370 | msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK ); |
|---|
| 371 | msg.len = count; |
|---|
| 372 | (const char *)msg.buf = buf; |
|---|
| 373 | |
|---|
| 374 | DEB(printk("master_send: writing %d bytes on %s.\n", |
|---|
| 375 | count,client->adapter->name)); |
|---|
| 376 | |
|---|
| 377 | I2C_LOCK(adap); |
|---|
| 378 | ret = adap->algo->master_xfer(adap,&msg,1); |
|---|
| 379 | I2C_UNLOCK(adap); |
|---|
| 380 | |
|---|
| 381 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes |
|---|
| 382 | * transmitted, else error code. |
|---|
| 383 | */ |
|---|
| 384 | return (ret == 1 )? count : ret; |
|---|
| 385 | } else { |
|---|
| 386 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 387 | client->adapter->id); |
|---|
| 388 | return 0; |
|---|
| 389 | } |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | int i2c_master_send_subadress(struct i2c_client *client,const char *buf ,int count, int subadress) |
|---|
| 393 | { |
|---|
| 394 | char* c; |
|---|
| 395 | |
|---|
| 396 | int ret; |
|---|
| 397 | struct i2c_adapter *adap=client->adapter; |
|---|
| 398 | struct i2c_msg msg; |
|---|
| 399 | |
|---|
| 400 | if (client->adapter->algo->master_xfer) { |
|---|
| 401 | c = (char*)kmalloc(sizeof(char)*(count+1),GFP_KERNEL); |
|---|
| 402 | if (0 == c) |
|---|
| 403 | return -ENOMEM; |
|---|
| 404 | |
|---|
| 405 | msg.addr = client->addr; |
|---|
| 406 | msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK ); |
|---|
| 407 | msg.len = count+1; |
|---|
| 408 | (const char *)msg.buf = c; |
|---|
| 409 | |
|---|
| 410 | c[0] = subadress; |
|---|
| 411 | memcpy(&c[1], buf, sizeof(char)*count); |
|---|
| 412 | |
|---|
| 413 | DEB(printk("master_send_subadress: writing %d bytes on %s. (sa:0x%02x)\n", |
|---|
| 414 | count,client->adapter->name,subadress)); |
|---|
| 415 | |
|---|
| 416 | I2C_LOCK(adap); |
|---|
| 417 | ret = adap->algo->master_xfer(adap,&msg,1); |
|---|
| 418 | I2C_UNLOCK(adap); |
|---|
| 419 | |
|---|
| 420 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes |
|---|
| 421 | * transmitted, else error code. |
|---|
| 422 | */ |
|---|
| 423 | |
|---|
| 424 | kfree(c); |
|---|
| 425 | |
|---|
| 426 | return (ret == 1 )? count : ret; |
|---|
| 427 | } else { |
|---|
| 428 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 429 | client->adapter->id); |
|---|
| 430 | return 0; |
|---|
| 431 | } |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | int i2c_master_recv_subadress(struct i2c_client *client,const char *buf ,int count, int subadress) |
|---|
| 436 | { |
|---|
| 437 | int ret; |
|---|
| 438 | struct i2c_adapter *adap=client->adapter; |
|---|
| 439 | struct i2c_msg msg[2]; |
|---|
| 440 | |
|---|
| 441 | if (client->adapter->algo->master_xfer) { |
|---|
| 442 | msg[0].addr = client->addr; |
|---|
| 443 | msg[0].flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK ); |
|---|
| 444 | msg[0].len = 1; |
|---|
| 445 | (const char*)msg[0].buf = (const char*)&subadress; |
|---|
| 446 | |
|---|
| 447 | msg[1].addr = client->addr; |
|---|
| 448 | msg[1].flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK ); |
|---|
| 449 | msg[1].flags |= I2C_M_RD; |
|---|
| 450 | msg[1].len = count; |
|---|
| 451 | (const char*)msg[1].buf = (const char*)buf; |
|---|
| 452 | |
|---|
| 453 | DEB(printk("master_recv_subadress: reading %d bytes from subadress %d on %s.\n", |
|---|
| 454 | count,subadress,client->adapter->name)); |
|---|
| 455 | |
|---|
| 456 | I2C_LOCK(adap); |
|---|
| 457 | ret = adap->algo->master_xfer(adap,msg,2); |
|---|
| 458 | I2C_UNLOCK(adap); |
|---|
| 459 | |
|---|
| 460 | /* if everything went ok (i.e. 1 msg transmitted), |
|---|
| 461 | return 0, else return error code. |
|---|
| 462 | */ |
|---|
| 463 | return (ret == 1 ) ? 0 : ret; |
|---|
| 464 | } else { |
|---|
| 465 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 466 | client->adapter->id); |
|---|
| 467 | return 0; |
|---|
| 468 | } |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | int i2c_master_recv(struct i2c_client *client, char *buf ,int count) |
|---|
| 474 | { |
|---|
| 475 | struct i2c_adapter *adap=client->adapter; |
|---|
| 476 | struct i2c_msg msg; |
|---|
| 477 | int ret; |
|---|
| 478 | if (client->adapter->algo->master_xfer) { |
|---|
| 479 | msg.addr = client->addr; |
|---|
| 480 | msg.flags = client->flags & ( I2C_M_TEN|I2C_M_TENMASK ); |
|---|
| 481 | msg.flags |= I2C_M_RD; |
|---|
| 482 | msg.len = count; |
|---|
| 483 | msg.buf = buf; |
|---|
| 484 | |
|---|
| 485 | DEB(printk("master_recv: reading %d bytes on %s.\n", |
|---|
| 486 | count,client->adapter->name)); |
|---|
| 487 | |
|---|
| 488 | I2C_LOCK(adap); |
|---|
| 489 | ret = adap->algo->master_xfer(adap,&msg,1); |
|---|
| 490 | I2C_UNLOCK(adap); |
|---|
| 491 | |
|---|
| 492 | DEB(printk("master_recv: return:%d (count:%d, addr:0x%02x)\n", |
|---|
| 493 | ret, count, client->addr)); |
|---|
| 494 | |
|---|
| 495 | /* if everything went ok (i.e. 1 msg transmitted), return #bytes |
|---|
| 496 | * transmitted, else error code. |
|---|
| 497 | */ |
|---|
| 498 | return (ret == 1 )? count : ret; |
|---|
| 499 | } else { |
|---|
| 500 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 501 | client->adapter->id); |
|---|
| 502 | return 0; |
|---|
| 503 | } |
|---|
| 504 | } |
|---|
| 505 | |
|---|
| 506 | |
|---|
| 507 | int i2c_control(struct i2c_client *client, |
|---|
| 508 | unsigned int cmd, unsigned long arg) |
|---|
| 509 | { |
|---|
| 510 | int ret = 0; |
|---|
| 511 | struct i2c_adapter *adap = client->adapter; |
|---|
| 512 | |
|---|
| 513 | DEB2(printk("i2c ioctl, cmd: 0x%x, arg: %#lx\n", cmd, arg)); |
|---|
| 514 | switch ( cmd ) { |
|---|
| 515 | case I2C_RETRIES: |
|---|
| 516 | adap->retries = arg; |
|---|
| 517 | break; |
|---|
| 518 | case I2C_TIMEOUT: |
|---|
| 519 | adap->timeout = arg; |
|---|
| 520 | break; |
|---|
| 521 | default: |
|---|
| 522 | if (adap->algo->algo_control!=NULL) |
|---|
| 523 | ret = adap->algo->algo_control(adap,cmd,arg); |
|---|
| 524 | } |
|---|
| 525 | return ret; |
|---|
| 526 | } |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | int i2c_probe(struct i2c_client *client, int low_addr, int hi_addr) |
|---|
| 530 | { |
|---|
| 531 | int i; |
|---|
| 532 | struct i2c_msg msg; |
|---|
| 533 | if (client->adapter->algo->master_xfer) { |
|---|
| 534 | msg.flags=client->flags & (I2C_M_TENMASK | I2C_M_TEN ); |
|---|
| 535 | msg.buf = NULL; |
|---|
| 536 | msg.len = 0; |
|---|
| 537 | I2C_LOCK(client->adapter); |
|---|
| 538 | for (i = low_addr; i <= hi_addr; i++) { |
|---|
| 539 | msg.addr=i; |
|---|
| 540 | /* TODO: implement a control statement in the algo layer |
|---|
| 541 | * that does address lookup only. |
|---|
| 542 | */ |
|---|
| 543 | if (1 == client->adapter-> |
|---|
| 544 | algo->master_xfer(client->adapter,&msg,1)) |
|---|
| 545 | break; |
|---|
| 546 | } |
|---|
| 547 | I2C_UNLOCK(client->adapter); |
|---|
| 548 | return (i <= hi_addr) ? (client->addr=i) : -1; |
|---|
| 549 | } else { |
|---|
| 550 | printk("I2C adapter %04x: I2C level transfers not supported\n", |
|---|
| 551 | client->adapter->id); |
|---|
| 552 | return 0; |
|---|
| 553 | } |
|---|
| 554 | } |
|---|
| 555 | |
|---|
| 556 | /* +++ frodo |
|---|
| 557 | * return id number for a specific adapter |
|---|
| 558 | */ |
|---|
| 559 | int i2c_adapter_id(struct i2c_adapter *adap) |
|---|
| 560 | { |
|---|
| 561 | int i; |
|---|
| 562 | for (i = 0; i < I2C_ADAP_MAX; i++) |
|---|
| 563 | if (adap == adapters[i]) |
|---|
| 564 | return i; |
|---|
| 565 | return -1; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | /* The SMBus parts */ |
|---|
| 569 | |
|---|
| 570 | extern s32 i2c_smbus_write_quick(struct i2c_adapter * adapter, u8 addr, |
|---|
| 571 | u8 value) |
|---|
| 572 | { |
|---|
| 573 | return i2c_smbus_xfer(adapter,addr,value,0,I2C_SMBUS_QUICK,NULL); |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | extern s32 i2c_smbus_read_byte(struct i2c_adapter * adapter,u8 addr) |
|---|
| 577 | { |
|---|
| 578 | union i2c_smbus_data data; |
|---|
| 579 | if (i2c_smbus_xfer(adapter,addr,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, |
|---|
| 580 | &data)) |
|---|
| 581 | return -1; |
|---|
| 582 | else |
|---|
| 583 | return 0x0FF & data.byte; |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | extern s32 i2c_smbus_write_byte(struct i2c_adapter * adapter, u8 addr, |
|---|
| 587 | u8 value) |
|---|
| 588 | { |
|---|
| 589 | return i2c_smbus_xfer(adapter,addr,I2C_SMBUS_WRITE,value, |
|---|
| 590 | I2C_SMBUS_BYTE,NULL); |
|---|
| 591 | } |
|---|
| 592 | |
|---|
| 593 | extern s32 i2c_smbus_read_byte_data(struct i2c_adapter * adapter, |
|---|
| 594 | u8 addr, u8 command) |
|---|
| 595 | { |
|---|
| 596 | union i2c_smbus_data data; |
|---|
| 597 | if (i2c_smbus_xfer(adapter,addr,I2C_SMBUS_READ,command, |
|---|
| 598 | I2C_SMBUS_BYTE_DATA,&data)) |
|---|
| 599 | return -1; |
|---|
| 600 | else |
|---|
| 601 | return 0x0FF & data.byte; |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | extern s32 i2c_smbus_write_byte_data(struct i2c_adapter * adapter, |
|---|
| 605 | u8 addr, u8 command, u8 value) |
|---|
| 606 | { |
|---|
| 607 | union i2c_smbus_data data; |
|---|
| 608 | data.byte = value; |
|---|
| 609 | return i2c_smbus_xfer(adapter,addr,I2C_SMBUS_WRITE,command, |
|---|
| 610 | I2C_SMBUS_BYTE_DATA,&data); |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | extern s32 i2c_smbus_read_word_data(struct i2c_adapter * adapter, |
|---|
| 614 | u8 addr, u8 command) |
|---|
| 615 | { |
|---|
| 616 | union i2c_smbus_data data; |
|---|
| 617 | if (i2c_smbus_xfer(adapter,addr,I2C_SMBUS_READ,command, |
|---|
| 618 | I2C_SMBUS_WORD_DATA, &data)) |
|---|
| 619 | return -1; |
|---|
| 620 | else |
|---|
| 621 | return 0x0FFFF & data.word; |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | extern s32 i2c_smbus_write_word_data(struct i2c_adapter * adapter, |
|---|
| 625 | u8 addr, u8 command, u16 value) |
|---|
| 626 | { |
|---|
| 627 | union i2c_smbus_data data; |
|---|
| 628 | data.word = value; |
|---|
| 629 | return i2c_smbus_xfer(adapter,addr,I2C_SMBUS_WRITE,command, |
|---|
| 630 | I2C_SMBUS_WORD_DATA,&data); |
|---|
| 631 | } |
|---|
| 632 | |
|---|
| 633 | extern s32 i2c_smbus_process_call(struct i2c_adapter * adapter, |
|---|
| 634 | u8 addr, u8 command, u16 value) |
|---|
| 635 | { |
|---|
| 636 | union i2c_smbus_data data; |
|---|
| 637 | data.word = value; |
|---|
| 638 | if (i2c_smbus_xfer(adapter,addr,I2C_SMBUS_WRITE,command, |
|---|
| 639 | I2C_SMBUS_PROC_CALL, &data)) |
|---|
| 640 | return -1; |
|---|
| 641 | else |
|---|
| 642 | return 0x0FFFF & data.word; |
|---|
| 643 | } |
|---|
| 644 | |
|---|
| 645 | /* Returns the number of read bytes */ |
|---|
| 646 | extern s32 i2c_smbus_read_block_data(struct i2c_adapter * adapter, |
|---|
| 647 | u8 addr, u8 command, u8 *values) |
|---|
| 648 | { |
|---|
| 649 | union i2c_smbus_data data; |
|---|
| 650 | int i; |
|---|
| 651 | if (i2c_smbus_xfer(adapter,addr,I2C_SMBUS_READ,command, |
|---|
| 652 | I2C_SMBUS_BLOCK_DATA,&data)) |
|---|
| 653 | return -1; |
|---|
| 654 | else { |
|---|
| 655 | for (i = 1; i <= data.block[0]; i++) |
|---|
| 656 | values[i-1] = data.block[i]; |
|---|
| 657 | return data.block[0]; |
|---|
| 658 | } |
|---|
| 659 | } |
|---|
| 660 | |
|---|
| 661 | extern s32 i2c_smbus_write_block_data(struct i2c_adapter * adapter, |
|---|
| 662 | u8 addr, u8 command, u8 length, |
|---|
| 663 | u8 *values) |
|---|
| 664 | { |
|---|
| 665 | union i2c_smbus_data data; |
|---|
| 666 | int i; |
|---|
| 667 | if (length > 32) |
|---|
| 668 | length = 32; |
|---|
| 669 | for (i = 1; i <= length; i++) |
|---|
| 670 | data.block[i] = values[i-1]; |
|---|
| 671 | data.block[0] = length; |
|---|
| 672 | return i2c_smbus_xfer(adapter,addr,I2C_SMBUS_WRITE,command, |
|---|
| 673 | I2C_SMBUS_BLOCK_DATA,&data); |
|---|
| 674 | } |
|---|
| 675 | |
|---|
| 676 | /* Simulate a SMBus command using the i2c protocol |
|---|
| 677 | No checking of parameters is done! */ |
|---|
| 678 | static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u8 addr, |
|---|
| 679 | char read_write, u8 command, int size, |
|---|
| 680 | union i2c_smbus_data * data) |
|---|
| 681 | { |
|---|
| 682 | /* So we need to generate a series of msgs. In the case of writing, we |
|---|
| 683 | need to use only one message; when reading, we need two. We initialize |
|---|
| 684 | most things with sane defaults, to keep the code below somewhat |
|---|
| 685 | simpler. */ |
|---|
| 686 | unsigned char msgbuf0[33]; |
|---|
| 687 | unsigned char msgbuf1[33]; |
|---|
| 688 | int num = read_write == I2C_SMBUS_READ?2:1; |
|---|
| 689 | struct i2c_msg msg[2] = { { addr, 0, 1, msgbuf0 }, |
|---|
| 690 | { addr, I2C_M_RD, 0, msgbuf1 } |
|---|
| 691 | }; |
|---|
| 692 | int i; |
|---|
| 693 | |
|---|
| 694 | msgbuf0[0] = command; |
|---|
| 695 | switch(size) { |
|---|
| 696 | case I2C_SMBUS_QUICK: |
|---|
| 697 | msg[0].len = 0; |
|---|
| 698 | num = 1; /* Special case: The read/write field is used |
|---|
| 699 | as data */ |
|---|
| 700 | break; |
|---|
| 701 | case I2C_SMBUS_BYTE: |
|---|
| 702 | if (read_write == I2C_SMBUS_READ) { |
|---|
| 703 | /* Special case: only a read! */ |
|---|
| 704 | msg[0].flags = I2C_M_RD; |
|---|
| 705 | num = 1; |
|---|
| 706 | } |
|---|
| 707 | break; |
|---|
| 708 | case I2C_SMBUS_BYTE_DATA: |
|---|
| 709 | if (read_write == I2C_SMBUS_READ) |
|---|
| 710 | msg[1].len = 1; |
|---|
| 711 | else { |
|---|
| 712 | msg[0].len = 2; |
|---|
| 713 | msgbuf0[1] = data->byte; |
|---|
| 714 | } |
|---|
| 715 | break; |
|---|
| 716 | case I2C_SMBUS_WORD_DATA: |
|---|
| 717 | if (read_write == I2C_SMBUS_READ) |
|---|
| 718 | msg[1].len = 2; |
|---|
| 719 | else { |
|---|
| 720 | msg[0].len=3; |
|---|
| 721 | msgbuf0[1] = data->word & 0xff; |
|---|
| 722 | msgbuf0[2] = (data->word >> 8) & 0xff; |
|---|
| 723 | } |
|---|
| 724 | break; |
|---|
| 725 | case I2C_SMBUS_PROC_CALL: |
|---|
| 726 | num = 2; /* Special case */ |
|---|
| 727 | msg[0].len = 3; |
|---|
| 728 | msg[1].len = 2; |
|---|
| 729 | msgbuf0[1] = data->word & 0xff; |
|---|
| 730 | msgbuf0[2] = (data->word >> 8) & 0xff; |
|---|
| 731 | break; |
|---|
| 732 | case I2C_SMBUS_BLOCK_DATA: |
|---|
| 733 | if (read_write == I2C_SMBUS_READ) { |
|---|
| 734 | printk("smbus.o: Block read not supported under " |
|---|
| 735 | "I2C emulation!\n"); |
|---|
| 736 | return -1; |
|---|
| 737 | } else { |
|---|
| 738 | msg[1].len = data->block[0] + 1; |
|---|
| 739 | if (msg[1].len > 32) { |
|---|
| 740 | printk("smbus.o: smbus_access called with " |
|---|
| 741 | "invalid block write size (%d)\n", |
|---|
| 742 | msg[1].len); |
|---|
| 743 | return -1; |
|---|
| 744 | } |
|---|
| 745 | for (i = 1; i <= msg[1].len; i++) |
|---|
| 746 | msgbuf0[i] = data->block[i]; |
|---|
| 747 | } |
|---|
| 748 | break; |
|---|
| 749 | default: |
|---|
| 750 | printk("smbus.o: smbus_access called with invalid size (%d)\n", |
|---|
| 751 | size); |
|---|
| 752 | return -1; |
|---|
| 753 | } |
|---|
| 754 | |
|---|
| 755 | if (i2c_transfer(adapter, msg, num) < 0) |
|---|
| 756 | return -1; |
|---|
| 757 | |
|---|
| 758 | if (read_write == I2C_SMBUS_READ) |
|---|
| 759 | switch(size) { |
|---|
| 760 | case I2C_SMBUS_BYTE: |
|---|
| 761 | data->byte = msgbuf0[0]; |
|---|
| 762 | break; |
|---|
| 763 | case I2C_SMBUS_BYTE_DATA: |
|---|
| 764 | data->byte = msgbuf1[0]; |
|---|
| 765 | break; |
|---|
| 766 | case I2C_SMBUS_WORD_DATA: |
|---|
| 767 | case I2C_SMBUS_PROC_CALL: |
|---|
| 768 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); |
|---|
| 769 | break; |
|---|
| 770 | } |
|---|
| 771 | return 0; |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | |
|---|
| 775 | s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u8 addr, char read_write, |
|---|
| 776 | u8 command, int size, union i2c_smbus_data * data) |
|---|
| 777 | { |
|---|
| 778 | s32 res; |
|---|
| 779 | if (adapter->algo->smbus_xfer) { |
|---|
| 780 | down(&adapter->lock); |
|---|
| 781 | res = adapter->algo->smbus_xfer(adapter,addr,read_write, |
|---|
| 782 | command,size,data); |
|---|
| 783 | up(&adapter->lock); |
|---|
| 784 | } else |
|---|
| 785 | res = i2c_smbus_xfer_emulated(adapter,addr,read_write, |
|---|
| 786 | command,size,data); |
|---|
| 787 | return res; |
|---|
| 788 | } |
|---|
| 789 | |
|---|
| 790 | |
|---|
| 791 | int __init i2c_init(void) |
|---|
| 792 | { |
|---|
| 793 | /* clear algorithms */ |
|---|
| 794 | memset(algorithms,0,sizeof(algorithms)); |
|---|
| 795 | memset(adapters,0,sizeof(adapters)); |
|---|
| 796 | memset(drivers,0,sizeof(drivers)); |
|---|
| 797 | algo_count=0; |
|---|
| 798 | adap_count=0; |
|---|
| 799 | driver_count=0; |
|---|
| 800 | |
|---|
| 801 | printk(KERN_INFO "i2c module initialized.\n"); |
|---|
| 802 | return 0; |
|---|
| 803 | } |
|---|
| 804 | |
|---|
| 805 | #ifndef MODULE |
|---|
| 806 | #ifdef CONFIG_I2C_CHARDEV |
|---|
| 807 | extern int i2cdev_init(void); |
|---|
| 808 | #endif |
|---|
| 809 | #ifdef CONFIG_I2C_ALGOBIT |
|---|
| 810 | extern int algo_bit_init(void); |
|---|
| 811 | #endif |
|---|
| 812 | #ifdef CONFIG_I2C_BITLP |
|---|
| 813 | extern int bitlp_init(void); |
|---|
| 814 | #endif |
|---|
| 815 | #ifdef CONFIG_I2C_BITELV |
|---|
| 816 | extern int bitelv_init(void); |
|---|
| 817 | #endif |
|---|
| 818 | #ifdef CONFIG_I2C_BITVELLE |
|---|
| 819 | extern int bitvelle_init(void); |
|---|
| 820 | #endif |
|---|
| 821 | #ifdef CONFIG_I2C_BITVIA |
|---|
| 822 | extern int bitvia_init(void); |
|---|
| 823 | #endif |
|---|
| 824 | |
|---|
| 825 | #ifdef CONFIG_I2C_ALGOPCF |
|---|
| 826 | extern int algo_pcf_init(void); |
|---|
| 827 | #endif |
|---|
| 828 | #ifdef CONFIG_I2C_PCFISA |
|---|
| 829 | extern int pcfisa_init(void); |
|---|
| 830 | #endif |
|---|
| 831 | |
|---|
| 832 | |
|---|
| 833 | int simons_i2c_init(void) |
|---|
| 834 | { |
|---|
| 835 | /* --------------------- global ----- */ |
|---|
| 836 | i2c_init(); |
|---|
| 837 | |
|---|
| 838 | #ifdef CONFIG_I2C_CHARDEV |
|---|
| 839 | i2cdev_init(); |
|---|
| 840 | #endif |
|---|
| 841 | /* --------------------- bit -------- */ |
|---|
| 842 | #ifdef CONFIG_I2C_ALGOBIT |
|---|
| 843 | algo_bit_init(); |
|---|
| 844 | #endif |
|---|
| 845 | #ifdef CONFIG_I2C_BITLP |
|---|
| 846 | bitlp_init(); |
|---|
| 847 | #endif |
|---|
| 848 | #ifdef CONFIG_I2C_BITELV |
|---|
| 849 | bitelv_init(); |
|---|
| 850 | #endif |
|---|
| 851 | #ifdef CONFIG_I2C_BITVELLE |
|---|
| 852 | bitvelle_init(); |
|---|
| 853 | #endif |
|---|
| 854 | #ifdef CONFIG_I2C_BITVIA |
|---|
| 855 | bitvia_init(); |
|---|
| 856 | #endif |
|---|
| 857 | |
|---|
| 858 | /* --------------------- pcf -------- */ |
|---|
| 859 | #ifdef CONFIG_I2C_ALGOPCF |
|---|
| 860 | algo_pcf_init(); |
|---|
| 861 | #endif |
|---|
| 862 | #ifdef CONFIG_I2C_PCFISA |
|---|
| 863 | pcfisa_init(); |
|---|
| 864 | #endif |
|---|
| 865 | return 0; |
|---|
| 866 | } |
|---|
| 867 | |
|---|
| 868 | #endif |
|---|
| 869 | |
|---|
| 870 | |
|---|
| 871 | #ifdef MODULE |
|---|
| 872 | MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); |
|---|
| 873 | MODULE_DESCRIPTION("I2C-Bus main module"); |
|---|
| 874 | MODULE_PARM(i2c_debug, "i"); |
|---|
| 875 | MODULE_PARM_DESC(i2c_debug,"debug level"); |
|---|
| 876 | |
|---|
| 877 | EXPORT_SYMBOL(i2c_add_algorithm); |
|---|
| 878 | EXPORT_SYMBOL(i2c_del_algorithm); |
|---|
| 879 | EXPORT_SYMBOL(i2c_add_adapter); |
|---|
| 880 | EXPORT_SYMBOL(i2c_del_adapter); |
|---|
| 881 | EXPORT_SYMBOL(i2c_add_driver); |
|---|
| 882 | EXPORT_SYMBOL(i2c_del_driver); |
|---|
| 883 | EXPORT_SYMBOL(i2c_attach_client); |
|---|
| 884 | EXPORT_SYMBOL(i2c_detach_client); |
|---|
| 885 | EXPORT_SYMBOL(i2c_inc_use_client); |
|---|
| 886 | EXPORT_SYMBOL(i2c_dec_use_client); |
|---|
| 887 | |
|---|
| 888 | |
|---|
| 889 | EXPORT_SYMBOL(i2c_master_send); |
|---|
| 890 | EXPORT_SYMBOL(i2c_master_recv); |
|---|
| 891 | EXPORT_SYMBOL(i2c_master_send_subadress); |
|---|
| 892 | EXPORT_SYMBOL(i2c_master_recv_subadress); |
|---|
| 893 | EXPORT_SYMBOL(i2c_control); |
|---|
| 894 | EXPORT_SYMBOL(i2c_transfer); |
|---|
| 895 | |
|---|
| 896 | EXPORT_SYMBOL(i2c_smbus_xfer); |
|---|
| 897 | EXPORT_SYMBOL(i2c_smbus_write_quick); |
|---|
| 898 | EXPORT_SYMBOL(i2c_smbus_read_byte); |
|---|
| 899 | EXPORT_SYMBOL(i2c_smbus_write_byte); |
|---|
| 900 | EXPORT_SYMBOL(i2c_smbus_read_byte_data); |
|---|
| 901 | EXPORT_SYMBOL(i2c_smbus_write_byte_data); |
|---|
| 902 | EXPORT_SYMBOL(i2c_smbus_read_word_data); |
|---|
| 903 | EXPORT_SYMBOL(i2c_smbus_write_word_data); |
|---|
| 904 | EXPORT_SYMBOL(i2c_smbus_process_call); |
|---|
| 905 | EXPORT_SYMBOL(i2c_smbus_read_block_data); |
|---|
| 906 | EXPORT_SYMBOL(i2c_smbus_write_block_data); |
|---|
| 907 | |
|---|
| 908 | int init_module(void) |
|---|
| 909 | { |
|---|
| 910 | return i2c_init(); |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | void cleanup_module(void) |
|---|
| 914 | { |
|---|
| 915 | } |
|---|
| 916 | #endif |
|---|