board-fsample.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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/gpio.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/nand.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <linux/input.h>
  23. #include <linux/smc91x.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 <plat/mux.h>
  29. #include <plat/flash.h>
  30. #include <plat/fpga.h>
  31. #include <plat/keypad.h>
  32. #include <plat/board.h>
  33. #include <mach/hardware.h>
  34. #include "iomap.h"
  35. #include "common.h"
  36. /* fsample is pretty close to p2-sample */
  37. #define fsample_cpld_read(reg) __raw_readb(reg)
  38. #define fsample_cpld_write(val, reg) __raw_writeb(val, reg)
  39. #define FSAMPLE_CPLD_BASE 0xE8100000
  40. #define FSAMPLE_CPLD_SIZE SZ_4K
  41. #define FSAMPLE_CPLD_START 0x05080000
  42. #define FSAMPLE_CPLD_REG_A (FSAMPLE_CPLD_BASE + 0x00)
  43. #define FSAMPLE_CPLD_SWITCH (FSAMPLE_CPLD_BASE + 0x02)
  44. #define FSAMPLE_CPLD_UART (FSAMPLE_CPLD_BASE + 0x02)
  45. #define FSAMPLE_CPLD_REG_B (FSAMPLE_CPLD_BASE + 0x04)
  46. #define FSAMPLE_CPLD_VERSION (FSAMPLE_CPLD_BASE + 0x06)
  47. #define FSAMPLE_CPLD_SET_CLR (FSAMPLE_CPLD_BASE + 0x06)
  48. #define FSAMPLE_CPLD_BIT_BT_RESET 0
  49. #define FSAMPLE_CPLD_BIT_LCD_RESET 1
  50. #define FSAMPLE_CPLD_BIT_CAM_PWDN 2
  51. #define FSAMPLE_CPLD_BIT_CHARGER_ENABLE 3
  52. #define FSAMPLE_CPLD_BIT_SD_MMC_EN 4
  53. #define FSAMPLE_CPLD_BIT_aGPS_PWREN 5
  54. #define FSAMPLE_CPLD_BIT_BACKLIGHT 6
  55. #define FSAMPLE_CPLD_BIT_aGPS_EN_RESET 7
  56. #define FSAMPLE_CPLD_BIT_aGPS_SLEEPx_N 8
  57. #define FSAMPLE_CPLD_BIT_OTG_RESET 9
  58. #define fsample_cpld_set(bit) \
  59. fsample_cpld_write((((bit) & 15) << 4) | 0x0f, FSAMPLE_CPLD_SET_CLR)
  60. #define fsample_cpld_clear(bit) \
  61. fsample_cpld_write(0xf0 | ((bit) & 15), FSAMPLE_CPLD_SET_CLR)
  62. static const unsigned int fsample_keymap[] = {
  63. KEY(0, 0, KEY_UP),
  64. KEY(1, 0, KEY_RIGHT),
  65. KEY(2, 0, KEY_LEFT),
  66. KEY(3, 0, KEY_DOWN),
  67. KEY(4, 0, KEY_ENTER),
  68. KEY(0, 1, KEY_F10),
  69. KEY(1, 1, KEY_SEND),
  70. KEY(2, 1, KEY_END),
  71. KEY(3, 1, KEY_VOLUMEDOWN),
  72. KEY(4, 1, KEY_VOLUMEUP),
  73. KEY(5, 1, KEY_RECORD),
  74. KEY(0, 2, KEY_F9),
  75. KEY(1, 2, KEY_3),
  76. KEY(2, 2, KEY_6),
  77. KEY(3, 2, KEY_9),
  78. KEY(4, 2, KEY_KPDOT),
  79. KEY(0, 3, KEY_BACK),
  80. KEY(1, 3, KEY_2),
  81. KEY(2, 3, KEY_5),
  82. KEY(3, 3, KEY_8),
  83. KEY(4, 3, KEY_0),
  84. KEY(5, 3, KEY_KPSLASH),
  85. KEY(0, 4, KEY_HOME),
  86. KEY(1, 4, KEY_1),
  87. KEY(2, 4, KEY_4),
  88. KEY(3, 4, KEY_7),
  89. KEY(4, 4, KEY_KPASTERISK),
  90. KEY(5, 4, KEY_POWER),
  91. };
  92. static struct smc91x_platdata smc91x_info = {
  93. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  94. .leda = RPC_LED_100_10,
  95. .ledb = RPC_LED_TX_RX,
  96. };
  97. static struct resource smc91x_resources[] = {
  98. [0] = {
  99. .start = H2P2_DBG_FPGA_ETHR_START, /* Physical */
  100. .end = H2P2_DBG_FPGA_ETHR_START + 0xf,
  101. .flags = IORESOURCE_MEM,
  102. },
  103. [1] = {
  104. .start = INT_7XX_MPU_EXT_NIRQ,
  105. .end = 0,
  106. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  107. },
  108. };
  109. static void __init fsample_init_smc91x(void)
  110. {
  111. fpga_write(1, H2P2_DBG_FPGA_LAN_RESET);
  112. mdelay(50);
  113. fpga_write(fpga_read(H2P2_DBG_FPGA_LAN_RESET) & ~1,
  114. H2P2_DBG_FPGA_LAN_RESET);
  115. mdelay(50);
  116. }
  117. static struct mtd_partition nor_partitions[] = {
  118. /* bootloader (U-Boot, etc) in first sector */
  119. {
  120. .name = "bootloader",
  121. .offset = 0,
  122. .size = SZ_128K,
  123. .mask_flags = MTD_WRITEABLE, /* force read-only */
  124. },
  125. /* bootloader params in the next sector */
  126. {
  127. .name = "params",
  128. .offset = MTDPART_OFS_APPEND,
  129. .size = SZ_128K,
  130. .mask_flags = 0,
  131. },
  132. /* kernel */
  133. {
  134. .name = "kernel",
  135. .offset = MTDPART_OFS_APPEND,
  136. .size = SZ_2M,
  137. .mask_flags = 0
  138. },
  139. /* rest of flash is a file system */
  140. {
  141. .name = "rootfs",
  142. .offset = MTDPART_OFS_APPEND,
  143. .size = MTDPART_SIZ_FULL,
  144. .mask_flags = 0
  145. },
  146. };
  147. static struct physmap_flash_data nor_data = {
  148. .width = 2,
  149. .set_vpp = omap1_set_vpp,
  150. .parts = nor_partitions,
  151. .nr_parts = ARRAY_SIZE(nor_partitions),
  152. };
  153. static struct resource nor_resource = {
  154. .start = OMAP_CS0_PHYS,
  155. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  156. .flags = IORESOURCE_MEM,
  157. };
  158. static struct platform_device nor_device = {
  159. .name = "physmap-flash",
  160. .id = 0,
  161. .dev = {
  162. .platform_data = &nor_data,
  163. },
  164. .num_resources = 1,
  165. .resource = &nor_resource,
  166. };
  167. static void nand_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
  168. {
  169. struct nand_chip *this = mtd->priv;
  170. unsigned long mask;
  171. if (cmd == NAND_CMD_NONE)
  172. return;
  173. mask = (ctrl & NAND_CLE) ? 0x02 : 0;
  174. if (ctrl & NAND_ALE)
  175. mask |= 0x04;
  176. writeb(cmd, (unsigned long)this->IO_ADDR_W | mask);
  177. }
  178. #define FSAMPLE_NAND_RB_GPIO_PIN 62
  179. static int nand_dev_ready(struct mtd_info *mtd)
  180. {
  181. return gpio_get_value(FSAMPLE_NAND_RB_GPIO_PIN);
  182. }
  183. static const char *part_probes[] = { "cmdlinepart", NULL };
  184. static struct platform_nand_data nand_data = {
  185. .chip = {
  186. .nr_chips = 1,
  187. .chip_offset = 0,
  188. .options = NAND_SAMSUNG_LP_OPTIONS,
  189. .part_probe_types = part_probes,
  190. },
  191. .ctrl = {
  192. .cmd_ctrl = nand_cmd_ctl,
  193. .dev_ready = nand_dev_ready,
  194. },
  195. };
  196. static struct resource nand_resource = {
  197. .start = OMAP_CS3_PHYS,
  198. .end = OMAP_CS3_PHYS + SZ_4K - 1,
  199. .flags = IORESOURCE_MEM,
  200. };
  201. static struct platform_device nand_device = {
  202. .name = "gen_nand",
  203. .id = 0,
  204. .dev = {
  205. .platform_data = &nand_data,
  206. },
  207. .num_resources = 1,
  208. .resource = &nand_resource,
  209. };
  210. static struct platform_device smc91x_device = {
  211. .name = "smc91x",
  212. .id = 0,
  213. .dev = {
  214. .platform_data = &smc91x_info,
  215. },
  216. .num_resources = ARRAY_SIZE(smc91x_resources),
  217. .resource = smc91x_resources,
  218. };
  219. static struct resource kp_resources[] = {
  220. [0] = {
  221. .start = INT_7XX_MPUIO_KEYPAD,
  222. .end = INT_7XX_MPUIO_KEYPAD,
  223. .flags = IORESOURCE_IRQ,
  224. },
  225. };
  226. static const struct matrix_keymap_data fsample_keymap_data = {
  227. .keymap = fsample_keymap,
  228. .keymap_size = ARRAY_SIZE(fsample_keymap),
  229. };
  230. static struct omap_kp_platform_data kp_data = {
  231. .rows = 8,
  232. .cols = 8,
  233. .keymap_data = &fsample_keymap_data,
  234. .delay = 4,
  235. };
  236. static struct platform_device kp_device = {
  237. .name = "omap-keypad",
  238. .id = -1,
  239. .dev = {
  240. .platform_data = &kp_data,
  241. },
  242. .num_resources = ARRAY_SIZE(kp_resources),
  243. .resource = kp_resources,
  244. };
  245. static struct platform_device lcd_device = {
  246. .name = "lcd_p2",
  247. .id = -1,
  248. };
  249. static struct platform_device *devices[] __initdata = {
  250. &nor_device,
  251. &nand_device,
  252. &smc91x_device,
  253. &kp_device,
  254. &lcd_device,
  255. };
  256. static struct omap_lcd_config fsample_lcd_config = {
  257. .ctrl_name = "internal",
  258. };
  259. static struct omap_board_config_kernel fsample_config[] __initdata = {
  260. { OMAP_TAG_LCD, &fsample_lcd_config },
  261. };
  262. static void __init omap_fsample_init(void)
  263. {
  264. /* Early, board-dependent init */
  265. /*
  266. * Hold GSM Reset until needed
  267. */
  268. omap_writew(omap_readw(OMAP7XX_DSP_M_CTL) & ~1, OMAP7XX_DSP_M_CTL);
  269. /*
  270. * UARTs -> done automagically by 8250 driver
  271. */
  272. /*
  273. * CSx timings, GPIO Mux ... setup
  274. */
  275. /* Flash: CS0 timings setup */
  276. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_0);
  277. omap_writel(0x00000088, OMAP7XX_FLASH_ACFG_0);
  278. /*
  279. * Ethernet support through the debug board
  280. * CS1 timings setup
  281. */
  282. omap_writel(0x0000fff3, OMAP7XX_FLASH_CFG_1);
  283. omap_writel(0x00000000, OMAP7XX_FLASH_ACFG_1);
  284. /*
  285. * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
  286. * It is used as the Ethernet controller interrupt
  287. */
  288. omap_writel(omap_readl(OMAP7XX_IO_CONF_9) & 0x1FFFFFFF,
  289. OMAP7XX_IO_CONF_9);
  290. fsample_init_smc91x();
  291. if (gpio_request(FSAMPLE_NAND_RB_GPIO_PIN, "NAND ready") < 0)
  292. BUG();
  293. gpio_direction_input(FSAMPLE_NAND_RB_GPIO_PIN);
  294. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  295. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  296. /* Mux pins for keypad */
  297. omap_cfg_reg(E2_7XX_KBR0);
  298. omap_cfg_reg(J7_7XX_KBR1);
  299. omap_cfg_reg(E1_7XX_KBR2);
  300. omap_cfg_reg(F3_7XX_KBR3);
  301. omap_cfg_reg(D2_7XX_KBR4);
  302. omap_cfg_reg(C2_7XX_KBC0);
  303. omap_cfg_reg(D3_7XX_KBC1);
  304. omap_cfg_reg(E4_7XX_KBC2);
  305. omap_cfg_reg(F4_7XX_KBC3);
  306. omap_cfg_reg(E3_7XX_KBC4);
  307. platform_add_devices(devices, ARRAY_SIZE(devices));
  308. omap_board_config = fsample_config;
  309. omap_board_config_size = ARRAY_SIZE(fsample_config);
  310. omap_serial_init();
  311. omap_register_i2c_bus(1, 100, NULL, 0);
  312. }
  313. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  314. static struct map_desc omap_fsample_io_desc[] __initdata = {
  315. {
  316. .virtual = H2P2_DBG_FPGA_BASE,
  317. .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
  318. .length = H2P2_DBG_FPGA_SIZE,
  319. .type = MT_DEVICE
  320. },
  321. {
  322. .virtual = FSAMPLE_CPLD_BASE,
  323. .pfn = __phys_to_pfn(FSAMPLE_CPLD_START),
  324. .length = FSAMPLE_CPLD_SIZE,
  325. .type = MT_DEVICE
  326. }
  327. };
  328. static void __init omap_fsample_map_io(void)
  329. {
  330. omap15xx_map_io();
  331. iotable_init(omap_fsample_io_desc,
  332. ARRAY_SIZE(omap_fsample_io_desc));
  333. }
  334. MACHINE_START(OMAP_FSAMPLE, "OMAP730 F-Sample")
  335. /* Maintainer: Brian Swetland <swetland@google.com> */
  336. .atag_offset = 0x100,
  337. .map_io = omap_fsample_map_io,
  338. .init_early = omap1_init_early,
  339. .reserve = omap_reserve,
  340. .init_irq = omap1_init_irq,
  341. .init_machine = omap_fsample_init,
  342. .timer = &omap1_timer,
  343. .restart = omap1_restart,
  344. MACHINE_END