clocks-init.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * arch/blackfin/mach-common/clocks-init.c - reprogram clocks / memory
  3. *
  4. * Copyright 2004-2008 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/linkage.h>
  9. #include <linux/init.h>
  10. #include <asm/blackfin.h>
  11. #include <asm/dma.h>
  12. #include <asm/clocks.h>
  13. #include <asm/mem_init.h>
  14. #define PLL_CTL_VAL \
  15. (((CONFIG_VCO_MULT & 63) << 9) | CLKIN_HALF | \
  16. (PLL_BYPASS << 8) | (ANOMALY_05000265 ? 0x8000 : 0))
  17. __attribute__((l1_text))
  18. static void do_sync(void)
  19. {
  20. __builtin_bfin_ssync();
  21. }
  22. __attribute__((l1_text))
  23. void init_clocks(void)
  24. {
  25. /* Kill any active DMAs as they may trigger external memory accesses
  26. * in the middle of reprogramming things, and that'll screw us up.
  27. * For example, any automatic DMAs left by U-Boot for splash screens.
  28. */
  29. size_t i;
  30. for (i = 0; i < MAX_DMA_CHANNELS; ++i) {
  31. struct dma_register *dma = dma_io_base_addr[i];
  32. dma->cfg = 0;
  33. }
  34. do_sync();
  35. #ifdef SIC_IWR0
  36. bfin_write_SIC_IWR0(IWR_ENABLE(0));
  37. # ifdef SIC_IWR1
  38. /* BF52x system reset does not properly reset SIC_IWR1 which
  39. * will screw up the bootrom as it relies on MDMA0/1 waking it
  40. * up from IDLE instructions. See this report for more info:
  41. * http://blackfin.uclinux.org/gf/tracker/4323
  42. */
  43. if (ANOMALY_05000435)
  44. bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));
  45. else
  46. bfin_write_SIC_IWR1(IWR_DISABLE_ALL);
  47. # endif
  48. # ifdef SIC_IWR2
  49. bfin_write_SIC_IWR2(IWR_DISABLE_ALL);
  50. # endif
  51. #else
  52. bfin_write_SIC_IWR(IWR_ENABLE(0));
  53. #endif
  54. do_sync();
  55. #ifdef EBIU_SDGCTL
  56. bfin_write_EBIU_SDGCTL(bfin_read_EBIU_SDGCTL() | SRFS);
  57. do_sync();
  58. #endif
  59. #ifdef CLKBUFOE
  60. bfin_write16(VR_CTL, bfin_read_VR_CTL() | CLKBUFOE);
  61. do_sync();
  62. __asm__ __volatile__("IDLE;");
  63. #endif
  64. bfin_write_PLL_LOCKCNT(0x300);
  65. do_sync();
  66. bfin_write16(PLL_CTL, PLL_CTL_VAL);
  67. __asm__ __volatile__("IDLE;");
  68. bfin_write_PLL_DIV(CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
  69. #ifdef EBIU_SDGCTL
  70. bfin_write_EBIU_SDRRC(mem_SDRRC);
  71. bfin_write_EBIU_SDGCTL(mem_SDGCTL);
  72. #else
  73. bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ));
  74. do_sync();
  75. bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() | 0x1);
  76. bfin_write_EBIU_DDRCTL0(mem_DDRCTL0);
  77. bfin_write_EBIU_DDRCTL1(mem_DDRCTL1);
  78. bfin_write_EBIU_DDRCTL2(mem_DDRCTL2);
  79. #ifdef CONFIG_MEM_EBIU_DDRQUE
  80. bfin_write_EBIU_DDRQUE(CONFIG_MEM_EBIU_DDRQUE);
  81. #endif
  82. #endif
  83. do_sync();
  84. bfin_read16(0);
  85. }