psci.h revision 281466
1281466Sandrew/*- 2281466Sandrew * Copyright (c) 2013, 2014 Robin Randhawa 3281466Sandrew * All rights reserved. 4281466Sandrew * 5281466Sandrew * Redistribution and use in source and binary forms, with or without 6281466Sandrew * modification, are permitted provided that the following conditions 7281466Sandrew * are met: 8281466Sandrew * 1. Redistributions of source code must retain the above copyright 9281466Sandrew * notice, this list of conditions and the following disclaimer. 10281466Sandrew * 2. Redistributions in binary form must reproduce the above copyright 11281466Sandrew * notice, this list of conditions and the following disclaimer in the 12281466Sandrew * documentation and/or other materials provided with the distribution. 13281466Sandrew * 14281466Sandrew * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15281466Sandrew * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16281466Sandrew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17281466Sandrew * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18281466Sandrew * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19281466Sandrew * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20281466Sandrew * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21281466Sandrew * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22281466Sandrew * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23281466Sandrew * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24281466Sandrew * SUCH DAMAGE. 25281466Sandrew * 26281466Sandrew * $FreeBSD: head/sys/dev/psci/psci.h 281466 2015-04-12 13:00:58Z andrew $ 27281466Sandrew */ 28281466Sandrew 29281466Sandrew#ifndef _MACHINE_PSCI_H_ 30281466Sandrew#define _MACHINE_PSCI_H_ 31281466Sandrew 32281466Sandrew#include <sys/types.h> 33281466Sandrew 34281466Sandrewtypedef int (*psci_initfn_t)(device_t dev); 35281466Sandrewtypedef int (*psci_callfn_t)(register_t, register_t, register_t, register_t); 36281466Sandrew 37281466Sandrewextern int psci_present; 38281466Sandrew 39281466Sandrewvoid psci_system_reset(void); 40281466Sandrewint psci_cpu_on(unsigned long, unsigned long, unsigned long); 41281466Sandrewint psci_hvc_despatch(register_t, register_t, register_t, register_t); 42281466Sandrewint psci_smc_despatch(register_t, register_t, register_t, register_t); 43281466Sandrew 44281466Sandrew 45281466Sandrew/* 46281466Sandrew * PSCI return codes. 47281466Sandrew */ 48281466Sandrew#define PSCI_RETVAL_SUCCESS 0 49281466Sandrew#define PSCI_RETVAL_NOT_SUPPORTED -1 50281466Sandrew#define PSCI_RETVAL_INVALID_PARAMS -2 51281466Sandrew#define PSCI_RETVAL_DENIED -3 52281466Sandrew#define PSCI_RETVAL_ALREADY_ON -4 53281466Sandrew#define PSCI_RETVAL_ON_PENDING -5 54281466Sandrew#define PSCI_RETVAL_INTERNAL_FAILURE -6 55281466Sandrew#define PSCI_RETVAL_NOT_PRESENT -7 56281466Sandrew#define PSCI_RETVAL_DISABLED -8 57281466Sandrew 58281466Sandrew/* 59281466Sandrew * PSCI function codes (as per PSCI v0.2). 60281466Sandrew */ 61281466Sandrew#ifdef __aarch64__ 62281466Sandrew#define PSCI_FNID_VERSION 0x84000000 63281466Sandrew#define PSCI_FNID_CPU_SUSPEND 0xc4000001 64281466Sandrew#define PSCI_FNID_CPU_OFF 0x84000002 65281466Sandrew#define PSCI_FNID_CPU_ON 0xc4000003 66281466Sandrew#define PSCI_FNID_AFFINITY_INFO 0xc4000004 67281466Sandrew#define PSCI_FNID_MIGRATE 0xc4000005 68281466Sandrew#define PSCI_FNID_MIGRATE_INFO_TYPE 0x84000006 69281466Sandrew#define PSCI_FNID_MIGRATE_INFO_UP_CPU 0xc4000007 70281466Sandrew#define PSCI_FNID_SYSTEM_OFF 0x84000008 71281466Sandrew#define PSCI_FNID_SYSTEM_RESET 0x84000009 72281466Sandrew#else 73281466Sandrew#define PSCI_FNID_VERSION 0x84000000 74281466Sandrew#define PSCI_FNID_CPU_SUSPEND 0x84000001 75281466Sandrew#define PSCI_FNID_CPU_OFF 0x84000002 76281466Sandrew#define PSCI_FNID_CPU_ON 0x84000003 77281466Sandrew#define PSCI_FNID_AFFINITY_INFO 0x84000004 78281466Sandrew#define PSCI_FNID_MIGRATE 0x84000005 79281466Sandrew#define PSCI_FNID_MIGRATE_INFO_TYPE 0x84000006 80281466Sandrew#define PSCI_FNID_MIGRATE_INFO_UP_CPU 0x84000007 81281466Sandrew#define PSCI_FNID_SYSTEM_OFF 0x84000008 82281466Sandrew#define PSCI_FNID_SYSTEM_RESET 0x84000009 83281466Sandrew#endif 84281466Sandrew 85281466Sandrew#define PSCI_VER_MAJOR(v) (((v) >> 16) & 0xFF) 86281466Sandrew#define PSCI_VER_MINOR(v) ((v) & 0xFF) 87281466Sandrew 88281466Sandrewenum psci_fn { 89281466Sandrew PSCI_FN_VERSION, 90281466Sandrew PSCI_FN_CPU_SUSPEND, 91281466Sandrew PSCI_FN_CPU_OFF, 92281466Sandrew PSCI_FN_CPU_ON, 93281466Sandrew PSCI_FN_AFFINITY_INFO, 94281466Sandrew PSCI_FN_MIGRATE, 95281466Sandrew PSCI_FN_MIGRATE_INFO_TYPE, 96281466Sandrew PSCI_FN_MIGRATE_INFO_UP_CPU, 97281466Sandrew PSCI_FN_SYSTEM_OFF, 98281466Sandrew PSCI_FN_SYSTEM_RESET, 99281466Sandrew PSCI_FN_MAX 100281466Sandrew}; 101281466Sandrew 102281466Sandrew#endif /* _MACHINE_PSCI_H_ */ 103