Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.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 #include <linux/config.h>
8
9 enum crisv32_io_dir
10 {
11   crisv32_io_dir_in = 0,
12   crisv32_io_dir_out = 1
13 };
14
15 struct crisv32_ioport
16 {
17   unsigned long* oe;
18   unsigned long* data;
19   unsigned long* data_in;
20   unsigned int pin_count;
21 };
22
23 struct crisv32_iopin
24 {
25   struct crisv32_ioport* port;
26   int bit;
27 };
28
29 extern struct crisv32_ioport crisv32_ioports[];
30
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;
37
38 extern inline void crisv32_io_set(struct crisv32_iopin* iopin,
39                            int val)
40 {
41         if (val)
42                 *iopin->port->data |= iopin->bit;
43         else
44                 *iopin->port->data &= ~iopin->bit;
45 }
46
47 extern inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
48                                enum crisv32_io_dir dir)
49 {
50         if (dir == crisv32_io_dir_in)
51                 *iopin->port->oe &= ~iopin->bit;
52         else
53                 *iopin->port->oe |= iopin->bit;
54 }
55
56 extern inline int crisv32_io_rd(struct crisv32_iopin* iopin)
57 {
58         return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
59 }
60
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);
65
66 #define LED_OFF    0x00
67 #define LED_GREEN  0x01
68 #define LED_RED    0x02
69 #define LED_ORANGE (LED_GREEN | LED_RED)
70
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)
81
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));
97
98 #endif