board-igep0020.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 "mux.h"
  28. #include "mmc-twl4030.h"
  29. #define IGEP2_SMSC911X_CS 5
  30. #define IGEP2_SMSC911X_GPIO 176
  31. #define IGEP2_GPIO_USBH_NRESET 24
  32. #define IGEP2_GPIO_LED0_RED 26
  33. #define IGEP2_GPIO_LED0_GREEN 27
  34. #define IGEP2_GPIO_LED1_RED 28
  35. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  36. #include <linux/smsc911x.h>
  37. static struct smsc911x_platform_config igep2_smsc911x_config = {
  38. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  39. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  40. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS ,
  41. .phy_interface = PHY_INTERFACE_MODE_MII,
  42. };
  43. static struct resource igep2_smsc911x_resources[] = {
  44. {
  45. .flags = IORESOURCE_MEM,
  46. },
  47. {
  48. .start = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
  49. .end = OMAP_GPIO_IRQ(IGEP2_SMSC911X_GPIO),
  50. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  51. },
  52. };
  53. static struct platform_device igep2_smsc911x_device = {
  54. .name = "smsc911x",
  55. .id = 0,
  56. .num_resources = ARRAY_SIZE(igep2_smsc911x_resources),
  57. .resource = igep2_smsc911x_resources,
  58. .dev = {
  59. .platform_data = &igep2_smsc911x_config,
  60. },
  61. };
  62. static inline void __init igep2_init_smsc911x(void)
  63. {
  64. unsigned long cs_mem_base;
  65. if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
  66. pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
  67. gpmc_cs_free(IGEP2_SMSC911X_CS);
  68. return;
  69. }
  70. igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
  71. igep2_smsc911x_resources[0].end = cs_mem_base + 0xff;
  72. if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
  73. (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
  74. gpio_export(IGEP2_SMSC911X_GPIO, 0);
  75. } else {
  76. pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
  77. return;
  78. }
  79. platform_device_register(&igep2_smsc911x_device);
  80. }
  81. #else
  82. static inline void __init igep2_init_smsc911x(void) { }
  83. #endif
  84. static struct omap_board_config_kernel igep2_config[] __initdata = {
  85. };
  86. static struct regulator_consumer_supply igep2_vmmc1_supply = {
  87. .supply = "vmmc",
  88. };
  89. /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
  90. static struct regulator_init_data igep2_vmmc1 = {
  91. .constraints = {
  92. .min_uV = 1850000,
  93. .max_uV = 3150000,
  94. .valid_modes_mask = REGULATOR_MODE_NORMAL
  95. | REGULATOR_MODE_STANDBY,
  96. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  97. | REGULATOR_CHANGE_MODE
  98. | REGULATOR_CHANGE_STATUS,
  99. },
  100. .num_consumer_supplies = 1,
  101. .consumer_supplies = &igep2_vmmc1_supply,
  102. };
  103. static struct twl4030_hsmmc_info mmc[] = {
  104. {
  105. .mmc = 1,
  106. .wires = 4,
  107. .gpio_cd = -EINVAL,
  108. .gpio_wp = -EINVAL,
  109. },
  110. {
  111. .mmc = 2,
  112. .wires = 4,
  113. .gpio_cd = -EINVAL,
  114. .gpio_wp = -EINVAL,
  115. },
  116. {} /* Terminator */
  117. };
  118. static int igep2_twl_gpio_setup(struct device *dev,
  119. unsigned gpio, unsigned ngpio)
  120. {
  121. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  122. mmc[0].gpio_cd = gpio + 0;
  123. twl4030_mmc_init(mmc);
  124. /* link regulators to MMC adapters ... we "know" the
  125. * regulators will be set up only *after* we return.
  126. */
  127. igep2_vmmc1_supply.dev = mmc[0].dev;
  128. return 0;
  129. };
  130. static struct twl4030_gpio_platform_data igep2_gpio_data = {
  131. .gpio_base = OMAP_MAX_GPIO_LINES,
  132. .irq_base = TWL4030_GPIO_IRQ_BASE,
  133. .irq_end = TWL4030_GPIO_IRQ_END,
  134. .use_leds = false,
  135. .setup = igep2_twl_gpio_setup,
  136. };
  137. static struct twl4030_usb_data igep2_usb_data = {
  138. .usb_mode = T2_USB_MODE_ULPI,
  139. };
  140. static void __init igep2_init_irq(void)
  141. {
  142. omap_board_config = igep2_config;
  143. omap_board_config_size = ARRAY_SIZE(igep2_config);
  144. omap2_init_common_hw(NULL, NULL);
  145. omap_init_irq();
  146. omap_gpio_init();
  147. }
  148. static struct twl4030_platform_data igep2_twldata = {
  149. .irq_base = TWL4030_IRQ_BASE,
  150. .irq_end = TWL4030_IRQ_END,
  151. /* platform_data for children goes here */
  152. .usb = &igep2_usb_data,
  153. .gpio = &igep2_gpio_data,
  154. .vmmc1 = &igep2_vmmc1,
  155. };
  156. static struct i2c_board_info __initdata igep2_i2c_boardinfo[] = {
  157. {
  158. I2C_BOARD_INFO("twl4030", 0x48),
  159. .flags = I2C_CLIENT_WAKE,
  160. .irq = INT_34XX_SYS_NIRQ,
  161. .platform_data = &igep2_twldata,
  162. },
  163. };
  164. static int __init igep2_i2c_init(void)
  165. {
  166. omap_register_i2c_bus(1, 2600, igep2_i2c_boardinfo,
  167. ARRAY_SIZE(igep2_i2c_boardinfo));
  168. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  169. * projector don't work reliably with 400kHz */
  170. omap_register_i2c_bus(3, 100, NULL, 0);
  171. return 0;
  172. }
  173. #ifdef CONFIG_OMAP_MUX
  174. static struct omap_board_mux board_mux[] __initdata = {
  175. { .reg_offset = OMAP_MUX_TERMINATOR },
  176. };
  177. #else
  178. #define board_mux NULL
  179. #endif
  180. static void __init igep2_init(void)
  181. {
  182. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  183. igep2_i2c_init();
  184. omap_serial_init();
  185. usb_musb_init();
  186. igep2_init_smsc911x();
  187. /* GPIO userspace leds */
  188. if ((gpio_request(IGEP2_GPIO_LED0_RED, "GPIO_LED0_RED") == 0) &&
  189. (gpio_direction_output(IGEP2_GPIO_LED0_RED, 1) == 0)) {
  190. gpio_export(IGEP2_GPIO_LED0_RED, 0);
  191. gpio_set_value(IGEP2_GPIO_LED0_RED, 0);
  192. } else
  193. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_RED\n");
  194. if ((gpio_request(IGEP2_GPIO_LED0_GREEN, "GPIO_LED0_GREEN") == 0) &&
  195. (gpio_direction_output(IGEP2_GPIO_LED0_GREEN, 1) == 0)) {
  196. gpio_export(IGEP2_GPIO_LED0_GREEN, 0);
  197. gpio_set_value(IGEP2_GPIO_LED0_GREEN, 0);
  198. } else
  199. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED0_GREEN\n");
  200. if ((gpio_request(IGEP2_GPIO_LED1_RED, "GPIO_LED1_RED") == 0) &&
  201. (gpio_direction_output(IGEP2_GPIO_LED1_RED, 1) == 0)) {
  202. gpio_export(IGEP2_GPIO_LED1_RED, 0);
  203. gpio_set_value(IGEP2_GPIO_LED1_RED, 0);
  204. } else
  205. pr_warning("IGEP v2: Could not obtain gpio GPIO_LED1_RED\n");
  206. }
  207. static void __init igep2_map_io(void)
  208. {
  209. omap2_set_globals_343x();
  210. omap2_map_common_io();
  211. }
  212. MACHINE_START(IGEP0020, "IGEP v2 board")
  213. .phys_io = 0x48000000,
  214. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  215. .boot_params = 0x80000100,
  216. .map_io = igep2_map_io,
  217. .init_irq = igep2_init_irq,
  218. .init_machine = igep2_init,
  219. .timer = &omap_timer,
  220. MACHINE_END