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>
23 static struct resource uart_resources
[] = {
25 .start
= ADM8668_UART0_BASE
,
26 .end
= ADM8668_UART0_BASE
+ 0xF,
27 .flags
= IORESOURCE_MEM
,
30 .start
= INT_LVL_UART0
,
31 .flags
= IORESOURCE_IRQ
,
35 static struct platform_device adm8668_uart_device
= {
36 .name
= "adm8668_uart",
38 .resource
= uart_resources
,
39 .num_resources
= ARRAY_SIZE(uart_resources
),
42 static struct resource eth0_resources
[] = {
44 .start
= ADM8668_LAN_BASE
,
45 .end
= ADM8668_LAN_BASE
+ 256,
46 .flags
= IORESOURCE_MEM
,
50 .flags
= IORESOURCE_IRQ
,
54 static struct platform_device adm8668_eth0_device
= {
55 .name
= "adm8668_eth",
57 .resource
= eth0_resources
,
58 .num_resources
= ARRAY_SIZE(eth0_resources
),
61 static struct resource eth1_resources
[] = {
63 .start
= ADM8668_WAN_BASE
,
64 .end
= ADM8668_WAN_BASE
+ 256,
65 .flags
= IORESOURCE_MEM
,
69 .flags
= IORESOURCE_IRQ
,
73 static struct platform_device adm8668_eth1_device
= {
74 .name
= "adm8668_eth",
76 .resource
= eth1_resources
,
77 .num_resources
= ARRAY_SIZE(eth1_resources
),
80 static void adm8668_restart(char *cmd
)
84 /* stop eth0 and eth1 */
85 ADM8668_LAN_REG(NETCSR6
) = (1 << 13) | (1 << 1);
86 ADM8668_LAN_REG(NETCSR7
) = 0;
87 ADM8668_WAN_REG(NETCSR6
) = (1 << 13) | (1 << 1);
88 ADM8668_WAN_REG(NETCSR7
) = 0;
91 ADM8668_WAN_REG(NETCSR37
) = 0x20;
92 for (i
= 0; i
< 10000; i
++)
94 ADM8668_WAN_REG(NETCSR37
) = 0;
95 for (i
= 0; i
< 10000; i
++)
98 *(volatile unsigned int *)0xB1600000 = 1; /* reset eth0 mac */
99 *(volatile unsigned int *)0xB1A00000 = 1; /* reset eth1 mac */
100 *(volatile unsigned int *)0xB1800000 = 1; /* reset wlan0 mac */
103 for (i
= 0; i
< 1000; i
++)
105 ADM8668_CONFIG_REG(ADM8668_CR1
) = 1;
108 int __devinit
adm8668_devs_register(void)
110 _machine_restart
= adm8668_restart
;
111 platform_device_register(&adm8668_uart_device
);
112 platform_device_register(&adm8668_eth0_device
);
113 platform_device_register(&adm8668_eth1_device
);
118 void __init
plat_time_init(void)
120 int adj
= (ADM8668_CONFIG_REG(ADM8668_CR3
) >> 11) & 0xf;
122 /* adjustable clock selection
123 CR3 bit 14~11, 0000 -> 175MHz, 0001 -> 180MHz, etc... */
125 mips_hpt_frequency
= (SYS_CLOCK
+ adj
* 5000000) / 2;
126 printk("ADM8668 CPU clock: %d MHz\n", 2*mips_hpt_frequency
/ 1000000);
129 void __init
plat_mem_setup(void)
131 /* prom_init seemed like easier place for this. it's tooo simple */
134 const char *get_system_type(void)
136 unsigned long chipid
= ADM8668_CONFIG_REG(ADM8668_CR0
);
137 int adj
= (ADM8668_CONFIG_REG(ADM8668_CR3
) >> 11) & 0xf;
138 int product
, revision
, mhz
;
141 product
= chipid
>> 16;
142 revision
= chipid
& 0xffff;
143 mhz
= (SYS_CLOCK
/1000000) + (adj
* 5);
145 /* i getting fancy :\ */
146 snprintf(ret
, sizeof(ret
), "ADM%xr%x %dMHz", product
, revision
, mhz
);
151 arch_initcall(adm8668_devs_register
);