4 * LinkStation HW Control Driver
6 * Copyright (C) 2001-2004 BUFFALO INC.
8 * This software may be used and distributed according to the terms of
9 * the GNU General Public License (GPL), incorporated herein by reference.
10 * Drivers based on or derived from this code fall under the GPL and must
11 * retain the authorship, copyright and license notice. This file is not
12 * a complete program and may only be used when the entire operating
13 * system is licensed under the GPL.
21 #define mdelay(n) udelay((n)*1000)
23 #define AVR_PORT CFG_NS16550_COM2
24 extern void udelay(unsigned long usec);
28 static inline void out_b(volatile unsigned char *addr, int val)
30 __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
34 // PWR,DISK_FULL/STATUS,DIAG LED controll
35 void blink_led(unsigned char state)
40 case FLASH_CLEAR_START:
41 case FLASH_UPDATE_START:
42 out_b(AVR_PORT, 0x61);
43 out_b(AVR_PORT, 0x61);
44 out_b(AVR_PORT, 0x38);
45 out_b(AVR_PORT, 0x30);
46 out_b(AVR_PORT, 0x34);
47 out_b(AVR_PORT, 0x31);
49 out_b(AVR_PORT, 0x61);
50 out_b(AVR_PORT, 0x61);
51 out_b(AVR_PORT, 0x38);
52 out_b(AVR_PORT, 0x31);
53 out_b(AVR_PORT, 0x34);
54 out_b(AVR_PORT, 0x31);
56 out_b(AVR_PORT, 0x71);
57 out_b(AVR_PORT, 0x71);
58 // out_b(AVR_PORT, 0x71);
59 // out_b(AVR_PORT, 0x71);
61 out_b(AVR_PORT, 0x73);
62 out_b(AVR_PORT, 0x73);
63 // out_b(AVR_PORT, 0x73);
64 // out_b(AVR_PORT, 0x73);
68 case FLASH_UPDATE_END:
69 out_b(AVR_PORT, 0x70);
70 out_b(AVR_PORT, 0x70);
71 // out_b(AVR_PORT, 0x70);
72 // out_b(AVR_PORT, 0x70);
74 out_b(AVR_PORT, 0x72);
75 out_b(AVR_PORT, 0x72);
76 // out_b(AVR_PORT, 0x72);
77 // out_b(AVR_PORT, 0x72);
80 case RAID_RESYNC_START:
85 out_b(AVR_PORT, state);
86 out_b(AVR_PORT, state);
87 out_b(AVR_PORT, state);
88 out_b(AVR_PORT, state);
92 out_b(AVR_PORT, state);
93 out_b(AVR_PORT, state);
94 out_b(AVR_PORT, state);
95 out_b(AVR_PORT, state);
101 // 2005.5.10 BUFFALO add
102 //--------------------------------------------------------------
103 static inline void miconCntl_SendUart(unsigned char dat)
105 out_b((char *)AVR_PORT, dat);
109 //--------------------------------------------------------------
110 void miconCntl_SendCmd(unsigned char dat)
115 miconCntl_SendUart(dat);
119 //--------------------------------------------------------------
120 void miconCntl_FanLow(void)
122 debug("%s\n",__FUNCTION__);
124 miconCntl_SendCmd(0x5C);
127 //--------------------------------------------------------------
128 void miconCntl_FanHigh(void)
130 debug("%s\n",__FUNCTION__);
132 miconCntl_SendCmd(0x5D);
136 //--------------------------------------------------------------
138 void miconCntl_Eth1000M(int up)
140 debug("%s (%d)\n",__FUNCTION__,up);
143 miconCntl_SendCmd(0x93);
145 miconCntl_SendCmd(0x92);
149 miconCntl_SendCmd(0x5D);
151 miconCntl_SendCmd(0x5C);
155 //--------------------------------------------------------------
157 void miconCntl_Eth100M(int up)
159 debug("%s (%d)\n",__FUNCTION__,up);
162 miconCntl_SendCmd(0x91);
164 miconCntl_SendCmd(0x90);
168 miconCntl_SendCmd(0x5C);
172 //--------------------------------------------------------------
174 void miconCntl_Eth10M(int up)
176 debug("%s (%d)\n",__FUNCTION__,up);
179 miconCntl_SendCmd(0x8F);
181 miconCntl_SendCmd(0x8E);
185 miconCntl_SendCmd(0x5C);
189 //--------------------------------------------------------------
191 void miconCntl_5f(void)
193 debug("%s\n",__FUNCTION__);
194 miconCntl_SendCmd(0x5F);
198 //--------------------------------------------------------------
199 // "reboot start" signal
200 void miconCntl_Reboot(void)
202 debug("%s\n",__FUNCTION__);
203 miconCntl_SendCmd(0x43);
206 //--------------------------------------------------------------
207 // Raid recovery start
208 void miconCntl_RadiRecovery(void)
210 debug("%s\n",__FUNCTION__);
212 miconCntl_SendUart(0x61); // a
213 miconCntl_SendUart(0x61); // a
214 miconCntl_SendUart(0x38); // 8
215 miconCntl_SendUart(0x30); // 0
216 miconCntl_SendUart(0x34); // 4
217 miconCntl_SendUart(0x31); // 1
218 miconCntl_SendCmd(0x71); // q
221 //--------------------------------------------------------------
222 // Raid recovery finish
223 void miconCntl_RadiRecoveryFin(void)
225 debug("%s\n",__FUNCTION__);
227 miconCntl_SendCmd(0x70);
232 // ---------------------------------------------------------------
233 // Disable watchdog timer
234 void miconCntl_DisWDT(void)
236 debug("%s\n",__FUNCTION__);
237 miconCntl_SendCmd(0x41); // A
238 miconCntl_SendCmd(0x46); // F
239 miconCntl_SendCmd(0x4A); // J
240 miconCntl_SendCmd(0x3E); // >
241 miconCntl_SendCmd(0x56); // V
242 miconCntl_SendCmd(0x3E); // >
243 miconCntl_SendCmd(0x5A); // Z
244 miconCntl_SendCmd(0x56); // V
245 miconCntl_SendCmd(0x4B); // K
247 // ---------------------------------------------------------------
248 // U-Boot calls this function
249 int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
251 disable_interrupts();
254 miconCntl_SendUart(0x47); /* Wait for reboot */