aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-06-15 07:38:14 -0400
committerRussell King <rmk@dyn-67.arm.linux.org.uk>2005-06-15 07:38:14 -0400
commitb652b438fcad4c9c079d0774e9d45ee58fae22e2 (patch)
tree8911e5232e55f436491f24d19d802c4f49d7749c /include
parentc0105338eb4e61e537ca34ae06921177cb6efcf0 (diff)
[PATCH] I2C: Add PXA I2C driver
Add support for the I2C PXA driver. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/arch-pxa/i2c.h70
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/i2c-pxa.h48
3 files changed, 119 insertions, 0 deletions
diff --git a/include/asm-arm/arch-pxa/i2c.h b/include/asm-arm/arch-pxa/i2c.h
new file mode 100644
index 000000000000..46ec2243974a
--- /dev/null
+++ b/include/asm-arm/arch-pxa/i2c.h
@@ -0,0 +1,70 @@
1/*
2 * i2c_pxa.h
3 *
4 * Copyright (C) 2002 Intrinsyc Software Inc.
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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11#ifndef _I2C_PXA_H_
12#define _I2C_PXA_H_
13
14#if 0
15#define DEF_TIMEOUT 3
16#else
17/* need a longer timeout if we're dealing with the fact we may well be
18 * looking at a multi-master environment
19*/
20#define DEF_TIMEOUT 32
21#endif
22
23#define BUS_ERROR (-EREMOTEIO)
24#define XFER_NAKED (-ECONNREFUSED)
25#define I2C_RETRY (-2000) /* an error has occurred retry transmit */
26
27/* ICR initialize bit values
28*
29* 15. FM 0 (100 Khz operation)
30* 14. UR 0 (No unit reset)
31* 13. SADIE 0 (Disables the unit from interrupting on slave addresses
32* matching its slave address)
33* 12. ALDIE 0 (Disables the unit from interrupt when it loses arbitration
34* in master mode)
35* 11. SSDIE 0 (Disables interrupts from a slave stop detected, in slave mode)
36* 10. BEIE 1 (Enable interrupts from detected bus errors, no ACK sent)
37* 9. IRFIE 1 (Enable interrupts from full buffer received)
38* 8. ITEIE 1 (Enables the I2C unit to interrupt when transmit buffer empty)
39* 7. GCD 1 (Disables i2c unit response to general call messages as a slave)
40* 6. IUE 0 (Disable unit until we change settings)
41* 5. SCLE 1 (Enables the i2c clock output for master mode (drives SCL)
42* 4. MA 0 (Only send stop with the ICR stop bit)
43* 3. TB 0 (We are not transmitting a byte initially)
44* 2. ACKNAK 0 (Send an ACK after the unit receives a byte)
45* 1. STOP 0 (Do not send a STOP)
46* 0. START 0 (Do not send a START)
47*
48*/
49#define I2C_ICR_INIT (ICR_BEIE | ICR_IRFIE | ICR_ITEIE | ICR_GCD | ICR_SCLE)
50
51/* I2C status register init values
52 *
53 * 10. BED 1 (Clear bus error detected)
54 * 9. SAD 1 (Clear slave address detected)
55 * 7. IRF 1 (Clear IDBR Receive Full)
56 * 6. ITE 1 (Clear IDBR Transmit Empty)
57 * 5. ALD 1 (Clear Arbitration Loss Detected)
58 * 4. SSD 1 (Clear Slave Stop Detected)
59 */
60#define I2C_ISR_INIT 0x7FF /* status register init */
61
62struct i2c_slave_client;
63
64struct i2c_pxa_platform_data {
65 unsigned int slave_addr;
66 struct i2c_slave_client *slave;
67};
68
69extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
70#endif
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 89270ce51470..74d6dc942715 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -203,6 +203,7 @@
203#define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */ 203#define I2C_ALGO_MV64XXX 0x190000 /* Marvell mv64xxx i2c ctlr */
204#define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */ 204#define I2C_ALGO_PCA 0x1a0000 /* PCA 9564 style adapters */
205#define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */ 205#define I2C_ALGO_AU1550 0x1b0000 /* Au1550 PSC algorithm */
206#define I2C_ALGO_PXA 0x1c0000 /* Intel PXA I2C algorithm */
206 207
207#define I2C_ALGO_EXP 0x800000 /* experimental */ 208#define I2C_ALGO_EXP 0x800000 /* experimental */
208 209
diff --git a/include/linux/i2c-pxa.h b/include/linux/i2c-pxa.h
new file mode 100644
index 000000000000..5f3eaf802223
--- /dev/null
+++ b/include/linux/i2c-pxa.h
@@ -0,0 +1,48 @@
1#ifndef _LINUX_I2C_ALGO_PXA_H
2#define _LINUX_I2C_ALGO_PXA_H
3
4struct i2c_eeprom_emu_watcher {
5 void (*write)(void *, unsigned int addr, unsigned char newval);
6};
7
8struct i2c_eeprom_emu_watch {
9 struct list_head node;
10 unsigned int start;
11 unsigned int end;
12 struct i2c_eeprom_emu_watcher *ops;
13 void *data;
14};
15
16#define I2C_EEPROM_EMU_SIZE (256)
17
18struct i2c_eeprom_emu {
19 unsigned int size;
20 unsigned int ptr;
21 unsigned int seen_start;
22 struct list_head watch;
23
24 unsigned char bytes[I2C_EEPROM_EMU_SIZE];
25};
26
27typedef enum i2c_slave_event_e {
28 I2C_SLAVE_EVENT_START_READ,
29 I2C_SLAVE_EVENT_START_WRITE,
30 I2C_SLAVE_EVENT_STOP
31} i2c_slave_event_t;
32
33struct i2c_slave_client {
34 void *data;
35 void (*event)(void *ptr, i2c_slave_event_t event);
36 int (*read) (void *ptr);
37 void (*write)(void *ptr, unsigned int val);
38};
39
40extern int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *, void *data,
41 unsigned int addr, unsigned int size,
42 struct i2c_eeprom_emu_watcher *);
43
44extern void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *, void *data, struct i2c_eeprom_emu_watcher *watcher);
45
46extern struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void);
47
48#endif /* _LINUX_I2C_ALGO_PXA_H */