board-perseus2.c 6.9 KB

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