diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2008-04-22 16:16:46 -0400 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2008-04-22 16:16:46 -0400 |
commit | c01b0831057381c7f6e0bfb3634bac8c5f7fb256 (patch) | |
tree | 43fb4c2d626df0c32f3196c81062592ab60ccd12 /include/linux | |
parent | 3d4382913f9a86f0d9ff47740feb427415fe7234 (diff) |
i2c-algo-pca: Extend for future drivers
The separation between algorithm and adapter was unsharp at places. This was
partly hidden by the fact, that the ISA-driver allowed just one instance and
had all private data in static variables. This patch makes neccessary
preparations to add a platform driver on top of the algorithm, while still
supporting ISA. Note: Due to lack of hardware, the ISA-driver could not be
tested except that it builds.
Concerning the core struct i2c_algo_pca_data:
- A private data field was added, all hardware dependant data may go here.
Similar to other algorithms, now a pointer to this data is passed to the
adapter's functions. In order to make as less changes as possible to the
ISA-driver, it leaves the private data empty and still only uses its static
variables.
- A "reset_chip" function pointer was added; such a functionality must come
from the adapter, not the algorithm.
- use a variable "i2c_clock" instead of a function pointer "get_clock",
allowing for write access to a default in case a wrong value was supplied.
In the algorithm-file:
- move "i2c-pca-algo.h" into "linux/i2c-algo-pca.h"
- now using per_instance timeout values (i2c_adap->timeout)
- error messages specify the device, not only the driver name
- restructure initialization to easily support "i2c_add_numbered_adapter"
- drop "retries" and "own" (i2c address) as they were unused
(The state-machine for I2C-communication was not touched.)
In the ISA-driver:
- adapt to new algorithm
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/i2c-algo-pca.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h index fce47c051bb1..adcb3dc7ac26 100644 --- a/include/linux/i2c-algo-pca.h +++ b/include/linux/i2c-algo-pca.h | |||
@@ -1,14 +1,41 @@ | |||
1 | #ifndef _LINUX_I2C_ALGO_PCA_H | 1 | #ifndef _LINUX_I2C_ALGO_PCA_H |
2 | #define _LINUX_I2C_ALGO_PCA_H | 2 | #define _LINUX_I2C_ALGO_PCA_H |
3 | 3 | ||
4 | /* Clock speeds for the bus */ | ||
5 | #define I2C_PCA_CON_330kHz 0x00 | ||
6 | #define I2C_PCA_CON_288kHz 0x01 | ||
7 | #define I2C_PCA_CON_217kHz 0x02 | ||
8 | #define I2C_PCA_CON_146kHz 0x03 | ||
9 | #define I2C_PCA_CON_88kHz 0x04 | ||
10 | #define I2C_PCA_CON_59kHz 0x05 | ||
11 | #define I2C_PCA_CON_44kHz 0x06 | ||
12 | #define I2C_PCA_CON_36kHz 0x07 | ||
13 | |||
14 | /* PCA9564 registers */ | ||
15 | #define I2C_PCA_STA 0x00 /* STATUS Read Only */ | ||
16 | #define I2C_PCA_TO 0x00 /* TIMEOUT Write Only */ | ||
17 | #define I2C_PCA_DAT 0x01 /* DATA Read/Write */ | ||
18 | #define I2C_PCA_ADR 0x02 /* OWN ADR Read/Write */ | ||
19 | #define I2C_PCA_CON 0x03 /* CONTROL Read/Write */ | ||
20 | |||
21 | #define I2C_PCA_CON_AA 0x80 /* Assert Acknowledge */ | ||
22 | #define I2C_PCA_CON_ENSIO 0x40 /* Enable */ | ||
23 | #define I2C_PCA_CON_STA 0x20 /* Start */ | ||
24 | #define I2C_PCA_CON_STO 0x10 /* Stop */ | ||
25 | #define I2C_PCA_CON_SI 0x08 /* Serial Interrupt */ | ||
26 | #define I2C_PCA_CON_CR 0x07 /* Clock Rate (MASK) */ | ||
27 | |||
4 | struct i2c_algo_pca_data { | 28 | struct i2c_algo_pca_data { |
5 | int (*get_own) (struct i2c_algo_pca_data *adap); /* Obtain own address */ | 29 | void *data; /* private low level data */ |
6 | int (*get_clock) (struct i2c_algo_pca_data *adap); | 30 | void (*write_byte) (void *data, int reg, int val); |
7 | void (*write_byte) (struct i2c_algo_pca_data *adap, int reg, int val); | 31 | int (*read_byte) (void *data, int reg); |
8 | int (*read_byte) (struct i2c_algo_pca_data *adap, int reg); | 32 | int (*wait_for_completion) (void *data); |
9 | int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap); | 33 | void (*reset_chip) (void *data); |
34 | /* i2c_clock values are defined in linux/i2c-algo-pca.h */ | ||
35 | unsigned int i2c_clock; | ||
10 | }; | 36 | }; |
11 | 37 | ||
12 | int i2c_pca_add_bus(struct i2c_adapter *); | 38 | int i2c_pca_add_bus(struct i2c_adapter *); |
39 | int i2c_pca_add_numbered_bus(struct i2c_adapter *); | ||
13 | 40 | ||
14 | #endif /* _LINUX_I2C_ALGO_PCA_H */ | 41 | #endif /* _LINUX_I2C_ALGO_PCA_H */ |