board-perseus2.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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/mtd/physmap.h>
  21. #include <linux/input.h>
  22. #include <linux/smc91x.h>
  23. #include <mach/hardware.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/mach/arch.h>
  26. #include <asm/mach/map.h>
  27. #include <plat/tc.h>
  28. #include <mach/gpio.h>
  29. #include <plat/mux.h>
  30. #include <plat/fpga.h>
  31. #include <plat/flash.h>
  32. #include <plat/keypad.h>
  33. #include <plat/common.h>
  34. #include <plat/board.h>
  35. static int p2_keymap[] = {
  36. KEY(0,0,KEY_UP),
  37. KEY(0,1,KEY_RIGHT),
  38. KEY(0,2,KEY_LEFT),
  39. KEY(0,3,KEY_DOWN),
  40. KEY(0,4,KEY_ENTER),
  41. KEY(1,0,KEY_F10),
  42. KEY(1,1,KEY_SEND),
  43. KEY(1,2,KEY_END),
  44. KEY(1,3,KEY_VOLUMEDOWN),
  45. KEY(1,4,KEY_VOLUMEUP),
  46. KEY(1,5,KEY_RECORD),
  47. KEY(2,0,KEY_F9),
  48. KEY(2,1,KEY_3),
  49. KEY(2,2,KEY_6),
  50. KEY(2,3,KEY_9),
  51. KEY(2,4,KEY_KPDOT),
  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_KPSLASH),
  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_KPASTERISK),
  63. KEY(4,5,KEY_POWER),
  64. 0
  65. };
  66. static struct smc91x_platdata smc91x_info = {
  67. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  68. .leda = RPC_LED_100_10,
  69. .ledb = RPC_LED_TX_RX,
  70. };
  71. static struct resource smc91x_resources[] = {
  72. [0] = {
  73. .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
  74. .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
  75. .flags = IORESOURCE_MEM,
  76. },
  77. [1] = {
  78. .start = INT_7XX_MPU_EXT_NIRQ,
  79. .end = 0,
  80. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  81. },
  82. };
  83. static struct mtd_partition nor_partitions[] = {
  84. /* bootloader (U-Boot, etc) in first sector */
  85. {
  86. .name = "bootloader",
  87. .offset = 0,
  88. .size = SZ_128K,
  89. .mask_flags = MTD_WRITEABLE, /* force read-only */
  90. },
  91. /* bootloader params in the next sector */
  92. {
  93. .name = "params",
  94. .offset = MTDPART_OFS_APPEND,
  95. .size = SZ_128K,
  96. .mask_flags = 0,
  97. },
  98. /* kernel */
  99. {
  100. .name = "kernel",
  101. .offset = MTDPART_OFS_APPEND,
  102. .size = SZ_2M,
  103. .mask_flags = 0
  104. },
  105. /* rest of flash is a file system */
  106. {
  107. .name = "rootfs",
  108. .offset = MTDPART_OFS_APPEND,
  109. .size = MTDPART_SIZ_FULL,
  110. .mask_flags = 0
  111. },
  112. };
  113. static struct physmap_flash_data nor_data = {
  114. .width = 2,
  115. .set_vpp = omap1_set_vpp,
  116. .parts = nor_partitions,
  117. .nr_parts = ARRAY_SIZE(nor_partitions),
  118. };
  119. static struct resource nor_resource = {
  120. .start = OMAP_CS0_PHYS,
  121. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  122. .flags = IORESOURCE_MEM,
  123. };
  124. static struct platform_device nor_device = {
  125. .name = "physmap-flash",
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &nor_data,
  129. },
  130. .num_resources = 1,
  131. .resource = &nor_resource,
  132. };
  133. static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  134. {
  135. struct nand_chip *this = mtd->priv;
  136. unsigned long mask;
  137. if (cmd == NAND_CMD_NONE)
  138. return;
  139. mask = (ctrl & NAND_CLE) ? 0x02 : 0;
  140. if (ctrl & NAND_ALE)
  141. mask |= 0x04;
  142. writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
  143. }
  144. #define P2_NAND_RB_GPIO_PIN 62
  145. static int nand_dev_ready(struct mtd_info *mtd)
  146. {
  147. return gpio_get_value(P2_NAND_RB_GPIO_PIN);
  148. }
  149. static const char *part_probes[] = { "cmdlinepart", NULL };
  150. static struct platform_nand_data nand_data = {
  151. .chip = {
  152. .nr_chips = 1,
  153. .chip_offset = 0,
  154. .options = NAND_SAMSUNG_LP_OPTIONS,
  155. .part_probe_types = part_probes,
  156. },
  157. .ctrl = {
  158. .cmd_ctrl = nand_cmd_ctl,
  159. .dev_ready = nand_dev_ready,
  160. },
  161. };
  162. static struct resource nand_resource = {
  163. .start = OMAP_CS3_PHYS,
  164. .end = OMAP_CS3_PHYS + SZ_4K - 1,
  165. .flags = IORESOURCE_MEM,
  166. };
  167. static struct platform_device nand_device = {
  168. .name = "gen_nand",
  169. .id = 0,
  170. .dev = {
  171. .platform_data = &nand_data,
  172. },
  173. .num_resources = 1,
  174. .resource = &nand_resource,
  175. };
  176. static struct platform_device smc91x_device = {
  177. .name = "smc91x",
  178. .id = 0,
  179. .dev = {
  180. .platform_data = &smc91x_info,
  181. },
  182. .num_resources = ARRAY_SIZE(smc91x_resources),
  183. .resource = smc91x_resources,
  184. };
  185. static struct resource kp_resources[] = {
  186. [0] = {
  187. .start = INT_7XX_MPUIO_KEYPAD,
  188. .end = INT_7XX_MPUIO_KEYPAD,
  189. .flags = IORESOURCE_IRQ,
  190. },
  191. };
  192. static struct omap_kp_platform_data kp_data = {
  193. .rows = 8,
  194. .cols = 8,
  195. .keymap = p2_keymap,
  196. .keymapsize = ARRAY_SIZE(p2_keymap),
  197. .delay = 4,
  198. .dbounce = 1,
  199. };
  200. static struct platform_device kp_device = {
  201. .name = "omap-keypad",
  202. .id = -1,
  203. .dev = {
  204. .platform_data = &kp_data,
  205. },
  206. .num_resources = ARRAY_SIZE(kp_resources),
  207. .resource = kp_resources,
  208. };
  209. static struct platform_device lcd_device = {
  210. .name = "lcd_p2",
  211. .id = -1,
  212. };
  213. static struct platform_device *devices[] __initdata = {
  214. &nor_device,
  215. &nand_device,
  216. &smc91x_device,
  217. &kp_device,
  218. &lcd_device,
  219. };
  220. static struct omap_lcd_config perseus2_lcd_config __initdata = {
  221. .ctrl_name = "internal",
  222. };
  223. static struct omap_board_config_kernel perseus2_config[] __initdata = {
  224. { OMAP_TAG_LCD, &perseus2_lcd_config },
  225. };
  226. static void __init omap_perseus2_init(void)
  227. {
  228. if (gpio_request(P2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
  229. BUG();
  230. gpio_direction_input(P2_NAND_RB_GPIO_PIN);
  231. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  232. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  233. /* Mux pins for keypad */
  234. omap_cfg_reg(E2_7XX_KBR0);
  235. omap_cfg_reg(J7_7XX_KBR1);
  236. omap_cfg_reg(E1_7XX_KBR2);
  237. omap_cfg_reg(F3_7XX_KBR3);
  238. omap_cfg_reg(D2_7XX_KBR4);
  239. omap_cfg_reg(C2_7XX_KBC0);
  240. omap_cfg_reg(D3_7XX_KBC1);
  241. omap_cfg_reg(E4_7XX_KBC2);
  242. omap_cfg_reg(F4_7XX_KBC3);
  243. omap_cfg_reg(E3_7XX_KBC4);
  244. platform_add_devices(devices, ARRAY_SIZE(devices));
  245. omap_board_config = perseus2_config;
  246. omap_board_config_size = ARRAY_SIZE(perseus2_config);
  247. omap_serial_init();
  248. omap_register_i2c_bus(1, 100, NULL, 0);
  249. }
  250. static void __init perseus2_init_smc91x(void)
  251. {
  252. fpga_write(1, H2P2_DBG_FPGA_LAN_RESET);
  253. mdelay(50);
  254. fpga_write(fpga_read(H2P2_DBG_FPGA_LAN_RESET) & ~1,
  255. H2P2_DBG_FPGA_LAN_RESET);
  256. mdelay(50);
  257. }
  258. static void __init omap_perseus2_init_irq(void)
  259. {
  260. omap1_init_common_hw();
  261. omap_init_irq();
  262. omap_gpio_init();
  263. perseus2_init_smc91x();
  264. }
  265. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  266. static struct map_desc omap_perseus2_io_desc[] __initdata = {
  267. {
  268. .virtual = H2P2_DBG_FPGA_BASE,
  269. .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
  270. .length = H2P2_DBG_FPGA_SIZE,
  271. .type = MT_DEVICE
  272. }
  273. };
  274. static void __init omap_perseus2_map_io(void)
  275. {
  276. omap1_map_common_io();
  277. iotable_init(omap_perseus2_io_desc,
  278. ARRAY_SIZE(omap_perseus2_io_desc));
  279. /* Early, board-dependent init */
  280. /*
  281. * Hold GSM Reset until needed
  282. */
  283. omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
  284. /*
  285. * UARTs -> done automagically by 8250 driver
  286. */
  287. /*
  288. * CSx timings, GPIO Mux ... setup
  289. */
  290. /* Flash: CS0 timings setup */
  291. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
  292. omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
  293. /*
  294. * Ethernet support through the debug board
  295. * CS1 timings setup
  296. */
  297. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
  298. omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
  299. /*
  300. * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
  301. * It is used as the Ethernet controller interrupt
  302. */
  303. omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF, OMAP7XX_IO_CONF_9);
  304. }
  305. MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
  306. /* Maintainer: Kevin Hilman <kjh@hilman.org> */
  307. .phys_io = 0xfff00000,
  308. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  309. .boot_params = 0x10000100,
  310. .map_io = omap_perseus2_map_io,
  311. .reserve = omap_reserve,
  312. .init_irq = omap_perseus2_init_irq,
  313. .init_machine = omap_perseus2_init,
  314. .timer = &omap_timer,
  315. MACHINE_END