1 #ifndef _ASM_ARCH_CRIS_IO_H
2 #define _ASM_ARCH_CRIS_IO_H
4 #include <asm/arch/svinto.h>
5 #include <linux/config.h>
7 /* Etrax shadow registers - which live in arch/cris/kernel/shadows.c */
9 extern unsigned long gen_config_ii_shadow
;
10 extern unsigned long port_g_data_shadow
;
11 extern unsigned char port_pa_dir_shadow
;
12 extern unsigned char port_pa_data_shadow
;
13 extern unsigned char port_pb_i2c_shadow
;
14 extern unsigned char port_pb_config_shadow
;
15 extern unsigned char port_pb_dir_shadow
;
16 extern unsigned char port_pb_data_shadow
;
17 extern unsigned long r_timer_ctrl_shadow
;
19 extern unsigned long port_cse1_shadow
;
20 extern unsigned long port_csp0_shadow
;
21 extern unsigned long port_csp4_shadow
;
23 extern volatile unsigned long *port_cse1_addr
;
24 extern volatile unsigned long *port_csp0_addr
;
25 extern volatile unsigned long *port_csp4_addr
;
27 /* macro for setting regs through a shadow -
28 * r = register name (like R_PORT_PA_DATA)
29 * s = shadow name (like port_pa_data_shadow)
34 #define REG_SHADOW_SET(r,s,b,v) *r = s = (s & ~(1 << (b))) | ((v) << (b))
36 /* The LED's on various Etrax-based products are set differently. */
38 #if defined(CONFIG_ETRAX_NO_LEDS) || defined(CONFIG_SVINTO_SIM)
39 #undef CONFIG_ETRAX_PA_LEDS
40 #undef CONFIG_ETRAX_PB_LEDS
41 #undef CONFIG_ETRAX_CSP0_LEDS
42 #define LED_NETWORK_SET_G(x)
43 #define LED_NETWORK_SET_R(x)
44 #define LED_ACTIVE_SET_G(x)
45 #define LED_ACTIVE_SET_R(x)
46 #define LED_DISK_WRITE(x)
47 #define LED_DISK_READ(x)
50 #if !defined(CONFIG_ETRAX_CSP0_LEDS)
51 #define LED_BIT_SET(x)
52 #define LED_BIT_CLR(x)
56 #define LED_GREEN 0x01
58 #define LED_ORANGE (LED_GREEN | LED_RED)
60 #if CONFIG_ETRAX_LED1G == CONFIG_ETRAX_LED1R
61 #define LED_NETWORK_SET(x) \
63 LED_NETWORK_SET_G((x) & LED_GREEN); \
66 #define LED_NETWORK_SET(x) \
68 LED_NETWORK_SET_G((x) & LED_GREEN); \
69 LED_NETWORK_SET_R((x) & LED_RED); \
72 #if CONFIG_ETRAX_LED2G == CONFIG_ETRAX_LED2R
73 #define LED_ACTIVE_SET(x) \
75 LED_ACTIVE_SET_G((x) & LED_GREEN); \
78 #define LED_ACTIVE_SET(x) \
80 LED_ACTIVE_SET_G((x) & LED_GREEN); \
81 LED_ACTIVE_SET_R((x) & LED_RED); \
85 #ifdef CONFIG_ETRAX_PA_LEDS
86 #define LED_NETWORK_SET_G(x) \
87 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1G, !(x))
88 #define LED_NETWORK_SET_R(x) \
89 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1R, !(x))
90 #define LED_ACTIVE_SET_G(x) \
91 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2G, !(x))
92 #define LED_ACTIVE_SET_R(x) \
93 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2R, !(x))
94 #define LED_DISK_WRITE(x) \
96 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
97 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
99 #define LED_DISK_READ(x) \
100 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x))
103 #ifdef CONFIG_ETRAX_PB_LEDS
104 #define LED_NETWORK_SET_G(x) \
105 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1G, !(x))
106 #define LED_NETWORK_SET_R(x) \
107 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1R, !(x))
108 #define LED_ACTIVE_SET_G(x) \
109 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2G, !(x))
110 #define LED_ACTIVE_SET_R(x) \
111 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2R, !(x))
112 #define LED_DISK_WRITE(x) \
114 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
115 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
117 #define LED_DISK_READ(x) \
118 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x))
121 #ifdef CONFIG_ETRAX_CSP0_LEDS
122 #define CONFIGURABLE_LEDS\
123 ((1 << CONFIG_ETRAX_LED1G ) | (1 << CONFIG_ETRAX_LED1R ) |\
124 (1 << CONFIG_ETRAX_LED2G ) | (1 << CONFIG_ETRAX_LED2R ) |\
125 (1 << CONFIG_ETRAX_LED3G ) | (1 << CONFIG_ETRAX_LED3R ) |\
126 (1 << CONFIG_ETRAX_LED4G ) | (1 << CONFIG_ETRAX_LED4R ) |\
127 (1 << CONFIG_ETRAX_LED5G ) | (1 << CONFIG_ETRAX_LED5R ) |\
128 (1 << CONFIG_ETRAX_LED6G ) | (1 << CONFIG_ETRAX_LED6R ) |\
129 (1 << CONFIG_ETRAX_LED7G ) | (1 << CONFIG_ETRAX_LED7R ) |\
130 (1 << CONFIG_ETRAX_LED8Y ) | (1 << CONFIG_ETRAX_LED9Y ) |\
131 (1 << CONFIG_ETRAX_LED10Y ) |(1 << CONFIG_ETRAX_LED11Y )|\
132 (1 << CONFIG_ETRAX_LED12R ))
134 #define LED_NETWORK_SET_G(x) \
135 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1G, !(x))
136 #define LED_NETWORK_SET_R(x) \
137 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1R, !(x))
138 #define LED_ACTIVE_SET_G(x) \
139 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2G, !(x))
140 #define LED_ACTIVE_SET_R(x) \
141 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2R, !(x))
142 #define LED_DISK_WRITE(x) \
144 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x));\
145 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3R, !(x));\
147 #define LED_DISK_READ(x) \
148 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x))
149 #define LED_BIT_SET(x)\
151 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
152 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 1);\
154 #define LED_BIT_CLR(x)\
156 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
157 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 0);\
162 #ifdef CONFIG_ETRAX_SOFT_SHUTDOWN
163 #define SOFT_SHUTDOWN() \
164 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_SHUTDOWN_BIT, 1)
166 #define SOFT_SHUTDOWN()
169 /* Console I/O for simulated etrax100. Use #ifdef so erroneous
170 use will be evident. */
171 #ifdef CONFIG_SVINTO_SIM
172 /* Let's use the ucsim interface since it lets us do write(2, ...) */
173 #define SIMCOUT(s,len) \
174 asm ("moveq 4,$r9 \n\t" \
175 "moveq 2,$r10 \n\t" \
176 "move.d %0,$r11 \n\t" \
177 "move.d %1,$r12 \n\t" \
179 "move 0f,$irp \n\t" \
183 : : "rm" (s), "rm" (len) : "r9","r10","r11","r12","memory")
184 #define TRACE_ON() __extension__ \
185 ({ int _Foofoo; __asm__ volatile ("bmod [%0],%0" : "=r" (_Foofoo) : "0" \
188 #define TRACE_OFF() do { __asm__ volatile ("bmod [%0],%0" :: "r" (254)); } while (0)
189 #define SIM_END() do { __asm__ volatile ("bmod [%0],%0" :: "r" (28)); } while (0)
190 #define CRIS_CYCLES() __extension__ \
191 ({ unsigned long c; asm ("bmod [%1],%0" : "=r" (c) : "r" (27)); c;})
192 #endif /* ! defined CONFIG_SVINTO_SIM */