more debug output
[linux-2.4.git] / include / asm-cris / io.h
1 #ifndef _ASM_CRIS_IO_H
2 #define _ASM_CRIS_IO_H
3
4 #include <asm/page.h>   /* for __va, __pa */
5 #include <asm/svinto.h>
6 #include <linux/sched.h>
7 #include <asm/pgtable.h>
8 #include <linux/config.h>
9
10 /* Console I/O for simulated etrax100.  Use #ifdef so erroneous
11    use will be evident. */
12 #ifdef CONFIG_SVINTO_SIM
13   /* Let's use the ucsim interface since it lets us do write(2, ...) */
14 #define SIMCOUT(s,len)                                                  \
15   asm ("moveq 4,$r9     \n\t"                                           \
16        "moveq 2,$r10    \n\t"                                           \
17        "move.d %0,$r11  \n\t"                                           \
18        "move.d %1,$r12  \n\t"                                           \
19        "push $irp       \n\t"                                           \
20        "move 0f,$irp    \n\t"                                           \
21        "jump -6809      \n"                                             \
22        "0:              \n\t"                                           \
23        "pop $irp"                                                       \
24        : : "rm" (s), "rm" (len) : "r9","r10","r11","r12","memory")
25 #define TRACE_ON() __extension__ \
26  ({ int _Foofoo; __asm__ volatile ("bmod [%0],%0" : "=r" (_Foofoo) : "0" \
27                                (255)); _Foofoo; })
28
29 #define TRACE_OFF() do { __asm__ volatile ("bmod [%0],%0" :: "r" (254)); } while (0)
30 #define SIM_END() do { __asm__ volatile ("bmod [%0],%0" :: "r" (28)); } while (0)
31 #define CRIS_CYCLES() __extension__ \
32  ({ unsigned long c; asm ("bmod [%1],%0" : "=r" (c) : "r" (27)); c;})
33 #else  /* ! defined CONFIG_SVINTO_SIM */
34 /* FIXME: Is there a reliable cycle counter available in some chip?  Use
35    that then. */
36 #define CRIS_CYCLES() 0
37 #endif /* ! defined CONFIG_SVINTO_SIM */
38
39 /* Etrax shadow registers - which live in arch/cris/kernel/shadows.c */
40
41 extern unsigned long port_g_data_shadow;
42 extern unsigned char port_pa_dir_shadow;
43 extern unsigned char port_pa_data_shadow;
44 extern unsigned char port_pb_i2c_shadow;
45 extern unsigned char port_pb_config_shadow;
46 extern unsigned char port_pb_dir_shadow;
47 extern unsigned char port_pb_data_shadow;
48 extern unsigned long r_timer_ctrl_shadow;
49
50 extern unsigned long port_cse1_shadow;
51 extern unsigned long port_csp0_shadow;
52 extern unsigned long port_csp4_shadow;
53
54 extern volatile unsigned long *port_cse1_addr;
55 extern volatile unsigned long *port_csp0_addr;
56 extern volatile unsigned long *port_csp4_addr;
57
58 /* macro for setting regs through a shadow - 
59  * r = register name (like R_PORT_PA_DATA)
60  * s = shadow name (like port_pa_data_shadow)
61  * b = bit number
62  * v = value (0 or 1)
63  */
64
65 #define REG_SHADOW_SET(r,s,b,v) *r = s = (s & ~(1 << (b))) | ((v) << (b))
66
67 /* The LED's on various Etrax-based products are set differently. */
68
69 #if defined(CONFIG_ETRAX_NO_LEDS) || defined(CONFIG_SVINTO_SIM)
70 #undef CONFIG_ETRAX_PA_LEDS
71 #undef CONFIG_ETRAX_PB_LEDS
72 #undef CONFIG_ETRAX_CSP0_LEDS
73 #define LED_NETWORK_SET_G(x)
74 #define LED_NETWORK_SET_R(x)
75 #define LED_ACTIVE_SET_G(x)
76 #define LED_ACTIVE_SET_R(x)
77 #define LED_DISK_WRITE(x)
78 #define LED_DISK_READ(x)
79 #endif
80
81 #if !defined(CONFIG_ETRAX_CSP0_LEDS)
82 #define LED_BIT_SET(x)
83 #define LED_BIT_CLR(x)
84 #endif
85
86 #define LED_OFF    0x00
87 #define LED_GREEN  0x01
88 #define LED_RED    0x02
89 #define LED_ORANGE (LED_GREEN | LED_RED)
90
91 #if CONFIG_ETRAX_LED1G == CONFIG_ETRAX_LED1R 
92 #define LED_NETWORK_SET(x)                          \
93         do {                                        \
94                 LED_NETWORK_SET_G((x) & LED_GREEN); \
95         } while (0)
96 #else
97 #define LED_NETWORK_SET(x)                          \
98         do {                                        \
99                 LED_NETWORK_SET_G((x) & LED_GREEN); \
100                 LED_NETWORK_SET_R((x) & LED_RED);   \
101         } while (0)
102 #endif
103 #if CONFIG_ETRAX_LED2G == CONFIG_ETRAX_LED2R 
104 #define LED_ACTIVE_SET(x)                           \
105         do {                                        \
106                 LED_ACTIVE_SET_G((x) & LED_GREEN);  \
107         } while (0)
108 #else
109 #define LED_ACTIVE_SET(x)                           \
110         do {                                        \
111                 LED_ACTIVE_SET_G((x) & LED_GREEN);  \
112                 LED_ACTIVE_SET_R((x) & LED_RED);    \
113         } while (0)
114 #endif
115
116 #ifdef CONFIG_ETRAX_PA_LEDS
117 #define LED_NETWORK_SET_G(x) \
118          REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1G, !(x))
119 #define LED_NETWORK_SET_R(x) \
120          REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1R, !(x))
121 #define LED_ACTIVE_SET_G(x) \
122          REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2G, !(x))
123 #define LED_ACTIVE_SET_R(x) \
124          REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2R, !(x))
125 #define LED_DISK_WRITE(x) \
126          do{\
127                 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
128                 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
129         }while(0)
130 #define LED_DISK_READ(x) \
131          REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x)) 
132 #endif
133
134 #ifdef CONFIG_ETRAX_PB_LEDS
135 #define LED_NETWORK_SET_G(x) \
136          REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1G, !(x))
137 #define LED_NETWORK_SET_R(x) \
138          REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1R, !(x))
139 #define LED_ACTIVE_SET_G(x) \
140          REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2G, !(x))
141 #define LED_ACTIVE_SET_R(x) \
142          REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2R, !(x))
143 #define LED_DISK_WRITE(x) \
144         do{\
145                 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
146                 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
147         }while(0)
148 #define LED_DISK_READ(x) \
149          REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x))     
150 #endif
151
152 #ifdef CONFIG_ETRAX_CSP0_LEDS
153 #define CONFIGURABLE_LEDS\
154         ((1 << CONFIG_ETRAX_LED1G ) | (1 << CONFIG_ETRAX_LED1R ) |\
155          (1 << CONFIG_ETRAX_LED2G ) | (1 << CONFIG_ETRAX_LED2R ) |\
156          (1 << CONFIG_ETRAX_LED3G ) | (1 << CONFIG_ETRAX_LED3R ) |\
157          (1 << CONFIG_ETRAX_LED4G ) | (1 << CONFIG_ETRAX_LED4R ) |\
158          (1 << CONFIG_ETRAX_LED5G ) | (1 << CONFIG_ETRAX_LED5R ) |\
159          (1 << CONFIG_ETRAX_LED6G ) | (1 << CONFIG_ETRAX_LED6R ) |\
160          (1 << CONFIG_ETRAX_LED7G ) | (1 << CONFIG_ETRAX_LED7R ) |\
161          (1 << CONFIG_ETRAX_LED8Y ) | (1 << CONFIG_ETRAX_LED9Y ) |\
162          (1 << CONFIG_ETRAX_LED10Y ) |(1 << CONFIG_ETRAX_LED11Y )|\
163          (1 << CONFIG_ETRAX_LED12R ))
164
165 #define LED_NETWORK_SET_G(x) \
166          REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1G, !(x))
167 #define LED_NETWORK_SET_R(x) \
168          REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1R, !(x))
169 #define LED_ACTIVE_SET_G(x) \
170          REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2G, !(x))
171 #define LED_ACTIVE_SET_R(x) \
172          REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2R, !(x))
173 #define LED_DISK_WRITE(x) \
174         do{\
175                 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x));\
176                 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3R, !(x));\
177         }while(0)
178 #define LED_DISK_READ(x) \
179          REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x))
180 #define LED_BIT_SET(x)\
181         do{\
182                 if((( 1 << x) & CONFIGURABLE_LEDS)  != 0)\
183                        REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 1);\
184         }while(0)
185 #define LED_BIT_CLR(x)\
186         do{\
187                 if((( 1 << x) & CONFIGURABLE_LEDS)  != 0)\
188                        REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 0);\
189         }while(0)
190 #endif
191
192 #
193 #ifdef CONFIG_ETRAX_SOFT_SHUTDOWN
194 #define SOFT_SHUTDOWN() \
195           REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_SHUTDOWN_BIT, 1)
196 #else
197 #define SOFT_SHUTDOWN()
198 #endif
199
200 /*
201  * Change virtual addresses to physical addresses and vv.
202  */
203
204 extern inline unsigned long virt_to_phys(volatile void * address)
205 {
206         return __pa(address);
207 }
208
209 extern inline void * phys_to_virt(unsigned long address)
210 {
211         return __va(address);
212 }
213
214 #define page_to_phys(page)      __pa(__page_address(page))
215
216 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
217
218 extern inline void * ioremap (unsigned long offset, unsigned long size)
219 {
220         return __ioremap(offset, size, 0);
221 }
222
223 extern void iounmap(void *addr);
224
225 /*
226  * IO bus memory addresses are also 1:1 with the physical address
227  */
228 #define virt_to_bus virt_to_phys
229 #define bus_to_virt phys_to_virt
230
231 /*
232  * readX/writeX() are used to access memory mapped devices. On some
233  * architectures the memory mapped IO stuff needs to be accessed
234  * differently. On the CRIS architecture, we just read/write the
235  * memory location directly.
236  */
237 #define readb(addr) (*(volatile unsigned char *) (addr))
238 #define readw(addr) (*(volatile unsigned short *) (addr))
239 #define readl(addr) (*(volatile unsigned int *) (addr))
240
241 #define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
242 #define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
243 #define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
244
245 #define memset_io(a,b,c)        memset((void *)(a),(b),(c))
246 #define memcpy_fromio(a,b,c)    memcpy((a),(void *)(b),(c))
247 #define memcpy_toio(a,b,c)      memcpy((void *)(a),(b),(c))
248
249 /*
250  * Again, CRIS does not require mem IO specific function.
251  */
252
253 #define eth_io_copy_and_sum(a,b,c,d)    eth_copy_and_sum((a),(void *)(b),(c),(d))
254
255 /* The following is junk needed for the arch-independant code but which
256  * we never use in the CRIS port
257  */
258
259 #define IO_SPACE_LIMIT 0xffff
260 #define inb(x) (0)
261 #define inw(x) (0)
262 #define inl(x) (0)
263 #define outb(x,y)
264 #define outw(x,y)
265 #define outl(x,y)
266 #define insb(x,y,z)
267 #define insw(x,y,z)
268 #define insl(x,y,z)
269 #define outsb(x,y,z)
270 #define outsw(x,y,z)
271 #define outsl(x,y,z)
272
273 #endif