Home | History | Annotate | Line # | Download | only in fdt
cpu_fdt.c revision 1.4.2.8
      1  1.4.2.8  pgoyette /* $NetBSD: cpu_fdt.c,v 1.4.2.8 2019/01/26 22:00:00 pgoyette Exp $ */
      2      1.1  jmcneill 
      3      1.1  jmcneill /*-
      4      1.1  jmcneill  * Copyright (c) 2017 Jared McNeill <jmcneill (at) invisible.ca>
      5      1.1  jmcneill  * All rights reserved.
      6      1.1  jmcneill  *
      7      1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8      1.1  jmcneill  * modification, are permitted provided that the following conditions
      9      1.1  jmcneill  * are met:
     10      1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12      1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15      1.1  jmcneill  *
     16      1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17      1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18      1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19      1.1  jmcneill  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20      1.1  jmcneill  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21      1.1  jmcneill  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22      1.1  jmcneill  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23      1.1  jmcneill  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24      1.1  jmcneill  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25      1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26      1.1  jmcneill  * SUCH DAMAGE.
     27      1.1  jmcneill  */
     28      1.1  jmcneill 
     29  1.4.2.5  pgoyette #include "opt_multiprocessor.h"
     30  1.4.2.5  pgoyette #include "psci_fdt.h"
     31  1.4.2.5  pgoyette 
     32      1.1  jmcneill #include <sys/cdefs.h>
     33  1.4.2.8  pgoyette __KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.4.2.8 2019/01/26 22:00:00 pgoyette Exp $");
     34      1.1  jmcneill 
     35      1.1  jmcneill #include <sys/param.h>
     36  1.4.2.5  pgoyette #include <sys/atomic.h>
     37      1.1  jmcneill #include <sys/bus.h>
     38      1.1  jmcneill #include <sys/device.h>
     39      1.4     skrll #include <sys/lwp.h>
     40      1.1  jmcneill #include <sys/systm.h>
     41      1.1  jmcneill #include <sys/kernel.h>
     42      1.1  jmcneill 
     43      1.1  jmcneill #include <dev/fdt/fdtvar.h>
     44      1.1  jmcneill 
     45  1.4.2.1  pgoyette #include <arm/armreg.h>
     46      1.1  jmcneill #include <arm/cpu.h>
     47  1.4.2.1  pgoyette #include <arm/cpufunc.h>
     48  1.4.2.5  pgoyette #include <arm/locore.h>
     49  1.4.2.5  pgoyette 
     50  1.4.2.5  pgoyette #include <arm/arm/psci.h>
     51  1.4.2.5  pgoyette #include <arm/fdt/arm_fdtvar.h>
     52  1.4.2.5  pgoyette #include <arm/fdt/psci_fdtvar.h>
     53  1.4.2.5  pgoyette 
     54  1.4.2.5  pgoyette #include <uvm/uvm_extern.h>
     55      1.1  jmcneill 
     56      1.1  jmcneill static int	cpu_fdt_match(device_t, cfdata_t, void *);
     57      1.1  jmcneill static void	cpu_fdt_attach(device_t, device_t, void *);
     58      1.1  jmcneill 
     59      1.3  jmcneill enum cpu_fdt_type {
     60      1.3  jmcneill 	ARM_CPU_UP = 1,
     61      1.3  jmcneill 	ARM_CPU_ARMV7,
     62      1.3  jmcneill 	ARM_CPU_ARMV8,
     63      1.3  jmcneill };
     64      1.3  jmcneill 
     65      1.1  jmcneill struct cpu_fdt_softc {
     66      1.1  jmcneill 	device_t		sc_dev;
     67      1.1  jmcneill 	int			sc_phandle;
     68      1.1  jmcneill };
     69      1.1  jmcneill 
     70      1.3  jmcneill static const struct of_compat_data compat_data[] = {
     71      1.3  jmcneill 	{ "arm,arm1176jzf-s",		ARM_CPU_UP },
     72      1.3  jmcneill 
     73  1.4.2.2  pgoyette 	{ "arm,arm-v7",			ARM_CPU_ARMV7 },
     74      1.3  jmcneill 	{ "arm,cortex-a5",		ARM_CPU_ARMV7 },
     75      1.3  jmcneill 	{ "arm,cortex-a7",		ARM_CPU_ARMV7 },
     76      1.3  jmcneill 	{ "arm,cortex-a8",		ARM_CPU_ARMV7 },
     77      1.3  jmcneill 	{ "arm,cortex-a9",		ARM_CPU_ARMV7 },
     78      1.3  jmcneill 	{ "arm,cortex-a12",		ARM_CPU_ARMV7 },
     79      1.3  jmcneill 	{ "arm,cortex-a15",		ARM_CPU_ARMV7 },
     80      1.3  jmcneill 	{ "arm,cortex-a17",		ARM_CPU_ARMV7 },
     81      1.3  jmcneill 
     82  1.4.2.5  pgoyette 	{ "arm,armv8",			ARM_CPU_ARMV8 },
     83      1.3  jmcneill 	{ "arm,cortex-a53",		ARM_CPU_ARMV8 },
     84      1.3  jmcneill 	{ "arm,cortex-a57",		ARM_CPU_ARMV8 },
     85      1.3  jmcneill 	{ "arm,cortex-a72",		ARM_CPU_ARMV8 },
     86      1.3  jmcneill 	{ "arm,cortex-a73",		ARM_CPU_ARMV8 },
     87  1.4.2.2  pgoyette 
     88      1.3  jmcneill 	{ NULL }
     89      1.3  jmcneill };
     90      1.3  jmcneill 
     91      1.1  jmcneill CFATTACH_DECL_NEW(cpu_fdt, sizeof(struct cpu_fdt_softc),
     92      1.1  jmcneill 	cpu_fdt_match, cpu_fdt_attach, NULL, NULL);
     93      1.1  jmcneill 
     94      1.1  jmcneill static int
     95      1.1  jmcneill cpu_fdt_match(device_t parent, cfdata_t cf, void *aux)
     96      1.1  jmcneill {
     97      1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
     98      1.3  jmcneill 	const int phandle = faa->faa_phandle;
     99      1.3  jmcneill 	enum cpu_fdt_type type;
    100      1.2  jmcneill 	int is_compatible;
    101      1.2  jmcneill 	bus_addr_t mpidr;
    102      1.2  jmcneill 
    103      1.3  jmcneill 	is_compatible = of_match_compat_data(phandle, compat_data);
    104      1.2  jmcneill 	if (!is_compatible)
    105      1.2  jmcneill 		return 0;
    106      1.2  jmcneill 
    107      1.3  jmcneill 	type = of_search_compatible(phandle, compat_data)->data;
    108      1.3  jmcneill 	switch (type) {
    109      1.3  jmcneill 	case ARM_CPU_ARMV7:
    110      1.3  jmcneill 	case ARM_CPU_ARMV8:
    111      1.3  jmcneill 		if (fdtbus_get_reg(phandle, 0, &mpidr, NULL) != 0)
    112      1.3  jmcneill 			return 0;
    113      1.3  jmcneill 	default:
    114      1.3  jmcneill 		break;
    115      1.3  jmcneill 	}
    116      1.1  jmcneill 
    117      1.2  jmcneill 	return is_compatible;
    118      1.1  jmcneill }
    119      1.1  jmcneill 
    120      1.1  jmcneill static void
    121      1.1  jmcneill cpu_fdt_attach(device_t parent, device_t self, void *aux)
    122      1.1  jmcneill {
    123      1.1  jmcneill 	struct cpu_fdt_softc * const sc = device_private(self);
    124      1.1  jmcneill 	struct fdt_attach_args * const faa = aux;
    125      1.3  jmcneill 	const int phandle = faa->faa_phandle;
    126      1.3  jmcneill 	enum cpu_fdt_type type;
    127      1.1  jmcneill 	bus_addr_t mpidr;
    128      1.3  jmcneill 	cpuid_t cpuid;
    129      1.1  jmcneill 
    130      1.1  jmcneill 	sc->sc_dev = self;
    131      1.3  jmcneill 	sc->sc_phandle = phandle;
    132      1.3  jmcneill 
    133      1.3  jmcneill 	type = of_search_compatible(phandle, compat_data)->data;
    134      1.1  jmcneill 
    135      1.3  jmcneill 	switch (type) {
    136      1.3  jmcneill 	case ARM_CPU_ARMV7:
    137      1.3  jmcneill 	case ARM_CPU_ARMV8:
    138      1.3  jmcneill 		if (fdtbus_get_reg(phandle, 0, &mpidr, NULL) != 0) {
    139      1.3  jmcneill 			aprint_error(": missing 'reg' property\n");
    140      1.3  jmcneill 			return;
    141      1.3  jmcneill 		}
    142  1.4.2.4  pgoyette 		cpuid = mpidr;
    143      1.3  jmcneill 		break;
    144      1.3  jmcneill 	default:
    145      1.3  jmcneill 		cpuid = 0;
    146      1.3  jmcneill 		break;
    147      1.1  jmcneill 	}
    148      1.1  jmcneill 
    149      1.2  jmcneill 	/* Attach the CPU */
    150      1.3  jmcneill 	cpu_attach(self, cpuid);
    151  1.4.2.3  pgoyette 
    152  1.4.2.3  pgoyette 	/* Attach CPU frequency scaling provider */
    153  1.4.2.3  pgoyette 	config_found(self, faa, NULL);
    154      1.1  jmcneill }
    155  1.4.2.5  pgoyette 
    156  1.4.2.5  pgoyette #ifdef MULTIPROCESSOR
    157  1.4.2.5  pgoyette static register_t
    158  1.4.2.5  pgoyette cpu_fdt_mpstart_pa(void)
    159  1.4.2.5  pgoyette {
    160  1.4.2.6  pgoyette 	bool ok __diagused;
    161  1.4.2.6  pgoyette 	paddr_t pa;
    162  1.4.2.6  pgoyette 
    163  1.4.2.6  pgoyette 	ok = pmap_extract(pmap_kernel(), (vaddr_t)cpu_mpstart, &pa);
    164  1.4.2.6  pgoyette 	KASSERT(ok);
    165  1.4.2.6  pgoyette 
    166  1.4.2.6  pgoyette 	return pa;
    167  1.4.2.5  pgoyette }
    168  1.4.2.5  pgoyette 
    169  1.4.2.5  pgoyette static int
    170  1.4.2.5  pgoyette spintable_cpu_on(u_int cpuindex, paddr_t entry_point_address, paddr_t cpu_release_addr)
    171  1.4.2.5  pgoyette {
    172  1.4.2.5  pgoyette 	/*
    173  1.4.2.5  pgoyette 	 * we need devmap for cpu-release-addr in advance.
    174  1.4.2.5  pgoyette 	 * __HAVE_MM_MD_DIRECT_MAPPED_PHYS nor pmap didn't work at this point.
    175  1.4.2.5  pgoyette 	 */
    176  1.4.2.5  pgoyette 	if (pmap_devmap_find_pa(cpu_release_addr, sizeof(paddr_t)) == NULL) {
    177  1.4.2.5  pgoyette 		aprint_error("%s: devmap for cpu-release-addr"
    178  1.4.2.5  pgoyette 		    " 0x%08"PRIxPADDR" required\n", __func__, cpu_release_addr);
    179  1.4.2.5  pgoyette 		return -1;
    180  1.4.2.5  pgoyette 	} else {
    181  1.4.2.5  pgoyette 		extern struct bus_space arm_generic_bs_tag;
    182  1.4.2.5  pgoyette 		bus_space_handle_t ioh;
    183  1.4.2.5  pgoyette 
    184  1.4.2.5  pgoyette 		bus_space_map(&arm_generic_bs_tag, cpu_release_addr,
    185  1.4.2.5  pgoyette 		    sizeof(paddr_t), 0, &ioh);
    186  1.4.2.5  pgoyette 		bus_space_write_4(&arm_generic_bs_tag, ioh, 0,
    187  1.4.2.5  pgoyette 		    entry_point_address);
    188  1.4.2.5  pgoyette 		bus_space_unmap(&arm_generic_bs_tag, ioh, sizeof(paddr_t));
    189  1.4.2.5  pgoyette 	}
    190  1.4.2.5  pgoyette 
    191  1.4.2.5  pgoyette 	return 0;
    192  1.4.2.5  pgoyette }
    193  1.4.2.5  pgoyette #endif /* MULTIPROCESSOR */
    194  1.4.2.5  pgoyette 
    195  1.4.2.5  pgoyette #ifdef MULTIPROCESSOR
    196  1.4.2.5  pgoyette static bool
    197  1.4.2.5  pgoyette arm_fdt_cpu_okay(const int child)
    198  1.4.2.5  pgoyette {
    199  1.4.2.5  pgoyette 	const char *s;
    200  1.4.2.5  pgoyette 
    201  1.4.2.5  pgoyette 	s = fdtbus_get_string(child, "device_type");
    202  1.4.2.5  pgoyette 	if (!s || strcmp(s, "cpu") != 0)
    203  1.4.2.5  pgoyette 		return false;
    204  1.4.2.5  pgoyette 
    205  1.4.2.5  pgoyette 	s = fdtbus_get_string(child, "status");
    206  1.4.2.5  pgoyette 	if (s) {
    207  1.4.2.5  pgoyette 		if (strcmp(s, "okay") == 0)
    208  1.4.2.5  pgoyette 			return false;
    209  1.4.2.5  pgoyette 		if (strcmp(s, "disabled") == 0)
    210  1.4.2.5  pgoyette 			return of_hasprop(child, "enable-method");
    211  1.4.2.5  pgoyette 		return false;
    212  1.4.2.5  pgoyette 	} else {
    213  1.4.2.5  pgoyette 		return true;
    214  1.4.2.5  pgoyette 	}
    215  1.4.2.5  pgoyette }
    216  1.4.2.5  pgoyette #endif /* MULTIPROCESSOR */
    217  1.4.2.5  pgoyette 
    218  1.4.2.5  pgoyette void
    219  1.4.2.5  pgoyette arm_fdt_cpu_bootstrap(void)
    220  1.4.2.5  pgoyette {
    221  1.4.2.5  pgoyette #ifdef MULTIPROCESSOR
    222  1.4.2.5  pgoyette 	uint64_t mpidr, bp_mpidr;
    223  1.4.2.5  pgoyette 	u_int cpuindex;
    224  1.4.2.6  pgoyette 	int child;
    225  1.4.2.5  pgoyette 
    226  1.4.2.5  pgoyette 	const int cpus = OF_finddevice("/cpus");
    227  1.4.2.5  pgoyette 	if (cpus == -1) {
    228  1.4.2.5  pgoyette 		aprint_error("%s: no /cpus node found\n", __func__);
    229  1.4.2.5  pgoyette 		arm_cpu_max = 1;
    230  1.4.2.5  pgoyette 		return;
    231  1.4.2.5  pgoyette 	}
    232  1.4.2.5  pgoyette 
    233  1.4.2.5  pgoyette 	/* Count CPUs */
    234  1.4.2.5  pgoyette 	arm_cpu_max = 0;
    235  1.4.2.5  pgoyette 
    236  1.4.2.6  pgoyette 	/* MPIDR affinity levels of boot processor. */
    237  1.4.2.6  pgoyette 	bp_mpidr = cpu_mpidr_aff_read();
    238  1.4.2.6  pgoyette 
    239  1.4.2.6  pgoyette 	/* Boot APs */
    240  1.4.2.6  pgoyette 	cpuindex = 1;
    241  1.4.2.6  pgoyette 	for (child = OF_child(cpus); child; child = OF_peer(child)) {
    242  1.4.2.6  pgoyette 		if (!arm_fdt_cpu_okay(child))
    243  1.4.2.6  pgoyette 			continue;
    244  1.4.2.6  pgoyette 
    245  1.4.2.6  pgoyette 		arm_cpu_max++;
    246  1.4.2.6  pgoyette 		if (fdtbus_get_reg64(child, 0, &mpidr, NULL) != 0)
    247  1.4.2.6  pgoyette 			continue;
    248  1.4.2.6  pgoyette 		if (mpidr == bp_mpidr)
    249  1.4.2.6  pgoyette 			continue; 	/* BP already started */
    250  1.4.2.6  pgoyette 
    251  1.4.2.6  pgoyette 		KASSERT(cpuindex < MAXCPUS);
    252  1.4.2.6  pgoyette 		cpu_mpidr[cpuindex] = mpidr;
    253  1.4.2.6  pgoyette 		cpu_dcache_wb_range((vaddr_t)&cpu_mpidr[cpuindex],
    254  1.4.2.6  pgoyette 		    sizeof(cpu_mpidr[cpuindex]));
    255  1.4.2.6  pgoyette 
    256  1.4.2.6  pgoyette 		cpuindex++;
    257  1.4.2.6  pgoyette 	}
    258  1.4.2.6  pgoyette #endif
    259  1.4.2.6  pgoyette }
    260  1.4.2.6  pgoyette 
    261  1.4.2.7  pgoyette #ifdef MULTIPROCESSOR
    262  1.4.2.7  pgoyette static int
    263  1.4.2.7  pgoyette arm_fdt_cpu_enable(int phandle, const char *method)
    264  1.4.2.7  pgoyette {
    265  1.4.2.7  pgoyette 	__link_set_decl(arm_cpu_methods, struct arm_cpu_method);
    266  1.4.2.7  pgoyette 	struct arm_cpu_method * const *acm;
    267  1.4.2.7  pgoyette 	__link_set_foreach(acm, arm_cpu_methods) {
    268  1.4.2.7  pgoyette 		if (strcmp(method, (*acm)->acm_compat) == 0)
    269  1.4.2.7  pgoyette 			return (*acm)->acm_enable(phandle);
    270  1.4.2.7  pgoyette 	}
    271  1.4.2.7  pgoyette 	return ENOSYS;
    272  1.4.2.7  pgoyette }
    273  1.4.2.7  pgoyette #endif
    274  1.4.2.7  pgoyette 
    275  1.4.2.6  pgoyette void
    276  1.4.2.6  pgoyette arm_fdt_cpu_mpstart(void)
    277  1.4.2.6  pgoyette {
    278  1.4.2.6  pgoyette #ifdef MULTIPROCESSOR
    279  1.4.2.6  pgoyette 	uint64_t mpidr, bp_mpidr;
    280  1.4.2.7  pgoyette 	u_int cpuindex, i;
    281  1.4.2.7  pgoyette 	int child, error;
    282  1.4.2.6  pgoyette 	const char *method;
    283  1.4.2.6  pgoyette 
    284  1.4.2.6  pgoyette 	const int cpus = OF_finddevice("/cpus");
    285  1.4.2.6  pgoyette 	if (cpus == -1) {
    286  1.4.2.6  pgoyette 		aprint_error("%s: no /cpus node found\n", __func__);
    287  1.4.2.5  pgoyette 		return;
    288  1.4.2.6  pgoyette 	}
    289  1.4.2.6  pgoyette 
    290  1.4.2.5  pgoyette 	/* MPIDR affinity levels of boot processor. */
    291  1.4.2.5  pgoyette 	bp_mpidr = cpu_mpidr_aff_read();
    292  1.4.2.5  pgoyette 
    293  1.4.2.5  pgoyette 	/* Boot APs */
    294  1.4.2.5  pgoyette 	cpuindex = 1;
    295  1.4.2.5  pgoyette 	for (child = OF_child(cpus); child; child = OF_peer(child)) {
    296  1.4.2.5  pgoyette 		if (!arm_fdt_cpu_okay(child))
    297  1.4.2.5  pgoyette 			continue;
    298  1.4.2.6  pgoyette 
    299  1.4.2.5  pgoyette 		if (fdtbus_get_reg64(child, 0, &mpidr, NULL) != 0)
    300  1.4.2.5  pgoyette 			continue;
    301  1.4.2.7  pgoyette 
    302  1.4.2.5  pgoyette 		if (mpidr == bp_mpidr)
    303  1.4.2.5  pgoyette 			continue; 	/* BP already started */
    304  1.4.2.5  pgoyette 
    305  1.4.2.5  pgoyette 		method = fdtbus_get_string(child, "enable-method");
    306  1.4.2.5  pgoyette 		if (method == NULL)
    307  1.4.2.7  pgoyette 			method = fdtbus_get_string(cpus, "enable-method");
    308  1.4.2.7  pgoyette 		if (method == NULL)
    309  1.4.2.5  pgoyette 			continue;
    310  1.4.2.5  pgoyette 
    311  1.4.2.7  pgoyette 		error = arm_fdt_cpu_enable(child, method);
    312  1.4.2.7  pgoyette 		if (error != 0) {
    313  1.4.2.7  pgoyette 			aprint_error("%s: %s: unsupported enable-method\n", __func__, method);
    314  1.4.2.5  pgoyette 			continue;
    315  1.4.2.5  pgoyette 		}
    316  1.4.2.5  pgoyette 
    317  1.4.2.7  pgoyette 		/* Wake up AP in case firmware has placed it in WFE state */
    318  1.4.2.7  pgoyette 		__asm __volatile("sev" ::: "memory");
    319  1.4.2.7  pgoyette 
    320  1.4.2.7  pgoyette 		/* Wait for AP to start */
    321  1.4.2.8  pgoyette 		for (i = 0x10000000; i > 0; i--) {
    322  1.4.2.7  pgoyette 			membar_consumer();
    323  1.4.2.7  pgoyette 			if (arm_cpu_hatched & __BIT(cpuindex))
    324  1.4.2.7  pgoyette 				break;
    325  1.4.2.7  pgoyette 		}
    326  1.4.2.7  pgoyette 		if (i == 0)
    327  1.4.2.7  pgoyette 			aprint_error("cpu%d: WARNING: AP failed to start\n", cpuindex);
    328  1.4.2.7  pgoyette 
    329  1.4.2.5  pgoyette 		cpuindex++;
    330  1.4.2.5  pgoyette 	}
    331  1.4.2.7  pgoyette #endif /* MULTIPROCESSOR */
    332  1.4.2.7  pgoyette }
    333  1.4.2.5  pgoyette 
    334  1.4.2.7  pgoyette static int
    335  1.4.2.7  pgoyette cpu_enable_nullop(int phandle)
    336  1.4.2.7  pgoyette {
    337  1.4.2.7  pgoyette 	return ENXIO;
    338  1.4.2.7  pgoyette }
    339  1.4.2.7  pgoyette ARM_CPU_METHOD(default, "", cpu_enable_nullop);
    340  1.4.2.5  pgoyette 
    341  1.4.2.7  pgoyette #if defined(MULTIPROCESSOR) && NPSCI_FDT > 0
    342  1.4.2.7  pgoyette static int
    343  1.4.2.7  pgoyette cpu_enable_psci(int phandle)
    344  1.4.2.7  pgoyette {
    345  1.4.2.7  pgoyette 	static bool psci_probed, psci_p;
    346  1.4.2.7  pgoyette 	uint64_t mpidr;
    347  1.4.2.7  pgoyette 	int ret;
    348  1.4.2.7  pgoyette 
    349  1.4.2.7  pgoyette 	if (!psci_probed) {
    350  1.4.2.7  pgoyette 		psci_probed = true;
    351  1.4.2.7  pgoyette 		psci_p = psci_fdt_preinit() == 0;
    352  1.4.2.5  pgoyette 	}
    353  1.4.2.7  pgoyette 	if (!psci_p)
    354  1.4.2.7  pgoyette 		return ENXIO;
    355  1.4.2.7  pgoyette 
    356  1.4.2.7  pgoyette 	fdtbus_get_reg64(phandle, 0, &mpidr, NULL);
    357  1.4.2.7  pgoyette 
    358  1.4.2.7  pgoyette 	ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0);
    359  1.4.2.7  pgoyette 	if (ret != PSCI_SUCCESS)
    360  1.4.2.7  pgoyette 		return EIO;
    361  1.4.2.7  pgoyette 
    362  1.4.2.7  pgoyette 	return 0;
    363  1.4.2.5  pgoyette }
    364  1.4.2.7  pgoyette ARM_CPU_METHOD(psci, "psci", cpu_enable_psci);
    365  1.4.2.7  pgoyette #endif
    366  1.4.2.7  pgoyette 
    367  1.4.2.7  pgoyette #if defined(MULTIPROCESSOR)
    368  1.4.2.7  pgoyette static int
    369  1.4.2.7  pgoyette cpu_enable_spin_table(int phandle)
    370  1.4.2.7  pgoyette {
    371  1.4.2.7  pgoyette 	uint64_t mpidr, addr;
    372  1.4.2.7  pgoyette 	int ret;
    373  1.4.2.7  pgoyette 
    374  1.4.2.7  pgoyette 	fdtbus_get_reg64(phandle, 0, &mpidr, NULL);
    375  1.4.2.7  pgoyette 
    376  1.4.2.7  pgoyette 	if (of_getprop_uint64(phandle, "cpu-release-addr", &addr) != 0)
    377  1.4.2.7  pgoyette 		return ENXIO;
    378  1.4.2.7  pgoyette 
    379  1.4.2.7  pgoyette 	ret = spintable_cpu_on(mpidr, cpu_fdt_mpstart_pa(), (paddr_t)addr);
    380  1.4.2.7  pgoyette 	if (ret != 0)
    381  1.4.2.7  pgoyette 		return EIO;
    382  1.4.2.7  pgoyette 
    383  1.4.2.7  pgoyette 	return 0;
    384  1.4.2.7  pgoyette }
    385  1.4.2.7  pgoyette ARM_CPU_METHOD(spin_table, "spin-table", cpu_enable_spin_table);
    386  1.4.2.7  pgoyette #endif
    387