summaryrefslogtreecommitdiffstats
path: root/target/linux/adm8668/files/arch/mips/adm8668/setup.c
blob: 927d827284d6fa0034f7d4b8e1e6a6a71f64b8fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <linux/init.h>
#include <linux/reboot.h>

#include <asm/reboot.h>
#include <adm8668.h>

static void adm8668_restart(char *cmd)
{
	int i;

	/* stop eth0 and eth1 */
	ADM8668_LAN_REG(NETCSR6) = (1 << 13) | (1 << 1);
	ADM8668_LAN_REG(NETCSR7) = 0;
	ADM8668_WAN_REG(NETCSR6) = (1 << 13) | (1 << 1);
	ADM8668_WAN_REG(NETCSR7) = 0;

	/* reset PHY */
	ADM8668_WAN_REG(NETCSR37) = 0x20;
	for (i = 0; i < 10000; i++)
		;
	ADM8668_WAN_REG(NETCSR37) = 0;
	for (i = 0; i < 10000; i++)
		;

	/* the real deal */
	for (i = 0; i < 1000; i++)
		;
	ADM8668_CONFIG_REG(ADM8668_CR1) = 1;
}

void __init plat_mem_setup(void)
{
	_machine_restart = adm8668_restart;
}

const char *get_system_type(void)
{
        unsigned long chipid = ADM8668_CONFIG_REG(ADM8668_CR0);
        int adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
        int product, revision, mhz;
	static char ret[32];

        product = chipid >> 16;
        revision = chipid & 0xffff;
	mhz = (SYS_CLOCK/1000000) + (adj * 5);

	/* i getting fancy :\ */
	snprintf(ret, sizeof(ret), "ADM%xr%x %dMHz", product, revision, mhz);

	return ret;
}