mach-real6410.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. /* linux/arch/arm/mach-s3c64xx/mach-real6410.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. #include <linux/init.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/fb.h>
  17. #include <linux/gpio.h>
  18. #include <linux/kernel.h>
  19. #include <linux/list.h>
  20. #include <linux/dm9000.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/serial_core.h>
  25. #include <linux/types.h>
  26. #include <asm/hardware/vic.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <mach/map.h>
  31. #include <mach/regs-gpio.h>
  32. #include <mach/regs-modem.h>
  33. #include <mach/regs-srom.h>
  34. #include <plat/adc.h>
  35. #include <plat/cpu.h>
  36. #include <plat/devs.h>
  37. #include <plat/fb.h>
  38. #include <plat/nand.h>
  39. #include <plat/regs-serial.h>
  40. #include <plat/ts.h>
  41. #include <plat/regs-fb-v4.h>
  42. #include <video/platform_lcd.h>
  43. #include "common.h"
  44. #define UCON S3C2410_UCON_DEFAULT
  45. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
  46. #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
  47. static struct s3c2410_uartcfg real6410_uartcfgs[] __initdata = {
  48. [0] = {
  49. .hwport = 0,
  50. .flags = 0,
  51. .ucon = UCON,
  52. .ulcon = ULCON,
  53. .ufcon = UFCON,
  54. },
  55. [1] = {
  56. .hwport = 1,
  57. .flags = 0,
  58. .ucon = UCON,
  59. .ulcon = ULCON,
  60. .ufcon = UFCON,
  61. },
  62. [2] = {
  63. .hwport = 2,
  64. .flags = 0,
  65. .ucon = UCON,
  66. .ulcon = ULCON,
  67. .ufcon = UFCON,
  68. },
  69. [3] = {
  70. .hwport = 3,
  71. .flags = 0,
  72. .ucon = UCON,
  73. .ulcon = ULCON,
  74. .ufcon = UFCON,
  75. },
  76. };
  77. /* DM9000AEP 10/100 ethernet controller */
  78. static struct resource real6410_dm9k_resource[] = {
  79. [0] = {
  80. .start = S3C64XX_PA_XM0CSN1,
  81. .end = S3C64XX_PA_XM0CSN1 + 1,
  82. .flags = IORESOURCE_MEM
  83. },
  84. [1] = {
  85. .start = S3C64XX_PA_XM0CSN1 + 4,
  86. .end = S3C64XX_PA_XM0CSN1 + 5,
  87. .flags = IORESOURCE_MEM
  88. },
  89. [2] = {
  90. .start = S3C_EINT(7),
  91. .end = S3C_EINT(7),
  92. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL
  93. }
  94. };
  95. static struct dm9000_plat_data real6410_dm9k_pdata = {
  96. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  97. };
  98. static struct platform_device real6410_device_eth = {
  99. .name = "dm9000",
  100. .id = -1,
  101. .num_resources = ARRAY_SIZE(real6410_dm9k_resource),
  102. .resource = real6410_dm9k_resource,
  103. .dev = {
  104. .platform_data = &real6410_dm9k_pdata,
  105. },
  106. };
  107. static struct s3c_fb_pd_win real6410_lcd_type0_fb_win = {
  108. .max_bpp = 32,
  109. .default_bpp = 16,
  110. .xres = 480,
  111. .yres = 272,
  112. };
  113. static struct fb_videomode real6410_lcd_type0_timing = {
  114. /* 4.3" 480x272 */
  115. .left_margin = 3,
  116. .right_margin = 2,
  117. .upper_margin = 1,
  118. .lower_margin = 1,
  119. .hsync_len = 40,
  120. .vsync_len = 1,
  121. };
  122. static struct s3c_fb_pd_win real6410_lcd_type1_fb_win = {
  123. .max_bpp = 32,
  124. .default_bpp = 16,
  125. .xres = 800,
  126. .yres = 480,
  127. };
  128. static struct fb_videomode real6410_lcd_type1_timing = {
  129. /* 7.0" 800x480 */
  130. .left_margin = 8,
  131. .right_margin = 13,
  132. .upper_margin = 7,
  133. .lower_margin = 5,
  134. .hsync_len = 3,
  135. .vsync_len = 1,
  136. .xres = 800,
  137. .yres = 480,
  138. };
  139. static struct s3c_fb_platdata real6410_lcd_pdata[] __initdata = {
  140. {
  141. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  142. .vtiming = &real6410_lcd_type0_timing,
  143. .win[0] = &real6410_lcd_type0_fb_win,
  144. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  145. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  146. }, {
  147. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  148. .vtiming = &real6410_lcd_type1_timing,
  149. .win[0] = &real6410_lcd_type1_fb_win,
  150. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  151. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  152. },
  153. { },
  154. };
  155. static struct mtd_partition real6410_nand_part[] = {
  156. [0] = {
  157. .name = "uboot",
  158. .size = SZ_1M,
  159. .offset = 0,
  160. },
  161. [1] = {
  162. .name = "kernel",
  163. .size = SZ_2M,
  164. .offset = SZ_1M,
  165. },
  166. [2] = {
  167. .name = "rootfs",
  168. .size = MTDPART_SIZ_FULL,
  169. .offset = SZ_1M + SZ_2M,
  170. },
  171. };
  172. static struct s3c2410_nand_set real6410_nand_sets[] = {
  173. [0] = {
  174. .name = "nand",
  175. .nr_chips = 1,
  176. .nr_partitions = ARRAY_SIZE(real6410_nand_part),
  177. .partitions = real6410_nand_part,
  178. },
  179. };
  180. static struct s3c2410_platform_nand real6410_nand_info = {
  181. .tacls = 25,
  182. .twrph0 = 55,
  183. .twrph1 = 40,
  184. .nr_sets = ARRAY_SIZE(real6410_nand_sets),
  185. .sets = real6410_nand_sets,
  186. };
  187. static struct platform_device *real6410_devices[] __initdata = {
  188. &real6410_device_eth,
  189. &s3c_device_hsmmc0,
  190. &s3c_device_hsmmc1,
  191. &s3c_device_fb,
  192. &s3c_device_nand,
  193. &s3c_device_adc,
  194. &s3c_device_ts,
  195. &s3c_device_ohci,
  196. };
  197. static void __init real6410_map_io(void)
  198. {
  199. u32 tmp;
  200. s3c64xx_init_io(NULL, 0);
  201. s3c24xx_init_clocks(12000000);
  202. s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs));
  203. /* set the LCD type */
  204. tmp = __raw_readl(S3C64XX_SPCON);
  205. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  206. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  207. __raw_writel(tmp, S3C64XX_SPCON);
  208. /* remove the LCD bypass */
  209. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  210. tmp &= ~MIFPCON_LCD_BYPASS;
  211. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  212. }
  213. /*
  214. * real6410_features string
  215. *
  216. * 0-9 LCD configuration
  217. *
  218. */
  219. static char real6410_features_str[12] __initdata = "0";
  220. static int __init real6410_features_setup(char *str)
  221. {
  222. if (str)
  223. strlcpy(real6410_features_str, str,
  224. sizeof(real6410_features_str));
  225. return 1;
  226. }
  227. __setup("real6410=", real6410_features_setup);
  228. #define FEATURE_SCREEN (1 << 0)
  229. struct real6410_features_t {
  230. int done;
  231. int lcd_index;
  232. };
  233. static void real6410_parse_features(
  234. struct real6410_features_t *features,
  235. const char *features_str)
  236. {
  237. const char *fp = features_str;
  238. features->done = 0;
  239. features->lcd_index = 0;
  240. while (*fp) {
  241. char f = *fp++;
  242. switch (f) {
  243. case '0'...'9': /* tft screen */
  244. if (features->done & FEATURE_SCREEN) {
  245. printk(KERN_INFO "REAL6410: '%c' ignored, "
  246. "screen type already set\n", f);
  247. } else {
  248. int li = f - '0';
  249. if (li >= ARRAY_SIZE(real6410_lcd_pdata))
  250. printk(KERN_INFO "REAL6410: '%c' out "
  251. "of range LCD mode\n", f);
  252. else {
  253. features->lcd_index = li;
  254. }
  255. }
  256. features->done |= FEATURE_SCREEN;
  257. break;
  258. }
  259. }
  260. }
  261. static void __init real6410_machine_init(void)
  262. {
  263. u32 cs1;
  264. struct real6410_features_t features = { 0 };
  265. printk(KERN_INFO "REAL6410: Option string real6410=%s\n",
  266. real6410_features_str);
  267. /* Parse the feature string */
  268. real6410_parse_features(&features, real6410_features_str);
  269. printk(KERN_INFO "REAL6410: selected LCD display is %dx%d\n",
  270. real6410_lcd_pdata[features.lcd_index].win[0]->xres,
  271. real6410_lcd_pdata[features.lcd_index].win[0]->yres);
  272. s3c_fb_set_platdata(&real6410_lcd_pdata[features.lcd_index]);
  273. s3c_nand_set_platdata(&real6410_nand_info);
  274. s3c24xx_ts_set_platdata(NULL);
  275. /* configure nCS1 width to 16 bits */
  276. cs1 = __raw_readl(S3C64XX_SROM_BW) &
  277. ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
  278. cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
  279. (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
  280. (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
  281. S3C64XX_SROM_BW__NCS1__SHIFT;
  282. __raw_writel(cs1, S3C64XX_SROM_BW);
  283. /* set timing for nCS1 suitable for ethernet chip */
  284. __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
  285. (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
  286. (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
  287. (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
  288. (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
  289. (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
  290. (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
  291. gpio_request(S3C64XX_GPF(15), "LCD power");
  292. platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices));
  293. }
  294. MACHINE_START(REAL6410, "REAL6410")
  295. /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
  296. .atag_offset = 0x100,
  297. .init_irq = s3c6410_init_irq,
  298. .handle_irq = vic_handle_irq,
  299. .map_io = real6410_map_io,
  300. .init_machine = real6410_machine_init,
  301. .timer = &s3c24xx_timer,
  302. .restart = s3c64xx_restart,
  303. MACHINE_END