board-igep0020.c 14 KB

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