board-h4.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. static struct resource h4_smc91x_resources[] = {
  124. [0] = {
  125. .start = OMAP24XX_ETHR_START, /* Physical */
  126. .end = OMAP24XX_ETHR_START + 0xf,
  127. .flags = IORESOURCE_MEM,
  128. },
  129. [1] = {
  130. .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
  131. .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
  132. .flags = IORESOURCE_IRQ,
  133. },
  134. };
  135. static struct platform_device h4_smc91x_device = {
  136. .name = "smc91x",
  137. .id = -1,
  138. .num_resources = ARRAY_SIZE(h4_smc91x_resources),
  139. .resource = h4_smc91x_resources,
  140. };
  141. /* Select between the IrDA and aGPS module
  142. */
  143. static int h4_select_irda(struct device *dev, int state)
  144. {
  145. unsigned char expa;
  146. int err = 0;
  147. if ((err = read_gpio_expa(&expa, 0x21))) {
  148. printk(KERN_ERR "Error reading from I/O expander\n");
  149. return err;
  150. }
  151. /* 'P6' enable/disable IRDA_TX and IRDA_RX */
  152. if (state & IR_SEL) { /* IrDa */
  153. if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
  154. printk(KERN_ERR "Error writing to I/O expander\n");
  155. return err;
  156. }
  157. } else {
  158. if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
  159. printk(KERN_ERR "Error writing to I/O expander\n");
  160. return err;
  161. }
  162. }
  163. return err;
  164. }
  165. static void set_trans_mode(struct work_struct *work)
  166. {
  167. struct omap_irda_config *irda_config =
  168. container_of(work, struct omap_irda_config, gpio_expa.work);
  169. int mode = irda_config->mode;
  170. unsigned char expa;
  171. int err = 0;
  172. if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
  173. printk(KERN_ERR "Error reading from I/O expander\n");
  174. }
  175. expa &= ~0x01;
  176. if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
  177. expa |= 0x01;
  178. }
  179. if ((err = write_gpio_expa(expa, 0x20)) != 0) {
  180. printk(KERN_ERR "Error writing to I/O expander\n");
  181. }
  182. }
  183. static int h4_transceiver_mode(struct device *dev, int mode)
  184. {
  185. struct omap_irda_config *irda_config = dev->platform_data;
  186. irda_config->mode = mode;
  187. cancel_delayed_work(&irda_config->gpio_expa);
  188. PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
  189. schedule_delayed_work(&irda_config->gpio_expa, 0);
  190. return 0;
  191. }
  192. static struct omap_irda_config h4_irda_data = {
  193. .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
  194. .transceiver_mode = h4_transceiver_mode,
  195. .select_irda = h4_select_irda,
  196. .rx_channel = OMAP24XX_DMA_UART3_RX,
  197. .tx_channel = OMAP24XX_DMA_UART3_TX,
  198. .dest_start = OMAP_UART3_BASE,
  199. .src_start = OMAP_UART3_BASE,
  200. .tx_trigger = OMAP24XX_DMA_UART3_TX,
  201. .rx_trigger = OMAP24XX_DMA_UART3_RX,
  202. };
  203. static struct resource h4_irda_resources[] = {
  204. [0] = {
  205. .start = INT_24XX_UART3_IRQ,
  206. .end = INT_24XX_UART3_IRQ,
  207. .flags = IORESOURCE_IRQ,
  208. },
  209. };
  210. static struct platform_device h4_irda_device = {
  211. .name = "omapirda",
  212. .id = -1,
  213. .dev = {
  214. .platform_data = &h4_irda_data,
  215. },
  216. .num_resources = 1,
  217. .resource = h4_irda_resources,
  218. };
  219. static struct omap_kp_platform_data h4_kp_data = {
  220. .rows = 6,
  221. .cols = 7,
  222. .keymap = h4_keymap,
  223. .keymapsize = ARRAY_SIZE(h4_keymap),
  224. .rep = 1,
  225. .row_gpios = row_gpios,
  226. .col_gpios = col_gpios,
  227. };
  228. static struct platform_device h4_kp_device = {
  229. .name = "omap-keypad",
  230. .id = -1,
  231. .dev = {
  232. .platform_data = &h4_kp_data,
  233. },
  234. };
  235. static struct platform_device h4_lcd_device = {
  236. .name = "lcd_h4",
  237. .id = -1,
  238. };
  239. static struct resource h4_led_resources[] = {
  240. [0] = {
  241. .flags = IORESOURCE_MEM,
  242. },
  243. };
  244. static struct platform_device h4_led_device = {
  245. .name = "omap_dbg_led",
  246. .id = -1,
  247. .num_resources = ARRAY_SIZE(h4_led_resources),
  248. .resource = h4_led_resources,
  249. };
  250. static struct platform_device *h4_devices[] __initdata = {
  251. &h4_smc91x_device,
  252. &h4_flash_device,
  253. &h4_irda_device,
  254. &h4_kp_device,
  255. &h4_lcd_device,
  256. &h4_led_device,
  257. };
  258. static inline void __init h4_init_smc91x(void)
  259. {
  260. /* Make sure CS1 timings are correct */
  261. GPMC_CONFIG1_1 = 0x00011200;
  262. GPMC_CONFIG2_1 = 0x001f1f01;
  263. GPMC_CONFIG3_1 = 0x00080803;
  264. GPMC_CONFIG4_1 = 0x1c091c09;
  265. GPMC_CONFIG5_1 = 0x041f1f1f;
  266. GPMC_CONFIG6_1 = 0x000004c4;
  267. GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24);
  268. udelay(100);
  269. omap_cfg_reg(M15_24XX_GPIO92);
  270. if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
  271. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  272. OMAP24XX_ETHR_GPIO_IRQ);
  273. return;
  274. }
  275. omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
  276. }
  277. static void __init omap_h4_init_irq(void)
  278. {
  279. omap2_init_common_hw();
  280. omap_init_irq();
  281. omap_gpio_init();
  282. h4_init_smc91x();
  283. }
  284. static struct omap_uart_config h4_uart_config __initdata = {
  285. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  286. };
  287. static struct omap_mmc_config h4_mmc_config __initdata = {
  288. .mmc [0] = {
  289. .enabled = 1,
  290. .wire4 = 1,
  291. .wp_pin = -1,
  292. .power_pin = -1,
  293. .switch_pin = -1,
  294. },
  295. };
  296. static struct omap_lcd_config h4_lcd_config __initdata = {
  297. .ctrl_name = "internal",
  298. };
  299. static struct omap_board_config_kernel h4_config[] = {
  300. { OMAP_TAG_UART, &h4_uart_config },
  301. { OMAP_TAG_MMC, &h4_mmc_config },
  302. { OMAP_TAG_LCD, &h4_lcd_config },
  303. };
  304. static void __init omap_h4_init(void)
  305. {
  306. /*
  307. * Make sure the serial ports are muxed on at this point.
  308. * You have to mux them off in device drivers later on
  309. * if not needed.
  310. */
  311. #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
  312. omap_cfg_reg(K15_24XX_UART3_TX);
  313. omap_cfg_reg(K14_24XX_UART3_RX);
  314. #endif
  315. #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
  316. if (omap_has_menelaus()) {
  317. row_gpios[5] = 0;
  318. col_gpios[2] = 15;
  319. col_gpios[6] = 18;
  320. }
  321. #endif
  322. platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
  323. omap_board_config = h4_config;
  324. omap_board_config_size = ARRAY_SIZE(h4_config);
  325. omap_serial_init();
  326. }
  327. static void __init omap_h4_map_io(void)
  328. {
  329. omap2_map_common_io();
  330. }
  331. MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
  332. /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
  333. .phys_io = 0x48000000,
  334. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  335. .boot_params = 0x80000100,
  336. .map_io = omap_h4_map_io,
  337. .init_irq = omap_h4_init_irq,
  338. .init_machine = omap_h4_init,
  339. .timer = &omap_timer,
  340. MACHINE_END