5030565a2c5a56a57a0830fa4d3fc36c20ebfb0a
[openwrt.git] / target / linux / adm8668 / files / arch / mips / adm8668 / platform.c
1 /*
2  * Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
3  * Copyright (C) 2012 Florian Fainelli <florian@openwrt.org>
4  *
5  * This file is subject to the terms and conditions of the GNU General Public
6  * License.  See the file "COPYING" in the main directory of this archive
7  * for more details.
8  */
9
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/physmap.h>
14 #include <linux/pci.h>
15 #include <linux/slab.h>
16 #include <linux/ioport.h>
17 #include <linux/amba/bus.h>
18 #include <linux/amba/serial.h>
19
20 #include <asm/reboot.h>
21 #include <asm/time.h>
22 #include <asm/addrspace.h>
23 #include <asm/bootinfo.h>
24 #include <asm/io.h>
25 #include <adm8668.h>
26
27 static void adm8668_uart_set_mctrl(struct amba_device *dev,
28                                         void __iomem *base,
29                                         unsigned int mcrtl)
30 {
31 }
32
33 static struct amba_pl010_data adm8668_uart0_data = {
34         .set_mctrl = adm8668_uart_set_mctrl,
35 };
36
37 static struct amba_device adm8668_uart0_device = {
38         .dev = {
39                 .init_name      = "apb:uart0",
40                 .platform_data  = &adm8668_uart0_data,
41         },
42         .res = {
43                 .start          = ADM8668_UART0_BASE,
44                 .end            = ADM8668_UART0_BASE + 0xF,
45                 .flags          = IORESOURCE_MEM,
46         },
47         .irq = {
48                 INT_LVL_UART0,
49                 -1
50         },
51         .periphid = 0x0041010,
52 };
53
54 static struct resource eth0_resources[] = {
55         {
56                 .start          = ADM8668_LAN_BASE,
57                 .end            = ADM8668_LAN_BASE + 256,
58                 .flags          = IORESOURCE_MEM,
59         },
60         {
61                 .start          = INT_LVL_LAN,
62                 .flags          = IORESOURCE_IRQ,
63         },
64 };
65
66 static struct platform_device adm8668_eth0_device = {
67         .name           = "adm8668_eth",
68         .id             = 0,
69         .resource       = eth0_resources,
70         .num_resources  = ARRAY_SIZE(eth0_resources),
71 };
72
73 static struct resource eth1_resources[] = {
74         {
75                 .start          = ADM8668_WAN_BASE,
76                 .end            = ADM8668_WAN_BASE + 256,
77                 .flags          = IORESOURCE_MEM,
78         },
79         {
80                 .start          = INT_LVL_WAN,
81                 .flags          = IORESOURCE_IRQ,
82         },
83 };
84
85 static struct platform_device adm8668_eth1_device = {
86         .name           = "adm8668_eth",
87         .id             = 1,
88         .resource       = eth1_resources,
89         .num_resources  = ARRAY_SIZE(eth1_resources),
90 };
91
92 static struct platform_device *adm8668_devs[] = {
93         &adm8668_eth0_device,
94         &adm8668_eth1_device,
95 };
96
97 int __devinit adm8668_devs_register(void)
98 {
99         int ret;
100
101         ret = amba_device_register(&adm8668_uart0_device, &iomem_resource);
102         if (ret)
103                 panic("failed to register AMBA UART");
104
105         return platform_add_devices(adm8668_devs, ARRAY_SIZE(adm8668_devs));
106 }
107 arch_initcall(adm8668_devs_register);