board-omap3logic.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 Logic Product Development, Inc.
  8. * Peter Barada <peter.barada@logicpd.com>
  9. *
  10. * Modified from Beagle, EVM, and RX51
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/delay.h>
  20. #include <linux/err.h>
  21. #include <linux/clk.h>
  22. #include <linux/io.h>
  23. #include <linux/gpio.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/i2c/twl.h>
  26. #include <linux/mmc/host.h>
  27. #include <mach/hardware.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include "mux.h"
  32. #include "hsmmc.h"
  33. #include "timer-gp.h"
  34. #include "control.h"
  35. #include "common-board-devices.h"
  36. #include <plat/mux.h>
  37. #include <plat/board.h>
  38. #include <plat/common.h>
  39. #include <plat/gpmc-smsc911x.h>
  40. #include <plat/gpmc.h>
  41. #include <plat/sdrc.h>
  42. #define OMAP3LOGIC_SMSC911X_CS 1
  43. #define OMAP3530_LV_SOM_MMC_GPIO_CD 110
  44. #define OMAP3530_LV_SOM_MMC_GPIO_WP 126
  45. #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152
  46. #define OMAP3_TORPEDO_MMC_GPIO_CD 127
  47. #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129
  48. static struct regulator_consumer_supply omap3logic_vmmc1_supply = {
  49. .supply = "vmmc",
  50. };
  51. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  52. static struct regulator_init_data omap3logic_vmmc1 = {
  53. .constraints = {
  54. .name = "VMMC1",
  55. .min_uV = 1850000,
  56. .max_uV = 3150000,
  57. .valid_modes_mask = REGULATOR_MODE_NORMAL
  58. | REGULATOR_MODE_STANDBY,
  59. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  60. | REGULATOR_CHANGE_MODE
  61. | REGULATOR_CHANGE_STATUS,
  62. },
  63. .num_consumer_supplies = 1,
  64. .consumer_supplies = &omap3logic_vmmc1_supply,
  65. };
  66. static struct twl4030_gpio_platform_data omap3logic_gpio_data = {
  67. .gpio_base = OMAP_MAX_GPIO_LINES,
  68. .irq_base = TWL4030_GPIO_IRQ_BASE,
  69. .irq_end = TWL4030_GPIO_IRQ_END,
  70. .use_leds = true,
  71. .pullups = BIT(1),
  72. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8)
  73. | BIT(13) | BIT(15) | BIT(16) | BIT(17),
  74. };
  75. static struct twl4030_platform_data omap3logic_twldata = {
  76. .irq_base = TWL4030_IRQ_BASE,
  77. .irq_end = TWL4030_IRQ_END,
  78. /* platform_data for children goes here */
  79. .gpio = &omap3logic_gpio_data,
  80. .vmmc1 = &omap3logic_vmmc1,
  81. };
  82. static int __init omap3logic_i2c_init(void)
  83. {
  84. omap3_pmic_init("twl4030", &omap3logic_twldata);
  85. return 0;
  86. }
  87. static struct omap2_hsmmc_info __initdata board_mmc_info[] = {
  88. {
  89. .name = "external",
  90. .mmc = 1,
  91. .caps = MMC_CAP_4_BIT_DATA,
  92. .gpio_cd = -EINVAL,
  93. .gpio_wp = -EINVAL,
  94. },
  95. {} /* Terminator */
  96. };
  97. static void __init board_mmc_init(void)
  98. {
  99. if (machine_is_omap3530_lv_som()) {
  100. /* OMAP3530 LV SOM board */
  101. board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD;
  102. board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP;
  103. omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT);
  104. omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT);
  105. } else if (machine_is_omap3_torpedo()) {
  106. /* OMAP3 Torpedo board */
  107. board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD;
  108. omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT);
  109. } else {
  110. /* unsupported board */
  111. printk(KERN_ERR "%s(): unknown machine type\n", __func__);
  112. return;
  113. }
  114. omap2_hsmmc_init(board_mmc_info);
  115. /* link regulators to MMC adapters */
  116. omap3logic_vmmc1_supply.dev = board_mmc_info[0].dev;
  117. }
  118. static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
  119. .cs = OMAP3LOGIC_SMSC911X_CS,
  120. .gpio_irq = -EINVAL,
  121. .gpio_reset = -EINVAL,
  122. };
  123. /* TODO/FIXME (comment by Peter Barada, LogicPD):
  124. * Fix the PBIAS voltage for Torpedo MMC1 pins that
  125. * are used for other needs (IRQs, etc). */
  126. static void omap3torpedo_fix_pbias_voltage(void)
  127. {
  128. u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE;
  129. u32 reg;
  130. if (machine_is_omap3_torpedo())
  131. {
  132. /* Set the bias for the pin */
  133. reg = omap_ctrl_readl(control_pbias_offset);
  134. reg &= ~OMAP343X_PBIASLITEPWRDNZ1;
  135. omap_ctrl_writel(reg, control_pbias_offset);
  136. /* 100ms delay required for PBIAS configuration */
  137. msleep(100);
  138. reg |= OMAP343X_PBIASLITEVMODE1;
  139. reg |= OMAP343X_PBIASLITEPWRDNZ1;
  140. omap_ctrl_writel(reg | 0x300, control_pbias_offset);
  141. }
  142. }
  143. static inline void __init board_smsc911x_init(void)
  144. {
  145. if (machine_is_omap3530_lv_som()) {
  146. /* OMAP3530 LV SOM board */
  147. board_smsc911x_data.gpio_irq =
  148. OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ;
  149. omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT);
  150. } else if (machine_is_omap3_torpedo()) {
  151. /* OMAP3 Torpedo board */
  152. board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ;
  153. omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT);
  154. } else {
  155. /* unsupported board */
  156. printk(KERN_ERR "%s(): unknown machine type\n", __func__);
  157. return;
  158. }
  159. gpmc_smsc911x_init(&board_smsc911x_data);
  160. }
  161. static void __init omap3logic_init_early(void)
  162. {
  163. omap2_init_common_infrastructure();
  164. omap2_init_common_devices(NULL, NULL);
  165. }
  166. #ifdef CONFIG_OMAP_MUX
  167. static struct omap_board_mux board_mux[] __initdata = {
  168. { .reg_offset = OMAP_MUX_TERMINATOR },
  169. };
  170. #endif
  171. static void __init omap3logic_init(void)
  172. {
  173. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  174. omap3torpedo_fix_pbias_voltage();
  175. omap3logic_i2c_init();
  176. omap_serial_init();
  177. board_mmc_init();
  178. board_smsc911x_init();
  179. /* Ensure SDRC pins are mux'd for self-refresh */
  180. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  181. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  182. }
  183. MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
  184. .boot_params = 0x80000100,
  185. .map_io = omap3_map_io,
  186. .init_early = omap3logic_init_early,
  187. .init_irq = omap_init_irq,
  188. .init_machine = omap3logic_init,
  189. .timer = &omap_timer,
  190. MACHINE_END
  191. MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
  192. .boot_params = 0x80000100,
  193. .map_io = omap3_map_io,
  194. .init_early = omap3logic_init_early,
  195. .init_irq = omap_init_irq,
  196. .init_machine = omap3logic_init,
  197. .timer = &omap_timer,
  198. MACHINE_END