blob: dd39198ec67d31cea570d54e7eec84db883007f3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_ARCH_CRIS_IO_H
2#define _ASM_ARCH_CRIS_IO_H
3
4#include <asm/arch/svinto.h>
5#include <linux/config.h>
6
7/* Etrax shadow registers - which live in arch/cris/kernel/shadows.c */
8
Mikael Starvik63245d22005-07-27 11:44:35 -07009extern unsigned long gen_config_ii_shadow;
Linus Torvalds1da177e2005-04-16 15:20:36 -070010extern unsigned long port_g_data_shadow;
11extern unsigned char port_pa_dir_shadow;
12extern unsigned char port_pa_data_shadow;
13extern unsigned char port_pb_i2c_shadow;
14extern unsigned char port_pb_config_shadow;
15extern unsigned char port_pb_dir_shadow;
16extern unsigned char port_pb_data_shadow;
17extern unsigned long r_timer_ctrl_shadow;
18
19extern unsigned long port_cse1_shadow;
20extern unsigned long port_csp0_shadow;
21extern unsigned long port_csp4_shadow;
22
23extern volatile unsigned long *port_cse1_addr;
24extern volatile unsigned long *port_csp0_addr;
25extern volatile unsigned long *port_csp4_addr;
26
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)
30 * b = bit number
31 * v = value (0 or 1)
32 */
33
34#define REG_SHADOW_SET(r,s,b,v) *r = s = (s & ~(1 << (b))) | ((v) << (b))
35
36/* The LED's on various Etrax-based products are set differently. */
37
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)
48#endif
49
50#if !defined(CONFIG_ETRAX_CSP0_LEDS)
51#define LED_BIT_SET(x)
52#define LED_BIT_CLR(x)
53#endif
54
55#define LED_OFF 0x00
56#define LED_GREEN 0x01
57#define LED_RED 0x02
58#define LED_ORANGE (LED_GREEN | LED_RED)
59
60#if CONFIG_ETRAX_LED1G == CONFIG_ETRAX_LED1R
61#define LED_NETWORK_SET(x) \
62 do { \
63 LED_NETWORK_SET_G((x) & LED_GREEN); \
64 } while (0)
65#else
66#define LED_NETWORK_SET(x) \
67 do { \
68 LED_NETWORK_SET_G((x) & LED_GREEN); \
69 LED_NETWORK_SET_R((x) & LED_RED); \
70 } while (0)
71#endif
72#if CONFIG_ETRAX_LED2G == CONFIG_ETRAX_LED2R
73#define LED_ACTIVE_SET(x) \
74 do { \
75 LED_ACTIVE_SET_G((x) & LED_GREEN); \
76 } while (0)
77#else
78#define LED_ACTIVE_SET(x) \
79 do { \
80 LED_ACTIVE_SET_G((x) & LED_GREEN); \
81 LED_ACTIVE_SET_R((x) & LED_RED); \
82 } while (0)
83#endif
84
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) \
95 do{\
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));\
98 }while(0)
99#define LED_DISK_READ(x) \
100 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x))
101#endif
102
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) \
113 do{\
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));\
116 }while(0)
117#define LED_DISK_READ(x) \
118 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x))
119#endif
120
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 ))
133
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) \
143 do{\
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));\
146 }while(0)
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)\
150 do{\
151 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
152 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 1);\
153 }while(0)
154#define LED_BIT_CLR(x)\
155 do{\
156 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
157 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 0);\
158 }while(0)
159#endif
160
161#
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)
165#else
166#define SOFT_SHUTDOWN()
167#endif
168
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" \
178 "push $irp \n\t" \
179 "move 0f,$irp \n\t" \
180 "jump -6809 \n" \
181 "0: \n\t" \
182 "pop $irp" \
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" \
186 (255)); _Foofoo; })
187
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 */
193
194#endif