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