15dffb46cSSoby Mathew /* 25dffb46cSSoby Mathew * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 35dffb46cSSoby Mathew * 45dffb46cSSoby Mathew * Redistribution and use in source and binary forms, with or without 55dffb46cSSoby Mathew * modification, are permitted provided that the following conditions are met: 65dffb46cSSoby Mathew * 75dffb46cSSoby Mathew * Redistributions of source code must retain the above copyright notice, this 85dffb46cSSoby Mathew * list of conditions and the following disclaimer. 95dffb46cSSoby Mathew * 105dffb46cSSoby Mathew * Redistributions in binary form must reproduce the above copyright notice, 115dffb46cSSoby Mathew * this list of conditions and the following disclaimer in the documentation 125dffb46cSSoby Mathew * and/or other materials provided with the distribution. 135dffb46cSSoby Mathew * 145dffb46cSSoby Mathew * Neither the name of ARM nor the names of its contributors may be used 155dffb46cSSoby Mathew * to endorse or promote products derived from this software without specific 165dffb46cSSoby Mathew * prior written permission. 175dffb46cSSoby Mathew * 185dffb46cSSoby Mathew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 195dffb46cSSoby Mathew * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 205dffb46cSSoby Mathew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 215dffb46cSSoby Mathew * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 225dffb46cSSoby Mathew * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 235dffb46cSSoby Mathew * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 245dffb46cSSoby Mathew * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 255dffb46cSSoby Mathew * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 265dffb46cSSoby Mathew * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 275dffb46cSSoby Mathew * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 285dffb46cSSoby Mathew * POSSIBILITY OF SUCH DAMAGE. 295dffb46cSSoby Mathew */ 305dffb46cSSoby Mathew 315dffb46cSSoby Mathew #ifndef __PSCI_LIB_H__ 325dffb46cSSoby Mathew #define __PSCI_LIB_H__ 335dffb46cSSoby Mathew 345dffb46cSSoby Mathew #include <ep_info.h> 355dffb46cSSoby Mathew 365dffb46cSSoby Mathew #ifndef __ASSEMBLY__ 375dffb46cSSoby Mathew #include <types.h> 385dffb46cSSoby Mathew 395dffb46cSSoby Mathew /******************************************************************************* 405dffb46cSSoby Mathew * Optional structure populated by the Secure Payload Dispatcher to be given a 415dffb46cSSoby Mathew * chance to perform any bookkeeping before PSCI executes a power management 425dffb46cSSoby Mathew * operation. It also allows PSCI to determine certain properties of the SP e.g. 435dffb46cSSoby Mathew * migrate capability etc. 445dffb46cSSoby Mathew ******************************************************************************/ 455dffb46cSSoby Mathew typedef struct spd_pm_ops { 465dffb46cSSoby Mathew void (*svc_on)(u_register_t target_cpu); 475dffb46cSSoby Mathew int32_t (*svc_off)(u_register_t __unused); 485dffb46cSSoby Mathew void (*svc_suspend)(u_register_t max_off_pwrlvl); 495dffb46cSSoby Mathew void (*svc_on_finish)(u_register_t __unused); 505dffb46cSSoby Mathew void (*svc_suspend_finish)(u_register_t max_off_pwrlvl); 515dffb46cSSoby Mathew int32_t (*svc_migrate)(u_register_t from_cpu, u_register_t to_cpu); 525dffb46cSSoby Mathew int32_t (*svc_migrate_info)(u_register_t *resident_cpu); 535dffb46cSSoby Mathew void (*svc_system_off)(void); 545dffb46cSSoby Mathew void (*svc_system_reset)(void); 555dffb46cSSoby Mathew } spd_pm_ops_t; 565dffb46cSSoby Mathew 575dffb46cSSoby Mathew /* 585dffb46cSSoby Mathew * Function prototype for the warmboot entrypoint function which will be 595dffb46cSSoby Mathew * programmed in the mailbox by the platform. 605dffb46cSSoby Mathew */ 615dffb46cSSoby Mathew typedef void (*mailbox_entrypoint_t)(void); 625dffb46cSSoby Mathew 635dffb46cSSoby Mathew /****************************************************************************** 645dffb46cSSoby Mathew * Structure to pass PSCI Library arguments. 655dffb46cSSoby Mathew *****************************************************************************/ 665dffb46cSSoby Mathew typedef struct psci_lib_args { 675dffb46cSSoby Mathew /* The version information of PSCI Library Interface */ 685dffb46cSSoby Mathew param_header_t h; 695dffb46cSSoby Mathew /* The warm boot entrypoint function */ 705dffb46cSSoby Mathew mailbox_entrypoint_t mailbox_ep; 715dffb46cSSoby Mathew } psci_lib_args_t; 725dffb46cSSoby Mathew 735dffb46cSSoby Mathew /* Helper macro to set the psci_lib_args_t structure at runtime */ 745dffb46cSSoby Mathew #define SET_PSCI_LIB_ARGS_V1(_p, _entry) do { \ 755dffb46cSSoby Mathew SET_PARAM_HEAD(_p, PARAM_PSCI_LIB_ARGS, VERSION_1, 0); \ 765dffb46cSSoby Mathew (_p)->mailbox_ep = (_entry); \ 775dffb46cSSoby Mathew } while (0) 785dffb46cSSoby Mathew 795dffb46cSSoby Mathew /* Helper macro to define the psci_lib_args_t statically */ 805dffb46cSSoby Mathew #define DEFINE_STATIC_PSCI_LIB_ARGS_V1(_name, _entry) \ 815dffb46cSSoby Mathew static const psci_lib_args_t (_name) = { \ 825dffb46cSSoby Mathew .h.type = (uint8_t)PARAM_PSCI_LIB_ARGS, \ 835dffb46cSSoby Mathew .h.version = (uint8_t)VERSION_1, \ 845dffb46cSSoby Mathew .h.size = (uint16_t)sizeof(_name), \ 855dffb46cSSoby Mathew .h.attr = 0, \ 865dffb46cSSoby Mathew .mailbox_ep = (_entry) \ 875dffb46cSSoby Mathew } 885dffb46cSSoby Mathew 895dffb46cSSoby Mathew /* Helper macro to verify the pointer to psci_lib_args_t structure */ 905dffb46cSSoby Mathew #define VERIFY_PSCI_LIB_ARGS_V1(_p) ((_p) \ 915dffb46cSSoby Mathew && ((_p)->h.type == PARAM_PSCI_LIB_ARGS) \ 925dffb46cSSoby Mathew && ((_p)->h.version == VERSION_1) \ 935dffb46cSSoby Mathew && ((_p)->h.size == sizeof(*(_p))) \ 945dffb46cSSoby Mathew && ((_p)->h.attr == 0) \ 955dffb46cSSoby Mathew && ((_p)->mailbox_ep)) 965dffb46cSSoby Mathew 975dffb46cSSoby Mathew /****************************************************************************** 985dffb46cSSoby Mathew * PSCI Library Interfaces 995dffb46cSSoby Mathew *****************************************************************************/ 1005dffb46cSSoby Mathew u_register_t psci_smc_handler(uint32_t smc_fid, 1015dffb46cSSoby Mathew u_register_t x1, 1025dffb46cSSoby Mathew u_register_t x2, 1035dffb46cSSoby Mathew u_register_t x3, 1045dffb46cSSoby Mathew u_register_t x4, 1055dffb46cSSoby Mathew void *cookie, 1065dffb46cSSoby Mathew void *handle, 1075dffb46cSSoby Mathew u_register_t flags); 1085dffb46cSSoby Mathew int psci_setup(const psci_lib_args_t *lib_args); 109*b10d4499SJeenu Viswambharan int psci_secondaries_brought_up(void); 1105dffb46cSSoby Mathew void psci_warmboot_entrypoint(void); 1115dffb46cSSoby Mathew void psci_register_spd_pm_hook(const spd_pm_ops_t *pm); 1125dffb46cSSoby Mathew void psci_prepare_next_non_secure_ctx( 1135dffb46cSSoby Mathew entry_point_info_t *next_image_info); 1145dffb46cSSoby Mathew #endif /* __ASSEMBLY__ */ 1155dffb46cSSoby Mathew 1165dffb46cSSoby Mathew #endif /* __PSCI_LIB_H */ 1175dffb46cSSoby Mathew 118