mach-real6410.c 7.8 KB

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