Commit | Line | Data |
---|---|---|
5102aa4a MP |
1 | /* linux/arch/arm/mach-s3c2440/mach-mini2440.c |
2 | * | |
3 | * Copyright (c) 2008 Ramax Lo <ramaxlo@gmail.com> | |
4 | * Based on mach-anubis.c by Ben Dooks <ben@simtec.co.uk> | |
5 | * and modifications by SBZ <sbz@spgui.org> and | |
6 | * Weibing <http://weibing.blogbus.com> and | |
7 | * Michel Pollet <buserror@gmail.com> | |
8 | * | |
9 | * For product information, visit http://code.google.com/p/mini2440/ | |
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 version 2 as | |
13 | * published by the Free Software Foundation. | |
14 | */ | |
15 | ||
16 | #include <linux/kernel.h> | |
17 | #include <linux/types.h> | |
18 | #include <linux/interrupt.h> | |
19 | #include <linux/list.h> | |
20 | #include <linux/timer.h> | |
21 | #include <linux/init.h> | |
22 | #include <linux/gpio.h> | |
23 | #include <linux/input.h> | |
24 | #include <linux/io.h> | |
25 | #include <linux/serial_core.h> | |
334a1c70 | 26 | #include <linux/serial_s3c.h> |
5102aa4a | 27 | #include <linux/dm9000.h> |
25f73ed5 | 28 | #include <linux/platform_data/at24.h> |
5102aa4a MP |
29 | #include <linux/platform_device.h> |
30 | #include <linux/gpio_keys.h> | |
31 | #include <linux/i2c.h> | |
32 | #include <linux/mmc/host.h> | |
33 | ||
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/map.h> | |
36 | ||
37 | #include <mach/hardware.h> | |
38 | #include <mach/fb.h> | |
39 | #include <asm/mach-types.h> | |
40 | ||
5102aa4a | 41 | #include <mach/regs-gpio.h> |
436d42c6 | 42 | #include <linux/platform_data/leds-s3c24xx.h> |
5102aa4a MP |
43 | #include <mach/regs-lcd.h> |
44 | #include <mach/irqs.h> | |
b0161caa | 45 | #include <mach/gpio-samsung.h> |
436d42c6 AB |
46 | #include <linux/platform_data/mtd-nand-s3c2410.h> |
47 | #include <linux/platform_data/i2c-s3c2410.h> | |
48 | #include <linux/platform_data/mmc-s3cmci.h> | |
49 | #include <linux/platform_data/usb-s3c2410_udc.h> | |
5102aa4a | 50 | |
5102aa4a MP |
51 | #include <linux/mtd/mtd.h> |
52 | #include <linux/mtd/nand.h> | |
53 | #include <linux/mtd/nand_ecc.h> | |
54 | #include <linux/mtd/partitions.h> | |
55 | ||
40b956f0 | 56 | #include <plat/gpio-cfg.h> |
5102aa4a MP |
57 | #include <plat/devs.h> |
58 | #include <plat/cpu.h> | |
7f78b6eb | 59 | #include <plat/samsung-time.h> |
5102aa4a MP |
60 | |
61 | #include <sound/s3c24xx_uda134x.h> | |
62 | ||
b27b0727 KK |
63 | #include "common.h" |
64 | ||
5102aa4a MP |
65 | #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300) |
66 | ||
67 | static struct map_desc mini2440_iodesc[] __initdata = { | |
68 | /* nothing to declare, move along */ | |
69 | }; | |
70 | ||
71 | #define UCON S3C2410_UCON_DEFAULT | |
72 | #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB | |
73 | #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE | |
74 | ||
75 | ||
76 | static struct s3c2410_uartcfg mini2440_uartcfgs[] __initdata = { | |
77 | [0] = { | |
78 | .hwport = 0, | |
79 | .flags = 0, | |
80 | .ucon = UCON, | |
81 | .ulcon = ULCON, | |
82 | .ufcon = UFCON, | |
83 | }, | |
84 | [1] = { | |
85 | .hwport = 1, | |
86 | .flags = 0, | |
87 | .ucon = UCON, | |
88 | .ulcon = ULCON, | |
89 | .ufcon = UFCON, | |
90 | }, | |
91 | [2] = { | |
92 | .hwport = 2, | |
93 | .flags = 0, | |
94 | .ucon = UCON, | |
95 | .ulcon = ULCON, | |
96 | .ufcon = UFCON, | |
97 | }, | |
98 | }; | |
99 | ||
100 | /* USB device UDC support */ | |
101 | ||
5102aa4a | 102 | static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata = { |
e27c3c5c | 103 | .pullup_pin = S3C2410_GPC(5), |
5102aa4a MP |
104 | }; |
105 | ||
106 | ||
107 | /* LCD timing and setup */ | |
108 | ||
109 | /* | |
110 | * This macro simplifies the table bellow | |
111 | */ | |
112 | #define _LCD_DECLARE(_clock,_xres,margin_left,margin_right,hsync, \ | |
113 | _yres,margin_top,margin_bottom,vsync, refresh) \ | |
114 | .width = _xres, \ | |
115 | .xres = _xres, \ | |
116 | .height = _yres, \ | |
117 | .yres = _yres, \ | |
118 | .left_margin = margin_left, \ | |
119 | .right_margin = margin_right, \ | |
120 | .upper_margin = margin_top, \ | |
121 | .lower_margin = margin_bottom, \ | |
122 | .hsync_len = hsync, \ | |
123 | .vsync_len = vsync, \ | |
124 | .pixclock = ((_clock*100000000000LL) / \ | |
125 | ((refresh) * \ | |
126 | (hsync + margin_left + _xres + margin_right) * \ | |
127 | (vsync + margin_top + _yres + margin_bottom))), \ | |
128 | .bpp = 16,\ | |
129 | .type = (S3C2410_LCDCON1_TFT16BPP |\ | |
130 | S3C2410_LCDCON1_TFT) | |
131 | ||
00709947 | 132 | static struct s3c2410fb_display mini2440_lcd_cfg[] __initdata = { |
5102aa4a MP |
133 | [0] = { /* mini2440 + 3.5" TFT + touchscreen */ |
134 | _LCD_DECLARE( | |
135 | 7, /* The 3.5 is quite fast */ | |
136 | 240, 21, 38, 6, /* x timing */ | |
137 | 320, 4, 4, 2, /* y timing */ | |
138 | 60), /* refresh rate */ | |
139 | .lcdcon5 = (S3C2410_LCDCON5_FRM565 | | |
140 | S3C2410_LCDCON5_INVVLINE | | |
141 | S3C2410_LCDCON5_INVVFRAME | | |
142 | S3C2410_LCDCON5_INVVDEN | | |
143 | S3C2410_LCDCON5_PWREN), | |
144 | }, | |
145 | [1] = { /* mini2440 + 7" TFT + touchscreen */ | |
146 | _LCD_DECLARE( | |
147 | 10, /* the 7" runs slower */ | |
148 | 800, 40, 40, 48, /* x timing */ | |
149 | 480, 29, 3, 3, /* y timing */ | |
150 | 50), /* refresh rate */ | |
151 | .lcdcon5 = (S3C2410_LCDCON5_FRM565 | | |
152 | S3C2410_LCDCON5_INVVLINE | | |
153 | S3C2410_LCDCON5_INVVFRAME | | |
154 | S3C2410_LCDCON5_PWREN), | |
155 | }, | |
156 | /* The VGA shield can outout at several resolutions. All share | |
157 | * the same timings, however, anything smaller than 1024x768 | |
158 | * will only be displayed in the top left corner of a 1024x768 | |
159 | * XGA output unless you add optional dip switches to the shield. | |
25985edc | 160 | * Therefore timings for other resolutions have been omitted here. |
5102aa4a MP |
161 | */ |
162 | [2] = { | |
163 | _LCD_DECLARE( | |
164 | 10, | |
165 | 1024, 1, 2, 2, /* y timing */ | |
166 | 768, 200, 16, 16, /* x timing */ | |
167 | 24), /* refresh rate, maximum stable, | |
168 | tested with the FPGA shield */ | |
169 | .lcdcon5 = (S3C2410_LCDCON5_FRM565 | | |
170 | S3C2410_LCDCON5_HWSWP), | |
171 | }, | |
8e146f54 DK |
172 | /* mini2440 + 3.5" TFT (LCD-W35i, LQ035Q1DG06 type) + touchscreen*/ |
173 | [3] = { | |
174 | _LCD_DECLARE( | |
175 | /* clock */ | |
176 | 7, | |
177 | /* xres, margin_right, margin_left, hsync */ | |
178 | 320, 68, 66, 4, | |
179 | /* yres, margin_top, margin_bottom, vsync */ | |
180 | 240, 4, 4, 9, | |
181 | /* refresh rate */ | |
182 | 60), | |
183 | .lcdcon5 = (S3C2410_LCDCON5_FRM565 | | |
184 | S3C2410_LCDCON5_INVVDEN | | |
185 | S3C2410_LCDCON5_INVVFRAME | | |
186 | S3C2410_LCDCON5_INVVLINE | | |
187 | S3C2410_LCDCON5_INVVCLK | | |
188 | S3C2410_LCDCON5_HWSWP), | |
189 | }, | |
5102aa4a MP |
190 | }; |
191 | ||
192 | /* todo - put into gpio header */ | |
193 | ||
194 | #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2)) | |
195 | #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2)) | |
196 | ||
00709947 | 197 | static struct s3c2410fb_mach_info mini2440_fb_info __initdata = { |
5102aa4a MP |
198 | .displays = &mini2440_lcd_cfg[0], /* not constant! see init */ |
199 | .num_displays = 1, | |
200 | .default_display = 0, | |
201 | ||
202 | /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN | |
203 | * and disable the pull down resistors on pins we are using for LCD | |
204 | * data. */ | |
205 | ||
206 | .gpcup = (0xf << 1) | (0x3f << 10), | |
207 | ||
208 | .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE | | |
209 | S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM | | |
210 | S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 | | |
211 | S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 | | |
212 | S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7), | |
213 | ||
214 | .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) | | |
215 | S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) | | |
216 | S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) | | |
217 | S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) | | |
218 | S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)), | |
219 | ||
220 | .gpdup = (0x3f << 2) | (0x3f << 10), | |
221 | ||
222 | .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 | | |
223 | S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 | | |
224 | S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 | | |
225 | S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 | | |
226 | S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 | | |
227 | S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23), | |
228 | ||
229 | .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) | | |
230 | S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) | | |
231 | S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) | | |
232 | S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)| | |
233 | S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)| | |
234 | S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)), | |
235 | }; | |
236 | ||
237 | /* MMC/SD */ | |
238 | ||
239 | static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { | |
240 | .gpio_detect = S3C2410_GPG(8), | |
241 | .gpio_wprotect = S3C2410_GPH(8), | |
242 | .set_power = NULL, | |
243 | .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, | |
244 | }; | |
245 | ||
246 | /* NAND Flash on MINI2440 board */ | |
247 | ||
248 | static struct mtd_partition mini2440_default_nand_part[] __initdata = { | |
249 | [0] = { | |
250 | .name = "u-boot", | |
251 | .size = SZ_256K, | |
252 | .offset = 0, | |
253 | }, | |
254 | [1] = { | |
255 | .name = "u-boot-env", | |
256 | .size = SZ_128K, | |
257 | .offset = SZ_256K, | |
258 | }, | |
259 | [2] = { | |
260 | .name = "kernel", | |
261 | /* 5 megabytes, for a kernel with no modules | |
262 | * or a uImage with a ramdisk attached */ | |
263 | .size = 0x00500000, | |
264 | .offset = SZ_256K + SZ_128K, | |
265 | }, | |
266 | [3] = { | |
267 | .name = "root", | |
268 | .offset = SZ_256K + SZ_128K + 0x00500000, | |
269 | .size = MTDPART_SIZ_FULL, | |
270 | }, | |
271 | }; | |
272 | ||
273 | static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = { | |
274 | [0] = { | |
275 | .name = "nand", | |
276 | .nr_chips = 1, | |
277 | .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part), | |
278 | .partitions = mini2440_default_nand_part, | |
51af243c | 279 | .flash_bbt = 1, /* we use u-boot to create a BBT */ |
5102aa4a MP |
280 | }, |
281 | }; | |
282 | ||
283 | static struct s3c2410_platform_nand mini2440_nand_info __initdata = { | |
284 | .tacls = 0, | |
285 | .twrph0 = 25, | |
286 | .twrph1 = 15, | |
287 | .nr_sets = ARRAY_SIZE(mini2440_nand_sets), | |
288 | .sets = mini2440_nand_sets, | |
289 | .ignore_unset_ecc = 1, | |
290 | }; | |
291 | ||
292 | /* DM9000AEP 10/100 ethernet controller */ | |
293 | ||
3ce2f76f | 294 | static struct resource mini2440_dm9k_resource[] = { |
7498b728 TB |
295 | [0] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE, 4), |
296 | [1] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE + 4, 4), | |
297 | [2] = DEFINE_RES_NAMED(IRQ_EINT7, 1, NULL, IORESOURCE_IRQ \ | |
298 | | IORESOURCE_IRQ_HIGHEDGE), | |
5102aa4a MP |
299 | }; |
300 | ||
301 | /* | |
302 | * The DM9000 has no eeprom, and it's MAC address is set by | |
303 | * the bootloader before starting the kernel. | |
304 | */ | |
3ce2f76f | 305 | static struct dm9000_plat_data mini2440_dm9k_pdata = { |
5102aa4a MP |
306 | .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), |
307 | }; | |
308 | ||
3ce2f76f | 309 | static struct platform_device mini2440_device_eth = { |
5102aa4a MP |
310 | .name = "dm9000", |
311 | .id = -1, | |
312 | .num_resources = ARRAY_SIZE(mini2440_dm9k_resource), | |
313 | .resource = mini2440_dm9k_resource, | |
314 | .dev = { | |
315 | .platform_data = &mini2440_dm9k_pdata, | |
316 | }, | |
317 | }; | |
318 | ||
319 | /* CON5 | |
320 | * +--+ /-----\ | |
321 | * | | | | | |
322 | * | | | BAT | | |
323 | * | | \_____/ | |
324 | * | | | |
325 | * | | +----+ +----+ | |
326 | * | | | K5 | | K1 | | |
327 | * | | +----+ +----+ | |
328 | * | | +----+ +----+ | |
329 | * | | | K4 | | K2 | | |
330 | * | | +----+ +----+ | |
331 | * | | +----+ +----+ | |
332 | * | | | K6 | | K3 | | |
333 | * | | +----+ +----+ | |
334 | * ..... | |
335 | */ | |
3ce2f76f | 336 | static struct gpio_keys_button mini2440_buttons[] = { |
5102aa4a MP |
337 | { |
338 | .gpio = S3C2410_GPG(0), /* K1 */ | |
339 | .code = KEY_F1, | |
340 | .desc = "Button 1", | |
341 | .active_low = 1, | |
342 | }, | |
343 | { | |
344 | .gpio = S3C2410_GPG(3), /* K2 */ | |
345 | .code = KEY_F2, | |
346 | .desc = "Button 2", | |
347 | .active_low = 1, | |
348 | }, | |
349 | { | |
350 | .gpio = S3C2410_GPG(5), /* K3 */ | |
351 | .code = KEY_F3, | |
352 | .desc = "Button 3", | |
353 | .active_low = 1, | |
354 | }, | |
355 | { | |
356 | .gpio = S3C2410_GPG(6), /* K4 */ | |
357 | .code = KEY_POWER, | |
358 | .desc = "Power", | |
359 | .active_low = 1, | |
360 | }, | |
361 | { | |
362 | .gpio = S3C2410_GPG(7), /* K5 */ | |
363 | .code = KEY_F5, | |
364 | .desc = "Button 5", | |
365 | .active_low = 1, | |
366 | }, | |
367 | #if 0 | |
368 | /* this pin is also known as TCLK1 and seems to already | |
369 | * marked as "in use" somehow in the kernel -- possibly wrongly */ | |
370 | { | |
371 | .gpio = S3C2410_GPG(11), /* K6 */ | |
372 | .code = KEY_F6, | |
373 | .desc = "Button 6", | |
374 | .active_low = 1, | |
375 | }, | |
376 | #endif | |
377 | }; | |
378 | ||
3ce2f76f | 379 | static struct gpio_keys_platform_data mini2440_button_data = { |
5102aa4a MP |
380 | .buttons = mini2440_buttons, |
381 | .nbuttons = ARRAY_SIZE(mini2440_buttons), | |
382 | }; | |
383 | ||
3ce2f76f | 384 | static struct platform_device mini2440_button_device = { |
5102aa4a MP |
385 | .name = "gpio-keys", |
386 | .id = -1, | |
387 | .dev = { | |
388 | .platform_data = &mini2440_button_data, | |
389 | } | |
390 | }; | |
391 | ||
392 | /* LEDS */ | |
393 | ||
0a3727ff | 394 | static struct s3c24xx_led_platdata mini2440_led1_pdata = { |
5102aa4a MP |
395 | .name = "led1", |
396 | .gpio = S3C2410_GPB(5), | |
397 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, | |
398 | .def_trigger = "heartbeat", | |
399 | }; | |
400 | ||
0a3727ff | 401 | static struct s3c24xx_led_platdata mini2440_led2_pdata = { |
5102aa4a MP |
402 | .name = "led2", |
403 | .gpio = S3C2410_GPB(6), | |
404 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, | |
405 | .def_trigger = "nand-disk", | |
406 | }; | |
407 | ||
0a3727ff | 408 | static struct s3c24xx_led_platdata mini2440_led3_pdata = { |
5102aa4a MP |
409 | .name = "led3", |
410 | .gpio = S3C2410_GPB(7), | |
411 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, | |
412 | .def_trigger = "mmc0", | |
413 | }; | |
414 | ||
0a3727ff | 415 | static struct s3c24xx_led_platdata mini2440_led4_pdata = { |
5102aa4a MP |
416 | .name = "led4", |
417 | .gpio = S3C2410_GPB(8), | |
418 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, | |
419 | .def_trigger = "", | |
420 | }; | |
421 | ||
0a3727ff | 422 | static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = { |
5102aa4a MP |
423 | .name = "backlight", |
424 | .gpio = S3C2410_GPG(4), | |
425 | .def_trigger = "backlight", | |
426 | }; | |
427 | ||
3ce2f76f | 428 | static struct platform_device mini2440_led1 = { |
5102aa4a MP |
429 | .name = "s3c24xx_led", |
430 | .id = 1, | |
431 | .dev = { | |
432 | .platform_data = &mini2440_led1_pdata, | |
433 | }, | |
434 | }; | |
435 | ||
3ce2f76f | 436 | static struct platform_device mini2440_led2 = { |
5102aa4a MP |
437 | .name = "s3c24xx_led", |
438 | .id = 2, | |
439 | .dev = { | |
440 | .platform_data = &mini2440_led2_pdata, | |
441 | }, | |
442 | }; | |
443 | ||
3ce2f76f | 444 | static struct platform_device mini2440_led3 = { |
5102aa4a MP |
445 | .name = "s3c24xx_led", |
446 | .id = 3, | |
447 | .dev = { | |
448 | .platform_data = &mini2440_led3_pdata, | |
449 | }, | |
450 | }; | |
451 | ||
3ce2f76f | 452 | static struct platform_device mini2440_led4 = { |
5102aa4a MP |
453 | .name = "s3c24xx_led", |
454 | .id = 4, | |
455 | .dev = { | |
456 | .platform_data = &mini2440_led4_pdata, | |
457 | }, | |
458 | }; | |
459 | ||
3ce2f76f | 460 | static struct platform_device mini2440_led_backlight = { |
5102aa4a MP |
461 | .name = "s3c24xx_led", |
462 | .id = 5, | |
463 | .dev = { | |
464 | .platform_data = &mini2440_led_backlight_pdata, | |
465 | }, | |
466 | }; | |
467 | ||
468 | /* AUDIO */ | |
469 | ||
3ce2f76f | 470 | static struct s3c24xx_uda134x_platform_data mini2440_audio_pins = { |
5102aa4a MP |
471 | .l3_clk = S3C2410_GPB(4), |
472 | .l3_mode = S3C2410_GPB(2), | |
473 | .l3_data = S3C2410_GPB(3), | |
474 | .model = UDA134X_UDA1341 | |
475 | }; | |
476 | ||
3ce2f76f | 477 | static struct platform_device mini2440_audio = { |
5102aa4a MP |
478 | .name = "s3c24xx_uda134x", |
479 | .id = 0, | |
480 | .dev = { | |
481 | .platform_data = &mini2440_audio_pins, | |
482 | }, | |
483 | }; | |
484 | ||
485 | /* | |
486 | * I2C devices | |
487 | */ | |
488 | static struct at24_platform_data at24c08 = { | |
489 | .byte_len = SZ_8K / 8, | |
490 | .page_size = 16, | |
491 | }; | |
492 | ||
493 | static struct i2c_board_info mini2440_i2c_devs[] __initdata = { | |
494 | { | |
495 | I2C_BOARD_INFO("24c08", 0x50), | |
496 | .platform_data = &at24c08, | |
497 | }, | |
498 | }; | |
499 | ||
a110f4ef MB |
500 | static struct platform_device uda1340_codec = { |
501 | .name = "uda134x-codec", | |
502 | .id = -1, | |
503 | }; | |
504 | ||
5102aa4a | 505 | static struct platform_device *mini2440_devices[] __initdata = { |
b813248c | 506 | &s3c_device_ohci, |
5102aa4a | 507 | &s3c_device_wdt, |
5102aa4a MP |
508 | &s3c_device_i2c0, |
509 | &s3c_device_rtc, | |
510 | &s3c_device_usbgadget, | |
511 | &mini2440_device_eth, | |
512 | &mini2440_led1, | |
513 | &mini2440_led2, | |
514 | &mini2440_led3, | |
515 | &mini2440_led4, | |
516 | &mini2440_button_device, | |
517 | &s3c_device_nand, | |
518 | &s3c_device_sdi, | |
519 | &s3c_device_iis, | |
a110f4ef | 520 | &uda1340_codec, |
5102aa4a | 521 | &mini2440_audio, |
5102aa4a MP |
522 | }; |
523 | ||
524 | static void __init mini2440_map_io(void) | |
525 | { | |
526 | s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc)); | |
5102aa4a | 527 | s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs)); |
7f78b6eb | 528 | samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); |
5102aa4a MP |
529 | } |
530 | ||
a28d618e HS |
531 | static void __init mini2440_init_time(void) |
532 | { | |
533 | s3c2440_init_clocks(12000000); | |
534 | samsung_timer_init(); | |
535 | } | |
536 | ||
5102aa4a MP |
537 | /* |
538 | * mini2440_features string | |
539 | * | |
540 | * t = Touchscreen present | |
541 | * b = backlight control | |
542 | * c = camera [TODO] | |
543 | * 0-9 LCD configuration | |
544 | * | |
545 | */ | |
546 | static char mini2440_features_str[12] __initdata = "0tb"; | |
547 | ||
548 | static int __init mini2440_features_setup(char *str) | |
549 | { | |
550 | if (str) | |
551 | strlcpy(mini2440_features_str, str, sizeof(mini2440_features_str)); | |
552 | return 1; | |
553 | } | |
554 | ||
555 | __setup("mini2440=", mini2440_features_setup); | |
556 | ||
557 | #define FEATURE_SCREEN (1 << 0) | |
558 | #define FEATURE_BACKLIGHT (1 << 1) | |
559 | #define FEATURE_TOUCH (1 << 2) | |
560 | #define FEATURE_CAMERA (1 << 3) | |
561 | ||
562 | struct mini2440_features_t { | |
563 | int count; | |
564 | int done; | |
565 | int lcd_index; | |
566 | struct platform_device *optional[8]; | |
567 | }; | |
568 | ||
d34c1fcd | 569 | static void __init mini2440_parse_features( |
5102aa4a MP |
570 | struct mini2440_features_t * features, |
571 | const char * features_str ) | |
572 | { | |
573 | const char * fp = features_str; | |
574 | ||
575 | features->count = 0; | |
576 | features->done = 0; | |
577 | features->lcd_index = -1; | |
578 | ||
579 | while (*fp) { | |
580 | char f = *fp++; | |
581 | ||
582 | switch (f) { | |
583 | case '0'...'9': /* tft screen */ | |
584 | if (features->done & FEATURE_SCREEN) { | |
585 | printk(KERN_INFO "MINI2440: '%c' ignored, " | |
586 | "screen type already set\n", f); | |
587 | } else { | |
588 | int li = f - '0'; | |
589 | if (li >= ARRAY_SIZE(mini2440_lcd_cfg)) | |
590 | printk(KERN_INFO "MINI2440: " | |
591 | "'%c' out of range LCD mode\n", f); | |
592 | else { | |
593 | features->optional[features->count++] = | |
594 | &s3c_device_lcd; | |
595 | features->lcd_index = li; | |
596 | } | |
597 | } | |
598 | features->done |= FEATURE_SCREEN; | |
599 | break; | |
600 | case 'b': | |
601 | if (features->done & FEATURE_BACKLIGHT) | |
602 | printk(KERN_INFO "MINI2440: '%c' ignored, " | |
603 | "backlight already set\n", f); | |
604 | else { | |
605 | features->optional[features->count++] = | |
606 | &mini2440_led_backlight; | |
607 | } | |
608 | features->done |= FEATURE_BACKLIGHT; | |
609 | break; | |
610 | case 't': | |
611 | printk(KERN_INFO "MINI2440: '%c' ignored, " | |
612 | "touchscreen not compiled in\n", f); | |
613 | break; | |
614 | case 'c': | |
615 | if (features->done & FEATURE_CAMERA) | |
616 | printk(KERN_INFO "MINI2440: '%c' ignored, " | |
617 | "camera already registered\n", f); | |
618 | else | |
619 | features->optional[features->count++] = | |
620 | &s3c_device_camif; | |
621 | features->done |= FEATURE_CAMERA; | |
622 | break; | |
623 | } | |
624 | } | |
625 | } | |
626 | ||
627 | static void __init mini2440_init(void) | |
628 | { | |
629 | struct mini2440_features_t features = { 0 }; | |
630 | int i; | |
631 | ||
632 | printk(KERN_INFO "MINI2440: Option string mini2440=%s\n", | |
633 | mini2440_features_str); | |
634 | ||
635 | /* Parse the feature string */ | |
636 | mini2440_parse_features(&features, mini2440_features_str); | |
637 | ||
638 | /* turn LCD on */ | |
40b956f0 | 639 | s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND); |
5102aa4a MP |
640 | |
641 | /* Turn the backlight early on */ | |
57370aed SN |
642 | WARN_ON(gpio_request_one(S3C2410_GPG(4), GPIOF_OUT_INIT_HIGH, NULL)); |
643 | gpio_free(S3C2410_GPG(4)); | |
5102aa4a MP |
644 | |
645 | /* remove pullup on optional PWM backlight -- unused on 3.5 and 7"s */ | |
42aa322c | 646 | gpio_request_one(S3C2410_GPB(1), GPIOF_IN, NULL); |
64f508da | 647 | s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP); |
42aa322c | 648 | gpio_free(S3C2410_GPB(1)); |
5102aa4a | 649 | |
5102aa4a MP |
650 | /* mark the key as input, without pullups (there is one on the board) */ |
651 | for (i = 0; i < ARRAY_SIZE(mini2440_buttons); i++) { | |
64f508da BD |
652 | s3c_gpio_setpull(mini2440_buttons[i].gpio, S3C_GPIO_PULL_UP); |
653 | s3c_gpio_cfgpin(mini2440_buttons[i].gpio, S3C2410_GPIO_INPUT); | |
5102aa4a MP |
654 | } |
655 | if (features.lcd_index != -1) { | |
656 | int li; | |
657 | ||
658 | mini2440_fb_info.displays = | |
659 | &mini2440_lcd_cfg[features.lcd_index]; | |
660 | ||
661 | printk(KERN_INFO "MINI2440: LCD"); | |
662 | for (li = 0; li < ARRAY_SIZE(mini2440_lcd_cfg); li++) | |
663 | if (li == features.lcd_index) | |
664 | printk(" [%d:%dx%d]", li, | |
665 | mini2440_lcd_cfg[li].width, | |
666 | mini2440_lcd_cfg[li].height); | |
667 | else | |
668 | printk(" %d:%dx%d", li, | |
669 | mini2440_lcd_cfg[li].width, | |
670 | mini2440_lcd_cfg[li].height); | |
671 | printk("\n"); | |
672 | s3c24xx_fb_set_platdata(&mini2440_fb_info); | |
673 | } | |
2a3a1804 | 674 | |
5102aa4a | 675 | s3c24xx_udc_set_platdata(&mini2440_udc_cfg); |
22c810ab | 676 | s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); |
2a3a1804 | 677 | s3c_nand_set_platdata(&mini2440_nand_info); |
5102aa4a | 678 | s3c_i2c0_set_platdata(NULL); |
2a3a1804 | 679 | |
5102aa4a MP |
680 | i2c_register_board_info(0, mini2440_i2c_devs, |
681 | ARRAY_SIZE(mini2440_i2c_devs)); | |
682 | ||
683 | platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices)); | |
684 | ||
685 | if (features.count) /* the optional features */ | |
686 | platform_add_devices(features.optional, features.count); | |
687 | ||
688 | } | |
689 | ||
690 | ||
691 | MACHINE_START(MINI2440, "MINI2440") | |
692 | /* Maintainer: Michel Pollet <buserror@gmail.com> */ | |
69d50710 | 693 | .atag_offset = 0x100, |
5102aa4a MP |
694 | .map_io = mini2440_map_io, |
695 | .init_machine = mini2440_init, | |
ce6c164b | 696 | .init_irq = s3c2440_init_irq, |
a28d618e | 697 | .init_time = mini2440_init_time, |
5102aa4a | 698 | MACHINE_END |