From owner-svn-src-all@FreeBSD.ORG Thu Feb 19 12:47:49 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ECD41E81; Thu, 19 Feb 2015 12:47:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BDE89F66; Thu, 19 Feb 2015 12:47:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1JClnOI051036; Thu, 19 Feb 2015 12:47:49 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1JClnx7051034; Thu, 19 Feb 2015 12:47:49 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201502191247.t1JClnx7051034@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 19 Feb 2015 12:47:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278998 - in head/sys: dev/ofw sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Feb 2015 12:47:50 -0000 Author: andrew Date: Thu Feb 19 12:47:48 2015 New Revision: 278998 URL: https://svnweb.freebsd.org/changeset/base/278998 Log: Add support to get the cpu ID from its device driver in a generic way. This will be needed by arm64 to find the value to pass to the psci (Power State Coordination Interface) driver, among other things, used to enable cores. Differential Revision: https://reviews.freebsd.org/D1824 Reviewed by: imp Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/ofw/ofw_cpu.c head/sys/sys/cpu.h Modified: head/sys/dev/ofw/ofw_cpu.c ============================================================================== --- head/sys/dev/ofw/ofw_cpu.c Thu Feb 19 12:20:21 2015 (r278997) +++ head/sys/dev/ofw/ofw_cpu.c Thu Feb 19 12:47:48 2015 (r278998) @@ -244,6 +244,7 @@ ofw_cpu_attach(device_t dev) static int ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) { + struct ofw_cpulist_softc *psc; struct ofw_cpu_softc *sc; sc = device_get_softc(dev); @@ -258,6 +259,16 @@ ofw_cpu_read_ivar(device_t dev, device_t return (0); } break; + case CPU_IVAR_CPUID_SIZE: + psc = device_get_softc(device_get_parent(dev)); + *result = psc->sc_addr_cells; + return (0); + case CPU_IVAR_CPUID: + if (sc->sc_reg_valid) { + *result = (uintptr_t)sc->sc_reg; + return (0); + } + break; } return (ENOENT); Modified: head/sys/sys/cpu.h ============================================================================== --- head/sys/sys/cpu.h Thu Feb 19 12:20:21 2015 (r278997) +++ head/sys/sys/cpu.h Thu Feb 19 12:47:48 2015 (r278998) @@ -37,6 +37,8 @@ #define CPU_IVAR_PCPU 1 #define CPU_IVAR_NOMINAL_MHZ 2 +#define CPU_IVAR_CPUID_SIZE 3 +#define CPU_IVAR_CPUID 4 static __inline struct pcpu *cpu_get_pcpu(device_t dev) { @@ -54,6 +56,20 @@ static __inline int32_t cpu_get_nominal_ return ((int32_t)v); } +static __inline const uint32_t *cpu_get_cpuid(device_t dev, size_t *count) +{ + uintptr_t v = 0; + if (BUS_READ_IVAR(device_get_parent(dev), dev, + CPU_IVAR_CPUID_SIZE, &v) != 0) + return (NULL); + *count = (size_t)v; + + if (BUS_READ_IVAR(device_get_parent(dev), dev, + CPU_IVAR_CPUID, &v) != 0) + return (NULL); + return ((const uint32_t *)v); +} + /* * CPU frequency control interface. */