mach-real6410.c 7.7 KB

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