board-h4.c 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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/gpio.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/mtd/mtd.h>
  18. #include <linux/mtd/partitions.h>
  19. #include <linux/mtd/physmap.h>
  20. #include <linux/delay.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c/at24.h>
  24. #include <linux/input.h>
  25. #include <linux/err.h>
  26. #include <linux/clk.h>
  27. #include <linux/io.h>
  28. #include <linux/input/matrix_keypad.h>
  29. #include <linux/mfd/menelaus.h>
  30. #include <linux/omap-dma.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/map.h>
  34. #include <video/omapdss.h>
  35. #include <video/omap-panel-generic-dpi.h>
  36. #include "common.h"
  37. #include "mux.h"
  38. #include "control.h"
  39. #include "gpmc.h"
  40. #include "gpmc-smc91x.h"
  41. #define H4_FLASH_CS 0
  42. #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
  43. static const uint32_t board_matrix_keys[] = {
  44. KEY(0, 0, KEY_LEFT),
  45. KEY(1, 0, KEY_RIGHT),
  46. KEY(2, 0, KEY_A),
  47. KEY(3, 0, KEY_B),
  48. KEY(4, 0, KEY_C),
  49. KEY(0, 1, KEY_DOWN),
  50. KEY(1, 1, KEY_UP),
  51. KEY(2, 1, KEY_E),
  52. KEY(3, 1, KEY_F),
  53. KEY(4, 1, KEY_G),
  54. KEY(0, 2, KEY_ENTER),
  55. KEY(1, 2, KEY_I),
  56. KEY(2, 2, KEY_J),
  57. KEY(3, 2, KEY_K),
  58. KEY(4, 2, KEY_3),
  59. KEY(0, 3, KEY_M),
  60. KEY(1, 3, KEY_N),
  61. KEY(2, 3, KEY_O),
  62. KEY(3, 3, KEY_P),
  63. KEY(4, 3, KEY_Q),
  64. KEY(0, 4, KEY_R),
  65. KEY(1, 4, KEY_4),
  66. KEY(2, 4, KEY_T),
  67. KEY(3, 4, KEY_U),
  68. KEY(4, 4, KEY_ENTER),
  69. KEY(0, 5, KEY_V),
  70. KEY(1, 5, KEY_W),
  71. KEY(2, 5, KEY_L),
  72. KEY(3, 5, KEY_S),
  73. KEY(4, 5, KEY_ENTER),
  74. };
  75. static const struct matrix_keymap_data board_keymap_data = {
  76. .keymap = board_matrix_keys,
  77. .keymap_size = ARRAY_SIZE(board_matrix_keys),
  78. };
  79. static unsigned int board_keypad_row_gpios[] = {
  80. 88, 89, 124, 11, 6, 96
  81. };
  82. static unsigned int board_keypad_col_gpios[] = {
  83. 90, 91, 100, 36, 12, 97, 98
  84. };
  85. static struct matrix_keypad_platform_data board_keypad_platform_data = {
  86. .keymap_data = &board_keymap_data,
  87. .row_gpios = board_keypad_row_gpios,
  88. .num_row_gpios = ARRAY_SIZE(board_keypad_row_gpios),
  89. .col_gpios = board_keypad_col_gpios,
  90. .num_col_gpios = ARRAY_SIZE(board_keypad_col_gpios),
  91. .active_low = 1,
  92. .debounce_ms = 20,
  93. .col_scan_delay_us = 5,
  94. };
  95. static struct platform_device board_keyboard = {
  96. .name = "matrix-keypad",
  97. .id = -1,
  98. .dev = {
  99. .platform_data = &board_keypad_platform_data,
  100. },
  101. };
  102. static void __init board_mkp_init(void)
  103. {
  104. omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
  105. omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
  106. omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
  107. omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
  108. if (omap_has_menelaus()) {
  109. omap_mux_init_signal("sdrc_a14.gpio0",
  110. OMAP_PULL_ENA | OMAP_PULL_UP);
  111. omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
  112. omap_mux_init_signal("gpio_98", 0);
  113. board_keypad_row_gpios[5] = 0;
  114. board_keypad_col_gpios[2] = 15;
  115. board_keypad_col_gpios[6] = 18;
  116. } else {
  117. omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
  118. omap_mux_init_signal("gpio_100", 0);
  119. omap_mux_init_signal("gpio_98", 0);
  120. }
  121. omap_mux_init_signal("gpio_90", 0);
  122. omap_mux_init_signal("gpio_91", 0);
  123. omap_mux_init_signal("gpio_36", 0);
  124. omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
  125. omap_mux_init_signal("gpio_97", 0);
  126. platform_device_register(&board_keyboard);
  127. }
  128. #else
  129. static inline void board_mkp_init(void)
  130. {
  131. }
  132. #endif
  133. static struct mtd_partition h4_partitions[] = {
  134. /* bootloader (U-Boot, etc) in first sector */
  135. {
  136. .name = "bootloader",
  137. .offset = 0,
  138. .size = SZ_128K,
  139. .mask_flags = MTD_WRITEABLE, /* force read-only */
  140. },
  141. /* bootloader params in the next sector */
  142. {
  143. .name = "params",
  144. .offset = MTDPART_OFS_APPEND,
  145. .size = SZ_128K,
  146. .mask_flags = 0,
  147. },
  148. /* kernel */
  149. {
  150. .name = "kernel",
  151. .offset = MTDPART_OFS_APPEND,
  152. .size = SZ_2M,
  153. .mask_flags = 0
  154. },
  155. /* file system */
  156. {
  157. .name = "filesystem",
  158. .offset = MTDPART_OFS_APPEND,
  159. .size = MTDPART_SIZ_FULL,
  160. .mask_flags = 0
  161. }
  162. };
  163. static struct physmap_flash_data h4_flash_data = {
  164. .width = 2,
  165. .parts = h4_partitions,
  166. .nr_parts = ARRAY_SIZE(h4_partitions),
  167. };
  168. static struct resource h4_flash_resource = {
  169. .flags = IORESOURCE_MEM,
  170. };
  171. static struct platform_device h4_flash_device = {
  172. .name = "physmap-flash",
  173. .id = 0,
  174. .dev = {
  175. .platform_data = &h4_flash_data,
  176. },
  177. .num_resources = 1,
  178. .resource = &h4_flash_resource,
  179. };
  180. static struct platform_device *h4_devices[] __initdata = {
  181. &h4_flash_device,
  182. };
  183. static struct panel_generic_dpi_data h4_panel_data = {
  184. .name = "h4",
  185. };
  186. static struct omap_dss_device h4_lcd_device = {
  187. .name = "lcd",
  188. .driver_name = "generic_dpi_panel",
  189. .type = OMAP_DISPLAY_TYPE_DPI,
  190. .phy.dpi.data_lines = 16,
  191. .data = &h4_panel_data,
  192. };
  193. static struct omap_dss_device *h4_dss_devices[] = {
  194. &h4_lcd_device,
  195. };
  196. static struct omap_dss_board_info h4_dss_data = {
  197. .num_devices = ARRAY_SIZE(h4_dss_devices),
  198. .devices = h4_dss_devices,
  199. .default_device = &h4_lcd_device,
  200. };
  201. /* 2420 Sysboot setup (2430 is different) */
  202. static u32 get_sysboot_value(void)
  203. {
  204. return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
  205. (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
  206. OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
  207. OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
  208. }
  209. /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
  210. *
  211. * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
  212. * correctly. The macro needs to look at production_id not just hawkeye.
  213. */
  214. static u32 is_gpmc_muxed(void)
  215. {
  216. u32 mux;
  217. mux = get_sysboot_value();
  218. if ((mux & 0xF) == 0xd)
  219. return 1; /* NAND config (could be either) */
  220. if (mux & 0x2) /* if mux'ed */
  221. return 1;
  222. else
  223. return 0;
  224. }
  225. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91x_MODULE)
  226. static struct omap_smc91x_platform_data board_smc91x_data = {
  227. .cs = 1,
  228. .gpio_irq = 92,
  229. .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_LOWLEVEL,
  230. };
  231. static void __init board_smc91x_init(void)
  232. {
  233. if (is_gpmc_muxed())
  234. board_smc91x_data.flags |= GPMC_MUX_ADD_DATA;
  235. omap_mux_init_gpio(board_smc91x_data.gpio_irq, OMAP_PIN_INPUT);
  236. gpmc_smc91x_init(&board_smc91x_data);
  237. }
  238. #else
  239. static inline void board_smc91x_init(void)
  240. {
  241. }
  242. #endif
  243. static void __init h4_init_flash(void)
  244. {
  245. unsigned long base;
  246. if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
  247. printk("Can't request GPMC CS for flash\n");
  248. return;
  249. }
  250. h4_flash_resource.start = base;
  251. h4_flash_resource.end = base + SZ_64M - 1;
  252. }
  253. static struct at24_platform_data m24c01 = {
  254. .byte_len = SZ_1K / 8,
  255. .page_size = 16,
  256. };
  257. static struct i2c_board_info __initdata h4_i2c_board_info[] = {
  258. {
  259. I2C_BOARD_INFO("isp1301_omap", 0x2d),
  260. },
  261. { /* EEPROM on mainboard */
  262. I2C_BOARD_INFO("24c01", 0x52),
  263. .platform_data = &m24c01,
  264. },
  265. { /* EEPROM on cpu card */
  266. I2C_BOARD_INFO("24c01", 0x57),
  267. .platform_data = &m24c01,
  268. },
  269. };
  270. #ifdef CONFIG_OMAP_MUX
  271. static struct omap_board_mux board_mux[] __initdata = {
  272. { .reg_offset = OMAP_MUX_TERMINATOR },
  273. };
  274. #endif
  275. static void __init omap_h4_init(void)
  276. {
  277. omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
  278. /*
  279. * Make sure the serial ports are muxed on at this point.
  280. * You have to mux them off in device drivers later on
  281. * if not needed.
  282. */
  283. board_mkp_init();
  284. h4_i2c_board_info[0].irq = gpio_to_irq(125);
  285. i2c_register_board_info(1, h4_i2c_board_info,
  286. ARRAY_SIZE(h4_i2c_board_info));
  287. platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
  288. omap_serial_init();
  289. omap_sdrc_init(NULL, NULL);
  290. h4_init_flash();
  291. board_smc91x_init();
  292. omap_display_init(&h4_dss_data);
  293. }
  294. MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
  295. /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
  296. .atag_offset = 0x100,
  297. .reserve = omap_reserve,
  298. .map_io = omap242x_map_io,
  299. .init_early = omap2420_init_early,
  300. .init_irq = omap2_init_irq,
  301. .handle_irq = omap2_intc_handle_irq,
  302. .init_machine = omap_h4_init,
  303. .init_late = omap2420_init_late,
  304. .init_time = omap2_sync32k_timer_init,
  305. .restart = omap2xxx_restart,
  306. MACHINE_END