mach-real6410.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. .win_mode = { /* 4.3" 480x272 */
  109. .left_margin = 3,
  110. .right_margin = 2,
  111. .upper_margin = 1,
  112. .lower_margin = 1,
  113. .hsync_len = 40,
  114. .vsync_len = 1,
  115. .xres = 480,
  116. .yres = 272,
  117. },
  118. .max_bpp = 32,
  119. .default_bpp = 16,
  120. };
  121. static struct s3c_fb_pd_win real6410_lcd_type1_fb_win = {
  122. .win_mode = { /* 7.0" 800x480 */
  123. .left_margin = 8,
  124. .right_margin = 13,
  125. .upper_margin = 7,
  126. .lower_margin = 5,
  127. .hsync_len = 3,
  128. .vsync_len = 1,
  129. .xres = 800,
  130. .yres = 480,
  131. },
  132. .max_bpp = 32,
  133. .default_bpp = 16,
  134. };
  135. static struct s3c_fb_platdata real6410_lcd_pdata[] __initdata = {
  136. {
  137. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  138. .win[0] = &real6410_lcd_type0_fb_win,
  139. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  140. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  141. }, {
  142. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  143. .win[0] = &real6410_lcd_type1_fb_win,
  144. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  145. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  146. },
  147. { },
  148. };
  149. static struct mtd_partition real6410_nand_part[] = {
  150. [0] = {
  151. .name = "uboot",
  152. .size = SZ_1M,
  153. .offset = 0,
  154. },
  155. [1] = {
  156. .name = "kernel",
  157. .size = SZ_2M,
  158. .offset = SZ_1M,
  159. },
  160. [2] = {
  161. .name = "rootfs",
  162. .size = MTDPART_SIZ_FULL,
  163. .offset = SZ_1M + SZ_2M,
  164. },
  165. };
  166. static struct s3c2410_nand_set real6410_nand_sets[] = {
  167. [0] = {
  168. .name = "nand",
  169. .nr_chips = 1,
  170. .nr_partitions = ARRAY_SIZE(real6410_nand_part),
  171. .partitions = real6410_nand_part,
  172. },
  173. };
  174. static struct s3c2410_platform_nand real6410_nand_info = {
  175. .tacls = 25,
  176. .twrph0 = 55,
  177. .twrph1 = 40,
  178. .nr_sets = ARRAY_SIZE(real6410_nand_sets),
  179. .sets = real6410_nand_sets,
  180. };
  181. static struct platform_device *real6410_devices[] __initdata = {
  182. &real6410_device_eth,
  183. &s3c_device_hsmmc0,
  184. &s3c_device_hsmmc1,
  185. &s3c_device_fb,
  186. &s3c_device_nand,
  187. &s3c_device_adc,
  188. &s3c_device_ts,
  189. &s3c_device_ohci,
  190. };
  191. static void __init real6410_map_io(void)
  192. {
  193. u32 tmp;
  194. s3c64xx_init_io(NULL, 0);
  195. s3c24xx_init_clocks(12000000);
  196. s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs));
  197. /* set the LCD type */
  198. tmp = __raw_readl(S3C64XX_SPCON);
  199. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  200. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  201. __raw_writel(tmp, S3C64XX_SPCON);
  202. /* remove the LCD bypass */
  203. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  204. tmp &= ~MIFPCON_LCD_BYPASS;
  205. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  206. }
  207. /*
  208. * real6410_features string
  209. *
  210. * 0-9 LCD configuration
  211. *
  212. */
  213. static char real6410_features_str[12] __initdata = "0";
  214. static int __init real6410_features_setup(char *str)
  215. {
  216. if (str)
  217. strlcpy(real6410_features_str, str,
  218. sizeof(real6410_features_str));
  219. return 1;
  220. }
  221. __setup("real6410=", real6410_features_setup);
  222. #define FEATURE_SCREEN (1 << 0)
  223. struct real6410_features_t {
  224. int done;
  225. int lcd_index;
  226. };
  227. static void real6410_parse_features(
  228. struct real6410_features_t *features,
  229. const char *features_str)
  230. {
  231. const char *fp = features_str;
  232. features->done = 0;
  233. features->lcd_index = 0;
  234. while (*fp) {
  235. char f = *fp++;
  236. switch (f) {
  237. case '0'...'9': /* tft screen */
  238. if (features->done & FEATURE_SCREEN) {
  239. printk(KERN_INFO "REAL6410: '%c' ignored, "
  240. "screen type already set\n", f);
  241. } else {
  242. int li = f - '0';
  243. if (li >= ARRAY_SIZE(real6410_lcd_pdata))
  244. printk(KERN_INFO "REAL6410: '%c' out "
  245. "of range LCD mode\n", f);
  246. else {
  247. features->lcd_index = li;
  248. }
  249. }
  250. features->done |= FEATURE_SCREEN;
  251. break;
  252. }
  253. }
  254. }
  255. static void __init real6410_machine_init(void)
  256. {
  257. u32 cs1;
  258. struct real6410_features_t features = { 0 };
  259. printk(KERN_INFO "REAL6410: Option string real6410=%s\n",
  260. real6410_features_str);
  261. /* Parse the feature string */
  262. real6410_parse_features(&features, real6410_features_str);
  263. printk(KERN_INFO "REAL6410: selected LCD display is %dx%d\n",
  264. real6410_lcd_pdata[features.lcd_index].win[0]->win_mode.xres,
  265. real6410_lcd_pdata[features.lcd_index].win[0]->win_mode.yres);
  266. s3c_fb_set_platdata(&real6410_lcd_pdata[features.lcd_index]);
  267. s3c_nand_set_platdata(&real6410_nand_info);
  268. s3c24xx_ts_set_platdata(NULL);
  269. /* configure nCS1 width to 16 bits */
  270. cs1 = __raw_readl(S3C64XX_SROM_BW) &
  271. ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
  272. cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
  273. (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
  274. (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
  275. S3C64XX_SROM_BW__NCS1__SHIFT;
  276. __raw_writel(cs1, S3C64XX_SROM_BW);
  277. /* set timing for nCS1 suitable for ethernet chip */
  278. __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
  279. (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
  280. (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
  281. (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
  282. (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
  283. (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
  284. (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
  285. gpio_request(S3C64XX_GPF(15), "LCD power");
  286. platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices));
  287. }
  288. MACHINE_START(REAL6410, "REAL6410")
  289. /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
  290. .atag_offset = 0x100,
  291. .init_irq = s3c6410_init_irq,
  292. .handle_irq = vic_handle_irq,
  293. .map_io = real6410_map_io,
  294. .init_machine = real6410_machine_init,
  295. .timer = &s3c24xx_timer,
  296. .restart = s3c64xx_restart,
  297. MACHINE_END