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