]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/asm-cris/arch-v32/io.h
[CRISv32] Remove warning in io.h
[net-next-2.6.git] / include / asm-cris / arch-v32 / io.h
CommitLineData
51533b61
MS
1#ifndef _ASM_ARCH_CRIS_IO_H
2#define _ASM_ARCH_CRIS_IO_H
3
d8ca6b15
JN
4#include <linux/spinlock.h>
5#include <hwregs/reg_map.h>
6#include <hwregs/reg_rdwr.h>
7#include <hwregs/gio_defs.h>
51533b61
MS
8
9enum crisv32_io_dir
10{
11 crisv32_io_dir_in = 0,
12 crisv32_io_dir_out = 1
13};
14
15struct crisv32_ioport
16{
d8ca6b15
JN
17 volatile unsigned long *oe;
18 volatile unsigned long *data;
19 volatile unsigned long *data_in;
51533b61 20 unsigned int pin_count;
d8ca6b15 21 spinlock_t lock;
51533b61
MS
22};
23
24struct crisv32_iopin
25{
26 struct crisv32_ioport* port;
27 int bit;
28};
29
30extern struct crisv32_ioport crisv32_ioports[];
31
32extern struct crisv32_iopin crisv32_led1_green;
33extern struct crisv32_iopin crisv32_led1_red;
34extern struct crisv32_iopin crisv32_led2_green;
35extern struct crisv32_iopin crisv32_led2_red;
36extern struct crisv32_iopin crisv32_led3_green;
37extern struct crisv32_iopin crisv32_led3_red;
38
d8ca6b15
JN
39extern struct crisv32_iopin crisv32_led_net0_green;
40extern struct crisv32_iopin crisv32_led_net0_red;
41extern struct crisv32_iopin crisv32_led_net1_green;
42extern struct crisv32_iopin crisv32_led_net1_red;
43
0d9f2e6f 44static inline void crisv32_io_set(struct crisv32_iopin *iopin, int val)
51533b61 45{
a54373ee 46 unsigned long flags;
d8ca6b15
JN
47 spin_lock_irqsave(&iopin->port->lock, flags);
48
51533b61
MS
49 if (val)
50 *iopin->port->data |= iopin->bit;
51 else
52 *iopin->port->data &= ~iopin->bit;
d8ca6b15
JN
53
54 spin_unlock_irqrestore(&iopin->port->lock, flags);
51533b61
MS
55}
56
d9b5444e 57static inline void crisv32_io_set_dir(struct crisv32_iopin* iopin,
51533b61
MS
58 enum crisv32_io_dir dir)
59{
a54373ee 60 unsigned long flags;
d8ca6b15
JN
61 spin_lock_irqsave(&iopin->port->lock, flags);
62
51533b61
MS
63 if (dir == crisv32_io_dir_in)
64 *iopin->port->oe &= ~iopin->bit;
65 else
66 *iopin->port->oe |= iopin->bit;
d8ca6b15
JN
67
68 spin_unlock_irqrestore(&iopin->port->lock, flags);
51533b61
MS
69}
70
d9b5444e 71static inline int crisv32_io_rd(struct crisv32_iopin* iopin)
51533b61
MS
72{
73 return ((*iopin->port->data_in & iopin->bit) ? 1 : 0);
74}
75
76int crisv32_io_get(struct crisv32_iopin* iopin,
77 unsigned int port, unsigned int pin);
78int crisv32_io_get_name(struct crisv32_iopin* iopin,
d8ca6b15 79 const char *name);
51533b61 80
0d9f2e6f
JN
81#define CRIS_LED_OFF 0x00
82#define CRIS_LED_GREEN 0x01
83#define CRIS_LED_RED 0x02
84#define CRIS_LED_ORANGE (CRIS_LED_GREEN | CRIS_LED_RED)
51533b61 85
d8ca6b15 86#if (defined(CONFIG_ETRAX_NBR_LED_GRP_ONE) || defined(CONFIG_ETRAX_NBR_LED_GRP_TWO))
0d9f2e6f 87#define CRIS_LED_NETWORK_GRP0_SET(x) \
d8ca6b15 88 do { \
0d9f2e6f
JN
89 CRIS_LED_NETWORK_GRP0_SET_G((x) & CRIS_LED_GREEN); \
90 CRIS_LED_NETWORK_GRP0_SET_R((x) & CRIS_LED_RED); \
51533b61 91 } while (0)
d8ca6b15 92#else
0d9f2e6f 93#define CRIS_LED_NETWORK_GRP0_SET(x) while (0) {}
d8ca6b15
JN
94#endif
95
0d9f2e6f 96#define CRIS_LED_NETWORK_GRP0_SET_G(x) \
d8ca6b15
JN
97 crisv32_io_set(&crisv32_led_net0_green, !(x));
98
0d9f2e6f 99#define CRIS_LED_NETWORK_GRP0_SET_R(x) \
d8ca6b15
JN
100 crisv32_io_set(&crisv32_led_net0_red, !(x));
101
102#if defined(CONFIG_ETRAX_NBR_LED_GRP_TWO)
0d9f2e6f 103#define CRIS_LED_NETWORK_GRP1_SET(x) \
d8ca6b15 104 do { \
0d9f2e6f
JN
105 CRIS_LED_NETWORK_GRP1_SET_G((x) & CRIS_LED_GREEN); \
106 CRIS_LED_NETWORK_GRP1_SET_R((x) & CRIS_LED_RED); \
d8ca6b15
JN
107 } while (0)
108#else
0d9f2e6f 109#define CRIS_LED_NETWORK_GRP1_SET(x) while (0) {}
d8ca6b15
JN
110#endif
111
0d9f2e6f 112#define CRIS_LED_NETWORK_GRP1_SET_G(x) \
d8ca6b15
JN
113 crisv32_io_set(&crisv32_led_net1_green, !(x));
114
0d9f2e6f 115#define CRIS_LED_NETWORK_GRP1_SET_R(x) \
d8ca6b15
JN
116 crisv32_io_set(&crisv32_led_net1_red, !(x));
117
0d9f2e6f 118#define CRIS_LED_ACTIVE_SET(x) \
51533b61 119 do { \
0d9f2e6f
JN
120 CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \
121 CRIS_LED_ACTIVE_SET_R((x) & CRIS_LED_RED); \
51533b61
MS
122 } while (0)
123
0d9f2e6f 124#define CRIS_LED_ACTIVE_SET_G(x) \
51533b61 125 crisv32_io_set(&crisv32_led2_green, !(x));
0d9f2e6f 126#define CRIS_LED_ACTIVE_SET_R(x) \
51533b61 127 crisv32_io_set(&crisv32_led2_red, !(x));
0d9f2e6f 128#define CRIS_LED_DISK_WRITE(x) \
51533b61
MS
129 do{\
130 crisv32_io_set(&crisv32_led3_green, !(x)); \
131 crisv32_io_set(&crisv32_led3_red, !(x)); \
132 }while(0)
0d9f2e6f 133#define CRIS_LED_DISK_READ(x) \
51533b61
MS
134 crisv32_io_set(&crisv32_led3_green, !(x));
135
136#endif