board-h3.c 11 KB

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