board-perseus2.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * linux/arch/arm/mach-omap1/board-perseus2.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * Original OMAP730 support by Jean Pihet <j-pihet@ti.com>
  7. * Updated for 2.6 by Kevin Hilman <kjh@hilman.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/delay.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/input.h>
  21. #include <mach/hardware.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/flash.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/tc.h>
  27. #include <mach/gpio.h>
  28. #include <mach/mux.h>
  29. #include <mach/fpga.h>
  30. #include <mach/nand.h>
  31. #include <mach/keypad.h>
  32. #include <mach/common.h>
  33. #include <mach/board.h>
  34. static int p2_keymap[] = {
  35. KEY(0,0,KEY_UP),
  36. KEY(0,1,KEY_RIGHT),
  37. KEY(0,2,KEY_LEFT),
  38. KEY(0,3,KEY_DOWN),
  39. KEY(0,4,KEY_ENTER),
  40. KEY(1,0,KEY_F10),
  41. KEY(1,1,KEY_SEND),
  42. KEY(1,2,KEY_END),
  43. KEY(1,3,KEY_VOLUMEDOWN),
  44. KEY(1,4,KEY_VOLUMEUP),
  45. KEY(1,5,KEY_RECORD),
  46. KEY(2,0,KEY_F9),
  47. KEY(2,1,KEY_3),
  48. KEY(2,2,KEY_6),
  49. KEY(2,3,KEY_9),
  50. KEY(2,4,KEY_KPDOT),
  51. KEY(3,0,KEY_BACK),
  52. KEY(3,1,KEY_2),
  53. KEY(3,2,KEY_5),
  54. KEY(3,3,KEY_8),
  55. KEY(3,4,KEY_0),
  56. KEY(3,5,KEY_KPSLASH),
  57. KEY(4,0,KEY_HOME),
  58. KEY(4,1,KEY_1),
  59. KEY(4,2,KEY_4),
  60. KEY(4,3,KEY_7),
  61. KEY(4,4,KEY_KPASTERISK),
  62. KEY(4,5,KEY_POWER),
  63. 0
  64. };
  65. static struct resource smc91x_resources[] = {
  66. [0] = {
  67. .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
  68. .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .start = INT_730_MPU_EXT_NIRQ,
  73. .end = 0,
  74. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  75. },
  76. };
  77. static struct mtd_partition nor_partitions[] = {
  78. /* bootloader (U-Boot, etc) in first sector */
  79. {
  80. .name = "bootloader",
  81. .offset = 0,
  82. .size = SZ_128K,
  83. .mask_flags = MTD_WRITEABLE, /* force read-only */
  84. },
  85. /* bootloader params in the next sector */
  86. {
  87. .name = "params",
  88. .offset = MTDPART_OFS_APPEND,
  89. .size = SZ_128K,
  90. .mask_flags = 0,
  91. },
  92. /* kernel */
  93. {
  94. .name = "kernel",
  95. .offset = MTDPART_OFS_APPEND,
  96. .size = SZ_2M,
  97. .mask_flags = 0
  98. },
  99. /* rest of flash is a file system */
  100. {
  101. .name = "rootfs",
  102. .offset = MTDPART_OFS_APPEND,
  103. .size = MTDPART_SIZ_FULL,
  104. .mask_flags = 0
  105. },
  106. };
  107. static struct flash_platform_data nor_data = {
  108. .map_name = "cfi_probe",
  109. .width = 2,
  110. .parts = nor_partitions,
  111. .nr_parts = ARRAY_SIZE(nor_partitions),
  112. };
  113. static struct resource nor_resource = {
  114. .start = OMAP_CS0_PHYS,
  115. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  116. .flags = IORESOURCE_MEM,
  117. };
  118. static struct platform_device nor_device = {
  119. .name = "omapflash",
  120. .id = 0,
  121. .dev = {
  122. .platform_data = &nor_data,
  123. },
  124. .num_resources = 1,
  125. .resource = &nor_resource,
  126. };
  127. static struct omap_nand_platform_data nand_data = {
  128. .options = NAND_SAMSUNG_LP_OPTIONS,
  129. };
  130. static struct resource nand_resource = {
  131. .start = OMAP_CS3_PHYS,
  132. .end = OMAP_CS3_PHYS + SZ_4K - 1,
  133. .flags = IORESOURCE_MEM,
  134. };
  135. static struct platform_device nand_device = {
  136. .name = "omapnand",
  137. .id = 0,
  138. .dev = {
  139. .platform_data = &nand_data,
  140. },
  141. .num_resources = 1,
  142. .resource = &nand_resource,
  143. };
  144. static struct platform_device smc91x_device = {
  145. .name = "smc91x",
  146. .id = 0,
  147. .num_resources = ARRAY_SIZE(smc91x_resources),
  148. .resource = smc91x_resources,
  149. };
  150. static struct resource kp_resources[] = {
  151. [0] = {
  152. .start = INT_730_MPUIO_KEYPAD,
  153. .end = INT_730_MPUIO_KEYPAD,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. };
  157. static struct omap_kp_platform_data kp_data = {
  158. .rows = 8,
  159. .cols = 8,
  160. .keymap = p2_keymap,
  161. .keymapsize = ARRAY_SIZE(p2_keymap),
  162. .delay = 4,
  163. .dbounce = 1,
  164. };
  165. static struct platform_device kp_device = {
  166. .name = "omap-keypad",
  167. .id = -1,
  168. .dev = {
  169. .platform_data = &kp_data,
  170. },
  171. .num_resources = ARRAY_SIZE(kp_resources),
  172. .resource = kp_resources,
  173. };
  174. static struct platform_device lcd_device = {
  175. .name = "lcd_p2",
  176. .id = -1,
  177. };
  178. static struct platform_device *devices[] __initdata = {
  179. &nor_device,
  180. &nand_device,
  181. &smc91x_device,
  182. &kp_device,
  183. &lcd_device,
  184. };
  185. #define P2_NAND_RB_GPIO_PIN 62
  186. static int nand_dev_ready(struct omap_nand_platform_data *data)
  187. {
  188. return gpio_get_value(P2_NAND_RB_GPIO_PIN);
  189. }
  190. static struct omap_uart_config perseus2_uart_config __initdata = {
  191. .enabled_uarts = ((1 << 0) | (1 << 1)),
  192. };
  193. static struct omap_lcd_config perseus2_lcd_config __initdata = {
  194. .ctrl_name = "internal",
  195. };
  196. static struct omap_board_config_kernel perseus2_config[] __initdata = {
  197. { OMAP_TAG_UART, &perseus2_uart_config },
  198. { OMAP_TAG_LCD, &perseus2_lcd_config },
  199. };
  200. static void __init omap_perseus2_init(void)
  201. {
  202. if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
  203. BUG();
  204. nand_data.dev_ready = nand_dev_ready;
  205. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  206. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  207. platform_add_devices(devices, ARRAY_SIZE(devices));
  208. omap_board_config = perseus2_config;
  209. omap_board_config_size = ARRAY_SIZE(perseus2_config);
  210. omap_serial_init();
  211. omap_register_i2c_bus(1, 100, NULL, 0);
  212. }
  213. static void __init perseus2_init_smc91x(void)
  214. {
  215. fpga_write(1, H2P2_DBG_FPGA_LAN_RESET);
  216. mdelay(50);
  217. fpga_write(fpga_read(H2P2_DBG_FPGA_LAN_RESET) & ~1,
  218. H2P2_DBG_FPGA_LAN_RESET);
  219. mdelay(50);
  220. }
  221. static void __init omap_perseus2_init_irq(void)
  222. {
  223. omap1_init_common_hw();
  224. omap_init_irq();
  225. omap_gpio_init();
  226. perseus2_init_smc91x();
  227. }
  228. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  229. static struct map_desc omap_perseus2_io_desc[] __initdata = {
  230. {
  231. .virtual = H2P2_DBG_FPGA_BASE,
  232. .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
  233. .length = H2P2_DBG_FPGA_SIZE,
  234. .type = MT_DEVICE
  235. }
  236. };
  237. static void __init omap_perseus2_map_io(void)
  238. {
  239. omap1_map_common_io();
  240. iotable_init(omap_perseus2_io_desc,
  241. ARRAY_SIZE(omap_perseus2_io_desc));
  242. /* Early, board-dependent init */
  243. /*
  244. * Hold GSM Reset until needed
  245. */
  246. omap_writew(omap_readw(OMAP730_DSP_M_CTL) & ~1, OMAP730_DSP_M_CTL);
  247. /*
  248. * UARTs -> done automagically by 8250 driver
  249. */
  250. /*
  251. * CSx timings, GPIO Mux ... setup
  252. */
  253. /* Flash: CS0 timings setup */
  254. omap_writel(0x0000fff3, OMAP730_FLASH_CFG_0);
  255. omap_writel(0x00000088, OMAP730_FLASH_ACFG_0);
  256. /*
  257. * Ethernet support through the debug board
  258. * CS1 timings setup
  259. */
  260. omap_writel(0x0000fff3, OMAP730_FLASH_CFG_1);
  261. omap_writel(0x00000000, OMAP730_FLASH_ACFG_1);
  262. /*
  263. * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
  264. * It is used as the Ethernet controller interrupt
  265. */
  266. omap_writel(omap_readl(OMAP730_IO_CONF_9) & 0x1FFFFFFF, OMAP730_IO_CONF_9);
  267. }
  268. MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
  269. /* Maintainer: Kevin Hilman <kjh@hilman.org> */
  270. .phys_io = 0xfff00000,
  271. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  272. .boot_params = 0x10000100,
  273. .map_io = omap_perseus2_map_io,
  274. .init_irq = omap_perseus2_init_irq,
  275. .init_machine = omap_perseus2_init,
  276. .timer = &omap_timer,
  277. MACHINE_END