mach-mini6410.c 8.5 KB

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