board-h4.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /*
  2. * linux/arch/arm/mach-omap2/board-h4.c
  3. *
  4. * Copyright (C) 2005 Nokia Corporation
  5. * Author: Paul Mundt <paul.mundt@nokia.com>
  6. *
  7. * Modified from mach-omap/omap1/board-generic.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/delay.h>
  19. #include <linux/workqueue.h>
  20. #include <linux/input.h>
  21. #include <asm/hardware.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>
  25. #include <asm/mach/flash.h>
  26. #include <asm/arch/gpio.h>
  27. #include <asm/arch/gpioexpander.h>
  28. #include <asm/arch/mux.h>
  29. #include <asm/arch/usb.h>
  30. #include <asm/arch/irda.h>
  31. #include <asm/arch/board.h>
  32. #include <asm/arch/common.h>
  33. #include <asm/arch/keypad.h>
  34. #include <asm/arch/menelaus.h>
  35. #include <asm/arch/dma.h>
  36. #include "prcm-regs.h"
  37. #include <asm/io.h>
  38. static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
  39. static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
  40. static int h4_keymap[] = {
  41. KEY(0, 0, KEY_LEFT),
  42. KEY(0, 1, KEY_RIGHT),
  43. KEY(0, 2, KEY_A),
  44. KEY(0, 3, KEY_B),
  45. KEY(0, 4, KEY_C),
  46. KEY(1, 0, KEY_DOWN),
  47. KEY(1, 1, KEY_UP),
  48. KEY(1, 2, KEY_E),
  49. KEY(1, 3, KEY_F),
  50. KEY(1, 4, KEY_G),
  51. KEY(2, 0, KEY_ENTER),
  52. KEY(2, 1, KEY_I),
  53. KEY(2, 2, KEY_J),
  54. KEY(2, 3, KEY_K),
  55. KEY(2, 4, KEY_3),
  56. KEY(3, 0, KEY_M),
  57. KEY(3, 1, KEY_N),
  58. KEY(3, 2, KEY_O),
  59. KEY(3, 3, KEY_P),
  60. KEY(3, 4, KEY_Q),
  61. KEY(4, 0, KEY_R),
  62. KEY(4, 1, KEY_4),
  63. KEY(4, 2, KEY_T),
  64. KEY(4, 3, KEY_U),
  65. KEY(4, 4, KEY_ENTER),
  66. KEY(5, 0, KEY_V),
  67. KEY(5, 1, KEY_W),
  68. KEY(5, 2, KEY_L),
  69. KEY(5, 3, KEY_S),
  70. KEY(5, 4, KEY_ENTER),
  71. 0
  72. };
  73. static struct mtd_partition h4_partitions[] = {
  74. /* bootloader (U-Boot, etc) in first sector */
  75. {
  76. .name = "bootloader",
  77. .offset = 0,
  78. .size = SZ_128K,
  79. .mask_flags = MTD_WRITEABLE, /* force read-only */
  80. },
  81. /* bootloader params in the next sector */
  82. {
  83. .name = "params",
  84. .offset = MTDPART_OFS_APPEND,
  85. .size = SZ_128K,
  86. .mask_flags = 0,
  87. },
  88. /* kernel */
  89. {
  90. .name = "kernel",
  91. .offset = MTDPART_OFS_APPEND,
  92. .size = SZ_2M,
  93. .mask_flags = 0
  94. },
  95. /* file system */
  96. {
  97. .name = "filesystem",
  98. .offset = MTDPART_OFS_APPEND,
  99. .size = MTDPART_SIZ_FULL,
  100. .mask_flags = 0
  101. }
  102. };
  103. static struct flash_platform_data h4_flash_data = {
  104. .map_name = "cfi_probe",
  105. .width = 2,
  106. .parts = h4_partitions,
  107. .nr_parts = ARRAY_SIZE(h4_partitions),
  108. };
  109. static struct resource h4_flash_resource = {
  110. .start = H4_CS0_BASE,
  111. .end = H4_CS0_BASE + SZ_64M - 1,
  112. .flags = IORESOURCE_MEM,
  113. };
  114. static struct platform_device h4_flash_device = {
  115. .name = "omapflash",
  116. .id = 0,
  117. .dev = {
  118. .platform_data = &h4_flash_data,
  119. },
  120. .num_resources = 1,
  121. .resource = &h4_flash_resource,
  122. };
  123. /* Select between the IrDA and aGPS module
  124. */
  125. static int h4_select_irda(struct device *dev, int state)
  126. {
  127. unsigned char expa;
  128. int err = 0;
  129. if ((err = read_gpio_expa(&expa, 0x21))) {
  130. printk(KERN_ERR "Error reading from I/O expander\n");
  131. return err;
  132. }
  133. /* 'P6' enable/disable IRDA_TX and IRDA_RX */
  134. if (state & IR_SEL) { /* IrDa */
  135. if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
  136. printk(KERN_ERR "Error writing to I/O expander\n");
  137. return err;
  138. }
  139. } else {
  140. if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
  141. printk(KERN_ERR "Error writing to I/O expander\n");
  142. return err;
  143. }
  144. }
  145. return err;
  146. }
  147. static void set_trans_mode(struct work_struct *work)
  148. {
  149. struct omap_irda_config *irda_config =
  150. container_of(work, struct omap_irda_config, gpio_expa.work);
  151. int mode = irda_config->mode;
  152. unsigned char expa;
  153. int err = 0;
  154. if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
  155. printk(KERN_ERR "Error reading from I/O expander\n");
  156. }
  157. expa &= ~0x01;
  158. if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
  159. expa |= 0x01;
  160. }
  161. if ((err = write_gpio_expa(expa, 0x20)) != 0) {
  162. printk(KERN_ERR "Error writing to I/O expander\n");
  163. }
  164. }
  165. static int h4_transceiver_mode(struct device *dev, int mode)
  166. {
  167. struct omap_irda_config *irda_config = dev->platform_data;
  168. irda_config->mode = mode;
  169. cancel_delayed_work(&irda_config->gpio_expa);
  170. PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
  171. schedule_delayed_work(&irda_config->gpio_expa, 0);
  172. return 0;
  173. }
  174. static struct omap_irda_config h4_irda_data = {
  175. .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
  176. .transceiver_mode = h4_transceiver_mode,
  177. .select_irda = h4_select_irda,
  178. .rx_channel = OMAP24XX_DMA_UART3_RX,
  179. .tx_channel = OMAP24XX_DMA_UART3_TX,
  180. .dest_start = OMAP_UART3_BASE,
  181. .src_start = OMAP_UART3_BASE,
  182. .tx_trigger = OMAP24XX_DMA_UART3_TX,
  183. .rx_trigger = OMAP24XX_DMA_UART3_RX,
  184. };
  185. static struct resource h4_irda_resources[] = {
  186. [0] = {
  187. .start = INT_24XX_UART3_IRQ,
  188. .end = INT_24XX_UART3_IRQ,
  189. .flags = IORESOURCE_IRQ,
  190. },
  191. };
  192. static struct platform_device h4_irda_device = {
  193. .name = "omapirda",
  194. .id = -1,
  195. .dev = {
  196. .platform_data = &h4_irda_data,
  197. },
  198. .num_resources = 1,
  199. .resource = h4_irda_resources,
  200. };
  201. static struct omap_kp_platform_data h4_kp_data = {
  202. .rows = 6,
  203. .cols = 7,
  204. .keymap = h4_keymap,
  205. .keymapsize = ARRAY_SIZE(h4_keymap),
  206. .rep = 1,
  207. .row_gpios = row_gpios,
  208. .col_gpios = col_gpios,
  209. };
  210. static struct platform_device h4_kp_device = {
  211. .name = "omap-keypad",
  212. .id = -1,
  213. .dev = {
  214. .platform_data = &h4_kp_data,
  215. },
  216. };
  217. static struct platform_device h4_lcd_device = {
  218. .name = "lcd_h4",
  219. .id = -1,
  220. };
  221. static struct platform_device *h4_devices[] __initdata = {
  222. &h4_flash_device,
  223. &h4_irda_device,
  224. &h4_kp_device,
  225. &h4_lcd_device,
  226. };
  227. static inline void __init h4_init_debug(void)
  228. {
  229. /* Make sure CS1 timings are correct */
  230. GPMC_CONFIG1_1 = 0x00011200;
  231. GPMC_CONFIG2_1 = 0x001f1f01;
  232. GPMC_CONFIG3_1 = 0x00080803;
  233. GPMC_CONFIG4_1 = 0x1c091c09;
  234. GPMC_CONFIG5_1 = 0x041f1f1f;
  235. GPMC_CONFIG6_1 = 0x000004c4;
  236. GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24);
  237. udelay(100);
  238. omap_cfg_reg(M15_24XX_GPIO92);
  239. if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
  240. gpmc_cs_free(eth_cs);
  241. }
  242. static void __init omap_h4_init_irq(void)
  243. {
  244. omap2_init_common_hw();
  245. omap_init_irq();
  246. omap_gpio_init();
  247. }
  248. static struct omap_uart_config h4_uart_config __initdata = {
  249. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  250. };
  251. static struct omap_mmc_config h4_mmc_config __initdata = {
  252. .mmc [0] = {
  253. .enabled = 1,
  254. .wire4 = 1,
  255. .wp_pin = -1,
  256. .power_pin = -1,
  257. .switch_pin = -1,
  258. },
  259. };
  260. static struct omap_lcd_config h4_lcd_config __initdata = {
  261. .ctrl_name = "internal",
  262. };
  263. static struct omap_board_config_kernel h4_config[] = {
  264. { OMAP_TAG_UART, &h4_uart_config },
  265. { OMAP_TAG_MMC, &h4_mmc_config },
  266. { OMAP_TAG_LCD, &h4_lcd_config },
  267. };
  268. static void __init omap_h4_init(void)
  269. {
  270. /*
  271. * Make sure the serial ports are muxed on at this point.
  272. * You have to mux them off in device drivers later on
  273. * if not needed.
  274. */
  275. #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
  276. omap_cfg_reg(K15_24XX_UART3_TX);
  277. omap_cfg_reg(K14_24XX_UART3_RX);
  278. #endif
  279. #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
  280. if (omap_has_menelaus()) {
  281. row_gpios[5] = 0;
  282. col_gpios[2] = 15;
  283. col_gpios[6] = 18;
  284. }
  285. #endif
  286. platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
  287. omap_board_config = h4_config;
  288. omap_board_config_size = ARRAY_SIZE(h4_config);
  289. omap_serial_init();
  290. }
  291. static void __init omap_h4_map_io(void)
  292. {
  293. omap2_map_common_io();
  294. }
  295. MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
  296. /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
  297. .phys_io = 0x48000000,
  298. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  299. .boot_params = 0x80000100,
  300. .map_io = omap_h4_map_io,
  301. .init_irq = omap_h4_init_irq,
  302. .init_machine = omap_h4_init,
  303. .timer = &omap_timer,
  304. MACHINE_END