mach-real6410.c 7.8 KB

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