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