OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [i2c/] [i2c-keywest.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#ifndef __I2C_KEYWEST_H__
2
#define __I2C_KEYWEST_H__
3
 
4
/* The Tumbler audio equalizer can be really slow sometimes */
5
#define POLL_TIMEOUT            (2*HZ)
6
 
7
/* Register indices */
8
typedef enum {
9
        reg_mode = 0,
10
        reg_control,
11
        reg_status,
12
        reg_isr,
13
        reg_ier,
14
        reg_addr,
15
        reg_subaddr,
16
        reg_data
17
} reg_t;
18
 
19
 
20
/* Mode register */
21
#define KW_I2C_MODE_100KHZ      0x00
22
#define KW_I2C_MODE_50KHZ       0x01
23
#define KW_I2C_MODE_25KHZ       0x02
24
#define KW_I2C_MODE_DUMB        0x00
25
#define KW_I2C_MODE_STANDARD    0x04
26
#define KW_I2C_MODE_STANDARDSUB 0x08
27
#define KW_I2C_MODE_COMBINED    0x0C
28
#define KW_I2C_MODE_MODE_MASK   0x0C
29
#define KW_I2C_MODE_CHAN_MASK   0xF0
30
 
31
/* Control register */
32
#define KW_I2C_CTL_AAK          0x01
33
#define KW_I2C_CTL_XADDR        0x02
34
#define KW_I2C_CTL_STOP         0x04
35
#define KW_I2C_CTL_START        0x08
36
 
37
/* Status register */
38
#define KW_I2C_STAT_BUSY        0x01
39
#define KW_I2C_STAT_LAST_AAK    0x02
40
#define KW_I2C_STAT_LAST_RW     0x04
41
#define KW_I2C_STAT_SDA         0x08
42
#define KW_I2C_STAT_SCL         0x10
43
 
44
/* IER & ISR registers */
45
#define KW_I2C_IRQ_DATA         0x01
46
#define KW_I2C_IRQ_ADDR         0x02
47
#define KW_I2C_IRQ_STOP         0x04
48
#define KW_I2C_IRQ_START        0x08
49
#define KW_I2C_IRQ_MASK         0x0F
50
 
51
/* Physical interface */
52
struct keywest_iface
53
{
54
        unsigned long           base;
55
        unsigned                bsteps;
56
        int                     irq;
57
        struct semaphore        sem;
58
        spinlock_t              lock;
59
        struct keywest_chan*    channels;
60
        unsigned                chan_count;
61
        u8                      cur_mode;
62
        char                    read_write;
63
        u8*                     data;
64
        unsigned                datalen;
65
        int                     state;
66
        int                     result;
67
        int                     stopretry;
68
        struct timer_list       timeout_timer;
69
        struct completion       complete;
70
        struct keywest_iface*   next;
71
};
72
 
73
enum {
74
        state_idle,
75
        state_addr,
76
        state_read,
77
        state_write,
78
        state_stop,
79
        state_dead
80
};
81
 
82
/* Channel on an interface */
83
struct keywest_chan
84
{
85
        struct i2c_adapter      adapter;
86
        struct keywest_iface*   iface;
87
        unsigned                chan_no;
88
};
89
 
90
/* Register access */
91
 
92
static inline u8 __read_reg(struct keywest_iface *iface, reg_t reg)
93
{
94
        return in_8(((volatile u8 *)iface->base)
95
                + (((unsigned)reg) << iface->bsteps));
96
}
97
 
98
static inline void __write_reg(struct keywest_iface *iface, reg_t reg, u8 val)
99
{
100
        out_8(((volatile u8 *)iface->base)
101
                + (((unsigned)reg) << iface->bsteps), val);
102
        (void)__read_reg(iface, reg);
103
        udelay(10);
104
}
105
 
106
#define write_reg(reg, val)     __write_reg(iface, reg, val) 
107
#define read_reg(reg)           __read_reg(iface, reg) 
108
 
109
 
110
 
111
#endif /* __I2C_KEYWEST_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.