summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2007-10-08 05:11:15 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2007-10-08 05:11:15 +0000
commit7569420e54564a12dd92219b95b9d5f87a7bd466 (patch)
tree8182fa50f700129eb4b4c568da731aab7c8055a5 /sys
parentd0aa54a0d4ea6a5829f72c5d8e83be3a2600deca (diff)
Correct frequency for SDRAM.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/i2c/spdmem.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/sys/dev/i2c/spdmem.c b/sys/dev/i2c/spdmem.c
index 662071b8873..624cfc8065d 100644
--- a/sys/dev/i2c/spdmem.c
+++ b/sys/dev/i2c/spdmem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spdmem.c,v 1.4 2007/10/08 03:10:58 jsg Exp $ */
+/* $OpenBSD: spdmem.c,v 1.5 2007/10/08 05:11:14 jsg Exp $ */
/* $NetBSD: spdmem.c,v 1.3 2007/09/20 23:09:59 xtraeme Exp $ */
/*
@@ -98,6 +98,12 @@
#define SPDMEM_SDR_BANKS_PER_CHIP 0x0e
#define SPDMEM_SDR_SUPERSET 0x1d
+#define SPDMEM_SDR_FREQUENCY 126
+#define SPDMEM_SDR_CAS 127
+#define SPDMEM_SDR_FREQ_66 0x66
+#define SPDMEM_SDR_FREQ_100 0x64
+#define SPDMEM_SDR_FREQ_133 0x85
+
/* Dual Data Rate SDRAM */
#define SPDMEM_DDR_ROWS 0x00
#define SPDMEM_DDR_COLS 0x01
@@ -344,13 +350,32 @@ spdmem_attach(struct device *parent, struct device *self, void *aux)
bits -= 8;
ddr_type_string = "PC";
}
- d_clk /= cycle_time;
- if (s->sm_type == SPDMEM_MEMTYPE_DDR2SDRAM)
- d_clk = (d_clk + 1) / 2;
- p_clk = d_clk * bits / 8;
- if ((p_clk % 100) >= 50)
- p_clk += 50;
- p_clk -= p_clk % 100;
+
+ if (s->sm_type == SPDMEM_MEMTYPE_SDRAM) {
+ p_clk = 66;
+ if (s->sm_len >= 128) {
+ switch(spdmem_read(sc, SPDMEM_SDR_FREQUENCY)) {
+ case SPDMEM_SDR_FREQ_100:
+ p_clk = 100;
+ break;
+ case SPDMEM_SDR_FREQ_133:
+ p_clk = 133;
+ break;
+ case SPDMEM_SDR_FREQ_66:
+ default:
+ p_clk = 66;
+ break;
+ }
+ }
+ } else {
+ d_clk /= cycle_time;
+ if (s->sm_type == SPDMEM_MEMTYPE_DDR2SDRAM)
+ d_clk = (d_clk + 1) / 2;
+ p_clk = d_clk * bits / 8;
+ if ((p_clk % 100) >= 50)
+ p_clk += 50;
+ p_clk -= p_clk % 100;
+ }
printf(" %s%d", ddr_type_string, p_clk);
}