board-h3.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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/config.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/mtd/mtd.h>
  25. #include <linux/mtd/nand.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/input.h>
  28. #include <asm/setup.h>
  29. #include <asm/page.h>
  30. #include <asm/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/flash.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/arch/gpio.h>
  36. #include <asm/arch/gpioexpander.h>
  37. #include <asm/arch/irqs.h>
  38. #include <asm/arch/mux.h>
  39. #include <asm/arch/tc.h>
  40. #include <asm/arch/irda.h>
  41. #include <asm/arch/usb.h>
  42. #include <asm/arch/keypad.h>
  43. #include <asm/arch/dma.h>
  44. #include <asm/arch/common.h>
  45. extern int omap_gpio_init(void);
  46. static int h3_keymap[] = {
  47. KEY(0, 0, KEY_LEFT),
  48. KEY(0, 1, KEY_RIGHT),
  49. KEY(0, 2, KEY_3),
  50. KEY(0, 3, KEY_F10),
  51. KEY(0, 4, KEY_F5),
  52. KEY(0, 5, KEY_9),
  53. KEY(1, 0, KEY_DOWN),
  54. KEY(1, 1, KEY_UP),
  55. KEY(1, 2, KEY_2),
  56. KEY(1, 3, KEY_F9),
  57. KEY(1, 4, KEY_F7),
  58. KEY(1, 5, KEY_0),
  59. KEY(2, 0, KEY_ENTER),
  60. KEY(2, 1, KEY_6),
  61. KEY(2, 2, KEY_1),
  62. KEY(2, 3, KEY_F2),
  63. KEY(2, 4, KEY_F6),
  64. KEY(2, 5, KEY_HOME),
  65. KEY(3, 0, KEY_8),
  66. KEY(3, 1, KEY_5),
  67. KEY(3, 2, KEY_F12),
  68. KEY(3, 3, KEY_F3),
  69. KEY(3, 4, KEY_F8),
  70. KEY(3, 5, KEY_END),
  71. KEY(4, 0, KEY_7),
  72. KEY(4, 1, KEY_4),
  73. KEY(4, 2, KEY_F11),
  74. KEY(4, 3, KEY_F1),
  75. KEY(4, 4, KEY_F4),
  76. KEY(4, 5, KEY_ESC),
  77. KEY(5, 0, KEY_F13),
  78. KEY(5, 1, KEY_F14),
  79. KEY(5, 2, KEY_F15),
  80. KEY(5, 3, KEY_F16),
  81. KEY(5, 4, KEY_SLEEP),
  82. 0
  83. };
  84. static struct mtd_partition nor_partitions[] = {
  85. /* bootloader (U-Boot, etc) in first sector */
  86. {
  87. .name = "bootloader",
  88. .offset = 0,
  89. .size = SZ_128K,
  90. .mask_flags = MTD_WRITEABLE, /* force read-only */
  91. },
  92. /* bootloader params in the next sector */
  93. {
  94. .name = "params",
  95. .offset = MTDPART_OFS_APPEND,
  96. .size = SZ_128K,
  97. .mask_flags = 0,
  98. },
  99. /* kernel */
  100. {
  101. .name = "kernel",
  102. .offset = MTDPART_OFS_APPEND,
  103. .size = SZ_2M,
  104. .mask_flags = 0
  105. },
  106. /* file system */
  107. {
  108. .name = "filesystem",
  109. .offset = MTDPART_OFS_APPEND,
  110. .size = MTDPART_SIZ_FULL,
  111. .mask_flags = 0
  112. }
  113. };
  114. static struct flash_platform_data nor_data = {
  115. .map_name = "cfi_probe",
  116. .width = 2,
  117. .parts = nor_partitions,
  118. .nr_parts = ARRAY_SIZE(nor_partitions),
  119. };
  120. static struct resource nor_resource = {
  121. /* This is on CS3, wherever it's mapped */
  122. .flags = IORESOURCE_MEM,
  123. };
  124. static struct platform_device nor_device = {
  125. .name = "omapflash",
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &nor_data,
  129. },
  130. .num_resources = 1,
  131. .resource = &nor_resource,
  132. };
  133. static struct mtd_partition nand_partitions[] = {
  134. #if 0
  135. /* REVISIT: enable these partitions if you make NAND BOOT work */
  136. {
  137. .name = "xloader",
  138. .offset = 0,
  139. .size = 64 * 1024,
  140. .mask_flags = MTD_WRITEABLE, /* force read-only */
  141. },
  142. {
  143. .name = "bootloader",
  144. .offset = MTDPART_OFS_APPEND,
  145. .size = 256 * 1024,
  146. .mask_flags = MTD_WRITEABLE, /* force read-only */
  147. },
  148. {
  149. .name = "params",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = 192 * 1024,
  152. },
  153. {
  154. .name = "kernel",
  155. .offset = MTDPART_OFS_APPEND,
  156. .size = 2 * SZ_1M,
  157. },
  158. #endif
  159. {
  160. .name = "filesystem",
  161. .size = MTDPART_SIZ_FULL,
  162. .offset = MTDPART_OFS_APPEND,
  163. },
  164. };
  165. /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
  166. static struct nand_platform_data nand_data = {
  167. .options = NAND_SAMSUNG_LP_OPTIONS,
  168. .parts = nand_partitions,
  169. .nr_parts = ARRAY_SIZE(nand_partitions),
  170. };
  171. static struct resource nand_resource = {
  172. .flags = IORESOURCE_MEM,
  173. };
  174. static struct platform_device nand_device = {
  175. .name = "omapnand",
  176. .id = 0,
  177. .dev = {
  178. .platform_data = &nand_data,
  179. },
  180. .num_resources = 1,
  181. .resource = &nand_resource,
  182. };
  183. static struct resource smc91x_resources[] = {
  184. [0] = {
  185. .start = OMAP1710_ETHR_START, /* Physical */
  186. .end = OMAP1710_ETHR_START + 0xf,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. [1] = {
  190. .start = OMAP_GPIO_IRQ(40),
  191. .end = OMAP_GPIO_IRQ(40),
  192. .flags = IORESOURCE_IRQ,
  193. },
  194. };
  195. static struct platform_device smc91x_device = {
  196. .name = "smc91x",
  197. .id = 0,
  198. .num_resources = ARRAY_SIZE(smc91x_resources),
  199. .resource = smc91x_resources,
  200. };
  201. #define GPTIMER_BASE 0xFFFB1400
  202. #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
  203. #define GPTIMER_REGS_SIZE 0x46
  204. static struct resource intlat_resources[] = {
  205. [0] = {
  206. .start = GPTIMER_REGS(0), /* Physical */
  207. .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
  208. .flags = IORESOURCE_MEM,
  209. },
  210. [1] = {
  211. .start = INT_1610_GPTIMER1,
  212. .end = INT_1610_GPTIMER1,
  213. .flags = IORESOURCE_IRQ,
  214. },
  215. };
  216. static struct platform_device intlat_device = {
  217. .name = "omap_intlat",
  218. .id = 0,
  219. .num_resources = ARRAY_SIZE(intlat_resources),
  220. .resource = intlat_resources,
  221. };
  222. static struct resource h3_kp_resources[] = {
  223. [0] = {
  224. .start = INT_KEYBOARD,
  225. .end = INT_KEYBOARD,
  226. .flags = IORESOURCE_IRQ,
  227. },
  228. };
  229. static struct omap_kp_platform_data h3_kp_data = {
  230. .rows = 8,
  231. .cols = 8,
  232. .keymap = h3_keymap,
  233. .rep = 1,
  234. };
  235. static struct platform_device h3_kp_device = {
  236. .name = "omap-keypad",
  237. .id = -1,
  238. .dev = {
  239. .platform_data = &h3_kp_data,
  240. },
  241. .num_resources = ARRAY_SIZE(h3_kp_resources),
  242. .resource = h3_kp_resources,
  243. };
  244. /* Select between the IrDA and aGPS module
  245. */
  246. static int h3_select_irda(struct device *dev, int state)
  247. {
  248. unsigned char expa;
  249. int err = 0;
  250. if ((err = read_gpio_expa(&expa, 0x26))) {
  251. printk(KERN_ERR "Error reading from I/O EXPANDER \n");
  252. return err;
  253. }
  254. /* 'P6' enable/disable IRDA_TX and IRDA_RX */
  255. if (state & IR_SEL) { /* IrDA */
  256. if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
  257. printk(KERN_ERR "Error writing to I/O EXPANDER \n");
  258. return err;
  259. }
  260. } else {
  261. if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
  262. printk(KERN_ERR "Error writing to I/O EXPANDER \n");
  263. return err;
  264. }
  265. }
  266. return err;
  267. }
  268. static void set_trans_mode(void *data)
  269. {
  270. int *mode = data;
  271. unsigned char expa;
  272. int err = 0;
  273. if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
  274. printk(KERN_ERR "Error reading from I/O expander\n");
  275. }
  276. expa &= ~0x03;
  277. if (*mode & IR_SIRMODE) {
  278. expa |= 0x01;
  279. } else { /* MIR/FIR */
  280. expa |= 0x03;
  281. }
  282. if ((err = write_gpio_expa(expa, 0x27)) != 0) {
  283. printk(KERN_ERR "Error writing to I/O expander\n");
  284. }
  285. }
  286. static int h3_transceiver_mode(struct device *dev, int mode)
  287. {
  288. struct omap_irda_config *irda_config = dev->platform_data;
  289. cancel_delayed_work(&irda_config->gpio_expa);
  290. PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
  291. schedule_work(&irda_config->gpio_expa);
  292. return 0;
  293. }
  294. static struct omap_irda_config h3_irda_data = {
  295. .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
  296. .transceiver_mode = h3_transceiver_mode,
  297. .select_irda = h3_select_irda,
  298. .rx_channel = OMAP_DMA_UART3_RX,
  299. .tx_channel = OMAP_DMA_UART3_TX,
  300. .dest_start = UART3_THR,
  301. .src_start = UART3_RHR,
  302. .tx_trigger = 0,
  303. .rx_trigger = 0,
  304. };
  305. static struct resource h3_irda_resources[] = {
  306. [0] = {
  307. .start = INT_UART3,
  308. .end = INT_UART3,
  309. .flags = IORESOURCE_IRQ,
  310. },
  311. };
  312. static struct platform_device h3_irda_device = {
  313. .name = "omapirda",
  314. .id = 0,
  315. .dev = {
  316. .platform_data = &h3_irda_data,
  317. },
  318. .num_resources = ARRAY_SIZE(h3_irda_resources),
  319. .resource = h3_irda_resources,
  320. };
  321. static struct platform_device h3_lcd_device = {
  322. .name = "lcd_h3",
  323. .id = -1,
  324. };
  325. static struct platform_device *devices[] __initdata = {
  326. &nor_device,
  327. &nand_device,
  328. &smc91x_device,
  329. &intlat_device,
  330. &h3_irda_device,
  331. &h3_kp_device,
  332. &h3_lcd_device,
  333. };
  334. static struct omap_usb_config h3_usb_config __initdata = {
  335. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  336. .otg = 2,
  337. #ifdef CONFIG_USB_GADGET_OMAP
  338. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  339. #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  340. /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
  341. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  342. #endif
  343. .pins[1] = 3,
  344. };
  345. static struct omap_mmc_config h3_mmc_config __initdata = {
  346. .mmc[0] = {
  347. .enabled = 1,
  348. .power_pin = -1, /* tps65010 GPIO4 */
  349. .switch_pin = OMAP_MPUIO(1),
  350. },
  351. };
  352. static struct omap_uart_config h3_uart_config __initdata = {
  353. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  354. };
  355. static struct omap_lcd_config h3_lcd_config __initdata = {
  356. .ctrl_name = "internal",
  357. };
  358. static struct omap_board_config_kernel h3_config[] = {
  359. { OMAP_TAG_USB, &h3_usb_config },
  360. { OMAP_TAG_MMC, &h3_mmc_config },
  361. { OMAP_TAG_UART, &h3_uart_config },
  362. { OMAP_TAG_LCD, &h3_lcd_config },
  363. };
  364. #define H3_NAND_RB_GPIO_PIN 10
  365. static int nand_dev_ready(struct nand_platform_data *data)
  366. {
  367. return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
  368. }
  369. static void __init h3_init(void)
  370. {
  371. /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
  372. * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
  373. * notice whether a NAND chip is enabled at probe time.
  374. *
  375. * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
  376. * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
  377. * to avoid probing every possible flash configuration...
  378. */
  379. nor_resource.end = nor_resource.start = omap_cs3_phys();
  380. nor_resource.end += SZ_32M - 1;
  381. nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
  382. nand_resource.end += SZ_4K - 1;
  383. if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
  384. nand_data.dev_ready = nand_dev_ready;
  385. /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
  386. /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
  387. omap_cfg_reg(V2_1710_GPIO10);
  388. platform_add_devices(devices, ARRAY_SIZE(devices));
  389. omap_board_config = h3_config;
  390. omap_board_config_size = ARRAY_SIZE(h3_config);
  391. omap_serial_init();
  392. }
  393. static void __init h3_init_smc91x(void)
  394. {
  395. omap_cfg_reg(W15_1710_GPIO40);
  396. if (omap_request_gpio(40) < 0) {
  397. printk("Error requesting gpio 40 for smc91x irq\n");
  398. return;
  399. }
  400. }
  401. void h3_init_irq(void)
  402. {
  403. omap1_init_common_hw();
  404. omap_init_irq();
  405. omap_gpio_init();
  406. h3_init_smc91x();
  407. }
  408. static void __init h3_map_io(void)
  409. {
  410. omap1_map_common_io();
  411. }
  412. MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
  413. /* Maintainer: Texas Instruments, Inc. */
  414. .phys_io = 0xfff00000,
  415. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  416. .boot_params = 0x10000100,
  417. .map_io = h3_map_io,
  418. .init_irq = h3_init_irq,
  419. .init_machine = h3_init,
  420. .timer = &omap_timer,
  421. MACHINE_END