mach-qt2410.c 7.9 KB

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