board-fsample.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * linux/arch/arm/mach-omap1/board-fsample.c
  3. *
  4. * Modified from board-perseus2.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. #include <asm/arch/board-fsample.h>
  34. static int fsample_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_CENTER),
  40. KEY(0,5,KEY_0_5),
  41. KEY(1,0,KEY_SOFT2),
  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_SOFT1),
  48. KEY(2,1,KEY_3),
  49. KEY(2,2,KEY_6),
  50. KEY(2,3,KEY_9),
  51. KEY(2,4,KEY_SHARP),
  52. KEY(2,5,KEY_2_5),
  53. KEY(3,0,KEY_BACK),
  54. KEY(3,1,KEY_2),
  55. KEY(3,2,KEY_5),
  56. KEY(3,3,KEY_8),
  57. KEY(3,4,KEY_0),
  58. KEY(3,5,KEY_HEADSETHOOK),
  59. KEY(4,0,KEY_HOME),
  60. KEY(4,1,KEY_1),
  61. KEY(4,2,KEY_4),
  62. KEY(4,3,KEY_7),
  63. KEY(4,4,KEY_STAR),
  64. KEY(4,5,KEY_POWER),
  65. 0
  66. };
  67. static struct resource smc91x_resources[] = {
  68. [0] = {
  69. .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
  70. .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. [1] = {
  74. .start = INT_730_MPU_EXT_NIRQ,
  75. .end = 0,
  76. .flags = IORESOURCE_IRQ,
  77. },
  78. };
  79. static struct mtd_partition nor_partitions[] = {
  80. /* bootloader (U-Boot, etc) in first sector */
  81. {
  82. .name = "bootloader",
  83. .offset = 0,
  84. .size = SZ_128K,
  85. .mask_flags = MTD_WRITEABLE, /* force read-only */
  86. },
  87. /* bootloader params in the next sector */
  88. {
  89. .name = "params",
  90. .offset = MTDPART_OFS_APPEND,
  91. .size = SZ_128K,
  92. .mask_flags = 0,
  93. },
  94. /* kernel */
  95. {
  96. .name = "kernel",
  97. .offset = MTDPART_OFS_APPEND,
  98. .size = SZ_2M,
  99. .mask_flags = 0
  100. },
  101. /* rest of flash is a file system */
  102. {
  103. .name = "rootfs",
  104. .offset = MTDPART_OFS_APPEND,
  105. .size = MTDPART_SIZ_FULL,
  106. .mask_flags = 0
  107. },
  108. };
  109. static struct flash_platform_data nor_data = {
  110. .map_name = "cfi_probe",
  111. .width = 2,
  112. .parts = nor_partitions,
  113. .nr_parts = ARRAY_SIZE(nor_partitions),
  114. };
  115. static struct resource nor_resource = {
  116. .start = OMAP_CS0_PHYS,
  117. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  118. .flags = IORESOURCE_MEM,
  119. };
  120. static struct platform_device nor_device = {
  121. .name = "omapflash",
  122. .id = 0,
  123. .dev = {
  124. .platform_data = &nor_data,
  125. },
  126. .num_resources = 1,
  127. .resource = &nor_resource,
  128. };
  129. static struct nand_platform_data nand_data = {
  130. .options = NAND_SAMSUNG_LP_OPTIONS,
  131. };
  132. static struct resource nand_resource = {
  133. .start = OMAP_CS3_PHYS,
  134. .end = OMAP_CS3_PHYS + SZ_4K - 1,
  135. .flags = IORESOURCE_MEM,
  136. };
  137. static struct platform_device nand_device = {
  138. .name = "omapnand",
  139. .id = 0,
  140. .dev = {
  141. .platform_data = &nand_data,
  142. },
  143. .num_resources = 1,
  144. .resource = &nand_resource,
  145. };
  146. static struct platform_device smc91x_device = {
  147. .name = "smc91x",
  148. .id = 0,
  149. .num_resources = ARRAY_SIZE(smc91x_resources),
  150. .resource = smc91x_resources,
  151. };
  152. static struct resource kp_resources[] = {
  153. [0] = {
  154. .start = INT_730_MPUIO_KEYPAD,
  155. .end = INT_730_MPUIO_KEYPAD,
  156. .flags = IORESOURCE_IRQ,
  157. },
  158. };
  159. static struct omap_kp_platform_data kp_data = {
  160. .rows = 8,
  161. .cols = 8,
  162. .keymap = fsample_keymap,
  163. .keymapsize = ARRAY_SIZE(fsample_keymap),
  164. .delay = 4,
  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 fsample_uart_config __initdata = {
  192. .enabled_uarts = ((1 << 0) | (1 << 1)),
  193. };
  194. static struct omap_lcd_config fsample_lcd_config __initdata = {
  195. .ctrl_name = "internal",
  196. };
  197. static struct omap_board_config_kernel fsample_config[] = {
  198. { OMAP_TAG_UART, &fsample_uart_config },
  199. { OMAP_TAG_LCD, &fsample_lcd_config },
  200. };
  201. static void __init omap_fsample_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 = fsample_config;
  209. omap_board_config_size = ARRAY_SIZE(fsample_config);
  210. omap_serial_init();
  211. }
  212. static void __init fsample_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_fsample_init_irq(void)
  221. {
  222. omap1_init_common_hw();
  223. omap_init_irq();
  224. omap_gpio_init();
  225. fsample_init_smc91x();
  226. }
  227. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  228. static struct map_desc omap_fsample_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. .virtual = FSAMPLE_CPLD_BASE,
  237. .pfn = __phys_to_pfn(FSAMPLE_CPLD_START),
  238. .length = FSAMPLE_CPLD_SIZE,
  239. .type = MT_DEVICE
  240. }
  241. };
  242. static void __init omap_fsample_map_io(void)
  243. {
  244. omap1_map_common_io();
  245. iotable_init(omap_fsample_io_desc,
  246. ARRAY_SIZE(omap_fsample_io_desc));
  247. /* Early, board-dependent init */
  248. /*
  249. * Hold GSM Reset until needed
  250. */
  251. omap_writew(omap_readw(OMAP730_DSP_M_CTL) & ~1, OMAP730_DSP_M_CTL);
  252. /*
  253. * UARTs -> done automagically by 8250 driver
  254. */
  255. /*
  256. * CSx timings, GPIO Mux ... setup
  257. */
  258. /* Flash: CS0 timings setup */
  259. omap_writel(0x0000fff3, OMAP730_FLASH_CFG_0);
  260. omap_writel(0x00000088, OMAP730_FLASH_ACFG_0);
  261. /*
  262. * Ethernet support through the debug board
  263. * CS1 timings setup
  264. */
  265. omap_writel(0x0000fff3, OMAP730_FLASH_CFG_1);
  266. omap_writel(0x00000000, OMAP730_FLASH_ACFG_1);
  267. /*
  268. * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
  269. * It is used as the Ethernet controller interrupt
  270. */
  271. omap_writel(omap_readl(OMAP730_IO_CONF_9) & 0x1FFFFFFF, OMAP730_IO_CONF_9);
  272. }
  273. MACHINE_START(OMAP_FSAMPLE, "OMAP730 F-Sample")
  274. /* Maintainer: Brian Swetland <swetland@google.com> */
  275. .phys_io = 0xfff00000,
  276. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  277. .boot_params = 0x10000100,
  278. .map_io = omap_fsample_map_io,
  279. .init_irq = omap_fsample_init_irq,
  280. .init_machine = omap_fsample_init,
  281. .timer = &omap_timer,
  282. MACHINE_END