sh: mach-se: Convert SE7343 FPGA to dynamic IRQ allocation.
[linux-2.6.git] / arch / sh / boards / mach-se / 7343 / setup.c
1 #include <linux/init.h>
2 #include <linux/platform_device.h>
3 #include <linux/mtd/physmap.h>
4 #include <linux/serial_8250.h>
5 #include <linux/serial_reg.h>
6 #include <linux/usb/isp116x.h>
7 #include <linux/delay.h>
8 #include <asm/machvec.h>
9 #include <mach-se/mach/se7343.h>
10 #include <asm/heartbeat.h>
11 #include <asm/irq.h>
12 #include <asm/io.h>
13
14 static struct resource heartbeat_resources[] = {
15         [0] = {
16                 .start  = PA_LED,
17                 .end    = PA_LED,
18                 .flags  = IORESOURCE_MEM,
19         },
20 };
21
22 static struct heartbeat_data heartbeat_data = {
23         .regsize = 16,
24 };
25
26 static struct platform_device heartbeat_device = {
27         .name           = "heartbeat",
28         .id             = -1,
29         .dev = {
30                 .platform_data = &heartbeat_data,
31         },
32         .num_resources  = ARRAY_SIZE(heartbeat_resources),
33         .resource       = heartbeat_resources,
34 };
35
36 static struct mtd_partition nor_flash_partitions[] = {
37         {
38                 .name           = "loader",
39                 .offset         = 0x00000000,
40                 .size           = 128 * 1024,
41         },
42         {
43                 .name           = "rootfs",
44                 .offset         = MTDPART_OFS_APPEND,
45                 .size           = 31 * 1024 * 1024,
46         },
47         {
48                 .name           = "data",
49                 .offset         = MTDPART_OFS_APPEND,
50                 .size           = MTDPART_SIZ_FULL,
51         },
52 };
53
54 static struct physmap_flash_data nor_flash_data = {
55         .width          = 2,
56         .parts          = nor_flash_partitions,
57         .nr_parts       = ARRAY_SIZE(nor_flash_partitions),
58 };
59
60 static struct resource nor_flash_resources[] = {
61         [0]     = {
62                 .start  = 0x00000000,
63                 .end    = 0x01ffffff,
64                 .flags  = IORESOURCE_MEM,
65         }
66 };
67
68 static struct platform_device nor_flash_device = {
69         .name           = "physmap-flash",
70         .dev            = {
71                 .platform_data  = &nor_flash_data,
72         },
73         .num_resources  = ARRAY_SIZE(nor_flash_resources),
74         .resource       = nor_flash_resources,
75 };
76
77 #define ST16C2550C_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP)
78
79 static struct plat_serial8250_port serial_platform_data[] = {
80         [0] = {
81                 .iotype         = UPIO_MEM,
82                 .mapbase        = 0x16000000,
83                 .regshift       = 1,
84                 .flags          = ST16C2550C_FLAGS,
85                 .uartclk        = 7372800,
86         },
87         [1] = {
88                 .iotype         = UPIO_MEM,
89                 .mapbase        = 0x17000000,
90                 .regshift       = 1,
91                 .flags          = ST16C2550C_FLAGS,
92                 .uartclk        = 7372800,
93         },
94         { },
95 };
96
97 static struct platform_device uart_device = {
98         .name                   = "serial8250",
99         .id                     = PLAT8250_DEV_PLATFORM,
100         .dev                    = {
101                 .platform_data  = serial_platform_data,
102         },
103 };
104
105 static void isp116x_delay(struct device *dev, int delay)
106 {
107         ndelay(delay);
108 }
109
110 static struct resource usb_resources[] = {
111         [0] = {
112                 .start  = 0x11800000,
113                 .end    = 0x11800001,
114                 .flags  = IORESOURCE_MEM,
115         },
116         [1] = {
117                 .start  = 0x11800002,
118                 .end    = 0x11800003,
119                 .flags  = IORESOURCE_MEM,
120         },
121         [2] = {
122                 /* Filled in later */
123                 .flags  = IORESOURCE_IRQ,
124         },
125 };
126
127 static struct isp116x_platform_data usb_platform_data = {
128         .sel15Kres              = 1,
129         .oc_enable              = 1,
130         .int_act_high           = 0,
131         .int_edge_triggered     = 0,
132         .remote_wakeup_enable   = 0,
133         .delay                  = isp116x_delay,
134 };
135
136 static struct platform_device usb_device = {
137         .name                   = "isp116x-hcd",
138         .id                     = -1,
139         .num_resources          = ARRAY_SIZE(usb_resources),
140         .resource               = usb_resources,
141         .dev                    = {
142                 .platform_data  = &usb_platform_data,
143         },
144
145 };
146
147 static struct platform_device *sh7343se_platform_devices[] __initdata = {
148         &heartbeat_device,
149         &nor_flash_device,
150         &uart_device,
151         &usb_device,
152 };
153
154 static int __init sh7343se_devices_setup(void)
155 {
156         /* Wire-up dynamic vectors */
157         serial_platform_data[0].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTA];
158         serial_platform_data[1].irq = se7343_fpga_irq[SE7343_FPGA_IRQ_UARTB];
159
160         usb_resources[2].start = usb_resources[2].end =
161                 se7343_fpga_irq[SE7343_FPGA_IRQ_USB];
162
163         return platform_add_devices(sh7343se_platform_devices,
164                                     ARRAY_SIZE(sh7343se_platform_devices));
165 }
166 device_initcall(sh7343se_devices_setup);
167
168 /*
169  * Initialize the board
170  */
171 static void __init sh7343se_setup(char **cmdline_p)
172 {
173         ctrl_outw(0xf900, FPGA_OUT);    /* FPGA */
174
175         ctrl_outw(0x0002, PORT_PECR);   /* PORT E 1 = IRQ5 */
176         ctrl_outw(0x0020, PORT_PSELD);
177
178         printk(KERN_INFO "MS7343CP01 Setup...done\n");
179 }
180
181 /*
182  * The Machine Vector
183  */
184 static struct sh_machine_vector mv_7343se __initmv = {
185         .mv_name = "SolutionEngine 7343",
186         .mv_setup = sh7343se_setup,
187         .mv_init_irq = init_7343se_IRQ,
188 };