board-h2.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /*
  2. * linux/arch/arm/mach-omap1/board-h2.c
  3. *
  4. * Board specific inits for OMAP-1610 H2
  5. *
  6. * Copyright (C) 2001 RidgeRun, Inc.
  7. * Author: Greg Lonnon <glonnon@ridgerun.com>
  8. *
  9. * Copyright (C) 2002 MontaVista Software, Inc.
  10. *
  11. * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
  12. * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
  13. *
  14. * H2 specific changes and cleanup
  15. * Copyright (C) 2004 Nokia Corporation by Imre Deak <imre.deak@nokia.com>
  16. *
  17. * This program is free software; you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License version 2 as
  19. * published by the Free Software Foundation.
  20. */
  21. #include <linux/gpio.h>
  22. #include <linux/kernel.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/delay.h>
  25. #include <linux/i2c.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/nand.h>
  28. #include <linux/mtd/partitions.h>
  29. #include <linux/mtd/physmap.h>
  30. #include <linux/input.h>
  31. #include <linux/i2c/tps65010.h>
  32. #include <linux/smc91x.h>
  33. #include <linux/omapfb.h>
  34. #include <linux/platform_data/gpio-omap.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <plat/mux.h>
  39. #include <plat/dma.h>
  40. #include <plat/tc.h>
  41. #include <plat/irda.h>
  42. #include <plat/keypad.h>
  43. #include <plat/flash.h>
  44. #include <mach/hardware.h>
  45. #include <mach/usb.h>
  46. #include "common.h"
  47. #include "board-h2.h"
  48. /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
  49. #define OMAP1610_ETHR_START 0x04000300
  50. static const unsigned int h2_keymap[] = {
  51. KEY(0, 0, KEY_LEFT),
  52. KEY(1, 0, KEY_RIGHT),
  53. KEY(2, 0, KEY_3),
  54. KEY(3, 0, KEY_F10),
  55. KEY(4, 0, KEY_F5),
  56. KEY(5, 0, KEY_9),
  57. KEY(0, 1, KEY_DOWN),
  58. KEY(1, 1, KEY_UP),
  59. KEY(2, 1, KEY_2),
  60. KEY(3, 1, KEY_F9),
  61. KEY(4, 1, KEY_F7),
  62. KEY(5, 1, KEY_0),
  63. KEY(0, 2, KEY_ENTER),
  64. KEY(1, 2, KEY_6),
  65. KEY(2, 2, KEY_1),
  66. KEY(3, 2, KEY_F2),
  67. KEY(4, 2, KEY_F6),
  68. KEY(5, 2, KEY_HOME),
  69. KEY(0, 3, KEY_8),
  70. KEY(1, 3, KEY_5),
  71. KEY(2, 3, KEY_F12),
  72. KEY(3, 3, KEY_F3),
  73. KEY(4, 3, KEY_F8),
  74. KEY(5, 3, KEY_END),
  75. KEY(0, 4, KEY_7),
  76. KEY(1, 4, KEY_4),
  77. KEY(2, 4, KEY_F11),
  78. KEY(3, 4, KEY_F1),
  79. KEY(4, 4, KEY_F4),
  80. KEY(5, 4, KEY_ESC),
  81. KEY(0, 5, KEY_F13),
  82. KEY(1, 5, KEY_F14),
  83. KEY(2, 5, KEY_F15),
  84. KEY(3, 5, KEY_F16),
  85. KEY(4, 5, KEY_SLEEP),
  86. };
  87. static struct mtd_partition h2_nor_partitions[] = {
  88. /* bootloader (U-Boot, etc) in first sector */
  89. {
  90. .name = "bootloader",
  91. .offset = 0,
  92. .size = SZ_128K,
  93. .mask_flags = MTD_WRITEABLE, /* force read-only */
  94. },
  95. /* bootloader params in the next sector */
  96. {
  97. .name = "params",
  98. .offset = MTDPART_OFS_APPEND,
  99. .size = SZ_128K,
  100. .mask_flags = 0,
  101. },
  102. /* kernel */
  103. {
  104. .name = "kernel",
  105. .offset = MTDPART_OFS_APPEND,
  106. .size = SZ_2M,
  107. .mask_flags = 0
  108. },
  109. /* file system */
  110. {
  111. .name = "filesystem",
  112. .offset = MTDPART_OFS_APPEND,
  113. .size = MTDPART_SIZ_FULL,
  114. .mask_flags = 0
  115. }
  116. };
  117. static struct physmap_flash_data h2_nor_data = {
  118. .width = 2,
  119. .set_vpp = omap1_set_vpp,
  120. .parts = h2_nor_partitions,
  121. .nr_parts = ARRAY_SIZE(h2_nor_partitions),
  122. };
  123. static struct resource h2_nor_resource = {
  124. /* This is on CS3, wherever it's mapped */
  125. .flags = IORESOURCE_MEM,
  126. };
  127. static struct platform_device h2_nor_device = {
  128. .name = "physmap-flash",
  129. .id = 0,
  130. .dev = {
  131. .platform_data = &h2_nor_data,
  132. },
  133. .num_resources = 1,
  134. .resource = &h2_nor_resource,
  135. };
  136. static struct mtd_partition h2_nand_partitions[] = {
  137. #if 0
  138. /* REVISIT: enable these partitions if you make NAND BOOT
  139. * work on your H2 (rev C or newer); published versions of
  140. * x-load only support P2 and H3.
  141. */
  142. {
  143. .name = "xloader",
  144. .offset = 0,
  145. .size = 64 * 1024,
  146. .mask_flags = MTD_WRITEABLE, /* force read-only */
  147. },
  148. {
  149. .name = "bootloader",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = 256 * 1024,
  152. .mask_flags = MTD_WRITEABLE, /* force read-only */
  153. },
  154. {
  155. .name = "params",
  156. .offset = MTDPART_OFS_APPEND,
  157. .size = 192 * 1024,
  158. },
  159. {
  160. .name = "kernel",
  161. .offset = MTDPART_OFS_APPEND,
  162. .size = 2 * SZ_1M,
  163. },
  164. #endif
  165. {
  166. .name = "filesystem",
  167. .size = MTDPART_SIZ_FULL,
  168. .offset = MTDPART_OFS_APPEND,
  169. },
  170. };
  171. #define H2_NAND_RB_GPIO_PIN 62
  172. static int h2_nand_dev_ready(struct mtd_info *mtd)
  173. {
  174. return gpio_get_value(H2_NAND_RB_GPIO_PIN);
  175. }
  176. static struct platform_nand_data h2_nand_platdata = {
  177. .chip = {
  178. .nr_chips = 1,
  179. .chip_offset = 0,
  180. .nr_partitions = ARRAY_SIZE(h2_nand_partitions),
  181. .partitions = h2_nand_partitions,
  182. .options = NAND_SAMSUNG_LP_OPTIONS,
  183. },
  184. .ctrl = {
  185. .cmd_ctrl = omap1_nand_cmd_ctl,
  186. .dev_ready = h2_nand_dev_ready,
  187. },
  188. };
  189. static struct resource h2_nand_resource = {
  190. .flags = IORESOURCE_MEM,
  191. };
  192. static struct platform_device h2_nand_device = {
  193. .name = "gen_nand",
  194. .id = 0,
  195. .dev = {
  196. .platform_data = &h2_nand_platdata,
  197. },
  198. .num_resources = 1,
  199. .resource = &h2_nand_resource,
  200. };
  201. static struct smc91x_platdata h2_smc91x_info = {
  202. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  203. .leda = RPC_LED_100_10,
  204. .ledb = RPC_LED_TX_RX,
  205. };
  206. static struct resource h2_smc91x_resources[] = {
  207. [0] = {
  208. .start = OMAP1610_ETHR_START, /* Physical */
  209. .end = OMAP1610_ETHR_START + 0xf,
  210. .flags = IORESOURCE_MEM,
  211. },
  212. [1] = {
  213. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  214. },
  215. };
  216. static struct platform_device h2_smc91x_device = {
  217. .name = "smc91x",
  218. .id = 0,
  219. .dev = {
  220. .platform_data = &h2_smc91x_info,
  221. },
  222. .num_resources = ARRAY_SIZE(h2_smc91x_resources),
  223. .resource = h2_smc91x_resources,
  224. };
  225. static struct resource h2_kp_resources[] = {
  226. [0] = {
  227. .start = INT_KEYBOARD,
  228. .end = INT_KEYBOARD,
  229. .flags = IORESOURCE_IRQ,
  230. },
  231. };
  232. static const struct matrix_keymap_data h2_keymap_data = {
  233. .keymap = h2_keymap,
  234. .keymap_size = ARRAY_SIZE(h2_keymap),
  235. };
  236. static struct omap_kp_platform_data h2_kp_data = {
  237. .rows = 8,
  238. .cols = 8,
  239. .keymap_data = &h2_keymap_data,
  240. .rep = true,
  241. .delay = 9,
  242. .dbounce = true,
  243. };
  244. static struct platform_device h2_kp_device = {
  245. .name = "omap-keypad",
  246. .id = -1,
  247. .dev = {
  248. .platform_data = &h2_kp_data,
  249. },
  250. .num_resources = ARRAY_SIZE(h2_kp_resources),
  251. .resource = h2_kp_resources,
  252. };
  253. #define H2_IRDA_FIRSEL_GPIO_PIN 17
  254. static struct omap_irda_config h2_irda_data = {
  255. .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
  256. .rx_channel = OMAP_DMA_UART3_RX,
  257. .tx_channel = OMAP_DMA_UART3_TX,
  258. .dest_start = UART3_THR,
  259. .src_start = UART3_RHR,
  260. .tx_trigger = 0,
  261. .rx_trigger = 0,
  262. };
  263. static struct resource h2_irda_resources[] = {
  264. [0] = {
  265. .start = INT_UART3,
  266. .end = INT_UART3,
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. };
  270. static u64 irda_dmamask = 0xffffffff;
  271. static struct platform_device h2_irda_device = {
  272. .name = "omapirda",
  273. .id = 0,
  274. .dev = {
  275. .platform_data = &h2_irda_data,
  276. .dma_mask = &irda_dmamask,
  277. },
  278. .num_resources = ARRAY_SIZE(h2_irda_resources),
  279. .resource = h2_irda_resources,
  280. };
  281. static struct platform_device *h2_devices[] __initdata = {
  282. &h2_nor_device,
  283. &h2_nand_device,
  284. &h2_smc91x_device,
  285. &h2_irda_device,
  286. &h2_kp_device,
  287. };
  288. static void __init h2_init_smc91x(void)
  289. {
  290. if (gpio_request(0, "SMC91x irq") < 0) {
  291. printk("Error requesting gpio 0 for smc91x irq\n");
  292. return;
  293. }
  294. }
  295. static int tps_setup(struct i2c_client *client, void *context)
  296. {
  297. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V |
  298. TPS_LDO1_ENABLE | TPS_VLDO1_3_0V);
  299. return 0;
  300. }
  301. static struct tps65010_board tps_board = {
  302. .base = H2_TPS_GPIO_BASE,
  303. .outmask = 0x0f,
  304. .setup = tps_setup,
  305. };
  306. static struct i2c_board_info __initdata h2_i2c_board_info[] = {
  307. {
  308. I2C_BOARD_INFO("tps65010", 0x48),
  309. .platform_data = &tps_board,
  310. }, {
  311. I2C_BOARD_INFO("isp1301_omap", 0x2d),
  312. },
  313. };
  314. static struct omap_usb_config h2_usb_config __initdata = {
  315. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  316. .otg = 2,
  317. #ifdef CONFIG_USB_GADGET_OMAP
  318. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  319. /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */
  320. #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  321. /* needs OTG cable, or NONSTANDARD (B-to-MiniB) */
  322. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  323. #endif
  324. .pins[1] = 3,
  325. };
  326. static struct omap_lcd_config h2_lcd_config __initdata = {
  327. .ctrl_name = "internal",
  328. };
  329. static void __init h2_init(void)
  330. {
  331. h2_init_smc91x();
  332. /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
  333. * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
  334. * notice whether a NAND chip is enabled at probe time.
  335. *
  336. * FIXME revC boards (and H3) support NAND-boot, with a dip switch to
  337. * put NOR on CS2B and NAND (which on H2 may be 16bit) on CS3. Try
  338. * detecting that in code here, to avoid probing every possible flash
  339. * configuration...
  340. */
  341. h2_nor_resource.end = h2_nor_resource.start = omap_cs3_phys();
  342. h2_nor_resource.end += SZ_32M - 1;
  343. h2_nand_resource.end = h2_nand_resource.start = OMAP_CS2B_PHYS;
  344. h2_nand_resource.end += SZ_4K - 1;
  345. if (gpio_request(H2_NAND_RB_GPIO_PIN, "NAND ready") < 0)
  346. BUG();
  347. gpio_direction_input(H2_NAND_RB_GPIO_PIN);
  348. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  349. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  350. /* MMC: card detect and WP */
  351. /* omap_cfg_reg(U19_ARMIO1); */ /* CD */
  352. omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */
  353. /* Mux pins for keypad */
  354. omap_cfg_reg(F18_1610_KBC0);
  355. omap_cfg_reg(D20_1610_KBC1);
  356. omap_cfg_reg(D19_1610_KBC2);
  357. omap_cfg_reg(E18_1610_KBC3);
  358. omap_cfg_reg(C21_1610_KBC4);
  359. omap_cfg_reg(G18_1610_KBR0);
  360. omap_cfg_reg(F19_1610_KBR1);
  361. omap_cfg_reg(H14_1610_KBR2);
  362. omap_cfg_reg(E20_1610_KBR3);
  363. omap_cfg_reg(E19_1610_KBR4);
  364. omap_cfg_reg(N19_1610_KBR5);
  365. h2_smc91x_resources[1].start = gpio_to_irq(0);
  366. h2_smc91x_resources[1].end = gpio_to_irq(0);
  367. platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
  368. omap_serial_init();
  369. h2_i2c_board_info[0].irq = gpio_to_irq(58);
  370. h2_i2c_board_info[1].irq = gpio_to_irq(2);
  371. omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  372. ARRAY_SIZE(h2_i2c_board_info));
  373. omap1_usb_init(&h2_usb_config);
  374. h2_mmc_init();
  375. omapfb_set_lcd_config(&h2_lcd_config);
  376. }
  377. MACHINE_START(OMAP_H2, "TI-H2")
  378. /* Maintainer: Imre Deak <imre.deak@nokia.com> */
  379. .atag_offset = 0x100,
  380. .map_io = omap16xx_map_io,
  381. .init_early = omap1_init_early,
  382. .reserve = omap_reserve,
  383. .init_irq = omap1_init_irq,
  384. .init_machine = h2_init,
  385. .init_late = omap1_init_late,
  386. .timer = &omap1_timer,
  387. .restart = omap1_restart,
  388. MACHINE_END