board.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/ddr_defs.h>
  22. #include <asm/arch/clock.h>
  23. #include <asm/io.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
  26. struct timer_reg *timerreg = (struct timer_reg *)DM_TIMER2_BASE;
  27. /*
  28. * early system init of muxing and clocks.
  29. */
  30. void s_init(u32 in_ddr)
  31. {
  32. /* WDT1 is already running when the bootloader gets control
  33. * Disable it to avoid "random" resets
  34. */
  35. writel(0xAAAA, &wdtimer->wdtwspr);
  36. while (readl(&wdtimer->wdtwwps) != 0x0)
  37. ;
  38. writel(0x5555, &wdtimer->wdtwspr);
  39. while (readl(&wdtimer->wdtwwps) != 0x0)
  40. ;
  41. /* Setup the PLLs and the clocks for the peripherals */
  42. #ifdef CONFIG_SETUP_PLL
  43. pll_init();
  44. #endif
  45. if (!in_ddr)
  46. config_ddr();
  47. }
  48. /* Initialize timer */
  49. void init_timer(void)
  50. {
  51. /* Reset the Timer */
  52. writel(0x2, (&timerreg->tsicrreg));
  53. /* Wait until the reset is done */
  54. while (readl(&timerreg->tiocpcfgreg) & 1)
  55. ;
  56. /* Start the Timer */
  57. writel(0x1, (&timerreg->tclrreg));
  58. }