Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c64xx/mach-mini6410.c |
| 2 | * |
| 3 | * Copyright 2010 Darius Augulis <augulis.darius@gmail.com> |
| 4 | * Copyright 2008 Openmoko, Inc. |
| 5 | * Copyright 2008 Simtec Electronics |
| 6 | * Ben Dooks <ben@simtec.co.uk> |
| 7 | * http://armlinux.simtec.co.uk/ |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/interrupt.h> |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 17 | #include <linux/fb.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 18 | #include <linux/gpio.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/list.h> |
| 21 | #include <linux/dm9000.h> |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 22 | #include <linux/mtd/mtd.h> |
| 23 | #include <linux/mtd/partitions.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 24 | #include <linux/serial_core.h> |
| 25 | #include <linux/types.h> |
| 26 | |
Jamie Iles | 774b51f | 2011-11-04 01:10:04 +0000 | [diff] [blame] | 27 | #include <asm/hardware/vic.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 28 | #include <asm/mach-types.h> |
| 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | |
| 32 | #include <mach/map.h> |
| 33 | #include <mach/regs-gpio.h> |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 34 | #include <mach/regs-modem.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 35 | #include <mach/regs-srom.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 36 | |
Darius Augulis | fe894f9 | 2010-10-19 16:10:02 +0900 | [diff] [blame] | 37 | #include <plat/adc.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 38 | #include <plat/cpu.h> |
| 39 | #include <plat/devs.h> |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 40 | #include <plat/fb.h> |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 41 | #include <plat/nand.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 42 | #include <plat/regs-serial.h> |
Darius Augulis | fe894f9 | 2010-10-19 16:10:02 +0900 | [diff] [blame] | 43 | #include <plat/ts.h> |
Ajay Kumar | 49965e6 | 2011-07-21 01:23:19 +0900 | [diff] [blame] | 44 | #include <plat/regs-fb-v4.h> |
Darius Augulis | fe894f9 | 2010-10-19 16:10:02 +0900 | [diff] [blame] | 45 | |
Darius Augulis | bbd7ac6 | 2010-10-19 16:09:59 +0900 | [diff] [blame] | 46 | #include <video/platform_lcd.h> |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 47 | |
Kukjin Kim | b024043b | 2011-12-22 23:27:42 +0100 | [diff] [blame] | 48 | #include "common.h" |
| 49 | |
Darius Augulis | 8b8c87d | 2010-11-16 18:08:50 +0900 | [diff] [blame] | 50 | #define UCON S3C2410_UCON_DEFAULT |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 51 | #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB) |
| 52 | #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE) |
| 53 | |
| 54 | static struct s3c2410_uartcfg mini6410_uartcfgs[] __initdata = { |
| 55 | [0] = { |
| 56 | .hwport = 0, |
| 57 | .flags = 0, |
| 58 | .ucon = UCON, |
| 59 | .ulcon = ULCON, |
| 60 | .ufcon = UFCON, |
| 61 | }, |
| 62 | [1] = { |
| 63 | .hwport = 1, |
| 64 | .flags = 0, |
| 65 | .ucon = UCON, |
| 66 | .ulcon = ULCON, |
| 67 | .ufcon = UFCON, |
| 68 | }, |
| 69 | [2] = { |
| 70 | .hwport = 2, |
| 71 | .flags = 0, |
| 72 | .ucon = UCON, |
| 73 | .ulcon = ULCON, |
| 74 | .ufcon = UFCON, |
| 75 | }, |
| 76 | [3] = { |
| 77 | .hwport = 3, |
| 78 | .flags = 0, |
| 79 | .ucon = UCON, |
| 80 | .ulcon = ULCON, |
| 81 | .ufcon = UFCON, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | /* DM9000AEP 10/100 ethernet controller */ |
| 86 | |
| 87 | static struct resource mini6410_dm9k_resource[] = { |
| 88 | [0] = { |
| 89 | .start = S3C64XX_PA_XM0CSN1, |
| 90 | .end = S3C64XX_PA_XM0CSN1 + 1, |
| 91 | .flags = IORESOURCE_MEM |
| 92 | }, |
| 93 | [1] = { |
| 94 | .start = S3C64XX_PA_XM0CSN1 + 4, |
| 95 | .end = S3C64XX_PA_XM0CSN1 + 5, |
| 96 | .flags = IORESOURCE_MEM |
| 97 | }, |
| 98 | [2] = { |
| 99 | .start = S3C_EINT(7), |
| 100 | .end = S3C_EINT(7), |
| 101 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | static struct dm9000_plat_data mini6410_dm9k_pdata = { |
| 106 | .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), |
| 107 | }; |
| 108 | |
| 109 | static struct platform_device mini6410_device_eth = { |
| 110 | .name = "dm9000", |
| 111 | .id = -1, |
| 112 | .num_resources = ARRAY_SIZE(mini6410_dm9k_resource), |
| 113 | .resource = mini6410_dm9k_resource, |
| 114 | .dev = { |
| 115 | .platform_data = &mini6410_dm9k_pdata, |
| 116 | }, |
| 117 | }; |
| 118 | |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 119 | static struct mtd_partition mini6410_nand_part[] = { |
| 120 | [0] = { |
| 121 | .name = "uboot", |
| 122 | .size = SZ_1M, |
| 123 | .offset = 0, |
| 124 | }, |
| 125 | [1] = { |
| 126 | .name = "kernel", |
| 127 | .size = SZ_2M, |
| 128 | .offset = SZ_1M, |
| 129 | }, |
| 130 | [2] = { |
| 131 | .name = "rootfs", |
| 132 | .size = MTDPART_SIZ_FULL, |
| 133 | .offset = SZ_1M + SZ_2M, |
| 134 | }, |
| 135 | }; |
| 136 | |
| 137 | static struct s3c2410_nand_set mini6410_nand_sets[] = { |
| 138 | [0] = { |
| 139 | .name = "nand", |
| 140 | .nr_chips = 1, |
| 141 | .nr_partitions = ARRAY_SIZE(mini6410_nand_part), |
| 142 | .partitions = mini6410_nand_part, |
| 143 | }, |
| 144 | }; |
| 145 | |
| 146 | static struct s3c2410_platform_nand mini6410_nand_info = { |
| 147 | .tacls = 25, |
| 148 | .twrph0 = 55, |
| 149 | .twrph1 = 40, |
| 150 | .nr_sets = ARRAY_SIZE(mini6410_nand_sets), |
| 151 | .sets = mini6410_nand_sets, |
| 152 | }; |
| 153 | |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 154 | static struct s3c_fb_pd_win mini6410_lcd_type0_fb_win = { |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 155 | .max_bpp = 32, |
| 156 | .default_bpp = 16, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame^] | 157 | .xres = 480, |
| 158 | .yres = 272, |
| 159 | }; |
| 160 | |
| 161 | static struct fb_videomode mini6410_lcd_type0_timing = { |
| 162 | /* 4.3" 480x272 */ |
| 163 | .left_margin = 3, |
| 164 | .right_margin = 2, |
| 165 | .upper_margin = 1, |
| 166 | .lower_margin = 1, |
| 167 | .hsync_len = 40, |
| 168 | .vsync_len = 1, |
| 169 | .xres = 480, |
| 170 | .yres = 272, |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 171 | }; |
| 172 | |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 173 | static struct s3c_fb_pd_win mini6410_lcd_type1_fb_win = { |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 174 | .max_bpp = 32, |
| 175 | .default_bpp = 16, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame^] | 176 | .xres = 800, |
| 177 | .yres = 480, |
| 178 | }; |
| 179 | |
| 180 | static struct fb_videomode mini6410_lcd_type1_timing = { |
| 181 | /* 7.0" 800x480 */ |
| 182 | .left_margin = 8, |
| 183 | .right_margin = 13, |
| 184 | .upper_margin = 7, |
| 185 | .lower_margin = 5, |
| 186 | .hsync_len = 3, |
| 187 | .vsync_len = 1, |
| 188 | .xres = 800, |
| 189 | .yres = 480, |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | static struct s3c_fb_platdata mini6410_lcd_pdata[] __initdata = { |
| 193 | { |
| 194 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame^] | 195 | .vtiming = &mini6410_lcd_type0_timing, |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 196 | .win[0] = &mini6410_lcd_type0_fb_win, |
| 197 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
| 198 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, |
| 199 | }, { |
| 200 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame^] | 201 | .vtiming = &mini6410_lcd_type1_timing, |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 202 | .win[0] = &mini6410_lcd_type1_fb_win, |
| 203 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
| 204 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, |
| 205 | }, |
| 206 | { }, |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 207 | }; |
| 208 | |
Darius Augulis | bbd7ac6 | 2010-10-19 16:09:59 +0900 | [diff] [blame] | 209 | static void mini6410_lcd_power_set(struct plat_lcd_data *pd, |
| 210 | unsigned int power) |
| 211 | { |
| 212 | if (power) |
| 213 | gpio_direction_output(S3C64XX_GPE(0), 1); |
| 214 | else |
| 215 | gpio_direction_output(S3C64XX_GPE(0), 0); |
| 216 | } |
| 217 | |
| 218 | static struct plat_lcd_data mini6410_lcd_power_data = { |
| 219 | .set_power = mini6410_lcd_power_set, |
| 220 | }; |
| 221 | |
| 222 | static struct platform_device mini6410_lcd_powerdev = { |
| 223 | .name = "platform-lcd", |
| 224 | .dev.parent = &s3c_device_fb.dev, |
| 225 | .dev.platform_data = &mini6410_lcd_power_data, |
| 226 | }; |
| 227 | |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 228 | static struct platform_device *mini6410_devices[] __initdata = { |
| 229 | &mini6410_device_eth, |
| 230 | &s3c_device_hsmmc0, |
| 231 | &s3c_device_hsmmc1, |
| 232 | &s3c_device_ohci, |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 233 | &s3c_device_nand, |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 234 | &s3c_device_fb, |
Darius Augulis | bbd7ac6 | 2010-10-19 16:09:59 +0900 | [diff] [blame] | 235 | &mini6410_lcd_powerdev, |
Darius Augulis | fe894f9 | 2010-10-19 16:10:02 +0900 | [diff] [blame] | 236 | &s3c_device_adc, |
| 237 | &s3c_device_ts, |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | static void __init mini6410_map_io(void) |
| 241 | { |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 242 | u32 tmp; |
| 243 | |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 244 | s3c64xx_init_io(NULL, 0); |
| 245 | s3c24xx_init_clocks(12000000); |
| 246 | s3c24xx_init_uarts(mini6410_uartcfgs, ARRAY_SIZE(mini6410_uartcfgs)); |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 247 | |
| 248 | /* set the LCD type */ |
| 249 | tmp = __raw_readl(S3C64XX_SPCON); |
| 250 | tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK; |
| 251 | tmp |= S3C64XX_SPCON_LCD_SEL_RGB; |
| 252 | __raw_writel(tmp, S3C64XX_SPCON); |
| 253 | |
| 254 | /* remove the LCD bypass */ |
| 255 | tmp = __raw_readl(S3C64XX_MODEM_MIFPCON); |
| 256 | tmp &= ~MIFPCON_LCD_BYPASS; |
| 257 | __raw_writel(tmp, S3C64XX_MODEM_MIFPCON); |
| 258 | } |
| 259 | |
| 260 | /* |
| 261 | * mini6410_features string |
| 262 | * |
| 263 | * 0-9 LCD configuration |
| 264 | * |
| 265 | */ |
| 266 | static char mini6410_features_str[12] __initdata = "0"; |
| 267 | |
| 268 | static int __init mini6410_features_setup(char *str) |
| 269 | { |
| 270 | if (str) |
| 271 | strlcpy(mini6410_features_str, str, |
| 272 | sizeof(mini6410_features_str)); |
| 273 | return 1; |
| 274 | } |
| 275 | |
| 276 | __setup("mini6410=", mini6410_features_setup); |
| 277 | |
| 278 | #define FEATURE_SCREEN (1 << 0) |
| 279 | |
| 280 | struct mini6410_features_t { |
| 281 | int done; |
| 282 | int lcd_index; |
| 283 | }; |
| 284 | |
| 285 | static void mini6410_parse_features( |
| 286 | struct mini6410_features_t *features, |
| 287 | const char *features_str) |
| 288 | { |
| 289 | const char *fp = features_str; |
| 290 | |
| 291 | features->done = 0; |
| 292 | features->lcd_index = 0; |
| 293 | |
| 294 | while (*fp) { |
| 295 | char f = *fp++; |
| 296 | |
| 297 | switch (f) { |
| 298 | case '0'...'9': /* tft screen */ |
| 299 | if (features->done & FEATURE_SCREEN) { |
| 300 | printk(KERN_INFO "MINI6410: '%c' ignored, " |
| 301 | "screen type already set\n", f); |
| 302 | } else { |
| 303 | int li = f - '0'; |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 304 | if (li >= ARRAY_SIZE(mini6410_lcd_pdata)) |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 305 | printk(KERN_INFO "MINI6410: '%c' out " |
| 306 | "of range LCD mode\n", f); |
| 307 | else { |
| 308 | features->lcd_index = li; |
| 309 | } |
| 310 | } |
| 311 | features->done |= FEATURE_SCREEN; |
| 312 | break; |
| 313 | } |
| 314 | } |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static void __init mini6410_machine_init(void) |
| 318 | { |
| 319 | u32 cs1; |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 320 | struct mini6410_features_t features = { 0 }; |
| 321 | |
| 322 | printk(KERN_INFO "MINI6410: Option string mini6410=%s\n", |
| 323 | mini6410_features_str); |
| 324 | |
| 325 | /* Parse the feature string */ |
| 326 | mini6410_parse_features(&features, mini6410_features_str); |
| 327 | |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 328 | printk(KERN_INFO "MINI6410: selected LCD display is %dx%d\n", |
Thomas Abraham | 79d3c41 | 2012-03-24 21:58:48 +0530 | [diff] [blame^] | 329 | mini6410_lcd_pdata[features.lcd_index].win[0]->xres, |
| 330 | mini6410_lcd_pdata[features.lcd_index].win[0]->yres); |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 331 | |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 332 | s3c_nand_set_platdata(&mini6410_nand_info); |
Thomas Abraham | 884924b | 2012-03-24 21:58:47 +0530 | [diff] [blame] | 333 | s3c_fb_set_platdata(&mini6410_lcd_pdata[features.lcd_index]); |
Naveen Krishna Chatradhi | 0804765 | 2011-08-19 21:56:10 +0900 | [diff] [blame] | 334 | s3c24xx_ts_set_platdata(NULL); |
Darius Augulis | 1c5d76e | 2010-10-19 16:04:16 +0900 | [diff] [blame] | 335 | |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 336 | /* configure nCS1 width to 16 bits */ |
| 337 | |
| 338 | cs1 = __raw_readl(S3C64XX_SROM_BW) & |
| 339 | ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT); |
| 340 | cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) | |
| 341 | (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) | |
| 342 | (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) << |
| 343 | S3C64XX_SROM_BW__NCS1__SHIFT; |
| 344 | __raw_writel(cs1, S3C64XX_SROM_BW); |
| 345 | |
| 346 | /* set timing for nCS1 suitable for ethernet chip */ |
| 347 | |
| 348 | __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) | |
| 349 | (6 << S3C64XX_SROM_BCX__TACP__SHIFT) | |
| 350 | (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) | |
| 351 | (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) | |
| 352 | (13 << S3C64XX_SROM_BCX__TACC__SHIFT) | |
| 353 | (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) | |
| 354 | (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1); |
| 355 | |
Darius Augulis | 2abca87 | 2010-10-19 16:06:54 +0900 | [diff] [blame] | 356 | gpio_request(S3C64XX_GPF(15), "LCD power"); |
| 357 | gpio_request(S3C64XX_GPE(0), "LCD power"); |
| 358 | |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 359 | platform_add_devices(mini6410_devices, ARRAY_SIZE(mini6410_devices)); |
| 360 | } |
| 361 | |
| 362 | MACHINE_START(MINI6410, "MINI6410") |
| 363 | /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */ |
Nicolas Pitre | 170a590 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 364 | .atag_offset = 0x100, |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 365 | .init_irq = s3c6410_init_irq, |
Jamie Iles | 774b51f | 2011-11-04 01:10:04 +0000 | [diff] [blame] | 366 | .handle_irq = vic_handle_irq, |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 367 | .map_io = mini6410_map_io, |
| 368 | .init_machine = mini6410_machine_init, |
| 369 | .timer = &s3c24xx_timer, |
Kukjin Kim | ff84ded | 2012-01-03 14:03:30 +0100 | [diff] [blame] | 370 | .restart = s3c64xx_restart, |
Darius Augulis | e9debd9 | 2010-10-21 07:42:29 +0900 | [diff] [blame] | 371 | MACHINE_END |