mach-qt2410.c 7.7 KB

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