synchronousMemoryDatabase.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * linux/arch/arm/mach-sa1100/cpu-sa1110.c
  3. *
  4. * Copyright (C) 2001 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Note: there are two erratas that apply to the SA1110 here:
  11. * 7 - SDRAM auto-power-up failure (rev A0)
  12. * 13 - Corruption of internal register reads/writes following
  13. * SDRAM reads (rev A0, B0, B1)
  14. *
  15. * We ignore rev. A0 and B0 devices; I don't think they're worth supporting.
  16. *
  17. * The SDRAM type can be passed on the command line as cpu_sa1110.sdram=type
  18. */
  19. #include <linux/cpufreq.h>
  20. #include <linux/delay.h>
  21. #include <linux/init.h>
  22. #include <linux/io.h>
  23. #include <linux/kernel.h>
  24. #include <linux/moduleparam.h>
  25. #include <linux/types.h>
  26. #include <asm/cputype.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/hardware.h>
  29. #include "generic.h"
  30. #undef DEBUG
  31. struct sdram_params {
  32. const char name[20];
  33. u_char rows; /* bits */
  34. u_char cas_latency; /* cycles */
  35. u_char tck; /* clock cycle time (ns) */
  36. u_char trcd; /* activate to r/w (ns) */
  37. u_char trp; /* precharge to activate (ns) */
  38. u_char twr; /* write recovery time (ns) */
  39. u_short refresh; /* refresh time for array (us) */
  40. };
  41. struct sdram_info {
  42. u_int mdcnfg;
  43. u_int mdrefr;
  44. u_int mdcas[3];
  45. };
  46. static struct sdram_params sdram_tbl[] __initdata = {
  47. { /* Toshiba TC59SM716 CL2 */
  48. .name = "TC59SM716-CL2",
  49. .rows = 12,
  50. .tck = 10,
  51. .trcd = 20,
  52. .trp = 20,
  53. .twr = 10,
  54. .refresh = 64000,
  55. .cas_latency = 2,
  56. }, { /* Toshiba TC59SM716 CL3 */
  57. .name = "TC59SM716-CL3",
  58. .rows = 12,
  59. .tck = 8,
  60. .trcd = 20,
  61. .trp = 20,
  62. .twr = 8,
  63. .refresh = 64000,
  64. .cas_latency = 3,
  65. }, { /* Samsung K4S641632D TC75 */
  66. .name = "K4S641632D",
  67. .rows = 14,
  68. .tck = 9,
  69. .trcd = 27,
  70. .trp = 20,
  71. .twr = 9,
  72. .refresh = 64000,
  73. .cas_latency = 3,
  74. }, { /* Samsung K4S281632B-1H */
  75. .name = "K4S281632B-1H",
  76. .rows = 12,
  77. .tck = 10,
  78. .trp = 20,
  79. .twr = 10,
  80. .refresh = 64000,
  81. .cas_latency = 3,
  82. }, { /* Samsung KM416S4030CT */
  83. .name = "KM416S4030CT",
  84. .rows = 13,
  85. .tck = 8,
  86. .trcd = 24, /* 3 CLKs */
  87. .trp = 24, /* 3 CLKs */
  88. .twr = 16, /* Trdl: 2 CLKs */
  89. .refresh = 64000,
  90. .cas_latency = 3,
  91. }, { /* Winbond W982516AH75L CL3 */
  92. .name = "W982516AH75L",
  93. .rows = 16,
  94. .tck = 8,
  95. .trcd = 20,
  96. .trp = 20,
  97. .twr = 8,
  98. .refresh = 64000,
  99. .cas_latency = 3,
  100. }, { /* Micron MT48LC8M16A2TG-75 */
  101. .name = "MT48LC8M16A2TG-75",
  102. .rows = 12,
  103. .tck = 8,
  104. .trcd = 20,
  105. .trp = 20,
  106. .twr = 8,
  107. .refresh = 64000,
  108. .cas_latency = 3,
  109. },
  110. };
  111. static struct sdram_params sdram_params;
  112. /*
  113. * Given a period in ns and frequency in khz, calculate the number of
  114. * cycles of frequency in period. Note that we round up to the next
  115. * cycle, even if we are only slightly over.
  116. */
  117. static inline u_int ns_to_cycles(u_int ns, u_int khz)
  118. {
  119. return (ns * khz + 999999) / 1000000;
  120. }