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