From owner-svn-src-all@FreeBSD.ORG Sun May 24 11:08:07 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EEAFBCD4; Sun, 24 May 2015 11:08:06 +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 D0A5B1263; Sun, 24 May 2015 11:08:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4OB86mW021188; Sun, 24 May 2015 11:08:06 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4OB865h021187; Sun, 24 May 2015 11:08:06 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201505241108.t4OB865h021187@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 24 May 2015 11:08:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283363 - head/sys/dev/psci 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.20 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: Sun, 24 May 2015 11:08:07 -0000 Author: andrew Date: Sun May 24 11:08:06 2015 New Revision: 283363 URL: https://svnweb.freebsd.org/changeset/base/283363 Log: Rework the PSCI cpu on code to allow it to work before device drivers have started. This allows this functions to be used with the regular ARM SMP initialisation sequence. Modified: head/sys/dev/psci/psci.c Modified: head/sys/dev/psci/psci.c ============================================================================== --- head/sys/dev/psci/psci.c Sun May 24 11:04:45 2015 (r283362) +++ head/sys/dev/psci/psci.c Sun May 24 11:08:06 2015 (r283363) @@ -102,6 +102,24 @@ EARLY_DRIVER_MODULE(psci, simplebus, psc EARLY_DRIVER_MODULE(psci, ofwbus, psci_driver, psci_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_FIRST); +static psci_callfn_t +psci_get_callfn(phandle_t node) +{ + char method[16]; + + if ((OF_getprop(node, "method", method, sizeof(method))) > 0) { + if (strcmp(method, "hvc") == 0) + return (psci_hvc_despatch); + else if (strcmp(method, "smc") == 0) + return (psci_smc_despatch); + else + printf("psci: PSCI conduit \"%s\" invalid\n", method); + } else + printf("psci: PSCI conduit not supplied in the device tree\n"); + + return (NULL); +} + static int psci_probe(device_t dev) { @@ -126,7 +144,6 @@ psci_attach(device_t dev) const struct ofw_compat_data *ocd; psci_initfn_t psci_init; phandle_t node; - char method[16]; if (psci_softc != NULL) return (ENXIO); @@ -136,22 +153,9 @@ psci_attach(device_t dev) KASSERT(psci_init != NULL, ("PSCI init function cannot be NULL")); node = ofw_bus_get_node(dev); - if ((OF_getprop(node, "method", method, sizeof(method))) > 0) { - if (strcmp(method, "hvc") == 0) - sc->psci_call = psci_hvc_despatch; - else if (strcmp(method, "smc") == 0) - sc->psci_call = psci_smc_despatch; - else { - device_printf(dev, - "psci_attach: PSCI conduit \"%s\" invalid\n", - method); - return (ENXIO); - } - } else { - device_printf(dev, - "psci_attach: PSCI conduit not supplied in the DT\n"); + sc->psci_call = psci_get_callfn(node); + if (sc->psci_call == NULL) return (ENXIO); - } if (psci_init(dev)) return (ENXIO); @@ -177,10 +181,27 @@ psci_get_version(struct psci_softc *sc) int psci_cpu_on(unsigned long cpu, unsigned long entry, unsigned long context_id) { + psci_callfn_t callfn; + phandle_t node; + uint32_t fnid; + + if (psci_softc == NULL) { + node = ofw_bus_find_compatible(OF_peer(0), "arm,psci-0.2"); + if (node == 0) + /* TODO: Handle psci 0.1 */ + return (PSCI_RETVAL_INTERNAL_FAILURE); + + fnid = PSCI_FNID_CPU_ON; + callfn = psci_get_callfn(node); + if (callfn == NULL) + return (PSCI_RETVAL_INTERNAL_FAILURE); + } else { + callfn = psci_softc->psci_call; + fnid = psci_softc->psci_fnids[PSCI_FN_CPU_ON]; + } /* PSCI v0.1 and v0.2 both support cpu_on. */ - return(psci_softc->psci_call(psci_softc->psci_fnids[PSCI_FN_CPU_ON], cpu, - entry, context_id)); + return (callfn(fnid, cpu, entry, context_id)); } static void