[adm8668] move setup-related functions to their own file
[openwrt/svn-archive/archive.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 adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
40 int product, revision, mhz;
41 static char ret[32];
42
43 product = chipid >> 16;
44 revision = chipid & 0xffff;
45 mhz = (SYS_CLOCK/1000000) + (adj * 5);
46
47 /* i getting fancy :\ */
48 snprintf(ret, sizeof(ret), "ADM%xr%x %dMHz", product, revision, mhz);
49
50 return ret;
51 }
52