mach-qt2410.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. // SPDX-License-Identifier: GPL-2.0+
  2. //
  3. // Copyright (C) 2006 by OpenMoko, Inc.
  4. // Author: Harald Welte <laforge@openmoko.org>
  5. // All rights reserved.
  6. #include <linux/kernel.h>
  7. #include <linux/types.h>
  8. #include <linux/interrupt.h>
  9. #include <linux/list.h>
  10. #include <linux/timer.h>
  11. #include <linux/init.h>
  12. #include <linux/gpio.h>
  13. #include <linux/gpio/machine.h>
  14. #include <linux/device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/serial_core.h>
  17. #include <linux/serial_s3c.h>
  18. #include <linux/spi/spi.h>
  19. #include <linux/spi/spi_gpio.h>
  20. #include <linux/io.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/rawnand.h>
  23. #include <linux/mtd/nand_ecc.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <asm/mach/irq.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach-types.h>
  31. #include <linux/platform_data/leds-s3c24xx.h>
  32. #include <mach/regs-lcd.h>
  33. #include <mach/fb.h>
  34. #include <linux/platform_data/mtd-nand-s3c2410.h>
  35. #include <linux/platform_data/usb-s3c2410_udc.h>
  36. #include <linux/platform_data/i2c-s3c2410.h>
  37. #include <mach/gpio-samsung.h>
  38. #include <plat/gpio-cfg.h>
  39. #include <plat/devs.h>
  40. #include <plat/cpu.h>
  41. #include <plat/pm.h>
  42. #include <plat/samsung-time.h>
  43. #include "common.h"
  44. #include "common-smdk.h"
  45. static struct map_desc qt2410_iodesc[] __initdata = {
  46. { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
  47. };
  48. #define UCON S3C2410_UCON_DEFAULT
  49. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  50. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  51. static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
  52. [0] = {
  53. .hwport = 0,
  54. .flags = 0,
  55. .ucon = UCON,
  56. .ulcon = ULCON,
  57. .ufcon = UFCON,
  58. },
  59. [1] = {
  60. .hwport = 1,
  61. .flags = 0,
  62. .ucon = UCON,
  63. .ulcon = ULCON,
  64. .ufcon = UFCON,
  65. },
  66. [2] = {
  67. .hwport = 2,
  68. .flags = 0,
  69. .ucon = UCON,
  70. .ulcon = ULCON,
  71. .ufcon = UFCON,
  72. }
  73. };
  74. /* LCD driver info */
  75. static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
  76. {
  77. /* Configuration for 640x480 SHARP LQ080V3DG01 */
  78. .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  79. S3C2410_LCDCON5_INVVLINE |
  80. S3C2410_LCDCON5_INVVFRAME |
  81. S3C2410_LCDCON5_PWREN |
  82. S3C2410_LCDCON5_HWSWP,
  83. .type = S3C2410_LCDCON1_TFT,
  84. .width = 640,
  85. .height = 480,
  86. .pixclock = 40000, /* HCLK/4 */
  87. .xres = 640,
  88. .yres = 480,
  89. .bpp = 16,
  90. .left_margin = 44,
  91. .right_margin = 116,
  92. .hsync_len = 96,
  93. .upper_margin = 19,
  94. .lower_margin = 11,
  95. .vsync_len = 15,
  96. },
  97. {
  98. /* Configuration for 480x640 toppoly TD028TTEC1 */
  99. .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  100. S3C2410_LCDCON5_INVVLINE |
  101. S3C2410_LCDCON5_INVVFRAME |
  102. S3C2410_LCDCON5_PWREN |
  103. S3C2410_LCDCON5_HWSWP,
  104. .type = S3C2410_LCDCON1_TFT,
  105. .width = 480,
  106. .height = 640,
  107. .pixclock = 40000, /* HCLK/4 */
  108. .xres = 480,
  109. .yres = 640,
  110. .bpp = 16,
  111. .left_margin = 8,
  112. .right_margin = 24,
  113. .hsync_len = 8,
  114. .upper_margin = 2,
  115. .lower_margin = 4,
  116. .vsync_len = 2,
  117. },
  118. {
  119. /* Config for 240x320 LCD */
  120. .lcdcon5 = S3C2410_LCDCON5_FRM565 |
  121. S3C2410_LCDCON5_INVVLINE |
  122. S3C2410_LCDCON5_INVVFRAME |
  123. S3C2410_LCDCON5_PWREN |
  124. S3C2410_LCDCON5_HWSWP,
  125. .type = S3C2410_LCDCON1_TFT,
  126. .width = 240,
  127. .height = 320,
  128. .pixclock = 100000, /* HCLK/10 */
  129. .xres = 240,
  130. .yres = 320,
  131. .bpp = 16,
  132. .left_margin = 13,
  133. .right_margin = 8,
  134. .hsync_len = 4,
  135. .upper_margin = 2,
  136. .lower_margin = 7,
  137. .vsync_len = 4,
  138. },
  139. };
  140. static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
  141. .displays = qt2410_lcd_cfg,
  142. .num_displays = ARRAY_SIZE(qt2410_lcd_cfg),
  143. .default_display = 0,
  144. .lpcsel = ((0xCE6) & ~7) | 1<<4,
  145. };
  146. /* CS8900 */
  147. static struct resource qt2410_cs89x0_resources[] = {
  148. [0] = DEFINE_RES_MEM(0x19000000, 17),
  149. [1] = DEFINE_RES_IRQ(IRQ_EINT9),
  150. };
  151. static struct platform_device qt2410_cs89x0 = {
  152. .name = "cirrus-cs89x0",
  153. .num_resources = ARRAY_SIZE(qt2410_cs89x0_resources),
  154. .resource = qt2410_cs89x0_resources,
  155. };
  156. /* LED */
  157. static struct s3c24xx_led_platdata qt2410_pdata_led = {
  158. .gpio = S3C2410_GPB(0),
  159. .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
  160. .name = "led",
  161. .def_trigger = "timer",
  162. };
  163. static struct platform_device qt2410_led = {
  164. .name = "s3c24xx_led",
  165. .id = 0,
  166. .dev = {
  167. .platform_data = &qt2410_pdata_led,
  168. },
  169. };
  170. /* SPI */
  171. static struct spi_gpio_platform_data spi_gpio_cfg = {
  172. .num_chipselect = 1,
  173. };
  174. static struct platform_device qt2410_spi = {
  175. .name = "spi_gpio",
  176. .id = 1,
  177. .dev.platform_data = &spi_gpio_cfg,
  178. };
  179. static struct gpiod_lookup_table qt2410_spi_gpiod_table = {
  180. .dev_id = "spi_gpio",
  181. .table = {
  182. GPIO_LOOKUP("GPIOG", 7,
  183. "sck", GPIO_ACTIVE_HIGH),
  184. GPIO_LOOKUP("GPIOG", 6,
  185. "mosi", GPIO_ACTIVE_HIGH),
  186. GPIO_LOOKUP("GPIOG", 5,
  187. "miso", GPIO_ACTIVE_HIGH),
  188. GPIO_LOOKUP("GPIOB", 5,
  189. "cs", GPIO_ACTIVE_HIGH),
  190. { },
  191. },
  192. };
  193. /* Board devices */
  194. static struct platform_device *qt2410_devices[] __initdata = {
  195. &s3c_device_ohci,
  196. &s3c_device_lcd,
  197. &s3c_device_wdt,
  198. &s3c_device_i2c0,
  199. &s3c_device_iis,
  200. &s3c_device_sdi,
  201. &s3c_device_usbgadget,
  202. &qt2410_spi,
  203. &qt2410_cs89x0,
  204. &qt2410_led,
  205. };
  206. static struct mtd_partition __initdata qt2410_nand_part[] = {
  207. [0] = {
  208. .name = "U-Boot",
  209. .size = 0x30000,
  210. .offset = 0,
  211. },
  212. [1] = {
  213. .name = "U-Boot environment",
  214. .offset = 0x30000,
  215. .size = 0x4000,
  216. },
  217. [2] = {
  218. .name = "kernel",
  219. .offset = 0x34000,
  220. .size = SZ_2M,
  221. },
  222. [3] = {
  223. .name = "initrd",
  224. .offset = 0x234000,
  225. .size = SZ_4M,
  226. },
  227. [4] = {
  228. .name = "jffs2",
  229. .offset = 0x634000,
  230. .size = 0x39cc000,
  231. },
  232. };
  233. static struct s3c2410_nand_set __initdata qt2410_nand_sets[] = {
  234. [0] = {
  235. .name = "NAND",
  236. .nr_chips = 1,
  237. .nr_partitions = ARRAY_SIZE(qt2410_nand_part),
  238. .partitions = qt2410_nand_part,
  239. },
  240. };
  241. /* choose a set of timings which should suit most 512Mbit
  242. * chips and beyond.
  243. */
  244. static struct s3c2410_platform_nand __initdata qt2410_nand_info = {
  245. .tacls = 20,
  246. .twrph0 = 60,
  247. .twrph1 = 20,
  248. .nr_sets = ARRAY_SIZE(qt2410_nand_sets),
  249. .sets = qt2410_nand_sets,
  250. .ecc_mode = NAND_ECC_SOFT,
  251. };
  252. /* UDC */
  253. static struct s3c2410_udc_mach_info qt2410_udc_cfg = {
  254. };
  255. static char tft_type = 's';
  256. static int __init qt2410_tft_setup(char *str)
  257. {
  258. tft_type = str[0];
  259. return 1;
  260. }
  261. __setup("tft=", qt2410_tft_setup);
  262. static void __init qt2410_map_io(void)
  263. {
  264. s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
  265. s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
  266. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  267. }
  268. static void __init qt2410_init_time(void)
  269. {
  270. s3c2410_init_clocks(12000000);
  271. samsung_timer_init();
  272. }
  273. static void __init qt2410_machine_init(void)
  274. {
  275. s3c_nand_set_platdata(&qt2410_nand_info);
  276. switch (tft_type) {
  277. case 'p': /* production */
  278. qt2410_fb_info.default_display = 1;
  279. break;
  280. case 'b': /* big */
  281. qt2410_fb_info.default_display = 0;
  282. break;
  283. case 's': /* small */
  284. default:
  285. qt2410_fb_info.default_display = 2;
  286. break;
  287. }
  288. s3c24xx_fb_set_platdata(&qt2410_fb_info);
  289. /* set initial state of the LED GPIO */
  290. WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
  291. gpio_free(S3C2410_GPB(0));
  292. s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
  293. s3c_i2c0_set_platdata(NULL);
  294. gpiod_add_lookup_table(&qt2410_spi_gpiod_table);
  295. platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
  296. s3c_pm_init();
  297. }
  298. MACHINE_START(QT2410, "QT2410")
  299. .atag_offset = 0x100,
  300. .map_io = qt2410_map_io,
  301. .init_irq = s3c2410_init_irq,
  302. .init_machine = qt2410_machine_init,
  303. .init_time = qt2410_init_time,
  304. MACHINE_END