Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc gather per-CPU EEPROM contents if we have them
details: https://anonhg.NetBSD.org/src/rev/2b36e77439f8
branches: trunk
changeset: 360563:2b36e77439f8
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Mar 16 22:08:53 2018 +0000
description:
gather per-CPU EEPROM contents if we have them
diffstat:
sys/arch/macppc/dev/uni-n.c | 45 ++++++++++++++++++++++++++++++++++++++++--
sys/arch/macppc/include/cpu.h | 3 +-
2 files changed, 44 insertions(+), 4 deletions(-)
diffs (108 lines):
diff -r bbabc93b73b3 -r 2b36e77439f8 sys/arch/macppc/dev/uni-n.c
--- a/sys/arch/macppc/dev/uni-n.c Fri Mar 16 18:49:18 2018 +0000
+++ b/sys/arch/macppc/dev/uni-n.c Fri Mar 16 22:08:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uni-n.c,v 1.8 2018/03/01 13:55:25 macallan Exp $ */
+/* $NetBSD: uni-n.c,v 1.9 2018/03/16 22:08:53 macallan Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.8 2018/03/01 13:55:25 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uni-n.c,v 1.9 2018/03/16 22:08:53 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -43,6 +43,8 @@
#include <machine/autoconf.h>
+#include "fcu.h"
+
static void uni_n_attach(device_t, device_t, void *);
static int uni_n_match(device_t, cfdata_t, void *);
static int uni_n_print(void *, const char *);
@@ -56,6 +58,11 @@
CFATTACH_DECL_NEW(uni_n, sizeof(struct uni_n_softc),
uni_n_match, uni_n_attach, NULL, NULL);
+#if NFCU > 0
+/* storage for CPUID SEEPROM contents found on some G5 */
+static uint8_t eeprom[2][160];
+#endif
+
int
uni_n_match(device_t parent, cfdata_t cf, void *aux)
{
@@ -85,6 +92,9 @@
struct confargs *our_ca = aux;
struct confargs ca;
int node, child, namelen;
+#if NFCU > 0
+ int cpuid;
+#endif
u_int reg[20];
int intr[6];
char name[32];
@@ -92,7 +102,25 @@
sc->sc_dev = self;
node = our_ca->ca_node;
sc->sc_node = node;
- printf(" address 0x%08x\n",our_ca->ca_reg[0]);
+ printf(" address 0x%08x\n",
+ our_ca->ca_reg[our_ca->ca_nreg > 8 ? 1 : 0]);
+
+#if NFCU > 0
+ /*
+ * zero out eeprom blocks, then see if we have valid data
+ * doing this here because the EEPROMs are dangling from out i2c bus
+ * but we can get all the data just from looking at the properties
+ */
+ memset(eeprom, 0, sizeof(eeprom));
+ cpuid = OF_finddevice("/u3/i2c/cpuid@a0");
+ OF_getprop(cpuid, "cpuid", eeprom[0], sizeof(eeprom[0]));
+ if (eeprom[0][1] != 0)
+ aprint_normal_dev(self, "found EEPROM data for CPU 0\n");
+ cpuid = OF_finddevice("/u3/i2c/cpuid@a2");
+ OF_getprop(cpuid, "cpuid", eeprom[1], sizeof(eeprom[1]));
+ if (eeprom[1][1] != 0)
+ aprint_normal_dev(self, "found EEPROM data for CPU 1\n");
+#endif
memset(&sc->sc_memt, 0, sizeof(struct powerpc_bus_space));
sc->sc_memt.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE;
@@ -137,3 +165,14 @@
return UNCONF;
}
+
+#if NFCU > 0
+int
+get_cpuid(int cpu, uint8_t *buf)
+{
+ if ((cpu < 0) || (cpu > 1)) return -1;
+ if (eeprom[cpu][1] == 0) return 0;
+ memcpy(buf, eeprom[cpu], sizeof(eeprom[cpu]));
+ return sizeof(eeprom[cpu]);
+}
+#endif
diff -r bbabc93b73b3 -r 2b36e77439f8 sys/arch/macppc/include/cpu.h
--- a/sys/arch/macppc/include/cpu.h Fri Mar 16 18:49:18 2018 +0000
+++ b/sys/arch/macppc/include/cpu.h Fri Mar 16 22:08:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.19 2011/06/20 06:35:40 matt Exp $ */
+/* $NetBSD: cpu.h,v 1.20 2018/03/16 22:08:53 macallan Exp $ */
/*
* Copyright (C) 1995-1997 Wolfgang Solfrank.
@@ -36,6 +36,7 @@
#if defined(_KERNEL) && !defined(_MODULE)
#define CPU_MAXNUM 2
extern char bootpath[];
+int get_cpuid(int, uint8_t *);
#endif /* _KERNEL */
#include <powerpc/cpu.h>
Home |
Main Index |
Thread Index |
Old Index