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