clocks-init.c 2.4 KB

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