mach-real6410.c 7.9 KB

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