synchronousMemoryDatabase.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * Copyright (C) 2009 Integration Software and Electronic Engineering.
  3. *
  4. * Modified from mach-omap2/board-generic.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/delay.h>
  14. #include <linux/err.h>
  15. #include <linux/clk.h>
  16. #include <linux/io.h>
  17. #include <linux/gpio.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/input.h>
  20. #include <linux/regulator/machine.h>
  21. #include <linux/regulator/fixed.h>
  22. #include <linux/i2c/twl.h>
  23. #include <linux/mmc/host.h>
  24. #include <linux/mtd/nand.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <video/omapdss.h>
  28. #include <video/omap-panel-tfp410.h>
  29. #include <linux/platform_data/mtd-onenand-omap2.h>
  30. #include "common.h"
  31. #include "gpmc.h"
  32. #include "mux.h"
  33. #include "hsmmc.h"
  34. #include "sdram-numonyx-m65kxxxxam.h"
  35. #include "common-board-devices.h"
  36. #include "board-flash.h"
  37. #include "control.h"
  38. #include "gpmc-onenand.h"
  39. #define IGEP2_SMSC911X_CS 5
  40. #define IGEP2_SMSC911X_GPIO 176
  41. #define IGEP2_GPIO_USBH_NRESET 24
  42. #define IGEP2_GPIO_LED0_GREEN 26
  43. #define IGEP2_GPIO_LED0_RED 27
  44. #define IGEP2_GPIO_LED1_RED 28
  45. #define IGEP2_GPIO_DVI_PUP 170
  46. #define IGEP2_RB_GPIO_WIFI_NPD 94
  47. #define IGEP2_RB_GPIO_WIFI_NRESET 95
  48. #define IGEP2_RB_GPIO_BT_NRESET 137
  49. #define IGEP2_RC_GPIO_WIFI_NPD 138
  50. #define IGEP2_RC_GPIO_WIFI_NRESET 139
  51. #define IGEP2_RC_GPIO_BT_NRESET 137
  52. #define IGEP3_GPIO_LED0_GREEN 54
  53. #define IGEP3_GPIO_LED0_RED 53
  54. #define IGEP3_GPIO_LED1_RED 16
  55. #define IGEP3_GPIO_USBH_NRESET 183
  56. #define IGEP_SYSBOOT_MASK 0x1f
  57. #define IGEP_SYSBOOT_NAND 0x0f
  58. #define IGEP_SYSBOOT_ONENAND 0x10
  59. /*
  60. * IGEP2 Hardware Revision Table
  61. *
  62. * --------------------------------------------------------------------------
  63. * | Id. | Hw Rev. | HW0 (28) | WIFI_NPD | WIFI_NRESET | BT_NRESET |
  64. * --------------------------------------------------------------------------
  65. * | 0 | B | high | gpio94 | gpio95 | - |
  66. * | 0 | B/C (B-compatible) | high | gpio94 | gpio95 | gpio137 |
  67. * | 1 | C | low | gpio138 | gpio139 | gpio137 |
  68. * --------------------------------------------------------------------------
  69. */
  70. #define IGEP2_BOARD_HWREV_B 0
  71. #define IGEP2_BOARD_HWREV_C 1
  72. #define IGEP3_BOARD_HWREV 2
  73. static u8 hwrev;
  74. static void __init igep2_get_revision(void)
  75. {
  76. u8 ret;
  77. if (machine_is_igep0030()) {
  78. hwrev = IGEP3_BOARD_HWREV;
  79. return;
  80. }
  81. omap_mux_init_gpio(IGEP2_GPIO_LED1_RED, OMAP_PIN_INPUT);
  82. if (gpio_request_one(IGEP2_GPIO_LED1_RED, GPIOF_IN, "GPIO_HW0_REV")) {
  83. pr_warning("IGEP2: Could not obtain gpio GPIO_HW0_REV\n");
  84. pr_err("IGEP2: Unknown Hardware Revision\n");
  85. return;
  86. }
  87. ret = gpio_get_value(IGEP2_GPIO_LED1_RED);
  88. if (ret == 0) {
  89. pr_info("IGEP2: Hardware Revision C (B-NON compatible)\n");
  90. hwrev = IGEP2_BOARD_HWREV_C;
  91. } else if (ret == 1) {
  92. pr_info("IGEP2: Hardware Revision B/C (B compatible)\n");
  93. hwrev = IGEP2_BOARD_HWREV_B;
  94. } else {
  95. pr_err("IGEP2: Unknown Hardware Revision\n");
  96. hwrev = -1;
  97. }
  98. gpio_free(IGEP2_GPIO_LED1_RED);
  99. }
  100. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  101. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) || \
  102. defined(CONFIG_MTD_NAND_OMAP2) || \
  103. defined(CONFIG_MTD_NAND_OMAP2_MODULE)
  104. #define ONENAND_MAP 0x20000000
  105. /* NAND04GR4E1A ( x2 Flash built-in COMBO POP MEMORY )
  106. * Since the device is equipped with two DataRAMs, and two-plane NAND
  107. * Flash memory array, these two component enables simultaneous program
  108. * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
  109. * while Plane2 has only odd blocks such as block1, block3, block5.
  110. * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
  111. */
  112. static struct mtd_partition igep_flash_partitions[] = {
  113. {
  114. .name = "X-Loader",
  115. .offset = 0,
  116. .size = 2 * (64*(2*2048))
  117. },
  118. {
  119. .name = "U-Boot",
  120. .offset = MTDPART_OFS_APPEND,
  121. .size = 6 * (64*(2*2048)),
  122. },
  123. {
  124. .name = "Environment",
  125. .offset = MTDPART_OFS_APPEND,
  126. .size = 2 * (64*(2*2048)),
  127. },
  128. {
  129. .name = "Kernel",
  130. .offset = MTDPART_OFS_APPEND,
  131. .size = 12 * (64*(2*2048)),
  132. },
  133. {
  134. .name = "File System",
  135. .offset = MTDPART_OFS_APPEND,
  136. .size = MTDPART_SIZ_FULL,
  137. },
  138. };
  139. static inline u32 igep_get_sysboot_value(void)
  140. {
  141. return omap_ctrl_readl(OMAP343X_CONTROL_STATUS) & IGEP_SYSBOOT_MASK;
  142. }
  143. static void __init igep_flash_init(void)
  144. {
  145. u32 mux;
  146. mux = igep_get_sysboot_value();
  147. if (mux == IGEP_SYSBOOT_NAND) {
  148. pr_info("IGEP: initializing NAND memory device\n");
  149. board_nand_init(igep_flash_partitions,
  150. ARRAY_SIZE(igep_flash_partitions),
  151. 0, NAND_BUSWIDTH_16, nand_default_timings);
  152. } else if (mux == IGEP_SYSBOOT_ONENAND) {
  153. pr_info("IGEP: initializing OneNAND memory device\n");
  154. board_onenand_init(igep_flash_partitions,
  155. ARRAY_SIZE(igep_flash_partitions), 0);
  156. } else {
  157. pr_err("IGEP: Flash: unsupported sysboot sequence found\n");
  158. }
  159. }
  160. #else
  161. static void __init igep_flash_init(void) {}
  162. #endif
  163. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  164. #include <linux/smsc911x.h>
  165. #include "gpmc-smsc911x.h"
  166. static struct omap_smsc911x_platform_data smsc911x_cfg = {
  167. .cs = IGEP2_SMSC911X_CS,
  168. .gpio_irq = IGEP2_SMSC911X_GPIO,
  169. .gpio_reset = -EINVAL,
  170. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  171. };
  172. static inline void __init igep2_init_smsc911x(void)
  173. {
  174. gpmc_smsc911x_init(&smsc911x_cfg);
  175. }
  176. #else
  177. static inline void __init igep2_init_smsc911x(void) { }
  178. #endif
  179. static struct regulator_consumer_supply igep_vmmc1_supply[] = {
  180. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  181. };
  182. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  183. static struct regulator_init_data igep_vmmc1 = {
  184. .constraints = {
  185. .min_uV = 1850000,
  186. .max_uV = 3150000,
  187. .valid_modes_mask = REGULATOR_MODE_NORMAL
  188. | REGULATOR_MODE_STANDBY,
  189. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  190. | REGULATOR_CHANGE_MODE
  191. | REGULATOR_CHANGE_STATUS,
  192. },
  193. .num_consumer_supplies = ARRAY_SIZE(igep_vmmc1_supply),
  194. .consumer_supplies = igep_vmmc1_supply,
  195. };
  196. static struct regulator_consumer_supply igep_vio_supply[] = {
  197. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
  198. };
  199. static struct regulator_init_data igep_vio = {
  200. .constraints = {
  201. .min_uV = 1800000,
  202. .max_uV = 1800000,
  203. .apply_uV = 1,
  204. .valid_modes_mask = REGULATOR_MODE_NORMAL
  205. | REGULATOR_MODE_STANDBY,
  206. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  207. | REGULATOR_CHANGE_MODE
  208. | REGULATOR_CHANGE_STATUS,
  209. },
  210. .num_consumer_supplies = ARRAY_SIZE(igep_vio_supply),
  211. .consumer_supplies = igep_vio_supply,
  212. };
  213. static struct regulator_consumer_supply igep_vmmc2_supply[] = {
  214. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  215. };
  216. static struct regulator_init_data igep_vmmc2 = {
  217. .constraints = {
  218. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  219. .always_on = 1,
  220. },
  221. .num_consumer_supplies = ARRAY_SIZE(igep_vmmc2_supply),
  222. .consumer_supplies = igep_vmmc2_supply,
  223. };
  224. static struct fixed_voltage_config igep_vwlan = {
  225. .supply_name = "vwlan",
  226. .microvolts = 3300000,
  227. .gpio = -EINVAL,
  228. .enabled_at_boot = 1,
  229. .init_data = &igep_vmmc2,
  230. };
  231. static struct platform_device igep_vwlan_device = {
  232. .name = "reg-fixed-voltage",
  233. .id = 0,
  234. .dev = {
  235. .platform_data = &igep_vwlan,
  236. },
  237. };
  238. static struct omap2_hsmmc_info mmc[] = {
  239. {
  240. .mmc = 1,
  241. .caps = MMC_CAP_4_BIT_DATA,
  242. .gpio_cd = -EINVAL,
  243. .gpio_wp = -EINVAL,
  244. .deferred = true,
  245. },
  246. #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
  247. {
  248. .mmc = 2,
  249. .caps = MMC_CAP_4_BIT_DATA,
  250. .gpio_cd = -EINVAL,
  251. .gpio_wp = -EINVAL,
  252. },
  253. #endif
  254. {} /* Terminator */
  255. };