board-h4.c 8.3 KB

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