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 <linux/leds.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. #include <mach/mux.h>
  40. #include <linux/omap-dma.h>
  41. #include <mach/tc.h>
  42. #include <linux/platform_data/keypad-omap.h>
  43. #include "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. static struct gpio_led h2_gpio_led_pins[] = {
  254. {
  255. .name = "h2:red",
  256. .default_trigger = "heartbeat",
  257. .gpio = 3,
  258. },
  259. {
  260. .name = "h2:green",
  261. .default_trigger = "cpu0",
  262. .gpio = OMAP_MPUIO(4),
  263. },
  264. };
  265. static struct gpio_led_platform_data h2_gpio_led_data = {
  266. .leds = h2_gpio_led_pins,
  267. .num_leds = ARRAY_SIZE(h2_gpio_led_pins),
  268. };
  269. static struct platform_device h2_gpio_leds = {
  270. .name = "leds-gpio",
  271. .id = -1,
  272. .dev = {
  273. .platform_data = &h2_gpio_led_data,
  274. },
  275. };
  276. static struct platform_device *h2_devices[] __initdata = {
  277. &h2_nor_device,
  278. &h2_nand_device,
  279. &h2_smc91x_device,
  280. &h2_kp_device,
  281. &h2_gpio_leds,
  282. };
  283. static void __init h2_init_smc91x(void)
  284. {
  285. if (gpio_request(0, "SMC91x irq") < 0) {
  286. printk("Error requesting gpio 0 for smc91x irq\n");
  287. return;
  288. }
  289. }
  290. static int tps_setup(struct i2c_client *client, void *context)
  291. {
  292. if (!IS_BUILTIN(CONFIG_TPS65010))
  293. return -ENOSYS;
  294. tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V |
  295. TPS_LDO1_ENABLE | TPS_VLDO1_3_0V);
  296. return 0;
  297. }
  298. static struct tps65010_board tps_board = {
  299. .base = H2_TPS_GPIO_BASE,
  300. .outmask = 0x0f,
  301. .setup = tps_setup,
  302. };
  303. static struct i2c_board_info __initdata h2_i2c_board_info[] = {
  304. {
  305. I2C_BOARD_INFO("tps65010", 0x48),
  306. .platform_data = &tps_board,
  307. }, {
  308. I2C_BOARD_INFO("isp1301_omap", 0x2d),
  309. },
  310. };
  311. static struct omap_usb_config h2_usb_config __initdata = {
  312. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  313. .otg = 2,
  314. #if IS_ENABLED(CONFIG_USB_OMAP)
  315. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  316. /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */
  317. #elif IS_ENABLED(CONFIG_USB_OHCI_HCD)
  318. /* needs OTG cable, or NONSTANDARD (B-to-MiniB) */
  319. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  320. #endif
  321. .pins[1] = 3,
  322. };
  323. static struct omap_lcd_config h2_lcd_config __initdata = {
  324. .ctrl_name = "internal",
  325. };
  326. static void __init h2_init(void)
  327. {
  328. h2_init_smc91x();
  329. /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
  330. * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
  331. * notice whether a NAND chip is enabled at probe time.
  332. *
  333. * FIXME revC boards (and H3) support NAND-boot, with a dip switch to
  334. * put NOR on CS2B and NAND (which on H2 may be 16bit) on CS3. Try
  335. * detecting that in code here, to avoid probing every possible flash
  336. * configuration...
  337. */
  338. h2_nor_resource.end = h2_nor_resource.start = omap_cs3_phys();
  339. h2_nor_resource.end += SZ_32M - 1;
  340. h2_nand_resource.end = h2_nand_resource.start = OMAP_CS2B_PHYS;
  341. h2_nand_resource.end += SZ_4K - 1;
  342. BUG_ON(gpio_request(H2_NAND_RB_GPIO_PIN, "NAND ready") < 0);
  343. gpio_direction_input(H2_NAND_RB_GPIO_PIN);
  344. omap_cfg_reg(L3_1610_FLASH_CS2B_OE);
  345. omap_cfg_reg(M8_1610_FLASH_CS2B_WE);
  346. /* MMC: card detect and WP */
  347. /* omap_cfg_reg(U19_ARMIO1); */ /* CD */
  348. omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */
  349. /* Mux pins for keypad */
  350. omap_cfg_reg(F18_1610_KBC0);
  351. omap_cfg_reg(D20_1610_KBC1);
  352. omap_cfg_reg(D19_1610_KBC2);
  353. omap_cfg_reg(E18_1610_KBC3);
  354. omap_cfg_reg(C21_1610_KBC4);
  355. omap_cfg_reg(G18_1610_KBR0);
  356. omap_cfg_reg(F19_1610_KBR1);
  357. omap_cfg_reg(H14_1610_KBR2);
  358. omap_cfg_reg(E20_1610_KBR3);
  359. omap_cfg_reg(E19_1610_KBR4);
  360. omap_cfg_reg(N19_1610_KBR5);
  361. /* GPIO based LEDs */
  362. omap_cfg_reg(P18_1610_GPIO3);
  363. omap_cfg_reg(MPUIO4);
  364. h2_smc91x_resources[1].start = gpio_to_irq(0);
  365. h2_smc91x_resources[1].end = gpio_to_irq(0);
  366. platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
  367. omap_serial_init();
  368. h2_i2c_board_info[0].irq = gpio_to_irq(58);
  369. h2_i2c_board_info[1].irq = gpio_to_irq(2);
  370. omap_register_i2c_bus(1, 100, h2_i2c_board_info,
  371. ARRAY_SIZE(h2_i2c_board_info));
  372. omap1_usb_init(&h2_usb_config);
  373. h2_mmc_init();
  374. omapfb_set_lcd_config(&h2_lcd_config);
  375. }
  376. MACHINE_START(OMAP_H2, "TI-H2")
  377. /* Maintainer: Imre Deak <imre.deak@nokia.com> */
  378. .atag_offset = 0x100,
  379. .map_io = omap16xx_map_io,
  380. .init_early = omap1_init_early,
  381. .init_irq = omap1_init_irq,
  382. .handle_irq = omap1_handle_irq,
  383. .init_machine = h2_init,
  384. .init_late = omap1_init_late,
  385. .init_time = omap1_timer_init,
  386. .restart = omap1_restart,
  387. MACHINE_END