board-h4.c 9.5 KB

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