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 <asm/ilsel.h>
19 
20 static struct resource heartbeat_resources[] = {
21 	[0] = {
22 		.start	= 0xb8140020,
23 		.end	= 0xb8140020,
24 		.flags	= IORESOURCE_MEM,
25 	},
26 };
27 
28 static struct platform_device heartbeat_device = {
29 	.name		= "heartbeat",
30 	.id		= -1,
31 	.num_resources	= ARRAY_SIZE(heartbeat_resources),
32 	.resource	= heartbeat_resources,
33 };
34 
35 static struct smc91x_platdata smc91x_info = {
36 	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT,
37 };
38 
39 static struct resource smc91x_resources[] = {
40 	[0] = {
41 		.start		= 0x18000300,
42 		.end		= 0x18000300 + 0x10 - 1,
43 		.flags		= IORESOURCE_MEM,
44 	},
45 	[1] = {
46 		/* Filled in by ilsel */
47 		.flags		= IORESOURCE_IRQ,
48 	},
49 };
50 
51 static struct platform_device smc91x_device = {
52 	.name		= "smc91x",
53 	.id		= -1,
54 	.resource	= smc91x_resources,
55 	.num_resources	= ARRAY_SIZE(smc91x_resources),
56 	.dev	= {
57 		.platform_data = &smc91x_info,
58 	},
59 };
60 
61 static struct resource r8a66597_usb_host_resources[] = {
62 	[0] = {
63 		.name	= "r8a66597_hcd",
64 		.start	= 0x18040000,
65 		.end	= 0x18080000 - 1,
66 		.flags	= IORESOURCE_MEM,
67 	},
68 	[1] = {
69 		.name	= "r8a66597_hcd",
70 		/* Filled in by ilsel */
71 		.flags	= IORESOURCE_IRQ,
72 	},
73 };
74 
75 static struct platform_device r8a66597_usb_host_device = {
76 	.name		= "r8a66597_hcd",
77 	.id		= -1,
78 	.dev = {
79 		.dma_mask		= NULL,		/* don't use dma */
80 		.coherent_dma_mask	= 0xffffffff,
81 	},
82 	.num_resources	= ARRAY_SIZE(r8a66597_usb_host_resources),
83 	.resource	= r8a66597_usb_host_resources,
84 };
85 
86 static struct resource m66592_usb_peripheral_resources[] = {
87 	[0] = {
88 		.name	= "m66592_udc",
89 		.start	= 0x18080000,
90 		.end	= 0x180c0000 - 1,
91 		.flags	= IORESOURCE_MEM,
92 	},
93 	[1] = {
94 		.name	= "m66592_udc",
95 		/* Filled in by ilsel */
96 		.flags	= IORESOURCE_IRQ,
97 	},
98 };
99 
100 static struct platform_device m66592_usb_peripheral_device = {
101 	.name		= "m66592_udc",
102 	.id		= -1,
103 	.dev = {
104 		.dma_mask		= NULL,		/* don't use dma */
105 		.coherent_dma_mask	= 0xffffffff,
106 	},
107 	.num_resources	= ARRAY_SIZE(m66592_usb_peripheral_resources),
108 	.resource	= m66592_usb_peripheral_resources,
109 };
110 
111 static struct platform_device *x3proto_devices[] __initdata = {
112 	&heartbeat_device,
113 	&smc91x_device,
114 	&r8a66597_usb_host_device,
115 	&m66592_usb_peripheral_device,
116 };
117 
118 static int __init x3proto_devices_setup(void)
119 {
120 	r8a66597_usb_host_resources[1].start =
121 		r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I);
122 
123 	m66592_usb_peripheral_resources[1].start =
124 		m66592_usb_peripheral_resources[1].end = ilsel_enable(ILSEL_USBP_I);
125 
126 	smc91x_resources[1].start =
127 		smc91x_resources[1].end = ilsel_enable(ILSEL_LAN);
128 
129 	return platform_add_devices(x3proto_devices,
130 				    ARRAY_SIZE(x3proto_devices));
131 }
132 device_initcall(x3proto_devices_setup);
133 
134 static void __init x3proto_init_irq(void)
135 {
136 	plat_irq_setup_pins(IRQ_MODE_IRL3210);
137 
138 	/* Set ICR0.LVLMODE */
139 	ctrl_outl(ctrl_inl(0xfe410000) | (1 << 21), 0xfe410000);
140 }
141 
142 static struct sh_machine_vector mv_x3proto __initmv = {
143 	.mv_name		= "x3proto",
144 	.mv_init_irq		= x3proto_init_irq,
145 };
146