Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / include / asm-cris / arch-v32 / io.h
1 #ifndef _ASM_ARCH_CRIS_IO_H
2 #define _ASM_ARCH_CRIS_IO_H
3
4 #include <asm/arch/hwregs/reg_map.h>
5 #include <asm/arch/hwregs/reg_rdwr.h>
6 #include <asm/arch/hwregs/gio_defs.h>
7
8 enum crisv32_io_dir
9 {
10   crisv32_io_dir_in = 0,
11   crisv32_io_dir_out = 1
12 };
13
14 struct crisv32_ioport
15 {
16   unsigned long* oe;
17   unsigned long* data;
18   unsigned long* data_in;
19   unsigned int pin_count;
20 };
21
22 struct crisv32_iopin
23 {
24   struct crisv32_ioport* port;
25   int bit;
26 };
27
28 extern struct crisv32_ioport crisv32_ioports[];
29
30 extern struct crisv32_iopin crisv32_led1_green;
31 extern struct crisv32_iopin crisv32_led1_red;
32 extern struct crisv32_iopin crisv32_led2_green;
33 extern struct crisv32_iopin crisv32_led2_red;
34 extern struct crisv32_iopin crisv32_led3_green;
35 extern struct crisv32_iopin crisv32_led3_red;
36
37 static inline void crisv32_io_set(struct crisv32_iopin* iopin,
38                            int val)
39 {
40         if (val)
41                 *iopin->port->data |= iopin->bit;
42         else
43                 *iopin->port->data &= ~iopin->bit;
44 }
45
46 static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
47                                enum crisv32_io_dir dir)
48 {
49         if (dir == crisv32_io_dir_in)
50                 *iopin->port->oe &= ~iopin->bit;
51         else
52                 *iopin->port->oe |= iopin->bit;
53 }
54
55 static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
56 {
57         return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
58 }
59
60 int crisv32_io_get(struct crisv32_iopin* iopin,
61                    unsigned int port, unsigned int pin);
62 int crisv32_io_get_name(struct crisv32_iopin* iopin,
63                          char* name);
64
65 #define LED_OFF    0x00
66 #define LED_GREEN  0x01
67 #define LED_RED    0x02
68 #define LED_ORANGE (LED_GREEN | LED_RED)
69
70 #define LED_NETWORK_SET(x)                          \
71         do {                                        \
72                 LED_NETWORK_SET_G((x) & LED_GREEN); \
73                 LED_NETWORK_SET_R((x) & LED_RED);   \
74         } while (0)
75 #define LED_ACTIVE_SET(x)                           \
76         do {                                        \
77                 LED_ACTIVE_SET_G((x) & LED_GREEN);  \
78                 LED_ACTIVE_SET_R((x) & LED_RED);    \
79         } while (0)
80
81 #define LED_NETWORK_SET_G(x) \
82         crisv32_io_set(&crisv32_led1_green, !(x));
83 #define LED_NETWORK_SET_R(x) \
84         crisv32_io_set(&crisv32_led1_red, !(x));
85 #define LED_ACTIVE_SET_G(x) \
86         crisv32_io_set(&crisv32_led2_green, !(x));
87 #define LED_ACTIVE_SET_R(x) \
88         crisv32_io_set(&crisv32_led2_red, !(x));
89 #define LED_DISK_WRITE(x) \
90          do{\
91                 crisv32_io_set(&crisv32_led3_green, !(x)); \
92                 crisv32_io_set(&crisv32_led3_red, !(x));   \
93         }while(0)
94 #define LED_DISK_READ(x) \
95         crisv32_io_set(&crisv32_led3_green, !(x));
96
97 #endif