littleton.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /*
  2. * linux/arch/arm/mach-pxa/littleton.c
  3. *
  4. * Support for the Marvell Littleton Development Platform.
  5. *
  6. * Author: Jason Chagas (largely modified code)
  7. * Created: Nov 20, 2006
  8. * Copyright: (C) Copyright 2006 Marvell International Ltd.
  9. *
  10. * 2007-11-22 modified to align with latest kernel
  11. * eric miao <eric.miao@marvell.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * publishhed by the Free Software Foundation.
  16. */
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/delay.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/clk.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/smc91x.h>
  24. #include <asm/types.h>
  25. #include <asm/setup.h>
  26. #include <asm/memory.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/irq.h>
  33. #include <mach/pxa-regs.h>
  34. #include <mach/mfp-pxa300.h>
  35. #include <mach/gpio.h>
  36. #include <mach/pxafb.h>
  37. #include <mach/ssp.h>
  38. #include <mach/pxa2xx_spi.h>
  39. #include <mach/pxa27x_keypad.h>
  40. #include <mach/pxa3xx_nand.h>
  41. #include <mach/littleton.h>
  42. #include "generic.h"
  43. /* Littleton MFP configurations */
  44. static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
  45. /* LCD */
  46. GPIO54_LCD_LDD_0,
  47. GPIO55_LCD_LDD_1,
  48. GPIO56_LCD_LDD_2,
  49. GPIO57_LCD_LDD_3,
  50. GPIO58_LCD_LDD_4,
  51. GPIO59_LCD_LDD_5,
  52. GPIO60_LCD_LDD_6,
  53. GPIO61_LCD_LDD_7,
  54. GPIO62_LCD_LDD_8,
  55. GPIO63_LCD_LDD_9,
  56. GPIO64_LCD_LDD_10,
  57. GPIO65_LCD_LDD_11,
  58. GPIO66_LCD_LDD_12,
  59. GPIO67_LCD_LDD_13,
  60. GPIO68_LCD_LDD_14,
  61. GPIO69_LCD_LDD_15,
  62. GPIO70_LCD_LDD_16,
  63. GPIO71_LCD_LDD_17,
  64. GPIO72_LCD_FCLK,
  65. GPIO73_LCD_LCLK,
  66. GPIO74_LCD_PCLK,
  67. GPIO75_LCD_BIAS,
  68. /* SSP2 */
  69. GPIO25_SSP2_SCLK,
  70. GPIO27_SSP2_TXD,
  71. GPIO17_GPIO, /* SFRM as chip-select */
  72. /* Debug Ethernet */
  73. GPIO90_GPIO,
  74. /* Keypad */
  75. GPIO107_KP_DKIN_0,
  76. GPIO108_KP_DKIN_1,
  77. GPIO115_KP_MKIN_0,
  78. GPIO116_KP_MKIN_1,
  79. GPIO117_KP_MKIN_2,
  80. GPIO118_KP_MKIN_3,
  81. GPIO119_KP_MKIN_4,
  82. GPIO120_KP_MKIN_5,
  83. GPIO121_KP_MKOUT_0,
  84. GPIO122_KP_MKOUT_1,
  85. GPIO123_KP_MKOUT_2,
  86. GPIO124_KP_MKOUT_3,
  87. GPIO125_KP_MKOUT_4,
  88. };
  89. static struct resource smc91x_resources[] = {
  90. [0] = {
  91. .start = (LITTLETON_ETH_PHYS + 0x300),
  92. .end = (LITTLETON_ETH_PHYS + 0xfffff),
  93. .flags = IORESOURCE_MEM,
  94. },
  95. [1] = {
  96. .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  97. .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  98. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  99. }
  100. };
  101. static struct smc91x_platdata littleton_smc91x_info = {
  102. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
  103. SMC91X_NOWAIT | SMC91X_USE_DMA,
  104. };
  105. static struct platform_device smc91x_device = {
  106. .name = "smc91x",
  107. .id = 0,
  108. .num_resources = ARRAY_SIZE(smc91x_resources),
  109. .resource = smc91x_resources,
  110. .dev = {
  111. .platform_data = &littleton_smc91x_info,
  112. },
  113. };
  114. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  115. static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
  116. [0] = {
  117. /* VGA */
  118. .pixclock = 38250,
  119. .xres = 480,
  120. .yres = 640,
  121. .bpp = 16,
  122. .hsync_len = 8,
  123. .left_margin = 8,
  124. .right_margin = 24,
  125. .vsync_len = 2,
  126. .upper_margin = 2,
  127. .lower_margin = 4,
  128. .sync = 0,
  129. },
  130. [1] = {
  131. /* QVGA */
  132. .pixclock = 153000,
  133. .xres = 240,
  134. .yres = 320,
  135. .bpp = 16,
  136. .hsync_len = 8,
  137. .left_margin = 8,
  138. .right_margin = 88,
  139. .vsync_len = 2,
  140. .upper_margin = 2,
  141. .lower_margin = 2,
  142. .sync = 0,
  143. },
  144. };
  145. static struct pxafb_mach_info littleton_lcd_info = {
  146. .modes = tpo_tdo24mtea1_modes,
  147. .num_modes = 2,
  148. .lcd_conn = LCD_COLOR_TFT_16BPP,
  149. };
  150. static void littleton_init_lcd(void)
  151. {
  152. set_pxa_fb_info(&littleton_lcd_info);
  153. }
  154. #else
  155. static inline void littleton_init_lcd(void) {};
  156. #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
  157. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  158. static struct pxa2xx_spi_master littleton_spi_info = {
  159. .num_chipselect = 1,
  160. };
  161. static void littleton_tdo24m_cs(u32 cmd)
  162. {
  163. gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT));
  164. }
  165. static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
  166. .rx_threshold = 1,
  167. .tx_threshold = 1,
  168. .cs_control = littleton_tdo24m_cs,
  169. };
  170. static struct spi_board_info littleton_spi_devices[] __initdata = {
  171. {
  172. .modalias = "tdo24m",
  173. .max_speed_hz = 1000000,
  174. .bus_num = 2,
  175. .chip_select = 0,
  176. .controller_data= &littleton_tdo24m_chip,
  177. },
  178. };
  179. static void __init littleton_init_spi(void)
  180. {
  181. int err;
  182. err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS");
  183. if (err) {
  184. pr_warning("failed to request GPIO for LCS CS\n");
  185. return;
  186. }
  187. gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1);
  188. pxa2xx_set_spi_info(2, &littleton_spi_info);
  189. spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
  190. }
  191. #else
  192. static inline void littleton_init_spi(void) {}
  193. #endif
  194. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  195. static unsigned int littleton_matrix_key_map[] = {
  196. /* KEY(row, col, key_code) */
  197. KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
  198. KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
  199. KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
  200. KEY(0, 3, KEY_KPASTERISK), /* * */
  201. KEY(2, 3, KEY_KPDOT), /* # */
  202. KEY(5, 4, KEY_ENTER),
  203. KEY(5, 0, KEY_UP),
  204. KEY(5, 1, KEY_DOWN),
  205. KEY(5, 2, KEY_LEFT),
  206. KEY(5, 3, KEY_RIGHT),
  207. KEY(3, 2, KEY_HOME),
  208. KEY(4, 1, KEY_END),
  209. KEY(3, 3, KEY_BACK),
  210. KEY(4, 0, KEY_SEND),
  211. KEY(4, 2, KEY_VOLUMEUP),
  212. KEY(4, 3, KEY_VOLUMEDOWN),
  213. KEY(3, 0, KEY_F22), /* soft1 */
  214. KEY(3, 1, KEY_F23), /* soft2 */
  215. };
  216. static struct pxa27x_keypad_platform_data littleton_keypad_info = {
  217. .matrix_key_rows = 6,
  218. .matrix_key_cols = 5,
  219. .matrix_key_map = littleton_matrix_key_map,
  220. .matrix_key_map_size = ARRAY_SIZE(littleton_matrix_key_map),
  221. .enable_rotary0 = 1,
  222. .rotary0_up_key = KEY_UP,
  223. .rotary0_down_key = KEY_DOWN,
  224. .debounce_interval = 30,
  225. };
  226. static void __init littleton_init_keypad(void)
  227. {
  228. pxa_set_keypad_info(&littleton_keypad_info);
  229. }
  230. #else
  231. static inline void littleton_init_keypad(void) {}
  232. #endif
  233. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  234. static struct mtd_partition littleton_nand_partitions[] = {
  235. [0] = {
  236. .name = "Bootloader",
  237. .offset = 0,
  238. .size = 0x060000,
  239. .mask_flags = MTD_WRITEABLE, /* force read-only */
  240. },
  241. [1] = {
  242. .name = "Kernel",
  243. .offset = 0x060000,
  244. .size = 0x200000,
  245. .mask_flags = MTD_WRITEABLE, /* force read-only */
  246. },
  247. [2] = {
  248. .name = "Filesystem",
  249. .offset = 0x0260000,
  250. .size = 0x3000000, /* 48M - rootfs */
  251. },
  252. [3] = {
  253. .name = "MassStorage",
  254. .offset = 0x3260000,
  255. .size = 0x3d40000,
  256. },
  257. [4] = {
  258. .name = "BBT",
  259. .offset = 0x6FA0000,
  260. .size = 0x80000,
  261. .mask_flags = MTD_WRITEABLE, /* force read-only */
  262. },
  263. /* NOTE: we reserve some blocks at the end of the NAND flash for
  264. * bad block management, and the max number of relocation blocks
  265. * differs on different platforms. Please take care with it when
  266. * defining the partition table.
  267. */
  268. };
  269. static struct pxa3xx_nand_platform_data littleton_nand_info = {
  270. .enable_arbiter = 1,
  271. .parts = littleton_nand_partitions,
  272. .nr_parts = ARRAY_SIZE(littleton_nand_partitions),
  273. };
  274. static void __init littleton_init_nand(void)
  275. {
  276. pxa3xx_set_nand_info(&littleton_nand_info);
  277. }
  278. #else
  279. static inline void littleton_init_nand(void) {}
  280. #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
  281. static void __init littleton_init(void)
  282. {
  283. /* initialize MFP configurations */
  284. pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
  285. /*
  286. * Note: we depend bootloader set the correct
  287. * value to MSC register for SMC91x.
  288. */
  289. platform_device_register(&smc91x_device);
  290. littleton_init_spi();
  291. littleton_init_lcd();
  292. littleton_init_keypad();
  293. littleton_init_nand();
  294. }
  295. MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
  296. .phys_io = 0x40000000,
  297. .boot_params = 0xa0000100,
  298. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  299. .map_io = pxa_map_io,
  300. .init_irq = pxa3xx_init_irq,
  301. .timer = &pxa_timer,
  302. .init_machine = littleton_init,
  303. MACHINE_END