beagle.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * (C) Copyright 2004-2008
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Author :
  6. * Sunil Kumar <sunilsaini05@gmail.com>
  7. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  8. *
  9. * Derived from Beagle Board and 3430 SDP code by
  10. * Richard Woodruff <r-woodruff2@ti.com>
  11. * Syed Mohammed Khasim <khasim@ti.com>
  12. *
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. #include <common.h>
  33. #include <twl4030.h>
  34. #include <asm/io.h>
  35. #include <asm/arch/mux.h>
  36. #include <asm/arch/sys_proto.h>
  37. #include <asm/arch/gpio.h>
  38. #include <asm/mach-types.h>
  39. #include "beagle.h"
  40. /*
  41. * Routine: board_init
  42. * Description: Early hardware init.
  43. */
  44. int board_init(void)
  45. {
  46. DECLARE_GLOBAL_DATA_PTR;
  47. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  48. /* board id for Linux */
  49. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
  50. /* boot param addr */
  51. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  52. return 0;
  53. }
  54. /*
  55. * Routine: get_board_revision
  56. * Description: Detect if we are running on a Beagle revision Ax/Bx,
  57. * C1/2/3, or C4. This can be done by reading
  58. * the level of GPIO173, GPIO172 and GPIO171. This should
  59. * result in
  60. * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  61. * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  62. * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
  63. */
  64. int get_board_revision(void)
  65. {
  66. int revision;
  67. if (!omap_request_gpio(171) &&
  68. !omap_request_gpio(172) &&
  69. !omap_request_gpio(173)) {
  70. omap_set_gpio_direction(171, 1);
  71. omap_set_gpio_direction(172, 1);
  72. omap_set_gpio_direction(173, 1);
  73. revision = omap_get_gpio_datain(173) << 2 |
  74. omap_get_gpio_datain(172) << 1 |
  75. omap_get_gpio_datain(171);
  76. omap_free_gpio(171);
  77. omap_free_gpio(172);
  78. omap_free_gpio(173);
  79. } else {
  80. printf("Error: unable to acquire board revision GPIOs\n");
  81. revision = -1;
  82. }
  83. return revision;
  84. }
  85. /*
  86. * Routine: misc_init_r
  87. * Description: Configure board specific parts
  88. */
  89. int misc_init_r(void)
  90. {
  91. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  92. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  93. switch (get_board_revision()) {
  94. case REVISION_AXBX:
  95. printf("Beagle Rev Ax/Bx\n");
  96. setenv("beaglerev", "AxBx");
  97. setenv("mpurate", "600");
  98. break;
  99. case REVISION_CX:
  100. printf("Beagle Rev C1/C2/C3\n");
  101. setenv("beaglerev", "Cx");
  102. setenv("mpurate", "600");
  103. MUX_BEAGLE_C();
  104. break;
  105. case REVISION_C4:
  106. printf("Beagle Rev C4\n");
  107. setenv("beaglerev", "Cx");
  108. setenv("mpurate", "720");
  109. MUX_BEAGLE_C();
  110. /* Set VAUX2 to 1.8V for EHCI PHY */
  111. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  112. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  113. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  114. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  115. break;
  116. default:
  117. printf("Beagle unknown 0x%02x\n", get_board_revision());
  118. }
  119. twl4030_power_init();
  120. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  121. /* Configure GPIOs to output */
  122. writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  123. writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  124. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  125. /* Set GPIOs */
  126. writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
  127. &gpio6_base->setdataout);
  128. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  129. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  130. dieid_num_r();
  131. return 0;
  132. }
  133. /*
  134. * Routine: set_muxconf_regs
  135. * Description: Setting up the configuration Mux registers specific to the
  136. * hardware. Many pins need to be moved from protect to primary
  137. * mode.
  138. */
  139. void set_muxconf_regs(void)
  140. {
  141. MUX_BEAGLE();
  142. }