blob: c08c24265299df0b9b526ef2fe69e799915007a5 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6/* Etrax shadow registers - which live in arch/cris/kernel/shadows.c */
7
Mikael Starvik63245d22005-07-27 11:44:35 -07008extern unsigned long gen_config_ii_shadow;
Linus Torvalds1da177e2005-04-16 15:20:36 -07009extern unsigned long port_g_data_shadow;
10extern unsigned char port_pa_dir_shadow;
11extern unsigned char port_pa_data_shadow;
12extern unsigned char port_pb_i2c_shadow;
13extern unsigned char port_pb_config_shadow;
14extern unsigned char port_pb_dir_shadow;
15extern unsigned char port_pb_data_shadow;
16extern unsigned long r_timer_ctrl_shadow;
17
18extern unsigned long port_cse1_shadow;
19extern unsigned long port_csp0_shadow;
20extern unsigned long port_csp4_shadow;
21
22extern volatile unsigned long *port_cse1_addr;
23extern volatile unsigned long *port_csp0_addr;
24extern volatile unsigned long *port_csp4_addr;
25
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010026/* macro for setting regs through a shadow -
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 * r = register name (like R_PORT_PA_DATA)
28 * s = shadow name (like port_pa_data_shadow)
29 * b = bit number
30 * v = value (0 or 1)
31 */
32
33#define REG_SHADOW_SET(r,s,b,v) *r = s = (s & ~(1 << (b))) | ((v) << (b))
34
35/* The LED's on various Etrax-based products are set differently. */
36
37#if defined(CONFIG_ETRAX_NO_LEDS) || defined(CONFIG_SVINTO_SIM)
38#undef CONFIG_ETRAX_PA_LEDS
39#undef CONFIG_ETRAX_PB_LEDS
40#undef CONFIG_ETRAX_CSP0_LEDS
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010041#define CRIS_LED_NETWORK_SET_G(x)
42#define CRIS_LED_NETWORK_SET_R(x)
43#define CRIS_LED_ACTIVE_SET_G(x)
44#define CRIS_LED_ACTIVE_SET_R(x)
45#define CRIS_LED_DISK_WRITE(x)
46#define CRIS_LED_DISK_READ(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#endif
48
49#if !defined(CONFIG_ETRAX_CSP0_LEDS)
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010050#define CRIS_LED_BIT_SET(x)
51#define CRIS_LED_BIT_CLR(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#endif
53
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010054#define CRIS_LED_OFF 0x00
55#define CRIS_LED_GREEN 0x01
56#define CRIS_LED_RED 0x02
57#define CRIS_LED_ORANGE (CRIS_LED_GREEN | CRIS_LED_RED)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010059#if defined(CONFIG_ETRAX_NO_LEDS)
60#define CRIS_LED_NETWORK_SET(x)
61#else
62#if CONFIG_ETRAX_LED1G == CONFIG_ETRAX_LED1R
63#define CRIS_LED_NETWORK_SET(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 do { \
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010065 CRIS_LED_NETWORK_SET_G((x) & CRIS_LED_GREEN); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 } while (0)
67#else
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010068#define CRIS_LED_NETWORK_SET(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 do { \
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010070 CRIS_LED_NETWORK_SET_G((x) & CRIS_LED_GREEN); \
71 CRIS_LED_NETWORK_SET_R((x) & CRIS_LED_RED); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 } while (0)
73#endif
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010074#if CONFIG_ETRAX_LED2G == CONFIG_ETRAX_LED2R
75#define CRIS_LED_ACTIVE_SET(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 do { \
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010077 CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 } while (0)
79#else
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010080#define CRIS_LED_ACTIVE_SET(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 do { \
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010082 CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \
83 CRIS_LED_ACTIVE_SET_R((x) & CRIS_LED_RED); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 } while (0)
85#endif
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010086#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88#ifdef CONFIG_ETRAX_PA_LEDS
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010089#define CRIS_LED_NETWORK_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010091#define CRIS_LED_NETWORK_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010093#define CRIS_LED_ACTIVE_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010095#define CRIS_LED_ACTIVE_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +010097#define CRIS_LED_DISK_WRITE(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 do{\
99 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
100 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
101 }while(0)
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100102#define CRIS_LED_DISK_READ(x) \
103 REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, \
104 CONFIG_ETRAX_LED3G, !(x))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#endif
106
107#ifdef CONFIG_ETRAX_PB_LEDS
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100108#define CRIS_LED_NETWORK_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100110#define CRIS_LED_NETWORK_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100112#define CRIS_LED_ACTIVE_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100114#define CRIS_LED_ACTIVE_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100116#define CRIS_LED_DISK_WRITE(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 do{\
118 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3G, !(x));\
119 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED3R, !(x));\
120 }while(0)
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100121#define CRIS_LED_DISK_READ(x) \
122 REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, \
123 CONFIG_ETRAX_LED3G, !(x))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#endif
125
126#ifdef CONFIG_ETRAX_CSP0_LEDS
127#define CONFIGURABLE_LEDS\
128 ((1 << CONFIG_ETRAX_LED1G ) | (1 << CONFIG_ETRAX_LED1R ) |\
129 (1 << CONFIG_ETRAX_LED2G ) | (1 << CONFIG_ETRAX_LED2R ) |\
130 (1 << CONFIG_ETRAX_LED3G ) | (1 << CONFIG_ETRAX_LED3R ) |\
131 (1 << CONFIG_ETRAX_LED4G ) | (1 << CONFIG_ETRAX_LED4R ) |\
132 (1 << CONFIG_ETRAX_LED5G ) | (1 << CONFIG_ETRAX_LED5R ) |\
133 (1 << CONFIG_ETRAX_LED6G ) | (1 << CONFIG_ETRAX_LED6R ) |\
134 (1 << CONFIG_ETRAX_LED7G ) | (1 << CONFIG_ETRAX_LED7R ) |\
135 (1 << CONFIG_ETRAX_LED8Y ) | (1 << CONFIG_ETRAX_LED9Y ) |\
136 (1 << CONFIG_ETRAX_LED10Y ) |(1 << CONFIG_ETRAX_LED11Y )|\
137 (1 << CONFIG_ETRAX_LED12R ))
138
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100139#define CRIS_LED_NETWORK_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100141#define CRIS_LED_NETWORK_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100143#define CRIS_LED_ACTIVE_SET_G(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100145#define CRIS_LED_ACTIVE_SET_R(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2R, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100147#define CRIS_LED_DISK_WRITE(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 do{\
149 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x));\
150 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3R, !(x));\
151 }while(0)
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100152#define CRIS_LED_DISK_READ(x) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x))
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100154#define CRIS_LED_BIT_SET(x)\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 do{\
156 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
157 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 1);\
158 }while(0)
Jesper Nilsson0d9f2e62008-01-28 16:49:39 +0100159#define CRIS_LED_BIT_CLR(x)\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 do{\
161 if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\
162 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 0);\
163 }while(0)
164#endif
165
166#
167#ifdef CONFIG_ETRAX_SOFT_SHUTDOWN
168#define SOFT_SHUTDOWN() \
169 REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_SHUTDOWN_BIT, 1)
170#else
171#define SOFT_SHUTDOWN()
172#endif
173
174/* Console I/O for simulated etrax100. Use #ifdef so erroneous
175 use will be evident. */
176#ifdef CONFIG_SVINTO_SIM
177 /* Let's use the ucsim interface since it lets us do write(2, ...) */
178#define SIMCOUT(s,len) \
179 asm ("moveq 4,$r9 \n\t" \
180 "moveq 2,$r10 \n\t" \
181 "move.d %0,$r11 \n\t" \
182 "move.d %1,$r12 \n\t" \
183 "push $irp \n\t" \
184 "move 0f,$irp \n\t" \
185 "jump -6809 \n" \
186 "0: \n\t" \
187 "pop $irp" \
188 : : "rm" (s), "rm" (len) : "r9","r10","r11","r12","memory")
189#define TRACE_ON() __extension__ \
190 ({ int _Foofoo; __asm__ volatile ("bmod [%0],%0" : "=r" (_Foofoo) : "0" \
191 (255)); _Foofoo; })
192
193#define TRACE_OFF() do { __asm__ volatile ("bmod [%0],%0" :: "r" (254)); } while (0)
194#define SIM_END() do { __asm__ volatile ("bmod [%0],%0" :: "r" (28)); } while (0)
195#define CRIS_CYCLES() __extension__ \
196 ({ unsigned long c; asm ("bmod [%1],%0" : "=r" (c) : "r" (27)); c;})
197#endif /* ! defined CONFIG_SVINTO_SIM */
198
199#endif