board-igep0030.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * Copyright (C) 2010 - ISEE 2007 SL
  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/regulator/machine.h>
  20. #include <linux/regulator/fixed.h>
  21. #include <linux/i2c/twl.h>
  22. #include <linux/mmc/host.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <plat/board.h>
  26. #include <plat/common.h>
  27. #include <plat/gpmc.h>
  28. #include <plat/usb.h>
  29. #include <plat/onenand.h>
  30. #include "mux.h"
  31. #include "hsmmc.h"
  32. #include "sdram-numonyx-m65kxxxxam.h"
  33. #include "common-board-devices.h"
  34. #define IGEP3_GPIO_LED0_GREEN 54
  35. #define IGEP3_GPIO_LED0_RED 53
  36. #define IGEP3_GPIO_LED1_RED 16
  37. #define IGEP3_GPIO_WIFI_NPD 138
  38. #define IGEP3_GPIO_WIFI_NRESET 139
  39. #define IGEP3_GPIO_BT_NRESET 137
  40. #define IGEP3_GPIO_USBH_NRESET 183
  41. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  42. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  43. #define ONENAND_MAP 0x20000000
  44. /*
  45. * x2 Flash built-in COMBO POP MEMORY
  46. * Since the device is equipped with two DataRAMs, and two-plane NAND
  47. * Flash memory array, these two component enables simultaneous program
  48. * of 4KiB. Plane1 has only even blocks such as block0, block2, block4
  49. * while Plane2 has only odd blocks such as block1, block3, block5.
  50. * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048)
  51. */
  52. static struct mtd_partition igep3_onenand_partitions[] = {
  53. {
  54. .name = "X-Loader",
  55. .offset = 0,
  56. .size = 2 * (64*(2*2048))
  57. },
  58. {
  59. .name = "U-Boot",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = 6 * (64*(2*2048)),
  62. },
  63. {
  64. .name = "Environment",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = 2 * (64*(2*2048)),
  67. },
  68. {
  69. .name = "Kernel",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = 12 * (64*(2*2048)),
  72. },
  73. {
  74. .name = "File System",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = MTDPART_SIZ_FULL,
  77. },
  78. };
  79. static struct omap_onenand_platform_data igep3_onenand_pdata = {
  80. .parts = igep3_onenand_partitions,
  81. .nr_parts = ARRAY_SIZE(igep3_onenand_partitions),
  82. .onenand_setup = NULL,
  83. .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
  84. };
  85. static struct platform_device igep3_onenand_device = {
  86. .name = "omap2-onenand",
  87. .id = -1,
  88. .dev = {
  89. .platform_data = &igep3_onenand_pdata,
  90. },
  91. };
  92. static void __init igep3_flash_init(void)
  93. {
  94. u8 cs = 0;
  95. u8 onenandcs = GPMC_CS_NUM + 1;
  96. for (cs = 0; cs < GPMC_CS_NUM; cs++) {
  97. u32 ret;
  98. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  99. /* Check if NAND/oneNAND is configured */
  100. if ((ret & 0xC00) == 0x800)
  101. /* NAND found */
  102. pr_err("IGEP3: Unsupported NAND found\n");
  103. else {
  104. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  105. if ((ret & 0x3F) == (ONENAND_MAP >> 24))
  106. /* OneNAND found */
  107. onenandcs = cs;
  108. }
  109. }
  110. if (onenandcs > GPMC_CS_NUM) {
  111. pr_err("IGEP3: Unable to find configuration in GPMC\n");
  112. return;
  113. }
  114. igep3_onenand_pdata.cs = onenandcs;
  115. if (platform_device_register(&igep3_onenand_device) < 0)
  116. pr_err("IGEP3: Unable to register OneNAND device\n");
  117. }
  118. #else
  119. static void __init igep3_flash_init(void) {}
  120. #endif
  121. static struct regulator_consumer_supply igep3_vmmc1_supply =
  122. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0");
  123. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  124. static struct regulator_init_data igep3_vmmc1 = {
  125. .constraints = {
  126. .min_uV = 1850000,
  127. .max_uV = 3150000,
  128. .valid_modes_mask = REGULATOR_MODE_NORMAL
  129. | REGULATOR_MODE_STANDBY,
  130. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  131. | REGULATOR_CHANGE_MODE
  132. | REGULATOR_CHANGE_STATUS,
  133. },
  134. .num_consumer_supplies = 1,
  135. .consumer_supplies = &igep3_vmmc1_supply,
  136. };
  137. static struct regulator_consumer_supply igep3_vio_supply =
  138. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1");
  139. static struct regulator_init_data igep3_vio = {
  140. .constraints = {
  141. .min_uV = 1800000,
  142. .max_uV = 1800000,
  143. .apply_uV = 1,
  144. .valid_modes_mask = REGULATOR_MODE_NORMAL
  145. | REGULATOR_MODE_STANDBY,
  146. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  147. | REGULATOR_CHANGE_MODE
  148. | REGULATOR_CHANGE_STATUS,
  149. },
  150. .num_consumer_supplies = 1,
  151. .consumer_supplies = &igep3_vio_supply,
  152. };
  153. static struct regulator_consumer_supply igep3_vmmc2_supply =
  154. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1");
  155. static struct regulator_init_data igep3_vmmc2 = {
  156. .constraints = {
  157. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  158. .always_on = 1,
  159. },
  160. .num_consumer_supplies = 1,
  161. .consumer_supplies = &igep3_vmmc2_supply,
  162. };
  163. static struct fixed_voltage_config igep3_vwlan = {
  164. .supply_name = "vwlan",
  165. .microvolts = 3300000,
  166. .gpio = -EINVAL,
  167. .enabled_at_boot = 1,
  168. .init_data = &igep3_vmmc2,
  169. };
  170. static struct platform_device igep3_vwlan_device = {
  171. .name = "reg-fixed-voltage",
  172. .id = 0,
  173. .dev = {
  174. .platform_data = &igep3_vwlan,
  175. },
  176. };
  177. static struct omap2_hsmmc_info mmc[] = {
  178. [0] = {
  179. .mmc = 1,
  180. .caps = MMC_CAP_4_BIT_DATA,
  181. .gpio_cd = -EINVAL,
  182. .gpio_wp = -EINVAL,
  183. },
  184. #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
  185. [1] = {
  186. .mmc = 2,
  187. .caps = MMC_CAP_4_BIT_DATA,
  188. .gpio_cd = -EINVAL,
  189. .gpio_wp = -EINVAL,
  190. },
  191. #endif
  192. {} /* Terminator */
  193. };
  194. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  195. #include <linux/leds.h>
  196. static struct gpio_led igep3_gpio_leds[] = {
  197. [0] = {
  198. .name = "gpio-led:red:d0",
  199. .gpio = IGEP3_GPIO_LED0_RED,
  200. .default_trigger = "default-off"
  201. },
  202. [1] = {
  203. .name = "gpio-led:green:d0",
  204. .gpio = IGEP3_GPIO_LED0_GREEN,
  205. .default_trigger = "default-off",
  206. },
  207. [2] = {
  208. .name = "gpio-led:red:d1",
  209. .gpio = IGEP3_GPIO_LED1_RED,
  210. .default_trigger = "default-off",
  211. },
  212. [3] = {
  213. .name = "gpio-led:green:d1",
  214. .default_trigger = "heartbeat",
  215. .gpio = -EINVAL, /* gets replaced */
  216. },
  217. };
  218. static struct gpio_led_platform_data igep3_led_pdata = {
  219. .leds = igep3_gpio_leds,
  220. .num_leds = ARRAY_SIZE(igep3_gpio_leds),
  221. };
  222. static struct platform_device igep3_led_device = {
  223. .name = "leds-gpio",
  224. .id = -1,
  225. .dev = {
  226. .platform_data = &igep3_led_pdata,
  227. },
  228. };
  229. static void __init igep3_leds_init(void)
  230. {
  231. platform_device_register(&igep3_led_device);
  232. }
  233. #else
  234. static inline void igep3_leds_init(void)
  235. {
  236. if ((gpio_request(IGEP3_GPIO_LED0_RED, "gpio-led:red:d0") == 0) &&
  237. (gpio_direction_output(IGEP3_GPIO_LED0_RED, 1) == 0)) {
  238. gpio_export(IGEP3_GPIO_LED0_RED, 0);
  239. gpio_set_value(IGEP3_GPIO_LED0_RED, 1);
  240. } else
  241. pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_RED\n");
  242. if ((gpio_request(IGEP3_GPIO_LED0_GREEN, "gpio-led:green:d0") == 0) &&
  243. (gpio_direction_output(IGEP3_GPIO_LED0_GREEN, 1) == 0)) {
  244. gpio_export(IGEP3_GPIO_LED0_GREEN, 0);
  245. gpio_set_value(IGEP3_GPIO_LED0_GREEN, 1);
  246. } else
  247. pr_warning("IGEP3: Could not obtain gpio GPIO_LED0_GREEN\n");
  248. if ((gpio_request(IGEP3_GPIO_LED1_RED, "gpio-led:red:d1") == 0) &&
  249. (gpio_direction_output(IGEP3_GPIO_LED1_RED, 1) == 0)) {
  250. gpio_export(IGEP3_GPIO_LED1_RED, 0);
  251. gpio_set_value(IGEP3_GPIO_LED1_RED, 1);
  252. } else
  253. pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_RED\n");
  254. }
  255. #endif
  256. static int igep3_twl4030_gpio_setup(struct device *dev,
  257. unsigned gpio, unsigned ngpio)
  258. {
  259. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  260. mmc[0].gpio_cd = gpio + 0;
  261. omap2_hsmmc_init(mmc);
  262. /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
  263. #if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
  264. if ((gpio_request(gpio+TWL4030_GPIO_MAX+1, "gpio-led:green:d1") == 0)
  265. && (gpio_direction_output(gpio + TWL4030_GPIO_MAX + 1, 1) == 0)) {
  266. gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
  267. gpio_set_value(gpio + TWL4030_GPIO_MAX + 1, 0);
  268. } else
  269. pr_warning("IGEP3: Could not obtain gpio GPIO_LED1_GREEN\n");
  270. #else
  271. igep3_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
  272. #endif
  273. return 0;
  274. };
  275. static struct twl4030_gpio_platform_data igep3_twl4030_gpio_pdata = {
  276. .gpio_base = OMAP_MAX_GPIO_LINES,
  277. .irq_base = TWL4030_GPIO_IRQ_BASE,
  278. .irq_end = TWL4030_GPIO_IRQ_END,
  279. .use_leds = true,
  280. .setup = igep3_twl4030_gpio_setup,
  281. };
  282. static struct twl4030_usb_data igep3_twl4030_usb_data = {
  283. .usb_mode = T2_USB_MODE_ULPI,
  284. };
  285. static struct platform_device *igep3_devices[] __initdata = {
  286. &igep3_vwlan_device,
  287. };
  288. static void __init igep3_init_early(void)
  289. {
  290. omap2_init_common_infrastructure();
  291. omap2_init_common_devices(m65kxxxxam_sdrc_params,
  292. m65kxxxxam_sdrc_params);
  293. }
  294. static struct twl4030_platform_data igep3_twl4030_pdata = {
  295. .irq_base = TWL4030_IRQ_BASE,
  296. .irq_end = TWL4030_IRQ_END,
  297. /* platform_data for children goes here */
  298. .usb = &igep3_twl4030_usb_data,
  299. .gpio = &igep3_twl4030_gpio_pdata,
  300. .vmmc1 = &igep3_vmmc1,
  301. .vio = &igep3_vio,
  302. };
  303. static int __init igep3_i2c_init(void)
  304. {
  305. omap3_pmic_init("twl4030", &igep3_twl4030_pdata);
  306. return 0;
  307. }
  308. static struct omap_musb_board_data musb_board_data = {
  309. .interface_type = MUSB_INTERFACE_ULPI,
  310. .mode = MUSB_OTG,
  311. .power = 100,
  312. };
  313. #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
  314. static void __init igep3_wifi_bt_init(void)
  315. {
  316. /* Configure MUX values for W-LAN + Bluetooth GPIO's */
  317. omap_mux_init_gpio(IGEP3_GPIO_WIFI_NPD, OMAP_PIN_OUTPUT);
  318. omap_mux_init_gpio(IGEP3_GPIO_WIFI_NRESET, OMAP_PIN_OUTPUT);
  319. omap_mux_init_gpio(IGEP3_GPIO_BT_NRESET, OMAP_PIN_OUTPUT);
  320. /* Set GPIO's for W-LAN + Bluetooth combo module */
  321. if ((gpio_request(IGEP3_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
  322. (gpio_direction_output(IGEP3_GPIO_WIFI_NPD, 1) == 0)) {
  323. gpio_export(IGEP3_GPIO_WIFI_NPD, 0);
  324. } else
  325. pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NPD\n");
  326. if ((gpio_request(IGEP3_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
  327. (gpio_direction_output(IGEP3_GPIO_WIFI_NRESET, 1) == 0)) {
  328. gpio_export(IGEP3_GPIO_WIFI_NRESET, 0);
  329. gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 0);
  330. udelay(10);
  331. gpio_set_value(IGEP3_GPIO_WIFI_NRESET, 1);
  332. } else
  333. pr_warning("IGEP3: Could not obtain gpio GPIO_WIFI_NRESET\n");
  334. if ((gpio_request(IGEP3_GPIO_BT_NRESET, "GPIO_BT_NRESET") == 0) &&
  335. (gpio_direction_output(IGEP3_GPIO_BT_NRESET, 1) == 0)) {
  336. gpio_export(IGEP3_GPIO_BT_NRESET, 0);
  337. } else
  338. pr_warning("IGEP3: Could not obtain gpio GPIO_BT_NRESET\n");
  339. }
  340. #else
  341. void __init igep3_wifi_bt_init(void) {}
  342. #endif
  343. static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
  344. .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
  345. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  346. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  347. .phy_reset = true,
  348. .reset_gpio_port[0] = -EINVAL,
  349. .reset_gpio_port[1] = IGEP3_GPIO_USBH_NRESET,
  350. .reset_gpio_port[2] = -EINVAL,
  351. };
  352. #ifdef CONFIG_OMAP_MUX
  353. static struct omap_board_mux board_mux[] __initdata = {
  354. OMAP3_MUX(I2C2_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
  355. { .reg_offset = OMAP_MUX_TERMINATOR },
  356. };
  357. #endif
  358. static void __init igep3_init(void)
  359. {
  360. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  361. /* Register I2C busses and drivers */
  362. igep3_i2c_init();
  363. platform_add_devices(igep3_devices, ARRAY_SIZE(igep3_devices));
  364. omap_serial_init();
  365. usb_musb_init(&musb_board_data);
  366. usbhs_init(&usbhs_bdata);
  367. igep3_flash_init();
  368. igep3_leds_init();
  369. /*
  370. * WLAN-BT combo module from MuRata which has a Marvell WLAN
  371. * (88W8686) + CSR Bluetooth chipset. Uses SDIO interface.
  372. */
  373. igep3_wifi_bt_init();
  374. }
  375. MACHINE_START(IGEP0030, "IGEP OMAP3 module")
  376. .boot_params = 0x80000100,
  377. .reserve = omap_reserve,
  378. .map_io = omap3_map_io,
  379. .init_early = igep3_init_early,
  380. .init_irq = omap_init_irq,
  381. .init_machine = igep3_init,
  382. .timer = &omap_timer,
  383. MACHINE_END