Wed Dec 26 10:24:20 2018 UTC ()
- Fix DDR4's rows and columns value.
- Print "banks/group" instead of "banks" because it's not the total bank
  number.


(msaitoh)
diff -r1.28 -r1.29 src/sys/dev/ic/spdmem.c

cvs diff -r1.28 -r1.29 src/sys/dev/ic/spdmem.c (expand / switch to unified diff)

--- src/sys/dev/ic/spdmem.c 2017/10/24 08:02:06 1.28
+++ src/sys/dev/ic/spdmem.c 2018/12/26 10:24:20 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: spdmem.c,v 1.28 2017/10/24 08:02:06 msaitoh Exp $ */ 1/* $NetBSD: spdmem.c,v 1.29 2018/12/26 10:24:20 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Nicolas Joly 4 * Copyright (c) 2007 Nicolas Joly
5 * Copyright (c) 2007 Paul Goyette 5 * Copyright (c) 2007 Paul Goyette
6 * Copyright (c) 2007 Tobias Nygren 6 * Copyright (c) 2007 Tobias Nygren
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Serial Presence Detect (SPD) memory identification 34 * Serial Presence Detect (SPD) memory identification
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.28 2017/10/24 08:02:06 msaitoh Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.29 2018/12/26 10:24:20 msaitoh Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/device.h> 41#include <sys/device.h>
42#include <sys/endian.h> 42#include <sys/endian.h>
43#include <sys/sysctl.h> 43#include <sys/sysctl.h>
44#include <machine/bswap.h> 44#include <machine/bswap.h>
45 45
46#include <dev/i2c/i2cvar.h> 46#include <dev/i2c/i2cvar.h>
47#include <dev/ic/spdmemreg.h> 47#include <dev/ic/spdmemreg.h>
48#include <dev/ic/spdmemvar.h> 48#include <dev/ic/spdmemvar.h>
49 49
50/* Routines for decoding spd data */ 50/* Routines for decoding spd data */
51static void decode_edofpm(const struct sysctlnode *, device_t, struct spdmem *); 51static void decode_edofpm(const struct sysctlnode *, device_t, struct spdmem *);
@@ -928,29 +928,29 @@ decode_ddr4(const struct sysctlnode *nod @@ -928,29 +928,29 @@ decode_ddr4(const struct sysctlnode *nod
928 s->sm_ddr4.ddr4_##field##_ftb) - \ 928 s->sm_ddr4.ddr4_##field##_ftb) - \
929 ((s->sm_ddr4.ddr4_##field##_ftb > 127)?256:0)) 929 ((s->sm_ddr4.ddr4_##field##_ftb > 127)?256:0))
930 /* 930 /*
931 * For now, the only value for mtb is 0 = 125ps, and ftb = 1ps  931 * For now, the only value for mtb is 0 = 125ps, and ftb = 1ps
932 * so we don't need to figure out the time-base units - just 932 * so we don't need to figure out the time-base units - just
933 * hard-code them for now. 933 * hard-code them for now.
934 */ 934 */
935 cycle_time = __DDR4_VALUE(tCKAVGmin); 935 cycle_time = __DDR4_VALUE(tCKAVGmin);
936 decode_size_speed(self, node, dimm_size, cycle_time, 2, 936 decode_size_speed(self, node, dimm_size, cycle_time, 2,
937 1 << (s->sm_ddr4.ddr4_primary_bus_width + 3), 937 1 << (s->sm_ddr4.ddr4_primary_bus_width + 3),
938 TRUE, "PC4", 0); 938 TRUE, "PC4", 0);
939 939
940 aprint_verbose_dev(self, 940 aprint_verbose_dev(self,
941 "%d rows, %d cols, %d banks, %d bank groups, " 941 "%d rows, %d cols, %d banks/group, %d bank groups, "
942 "%d.%03dns cycle time\n", 942 "%d.%03dns cycle time\n",
943 s->sm_ddr4.ddr4_rows + 9, s->sm_ddr4.ddr4_cols + 12, 943 s->sm_ddr4.ddr4_rows + 12, s->sm_ddr4.ddr4_cols + 9,
944 1 << (2 + s->sm_ddr4.ddr4_logbanks), 944 1 << (2 + s->sm_ddr4.ddr4_logbanks),
945 1 << s->sm_ddr4.ddr4_bankgroups, 945 1 << s->sm_ddr4.ddr4_bankgroups,
946 cycle_time / 1000, cycle_time % 1000); 946 cycle_time / 1000, cycle_time % 1000);
947 947
948 948
949 tAA_clocks = __DDR4_VALUE(tAAmin) * 1000 / cycle_time; 949 tAA_clocks = __DDR4_VALUE(tAAmin) * 1000 / cycle_time;
950 tRCD_clocks = __DDR4_VALUE(tRCDmin) * 1000 / cycle_time; 950 tRCD_clocks = __DDR4_VALUE(tRCDmin) * 1000 / cycle_time;
951 tRP_clocks = __DDR4_VALUE(tRPmin) * 1000 / cycle_time; 951 tRP_clocks = __DDR4_VALUE(tRPmin) * 1000 / cycle_time;
952 tRAS_clocks = (s->sm_ddr4.ddr4_tRASmin_msb * 256 + 952 tRAS_clocks = (s->sm_ddr4.ddr4_tRASmin_msb * 256 +
953 s->sm_ddr4.ddr4_tRASmin_lsb) * 125 * 1000 / cycle_time; 953 s->sm_ddr4.ddr4_tRASmin_lsb) * 125 * 1000 / cycle_time;
954 954
955/* 955/*
956 * Per JEDEC spec, rounding is done by taking the time value, dividing 956 * Per JEDEC spec, rounding is done by taking the time value, dividing