board-igep0030.c 12 KB

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