board-h4.c 9.4 KB

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