Commit | Line | Data |
---|---|---|
920adc75 KM |
1 | /* |
2 | * mackerel board support | |
3 | * | |
4 | * Copyright (C) 2010 Renesas Solutions Corp. | |
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | |
6 | * | |
7 | * based on ap4evb | |
8 | * Copyright (C) 2010 Magnus Damm | |
9 | * Copyright (C) 2008 Yoshihiro Shimoda | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify | |
12 | * it under the terms of the GNU General Public License as published by | |
13 | * the Free Software Foundation; version 2 of the License. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
23 | */ | |
24 | #include <linux/kernel.h> | |
25 | #include <linux/init.h> | |
26 | #include <linux/interrupt.h> | |
27 | #include <linux/irq.h> | |
28 | #include <linux/platform_device.h> | |
29 | #include <linux/gpio.h> | |
30 | #include <linux/input.h> | |
31 | #include <linux/io.h> | |
32 | #include <linux/mtd/mtd.h> | |
33 | #include <linux/mtd/partitions.h> | |
34 | #include <linux/mtd/physmap.h> | |
2264c151 | 35 | #include <linux/smsc911x.h> |
920adc75 | 36 | |
11fee467 KM |
37 | #include <video/sh_mobile_lcdc.h> |
38 | ||
920adc75 KM |
39 | #include <mach/common.h> |
40 | #include <mach/sh7372.h> | |
41 | ||
42 | #include <asm/mach/arch.h> | |
43 | #include <asm/mach/time.h> | |
44 | #include <asm/mach/map.h> | |
45 | #include <asm/mach-types.h> | |
46 | ||
47 | /* | |
48 | * Address Interface BusWidth note | |
49 | * ------------------------------------------------------------------ | |
50 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON | |
51 | * 0x0800_0000 user area - | |
52 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF | |
53 | * 0x1400_0000 Ether (LAN9220) 16bit | |
54 | * 0x1600_0000 user area - cannot use with NAND | |
55 | * 0x1800_0000 user area - | |
56 | * 0x1A00_0000 - | |
57 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit | |
58 | */ | |
59 | ||
4b82b689 KM |
60 | /* |
61 | * CPU mode | |
62 | * | |
63 | * SW4 | Boot Area| Master | Remarks | |
64 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| | |
65 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- | |
66 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM | |
67 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug | |
68 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug | |
69 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM | |
70 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM | |
71 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM | |
72 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone | |
73 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone | |
74 | */ | |
75 | ||
76 | /* | |
77 | * NOR Flash ROM | |
78 | * | |
79 | * SW1 | SW2 | SW7 | NOR Flash ROM | |
80 | * bit1 | bit1 bit2 | bit1 | Memory allocation | |
81 | * ------+------------+------+------------------ | |
82 | * OFF | ON OFF | ON | Area 0 | |
83 | * OFF | ON OFF | OFF | Area 4 | |
84 | */ | |
85 | ||
86 | /* | |
87 | * SMSC 9220 | |
88 | * | |
89 | * SW1 SMSC 9220 | |
90 | * ----------------------- | |
91 | * ON access disable | |
92 | * OFF access enable | |
93 | */ | |
94 | ||
95 | /* | |
96 | * NAND Flash ROM | |
97 | * | |
98 | * SW1 | SW2 | SW7 | NAND Flash ROM | |
99 | * bit1 | bit1 bit2 | bit2 | Memory allocation | |
100 | * ------+------------+------+------------------ | |
101 | * OFF | ON OFF | ON | FCE 0 | |
102 | * OFF | ON OFF | OFF | FCE 1 | |
103 | */ | |
104 | ||
105 | /* | |
106 | * External interrupt pin settings | |
107 | * | |
108 | * IRQX | pin setting | device | level | |
109 | * ------+--------------------+--------------------+------- | |
110 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low | |
111 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High | |
112 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low | |
113 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low | |
114 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low | |
115 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High | |
116 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High | |
117 | ||
118 | */ | |
119 | ||
920adc75 KM |
120 | /* MTD */ |
121 | static struct mtd_partition nor_flash_partitions[] = { | |
122 | { | |
123 | .name = "loader", | |
124 | .offset = 0x00000000, | |
125 | .size = 512 * 1024, | |
126 | .mask_flags = MTD_WRITEABLE, | |
127 | }, | |
128 | { | |
129 | .name = "bootenv", | |
130 | .offset = MTDPART_OFS_APPEND, | |
131 | .size = 512 * 1024, | |
132 | .mask_flags = MTD_WRITEABLE, | |
133 | }, | |
134 | { | |
135 | .name = "kernel_ro", | |
136 | .offset = MTDPART_OFS_APPEND, | |
137 | .size = 8 * 1024 * 1024, | |
138 | .mask_flags = MTD_WRITEABLE, | |
139 | }, | |
140 | { | |
141 | .name = "kernel", | |
142 | .offset = MTDPART_OFS_APPEND, | |
143 | .size = 8 * 1024 * 1024, | |
144 | }, | |
145 | { | |
146 | .name = "data", | |
147 | .offset = MTDPART_OFS_APPEND, | |
148 | .size = MTDPART_SIZ_FULL, | |
149 | }, | |
150 | }; | |
151 | ||
152 | static struct physmap_flash_data nor_flash_data = { | |
153 | .width = 2, | |
154 | .parts = nor_flash_partitions, | |
155 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
156 | }; | |
157 | ||
158 | static struct resource nor_flash_resources[] = { | |
159 | [0] = { | |
160 | .start = 0x00000000, | |
161 | .end = 0x08000000 - 1, | |
162 | .flags = IORESOURCE_MEM, | |
163 | } | |
164 | }; | |
165 | ||
166 | static struct platform_device nor_flash_device = { | |
167 | .name = "physmap-flash", | |
168 | .dev = { | |
169 | .platform_data = &nor_flash_data, | |
170 | }, | |
171 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
172 | .resource = nor_flash_resources, | |
173 | }; | |
174 | ||
2264c151 KM |
175 | /* SMSC */ |
176 | static struct resource smc911x_resources[] = { | |
177 | { | |
178 | .start = 0x14000000, | |
179 | .end = 0x16000000 - 1, | |
180 | .flags = IORESOURCE_MEM, | |
181 | }, { | |
182 | .start = evt2irq(0x02c0) /* IRQ6A */, | |
183 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
184 | }, | |
185 | }; | |
186 | ||
187 | static struct smsc911x_platform_config smsc911x_info = { | |
188 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
189 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
190 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
191 | }; | |
192 | ||
193 | static struct platform_device smc911x_device = { | |
194 | .name = "smsc911x", | |
195 | .id = -1, | |
196 | .num_resources = ARRAY_SIZE(smc911x_resources), | |
197 | .resource = smc911x_resources, | |
198 | .dev = { | |
199 | .platform_data = &smsc911x_info, | |
200 | }, | |
201 | }; | |
202 | ||
11fee467 KM |
203 | /* LCDC */ |
204 | static struct fb_videomode mackerel_lcdc_modes[] = { | |
205 | { | |
206 | .name = "WVGA Panel", | |
207 | .xres = 800, | |
208 | .yres = 480, | |
209 | .left_margin = 220, | |
210 | .right_margin = 110, | |
211 | .hsync_len = 70, | |
212 | .upper_margin = 20, | |
213 | .lower_margin = 5, | |
214 | .vsync_len = 5, | |
215 | .sync = 0, | |
216 | }, | |
217 | }; | |
218 | ||
219 | static struct sh_mobile_lcdc_info lcdc_info = { | |
220 | .clock_source = LCDC_CLK_BUS, | |
221 | .ch[0] = { | |
222 | .chan = LCDC_CHAN_MAINLCD, | |
223 | .bpp = 16, | |
224 | .lcd_cfg = mackerel_lcdc_modes, | |
225 | .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), | |
226 | .interface_type = RGB24, | |
227 | .clock_divider = 2, | |
228 | .flags = 0, | |
229 | .lcd_size_cfg.width = 152, | |
230 | .lcd_size_cfg.height = 91, | |
231 | } | |
232 | }; | |
233 | ||
234 | static struct resource lcdc_resources[] = { | |
235 | [0] = { | |
236 | .name = "LCDC", | |
237 | .start = 0xfe940000, | |
238 | .end = 0xfe943fff, | |
239 | .flags = IORESOURCE_MEM, | |
240 | }, | |
241 | [1] = { | |
242 | .start = intcs_evt2irq(0x580), | |
243 | .flags = IORESOURCE_IRQ, | |
244 | }, | |
245 | }; | |
246 | ||
247 | static struct platform_device lcdc_device = { | |
248 | .name = "sh_mobile_lcdc_fb", | |
249 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
250 | .resource = lcdc_resources, | |
251 | .dev = { | |
252 | .platform_data = &lcdc_info, | |
253 | .coherent_dma_mask = ~0, | |
254 | }, | |
255 | }; | |
256 | ||
920adc75 KM |
257 | static struct platform_device *mackerel_devices[] __initdata = { |
258 | &nor_flash_device, | |
2264c151 | 259 | &smc911x_device, |
11fee467 | 260 | &lcdc_device, |
920adc75 KM |
261 | }; |
262 | ||
263 | static struct map_desc mackerel_io_desc[] __initdata = { | |
264 | /* create a 1:1 entity map for 0xe6xxxxxx | |
265 | * used by CPGA, INTC and PFC. | |
266 | */ | |
267 | { | |
268 | .virtual = 0xe6000000, | |
269 | .pfn = __phys_to_pfn(0xe6000000), | |
270 | .length = 256 << 20, | |
271 | .type = MT_DEVICE_NONSHARED | |
272 | }, | |
273 | }; | |
274 | ||
275 | static void __init mackerel_map_io(void) | |
276 | { | |
277 | iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); | |
278 | ||
279 | /* setup early devices and console here as well */ | |
280 | sh7372_add_early_devices(); | |
281 | shmobile_setup_console(); | |
282 | } | |
283 | ||
284 | static void __init mackerel_init(void) | |
285 | { | |
286 | sh7372_pinmux_init(); | |
287 | ||
288 | /* enable SCIFA0 */ | |
289 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); | |
290 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); | |
291 | ||
2264c151 KM |
292 | /* enable SMSC911X */ |
293 | gpio_request(GPIO_FN_CS5A, NULL); | |
294 | gpio_request(GPIO_FN_IRQ6_39, NULL); | |
295 | ||
11fee467 KM |
296 | /* LCDC */ |
297 | gpio_request(GPIO_FN_LCDD17, NULL); | |
298 | gpio_request(GPIO_FN_LCDD16, NULL); | |
299 | gpio_request(GPIO_FN_LCDD15, NULL); | |
300 | gpio_request(GPIO_FN_LCDD14, NULL); | |
301 | gpio_request(GPIO_FN_LCDD13, NULL); | |
302 | gpio_request(GPIO_FN_LCDD12, NULL); | |
303 | gpio_request(GPIO_FN_LCDD11, NULL); | |
304 | gpio_request(GPIO_FN_LCDD10, NULL); | |
305 | gpio_request(GPIO_FN_LCDD9, NULL); | |
306 | gpio_request(GPIO_FN_LCDD8, NULL); | |
307 | gpio_request(GPIO_FN_LCDD7, NULL); | |
308 | gpio_request(GPIO_FN_LCDD6, NULL); | |
309 | gpio_request(GPIO_FN_LCDD5, NULL); | |
310 | gpio_request(GPIO_FN_LCDD4, NULL); | |
311 | gpio_request(GPIO_FN_LCDD3, NULL); | |
312 | gpio_request(GPIO_FN_LCDD2, NULL); | |
313 | gpio_request(GPIO_FN_LCDD1, NULL); | |
314 | gpio_request(GPIO_FN_LCDD0, NULL); | |
315 | gpio_request(GPIO_FN_LCDDISP, NULL); | |
316 | gpio_request(GPIO_FN_LCDDCK, NULL); | |
317 | ||
318 | gpio_request(GPIO_PORT31, NULL); /* backlight */ | |
319 | gpio_direction_output(GPIO_PORT31, 1); | |
320 | ||
321 | gpio_request(GPIO_PORT151, NULL); /* LCDDON */ | |
322 | gpio_direction_output(GPIO_PORT151, 1); | |
323 | ||
324 | ||
920adc75 KM |
325 | sh7372_add_standard_devices(); |
326 | ||
327 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); | |
328 | } | |
329 | ||
330 | static void __init mackerel_timer_init(void) | |
331 | { | |
332 | sh7372_clock_init(); | |
333 | shmobile_timer.init(); | |
334 | } | |
335 | ||
336 | static struct sys_timer mackerel_timer = { | |
337 | .init = mackerel_timer_init, | |
338 | }; | |
339 | ||
340 | MACHINE_START(MACKEREL, "mackerel") | |
341 | .map_io = mackerel_map_io, | |
342 | .init_irq = sh7372_init_irq, | |
343 | .init_machine = mackerel_init, | |
344 | .timer = &mackerel_timer, | |
345 | MACHINE_END |