[adm8668] move setup-related functions to their own file
[openwrt/svn-archive/archive.git] / target / linux / adm8668 / files / arch / mips / adm8668 / platform.c
1 /*
2 * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
3 *
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
6 * for more details.
7 */
8
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>
17 #include <asm/time.h>
18 #include <asm/addrspace.h>
19 #include <asm/bootinfo.h>
20 #include <asm/io.h>
21 #include <adm8668.h>
22
23 static struct resource uart_resources[] = {
24 {
25 .start = ADM8668_UART0_BASE,
26 .end = ADM8668_UART0_BASE + 0xF,
27 .flags = IORESOURCE_MEM,
28 },
29 {
30 .start = INT_LVL_UART0,
31 .flags = IORESOURCE_IRQ,
32 },
33 };
34
35 static struct platform_device adm8668_uart_device = {
36 .name = "adm8668_uart",
37 .id = 0,
38 .resource = uart_resources,
39 .num_resources = ARRAY_SIZE(uart_resources),
40 };
41
42 static struct resource eth0_resources[] = {
43 {
44 .start = ADM8668_LAN_BASE,
45 .end = ADM8668_LAN_BASE + 256,
46 .flags = IORESOURCE_MEM,
47 },
48 {
49 .start = INT_LVL_LAN,
50 .flags = IORESOURCE_IRQ,
51 },
52 };
53
54 static struct platform_device adm8668_eth0_device = {
55 .name = "adm8668_eth",
56 .id = 0,
57 .resource = eth0_resources,
58 .num_resources = ARRAY_SIZE(eth0_resources),
59 };
60
61 static struct resource eth1_resources[] = {
62 {
63 .start = ADM8668_WAN_BASE,
64 .end = ADM8668_WAN_BASE + 256,
65 .flags = IORESOURCE_MEM,
66 },
67 {
68 .start = INT_LVL_WAN,
69 .flags = IORESOURCE_IRQ,
70 },
71 };
72
73 static struct platform_device adm8668_eth1_device = {
74 .name = "adm8668_eth",
75 .id = 1,
76 .resource = eth1_resources,
77 .num_resources = ARRAY_SIZE(eth1_resources),
78 };
79
80 int __devinit adm8668_devs_register(void)
81 {
82 platform_device_register(&adm8668_uart_device);
83 platform_device_register(&adm8668_eth0_device);
84 platform_device_register(&adm8668_eth1_device);
85
86 return 0;
87 }
88
89 void __init plat_time_init(void)
90 {
91 int adj = (ADM8668_CONFIG_REG(ADM8668_CR3) >> 11) & 0xf;
92
93 /* adjustable clock selection
94 CR3 bit 14~11, 0000 -> 175MHz, 0001 -> 180MHz, etc... */
95
96 mips_hpt_frequency = (SYS_CLOCK + adj * 5000000) / 2;
97 printk("ADM8668 CPU clock: %d MHz\n", 2*mips_hpt_frequency / 1000000);
98 }
99
100 arch_initcall(adm8668_devs_register);