mach-mini6410.c 8.7 KB

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