Merge branch 'drm-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / arch / sh / boards / mach-x3proto / setup.c
1 /*
2  * arch/sh/boards/renesas/x3proto/setup.c
3  *
4  * Renesas SH-X3 Prototype Board Support.
5  *
6  * Copyright (C) 2007 - 2008 Paul Mundt
7  *
8  * This file is subject to the terms and conditions of the GNU General Public
9  * License.  See the file "COPYING" in the main directory of this archive
10  * for more details.
11  */
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/kernel.h>
15 #include <linux/io.h>
16 #include <linux/smc91x.h>
17 #include <linux/irq.h>
18 #include <linux/interrupt.h>
19 #include <linux/usb/r8a66597.h>
20 #include <asm/ilsel.h>
21
22 static struct resource heartbeat_resources[] = {
23         [0] = {
24                 .start  = 0xb8140020,
25                 .end    = 0xb8140020,
26                 .flags  = IORESOURCE_MEM,
27         },
28 };
29
30 static struct platform_device heartbeat_device = {
31         .name           = "heartbeat",
32         .id             = -1,
33         .num_resources  = ARRAY_SIZE(heartbeat_resources),
34         .resource       = heartbeat_resources,
35 };
36
37 static struct smc91x_platdata smc91x_info = {
38         .flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT,
39 };
40
41 static struct resource smc91x_resources[] = {
42         [0] = {
43                 .start          = 0x18000300,
44                 .end            = 0x18000300 + 0x10 - 1,
45                 .flags          = IORESOURCE_MEM,
46         },
47         [1] = {
48                 /* Filled in by ilsel */
49                 .flags          = IORESOURCE_IRQ,
50         },
51 };
52
53 static struct platform_device smc91x_device = {
54         .name           = "smc91x",
55         .id             = -1,
56         .resource       = smc91x_resources,
57         .num_resources  = ARRAY_SIZE(smc91x_resources),
58         .dev    = {
59                 .platform_data = &smc91x_info,
60         },
61 };
62
63 static struct r8a66597_platdata r8a66597_data = {
64         .xtal = R8A66597_PLATDATA_XTAL_12MHZ,
65         .vif = 1,
66 };
67
68 static struct resource r8a66597_usb_host_resources[] = {
69         [0] = {
70                 .start  = 0x18040000,
71                 .end    = 0x18080000 - 1,
72                 .flags  = IORESOURCE_MEM,
73         },
74         [1] = {
75                 /* Filled in by ilsel */
76                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
77         },
78 };
79
80 static struct platform_device r8a66597_usb_host_device = {
81         .name           = "r8a66597_hcd",
82         .id             = -1,
83         .dev = {
84                 .dma_mask               = NULL,         /* don't use dma */
85                 .coherent_dma_mask      = 0xffffffff,
86                 .platform_data          = &r8a66597_data,
87         },
88         .num_resources  = ARRAY_SIZE(r8a66597_usb_host_resources),
89         .resource       = r8a66597_usb_host_resources,
90 };
91
92 static struct resource m66592_usb_peripheral_resources[] = {
93         [0] = {
94                 .name   = "m66592_udc",
95                 .start  = 0x18080000,
96                 .end    = 0x180c0000 - 1,
97                 .flags  = IORESOURCE_MEM,
98         },
99         [1] = {
100                 .name   = "m66592_udc",
101                 /* Filled in by ilsel */
102                 .flags  = IORESOURCE_IRQ,
103         },
104 };
105
106 static struct platform_device m66592_usb_peripheral_device = {
107         .name           = "m66592_udc",
108         .id             = -1,
109         .dev = {
110                 .dma_mask               = NULL,         /* don't use dma */
111                 .coherent_dma_mask      = 0xffffffff,
112         },
113         .num_resources  = ARRAY_SIZE(m66592_usb_peripheral_resources),
114         .resource       = m66592_usb_peripheral_resources,
115 };
116
117 static struct platform_device *x3proto_devices[] __initdata = {
118         &heartbeat_device,
119         &smc91x_device,
120         &r8a66597_usb_host_device,
121         &m66592_usb_peripheral_device,
122 };
123
124 static int __init x3proto_devices_setup(void)
125 {
126         r8a66597_usb_host_resources[1].start =
127                 r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I);
128
129         m66592_usb_peripheral_resources[1].start =
130                 m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I);
131
132         smc91x_resources[1].start =
133                 smc91x_resources[1].end = ilsel_enable(ILSEL_LAN);
134
135         return platform_add_devices(x3proto_devices,
136                                     ARRAY_SIZE(x3proto_devices));
137 }
138 device_initcall(x3proto_devices_setup);
139
140 static void __init x3proto_init_irq(void)
141 {
142         plat_irq_setup_pins(IRQ_MODE_IRL3210);
143
144         /* Set ICR0.LVLMODE */
145         ctrl_outl(ctrl_inl(0xfe410000) | (1 << 21), 0xfe410000);
146 }
147
148 static struct sh_machine_vector mv_x3proto __initmv = {
149         .mv_name                = "x3proto",
150         .mv_init_irq            = x3proto_init_irq,
151 };