board.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * board.c
  3. *
  4. * Common board functions for AM33XX based boards
  5. *
  6. * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <common.h>
  19. #include <asm/arch/cpu.h>
  20. #include <asm/arch/hardware.h>
  21. #include <asm/arch/omap.h>
  22. #include <asm/arch/ddr_defs.h>
  23. #include <asm/arch/clock.h>
  24. #include <asm/arch/gpio.h>
  25. #include <asm/arch/mmc_host_def.h>
  26. #include <asm/arch/common_def.h>
  27. #include <asm/io.h>
  28. #include <asm/omap_common.h>
  29. #include <asm/emif.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
  32. struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
  33. struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
  34. static const struct gpio_bank gpio_bank_am33xx[4] = {
  35. { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
  36. { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
  37. { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
  38. { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
  39. };
  40. const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
  41. /* UART Defines */
  42. #ifdef CONFIG_SPL_BUILD
  43. #define UART_RESET (0x1 << 1)
  44. #define UART_CLK_RUNNING_MASK 0x1
  45. #define UART_SMART_IDLE_EN (0x1 << 0x3)
  46. #endif
  47. #ifdef CONFIG_SPL_BUILD
  48. /* Initialize timer */
  49. static void init_timer(void)
  50. {
  51. /* Reset the Timer */
  52. writel(0x2, (&timer_base->tscir));
  53. /* Wait until the reset is done */
  54. while (readl(&timer_base->tiocp_cfg) & 1)
  55. ;
  56. /* Start the Timer */
  57. writel(0x1, (&timer_base->tclr));
  58. }
  59. #endif
  60. /*
  61. * early system init of muxing and clocks.
  62. */
  63. void s_init(void)
  64. {
  65. /* WDT1 is already running when the bootloader gets control
  66. * Disable it to avoid "random" resets
  67. */
  68. writel(0xAAAA, &wdtimer->wdtwspr);
  69. while (readl(&wdtimer->wdtwwps) != 0x0)
  70. ;
  71. writel(0x5555, &wdtimer->wdtwspr);
  72. while (readl(&wdtimer->wdtwwps) != 0x0)
  73. ;
  74. #ifdef CONFIG_SPL_BUILD
  75. /* Setup the PLLs and the clocks for the peripherals */
  76. pll_init();
  77. /* UART softreset */
  78. u32 regVal;
  79. enable_uart0_pin_mux();
  80. regVal = readl(&uart_base->uartsyscfg);
  81. regVal |= UART_RESET;
  82. writel(regVal, &uart_base->uartsyscfg);
  83. while ((readl(&uart_base->uartsyssts) &
  84. UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
  85. ;
  86. /* Disable smart idle */
  87. regVal = readl(&uart_base->uartsyscfg);
  88. regVal |= UART_SMART_IDLE_EN;
  89. writel(regVal, &uart_base->uartsyscfg);
  90. /* Initialize the Timer */
  91. init_timer();
  92. preloader_console_init();
  93. config_ddr(EMIF_REG_SDRAM_TYPE_DDR2);
  94. #endif
  95. /* Enable MMC0 */
  96. enable_mmc0_pin_mux();
  97. }
  98. #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
  99. int board_mmc_init(bd_t *bis)
  100. {
  101. return omap_mmc_init(0, 0, 0);
  102. }
  103. #endif
  104. void setup_clocks_for_console(void)
  105. {
  106. /* Not yet implemented */
  107. return;
  108. }