Roy Huang | 24a07a1 | 2007-07-12 22:41:45 +0800 | [diff] [blame] | 1 | /**************************************************** |
| 2 | * LED1 ---- PG6 LED2 ---- PG7 * |
| 3 | * LED3 ---- PG8 LED4 ---- PG9 * |
| 4 | * LED5 ---- PG10 LED6 ---- PG11 * |
| 5 | ****************************************************/ |
| 6 | |
| 7 | #include <linux/linkage.h> |
| 8 | #include <asm/blackfin.h> |
| 9 | |
| 10 | /* All functions in this file save the registers they uses. |
| 11 | So there is no need to save any registers before calling them. */ |
| 12 | |
| 13 | .text; |
| 14 | |
| 15 | /* Initialize LEDs. */ |
| 16 | |
| 17 | ENTRY(_led_init) |
| 18 | LINK 0; |
| 19 | [--SP] = P0; |
| 20 | [--SP] = R0; |
| 21 | [--SP] = R1; |
| 22 | [--SP] = R2; |
| 23 | R1 = (PG6|PG7|PG8|PG9|PG10|PG11)(Z); |
| 24 | R2 = ~R1; |
| 25 | |
| 26 | P0.H = hi(PORTG_FER); |
| 27 | P0.L = lo(PORTG_FER); |
| 28 | R0 = W[P0](Z); |
| 29 | SSYNC; |
| 30 | R0 = R0 & R2; |
| 31 | W[P0] = R0.L; |
| 32 | SSYNC; |
| 33 | |
| 34 | P0.H = hi(PORTG_DIR_SET); |
| 35 | P0.L = lo(PORTG_DIR_SET); |
| 36 | W[P0] = R1.L; |
| 37 | SSYNC; |
| 38 | |
| 39 | P0.H = hi(PORTG_INEN); |
| 40 | P0.L = lo(PORTG_INEN); |
| 41 | R0 = W[P0](Z); |
| 42 | SSYNC; |
| 43 | R0 = R0 & R2; |
| 44 | W[P0] = R0.L; |
| 45 | SSYNC; |
| 46 | |
| 47 | R2 = [SP++]; |
| 48 | R1 = [SP++]; |
| 49 | R0 = [SP++]; |
| 50 | P0 = [SP++]; |
| 51 | RTS; |
| 52 | .size _led_init, .-_led_init |
| 53 | |
| 54 | /* Set one LED on. Leave other LEDs unchanged. |
| 55 | It expects the LED number passed through R0. */ |
| 56 | |
| 57 | ENTRY(_led_on) |
| 58 | LINK 0; |
| 59 | [--SP] = P0; |
| 60 | [--SP] = R1; |
| 61 | CALL _led_init; |
| 62 | R1 = 1; |
| 63 | R0 += 5; |
| 64 | R1 <<= R0; |
| 65 | P0.H = hi(PORTG_SET); |
| 66 | P0.L = lo(PORTG_SET); |
| 67 | W[P0] = R1.L; |
| 68 | SSYNC; |
| 69 | R1 = [SP++]; |
| 70 | P0 = [SP++]; |
| 71 | UNLINK; |
| 72 | RTS; |
| 73 | .size _led_on, .-_led_on |
| 74 | |
| 75 | /* Set one LED off. Leave other LEDs unchanged. */ |
| 76 | |
| 77 | ENTRY(_led_off) |
| 78 | LINK 0; |
| 79 | [--SP] = P0; |
| 80 | [--SP] = R1; |
| 81 | CALL _led_init; |
| 82 | R1 = 1; |
| 83 | R0 += 5; |
| 84 | R1 <<= R0; |
| 85 | P0.H = hi(PORTG_CLEAR); |
| 86 | P0.L = lo(PORTG_CLEAR); |
| 87 | W[P0] = R1.L; |
| 88 | SSYNC; |
| 89 | R1 = [SP++]; |
| 90 | P0 = [SP++]; |
| 91 | UNLINK; |
| 92 | RTS; |
| 93 | .size _led_off, .-_led_off |
| 94 | |
| 95 | /* Toggle one LED. Leave other LEDs unchanged. */ |
| 96 | |
| 97 | ENTRY(_led_toggle) |
| 98 | LINK 0; |
| 99 | [--SP] = P0; |
| 100 | [--SP] = R1; |
| 101 | CALL _led_init; |
| 102 | R1 = 1; |
| 103 | R0 += 5; |
| 104 | R1 <<= R0; |
| 105 | P0.H = hi(PORTG); |
| 106 | P0.L = lo(PORTG); |
| 107 | R0 = W[P0](Z); |
| 108 | SSYNC; |
| 109 | R0 = R0 ^ R1; |
| 110 | W[P0] = R0.L; |
| 111 | SSYNC; |
| 112 | R1 = [SP++]; |
| 113 | P0 = [SP++]; |
| 114 | UNLINK; |
| 115 | RTS; |
| 116 | .size _led_toggle, .-_led_toggle |
| 117 | |
| 118 | /* Display the number using LEDs in binary format. */ |
| 119 | |
| 120 | ENTRY(_led_disp_num) |
| 121 | LINK 0; |
| 122 | [--SP] = P0; |
| 123 | [--SP] = R1; |
| 124 | [--SP] = R2; |
| 125 | CALL _led_init; |
| 126 | R1 = 0x3f(X); |
| 127 | R0 = R0 & R1; |
| 128 | R2 = 6(X); |
| 129 | R0 <<= R2; |
| 130 | R1 <<= R2; |
| 131 | P0.H = hi(PORTG); |
| 132 | P0.L = lo(PORTG); |
| 133 | R2 = W[P0](Z); |
| 134 | SSYNC; |
| 135 | R1 = ~R1; |
| 136 | R2 = R2 & R1; |
| 137 | R2 = R2 | R0; |
| 138 | W[P0] = R2.L; |
| 139 | SSYNC; |
| 140 | R2 = [SP++]; |
| 141 | R1 = [SP++]; |
| 142 | P0 = [SP++]; |
| 143 | UNLINK; |
| 144 | RTS; |
| 145 | .size _led_disp_num, .-_led_disp_num |
| 146 | |
| 147 | /* Toggle the number using LEDs in binary format. */ |
| 148 | |
| 149 | ENTRY(_led_toggle_num) |
| 150 | LINK 0; |
| 151 | [--SP] = P0; |
| 152 | [--SP] = R1; |
| 153 | [--SP] = R2; |
| 154 | CALL _led_init; |
| 155 | R1 = 0x3f(X); |
| 156 | R0 = R0 & R1; |
| 157 | R1 = 6(X); |
| 158 | R0 <<= R1; |
| 159 | P0.H = hi(PORTG); |
| 160 | P0.L = lo(PORTG); |
| 161 | R1 = W[P0](Z); |
| 162 | SSYNC; |
| 163 | R1 = R1 ^ R0; |
| 164 | W[P0] = R1.L; |
| 165 | SSYNC; |
| 166 | R2 = [SP++]; |
| 167 | R1 = [SP++]; |
| 168 | P0 = [SP++]; |
| 169 | UNLINK; |
| 170 | RTS; |
| 171 | .size _led_toggle_num, .-_led_toggle_num |
| 172 | |