5a177f2a505166aaf5886865e14ed2f0c24bad1b
[openwrt.git] / target / linux / adm8668 / files / arch / mips / adm8668 / setup.c
1 #include <linux/init.h>
2 #include <linux/reboot.h>
3
4 #include <asm/reboot.h>
5 #include <adm8668.h>
6
7 static void adm8668_restart(char *cmd)
8 {
9         int i;
10
11         /* stop eth0 and eth1 */
12         ADM8668_LAN_REG(NETCSR6) = (1 << 13) | (1 << 1);
13         ADM8668_LAN_REG(NETCSR7) = 0;
14         ADM8668_WAN_REG(NETCSR6) = (1 << 13) | (1 << 1);
15         ADM8668_WAN_REG(NETCSR7) = 0;
16
17         /* reset PHY */
18         ADM8668_WAN_REG(NETCSR37) = 0x20;
19         for (i = 0; i < 10000; i++)
20                 ;
21         ADM8668_WAN_REG(NETCSR37) = 0;
22         for (i = 0; i < 10000; i++)
23                 ;
24
25         /* the real deal */
26         for (i = 0; i < 1000; i++)
27                 ;
28         ADM8668_CONFIG_REG(ADM8668_CR1) = 1;
29 }
30
31 void __init plat_mem_setup(void)
32 {
33         _machine_restart = adm8668_restart;
34 }
35
36 const char *get_system_type(void)
37 {
38         unsigned long chipid = ADM8668_CONFIG_REG(ADM8668_CR0);
39         int product, revision;
40         static char ret[32];
41
42         product = chipid >> 16;
43         revision = chipid & 0xffff;
44
45         /* i getting fancy :\ */
46         snprintf(ret, sizeof(ret), "ADM%xr%x", product, revision);
47
48         return ret;
49 }
50