2 * Milkymist SoC (Software)
3 * Copyright (C) 2007, 2008, 2009, 2012 Sebastien Bourdeauducq
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <hw/sysctl.h>
24 void flush_cpu_icache(void)
35 void flush_cpu_dcache(void)
43 __attribute__((noreturn
)) void reboot(void)
48 CSR_SYSTEM_ID
= 1; /* Writing to CSR_SYSTEM_ID causes a system reset */
52 static void icap_write(int val
, unsigned int w
)
54 while(!(CSR_ICAP
& ICAP_READY
));
56 w
|= ICAP_CE
|ICAP_WRITE
;
60 __attribute__((noreturn
)) void reconf(void)
65 icap_write(0, 0xffff); /* dummy word */
66 icap_write(0, 0xffff); /* dummy word */
67 icap_write(0, 0xffff); /* dummy word */
68 icap_write(0, 0xffff); /* dummy word */
69 icap_write(1, 0xaa99); /* sync word part 1 */
70 icap_write(1, 0x5566); /* sync word part 2 */
71 icap_write(1, 0x30a1); /* write to command register */
72 icap_write(1, 0x0000); /* null command */
73 icap_write(1, 0x30a1); /* write to command register */
74 icap_write(1, 0x000e); /* reboot command */
75 icap_write(1, 0x2000); /* NOP */
76 icap_write(1, 0x2000); /* NOP */
77 icap_write(1, 0x2000); /* NOP */
78 icap_write(1, 0x2000); /* NOP */
79 icap_write(0, 0x1111); /* NULL */
80 icap_write(0, 0xffff); /* dummy word */