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 | |
Kukjin Kim | b27b072 | 2012-01-03 14:02:03 +0100 | [diff] [blame^] | 63 | #include "common.h" |
| 64 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 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 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 102 | static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata = { |
Lars-Peter Clausen | e27c3c5 | 2011-03-07 08:42:00 +0100 | [diff] [blame] | 103 | .pullup_pin = S3C2410_GPC(5), |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 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 | |
Ben Dooks | 0070994 | 2009-10-26 21:19:27 +0000 | [diff] [blame] | 132 | static struct s3c2410fb_display mini2440_lcd_cfg[] __initdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 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. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 160 | * Therefore timings for other resolutions have been omitted here. |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 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 | }, |
| 172 | }; |
| 173 | |
| 174 | /* todo - put into gpio header */ |
| 175 | |
| 176 | #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2)) |
| 177 | #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2)) |
| 178 | |
Ben Dooks | 0070994 | 2009-10-26 21:19:27 +0000 | [diff] [blame] | 179 | static struct s3c2410fb_mach_info mini2440_fb_info __initdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 180 | .displays = &mini2440_lcd_cfg[0], /* not constant! see init */ |
| 181 | .num_displays = 1, |
| 182 | .default_display = 0, |
| 183 | |
| 184 | /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN |
| 185 | * and disable the pull down resistors on pins we are using for LCD |
| 186 | * data. */ |
| 187 | |
| 188 | .gpcup = (0xf << 1) | (0x3f << 10), |
| 189 | |
| 190 | .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE | |
| 191 | S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM | |
| 192 | S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 | |
| 193 | S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 | |
| 194 | S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7), |
| 195 | |
| 196 | .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) | |
| 197 | S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) | |
| 198 | S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) | |
| 199 | S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) | |
| 200 | S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)), |
| 201 | |
| 202 | .gpdup = (0x3f << 2) | (0x3f << 10), |
| 203 | |
| 204 | .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 | |
| 205 | S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 | |
| 206 | S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 | |
| 207 | S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 | |
| 208 | S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 | |
| 209 | S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23), |
| 210 | |
| 211 | .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) | |
| 212 | S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) | |
| 213 | S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) | |
| 214 | S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)| |
| 215 | S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)| |
| 216 | S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)), |
| 217 | }; |
| 218 | |
| 219 | /* MMC/SD */ |
| 220 | |
| 221 | static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { |
| 222 | .gpio_detect = S3C2410_GPG(8), |
| 223 | .gpio_wprotect = S3C2410_GPH(8), |
| 224 | .set_power = NULL, |
| 225 | .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, |
| 226 | }; |
| 227 | |
| 228 | /* NAND Flash on MINI2440 board */ |
| 229 | |
| 230 | static struct mtd_partition mini2440_default_nand_part[] __initdata = { |
| 231 | [0] = { |
| 232 | .name = "u-boot", |
| 233 | .size = SZ_256K, |
| 234 | .offset = 0, |
| 235 | }, |
| 236 | [1] = { |
| 237 | .name = "u-boot-env", |
| 238 | .size = SZ_128K, |
| 239 | .offset = SZ_256K, |
| 240 | }, |
| 241 | [2] = { |
| 242 | .name = "kernel", |
| 243 | /* 5 megabytes, for a kernel with no modules |
| 244 | * or a uImage with a ramdisk attached */ |
| 245 | .size = 0x00500000, |
| 246 | .offset = SZ_256K + SZ_128K, |
| 247 | }, |
| 248 | [3] = { |
| 249 | .name = "root", |
| 250 | .offset = SZ_256K + SZ_128K + 0x00500000, |
| 251 | .size = MTDPART_SIZ_FULL, |
| 252 | }, |
| 253 | }; |
| 254 | |
| 255 | static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = { |
| 256 | [0] = { |
| 257 | .name = "nand", |
| 258 | .nr_chips = 1, |
| 259 | .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part), |
| 260 | .partitions = mini2440_default_nand_part, |
Ben Dooks | 51af243 | 2009-06-23 18:23:27 +0100 | [diff] [blame] | 261 | .flash_bbt = 1, /* we use u-boot to create a BBT */ |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 262 | }, |
| 263 | }; |
| 264 | |
| 265 | static struct s3c2410_platform_nand mini2440_nand_info __initdata = { |
| 266 | .tacls = 0, |
| 267 | .twrph0 = 25, |
| 268 | .twrph1 = 15, |
| 269 | .nr_sets = ARRAY_SIZE(mini2440_nand_sets), |
| 270 | .sets = mini2440_nand_sets, |
| 271 | .ignore_unset_ecc = 1, |
| 272 | }; |
| 273 | |
| 274 | /* DM9000AEP 10/100 ethernet controller */ |
| 275 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 276 | static struct resource mini2440_dm9k_resource[] = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 277 | [0] = { |
| 278 | .start = MACH_MINI2440_DM9K_BASE, |
| 279 | .end = MACH_MINI2440_DM9K_BASE + 3, |
| 280 | .flags = IORESOURCE_MEM |
| 281 | }, |
| 282 | [1] = { |
| 283 | .start = MACH_MINI2440_DM9K_BASE + 4, |
| 284 | .end = MACH_MINI2440_DM9K_BASE + 7, |
| 285 | .flags = IORESOURCE_MEM |
| 286 | }, |
| 287 | [2] = { |
| 288 | .start = IRQ_EINT7, |
| 289 | .end = IRQ_EINT7, |
| 290 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 291 | } |
| 292 | }; |
| 293 | |
| 294 | /* |
| 295 | * The DM9000 has no eeprom, and it's MAC address is set by |
| 296 | * the bootloader before starting the kernel. |
| 297 | */ |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 298 | static struct dm9000_plat_data mini2440_dm9k_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 299 | .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), |
| 300 | }; |
| 301 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 302 | static struct platform_device mini2440_device_eth = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 303 | .name = "dm9000", |
| 304 | .id = -1, |
| 305 | .num_resources = ARRAY_SIZE(mini2440_dm9k_resource), |
| 306 | .resource = mini2440_dm9k_resource, |
| 307 | .dev = { |
| 308 | .platform_data = &mini2440_dm9k_pdata, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | /* CON5 |
| 313 | * +--+ /-----\ |
| 314 | * | | | | |
| 315 | * | | | BAT | |
| 316 | * | | \_____/ |
| 317 | * | | |
| 318 | * | | +----+ +----+ |
| 319 | * | | | K5 | | K1 | |
| 320 | * | | +----+ +----+ |
| 321 | * | | +----+ +----+ |
| 322 | * | | | K4 | | K2 | |
| 323 | * | | +----+ +----+ |
| 324 | * | | +----+ +----+ |
| 325 | * | | | K6 | | K3 | |
| 326 | * | | +----+ +----+ |
| 327 | * ..... |
| 328 | */ |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 329 | static struct gpio_keys_button mini2440_buttons[] = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 330 | { |
| 331 | .gpio = S3C2410_GPG(0), /* K1 */ |
| 332 | .code = KEY_F1, |
| 333 | .desc = "Button 1", |
| 334 | .active_low = 1, |
| 335 | }, |
| 336 | { |
| 337 | .gpio = S3C2410_GPG(3), /* K2 */ |
| 338 | .code = KEY_F2, |
| 339 | .desc = "Button 2", |
| 340 | .active_low = 1, |
| 341 | }, |
| 342 | { |
| 343 | .gpio = S3C2410_GPG(5), /* K3 */ |
| 344 | .code = KEY_F3, |
| 345 | .desc = "Button 3", |
| 346 | .active_low = 1, |
| 347 | }, |
| 348 | { |
| 349 | .gpio = S3C2410_GPG(6), /* K4 */ |
| 350 | .code = KEY_POWER, |
| 351 | .desc = "Power", |
| 352 | .active_low = 1, |
| 353 | }, |
| 354 | { |
| 355 | .gpio = S3C2410_GPG(7), /* K5 */ |
| 356 | .code = KEY_F5, |
| 357 | .desc = "Button 5", |
| 358 | .active_low = 1, |
| 359 | }, |
| 360 | #if 0 |
| 361 | /* this pin is also known as TCLK1 and seems to already |
| 362 | * marked as "in use" somehow in the kernel -- possibly wrongly */ |
| 363 | { |
| 364 | .gpio = S3C2410_GPG(11), /* K6 */ |
| 365 | .code = KEY_F6, |
| 366 | .desc = "Button 6", |
| 367 | .active_low = 1, |
| 368 | }, |
| 369 | #endif |
| 370 | }; |
| 371 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 372 | static struct gpio_keys_platform_data mini2440_button_data = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 373 | .buttons = mini2440_buttons, |
| 374 | .nbuttons = ARRAY_SIZE(mini2440_buttons), |
| 375 | }; |
| 376 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 377 | static struct platform_device mini2440_button_device = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 378 | .name = "gpio-keys", |
| 379 | .id = -1, |
| 380 | .dev = { |
| 381 | .platform_data = &mini2440_button_data, |
| 382 | } |
| 383 | }; |
| 384 | |
| 385 | /* LEDS */ |
| 386 | |
Uri Yosef | 0a3727f | 2010-01-15 16:56:05 +0900 | [diff] [blame] | 387 | static struct s3c24xx_led_platdata mini2440_led1_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 388 | .name = "led1", |
| 389 | .gpio = S3C2410_GPB(5), |
| 390 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 391 | .def_trigger = "heartbeat", |
| 392 | }; |
| 393 | |
Uri Yosef | 0a3727f | 2010-01-15 16:56:05 +0900 | [diff] [blame] | 394 | static struct s3c24xx_led_platdata mini2440_led2_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 395 | .name = "led2", |
| 396 | .gpio = S3C2410_GPB(6), |
| 397 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 398 | .def_trigger = "nand-disk", |
| 399 | }; |
| 400 | |
Uri Yosef | 0a3727f | 2010-01-15 16:56:05 +0900 | [diff] [blame] | 401 | static struct s3c24xx_led_platdata mini2440_led3_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 402 | .name = "led3", |
| 403 | .gpio = S3C2410_GPB(7), |
| 404 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 405 | .def_trigger = "mmc0", |
| 406 | }; |
| 407 | |
Uri Yosef | 0a3727f | 2010-01-15 16:56:05 +0900 | [diff] [blame] | 408 | static struct s3c24xx_led_platdata mini2440_led4_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 409 | .name = "led4", |
| 410 | .gpio = S3C2410_GPB(8), |
| 411 | .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, |
| 412 | .def_trigger = "", |
| 413 | }; |
| 414 | |
Uri Yosef | 0a3727f | 2010-01-15 16:56:05 +0900 | [diff] [blame] | 415 | static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 416 | .name = "backlight", |
| 417 | .gpio = S3C2410_GPG(4), |
| 418 | .def_trigger = "backlight", |
| 419 | }; |
| 420 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 421 | static struct platform_device mini2440_led1 = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 422 | .name = "s3c24xx_led", |
| 423 | .id = 1, |
| 424 | .dev = { |
| 425 | .platform_data = &mini2440_led1_pdata, |
| 426 | }, |
| 427 | }; |
| 428 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 429 | static struct platform_device mini2440_led2 = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 430 | .name = "s3c24xx_led", |
| 431 | .id = 2, |
| 432 | .dev = { |
| 433 | .platform_data = &mini2440_led2_pdata, |
| 434 | }, |
| 435 | }; |
| 436 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 437 | static struct platform_device mini2440_led3 = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 438 | .name = "s3c24xx_led", |
| 439 | .id = 3, |
| 440 | .dev = { |
| 441 | .platform_data = &mini2440_led3_pdata, |
| 442 | }, |
| 443 | }; |
| 444 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 445 | static struct platform_device mini2440_led4 = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 446 | .name = "s3c24xx_led", |
| 447 | .id = 4, |
| 448 | .dev = { |
| 449 | .platform_data = &mini2440_led4_pdata, |
| 450 | }, |
| 451 | }; |
| 452 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 453 | static struct platform_device mini2440_led_backlight = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 454 | .name = "s3c24xx_led", |
| 455 | .id = 5, |
| 456 | .dev = { |
| 457 | .platform_data = &mini2440_led_backlight_pdata, |
| 458 | }, |
| 459 | }; |
| 460 | |
| 461 | /* AUDIO */ |
| 462 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 463 | static struct s3c24xx_uda134x_platform_data mini2440_audio_pins = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 464 | .l3_clk = S3C2410_GPB(4), |
| 465 | .l3_mode = S3C2410_GPB(2), |
| 466 | .l3_data = S3C2410_GPB(3), |
| 467 | .model = UDA134X_UDA1341 |
| 468 | }; |
| 469 | |
Ben Dooks | 3ce2f76 | 2010-01-15 17:04:42 +0900 | [diff] [blame] | 470 | static struct platform_device mini2440_audio = { |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 471 | .name = "s3c24xx_uda134x", |
| 472 | .id = 0, |
| 473 | .dev = { |
| 474 | .platform_data = &mini2440_audio_pins, |
| 475 | }, |
| 476 | }; |
| 477 | |
| 478 | /* |
| 479 | * I2C devices |
| 480 | */ |
| 481 | static struct at24_platform_data at24c08 = { |
| 482 | .byte_len = SZ_8K / 8, |
| 483 | .page_size = 16, |
| 484 | }; |
| 485 | |
| 486 | static struct i2c_board_info mini2440_i2c_devs[] __initdata = { |
| 487 | { |
| 488 | I2C_BOARD_INFO("24c08", 0x50), |
| 489 | .platform_data = &at24c08, |
| 490 | }, |
| 491 | }; |
| 492 | |
Marek Belisko | a110f4e | 2011-03-09 21:46:20 +0100 | [diff] [blame] | 493 | static struct platform_device uda1340_codec = { |
| 494 | .name = "uda134x-codec", |
| 495 | .id = -1, |
| 496 | }; |
| 497 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 498 | static struct platform_device *mini2440_devices[] __initdata = { |
Ben Dooks | b813248 | 2009-11-23 00:13:39 +0000 | [diff] [blame] | 499 | &s3c_device_ohci, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 500 | &s3c_device_wdt, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 501 | &s3c_device_i2c0, |
| 502 | &s3c_device_rtc, |
| 503 | &s3c_device_usbgadget, |
| 504 | &mini2440_device_eth, |
| 505 | &mini2440_led1, |
| 506 | &mini2440_led2, |
| 507 | &mini2440_led3, |
| 508 | &mini2440_led4, |
| 509 | &mini2440_button_device, |
| 510 | &s3c_device_nand, |
| 511 | &s3c_device_sdi, |
| 512 | &s3c_device_iis, |
Marek Belisko | a110f4e | 2011-03-09 21:46:20 +0100 | [diff] [blame] | 513 | &uda1340_codec, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 514 | &mini2440_audio, |
Marek Belisko | a110f4e | 2011-03-09 21:46:20 +0100 | [diff] [blame] | 515 | &samsung_asoc_dma, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 516 | }; |
| 517 | |
| 518 | static void __init mini2440_map_io(void) |
| 519 | { |
| 520 | s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc)); |
| 521 | s3c24xx_init_clocks(12000000); |
| 522 | s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs)); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | /* |
| 526 | * mini2440_features string |
| 527 | * |
| 528 | * t = Touchscreen present |
| 529 | * b = backlight control |
| 530 | * c = camera [TODO] |
| 531 | * 0-9 LCD configuration |
| 532 | * |
| 533 | */ |
| 534 | static char mini2440_features_str[12] __initdata = "0tb"; |
| 535 | |
| 536 | static int __init mini2440_features_setup(char *str) |
| 537 | { |
| 538 | if (str) |
| 539 | strlcpy(mini2440_features_str, str, sizeof(mini2440_features_str)); |
| 540 | return 1; |
| 541 | } |
| 542 | |
| 543 | __setup("mini2440=", mini2440_features_setup); |
| 544 | |
| 545 | #define FEATURE_SCREEN (1 << 0) |
| 546 | #define FEATURE_BACKLIGHT (1 << 1) |
| 547 | #define FEATURE_TOUCH (1 << 2) |
| 548 | #define FEATURE_CAMERA (1 << 3) |
| 549 | |
| 550 | struct mini2440_features_t { |
| 551 | int count; |
| 552 | int done; |
| 553 | int lcd_index; |
| 554 | struct platform_device *optional[8]; |
| 555 | }; |
| 556 | |
Wolfram Sang | d34c1fc | 2011-07-08 18:16:56 +0900 | [diff] [blame] | 557 | static void __init mini2440_parse_features( |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 558 | struct mini2440_features_t * features, |
| 559 | const char * features_str ) |
| 560 | { |
| 561 | const char * fp = features_str; |
| 562 | |
| 563 | features->count = 0; |
| 564 | features->done = 0; |
| 565 | features->lcd_index = -1; |
| 566 | |
| 567 | while (*fp) { |
| 568 | char f = *fp++; |
| 569 | |
| 570 | switch (f) { |
| 571 | case '0'...'9': /* tft screen */ |
| 572 | if (features->done & FEATURE_SCREEN) { |
| 573 | printk(KERN_INFO "MINI2440: '%c' ignored, " |
| 574 | "screen type already set\n", f); |
| 575 | } else { |
| 576 | int li = f - '0'; |
| 577 | if (li >= ARRAY_SIZE(mini2440_lcd_cfg)) |
| 578 | printk(KERN_INFO "MINI2440: " |
| 579 | "'%c' out of range LCD mode\n", f); |
| 580 | else { |
| 581 | features->optional[features->count++] = |
| 582 | &s3c_device_lcd; |
| 583 | features->lcd_index = li; |
| 584 | } |
| 585 | } |
| 586 | features->done |= FEATURE_SCREEN; |
| 587 | break; |
| 588 | case 'b': |
| 589 | if (features->done & FEATURE_BACKLIGHT) |
| 590 | printk(KERN_INFO "MINI2440: '%c' ignored, " |
| 591 | "backlight already set\n", f); |
| 592 | else { |
| 593 | features->optional[features->count++] = |
| 594 | &mini2440_led_backlight; |
| 595 | } |
| 596 | features->done |= FEATURE_BACKLIGHT; |
| 597 | break; |
| 598 | case 't': |
| 599 | printk(KERN_INFO "MINI2440: '%c' ignored, " |
| 600 | "touchscreen not compiled in\n", f); |
| 601 | break; |
| 602 | case 'c': |
| 603 | if (features->done & FEATURE_CAMERA) |
| 604 | printk(KERN_INFO "MINI2440: '%c' ignored, " |
| 605 | "camera already registered\n", f); |
| 606 | else |
| 607 | features->optional[features->count++] = |
| 608 | &s3c_device_camif; |
| 609 | features->done |= FEATURE_CAMERA; |
| 610 | break; |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | static void __init mini2440_init(void) |
| 616 | { |
| 617 | struct mini2440_features_t features = { 0 }; |
| 618 | int i; |
| 619 | |
| 620 | printk(KERN_INFO "MINI2440: Option string mini2440=%s\n", |
| 621 | mini2440_features_str); |
| 622 | |
| 623 | /* Parse the feature string */ |
| 624 | mini2440_parse_features(&features, mini2440_features_str); |
| 625 | |
| 626 | /* turn LCD on */ |
Ben Dooks | 40b956f | 2010-05-04 14:38:49 +0900 | [diff] [blame] | 627 | s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 628 | |
| 629 | /* Turn the backlight early on */ |
Ben Dooks | 64f508d | 2010-05-06 10:59:55 +0900 | [diff] [blame] | 630 | WARN_ON(gpio_request(S3C2410_GPG(4), "backlight")); |
| 631 | gpio_direction_output(S3C2410_GPG(4), 1); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 632 | |
| 633 | /* 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] | 634 | s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 635 | s3c2410_gpio_setpin(S3C2410_GPB(1), 0); |
Ben Dooks | 40b956f | 2010-05-04 14:38:49 +0900 | [diff] [blame] | 636 | s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPIO_INPUT); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 637 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 638 | /* mark the key as input, without pullups (there is one on the board) */ |
| 639 | for (i = 0; i < ARRAY_SIZE(mini2440_buttons); i++) { |
Ben Dooks | 64f508d | 2010-05-06 10:59:55 +0900 | [diff] [blame] | 640 | s3c_gpio_setpull(mini2440_buttons[i].gpio, S3C_GPIO_PULL_UP); |
| 641 | s3c_gpio_cfgpin(mini2440_buttons[i].gpio, S3C2410_GPIO_INPUT); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 642 | } |
| 643 | if (features.lcd_index != -1) { |
| 644 | int li; |
| 645 | |
| 646 | mini2440_fb_info.displays = |
| 647 | &mini2440_lcd_cfg[features.lcd_index]; |
| 648 | |
| 649 | printk(KERN_INFO "MINI2440: LCD"); |
| 650 | for (li = 0; li < ARRAY_SIZE(mini2440_lcd_cfg); li++) |
| 651 | if (li == features.lcd_index) |
| 652 | printk(" [%d:%dx%d]", li, |
| 653 | mini2440_lcd_cfg[li].width, |
| 654 | mini2440_lcd_cfg[li].height); |
| 655 | else |
| 656 | printk(" %d:%dx%d", li, |
| 657 | mini2440_lcd_cfg[li].width, |
| 658 | mini2440_lcd_cfg[li].height); |
| 659 | printk("\n"); |
| 660 | s3c24xx_fb_set_platdata(&mini2440_fb_info); |
| 661 | } |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 662 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 663 | s3c24xx_udc_set_platdata(&mini2440_udc_cfg); |
Ben Dooks | 22c810a | 2010-01-18 16:24:22 +0900 | [diff] [blame] | 664 | s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 665 | s3c_nand_set_platdata(&mini2440_nand_info); |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 666 | s3c_i2c0_set_platdata(NULL); |
Ben Dooks | 2a3a180 | 2009-09-28 13:59:49 +0300 | [diff] [blame] | 667 | |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 668 | i2c_register_board_info(0, mini2440_i2c_devs, |
| 669 | ARRAY_SIZE(mini2440_i2c_devs)); |
| 670 | |
| 671 | platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices)); |
| 672 | |
| 673 | if (features.count) /* the optional features */ |
| 674 | platform_add_devices(features.optional, features.count); |
| 675 | |
| 676 | } |
| 677 | |
| 678 | |
| 679 | MACHINE_START(MINI2440, "MINI2440") |
| 680 | /* Maintainer: Michel Pollet <buserror@gmail.com> */ |
Nicolas Pitre | 69d5071 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 681 | .atag_offset = 0x100, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 682 | .map_io = mini2440_map_io, |
| 683 | .init_machine = mini2440_init, |
| 684 | .init_irq = s3c24xx_init_irq, |
| 685 | .timer = &s3c24xx_timer, |
Kukjin Kim | b27b072 | 2012-01-03 14:02:03 +0100 | [diff] [blame^] | 686 | .restart = s3c2440_restart, |
Michel Pollet | 5102aa4 | 2009-03-25 17:19:14 +0000 | [diff] [blame] | 687 | MACHINE_END |