Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_ARCH_CRIS_IO_H |
| 2 | #define _ASM_ARCH_CRIS_IO_H |
| 3 | |
| 4 | #include <asm/arch/svinto.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | /* Etrax shadow registers - which live in arch/cris/kernel/shadows.c */ |
| 7 | |
Mikael Starvik | 63245d2 | 2005-07-27 11:44:35 -0700 | [diff] [blame] | 8 | extern unsigned long gen_config_ii_shadow; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | extern unsigned long port_g_data_shadow; |
| 10 | extern unsigned char port_pa_dir_shadow; |
| 11 | extern unsigned char port_pa_data_shadow; |
| 12 | extern unsigned char port_pb_i2c_shadow; |
| 13 | extern unsigned char port_pb_config_shadow; |
| 14 | extern unsigned char port_pb_dir_shadow; |
| 15 | extern unsigned char port_pb_data_shadow; |
| 16 | extern unsigned long r_timer_ctrl_shadow; |
| 17 | |
| 18 | extern unsigned long port_cse1_shadow; |
| 19 | extern unsigned long port_csp0_shadow; |
| 20 | extern unsigned long port_csp4_shadow; |
| 21 | |
| 22 | extern volatile unsigned long *port_cse1_addr; |
| 23 | extern volatile unsigned long *port_csp0_addr; |
| 24 | extern volatile unsigned long *port_csp4_addr; |
| 25 | |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 26 | /* macro for setting regs through a shadow - |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * 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 Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 41 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #endif |
| 48 | |
| 49 | #if !defined(CONFIG_ETRAX_CSP0_LEDS) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 50 | #define CRIS_LED_BIT_SET(x) |
| 51 | #define CRIS_LED_BIT_CLR(x) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #endif |
| 53 | |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 54 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 59 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | do { \ |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 65 | CRIS_LED_NETWORK_SET_G((x) & CRIS_LED_GREEN); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | } while (0) |
| 67 | #else |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 68 | #define CRIS_LED_NETWORK_SET(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | do { \ |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 70 | CRIS_LED_NETWORK_SET_G((x) & CRIS_LED_GREEN); \ |
| 71 | CRIS_LED_NETWORK_SET_R((x) & CRIS_LED_RED); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } while (0) |
| 73 | #endif |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 74 | #if CONFIG_ETRAX_LED2G == CONFIG_ETRAX_LED2R |
| 75 | #define CRIS_LED_ACTIVE_SET(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | do { \ |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 77 | CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } while (0) |
| 79 | #else |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 80 | #define CRIS_LED_ACTIVE_SET(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | do { \ |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 82 | CRIS_LED_ACTIVE_SET_G((x) & CRIS_LED_GREEN); \ |
| 83 | CRIS_LED_ACTIVE_SET_R((x) & CRIS_LED_RED); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } while (0) |
| 85 | #endif |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 86 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | #ifdef CONFIG_ETRAX_PA_LEDS |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 89 | #define CRIS_LED_NETWORK_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 91 | #define CRIS_LED_NETWORK_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED1R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 93 | #define CRIS_LED_ACTIVE_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 95 | #define CRIS_LED_ACTIVE_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, CONFIG_ETRAX_LED2R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 97 | #define CRIS_LED_DISK_WRITE(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | 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 Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 102 | #define CRIS_LED_DISK_READ(x) \ |
| 103 | REG_SHADOW_SET(R_PORT_PA_DATA, port_pa_data_shadow, \ |
| 104 | CONFIG_ETRAX_LED3G, !(x)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #endif |
| 106 | |
| 107 | #ifdef CONFIG_ETRAX_PB_LEDS |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 108 | #define CRIS_LED_NETWORK_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 110 | #define CRIS_LED_NETWORK_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED1R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 112 | #define CRIS_LED_ACTIVE_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 114 | #define CRIS_LED_ACTIVE_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, CONFIG_ETRAX_LED2R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 116 | #define CRIS_LED_DISK_WRITE(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | 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 Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 121 | #define CRIS_LED_DISK_READ(x) \ |
| 122 | REG_SHADOW_SET(R_PORT_PB_DATA, port_pb_data_shadow, \ |
| 123 | CONFIG_ETRAX_LED3G, !(x)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | #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 Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 139 | #define CRIS_LED_NETWORK_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 141 | #define CRIS_LED_NETWORK_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED1R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 143 | #define CRIS_LED_ACTIVE_SET_G(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 145 | #define CRIS_LED_ACTIVE_SET_R(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED2R, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 147 | #define CRIS_LED_DISK_WRITE(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | 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 Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 152 | #define CRIS_LED_DISK_READ(x) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, CONFIG_ETRAX_LED3G, !(x)) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 154 | #define CRIS_LED_BIT_SET(x)\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | do{\ |
| 156 | if((( 1 << x) & CONFIGURABLE_LEDS) != 0)\ |
| 157 | REG_SHADOW_SET(port_csp0_addr, port_csp0_shadow, x, 1);\ |
| 158 | }while(0) |
Jesper Nilsson | 0d9f2e6 | 2008-01-28 16:49:39 +0100 | [diff] [blame] | 159 | #define CRIS_LED_BIT_CLR(x)\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | 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 |