board-omap3logic.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3logic.c
  3. *
  4. * Copyright (C) 2010 Li-Pro.Net
  5. * Stephan Linz <linz@li-pro.net>
  6. *
  7. * Copyright (C) 2010-2012 Logic Product Development, Inc.
  8. * Peter Barada <peter.barada@logicpd.com>
  9. * Ashwin BIhari <ashwin.bihari@logicpd.com>
  10. *
  11. * Modified from Beagle, EVM, and RX51
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/delay.h>
  21. #include <linux/err.h>
  22. #include <linux/clk.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio.h>
  25. #include <linux/regulator/fixed.h>
  26. #include <linux/regulator/machine.h>
  27. #include <linux/i2c/twl.h>
  28. #include <linux/mmc/host.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include "common.h"
  33. #include "mux.h"
  34. #include "hsmmc.h"
  35. #include "control.h"
  36. #include "common-board-devices.h"
  37. #include "gpmc.h"
  38. #include "gpmc-smsc911x.h"
  39. #define OMAP3LOGIC_SMSC911X_CS 1
  40. #define OMAP3530_LV_SOM_MMC_GPIO_CD 110
  41. #define OMAP3530_LV_SOM_MMC_GPIO_WP 126
  42. #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
  43. #define OMAP3_TORPEDO_MMC_GPIO_CD 127
  44. #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
  45. static struct regulator_consumer_supply omap3logic_vmmc1_supply[] = {
  46. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  47. };
  48. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  49. static struct regulator_init_data omap3logic_vmmc1 = {
  50. .constraints = {
  51. .name = "VMMC1",
  52. .min_uV = 1850000,
  53. .max_uV = 3150000,
  54. .valid_modes_mask = REGULATOR_MODE_NORMAL
  55. | REGULATOR_MODE_STANDBY,
  56. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  57. | REGULATOR_CHANGE_MODE
  58. | REGULATOR_CHANGE_STATUS,
  59. },
  60. .num_consumer_supplies = ARRAY_SIZE(omap3logic_vmmc1_supply),
  61. .consumer_supplies = omap3logic_vmmc1_supply,
  62. };
  63. static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
  64. .use_leds = true,
  65. .pullups = BIT(1),
  66. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
  67. | BIT(13) | BIT(15) | BIT(16) | BIT(17),
  68. };
  69. static struct twl4030_usb_data omap3logic_usb_data = {
  70. .usb_mode = T2_USB_MODE_ULPI,
  71. };
  72. static struct twl4030_platform_data omap3logic_twldata = {
  73. /* platform_data for children goes here */
  74. .gpio = &omap3logic_gpio_data,
  75. .vmmc1 = &omap3logic_vmmc1,
  76. .usb = &omap3logic_usb_data,
  77. };
  78. static int __init omap3logic_i2c_init(void)
  79. {
  80. omap3_pmic_init("twl4030", &omap3logic_twldata);
  81. return 0;
  82. }
  83. static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
  84. {
  85. .name = "external",
  86. .mmc = 1,
  87. .caps = MMC_CAP_4_BIT_DATA,
  88. .gpio_cd = -EINVAL,
  89. .gpio_wp = -EINVAL,
  90. },
  91. {} /* Terminator */
  92. };
  93. static void __init board_mmc_init(void)
  94. {
  95. if (machine_is_omap3530_lv_som()) {
  96. /* OMAP3530 LV SOM board */
  97. board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
  98. board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
  99. omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
  100. omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
  101. } else if (machine_is_omap3_torpedo()) {
  102. /* OMAP3 Torpedo board */
  103. board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
  104. omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
  105. } else {
  106. /* unsupported board */
  107. printk(KERN_ERR "%s(): unknown machine type\n", __func__);
  108. return;
  109. }
  110. omap_hsmmc_init(board_mmc_info);
  111. }
  112. static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
  113. .cs = OMAP3LOGIC_SMSC911X_CS,
  114. .gpio_irq = -EINVAL,
  115. .gpio_reset = -EINVAL,
  116. };
  117. /* TODO/FIXME (comment by Peter Barada, LogicPD):
  118. * Fix the PBIAS voltage for Torpedo MMC1 pins that
  119. * are used for other needs (IRQs, etc). */
  120. static void omap3torpedo_fix_pbias_voltage(void)
  121. {
  122. u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
  123. u32 reg;
  124. if (machine_is_omap3_torpedo())
  125. {
  126. /* Set the bias for the pin */
  127. reg = omap_ctrl_readl(control_pbias_offset);
  128. reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
  129. omap_ctrl_writel(reg, control_pbias_offset);
  130. /* 100ms delay required for PBIAS configuration */
  131. msleep(100);
  132. reg |= OMAP343X_PBIASLITEVMODE1;
  133. reg |= OMAP343X_PBIASLITEPWRDNZ1;
  134. omap_ctrl_writel(reg | 0x300, control_pbias_offset);
  135. }
  136. }
  137. static inline void __init board_smsc911x_init(void)
  138. {
  139. if (machine_is_omap3530_lv_som()) {
  140. /* OMAP3530 LV SOM board */
  141. board_smsc911x_data.gpio_irq =
  142. OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
  143. omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
  144. } else if (machine_is_omap3_torpedo()) {
  145. /* OMAP3 Torpedo board */
  146. board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
  147. omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
  148. } else {
  149. /* unsupported board */
  150. printk(KERN_ERR "%s(): unknown machine type\n", __func__);
  151. return;
  152. }
  153. gpmc_smsc911x_init(&board_smsc911x_data);
  154. }
  155. #ifdef CONFIG_OMAP_MUX
  156. static struct omap_board_mux board_mux[] __initdata = {
  157. /* mUSB */
  158. OMAP3_MUX(HSUSB0_CLK, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  159. OMAP3_MUX(HSUSB0_STP, OMAP_MUX_MODE0 | OMAP_PIN_OUTPUT),
  160. OMAP3_MUX(HSUSB0_DIR, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  161. OMAP3_MUX(HSUSB0_NXT, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  162. OMAP3_MUX(HSUSB0_DATA0, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  163. OMAP3_MUX(HSUSB0_DATA1, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  164. OMAP3_MUX(HSUSB0_DATA2, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  165. OMAP3_MUX(HSUSB0_DATA3, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  166. OMAP3_MUX(HSUSB0_DATA4, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  167. OMAP3_MUX(HSUSB0_DATA5, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  168. OMAP3_MUX(HSUSB0_DATA6, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  169. OMAP3_MUX(HSUSB0_DATA7, OMAP_MUX_MODE0 | OMAP_PIN_INPUT),
  170. { .reg_offset = OMAP_MUX_TERMINATOR },
  171. };
  172. #endif
  173. static struct regulator_consumer_supply dummy_supplies[] = {
  174. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  175. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  176. };
  177. static void __init omap3logic_init(void)
  178. {
  179. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  180. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  181. omap3torpedo_fix_pbias_voltage();
  182. omap3logic_i2c_init();
  183. omap_serial_init();
  184. omap_sdrc_init(NULL, NULL);
  185. board_mmc_init();
  186. board_smsc911x_init();
  187. usb_musb_init(NULL);
  188. /* Ensure SDRC pins are mux'd for self-refresh */
  189. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  190. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  191. }
  192. MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
  193. .atag_offset = 0x100,
  194. .reserve = omap_reserve,
  195. .map_io = omap3_map_io,
  196. .init_early = omap35xx_init_early,
  197. .init_irq = omap3_init_irq,
  198. .handle_irq = omap3_intc_handle_irq,
  199. .init_machine = omap3logic_init,
  200. .init_late = omap35xx_init_late,
  201. .timer = &omap3_timer,
  202. .restart = omap_prcm_restart,
  203. MACHINE_END
  204. MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
  205. .atag_offset = 0x100,
  206. .reserve = omap_reserve,
  207. .map_io = omap3_map_io,
  208. .init_early = omap35xx_init_early,
  209. .init_irq = omap3_init_irq,
  210. .handle_irq = omap3_intc_handle_irq,
  211. .init_machine = omap3logic_init,
  212. .init_late = omap35xx_init_late,
  213. .timer = &omap3_timer,
  214. .restart = omap_prcm_restart,
  215. MACHINE_END