2 * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/physmap.h>
13 #include <linux/pci.h>
14 #include <linux/slab.h>
15 #include <linux/ioport.h>
16 #include <asm/reboot.h>
18 #include <asm/addrspace.h>
19 #include <asm/bootinfo.h>
24 #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
26 static struct resource uart_resources[] = {
28 .start = ADM8668_UART0_BASE,
29 .end = ADM8668_UART0_BASE + 0xF,
30 .flags = IORESOURCE_MEM,
33 .start = INT_LVL_UART0,
34 .flags = IORESOURCE_IRQ,
38 static struct platform_device adm8668_uart_device = {
39 .name = "adm8668_uart",
41 .resource = uart_resources,
42 .num_resources = ARRAY_SIZE(uart_resources),
45 static struct resource eth0_resources[] = {
47 .start = ADM8668_LAN_BASE,
48 .end = ADM8668_LAN_BASE + 256,
49 .flags = IORESOURCE_MEM,
53 .flags = IORESOURCE_IRQ,
57 static struct platform_device adm8668_eth0_device = {
58 .name = "adm8668_eth",
60 .resource = eth0_resources,
61 .num_resources = ARRAY_SIZE(eth0_resources),
64 static struct resource eth1_resources[] = {
66 .start = ADM8668_WAN_BASE,
67 .end = ADM8668_WAN_BASE + 256,
68 .flags = IORESOURCE_MEM,
72 .flags = IORESOURCE_IRQ,
76 static struct platform_device adm8668_eth1_device = {
77 .name = "adm8668_eth",
79 .resource = eth1_resources,
80 .num_resources = ARRAY_SIZE(eth1_resources),
83 static void adm8668_restart(char *cmd)
87 /* stop eth0 and eth1 */
88 ADM8668_LAN_REG(NETCSR6) = BIT_1|BIT_13;
89 ADM8668_LAN_REG(NETCSR7) = 0;
90 ADM8668_WAN_REG(NETCSR6) = BIT_1|BIT_13;
91 ADM8668_WAN_REG(NETCSR7) = 0;
94 ADM8668_WAN_REG(NETCSR37) = 0x20;
95 for (i = 0; i < 10000; i++)
97 ADM8668_WAN_REG(NETCSR37) = 0;
98 for (i = 0; i < 10000; i++)
101 *(volatile unsigned int *)0xB1600000 = 1; /* reset eth0 mac */
102 *(volatile unsigned int *)0xB1A00000 = 1; /* reset eth1 mac */
103 *(volatile unsigned int *)0xB1800000 = 1; /* reset wlan0 mac */
106 for (i = 0; i < 1000; i++)
108 ADM8668_CONFIG_REG(ADM8668_CR1) = BIT_0;
111 int __devinit adm8668_devs_register(void)
113 _machine_restart = adm8668_restart;
114 platform_device_register(&adm8668_uart_device);
115 platform_device_register(&adm8668_eth0_device);
116 platform_device_register(&adm8668_eth1_device);
121 void __init plat_time_init(void)
123 int adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
125 /* adjustable clock selection
126 CR3 bit 14~11, 0000 -> 175MHz, 0001 -> 180MHz, etc... */
128 mips_hpt_frequency = (SYS_CLOCK + adj * 5000000) / 2;
129 printk("ADM8668 CPU clock: %d MHz\n", 2*mips_hpt_frequency / 1000000);
132 void __init plat_mem_setup(void)
134 /* prom_init seemed like easier place for this. it's tooo simple */
137 const char *get_system_type(void)
139 unsigned long chipid = ADM8668_CONFIG_REG(ADM8668_CR0);
140 int adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
141 int product, revision, mhz;
144 product = chipid >> 16;
145 revision = chipid & 0xffff;
146 mhz = (SYS_CLOCK/1000000) + (adj * 5);
148 /* i getting fancy :\ */
149 snprintf(ret, sizeof(ret), "ADM%xr%x %dMHz", product, revision, mhz);
154 arch_initcall(adm8668_devs_register);