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