board-h4.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. #error this is not permitted - mode is an argument variable
  188. schedule_delayed_work(&irda_config->gpio_expa, 0);
  189. return 0;
  190. }
  191. static struct omap_irda_config h4_irda_data = {
  192. .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
  193. .transceiver_mode = h4_transceiver_mode,
  194. .select_irda = h4_select_irda,
  195. .rx_channel = OMAP24XX_DMA_UART3_RX,
  196. .tx_channel = OMAP24XX_DMA_UART3_TX,
  197. .dest_start = OMAP_UART3_BASE,
  198. .src_start = OMAP_UART3_BASE,
  199. .tx_trigger = OMAP24XX_DMA_UART3_TX,
  200. .rx_trigger = OMAP24XX_DMA_UART3_RX,
  201. };
  202. static struct resource h4_irda_resources[] = {
  203. [0] = {
  204. .start = INT_24XX_UART3_IRQ,
  205. .end = INT_24XX_UART3_IRQ,
  206. .flags = IORESOURCE_IRQ,
  207. },
  208. };
  209. static struct platform_device h4_irda_device = {
  210. .name = "omapirda",
  211. .id = -1,
  212. .dev = {
  213. .platform_data = &h4_irda_data,
  214. },
  215. .num_resources = 1,
  216. .resource = h4_irda_resources,
  217. };
  218. static struct omap_kp_platform_data h4_kp_data = {
  219. .rows = 6,
  220. .cols = 7,
  221. .keymap = h4_keymap,
  222. .keymapsize = ARRAY_SIZE(h4_keymap),
  223. .rep = 1,
  224. .row_gpios = row_gpios,
  225. .col_gpios = col_gpios,
  226. };
  227. static struct platform_device h4_kp_device = {
  228. .name = "omap-keypad",
  229. .id = -1,
  230. .dev = {
  231. .platform_data = &h4_kp_data,
  232. },
  233. };
  234. static struct platform_device h4_lcd_device = {
  235. .name = "lcd_h4",
  236. .id = -1,
  237. };
  238. static struct platform_device *h4_devices[] __initdata = {
  239. &h4_smc91x_device,
  240. &h4_flash_device,
  241. &h4_irda_device,
  242. &h4_kp_device,
  243. &h4_lcd_device,
  244. };
  245. static inline void __init h4_init_smc91x(void)
  246. {
  247. /* Make sure CS1 timings are correct */
  248. GPMC_CONFIG1_1 = 0x00011200;
  249. GPMC_CONFIG2_1 = 0x001f1f01;
  250. GPMC_CONFIG3_1 = 0x00080803;
  251. GPMC_CONFIG4_1 = 0x1c091c09;
  252. GPMC_CONFIG5_1 = 0x041f1f1f;
  253. GPMC_CONFIG6_1 = 0x000004c4;
  254. GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24);
  255. udelay(100);
  256. omap_cfg_reg(M15_24XX_GPIO92);
  257. if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
  258. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  259. OMAP24XX_ETHR_GPIO_IRQ);
  260. return;
  261. }
  262. omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
  263. }
  264. static void __init omap_h4_init_irq(void)
  265. {
  266. omap2_init_common_hw();
  267. omap_init_irq();
  268. omap_gpio_init();
  269. h4_init_smc91x();
  270. }
  271. static struct omap_uart_config h4_uart_config __initdata = {
  272. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  273. };
  274. static struct omap_mmc_config h4_mmc_config __initdata = {
  275. .mmc [0] = {
  276. .enabled = 1,
  277. .wire4 = 1,
  278. .wp_pin = -1,
  279. .power_pin = -1,
  280. .switch_pin = -1,
  281. },
  282. };
  283. static struct omap_lcd_config h4_lcd_config __initdata = {
  284. .ctrl_name = "internal",
  285. };
  286. static struct omap_board_config_kernel h4_config[] = {
  287. { OMAP_TAG_UART, &h4_uart_config },
  288. { OMAP_TAG_MMC, &h4_mmc_config },
  289. { OMAP_TAG_LCD, &h4_lcd_config },
  290. };
  291. static void __init omap_h4_init(void)
  292. {
  293. /*
  294. * Make sure the serial ports are muxed on at this point.
  295. * You have to mux them off in device drivers later on
  296. * if not needed.
  297. */
  298. #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
  299. omap_cfg_reg(K15_24XX_UART3_TX);
  300. omap_cfg_reg(K14_24XX_UART3_RX);
  301. #endif
  302. #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
  303. if (omap_has_menelaus()) {
  304. row_gpios[5] = 0;
  305. col_gpios[2] = 15;
  306. col_gpios[6] = 18;
  307. }
  308. #endif
  309. platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
  310. omap_board_config = h4_config;
  311. omap_board_config_size = ARRAY_SIZE(h4_config);
  312. omap_serial_init();
  313. }
  314. static void __init omap_h4_map_io(void)
  315. {
  316. omap2_map_common_io();
  317. }
  318. MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
  319. /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
  320. .phys_io = 0x48000000,
  321. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  322. .boot_params = 0x80000100,
  323. .map_io = omap_h4_map_io,
  324. .init_irq = omap_h4_init_irq,
  325. .init_machine = omap_h4_init,
  326. .timer = &omap_timer,
  327. MACHINE_END