Linux v2.6.15-rc6
[pohmelfs.git] / include / asm-cris / arch-v32 / io.h
blob043c9ce5294e9192ee00e0aa75edf9eb94f4c33e
1 #ifndef _ASM_ARCH_CRIS_IO_H
2 #define _ASM_ARCH_CRIS_IO_H
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 #include <linux/config.h>
9 enum crisv32_io_dir
11 crisv32_io_dir_in = 0,
12 crisv32_io_dir_out = 1
15 struct crisv32_ioport
17 unsigned long* oe;
18 unsigned long* data;
19 unsigned long* data_in;
20 unsigned int pin_count;
23 struct crisv32_iopin
25 struct crisv32_ioport* port;
26 int bit;
29 extern struct crisv32_ioport crisv32_ioports[];
31 extern struct crisv32_iopin crisv32_led1_green;
32 extern struct crisv32_iopin crisv32_led1_red;
33 extern struct crisv32_iopin crisv32_led2_green;
34 extern struct crisv32_iopin crisv32_led2_red;
35 extern struct crisv32_iopin crisv32_led3_green;
36 extern struct crisv32_iopin crisv32_led3_red;
38 static inline void crisv32_io_set(struct crisv32_iopin* iopin,
39 int val)
41 if (val)
42 *iopin->port->data |= iopin->bit;
43 else
44 *iopin->port->data &= ~iopin->bit;
47 static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
48 enum crisv32_io_dir dir)
50 if (dir == crisv32_io_dir_in)
51 *iopin->port->oe &= ~iopin->bit;
52 else
53 *iopin->port->oe |= iopin->bit;
56 static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
58 return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
61 int crisv32_io_get(struct crisv32_iopin* iopin,
62 unsigned int port, unsigned int pin);
63 int crisv32_io_get_name(struct crisv32_iopin* iopin,
64 char* name);
66 #define LED_OFF 0x00
67 #define LED_GREEN 0x01
68 #define LED_RED 0x02
69 #define LED_ORANGE (LED_GREEN | LED_RED)
71 #define LED_NETWORK_SET(x) \
72 do { \
73 LED_NETWORK_SET_G((x) & LED_GREEN); \
74 LED_NETWORK_SET_R((x) & LED_RED); \
75 } while (0)
76 #define LED_ACTIVE_SET(x) \
77 do { \
78 LED_ACTIVE_SET_G((x) & LED_GREEN); \
79 LED_ACTIVE_SET_R((x) & LED_RED); \
80 } while (0)
82 #define LED_NETWORK_SET_G(x) \
83 crisv32_io_set(&crisv32_led1_green, !(x));
84 #define LED_NETWORK_SET_R(x) \
85 crisv32_io_set(&crisv32_led1_red, !(x));
86 #define LED_ACTIVE_SET_G(x) \
87 crisv32_io_set(&crisv32_led2_green, !(x));
88 #define LED_ACTIVE_SET_R(x) \
89 crisv32_io_set(&crisv32_led2_red, !(x));
90 #define LED_DISK_WRITE(x) \
91 do{\
92 crisv32_io_set(&crisv32_led3_green, !(x)); \
93 crisv32_io_set(&crisv32_led3_red, !(x)); \
94 }while(0)
95 #define LED_DISK_READ(x) \
96 crisv32_io_set(&crisv32_led3_green, !(x));
98 #endif