memory.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * linux/arch/arm/mach-omap2/memory.c
  3. *
  4. * Memory timing related functions for OMAP24XX
  5. *
  6. * Copyright (C) 2005 Texas Instruments Inc.
  7. * Richard Woodruff <r-woodruff2@ti.com>
  8. *
  9. * Copyright (C) 2005 Nokia Corporation
  10. * Tony Lindgren <tony@atomide.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/device.h>
  19. #include <linux/list.h>
  20. #include <linux/errno.h>
  21. #include <linux/delay.h>
  22. #include <linux/clk.h>
  23. #include <asm/io.h>
  24. #include <asm/arch/clock.h>
  25. #include <asm/arch/sram.h>
  26. #include "prcm-regs.h"
  27. #include "memory.h"
  28. static struct memory_timings mem_timings;
  29. u32 omap2_memory_get_slow_dll_ctrl(void)
  30. {
  31. return mem_timings.slow_dll_ctrl;
  32. }
  33. u32 omap2_memory_get_fast_dll_ctrl(void)
  34. {
  35. return mem_timings.fast_dll_ctrl;
  36. }
  37. u32 omap2_memory_get_type(void)
  38. {
  39. return mem_timings.m_type;
  40. }
  41. void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
  42. {
  43. unsigned long dll_cnt;
  44. u32 fast_dll = 0;
  45. mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
  46. /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
  47. * In the case of 2422, its ok to use CS1 instead of CS0.
  48. */
  49. if (cpu_is_omap2422())
  50. mem_timings.base_cs = 1;
  51. else
  52. mem_timings.base_cs = 0;
  53. if (mem_timings.m_type != M_DDR)
  54. return;
  55. /* With DDR we need to determine the low frequency DLL value */
  56. if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL))
  57. mem_timings.dll_mode = M_UNLOCK;
  58. else
  59. mem_timings.dll_mode = M_LOCK;
  60. if (mem_timings.base_cs == 0) {
  61. fast_dll = SDRC_DLLA_CTRL;
  62. dll_cnt = SDRC_DLLA_STATUS & 0xff00;
  63. } else {
  64. fast_dll = SDRC_DLLB_CTRL;
  65. dll_cnt = SDRC_DLLB_STATUS & 0xff00;
  66. }
  67. if (force_lock_to_unlock_mode) {
  68. fast_dll &= ~0xff00;
  69. fast_dll |= dll_cnt; /* Current lock mode */
  70. }
  71. /* set fast timings with DLL filter disabled */
  72. mem_timings.fast_dll_ctrl = (fast_dll | (3 << 8));
  73. /* No disruptions, DDR will be offline & C-ABI not followed */
  74. omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl,
  75. mem_timings.fast_dll_ctrl,
  76. mem_timings.base_cs,
  77. force_lock_to_unlock_mode);
  78. mem_timings.slow_dll_ctrl &= 0xff00; /* Keep lock value */
  79. /* Turn status into unlock ctrl */
  80. mem_timings.slow_dll_ctrl |=
  81. ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2));
  82. /* 90 degree phase for anything below 133Mhz + disable DLL filter */
  83. mem_timings.slow_dll_ctrl |= ((1 << 1) | (3 << 8));
  84. }