board-h3.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. /*
  2. * linux/arch/arm/mach-omap1/board-h3.c
  3. *
  4. * This file contains OMAP1710 H3 specific code.
  5. *
  6. * Copyright (C) 2004 Texas Instruments, Inc.
  7. * Copyright (C) 2002 MontaVista Software, Inc.
  8. * Copyright (C) 2001 RidgeRun, Inc.
  9. * Author: RidgeRun, Inc.
  10. * Greg Lonnon (glonnon@ridgerun.com) or info@ridgerun.com
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/gpio.h>
  17. #include <linux/types.h>
  18. #include <linux/init.h>
  19. #include <linux/major.h>
  20. #include <linux/kernel.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/errno.h>
  23. #include <linux/workqueue.h>
  24. #include <linux/i2c.h>
  25. #include <linux/mtd/mtd.h>
  26. #include <linux/mtd/rawnand.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <linux/input.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/mfd/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/setup.h>
  37. #include <asm/page.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/map.h>
  41. #include <mach/mux.h>
  42. #include <mach/tc.h>
  43. #include <linux/platform_data/keypad-omap.h>
  44. #include <linux/omap-dma.h>
  45. #include "flash.h"
  46. #include <mach/hardware.h>
  47. #include <mach/irqs.h>
  48. #include <mach/usb.h>
  49. #include "common.h"
  50. #include "board-h3.h"
  51. /* In OMAP1710 H3 the Ethernet is directly connected to CS1 */
  52. #define OMAP1710_ETHR_START 0x04000300
  53. #define H3_TS_GPIO 48
  54. static const unsigned int h3_keymap[] = {
  55. KEY(0, 0, KEY_LEFT),
  56. KEY(1, 0, KEY_RIGHT),
  57. KEY(2, 0, KEY_3),
  58. KEY(3, 0, KEY_F10),
  59. KEY(4, 0, KEY_F5),
  60. KEY(5, 0, KEY_9),
  61. KEY(0, 1, KEY_DOWN),
  62. KEY(1, 1, KEY_UP),
  63. KEY(2, 1, KEY_2),
  64. KEY(3, 1, KEY_F9),
  65. KEY(4, 1, KEY_F7),
  66. KEY(5, 1, KEY_0),
  67. KEY(0, 2, KEY_ENTER),
  68. KEY(1, 2, KEY_6),
  69. KEY(2, 2, KEY_1),
  70. KEY(3, 2, KEY_F2),
  71. KEY(4, 2, KEY_F6),
  72. KEY(5, 2, KEY_HOME),
  73. KEY(0, 3, KEY_8),
  74. KEY(1, 3, KEY_5),
  75. KEY(2, 3, KEY_F12),
  76. KEY(3, 3, KEY_F3),
  77. KEY(4, 3, KEY_F8),
  78. KEY(5, 3, KEY_END),
  79. KEY(0, 4, KEY_7),
  80. KEY(1, 4, KEY_4),
  81. KEY(2, 4, KEY_F11),
  82. KEY(3, 4, KEY_F1),
  83. KEY(4, 4, KEY_F4),
  84. KEY(5, 4, KEY_ESC),
  85. KEY(0, 5, KEY_F13),
  86. KEY(1, 5, KEY_F14),
  87. KEY(2, 5, KEY_F15),
  88. KEY(3, 5, KEY_F16),
  89. KEY(4, 5, KEY_SLEEP),
  90. };
  91. static struct mtd_partition nor_partitions[] = {
  92. /* bootloader (U-Boot, etc) in first sector */
  93. {
  94. .name = "bootloader",
  95. .offset = 0,
  96. .size = SZ_128K,
  97. .mask_flags = MTD_WRITEABLE, /* force read-only */
  98. },
  99. /* bootloader params in the next sector */
  100. {
  101. .name = "params",
  102. .offset = MTDPART_OFS_APPEND,
  103. .size = SZ_128K,
  104. .mask_flags = 0,
  105. },
  106. /* kernel */
  107. {
  108. .name = "kernel",
  109. .offset = MTDPART_OFS_APPEND,
  110. .size = SZ_2M,
  111. .mask_flags = 0
  112. },
  113. /* file system */
  114. {
  115. .name = "filesystem",
  116. .offset = MTDPART_OFS_APPEND,
  117. .size = MTDPART_SIZ_FULL,
  118. .mask_flags = 0
  119. }
  120. };
  121. static struct physmap_flash_data nor_data = {
  122. .width = 2,
  123. .set_vpp = omap1_set_vpp,
  124. .parts = nor_partitions,
  125. .nr_parts = ARRAY_SIZE(nor_partitions),
  126. };
  127. static struct resource nor_resource = {
  128. /* This is on CS3, wherever it's mapped */
  129. .flags = IORESOURCE_MEM,
  130. };
  131. static struct platform_device nor_device = {
  132. .name = "physmap-flash",
  133. .id = 0,
  134. .dev = {
  135. .platform_data = &nor_data,
  136. },
  137. .num_resources = 1,
  138. .resource = &nor_resource,
  139. };
  140. static struct mtd_partition nand_partitions[] = {
  141. #if 0
  142. /* REVISIT: enable these partitions if you make NAND BOOT work */
  143. {
  144. .name = "xloader",
  145. .offset = 0,
  146. .size = 64 * 1024,
  147. .mask_flags = MTD_WRITEABLE, /* force read-only */
  148. },
  149. {
  150. .name = "bootloader",
  151. .offset = MTDPART_OFS_APPEND,
  152. .size = 256 * 1024,
  153. .mask_flags = MTD_WRITEABLE, /* force read-only */
  154. },
  155. {
  156. .name = "params",
  157. .offset = MTDPART_OFS_APPEND,
  158. .size = 192 * 1024,
  159. },
  160. {
  161. .name = "kernel",
  162. .offset = MTDPART_OFS_APPEND,
  163. .size = 2 * SZ_1M,
  164. },
  165. #endif
  166. {
  167. .name = "filesystem",
  168. .size = MTDPART_SIZ_FULL,
  169. .offset = MTDPART_OFS_APPEND,
  170. },
  171. };
  172. #define H3_NAND_RB_GPIO_PIN 10
  173. static int nand_dev_ready(struct mtd_info *mtd)
  174. {
  175. return gpio_get_value(H3_NAND_RB_GPIO_PIN);
  176. }
  177. static struct platform_nand_data nand_platdata = {
  178. .chip = {
  179. .nr_chips = 1,
  180. .chip_offset = 0,
  181. .nr_partitions = ARRAY_SIZE(nand_partitions),
  182. .partitions = nand_partitions,
  183. .options = NAND_SAMSUNG_LP_OPTIONS,
  184. },
  185. .ctrl = {
  186. .cmd_ctrl = omap1_nand_cmd_ctl,
  187. .dev_ready = nand_dev_ready,
  188. },
  189. };
  190. static struct resource nand_resource = {
  191. .flags = IORESOURCE_MEM,
  192. };
  193. static struct platform_device nand_device = {
  194. .name = "gen_nand",
  195. .id = 0,
  196. .dev = {
  197. .platform_data = &nand_platdata,
  198. },
  199. .num_resources = 1,
  200. .resource = &nand_resource,
  201. };
  202. static struct smc91x_platdata smc91x_info = {
  203. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  204. .leda = RPC_LED_100_10,
  205. .ledb = RPC_LED_TX_RX,
  206. };
  207. static struct resource smc91x_resources[] = {
  208. [0] = {
  209. .start = OMAP1710_ETHR_START, /* Physical */
  210. .end = OMAP1710_ETHR_START + 0xf,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. [1] = {
  214. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  215. },
  216. };
  217. static struct platform_device smc91x_device = {
  218. .name = "smc91x",
  219. .id = 0,
  220. .dev = {
  221. .platform_data = &smc91x_info,
  222. },
  223. .num_resources = ARRAY_SIZE(smc91x_resources),
  224. .resource = smc91x_resources,
  225. };
  226. static void __init h3_init_smc91x(void)
  227. {
  228. omap_cfg_reg(W15_1710_GPIO40);
  229. if (gpio_request(40, "SMC91x irq") < 0) {
  230. printk("Error requesting gpio 40 for smc91x irq\n");
  231. return;
  232. }
  233. }
  234. #define GPTIMER_BASE 0xFFFB1400
  235. #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
  236. #define GPTIMER_REGS_SIZE 0x46
  237. static struct resource intlat_resources[] = {
  238. [0] = {
  239. .start = GPTIMER_REGS(0), /* Physical */
  240. .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
  241. .flags = IORESOURCE_MEM,
  242. },
  243. [1] = {
  244. .start = INT_1610_GPTIMER1,
  245. .end = INT_1610_GPTIMER1,
  246. .flags = IORESOURCE_IRQ,
  247. },
  248. };
  249. static struct platform_device intlat_device = {
  250. .name = "omap_intlat",
  251. .id = 0,
  252. .num_resources = ARRAY_SIZE(intlat_resources),
  253. .resource = intlat_resources,
  254. };
  255. static struct resource h3_kp_resources[] = {
  256. [0] = {
  257. .start = INT_KEYBOARD,
  258. .end = INT_KEYBOARD,
  259. .flags = IORESOURCE_IRQ,
  260. },
  261. };
  262. static const struct matrix_keymap_data h3_keymap_data = {
  263. .keymap = h3_keymap,
  264. .keymap_size = ARRAY_SIZE(h3_keymap),
  265. };
  266. static struct omap_kp_platform_data h3_kp_data = {
  267. .rows = 8,
  268. .cols = 8,
  269. .keymap_data = &h3_keymap_data,
  270. .rep = true,
  271. .delay = 9,
  272. .dbounce = true,
  273. };
  274. static struct platform_device h3_kp_device = {
  275. .name = "omap-keypad",
  276. .id = -1,
  277. .dev = {
  278. .platform_data = &h3_kp_data,
  279. },
  280. .num_resources = ARRAY_SIZE(h3_kp_resources),
  281. .resource = h3_kp_resources,
  282. };
  283. static struct platform_device h3_lcd_device = {
  284. .name = "lcd_h3",
  285. .id = -1,
  286. };
  287. static struct spi_board_info h3_spi_board_info[] __initdata = {
  288. [0] = {
  289. .modalias = "tsc2101",
  290. .bus_num = 2,
  291. .chip_select = 0,
  292. .max_speed_hz = 16000000,
  293. /* .platform_data = &tsc_platform_data, */
  294. },
  295. };
  296. static const struct gpio_led h3_gpio_led_pins[] = {
  297. {
  298. .name = "h3:red",
  299. .default_trigger = "heartbeat",
  300. .gpio = 3,
  301. },
  302. {
  303. .name = "h3:green",
  304. .default_trigger = "cpu0",
  305. .gpio = OMAP_MPUIO(4),
  306. },
  307. };
  308. static struct gpio_led_platform_data h3_gpio_led_data = {
  309. .leds = h3_gpio_led_pins,
  310. .num_leds = ARRAY_SIZE(h3_gpio_led_pins),
  311. };
  312. static struct platform_device h3_gpio_leds = {
  313. .name = "leds-gpio",
  314. .id = -1,
  315. .dev = {
  316. .platform_data = &h3_gpio_led_data,
  317. },
  318. };
  319. static struct platform_device *devices[] __initdata = {
  320. &nor_device,
  321. &nand_device,
  322. &smc91x_device,
  323. &intlat_device,
  324. &h3_kp_device,
  325. &h3_lcd_device,
  326. &h3_gpio_leds,
  327. };
  328. static struct omap_usb_config h3_usb_config __initdata = {
  329. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  330. .otg = 2,
  331. #if IS_ENABLED(CONFIG_USB_OMAP)
  332. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  333. #elif IS_ENABLED(CONFIG_USB_OHCI_HCD)
  334. /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
  335. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  336. #endif
  337. .pins[1] = 3,
  338. };
  339. static const struct omap_lcd_config h3_lcd_config __initconst = {
  340. .ctrl_name = "internal",
  341. };
  342. static struct i2c_board_info __initdata h3_i2c_board_info[] = {
  343. {
  344. I2C_BOARD_INFO("tps65013", 0x48),
  345. },
  346. {
  347. I2C_BOARD_INFO("isp1301_omap", 0x2d),
  348. },
  349. };
  350. static void __init h3_init(void)
  351. {
  352. h3_init_smc91x();
  353. /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
  354. * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
  355. * notice whether a NAND chip is enabled at probe time.
  356. *
  357. * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
  358. * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
  359. * to avoid probing every possible flash configuration...
  360. */
  361. nor_resource.end = nor_resource.start = omap_cs3_phys();
  362. nor_resource.end += SZ_32M - 1;
  363. nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
  364. nand_resource.end += SZ_4K - 1;
  365. BUG_ON(gpio_request(H3_NAND_RB_GPIO_PIN, "NAND ready") < 0);
  366. gpio_direction_input(H3_NAND_RB_GPIO_PIN);
  367. /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
  368. /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
  369. omap_cfg_reg(V2_1710_GPIO10);
  370. /* Mux pins for keypad */
  371. omap_cfg_reg(F18_1610_KBC0);
  372. omap_cfg_reg(D20_1610_KBC1);
  373. omap_cfg_reg(D19_1610_KBC2);
  374. omap_cfg_reg(E18_1610_KBC3);
  375. omap_cfg_reg(C21_1610_KBC4);
  376. omap_cfg_reg(G18_1610_KBR0);
  377. omap_cfg_reg(F19_1610_KBR1);
  378. omap_cfg_reg(H14_1610_KBR2);
  379. omap_cfg_reg(E20_1610_KBR3);
  380. omap_cfg_reg(E19_1610_KBR4);
  381. omap_cfg_reg(N19_1610_KBR5);
  382. /* GPIO based LEDs */
  383. omap_cfg_reg(P18_1610_GPIO3);
  384. omap_cfg_reg(MPUIO4);
  385. smc91x_resources[1].start = gpio_to_irq(40);
  386. smc91x_resources[1].end = gpio_to_irq(40);
  387. platform_add_devices(devices, ARRAY_SIZE(devices));
  388. h3_spi_board_info[0].irq = gpio_to_irq(H3_TS_GPIO);
  389. spi_register_board_info(h3_spi_board_info,
  390. ARRAY_SIZE(h3_spi_board_info));
  391. omap_serial_init();
  392. h3_i2c_board_info[1].irq = gpio_to_irq(14);
  393. omap_register_i2c_bus(1, 100, h3_i2c_board_info,
  394. ARRAY_SIZE(h3_i2c_board_info));
  395. omap1_usb_init(&h3_usb_config);
  396. h3_mmc_init();
  397. omapfb_set_lcd_config(&h3_lcd_config);
  398. }
  399. MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
  400. /* Maintainer: Texas Instruments, Inc. */
  401. .atag_offset = 0x100,
  402. .map_io = omap16xx_map_io,
  403. .init_early = omap1_init_early,
  404. .init_irq = omap1_init_irq,
  405. .handle_irq = omap1_handle_irq,
  406. .init_machine = h3_init,
  407. .init_late = omap1_init_late,
  408. .init_time = omap1_timer_init,
  409. .restart = omap1_restart,
  410. MACHINE_END