board-igep0020.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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/regulator/machine.h>
  20. #include <linux/i2c/twl.h>
  21. #include <linux/mmc/host.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <plat/board.h>
  25. #include <plat/common.h>
  26. #include <plat/gpmc.h>
  27. #include <plat/usb.h>
  28. #include <plat/display.h>
  29. #include <plat/onenand.h>
  30. #include "mux.h"
  31. #include "hsmmc.h"
  32. #include "sdram-numonyx-m65kxxxxam.h"
  33. #define IGEP2_SMSC911X_CS 5
  34. #define IGEP2_SMSC911X_GPIO 176
  35. #define IGEP2_GPIO_USBH_NRESET 24
  36. #define IGEP2_GPIO_LED0_GREEN 26
  37. #define IGEP2_GPIO_LED0_RED 27
  38. #define IGEP2_GPIO_LED1_RED 28
  39. #define IGEP2_GPIO_DVI_PUP 170
  40. #define IGEP2_GPIO_WIFI_NPD 94
  41. #define IGEP2_GPIO_WIFI_NRESET 95
  42. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  43. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  44. #define ONENAND_MAP 0x20000000
  45. /* NAND04GR4E1A ( 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 igep2_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 int igep2_onenand_setup(void __iomem *onenand_base, int freq)
  80. {
  81. /* nothing is required to be setup for onenand as of now */
  82. return 0;
  83. }
  84. static struct omap_onenand_platform_data igep2_onenand_data = {
  85. .parts = igep2_onenand_partitions,
  86. .nr_parts = ARRAY_SIZE(igep2_onenand_partitions),
  87. .onenand_setup = igep2_onenand_setup,
  88. .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
  89. };
  90. static struct platform_device igep2_onenand_device = {
  91. .name = "omap2-onenand",
  92. .id = -1,
  93. .dev = {
  94. .platform_data = &igep2_onenand_data,
  95. },
  96. };
  97. void __init igep2_flash_init(void)
  98. {
  99. u8 cs = 0;
  100. u8 onenandcs = GPMC_CS_NUM + 1;
  101. while (cs < GPMC_CS_NUM) {
  102. u32 ret = 0;
  103. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  104. /* Check if NAND/oneNAND is configured */
  105. if ((ret & 0xC00) == 0x800)
  106. /* NAND found */
  107. pr_err("IGEP v2: Unsupported NAND found\n");
  108. else {
  109. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
  110. if ((ret & 0x3F) == (ONENAND_MAP >> 24))
  111. /* ONENAND found */
  112. onenandcs = cs;
  113. }
  114. cs++;
  115. }
  116. if (onenandcs > GPMC_CS_NUM) {
  117. pr_err("IGEP v2: Unable to find configuration in GPMC\n");
  118. return;
  119. }
  120. if (onenandcs < GPMC_CS_NUM) {
  121. igep2_onenand_data.cs = onenandcs;
  122. if (platform_device_register(&igep2_onenand_device) < 0)
  123. pr_err("IGEP v2: Unable to register OneNAND device\n");
  124. }
  125. }
  126. #else
  127. void __init igep2_flash_init(void) {}
  128. #endif
  129. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  130. #include <linux/smsc911x.h>
  131. static struct smsc911x_platform_config igep2_smsc911x_config = {
  132. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  133. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  134. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
  135. .phy_interface = PHY_INTERFACE_MODE_MII,
  136. };
  137. static struct resource igep2_smsc911x_resources[] = {
  138. {
  139. .flags = IORESOURCE_MEM,
  140. },
  141. {
  142. .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
  143. .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
  144. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  145. },
  146. };
  147. static struct platform_device igep2_smsc911x_device = {
  148. .name = "smsc911x",
  149. .id = 0,
  150. .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
  151. .resource = igep2_smsc911x_resources,
  152. .dev = {
  153. .platform_data = &igep2_smsc911x_config,
  154. },
  155. };
  156. static inline void __init igep2_init_smsc911x(void)
  157. {
  158. unsigned long cs_mem_base;
  159. if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
  160. pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
  161. gpmc_cs_free(IGEP2_SMSC911X_CS);
  162. return;
  163. }
  164. igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
  165. igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
  166. if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
  167. (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
  168. gpio_export(IGEP2_SMSC911X_GPIO, 0);
  169. } else {
  170. pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
  171. return;
  172. }
  173. platform_device_register(&igep2_smsc911x_device);
  174. }
  175. #else
  176. static inline void __init igep2_init_smsc911x(void) { }
  177. #endif
  178. static struct omap_board_config_kernel igep2_config[] __initdata = {
  179. };
  180. static struct regulator_consumer_supply igep2_vmmc1_supply = {
  181. .supply = "vmmc",
  182. };
  183. static struct regulator_consumer_supply igep2_vmmc2_supply = {
  184. .supply = "vmmc",
  185. };
  186. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  187. static struct regulator_init_data igep2_vmmc1 = {
  188. .constraints = {
  189. .min_uV = 1850000,
  190. .max_uV = 3150000,
  191. .valid_modes_mask = REGULATOR_MODE_NORMAL
  192. | REGULATOR_MODE_STANDBY,
  193. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  194. | REGULATOR_CHANGE_MODE
  195. | REGULATOR_CHANGE_STATUS,
  196. },
  197. .num_consumer_supplies = 1,
  198. .consumer_supplies = &igep2_vmmc1_supply,
  199. };
  200. /* VMMC2 for OMAP VDD_MMC2 (i/o) and MMC2 WIFI */
  201. static struct regulator_init_data igep2_vmmc2 = {
  202. .constraints = {
  203. .min_uV = 1850000,
  204. .max_uV = 3150000,
  205. .valid_modes_mask = REGULATOR_MODE_NORMAL
  206. | REGULATOR_MODE_STANDBY,
  207. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  208. | REGULATOR_CHANGE_MODE
  209. | REGULATOR_CHANGE_STATUS,
  210. },
  211. .num_consumer_supplies = 1,
  212. .consumer_supplies = &igep2_vmmc2_supply,
  213. };
  214. static struct omap2_hsmmc_info mmc[] = {
  215. {
  216. .mmc = 1,
  217. .caps = MMC_CAP_4_BIT_DATA,
  218. .gpio_cd = -EINVAL,
  219. .gpio_wp = -EINVAL,
  220. },
  221. {
  222. .mmc = 2,
  223. .caps = MMC_CAP_4_BIT_DATA,
  224. .gpio_cd = -EINVAL,
  225. .gpio_wp = -EINVAL,
  226. },
  227. {} /* Terminator */
  228. };
  229. static int igep2_twl_gpio_setup(struct device *dev,
  230. unsigned gpio, unsigned ngpio)
  231. {
  232. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  233. mmc[0].gpio_cd = gpio + 0;
  234. omap2_hsmmc_init(mmc);
  235. /* link regulators to MMC adapters ... we "know" the
  236. * regulators will be set up only *after* we return.
  237. */
  238. igep2_vmmc1_supply.dev = mmc[0].dev;
  239. igep2_vmmc2_supply.dev = mmc[1].dev;
  240. return 0;
  241. };
  242. static struct twl4030_gpio_platform_data igep2_gpio_data = {
  243. .gpio_base = OMAP_MAX_GPIO_LINES,
  244. .irq_base = TWL4030_GPIO_IRQ_BASE,
  245. .irq_end = TWL4030_GPIO_IRQ_END,
  246. .use_leds = false,
  247. .setup = igep2_twl_gpio_setup,
  248. };
  249. static struct twl4030_usb_data igep2_usb_data = {
  250. .usb_mode = T2_USB_MODE_ULPI,
  251. };
  252. static int igep2_enable_dvi(struct omap_dss_device *dssdev)
  253. {
  254. gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1);
  255. return 0;
  256. }
  257. static void igep2_disable_dvi(struct omap_dss_device *dssdev)
  258. {
  259. gpio_direction_output(IGEP2_GPIO_DVI_PUP, 0);
  260. }
  261. static struct omap_dss_device igep2_dvi_device = {
  262. .type = OMAP_DISPLAY_TYPE_DPI,
  263. .name = "dvi",
  264. .driver_name = "generic_panel",
  265. .phy.dpi.data_lines = 24,
  266. .platform_enable = igep2_enable_dvi,
  267. .platform_disable = igep2_disable_dvi,
  268. };
  269. static struct omap_dss_device *igep2_dss_devices[] = {
  270. &igep2_dvi_device
  271. };
  272. static struct omap_dss_board_info igep2_dss_data = {
  273. .num_devices = ARRAY_SIZE(igep2_dss_devices),
  274. .devices = igep2_dss_devices,
  275. .default_device = &igep2_dvi_device,
  276. };
  277. static struct platform_device igep2_dss_device = {
  278. .name = "omapdss",
  279. .id = -1,
  280. .dev = {
  281. .platform_data = &igep2_dss_data,
  282. },
  283. };
  284. static struct regulator_consumer_supply igep2_vpll2_supply = {
  285. .supply = "vdds_dsi",
  286. .dev = &igep2_dss_device.dev,
  287. };
  288. static struct regulator_init_data igep2_vpll2 = {
  289. .constraints = {
  290. .name = "VDVI",
  291. .min_uV = 1800000,
  292. .max_uV = 1800000,
  293. .apply_uV = true,
  294. .valid_modes_mask = REGULATOR_MODE_NORMAL
  295. | REGULATOR_MODE_STANDBY,
  296. .valid_ops_mask = REGULATOR_CHANGE_MODE
  297. | REGULATOR_CHANGE_STATUS,
  298. },
  299. .num_consumer_supplies = 1,
  300. .consumer_supplies = &igep2_vpll2_supply,
  301. };
  302. static void __init igep2_display_init(void)
  303. {
  304. if (gpio_request(IGEP2_GPIO_DVI_PUP, "GPIO_DVI_PUP") &&
  305. gpio_direction_output(IGEP2_GPIO_DVI_PUP, 1))
  306. pr_err("IGEP v2: Could not obtain gpio GPIO_DVI_PUP\n");
  307. }
  308. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  309. #include <linux/leds.h>
  310. static struct gpio_led igep2_gpio_leds[] = {
  311. {
  312. .name = "led0:red",
  313. .gpio = IGEP2_GPIO_LED0_RED,
  314. },
  315. {
  316. .name = "led0:green",
  317. .default_trigger = "heartbeat",
  318. .gpio = IGEP2_GPIO_LED0_GREEN,
  319. },
  320. {
  321. .name = "led1:red",
  322. .gpio = IGEP2_GPIO_LED1_RED,
  323. },
  324. };
  325. static struct gpio_led_platform_data igep2_led_pdata = {
  326. .leds = igep2_gpio_leds,
  327. .num_leds = ARRAY_SIZE(igep2_gpio_leds),
  328. };
  329. static struct platform_device igep2_led_device = {
  330. .name = "leds-gpio",
  331. .id = -1,
  332. .dev = {
  333. .platform_data = &igep2_led_pdata,
  334. },
  335. };
  336. static void __init igep2_init_led(void)
  337. {
  338. platform_device_register(&igep2_led_device);
  339. }
  340. #else
  341. static inline void igep2_init_led(void) {}
  342. #endif
  343. static struct platform_device *igep2_devices[] __initdata = {
  344. &igep2_dss_device,
  345. };
  346. static void __init igep2_init_irq(void)
  347. {
  348. omap_board_config = igep2_config;
  349. omap_board_config_size = ARRAY_SIZE(igep2_config);
  350. omap2_init_common_hw(m65kxxxxam_sdrc_params, m65kxxxxam_sdrc_params);
  351. omap_init_irq();
  352. omap_gpio_init();
  353. }
  354. static struct twl4030_codec_audio_data igep2_audio_data = {
  355. .audio_mclk = 26000000,
  356. };
  357. static struct twl4030_codec_data igep2_codec_data = {
  358. .audio_mclk = 26000000,
  359. .audio = &igep2_audio_data,
  360. };
  361. static struct twl4030_platform_data igep2_twldata = {
  362. .irq_base = TWL4030_IRQ_BASE,
  363. .irq_end = TWL4030_IRQ_END,
  364. /* platform_data for children goes here */
  365. .usb = &igep2_usb_data,
  366. .codec = &igep2_codec_data,
  367. .gpio = &igep2_gpio_data,
  368. .vmmc1 = &igep2_vmmc1,
  369. .vmmc2 = &igep2_vmmc2,
  370. .vpll2 = &igep2_vpll2,
  371. };
  372. static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
  373. {
  374. I2C_BOARD_INFO("twl4030", 0x48),
  375. .flags = I2C_CLIENT_WAKE,
  376. .irq = INT_34XX_SYS_NIRQ,
  377. .platform_data = &igep2_twldata,
  378. },
  379. };
  380. static int __init igep2_i2c_init(void)
  381. {
  382. omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
  383. ARRAY_SIZE(igep2_i2c_boardinfo));
  384. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  385. * projector don't work reliably with 400kHz */
  386. omap_register_i2c_bus(3, 100, NULL, 0);
  387. return 0;
  388. }
  389. static struct omap_musb_board_data musb_board_data = {
  390. .interface_type = MUSB_INTERFACE_ULPI,
  391. .mode = MUSB_OTG,
  392. .power = 100,
  393. };
  394. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  395. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  396. .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  397. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  398. .phy_reset = true,
  399. .reset_gpio_port[0] = IGEP2_GPIO_USBH_NRESET,
  400. .reset_gpio_port[1] = -EINVAL,
  401. .reset_gpio_port[2] = -EINVAL,
  402. };
  403. #ifdef CONFIG_OMAP_MUX
  404. static struct omap_board_mux board_mux[] __initdata = {
  405. { .reg_offset = OMAP_MUX_TERMINATOR },
  406. };
  407. #else
  408. #define board_mux NULL
  409. #endif
  410. static void __init igep2_init(void)
  411. {
  412. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  413. igep2_i2c_init();
  414. platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
  415. omap_serial_init();
  416. usb_musb_init(&musb_board_data);
  417. usb_ehci_init(&ehci_pdata);
  418. igep2_flash_init();
  419. igep2_init_led();
  420. igep2_display_init();
  421. igep2_init_smsc911x();
  422. /* GPIO userspace leds */
  423. #if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
  424. if ((gpio_request(IGEP2_GPIO_LED0_RED, "led0:red") == 0) &&
  425. (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
  426. gpio_export(IGEP2_GPIO_LED0_RED, 0);
  427. gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
  428. } else
  429. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
  430. if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "led0:green") == 0) &&
  431. (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
  432. gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
  433. gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
  434. } else
  435. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
  436. if ((gpio_request(IGEP2_GPIO_LED1_RED, "led1:red") == 0) &&
  437. (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
  438. gpio_export(IGEP2_GPIO_LED1_RED, 0);
  439. gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
  440. } else
  441. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
  442. #endif
  443. /* GPIO W-LAN + Bluetooth combo module */
  444. if ((gpio_request(IGEP2_GPIO_WIFI_NPD, "GPIO_WIFI_NPD") == 0) &&
  445. (gpio_direction_output(IGEP2_GPIO_WIFI_NPD, 1) == 0)) {
  446. gpio_export(IGEP2_GPIO_WIFI_NPD, 0);
  447. /* gpio_set_value(IGEP2_GPIO_WIFI_NPD, 0); */
  448. } else
  449. pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NPD\n");
  450. if ((gpio_request(IGEP2_GPIO_WIFI_NRESET, "GPIO_WIFI_NRESET") == 0) &&
  451. (gpio_direction_output(IGEP2_GPIO_WIFI_NRESET, 1) == 0)) {
  452. gpio_export(IGEP2_GPIO_WIFI_NRESET, 0);
  453. gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 0);
  454. udelay(10);
  455. gpio_set_value(IGEP2_GPIO_WIFI_NRESET, 1);
  456. } else
  457. pr_warning("IGEP v2: Could not obtain gpio GPIO_WIFI_NRESET\n");
  458. }
  459. MACHINE_START(IGEP0020, "IGEP v2 board")
  460. .phys_io = 0x48000000,
  461. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  462. .boot_params = 0x80000100,
  463. .map_io = omap3_map_io,
  464. .reserve = omap_reserve,
  465. .init_irq = igep2_init_irq,
  466. .init_machine = igep2_init,
  467. .timer = &omap_timer,
  468. MACHINE_END