mach-mini6410.c 8.6 KB

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