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