1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/stringify.h>
11 #define mfspr(rn) ({unsigned long rval; \
12 asm volatile("mfspr %0," __stringify(rn) \
13 : "=r" (rval)); rval; })
15 #define SPRN_PVR 0x11F /* Processor Version Register */
16 #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
17 #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
20 get_cpuid(char *buffer
, size_t sz
)
25 pvr
= mfspr(SPRN_PVR
);
27 nb
= scnprintf(buffer
, sz
, "%lu,%lu$", PVR_VER(pvr
), PVR_REV(pvr
));
29 /* look for end marker to ensure the entire data fit */
30 if (strchr(buffer
, '$')) {
38 get_cpuid_str(struct perf_pmu
*pmu __maybe_unused
)
42 if (asprintf(&bufp
, "%.8lx", mfspr(SPRN_PVR
)) < 0)