1*fcd41e86SJacky Bai /* SPDX-License-Identifier: BSD-3-Clause */ 2*fcd41e86SJacky Bai /** 3*fcd41e86SJacky Bai * Copyright 2019-2024 NXP 4*fcd41e86SJacky Bai * 5*fcd41e86SJacky Bai * KEYWORDS: micro-power uPower driver API 6*fcd41e86SJacky Bai * ----------------------------------------------------------------------------- 7*fcd41e86SJacky Bai * PURPOSE: uPower driver API 8*fcd41e86SJacky Bai * ----------------------------------------------------------------------------- 9*fcd41e86SJacky Bai * PARAMETERS: 10*fcd41e86SJacky Bai * PARAM NAME RANGE:DESCRIPTION: DEFAULTS: UNITS 11*fcd41e86SJacky Bai * ----------------------------------------------------------------------------- 12*fcd41e86SJacky Bai * REUSE ISSUES: no reuse issues 13*fcd41e86SJacky Bai */ 14*fcd41e86SJacky Bai #ifndef UPWR_API_H 15*fcd41e86SJacky Bai #define UPWR_API_H 16*fcd41e86SJacky Bai 17*fcd41e86SJacky Bai #include "upmu.h" 18*fcd41e86SJacky Bai #include "upower_soc_defs.h" 19*fcd41e86SJacky Bai /****************************************************************************** 20*fcd41e86SJacky Bai * uPower API Overview and Concepts 21*fcd41e86SJacky Bai * 22*fcd41e86SJacky Bai * This API is intended to be used by the OS drivers (Linux, FreeRTOS etc) 23*fcd41e86SJacky Bai * as well as bare metal drivers to command and use services from the uPower. 24*fcd41e86SJacky Bai * It aims to be OS-independent. 25*fcd41e86SJacky Bai * 26*fcd41e86SJacky Bai * The API functions fall in 3 categories: 27*fcd41e86SJacky Bai * - initialization/start-up 28*fcd41e86SJacky Bai * - service requests 29*fcd41e86SJacky Bai * - auxiliary 30*fcd41e86SJacky Bai * 31*fcd41e86SJacky Bai * The communication with the uPower is mostly made through the Message Unit 32*fcd41e86SJacky Bai * (MU) IP. uPower provides one MU for each CPU cluster in a different 33*fcd41e86SJacky Bai * power domain. An API instance runs on each CPU cluster. 34*fcd41e86SJacky Bai * 35*fcd41e86SJacky Bai * The API assumes each SoC power domain/CPU cluster receives 2 interrupts 36*fcd41e86SJacky Bai * from the uPower MU: 37*fcd41e86SJacky Bai * 1. Tx/Rx, which is issued on both transmission and reception 38*fcd41e86SJacky Bai * 2. Exception interrupt, to handle critical alams, catastrophic errors, etc. 39*fcd41e86SJacky Bai * This interrupt should have a high priority, preferably an NMI. 40*fcd41e86SJacky Bai * 41*fcd41e86SJacky Bai * The normal uPower operation is done by service requests. There is an API 42*fcd41e86SJacky Bai * function for each service request, and all service requests send back a 43*fcd41e86SJacky Bai * response, at least to indicate success/failure. 44*fcd41e86SJacky Bai * The service request functions are non-blocking, and their completion can be 45*fcd41e86SJacky Bai * tracked in two ways: 46*fcd41e86SJacky Bai * 1. by a callback, registered when the service request call is made by 47*fcd41e86SJacky Bai * passing the callback function pointer; a NULL pointer may be passed, 48*fcd41e86SJacky Bai * in which case no callback is made. 49*fcd41e86SJacky Bai * 2. by polling, using the auxiliary functions upwr_req_status or 50*fcd41e86SJacky Bai * upwr_poll_req_status; 51*fcd41e86SJacky Bai * polling must be used if no callback is registered, but callbacks and 52*fcd41e86SJacky Bai * polling are completely independent. 53*fcd41e86SJacky Bai * 54*fcd41e86SJacky Bai * Note: a service request must not be started from a callback. 55*fcd41e86SJacky Bai * 56*fcd41e86SJacky Bai * uPower service requests are classified in Service Groups. 57*fcd41e86SJacky Bai * Each Service Group has a set of related functions, named upwr_XXX_, 58*fcd41e86SJacky Bai * where XXX is a 3-letter service group mnemonic. The service groups are: 59*fcd41e86SJacky Bai * - Exception Service Group - upwr_xcp_* 60*fcd41e86SJacky Bai * ~ gathers functions that deal with errors and other processes outside 61*fcd41e86SJacky Bai * the functional scope. 62*fcd41e86SJacky Bai * - Power Management Service Group - upwr_pwm_* 63*fcd41e86SJacky Bai * ~ functions to control switches, configure power modes, set internal voltage etc 64*fcd41e86SJacky Bai * - Delay Measurement Service Group - upwr_dlm_* 65*fcd41e86SJacky Bai * ~ delay measurements function using the process monitor and delay meter 66*fcd41e86SJacky Bai * - Voltage Measurement Service Group - upwr_vtm_* 67*fcd41e86SJacky Bai * ~ functions for voltage measurements, comparisons, alarms, power meter, set PMIC rail voltage 68*fcd41e86SJacky Bai * - Temperature Measurement Service Group - upwr_tpm_* 69*fcd41e86SJacky Bai * ~ functions for temperature measurements, comparisons, alarms 70*fcd41e86SJacky Bai * - Current Measurement Service Group - upwr_crm_* 71*fcd41e86SJacky Bai * ~ functions for current and charge measurement 72*fcd41e86SJacky Bai * - Diagnostic Service Group - upwr_dgn_* 73*fcd41e86SJacky Bai * ~ functions for log configuration and statistics collecting 74*fcd41e86SJacky Bai * 75*fcd41e86SJacky Bai * Service requests follow this "golden rule": 76*fcd41e86SJacky Bai * *** No two requests run simultaneously for the same service group, 77*fcd41e86SJacky Bai * on the same domain *** 78*fcd41e86SJacky Bai * They can run simultaneously on different domains (RTD/APD), and can also run 79*fcd41e86SJacky Bai * simultaneously if belong to different service groups (even on same domain). 80*fcd41e86SJacky Bai * Therefore, requests to the same service group on the same domain must be 81*fcd41e86SJacky Bai * serialized. A service request call returns error if there is another request 82*fcd41e86SJacky Bai * on the same service group pending, waiting a response (on the same domain). 83*fcd41e86SJacky Bai * 84*fcd41e86SJacky Bai * A request for continuous service does not block the service group. 85*fcd41e86SJacky Bai * For instance, a request to "measure the temperature each 10 miliseconds" 86*fcd41e86SJacky Bai * responds quickly, unlocks the service group, and the temperature 87*fcd41e86SJacky Bai * continues to be measured as requested, every 10 miliseconds from then on. 88*fcd41e86SJacky Bai * 89*fcd41e86SJacky Bai * Service Groups have a fixed priority in the API, from higher to lower: 90*fcd41e86SJacky Bai * 1. Exception 91*fcd41e86SJacky Bai * 2. Power Management 92*fcd41e86SJacky Bai * 3. Delay Measurement 93*fcd41e86SJacky Bai * 4. Voltage Measurement 94*fcd41e86SJacky Bai * 5. Current Measurement 95*fcd41e86SJacky Bai * 6. Temperature Measurement 96*fcd41e86SJacky Bai * 7. Diagnostics 97*fcd41e86SJacky Bai * 98*fcd41e86SJacky Bai * The priority above only affects the order in which requests are sent to the 99*fcd41e86SJacky Bai * uPower firmware: request to the higher priority Service Group is sent first, 100*fcd41e86SJacky Bai * even if the call was made later, if there is an MU transmission pending, 101*fcd41e86SJacky Bai * blocking it. The service priorities in the firmware depend on other factors. 102*fcd41e86SJacky Bai * 103*fcd41e86SJacky Bai * Services are requested using API functions. A service function returns with 104*fcd41e86SJacky Bai * no error if a request was successfully made, but it doesn't mean the service 105*fcd41e86SJacky Bai * was completed. The service is executed asynchronously, and returns a result 106*fcd41e86SJacky Bai * (at least success/fail) via a callback or polling for service status. 107*fcd41e86SJacky Bai * The possible service response codes are: 108*fcd41e86SJacky Bai * - UPWR_RESP_OK = 0, : no error 109*fcd41e86SJacky Bai * - UPWR_RESP_SG_BUSY : service group is busy 110*fcd41e86SJacky Bai * - UPWR_RESP_SHUTDOWN : services not up or shutting down 111*fcd41e86SJacky Bai * - UPWR_RESP_BAD_REQ : invalid request (usually invalid argumnents) 112*fcd41e86SJacky Bai * - UPWR_RESP_BAD_STATE : system state doesn't allow perform the request 113*fcd41e86SJacky Bai * - UPWR_RESP_UNINSTALLD : service or function not installed 114*fcd41e86SJacky Bai * - UPWR_RESP_UNINSTALLED : service or function not installed (alias) 115*fcd41e86SJacky Bai * - UPWR_RESP_RESOURCE : resource not available 116*fcd41e86SJacky Bai * - UPWR_RESP_TIMEOUT : service timeout 117*fcd41e86SJacky Bai */ 118*fcd41e86SJacky Bai 119*fcd41e86SJacky Bai /** 120*fcd41e86SJacky Bai * upwr_callb()-generic function pointer for a request return callback; 121*fcd41e86SJacky Bai * @sg: request service group 122*fcd41e86SJacky Bai * @func: service request function id. 123*fcd41e86SJacky Bai * @errcode: error code. 124*fcd41e86SJacky Bai * @ret: return value, if any. Note that a request may return a value even if 125*fcd41e86SJacky Bai * service error is returned (errcode != UPWR_RESP_OK); that is dependent on 126*fcd41e86SJacky Bai * the specific service. 127*fcd41e86SJacky Bai * 128*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 129*fcd41e86SJacky Bai * Return: none (void) 130*fcd41e86SJacky Bai */ 131*fcd41e86SJacky Bai typedef void (*upwr_callb)(upwr_sg_t sg, uint32_t func, 132*fcd41e86SJacky Bai upwr_resp_t errcode, ...); 133*fcd41e86SJacky Bai 134*fcd41e86SJacky Bai /**--------------------------------------------------------------- 135*fcd41e86SJacky Bai * INITIALIZATION, CONFIGURATION 136*fcd41e86SJacky Bai * 137*fcd41e86SJacky Bai * A reference uPower initialization sequence goes as follows: 138*fcd41e86SJacky Bai * 139*fcd41e86SJacky Bai * 1. host CPU calls upwr_init. 140*fcd41e86SJacky Bai * 2. (optional) host checks the ROM version and SoC code calling upwr_vers(...) 141*fcd41e86SJacky Bai * and optionally performs any configuration or workaround accordingly. 142*fcd41e86SJacky Bai * 3. host CPU calls upwr_start to start the uPower services, passing a 143*fcd41e86SJacky Bai * service option number. 144*fcd41e86SJacky Bai * If no RAM code is loaded or it has no service options, the launch option 145*fcd41e86SJacky Bai * number passed must be 0, which will start the services available in ROM. 146*fcd41e86SJacky Bai * upwr_start also receives a pointer to a callback called by the API 147*fcd41e86SJacky Bai * when the firmware is ready to receive service requests. 148*fcd41e86SJacky Bai * The callback may be replaced by polling, calling upwr_req_status in a loop 149*fcd41e86SJacky Bai * or upwr_poll_req_status; in this case the callback pointer may be NULL. 150*fcd41e86SJacky Bai * A host may call upwr_start even if the services were already started by 151*fcd41e86SJacky Bai * any host: if the launch option is the same, the response will be ok, 152*fcd41e86SJacky Bai * but will indicate error if the services were already started with a 153*fcd41e86SJacky Bai * different launch option. 154*fcd41e86SJacky Bai * 4. host waits for the callback calling, or polling finishing; 155*fcd41e86SJacky Bai * if no error is returned, it can start making service calls using the API. 156*fcd41e86SJacky Bai * 157*fcd41e86SJacky Bai * Variations on that reference sequence are possible: 158*fcd41e86SJacky Bai * - the uPower services can be started using the ROM code only, which includes 159*fcd41e86SJacky Bai * the basic Power Management services, among others, with launch option 160*fcd41e86SJacky Bai * number = 0. 161*fcd41e86SJacky Bai * The code RAM can be loaded while these services are running and, 162*fcd41e86SJacky Bai * when the loading is done, the services can be re-started with these 2 163*fcd41e86SJacky Bai * requests executed in order: upwr_xcp_shutdown and upwr_start, 164*fcd41e86SJacky Bai * using the newly loaded RAM code (launch option > 0). 165*fcd41e86SJacky Bai * 166*fcd41e86SJacky Bai * NOTE: the initialization call upwr_init is not effective and 167*fcd41e86SJacky Bai * returns error when called after the uPower services are started. 168*fcd41e86SJacky Bai */ 169*fcd41e86SJacky Bai 170*fcd41e86SJacky Bai /** 171*fcd41e86SJacky Bai * upwr_init() - API initialization; must be the first API call after reset. 172*fcd41e86SJacky Bai * @domain: SoC-dependent CPU domain id; identifier used by the firmware in 173*fcd41e86SJacky Bai * many services. Defined by SoC-dependent type soc_domain_t found in 174*fcd41e86SJacky Bai * upower_soc_defs.h. 175*fcd41e86SJacky Bai * @muptr: pointer to the MU instance. 176*fcd41e86SJacky Bai * @mallocptr: pointer to the memory allocation function 177*fcd41e86SJacky Bai * @physaddrptr: pointer to the function to convert pointers to 178*fcd41e86SJacky Bai * physical addresses. If NULL, no conversion is made (pointer=physical address) 179*fcd41e86SJacky Bai * @isrinstptr: pointer to the function to install the uPower ISR callbacks; 180*fcd41e86SJacky Bai * the function receives the pointers to the MU tx/rx and Exception ISRs 181*fcd41e86SJacky Bai * callbacks, which must be called from the actual system ISRs. 182*fcd41e86SJacky Bai * The function pointed by isrinstptr must also enable the interrupt at the 183*fcd41e86SJacky Bai * core/interrupt controller, but must not enable the interrupt at the MU IP. 184*fcd41e86SJacky Bai * The system ISRs are responsible for dealing with the interrupt controller, 185*fcd41e86SJacky Bai * performing any other context save/restore, and any other housekeeping. 186*fcd41e86SJacky Bai * @lockptr: pointer to a function that prevents MU interrupts (if argrument=1) 187*fcd41e86SJacky Bai * or allows it (if argument=0). The API calls this function to make small 188*fcd41e86SJacky Bai * specific code portions thread safe. Only MU interrupts must be avoided, 189*fcd41e86SJacky Bai * the code may be suspended for other reasons. 190*fcd41e86SJacky Bai * If no MU interrupts can happen during the execution of an API call or 191*fcd41e86SJacky Bai * callback, even if enabled, for some other reason (e.g. interrupt priority), 192*fcd41e86SJacky Bai * then this argument may be NULL. 193*fcd41e86SJacky Bai * 194*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 195*fcd41e86SJacky Bai * Return: 0 if ok, 196*fcd41e86SJacky Bai * -1 if failed to allocate memory, or use some other resource. 197*fcd41e86SJacky Bai * -2 if any argument is invalid. 198*fcd41e86SJacky Bai * -3 if failed to send the ping message. 199*fcd41e86SJacky Bai * -4 if failed to receive the initialization message, or was invalid 200*fcd41e86SJacky Bai */ 201*fcd41e86SJacky Bai 202*fcd41e86SJacky Bai /* malloc function ptr */ 203*fcd41e86SJacky Bai typedef void* (*upwr_malloc_ptr_t)(unsigned int size); 204*fcd41e86SJacky Bai 205*fcd41e86SJacky Bai /* pointer->physical address conversion function ptr */ 206*fcd41e86SJacky Bai typedef void* (*upwr_phyadr_ptr_t)(const void *addr); 207*fcd41e86SJacky Bai 208*fcd41e86SJacky Bai typedef uint32_t upwr_api_state_t; 209*fcd41e86SJacky Bai 210*fcd41e86SJacky Bai extern volatile upwr_api_state_t api_state; 211*fcd41e86SJacky Bai 212*fcd41e86SJacky Bai /* 213*fcd41e86SJacky Bai * upwr_lock_ptr_t: pointer to a function that prevents MU interrupts 214*fcd41e86SJacky Bai * (if argrument lock=1) or allows it (if argument lock=0). 215*fcd41e86SJacky Bai * The API calls this function to make small specific code portions thread safe. 216*fcd41e86SJacky Bai * Only MU interrupts must be avoided, the code may be suspended for other 217*fcd41e86SJacky Bai * reasons. 218*fcd41e86SJacky Bai */ 219*fcd41e86SJacky Bai typedef void (*upwr_lock_ptr_t)(int lock); 220*fcd41e86SJacky Bai 221*fcd41e86SJacky Bai typedef void (*upwr_isr_callb)(void); 222*fcd41e86SJacky Bai 223*fcd41e86SJacky Bai typedef void (*upwr_inst_isr_ptr_t)(upwr_isr_callb txrx_isr, 224*fcd41e86SJacky Bai upwr_isr_callb excp_isr); 225*fcd41e86SJacky Bai void upwr_start_callb(void); 226*fcd41e86SJacky Bai 227*fcd41e86SJacky Bai int upwr_init(soc_domain_t domain, struct MU_t *muptr, 228*fcd41e86SJacky Bai const upwr_malloc_ptr_t mallocptr, 229*fcd41e86SJacky Bai const upwr_phyadr_ptr_t phyadrptr, 230*fcd41e86SJacky Bai const upwr_inst_isr_ptr_t isrinstptr, 231*fcd41e86SJacky Bai const upwr_lock_ptr_t lockptr); 232*fcd41e86SJacky Bai 233*fcd41e86SJacky Bai /** 234*fcd41e86SJacky Bai * upwr_start() - Starts the uPower services. 235*fcd41e86SJacky Bai * @launchopt: a number to select between multiple launch options, 236*fcd41e86SJacky Bai * that may define, among other things, which services will be started, 237*fcd41e86SJacky Bai * or which services implementations, features etc. 238*fcd41e86SJacky Bai * launchopt = 0 selects a subset of services implemented in ROM; 239*fcd41e86SJacky Bai * any other number selects service sets implemented in RAM, launched 240*fcd41e86SJacky Bai * by the firmware function ram_launch; if an invalid launchopt value is passed, 241*fcd41e86SJacky Bai * no services are started, and the callback returns error (see below). 242*fcd41e86SJacky Bai * @rdycallb: pointer to the callback to be called when the uPower is ready 243*fcd41e86SJacky Bai * to receive service requests. NULL if no callback needed. 244*fcd41e86SJacky Bai * The callback receives as arguments the RAM firmware version numbers. 245*fcd41e86SJacky Bai * If all 3 numbers (vmajor, vminor, vfixes) are 0, that means the 246*fcd41e86SJacky Bai * service launching failed. 247*fcd41e86SJacky Bai * Firmware version numbers will be the same as ROM if launchopt = 0, 248*fcd41e86SJacky Bai * selecting the ROM services. 249*fcd41e86SJacky Bai * 250*fcd41e86SJacky Bai * upwr_start can be called by any domain even if the services are already 251*fcd41e86SJacky Bai * started: it has no effect, returning success, if the launch option is the 252*fcd41e86SJacky Bai * same as the one that actually started the service, and returns error if 253*fcd41e86SJacky Bai * called with a different option. 254*fcd41e86SJacky Bai * 255*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 256*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 257*fcd41e86SJacky Bai * not. 258*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 259*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 260*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 261*fcd41e86SJacky Bai * 262*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 263*fcd41e86SJacky Bai * Return: 0 if ok, 264*fcd41e86SJacky Bai * -1 if a resource failed, 265*fcd41e86SJacky Bai * -2 if the domain passed is the same as the caller, 266*fcd41e86SJacky Bai * -3 if called in an invalid API state 267*fcd41e86SJacky Bai */ 268*fcd41e86SJacky Bai 269*fcd41e86SJacky Bai extern void upwr_txrx_isr(void); 270*fcd41e86SJacky Bai 271*fcd41e86SJacky Bai typedef void (*upwr_rdy_callb)(uint32_t vmajor, uint32_t vminor, uint32_t vfixes); 272*fcd41e86SJacky Bai 273*fcd41e86SJacky Bai int upwr_start(uint32_t launchopt, const upwr_rdy_callb rdycallb); 274*fcd41e86SJacky Bai 275*fcd41e86SJacky Bai 276*fcd41e86SJacky Bai /**--------------------------------------------------------------- 277*fcd41e86SJacky Bai * EXCEPTION SERVICE GROUP 278*fcd41e86SJacky Bai */ 279*fcd41e86SJacky Bai 280*fcd41e86SJacky Bai /** 281*fcd41e86SJacky Bai * upwr_xcp_config() - Applies general uPower configurations. 282*fcd41e86SJacky Bai * @config: pointer to the uPower SoC-dependent configuration struct 283*fcd41e86SJacky Bai * upwr_xcp_config_t defined in upower_soc_defs.h. NULL may be passed, meaning 284*fcd41e86SJacky Bai * a request to read the configuration, in which case it appears in the callback 285*fcd41e86SJacky Bai * argument ret, or can be pointed by argument retptr in the upwr_req_status and 286*fcd41e86SJacky Bai * upwr_poll_req_status calls, casted to upwr_xcp_config_t. 287*fcd41e86SJacky Bai * @callb: pointer to the callback to be called when the uPower has finished 288*fcd41e86SJacky Bai * the configuration, or NULL if no callback needed (polling used instead). 289*fcd41e86SJacky Bai * 290*fcd41e86SJacky Bai * Some configurations are targeted for a specific domain (see the struct 291*fcd41e86SJacky Bai * upwr_xcp_config_t definition in upower_soc_defs.h); this call has implicit 292*fcd41e86SJacky Bai * domain target (the same domain from which is called). 293*fcd41e86SJacky Bai * 294*fcd41e86SJacky Bai * The return value is always the current configuration value, either in a 295*fcd41e86SJacky Bai * read-only request (config = NULL) or after setting a new configuration 296*fcd41e86SJacky Bai * (non-NULL config). 297*fcd41e86SJacky Bai * 298*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 299*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 300*fcd41e86SJacky Bai * not. 301*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 302*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 303*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 304*fcd41e86SJacky Bai * 305*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 306*fcd41e86SJacky Bai * Return: 0 if ok, 307*fcd41e86SJacky Bai * -1 if service group is busy, 308*fcd41e86SJacky Bai * -3 if called in an invalid API state 309*fcd41e86SJacky Bai */ 310*fcd41e86SJacky Bai 311*fcd41e86SJacky Bai int upwr_xcp_config(const upwr_xcp_config_t *config, const upwr_callb callb); 312*fcd41e86SJacky Bai 313*fcd41e86SJacky Bai /** 314*fcd41e86SJacky Bai * upwr_xcp_sw_alarm() - Makes uPower issue an alarm interrupt to given domain. 315*fcd41e86SJacky Bai * @domain: identifier of the domain to alarm. Defined by SoC-dependent type 316*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 317*fcd41e86SJacky Bai * @code: alarm code. Defined by SoC-dependent type upwr_alarm_t found in 318*fcd41e86SJacky Bai * upower_soc_defs.h. 319*fcd41e86SJacky Bai * @callb: pointer to the callback to be called when the uPower has finished 320*fcd41e86SJacky Bai * the alarm, or NULL if no callback needed (polling used instead). 321*fcd41e86SJacky Bai * 322*fcd41e86SJacky Bai * The function requests the uPower to issue an alarm of the given code as if 323*fcd41e86SJacky Bai * it had originated internally. This service is useful mainly to test the 324*fcd41e86SJacky Bai * system response to such alarms, or to make the system handle a similar alarm 325*fcd41e86SJacky Bai * situation detected externally to uPower. 326*fcd41e86SJacky Bai * 327*fcd41e86SJacky Bai * The system ISR/code handling the alarm may retrieve the alarm code by calling 328*fcd41e86SJacky Bai * the auxiliary function upwr_alarm_code. 329*fcd41e86SJacky Bai * 330*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 331*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 332*fcd41e86SJacky Bai * not. 333*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 334*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 335*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 336*fcd41e86SJacky Bai * 337*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 338*fcd41e86SJacky Bai * Return: 0 if ok, 339*fcd41e86SJacky Bai * -1 if service group is busy, 340*fcd41e86SJacky Bai * -3 if called in an invalid API state 341*fcd41e86SJacky Bai */ 342*fcd41e86SJacky Bai 343*fcd41e86SJacky Bai int upwr_xcp_sw_alarm(soc_domain_t domain, upwr_alarm_t code, 344*fcd41e86SJacky Bai const upwr_callb callb); 345*fcd41e86SJacky Bai 346*fcd41e86SJacky Bai /** 347*fcd41e86SJacky Bai * upwr_xcp_set_ddr_retention() - M33/A35 can use this API to set/clear ddr retention 348*fcd41e86SJacky Bai * @domain: identifier of the caller domain. 349*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 350*fcd41e86SJacky Bai * @enable: true, means that set ddr retention, false clear ddr retention. 351*fcd41e86SJacky Bai * @callb: NULL 352*fcd41e86SJacky Bai * 353*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 354*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 355*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 356*fcd41e86SJacky Bai * 357*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 358*fcd41e86SJacky Bai * Return: 0 if ok, 359*fcd41e86SJacky Bai * -1 if service group is busy, 360*fcd41e86SJacky Bai * -3 if called in an invalid API state 361*fcd41e86SJacky Bai */ 362*fcd41e86SJacky Bai 363*fcd41e86SJacky Bai int upwr_xcp_set_ddr_retention(soc_domain_t domain, uint32_t enable, 364*fcd41e86SJacky Bai const upwr_callb callb); 365*fcd41e86SJacky Bai 366*fcd41e86SJacky Bai /** 367*fcd41e86SJacky Bai * upwr_xcp_set_mipi_dsi_ena() - M33/A35 can use this API to set/clear mipi dsi ena 368*fcd41e86SJacky Bai * @domain: identifier of the caller domain. 369*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 370*fcd41e86SJacky Bai * @enable: true, means that set ddr retention, false clear ddr retention. 371*fcd41e86SJacky Bai * @callb: NULL 372*fcd41e86SJacky Bai * 373*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 374*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 375*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 376*fcd41e86SJacky Bai * 377*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 378*fcd41e86SJacky Bai * Return: 0 if ok, 379*fcd41e86SJacky Bai * -1 if service group is busy, 380*fcd41e86SJacky Bai * -3 if called in an invalid API state 381*fcd41e86SJacky Bai */ 382*fcd41e86SJacky Bai 383*fcd41e86SJacky Bai int upwr_xcp_set_mipi_dsi_ena(soc_domain_t domain, uint32_t enable, 384*fcd41e86SJacky Bai const upwr_callb callb); 385*fcd41e86SJacky Bai 386*fcd41e86SJacky Bai /** 387*fcd41e86SJacky Bai * upwr_xcp_get_mipi_dsi_ena() - M33/A35 can use this API to get mipi dsi ena status 388*fcd41e86SJacky Bai * @domain: identifier of the caller domain. 389*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 390*fcd41e86SJacky Bai * @callb: NULL 391*fcd41e86SJacky Bai * 392*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 393*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 394*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 395*fcd41e86SJacky Bai * 396*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 397*fcd41e86SJacky Bai * Return: 0 if ok, 398*fcd41e86SJacky Bai * -1 if service group is busy, 399*fcd41e86SJacky Bai * -3 if called in an invalid API state 400*fcd41e86SJacky Bai */ 401*fcd41e86SJacky Bai 402*fcd41e86SJacky Bai int upwr_xcp_get_mipi_dsi_ena(soc_domain_t domain, const upwr_callb callb); 403*fcd41e86SJacky Bai 404*fcd41e86SJacky Bai /** 405*fcd41e86SJacky Bai * upwr_xcp_set_osc_mode() - M33/A35 can use this API to set uPower OSC mode 406*fcd41e86SJacky Bai * @domain: identifier of the caller domain. 407*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 408*fcd41e86SJacky Bai * @osc_mode, 0 means low frequency, not 0 means high frequency. 409*fcd41e86SJacky Bai * @callb: NULL 410*fcd41e86SJacky Bai * 411*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 412*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 413*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 414*fcd41e86SJacky Bai * 415*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 416*fcd41e86SJacky Bai * Return: 0 if ok, 417*fcd41e86SJacky Bai * -1 if service group is busy, 418*fcd41e86SJacky Bai * -3 if called in an invalid API state 419*fcd41e86SJacky Bai */ 420*fcd41e86SJacky Bai int upwr_xcp_set_osc_mode(soc_domain_t domain, uint32_t osc_mode, 421*fcd41e86SJacky Bai const upwr_callb callb); 422*fcd41e86SJacky Bai 423*fcd41e86SJacky Bai /** 424*fcd41e86SJacky Bai * upwr_xcp_set_rtd_use_ddr() - M33 call this API to inform uPower, M33 is using ddr 425*fcd41e86SJacky Bai * @domain: identifier of the caller domain. 426*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 427*fcd41e86SJacky Bai * @is_use_ddr: not 0, true, means that RTD is using ddr. 0, false, means that, RTD 428*fcd41e86SJacky Bai * is not using ddr. 429*fcd41e86SJacky Bai * @callb: NULL 430*fcd41e86SJacky Bai * 431*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 432*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 433*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 434*fcd41e86SJacky Bai * 435*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 436*fcd41e86SJacky Bai * Return: 0 if ok, 437*fcd41e86SJacky Bai * -1 if service group is busy, 438*fcd41e86SJacky Bai * -3 if called in an invalid API state 439*fcd41e86SJacky Bai */ 440*fcd41e86SJacky Bai int upwr_xcp_set_rtd_use_ddr(soc_domain_t domain, uint32_t is_use_ddr, 441*fcd41e86SJacky Bai const upwr_callb callb); 442*fcd41e86SJacky Bai 443*fcd41e86SJacky Bai /** 444*fcd41e86SJacky Bai * upwr_xcp_set_rtd_apd_llwu() - M33/A35 can use this API to set/clear rtd_llwu apd_llwu 445*fcd41e86SJacky Bai * @domain: set which domain (RTD_DOMAIN, APD_DOMAIN) LLWU. 446*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 447*fcd41e86SJacky Bai * @enable: true, means that set rtd_llwu or apd_llwu, false clear rtd_llwu or apd_llwu. 448*fcd41e86SJacky Bai * @callb: NULL 449*fcd41e86SJacky Bai * 450*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 451*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 452*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 453*fcd41e86SJacky Bai * 454*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 455*fcd41e86SJacky Bai * Return: 0 if ok, 456*fcd41e86SJacky Bai * -1 if service group is busy, 457*fcd41e86SJacky Bai * -3 if called in an invalid API state 458*fcd41e86SJacky Bai */ 459*fcd41e86SJacky Bai int upwr_xcp_set_rtd_apd_llwu(soc_domain_t domain, uint32_t enable, 460*fcd41e86SJacky Bai const upwr_callb callb); 461*fcd41e86SJacky Bai /** 462*fcd41e86SJacky Bai * upwr_xcp_shutdown() - Shuts down all uPower services and power mode tasks. 463*fcd41e86SJacky Bai * @callb: pointer to the callback to be called when the uPower has finished 464*fcd41e86SJacky Bai * the shutdown, or NULL if no callback needed 465*fcd41e86SJacky Bai * (polling used instead). 466*fcd41e86SJacky Bai * 467*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 468*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 469*fcd41e86SJacky Bai * not. 470*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 471*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 472*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 473*fcd41e86SJacky Bai * 474*fcd41e86SJacky Bai * At the callback the uPower/API is back to initialization/start-up phase, 475*fcd41e86SJacky Bai * so service request calls return error. 476*fcd41e86SJacky Bai * 477*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 478*fcd41e86SJacky Bai * Return: 0 if ok, 479*fcd41e86SJacky Bai * -1 if service group is busy, 480*fcd41e86SJacky Bai * -3 if called in an invalid API state 481*fcd41e86SJacky Bai */ 482*fcd41e86SJacky Bai int upwr_xcp_shutdown(const upwr_callb callb); 483*fcd41e86SJacky Bai 484*fcd41e86SJacky Bai /** 485*fcd41e86SJacky Bai * upwr_xcp_i2c_access() - Performs an access through the uPower I2C interface. 486*fcd41e86SJacky Bai * @addr: I2C slave address, up to 10 bits. 487*fcd41e86SJacky Bai * @data_size: determines the access direction and data size in bytes, up to 4; 488*fcd41e86SJacky Bai * negetive data_size determines a read access with size -data_size; 489*fcd41e86SJacky Bai * positive data_size determines a write access with size data_size; 490*fcd41e86SJacky Bai * data_size=0 is invalid, making the service return error UPWR_RESP_BAD_REQ. 491*fcd41e86SJacky Bai * @subaddr_size: size of the sub-address in bytes, up to 4; if subaddr_size=0, 492*fcd41e86SJacky Bai * no subaddress is used. 493*fcd41e86SJacky Bai * @subaddr: sub-address, only used if subaddr_size > 0. 494*fcd41e86SJacky Bai * @wdata: write data, up to 4 bytes; ignored if data_size < 0 (read) 495*fcd41e86SJacky Bai * @callb: pointer to the callback to be called when the uPower has finished 496*fcd41e86SJacky Bai * the access, or NULL if no callback needed 497*fcd41e86SJacky Bai * (polling used instead). 498*fcd41e86SJacky Bai * 499*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 500*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 501*fcd41e86SJacky Bai * not. 502*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 503*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 504*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_EXCEPT as the service group argument. 505*fcd41e86SJacky Bai * 506*fcd41e86SJacky Bai * The service performs a read (data_size < 0) or a write (data_size > 0) of 507*fcd41e86SJacky Bai * up to 4 bytes on the uPower I2C interface. The data read from I2C comes via 508*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 509*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 510*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 511*fcd41e86SJacky Bai * 512*fcd41e86SJacky Bai * Sub-addressing is supported, with sub-address size determined by the argument 513*fcd41e86SJacky Bai * subaddr_size, up to 4 bytes. Sub-addressing is not used if subaddr_size=0. 514*fcd41e86SJacky Bai * 515*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 516*fcd41e86SJacky Bai * Return: 0 if ok, 517*fcd41e86SJacky Bai * -1 if service group is busy, 518*fcd41e86SJacky Bai * -3 if called in an invalid API state 519*fcd41e86SJacky Bai */ 520*fcd41e86SJacky Bai int upwr_xcp_i2c_access(uint16_t addr, int8_t data_size, uint8_t subaddr_size, 521*fcd41e86SJacky Bai uint32_t subaddr, uint32_t wdata, 522*fcd41e86SJacky Bai const upwr_callb callb); 523*fcd41e86SJacky Bai 524*fcd41e86SJacky Bai 525*fcd41e86SJacky Bai /**--------------------------------------------------------------- 526*fcd41e86SJacky Bai * POWER MANAGEMENT SERVICE GROUP 527*fcd41e86SJacky Bai */ 528*fcd41e86SJacky Bai 529*fcd41e86SJacky Bai /** 530*fcd41e86SJacky Bai * upwr_pwm_dom_power_on() - Commands uPower to power on the platform of other 531*fcd41e86SJacky Bai * domain (not necessarily its core(s)); does not release the core reset. 532*fcd41e86SJacky Bai * @domain: identifier of the domain to power on. Defined by SoC-dependent type 533*fcd41e86SJacky Bai * soc_domain_t found in upower_soc_defs.h. 534*fcd41e86SJacky Bai * @boot_start: must be 1 to start the domain core(s) boot(s), releasing 535*fcd41e86SJacky Bai * its (their) resets, or 0 otherwise. 536*fcd41e86SJacky Bai * @pwroncallb: pointer to the callback to be called when the uPower has 537*fcd41e86SJacky Bai * finished the power on procedure, or NULL if no callback needed 538*fcd41e86SJacky Bai * (polling used instead). 539*fcd41e86SJacky Bai * 540*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 541*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 542*fcd41e86SJacky Bai * not. 543*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 544*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 545*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 546*fcd41e86SJacky Bai * 547*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 548*fcd41e86SJacky Bai * Return: 0 if ok, 549*fcd41e86SJacky Bai * -1 if service group is busy, 550*fcd41e86SJacky Bai * -2 if the domain passed is the same as the caller, 551*fcd41e86SJacky Bai * -3 if called in an invalid API state 552*fcd41e86SJacky Bai */ 553*fcd41e86SJacky Bai int upwr_pwm_dom_power_on(soc_domain_t domain, int boot_start, 554*fcd41e86SJacky Bai const upwr_callb pwroncallb); 555*fcd41e86SJacky Bai 556*fcd41e86SJacky Bai /** 557*fcd41e86SJacky Bai * upwr_pwm_boot_start() - Commands uPower to release the reset of other CPU(s), 558*fcd41e86SJacky Bai * starting their boots. 559*fcd41e86SJacky Bai * @domain: identifier of the domain to release the reset. Defined by 560*fcd41e86SJacky Bai * SoC-dependent type soc_domain_t found in upower_soc_defs.h. 561*fcd41e86SJacky Bai * @bootcallb: pointer to the callback to be called when the uPower has finished 562*fcd41e86SJacky Bai * the boot start procedure, or NULL if no callback needed 563*fcd41e86SJacky Bai * (polling used instead). 564*fcd41e86SJacky Bai * 565*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 566*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 567*fcd41e86SJacky Bai * not. 568*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 569*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 570*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 571*fcd41e86SJacky Bai * 572*fcd41e86SJacky Bai * The callback calling doesn't mean the CPUs boots have finished: 573*fcd41e86SJacky Bai * it only indicates that uPower released the CPUs resets, and can receive 574*fcd41e86SJacky Bai * other power management service group requests. 575*fcd41e86SJacky Bai * 576*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 577*fcd41e86SJacky Bai * Return: 0 if ok, 578*fcd41e86SJacky Bai * -1 if service group is busy, 579*fcd41e86SJacky Bai * -2 if the domain passed is the same as the caller, 580*fcd41e86SJacky Bai * -3 if called in an invalid API state 581*fcd41e86SJacky Bai */ 582*fcd41e86SJacky Bai int upwr_pwm_boot_start(soc_domain_t domain, const upwr_callb bootcallb); 583*fcd41e86SJacky Bai 584*fcd41e86SJacky Bai /** 585*fcd41e86SJacky Bai * upwr_pwm_param() - Changes Power Management parameters. 586*fcd41e86SJacky Bai * @param: pointer to a parameter structure upwr_pwm_param_t, SoC-dependent, 587*fcd41e86SJacky Bai * defined in upwr_soc_defines.h. NULL may be passed, meaning 588*fcd41e86SJacky Bai * a request to read the parameter set, in which case it appears in the callback 589*fcd41e86SJacky Bai * argument ret, or can be pointed by argument retptr in the upwr_req_status and 590*fcd41e86SJacky Bai * upwr_poll_req_status calls, casted to upwr_pwm_param_t. 591*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 592*fcd41e86SJacky Bai * 593*fcd41e86SJacky Bai * The return value is always the current parameter set value, either in a 594*fcd41e86SJacky Bai * read-only request (param = NULL) or after setting a new parameter 595*fcd41e86SJacky Bai * (non-NULL param). 596*fcd41e86SJacky Bai * 597*fcd41e86SJacky Bai * Some parameters may be targeted for a specific domain (see the struct 598*fcd41e86SJacky Bai * upwr_pwm_param_t definition in upower_soc_defs.h); this call has implicit 599*fcd41e86SJacky Bai * domain target (the same domain from which is called). 600*fcd41e86SJacky Bai * 601*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 602*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded or 603*fcd41e86SJacky Bai * not. 604*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 605*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 606*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 607*fcd41e86SJacky Bai * 608*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 609*fcd41e86SJacky Bai * Return: 0 if ok, 610*fcd41e86SJacky Bai * -1 if service group is busy, 611*fcd41e86SJacky Bai * -3 if called in an invalid API state 612*fcd41e86SJacky Bai */ 613*fcd41e86SJacky Bai int upwr_pwm_param(upwr_pwm_param_t *param, const upwr_callb callb); 614*fcd41e86SJacky Bai 615*fcd41e86SJacky Bai /** 616*fcd41e86SJacky Bai * upwr_pwm_chng_reg_voltage() - Changes the voltage at a given regulator. 617*fcd41e86SJacky Bai * @reg: regulator id. 618*fcd41e86SJacky Bai * @volt: voltage value; value unit is SoC-dependent, converted from mV by the 619*fcd41e86SJacky Bai * macro UPWR_VOLT_MILIV, or from micro-Volts by the macro UPWR_VOLT_MICROV, 620*fcd41e86SJacky Bai * both macros in upower_soc_defs.h 621*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 622*fcd41e86SJacky Bai * 623*fcd41e86SJacky Bai * The function requests uPower to change the voltage of the given regulator. 624*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 625*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 626*fcd41e86SJacky Bai * temperature and frequency. 627*fcd41e86SJacky Bai * 628*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 629*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 630*fcd41e86SJacky Bai * or not. 631*fcd41e86SJacky Bai * 632*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 633*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 634*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 635*fcd41e86SJacky Bai * 636*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 637*fcd41e86SJacky Bai * Return: 0 if ok, 638*fcd41e86SJacky Bai * -1 if service group is busy, 639*fcd41e86SJacky Bai * -3 if called in an invalid API state 640*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 641*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 642*fcd41e86SJacky Bai */ 643*fcd41e86SJacky Bai int upwr_pwm_chng_reg_voltage(uint32_t reg, uint32_t volt, upwr_callb callb); 644*fcd41e86SJacky Bai 645*fcd41e86SJacky Bai /** 646*fcd41e86SJacky Bai * upwr_pwm_freq_setup() - Determines the next frequency target for a given 647*fcd41e86SJacky Bai * domain and current frequency. 648*fcd41e86SJacky Bai * @domain: identifier of the domain to change frequency. Defined by 649*fcd41e86SJacky Bai * SoC-dependent type soc_domain_t found in upower_soc_defs.h. 650*fcd41e86SJacky Bai * @rail: the pmic regulator number for the target domain. 651*fcd41e86SJacky Bai * @stage: DVA adjust stage 652*fcd41e86SJacky Bai * refer to upower_defs.h "DVA adjust stage" 653*fcd41e86SJacky Bai * @target_freq: the target adjust frequency, accurate to MHz 654*fcd41e86SJacky Bai * 655*fcd41e86SJacky Bai * refer to upower_defs.h structure definition upwr_pwm_freq_msg 656*fcd41e86SJacky Bai * 657*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 658*fcd41e86SJacky Bai * 659*fcd41e86SJacky Bai * The DVA algorithm is broken down into two phases. 660*fcd41e86SJacky Bai * The first phase uses a look up table to get a safe operating voltage 661*fcd41e86SJacky Bai * for the requested frequency. 662*fcd41e86SJacky Bai * This voltage is guaranteed to work over process and temperature. 663*fcd41e86SJacky Bai * 664*fcd41e86SJacky Bai * The second step of the second phase is to measure the temperature 665*fcd41e86SJacky Bai * using the uPower Temperature Sensor module. 666*fcd41e86SJacky Bai * This is accomplished by doing a binary search of the TSEL bit field 667*fcd41e86SJacky Bai * in the Temperature Measurement Register (TMR). 668*fcd41e86SJacky Bai * The search is repeated until the THIGH bit fields in the same register change value. 669*fcd41e86SJacky Bai * There are 3 temperature sensors in 8ULP (APD, AVD, and RTD). 670*fcd41e86SJacky Bai * 671*fcd41e86SJacky Bai * 672*fcd41e86SJacky Bai * The second phase is the fine adjust of the voltage. 673*fcd41e86SJacky Bai * This stage is entered only when the new frequency requested 674*fcd41e86SJacky Bai * by application was already set as well as the voltage for that frequency. 675*fcd41e86SJacky Bai * The first step of the fine adjust is to find what is the current margins 676*fcd41e86SJacky Bai * for the monitored critical paths, or, in other words, 677*fcd41e86SJacky Bai * how many delay cells will be necessary to generate a setup-timing violation. 678*fcd41e86SJacky Bai * The function informs uPower that the given domain frequency has changed or 679*fcd41e86SJacky Bai * will change to the given value. uPower firmware will then adjust voltage and 680*fcd41e86SJacky Bai * bias to cope with the new frequency (if decreasing) or prepare for it 681*fcd41e86SJacky Bai * (if increasing). The function must be called after decreasing the frequency, 682*fcd41e86SJacky Bai * and before increasing it. The actual increase in frequency must not occur 683*fcd41e86SJacky Bai * before the service returns its response. 684*fcd41e86SJacky Bai * 685*fcd41e86SJacky Bai * So, for increase clock frequency case, user need to call this API twice, 686*fcd41e86SJacky Bai * the first stage gross adjust and the second stage fine adjust. 687*fcd41e86SJacky Bai * 688*fcd41e86SJacky Bai * for reduce clock frequency case, user can only call this API once, 689*fcd41e86SJacky Bai * full stage (combine gross stage and fine adjust) 690*fcd41e86SJacky Bai * 691*fcd41e86SJacky Bai * The request is executed if arguments are within range. 692*fcd41e86SJacky Bai * 693*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 694*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 695*fcd41e86SJacky Bai * or not. 696*fcd41e86SJacky Bai * 697*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 698*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 699*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 700*fcd41e86SJacky Bai * 701*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 702*fcd41e86SJacky Bai * Return: 0 if ok, 703*fcd41e86SJacky Bai * -1 if service group is busy, 704*fcd41e86SJacky Bai * -3 if called in an invalid API state 705*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 706*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 707*fcd41e86SJacky Bai */ 708*fcd41e86SJacky Bai int upwr_pwm_freq_setup(soc_domain_t domain, uint32_t rail, uint32_t stage, 709*fcd41e86SJacky Bai uint32_t target_freq, upwr_callb callb); 710*fcd41e86SJacky Bai 711*fcd41e86SJacky Bai /** 712*fcd41e86SJacky Bai * upwr_pwm_power_on()- Powers on (not off) one or more switches and ROM/RAMs. 713*fcd41e86SJacky Bai * @swton: pointer to an array of words that tells which power switches to 714*fcd41e86SJacky Bai * turn on. Each word in the array has 1 bit for each switch. 715*fcd41e86SJacky Bai * A bit=1 means the respective switch must be turned on, 716*fcd41e86SJacky Bai * bit = 0 means it will stay unchanged (on or off). 717*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no switch will be changed, 718*fcd41e86SJacky Bai * unless a memory that it feeds must be turned on. 719*fcd41e86SJacky Bai * WARNING: swton must not point to the first shared memory address. 720*fcd41e86SJacky Bai * @memon: pointer to an array of words that tells which memories to turn on. 721*fcd41e86SJacky Bai * Each word in the array has 1 bit for each switch. 722*fcd41e86SJacky Bai * A bit=1 means the respective memory must be turned on, both array and 723*fcd41e86SJacky Bai * periphery logic; 724*fcd41e86SJacky Bai * bit = 0 means it will stay unchanged (on or off). 725*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no memory will be changed. 726*fcd41e86SJacky Bai * WARNING: memon must not point to the first shared memory address. 727*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applyed. 728*fcd41e86SJacky Bai * NULL if no callback is required. 729*fcd41e86SJacky Bai * 730*fcd41e86SJacky Bai * The function requests uPower to turn on the PMC and memory array/peripheral 731*fcd41e86SJacky Bai * switches that control their power, as specified above. 732*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 733*fcd41e86SJacky Bai * regarding the adequate memory power state related to overall system state. 734*fcd41e86SJacky Bai * 735*fcd41e86SJacky Bai * If a memory is requested to turn on, but the power switch that feeds that 736*fcd41e86SJacky Bai * memory is not, the power switch will be turned on anyway, if the pwron 737*fcd41e86SJacky Bai * array is not provided (that is, if pwron is NULL). 738*fcd41e86SJacky Bai * 739*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 740*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 741*fcd41e86SJacky Bai * or not. 742*fcd41e86SJacky Bai * 743*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 744*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 745*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 746*fcd41e86SJacky Bai * 747*fcd41e86SJacky Bai * Callback or polling may return error if the service contends for a resource 748*fcd41e86SJacky Bai * already being used by a power mode transition or an ongoing service in 749*fcd41e86SJacky Bai * another domain. 750*fcd41e86SJacky Bai * 751*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 752*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 753*fcd41e86SJacky Bai * -2 if a pointer conversion to physical address failed, 754*fcd41e86SJacky Bai * -3 if called in an invalid API state. 755*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 756*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 757*fcd41e86SJacky Bai */ 758*fcd41e86SJacky Bai int upwr_pwm_power_on(const uint32_t swton[], const uint32_t memon[], 759*fcd41e86SJacky Bai upwr_callb callb); 760*fcd41e86SJacky Bai 761*fcd41e86SJacky Bai /** 762*fcd41e86SJacky Bai * upwr_pwm_power_off()- Powers off (not on) one or more switches and ROM/RAMs. 763*fcd41e86SJacky Bai * @swtoff: pointer to an array of words that tells which power switches to 764*fcd41e86SJacky Bai * turn off. Each word in the array has 1 bit for each switch. 765*fcd41e86SJacky Bai * A bit=1 means the respective switch must be turned off, 766*fcd41e86SJacky Bai * bit = 0 means it will stay unchanged (on or off). 767*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no switch will be changed. 768*fcd41e86SJacky Bai * WARNING: swtoff must not point to the first shared memory address. 769*fcd41e86SJacky Bai * @memoff: pointer to an array of words that tells which memories to turn off. 770*fcd41e86SJacky Bai * Each word in the array has 1 bit for each switch. 771*fcd41e86SJacky Bai * A bit=1 means the respective memory must be turned off, both array and 772*fcd41e86SJacky Bai * periphery logic; 773*fcd41e86SJacky Bai * bit = 0 means it will stay unchanged (on or off). 774*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no memory will be changed, 775*fcd41e86SJacky Bai * but notice it may be turned off if the switch that feeds it is powered off. 776*fcd41e86SJacky Bai * WARNING: memoff must not point to the first shared memory address. 777*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applyed. 778*fcd41e86SJacky Bai * NULL if no callback is required. 779*fcd41e86SJacky Bai * 780*fcd41e86SJacky Bai * The function requests uPower to turn off the PMC and memory array/peripheral 781*fcd41e86SJacky Bai * switches that control their power, as specified above. 782*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 783*fcd41e86SJacky Bai * regarding the adequate memory power state related to overall system state. 784*fcd41e86SJacky Bai * 785*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 786*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 787*fcd41e86SJacky Bai * or not. 788*fcd41e86SJacky Bai * 789*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 790*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 791*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 792*fcd41e86SJacky Bai * 793*fcd41e86SJacky Bai * Callback or polling may return error if the service contends for a resource 794*fcd41e86SJacky Bai * already being used by a power mode transition or an ongoing service in 795*fcd41e86SJacky Bai * another domain. 796*fcd41e86SJacky Bai * 797*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 798*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 799*fcd41e86SJacky Bai * -2 if a pointer conversion to physical address failed, 800*fcd41e86SJacky Bai * -3 if called in an invalid API state. 801*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 802*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 803*fcd41e86SJacky Bai */ 804*fcd41e86SJacky Bai int upwr_pwm_power_off(const uint32_t swtoff[], const uint32_t memoff[], 805*fcd41e86SJacky Bai upwr_callb callb); 806*fcd41e86SJacky Bai 807*fcd41e86SJacky Bai /** 808*fcd41e86SJacky Bai * upwr_pwm_mem_retain()- Configures one or more memory power switches to 809*fcd41e86SJacky Bai * retain its contents, having the power array on, while its peripheral logic 810*fcd41e86SJacky Bai * is turned off. 811*fcd41e86SJacky Bai * @mem: pointer to an array of words that tells which memories to put in a 812*fcd41e86SJacky Bai * retention state. Each word in the array has 1 bit for each memory. 813*fcd41e86SJacky Bai * A bit=1 means the respective memory must be put in retention state, 814*fcd41e86SJacky Bai * bit = 0 means it will stay unchanged (retention, fully on or off). 815*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applyed. 816*fcd41e86SJacky Bai * NULL if no callback is required. 817*fcd41e86SJacky Bai * 818*fcd41e86SJacky Bai * The function requests uPower to turn off the memory peripheral and leave 819*fcd41e86SJacky Bai * its array on, as specified above. 820*fcd41e86SJacky Bai * The request is executed if arguments are within range. 821*fcd41e86SJacky Bai * 822*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 823*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 824*fcd41e86SJacky Bai * or not. 825*fcd41e86SJacky Bai * 826*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 827*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 828*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 829*fcd41e86SJacky Bai * 830*fcd41e86SJacky Bai * Callback or polling may return error if the service contends for a resource 831*fcd41e86SJacky Bai * already being used by a power mode transition or an ongoing service in 832*fcd41e86SJacky Bai * another domain. 833*fcd41e86SJacky Bai * 834*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 835*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 836*fcd41e86SJacky Bai * -2 if a pointer conversion to physical address failed, 837*fcd41e86SJacky Bai * -3 if called in an invalid API state. 838*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 839*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 840*fcd41e86SJacky Bai */ 841*fcd41e86SJacky Bai int upwr_pwm_mem_retain(const uint32_t mem[], upwr_callb callb); 842*fcd41e86SJacky Bai 843*fcd41e86SJacky Bai /** 844*fcd41e86SJacky Bai * upwr_pwm_chng_switch_mem() - Turns on/off power on one or more PMC switches 845*fcd41e86SJacky Bai * and memories, including their array and peripheral logic. 846*fcd41e86SJacky Bai * @swt: pointer to a list of PMC switches to be opened/closed. 847*fcd41e86SJacky Bai * The list is structured as an array of struct upwr_switch_board_t 848*fcd41e86SJacky Bai * (see upower_defs.h), each one containing a word for up to 32 switches, 849*fcd41e86SJacky Bai * one per bit. A bit = 1 means switch closed, bit = 0 means switch open. 850*fcd41e86SJacky Bai * struct upwr_switch_board_t also specifies a mask with 1 bit for each 851*fcd41e86SJacky Bai * respective switch: mask bit = 1 means the open/close action is applied, 852*fcd41e86SJacky Bai * mask bit = 0 means the switch stays unchanged. 853*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no switch will be changed, 854*fcd41e86SJacky Bai * unless a memory that it feeds must be turned on. 855*fcd41e86SJacky Bai * WARNING: swt must not point to the first shared memory address. 856*fcd41e86SJacky Bai * @mem: pointer to a list of switches to be turned on/off. 857*fcd41e86SJacky Bai * The list is structured as an array of struct upwr_mem_switches_t 858*fcd41e86SJacky Bai * (see upower_defs.h), each one containing 2 word for up to 32 switches, 859*fcd41e86SJacky Bai * one per bit, one word for the RAM array power switch, other for the 860*fcd41e86SJacky Bai * RAM peripheral logic power switch. A bit = 1 means switch closed, 861*fcd41e86SJacky Bai * bit = 0 means switch open. 862*fcd41e86SJacky Bai * struct upwr_mem_switches_t also specifies a mask with 1 bit for each 863*fcd41e86SJacky Bai * respective switch: mask bit = 1 means the open/close action is applied, 864*fcd41e86SJacky Bai * mask bit = 0 means the switch stays unchanged. 865*fcd41e86SJacky Bai * The pointer may be set to NULL, in which case no memory switch will be 866*fcd41e86SJacky Bai * changed, but notice it may be turned off if the switch that feeds it is 867*fcd41e86SJacky Bai * powered off. 868*fcd41e86SJacky Bai * WARNING: mem must not point to the first shared memory address. 869*fcd41e86SJacky Bai * @callb: pointer to the callback called when the configurations are applied. 870*fcd41e86SJacky Bai * NULL if no callback is required. 871*fcd41e86SJacky Bai * 872*fcd41e86SJacky Bai * The function requests uPower to change the PMC switches and/or memory power 873*fcd41e86SJacky Bai * as specified above. 874*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 875*fcd41e86SJacky Bai * regarding the adequate switch combinations and overall system state. 876*fcd41e86SJacky Bai * 877*fcd41e86SJacky Bai * If a memory is requested to turn on, but the power switch that feeds that 878*fcd41e86SJacky Bai * memory is not, the power switch will be turned on anyway, if the swt 879*fcd41e86SJacky Bai * array is not provided (that is, if swt is NULL). 880*fcd41e86SJacky Bai * 881*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 882*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 883*fcd41e86SJacky Bai * or not. 884*fcd41e86SJacky Bai * 885*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 886*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 887*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 888*fcd41e86SJacky Bai * 889*fcd41e86SJacky Bai * Callback or polling may return error if the service contends for a resource 890*fcd41e86SJacky Bai * already being used by a power mode transition or an ongoing service in 891*fcd41e86SJacky Bai * another domain. 892*fcd41e86SJacky Bai * 893*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 894*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy. 895*fcd41e86SJacky Bai * -2 if a pointer conversion to physical address failed, 896*fcd41e86SJacky Bai * -3 if called in an invalid API state. 897*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 898*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 899*fcd41e86SJacky Bai */ 900*fcd41e86SJacky Bai int upwr_pwm_chng_switch_mem(const struct upwr_switch_board_t swt[], 901*fcd41e86SJacky Bai const struct upwr_mem_switches_t mem[], 902*fcd41e86SJacky Bai upwr_callb callb); 903*fcd41e86SJacky Bai 904*fcd41e86SJacky Bai /** 905*fcd41e86SJacky Bai * upwr_pwm_pmode_config() - Configures a given power mode in a given domain. 906*fcd41e86SJacky Bai * @domain: identifier of the domain to which the power mode belongs. 907*fcd41e86SJacky Bai * Defined by SoC-dependent type soc_domain_t found in upower_soc_defs.h. 908*fcd41e86SJacky Bai * @pmode: SoC-dependent power mode identifier defined by type abs_pwr_mode_t 909*fcd41e86SJacky Bai * found in upower_soc_defs.h. 910*fcd41e86SJacky Bai * @config: pointer to an SoC-dependent struct defining the power mode 911*fcd41e86SJacky Bai * configuration, found in upower_soc_defs.h. 912*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applied. 913*fcd41e86SJacky Bai * NULL if no callback is required. 914*fcd41e86SJacky Bai * 915*fcd41e86SJacky Bai * The function requests uPower to change the power mode configuration as 916*fcd41e86SJacky Bai * specified above. The request is executed if arguments are within range, 917*fcd41e86SJacky Bai * and complies with SoC-dependent restrictions on value combinations. 918*fcd41e86SJacky Bai * 919*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 920*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 921*fcd41e86SJacky Bai * or not. 922*fcd41e86SJacky Bai * 923*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 924*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 925*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 926*fcd41e86SJacky Bai * 927*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 928*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 929*fcd41e86SJacky Bai * -2 if the pointer conversion to physical address failed, 930*fcd41e86SJacky Bai * -3 if called in an invalid API state. 931*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 932*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 933*fcd41e86SJacky Bai */ 934*fcd41e86SJacky Bai int upwr_pwm_pmode_config(soc_domain_t domain, abs_pwr_mode_t pmode, 935*fcd41e86SJacky Bai const void *config, upwr_callb callb); 936*fcd41e86SJacky Bai 937*fcd41e86SJacky Bai 938*fcd41e86SJacky Bai 939*fcd41e86SJacky Bai /** 940*fcd41e86SJacky Bai * upwr_pwm_reg_config() - Configures the uPower internal regulators. 941*fcd41e86SJacky Bai * @config: pointer to the struct defining the regulator configuration; 942*fcd41e86SJacky Bai * the struct upwr_reg_config_t is defined in the file upower_defs.h. 943*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applied. 944*fcd41e86SJacky Bai * NULL if no callback is required. 945*fcd41e86SJacky Bai * 946*fcd41e86SJacky Bai * The function requests uPower to change/define the configurations of the 947*fcd41e86SJacky Bai * internal regulators. 948*fcd41e86SJacky Bai * 949*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 950*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 951*fcd41e86SJacky Bai * or not. 952*fcd41e86SJacky Bai * 953*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 954*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 955*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 956*fcd41e86SJacky Bai * 957*fcd41e86SJacky Bai * The service may fail with error UPWR_RESP_RESOURCE if a power mode transition 958*fcd41e86SJacky Bai * or the same service (called from another domain) is executing simultaneously. 959*fcd41e86SJacky Bai * This error should be interpreted as a "try later" response, as the service 960*fcd41e86SJacky Bai * will succeed once those concurrent executions are done, and no other is 961*fcd41e86SJacky Bai * started. 962*fcd41e86SJacky Bai * 963*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 964*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 965*fcd41e86SJacky Bai * -2 if the pointer conversion to physical address failed, 966*fcd41e86SJacky Bai * -3 if called in an invalid API state. 967*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 968*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 969*fcd41e86SJacky Bai */ 970*fcd41e86SJacky Bai int upwr_pwm_reg_config(const struct upwr_reg_config_t *config, 971*fcd41e86SJacky Bai upwr_callb callb); 972*fcd41e86SJacky Bai 973*fcd41e86SJacky Bai /** 974*fcd41e86SJacky Bai * upwr_pwm_chng_dom_bias() - Changes the domain bias. 975*fcd41e86SJacky Bai * @bias: pointer to a domain bias configuration struct (see upower_soc_defs.h). 976*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applied. 977*fcd41e86SJacky Bai * NULL if no callback is required. 978*fcd41e86SJacky Bai * 979*fcd41e86SJacky Bai * The function requests uPower to change the domain bias configuration as 980*fcd41e86SJacky Bai * specified above. The request is executed if arguments are within range, 981*fcd41e86SJacky Bai * with no protections regarding the adequate value combinations and 982*fcd41e86SJacky Bai * overall system state. 983*fcd41e86SJacky Bai * 984*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 985*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 986*fcd41e86SJacky Bai * or not. 987*fcd41e86SJacky Bai * 988*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 989*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 990*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 991*fcd41e86SJacky Bai * 992*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 993*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 994*fcd41e86SJacky Bai * -3 if called in an invalid API state. 995*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 996*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 997*fcd41e86SJacky Bai */ 998*fcd41e86SJacky Bai 999*fcd41e86SJacky Bai int upwr_pwm_chng_dom_bias(const struct upwr_dom_bias_cfg_t *bias, 1000*fcd41e86SJacky Bai upwr_callb callb); 1001*fcd41e86SJacky Bai 1002*fcd41e86SJacky Bai /** 1003*fcd41e86SJacky Bai * upwr_pwm_chng_mem_bias()- Changes a ROM/RAM power bias. 1004*fcd41e86SJacky Bai * @domain: identifier of the domain upon which the bias is applied. 1005*fcd41e86SJacky Bai * Defined by SoC-dependent type soc_domain_t found in upower_soc_defs.h. 1006*fcd41e86SJacky Bai * @bias: pointer to a memory bias configuration struct (see upower_soc_defs.h). 1007*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applied. 1008*fcd41e86SJacky Bai * NULL if no callback is required. 1009*fcd41e86SJacky Bai * 1010*fcd41e86SJacky Bai * The function requests uPower to change the memory bias configuration as 1011*fcd41e86SJacky Bai * specified above. The request is executed if arguments are within range, 1012*fcd41e86SJacky Bai * with no protections regarding the adequate value combinations and 1013*fcd41e86SJacky Bai * overall system state. 1014*fcd41e86SJacky Bai * 1015*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1016*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1017*fcd41e86SJacky Bai * or not. 1018*fcd41e86SJacky Bai * 1019*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1020*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1021*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 1022*fcd41e86SJacky Bai * 1023*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1024*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 1025*fcd41e86SJacky Bai * -3 if called in an invalid API state. 1026*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1027*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1028*fcd41e86SJacky Bai */ 1029*fcd41e86SJacky Bai 1030*fcd41e86SJacky Bai int upwr_pwm_chng_mem_bias(soc_domain_t domain, 1031*fcd41e86SJacky Bai const struct upwr_mem_bias_cfg_t *bias, 1032*fcd41e86SJacky Bai upwr_callb callb); 1033*fcd41e86SJacky Bai 1034*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1035*fcd41e86SJacky Bai * VOLTAGE MANAGEMENT SERVICE GROUP 1036*fcd41e86SJacky Bai */ 1037*fcd41e86SJacky Bai 1038*fcd41e86SJacky Bai /** 1039*fcd41e86SJacky Bai * upwr_vtm_pmic_cold_reset() -request cold reset the pmic. 1040*fcd41e86SJacky Bai * pmic will power cycle all the regulators 1041*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1042*fcd41e86SJacky Bai * 1043*fcd41e86SJacky Bai * The function requests uPower to cold reset the pmic. 1044*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1045*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1046*fcd41e86SJacky Bai * temperature and frequency. 1047*fcd41e86SJacky Bai * 1048*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1049*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1050*fcd41e86SJacky Bai * or not. 1051*fcd41e86SJacky Bai * 1052*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1053*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1054*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1055*fcd41e86SJacky Bai * 1056*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1057*fcd41e86SJacky Bai * Return: 0 if ok, 1058*fcd41e86SJacky Bai * -1 if service group is busy, 1059*fcd41e86SJacky Bai * -3 if called in an invalid API state 1060*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1061*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1062*fcd41e86SJacky Bai */ 1063*fcd41e86SJacky Bai int upwr_vtm_pmic_cold_reset(upwr_callb callb); 1064*fcd41e86SJacky Bai 1065*fcd41e86SJacky Bai /** 1066*fcd41e86SJacky Bai * upwr_vtm_set_pmic_mode() -request uPower set pmic mode 1067*fcd41e86SJacky Bai * @pmic_mode: the target mode need to be set 1068*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1069*fcd41e86SJacky Bai * 1070*fcd41e86SJacky Bai * The function requests uPower to set pmic mode 1071*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1072*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1073*fcd41e86SJacky Bai * temperature and frequency. 1074*fcd41e86SJacky Bai * 1075*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1076*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1077*fcd41e86SJacky Bai * or not. 1078*fcd41e86SJacky Bai * 1079*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1080*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1081*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1082*fcd41e86SJacky Bai * 1083*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1084*fcd41e86SJacky Bai * Return: 0 if ok, 1085*fcd41e86SJacky Bai * -1 if service group is busy, 1086*fcd41e86SJacky Bai * -3 if called in an invalid API state 1087*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1088*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1089*fcd41e86SJacky Bai */ 1090*fcd41e86SJacky Bai int upwr_vtm_set_pmic_mode(uint32_t pmic_mode, upwr_callb callb); 1091*fcd41e86SJacky Bai 1092*fcd41e86SJacky Bai /** 1093*fcd41e86SJacky Bai * upwr_vtm_chng_pmic_voltage() - Changes the voltage of a given rail. 1094*fcd41e86SJacky Bai * @rail: pmic rail id. 1095*fcd41e86SJacky Bai * @volt: the target voltage of the given rail, accurate to uV 1096*fcd41e86SJacky Bai * If pass volt value 0, means that power off this rail. 1097*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1098*fcd41e86SJacky Bai * 1099*fcd41e86SJacky Bai * The function requests uPower to change the voltage of the given rail. 1100*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1101*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1102*fcd41e86SJacky Bai * temperature and frequency. 1103*fcd41e86SJacky Bai * 1104*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1105*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1106*fcd41e86SJacky Bai * or not. 1107*fcd41e86SJacky Bai * 1108*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1109*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1110*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1111*fcd41e86SJacky Bai * 1112*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1113*fcd41e86SJacky Bai * Return: 0 if ok, 1114*fcd41e86SJacky Bai * -1 if service group is busy, 1115*fcd41e86SJacky Bai * -3 if called in an invalid API state 1116*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1117*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1118*fcd41e86SJacky Bai */ 1119*fcd41e86SJacky Bai int upwr_vtm_chng_pmic_voltage(uint32_t rail, uint32_t volt, upwr_callb callb); 1120*fcd41e86SJacky Bai 1121*fcd41e86SJacky Bai /** 1122*fcd41e86SJacky Bai * upwr_vtm_get_pmic_voltage() - Get the voltage of a given ral. 1123*fcd41e86SJacky Bai * @rail: pmic rail id. 1124*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1125*fcd41e86SJacky Bai * (polling used instead) 1126*fcd41e86SJacky Bai * 1127*fcd41e86SJacky Bai * The function requests uPower to get the voltage of the given rail. 1128*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1129*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1130*fcd41e86SJacky Bai * temperature and frequency. 1131*fcd41e86SJacky Bai * 1132*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1133*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1134*fcd41e86SJacky Bai * or not. 1135*fcd41e86SJacky Bai * 1136*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1137*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1138*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1139*fcd41e86SJacky Bai * 1140*fcd41e86SJacky Bai * The voltage data read from uPower via 1141*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1142*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1143*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1144*fcd41e86SJacky Bai * 1145*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1146*fcd41e86SJacky Bai * Return: 0 if ok, 1147*fcd41e86SJacky Bai * -1 if service group is busy, 1148*fcd41e86SJacky Bai * -3 if called in an invalid API state 1149*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1150*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1151*fcd41e86SJacky Bai */ 1152*fcd41e86SJacky Bai int upwr_vtm_get_pmic_voltage(uint32_t rail, upwr_callb callb); 1153*fcd41e86SJacky Bai 1154*fcd41e86SJacky Bai 1155*fcd41e86SJacky Bai /** 1156*fcd41e86SJacky Bai * upwr_vtm_power_measure() - request uPower to measure power consumption 1157*fcd41e86SJacky Bai * @ssel: This field determines which power switches will have their currents 1158*fcd41e86SJacky Bai * sampled to be accounted for a 1159*fcd41e86SJacky Bai * current/power measurement. Support 0~7 1160*fcd41e86SJacky Bai 1161*fcd41e86SJacky Bai * SSEL bit # Power Switch 1162*fcd41e86SJacky Bai * 0 M33 core complex/platform/peripherals 1163*fcd41e86SJacky Bai * 1 Fusion Core and Peripherals 1164*fcd41e86SJacky Bai * 2 A35[0] core complex 1165*fcd41e86SJacky Bai * 3 A35[1] core complex 1166*fcd41e86SJacky Bai * 4 3DGPU 1167*fcd41e86SJacky Bai * 5 HiFi4 1168*fcd41e86SJacky Bai * 6 DDR Controller (PHY and PLL NOT included) 1169*fcd41e86SJacky Bai * 7 PXP, EPDC 1170*fcd41e86SJacky Bai * 1171*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1172*fcd41e86SJacky Bai * (polling used instead) 1173*fcd41e86SJacky Bai * 1174*fcd41e86SJacky Bai * The function requests uPower to measure power consumption 1175*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1176*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1177*fcd41e86SJacky Bai * temperature and frequency. 1178*fcd41e86SJacky Bai * 1179*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1180*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1181*fcd41e86SJacky Bai * or not. 1182*fcd41e86SJacky Bai * 1183*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1184*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1185*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1186*fcd41e86SJacky Bai * 1187*fcd41e86SJacky Bai * The power consumption data read from uPower via 1188*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1189*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1190*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1191*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1192*fcd41e86SJacky Bai * 1193*fcd41e86SJacky Bai * Accurate to uA 1194*fcd41e86SJacky Bai * 1195*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1196*fcd41e86SJacky Bai * Return: 0 if ok, 1197*fcd41e86SJacky Bai * -1 if service group is busy, 1198*fcd41e86SJacky Bai * -3 if called in an invalid API state 1199*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1200*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1201*fcd41e86SJacky Bai */ 1202*fcd41e86SJacky Bai int upwr_vtm_power_measure(uint32_t ssel, upwr_callb callb); 1203*fcd41e86SJacky Bai 1204*fcd41e86SJacky Bai /** 1205*fcd41e86SJacky Bai * upwr_vtm_vmeter_measure() - request uPower to measure voltage 1206*fcd41e86SJacky Bai * @vdetsel: Voltage Detector Selector, support 0~3 1207*fcd41e86SJacky Bai * 00b - RTD sense point 1208*fcd41e86SJacky Bai * 01b - LDO output 1209*fcd41e86SJacky Bai * 10b - APD domain sense point 1210*fcd41e86SJacky Bai * 11b - AVD domain sense point 1211*fcd41e86SJacky Bai * Refer to upower_defs.h 1212*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1213*fcd41e86SJacky Bai * (polling used instead) 1214*fcd41e86SJacky Bai * 1215*fcd41e86SJacky Bai * The function requests uPower to use vmeter to measure voltage 1216*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1217*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1218*fcd41e86SJacky Bai * temperature and frequency. 1219*fcd41e86SJacky Bai * 1220*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1221*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1222*fcd41e86SJacky Bai * or not. 1223*fcd41e86SJacky Bai * 1224*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1225*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1226*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_VOLTM as the service group argument. 1227*fcd41e86SJacky Bai * 1228*fcd41e86SJacky Bai * The voltage data read from uPower via 1229*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1230*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1231*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1232*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1233*fcd41e86SJacky Bai * 1234*fcd41e86SJacky Bai * Refer to RM COREREGVL (Core Regulator Voltage Level) 1235*fcd41e86SJacky Bai * uPower return VDETLVL to user, user can calculate the real voltage: 1236*fcd41e86SJacky Bai * 1237*fcd41e86SJacky Bai * 0b000000(0x00) - 0.595833V 1238*fcd41e86SJacky Bai * 0b100110(0x26) - 1.007498V 1239*fcd41e86SJacky Bai * <value> - 0.595833V + <value>x10.8333mV 1240*fcd41e86SJacky Bai * 0b110010(0x32) - 1.138V 1241*fcd41e86SJacky Bai * 1242*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1243*fcd41e86SJacky Bai * Return: 0 if ok, 1244*fcd41e86SJacky Bai * -1 if service group is busy, 1245*fcd41e86SJacky Bai * -3 if called in an invalid API state 1246*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1247*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1248*fcd41e86SJacky Bai */ 1249*fcd41e86SJacky Bai int upwr_vtm_vmeter_measure(uint32_t vdetsel, upwr_callb callb); 1250*fcd41e86SJacky Bai 1251*fcd41e86SJacky Bai /** 1252*fcd41e86SJacky Bai * upwr_vtm_pmic_config() - Configures the SoC PMIC (Power Management IC). 1253*fcd41e86SJacky Bai * @config: pointer to a PMIC-dependent struct defining the PMIC configuration. 1254*fcd41e86SJacky Bai * @size: size of the struct pointed by config, in bytes. 1255*fcd41e86SJacky Bai * @callb: pointer to the callback called when configurations are applied. 1256*fcd41e86SJacky Bai * NULL if no callback is required. 1257*fcd41e86SJacky Bai * 1258*fcd41e86SJacky Bai * The function requests uPower to change/define the PMIC configuration. 1259*fcd41e86SJacky Bai * 1260*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1261*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1262*fcd41e86SJacky Bai * or not. 1263*fcd41e86SJacky Bai * 1264*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1265*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1266*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_PWRMGMT as the service group argument. 1267*fcd41e86SJacky Bai * 1268*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1269*fcd41e86SJacky Bai * Return: 0 if ok, -1 if service group is busy, 1270*fcd41e86SJacky Bai * -2 if the pointer conversion to physical address failed, 1271*fcd41e86SJacky Bai * -3 if called in an invalid API state. 1272*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1273*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1274*fcd41e86SJacky Bai */ 1275*fcd41e86SJacky Bai int upwr_vtm_pmic_config(const void *config, uint32_t size, upwr_callb callb); 1276*fcd41e86SJacky Bai 1277*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1278*fcd41e86SJacky Bai * TEMPERATURE MANAGEMENT SERVICE GROUP 1279*fcd41e86SJacky Bai */ 1280*fcd41e86SJacky Bai 1281*fcd41e86SJacky Bai /** 1282*fcd41e86SJacky Bai * upwr_tpm_get_temperature() - request uPower to get temperature of one temperature sensor 1283*fcd41e86SJacky Bai * @sensor_id: temperature sensor ID, support 0~2 1284*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1285*fcd41e86SJacky Bai * (polling used instead) 1286*fcd41e86SJacky Bai * 1287*fcd41e86SJacky Bai * The function requests uPower to measure temperature 1288*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1289*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1290*fcd41e86SJacky Bai * temperature and frequency. 1291*fcd41e86SJacky Bai * 1292*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1293*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1294*fcd41e86SJacky Bai * or not. 1295*fcd41e86SJacky Bai * 1296*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1297*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1298*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_TEMPM as the service group argument. 1299*fcd41e86SJacky Bai * 1300*fcd41e86SJacky Bai * The temperature data read from uPower via 1301*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1302*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1303*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1304*fcd41e86SJacky Bai * 1305*fcd41e86SJacky Bai * uPower return TSEL to the caller (M33 or A35), caller calculate the real temperature 1306*fcd41e86SJacky Bai * Tsh = 0.000002673049*TSEL[7:0]^3 + 0.0003734262*TSEL[7:0]^2 + 1307*fcd41e86SJacky Bai 0.4487042*TSEL[7:0] - 46.98694 1308*fcd41e86SJacky Bai * 1309*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1310*fcd41e86SJacky Bai * 1311*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1312*fcd41e86SJacky Bai * Return: 0 if ok, 1313*fcd41e86SJacky Bai * -1 if service group is busy, 1314*fcd41e86SJacky Bai * -3 if called in an invalid API state 1315*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1316*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1317*fcd41e86SJacky Bai */ 1318*fcd41e86SJacky Bai int upwr_tpm_get_temperature(uint32_t sensor_id, upwr_callb callb); 1319*fcd41e86SJacky Bai 1320*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1321*fcd41e86SJacky Bai * DELAY MANAGEMENT SERVICE GROUP 1322*fcd41e86SJacky Bai */ 1323*fcd41e86SJacky Bai 1324*fcd41e86SJacky Bai /** 1325*fcd41e86SJacky Bai * upwr_dlm_get_delay_margin() - request uPower to get delay margin 1326*fcd41e86SJacky Bai * @path: The critical path 1327*fcd41e86SJacky Bai * @index: Use whitch delay meter 1328*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1329*fcd41e86SJacky Bai * (polling used instead) 1330*fcd41e86SJacky Bai * 1331*fcd41e86SJacky Bai * The function requests uPower to get delay margin 1332*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1333*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1334*fcd41e86SJacky Bai * temperature and frequency. 1335*fcd41e86SJacky Bai * 1336*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1337*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1338*fcd41e86SJacky Bai * or not. 1339*fcd41e86SJacky Bai * 1340*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1341*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1342*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_DELAYM as the service group argument. 1343*fcd41e86SJacky Bai * 1344*fcd41e86SJacky Bai * The delay margin data read from uPower via 1345*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1346*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1347*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1348*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1349*fcd41e86SJacky Bai * 1350*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1351*fcd41e86SJacky Bai * Return: 0 if ok, 1352*fcd41e86SJacky Bai * -1 if service group is busy, 1353*fcd41e86SJacky Bai * -3 if called in an invalid API state 1354*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1355*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1356*fcd41e86SJacky Bai */ 1357*fcd41e86SJacky Bai int upwr_dlm_get_delay_margin(uint32_t path, uint32_t index, upwr_callb callb); 1358*fcd41e86SJacky Bai 1359*fcd41e86SJacky Bai /** 1360*fcd41e86SJacky Bai * upwr_dlm_set_delay_margin() - request uPower to set delay margin 1361*fcd41e86SJacky Bai * @path: The critical path 1362*fcd41e86SJacky Bai * @index: Use whitch delay meter 1363*fcd41e86SJacky Bai * @delay_margin: the value of delay margin 1364*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1365*fcd41e86SJacky Bai * (polling used instead) 1366*fcd41e86SJacky Bai * 1367*fcd41e86SJacky Bai * The function requests uPower to set delay margin 1368*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1369*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1370*fcd41e86SJacky Bai * temperature and frequency. 1371*fcd41e86SJacky Bai * 1372*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1373*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1374*fcd41e86SJacky Bai * or not. 1375*fcd41e86SJacky Bai * 1376*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1377*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1378*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_DELAYM as the service group argument. 1379*fcd41e86SJacky Bai * 1380*fcd41e86SJacky Bai * The result of the corresponding critical path, failed or not read from uPower via 1381*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1382*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1383*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1384*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1385*fcd41e86SJacky Bai * 1386*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1387*fcd41e86SJacky Bai * Return: 0 if ok, 1388*fcd41e86SJacky Bai * -1 if service group is busy, 1389*fcd41e86SJacky Bai * -3 if called in an invalid API state 1390*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1391*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1392*fcd41e86SJacky Bai */ 1393*fcd41e86SJacky Bai int upwr_dlm_set_delay_margin(uint32_t path, uint32_t index, uint32_t delay_margin, upwr_callb callb); 1394*fcd41e86SJacky Bai 1395*fcd41e86SJacky Bai /** 1396*fcd41e86SJacky Bai * upwr_dlm_process_monitor() - request uPower to do process monitor 1397*fcd41e86SJacky Bai * @chain_sel: Chain Cell Type Selection 1398*fcd41e86SJacky Bai * Select the chain to be used for the clock signal generation. 1399*fcd41e86SJacky Bai * Support two types chain cell, 0~1 1400*fcd41e86SJacky Bai 0b - P4 type delay cells selected 1401*fcd41e86SJacky Bai 1b - P16 type delay cells selected 1402*fcd41e86SJacky Bai * @callb: response callback pointer; NULL if no callback needed. 1403*fcd41e86SJacky Bai * (polling used instead) 1404*fcd41e86SJacky Bai * 1405*fcd41e86SJacky Bai * The function requests uPower to do process monitor 1406*fcd41e86SJacky Bai * The request is executed if arguments are within range, with no protections 1407*fcd41e86SJacky Bai * regarding the adequate voltage value for the given domain process, 1408*fcd41e86SJacky Bai * temperature and frequency. 1409*fcd41e86SJacky Bai * 1410*fcd41e86SJacky Bai * A callback can be optionally registered, and will be called upon the arrival 1411*fcd41e86SJacky Bai * of the request response from the uPower firmware, telling if it succeeded 1412*fcd41e86SJacky Bai * or not. 1413*fcd41e86SJacky Bai * 1414*fcd41e86SJacky Bai * A callback may not be registered (NULL pointer), in which case polling has 1415*fcd41e86SJacky Bai * to be used to check the response, by calling upwr_req_status or 1416*fcd41e86SJacky Bai * upwr_poll_req_status, using UPWR_SG_DELAYM as the service group argument. 1417*fcd41e86SJacky Bai * 1418*fcd41e86SJacky Bai * The result of process monitor, failed or not read from uPower via 1419*fcd41e86SJacky Bai * the callback argument ret, or written to the variable pointed by retptr, 1420*fcd41e86SJacky Bai * if polling is used (calls upwr_req_status or upwr_poll_req_status). 1421*fcd41e86SJacky Bai * ret (or *retptr) also returns the data written on writes. 1422*fcd41e86SJacky Bai * upower fw needs support cocurrent request from M33 and A35. 1423*fcd41e86SJacky Bai * 1424*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1425*fcd41e86SJacky Bai * Return: 0 if ok, 1426*fcd41e86SJacky Bai * -1 if service group is busy, 1427*fcd41e86SJacky Bai * -3 if called in an invalid API state 1428*fcd41e86SJacky Bai * Note that this is not the error response from the request itself: 1429*fcd41e86SJacky Bai * it only tells if the request was successfully sent to the uPower. 1430*fcd41e86SJacky Bai */ 1431*fcd41e86SJacky Bai int upwr_dlm_process_monitor(uint32_t chain_sel, upwr_callb callb); 1432*fcd41e86SJacky Bai 1433*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1434*fcd41e86SJacky Bai * DIAGNOSE SERVICE GROUP 1435*fcd41e86SJacky Bai */ 1436*fcd41e86SJacky Bai 1437*fcd41e86SJacky Bai /** 1438*fcd41e86SJacky Bai * upwr_dgn_mode() - Sets the diagnostic mode. 1439*fcd41e86SJacky Bai * @mode: diagnostic mode, which can be: 1440*fcd41e86SJacky Bai * - UPWR_DGN_NONE: no diagnostic recorded 1441*fcd41e86SJacky Bai * - UPWR_DGN_TRACE: warnings, errors, service, internal activity recorded 1442*fcd41e86SJacky Bai * - UPWR_DGN_SRVREQ: warnings, errors, service activity recorded 1443*fcd41e86SJacky Bai * - UPWR_DGN_WARN: warnings and errors recorded 1444*fcd41e86SJacky Bai * - UPWR_DGN_ALL: trace, service, warnings, errors, task state recorded 1445*fcd41e86SJacky Bai * - UPWR_DGN_ERROR: only errors recorded 1446*fcd41e86SJacky Bai * - UPWR_DGN_ALL2ERR: record all until an error occurs, 1447*fcd41e86SJacky Bai * freeze recording on error 1448*fcd41e86SJacky Bai * - UPWR_DGN_ALL2HLT: record all until an error occurs, 1449*fcd41e86SJacky Bai * executes an ebreak on error, which halts the core if enabled through 1450*fcd41e86SJacky Bai * the debug interface 1451*fcd41e86SJacky Bai * @callb: pointer to the callback called when mode is changed. 1452*fcd41e86SJacky Bai * NULL if no callback is required. 1453*fcd41e86SJacky Bai * 1454*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1455*fcd41e86SJacky Bai * Return: 0 if ok, 1456*fcd41e86SJacky Bai * -1 if service group is busy, 1457*fcd41e86SJacky Bai * -3 if called in an invalid API state 1458*fcd41e86SJacky Bai */ 1459*fcd41e86SJacky Bai int upwr_dgn_mode(upwr_dgn_mode_t mode, const upwr_callb callb); 1460*fcd41e86SJacky Bai 1461*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1462*fcd41e86SJacky Bai * AUXILIARY CALLS 1463*fcd41e86SJacky Bai */ 1464*fcd41e86SJacky Bai 1465*fcd41e86SJacky Bai /** 1466*fcd41e86SJacky Bai * upwr_rom_version() - informs the ROM firwmware version. 1467*fcd41e86SJacky Bai * @vmajor: pointer to the variable to get the firmware major version number. 1468*fcd41e86SJacky Bai * @vminor: pointer to the variable to get the firmware minor version number. 1469*fcd41e86SJacky Bai * @vfixes: pointer to the variable to get the firmware fixes number. 1470*fcd41e86SJacky Bai * 1471*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1472*fcd41e86SJacky Bai * Return: SoC id. 1473*fcd41e86SJacky Bai */ 1474*fcd41e86SJacky Bai uint32_t upwr_rom_version(uint32_t *vmajor, uint32_t *vminor, uint32_t *vfixes); 1475*fcd41e86SJacky Bai 1476*fcd41e86SJacky Bai /** 1477*fcd41e86SJacky Bai * upwr_ram_version() - informs the RAM firwmware version. 1478*fcd41e86SJacky Bai * @vminor: pointer to the variable to get the firmware minor version number. 1479*fcd41e86SJacky Bai * @vfixes: pointer to the variable to get the firmware fixes number. 1480*fcd41e86SJacky Bai * 1481*fcd41e86SJacky Bai * The 3 values returned are 0 if no RAM firmwmare was loaded and initialized. 1482*fcd41e86SJacky Bai * 1483*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1484*fcd41e86SJacky Bai * Return: firmware major version number. 1485*fcd41e86SJacky Bai */ 1486*fcd41e86SJacky Bai uint32_t upwr_ram_version(uint32_t *vminor, uint32_t *vfixes); 1487*fcd41e86SJacky Bai 1488*fcd41e86SJacky Bai /** 1489*fcd41e86SJacky Bai * upwr_req_status() - tells the status of the service group request, and 1490*fcd41e86SJacky Bai * returns a request return value, if any. 1491*fcd41e86SJacky Bai * @sg: service group of the request 1492*fcd41e86SJacky Bai * @sgfptr: pointer to the variable that will hold the function id of 1493*fcd41e86SJacky Bai * the last request completed; can be NULL, in which case it is not used. 1494*fcd41e86SJacky Bai * @errptr: pointer to the variable that will hold the error code; 1495*fcd41e86SJacky Bai * can be NULL, in which case it is not used. 1496*fcd41e86SJacky Bai * @retptr: pointer to the variable that will hold the value returned 1497*fcd41e86SJacky Bai * by the last request completed (invalid if the last request completed didn't 1498*fcd41e86SJacky Bai * return any value); can be NULL, in which case it is not used. 1499*fcd41e86SJacky Bai * Note that a request may return a value even if service error is returned 1500*fcd41e86SJacky Bai * (*errptr != UPWR_RESP_OK): that is dependent on the specific service. 1501*fcd41e86SJacky Bai * 1502*fcd41e86SJacky Bai * This call can be used in a poll loop of a service request completion in case 1503*fcd41e86SJacky Bai * a callback was not registered. 1504*fcd41e86SJacky Bai * 1505*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1506*fcd41e86SJacky Bai * Return: service request status: succeeded, failed, or ongoing (busy) 1507*fcd41e86SJacky Bai */ 1508*fcd41e86SJacky Bai 1509*fcd41e86SJacky Bai /* service request status */ 1510*fcd41e86SJacky Bai typedef enum { 1511*fcd41e86SJacky Bai UPWR_REQ_OK, /* request succeeded */ 1512*fcd41e86SJacky Bai UPWR_REQ_ERR, /* request failed */ 1513*fcd41e86SJacky Bai UPWR_REQ_BUSY /* request execution ongoing */ 1514*fcd41e86SJacky Bai } upwr_req_status_t; 1515*fcd41e86SJacky Bai 1516*fcd41e86SJacky Bai upwr_req_status_t upwr_req_status(upwr_sg_t sg, 1517*fcd41e86SJacky Bai uint32_t *sgfptr, 1518*fcd41e86SJacky Bai upwr_resp_t *errptr, 1519*fcd41e86SJacky Bai int *retptr); 1520*fcd41e86SJacky Bai 1521*fcd41e86SJacky Bai /** 1522*fcd41e86SJacky Bai * upwr_poll_req_status() - polls the status of the service group request, and 1523*fcd41e86SJacky Bai * returns a request return value, if any. 1524*fcd41e86SJacky Bai * @sg: service group of the request 1525*fcd41e86SJacky Bai * @sgfptr: pointer to the variable that will hold the function id of 1526*fcd41e86SJacky Bai * the last request completed; can be NULL, in which case it is not used. 1527*fcd41e86SJacky Bai * @errptr: pointer to the variable that will hold the error code; 1528*fcd41e86SJacky Bai * can be NULL, in which case it is not used. 1529*fcd41e86SJacky Bai * @retptr: pointer to the variable that will hold the value returned 1530*fcd41e86SJacky Bai * by the last request completed (invalid if the last request completed didn't 1531*fcd41e86SJacky Bai * return any value); can be NULL, in which case it is not used. 1532*fcd41e86SJacky Bai * Note that a request may return a value even if service error is returned 1533*fcd41e86SJacky Bai * (*errptr != UPWR_RESP_OK): that is dependent on the specific service. 1534*fcd41e86SJacky Bai * @attempts: maximum number of polling attempts; if attempts > 0 and is 1535*fcd41e86SJacky Bai * reached with no service response received, upwr_poll_req_status returns 1536*fcd41e86SJacky Bai * UPWR_REQ_BUSY and variables pointed by sgfptr, retptr and errptr are not 1537*fcd41e86SJacky Bai * updated; if attempts = 0, upwr_poll_req_status waits "forever". 1538*fcd41e86SJacky Bai * 1539*fcd41e86SJacky Bai * This call can be used to poll a service request completion in case a 1540*fcd41e86SJacky Bai * callback was not registered. 1541*fcd41e86SJacky Bai * 1542*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1543*fcd41e86SJacky Bai * Return: service request status: succeeded, failed, or ongoing (busy) 1544*fcd41e86SJacky Bai */ 1545*fcd41e86SJacky Bai upwr_req_status_t upwr_poll_req_status(upwr_sg_t sg, 1546*fcd41e86SJacky Bai uint32_t *sgfptr, 1547*fcd41e86SJacky Bai upwr_resp_t *errptr, 1548*fcd41e86SJacky Bai int *retptr, 1549*fcd41e86SJacky Bai uint32_t attempts); 1550*fcd41e86SJacky Bai 1551*fcd41e86SJacky Bai /** 1552*fcd41e86SJacky Bai * upwr_alarm_code() - returns the alarm code of the last alarm occurrence. 1553*fcd41e86SJacky Bai * 1554*fcd41e86SJacky Bai * The value returned is not meaningful if no alarm was issued by uPower. 1555*fcd41e86SJacky Bai * 1556*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1557*fcd41e86SJacky Bai * Return: alarm code, as defined by the type upwr_alarm_t in upwr_soc_defines.h 1558*fcd41e86SJacky Bai */ 1559*fcd41e86SJacky Bai upwr_alarm_t upwr_alarm_code(void); 1560*fcd41e86SJacky Bai 1561*fcd41e86SJacky Bai /**--------------------------------------------------------------- 1562*fcd41e86SJacky Bai * TRANSMIT/RECEIVE PRIMITIVES 1563*fcd41e86SJacky Bai * --------------------------------------------------------------- 1564*fcd41e86SJacky Bai */ 1565*fcd41e86SJacky Bai 1566*fcd41e86SJacky Bai typedef void (*UPWR_TX_CALLB_FUNC_T)(void); 1567*fcd41e86SJacky Bai typedef void (*UPWR_RX_CALLB_FUNC_T)(void); 1568*fcd41e86SJacky Bai 1569*fcd41e86SJacky Bai /** 1570*fcd41e86SJacky Bai * upwr_tx() - queues a message for transmission. 1571*fcd41e86SJacky Bai * @msg : pointer to the message sent. 1572*fcd41e86SJacky Bai * @size: message size in 32-bit words 1573*fcd41e86SJacky Bai * @callback: pointer to a function to be called when transmission done; 1574*fcd41e86SJacky Bai * can be NULL, in which case no callback is done. 1575*fcd41e86SJacky Bai * 1576*fcd41e86SJacky Bai * This is an auxiliary function used by the rest of the API calls. 1577*fcd41e86SJacky Bai * It is normally not called by the driver code, unless maybe for test purposes. 1578*fcd41e86SJacky Bai * 1579*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1580*fcd41e86SJacky Bai * Return: number of vacant positions left in the transmission queue, or 1581*fcd41e86SJacky Bai * -1 if the queue was already full when upwr_tx was called, or 1582*fcd41e86SJacky Bai * -2 if any argument is invalid (like size off-range) 1583*fcd41e86SJacky Bai */ 1584*fcd41e86SJacky Bai int upwr_tx(const uint32_t *msg, unsigned int size, 1585*fcd41e86SJacky Bai UPWR_TX_CALLB_FUNC_T callback); 1586*fcd41e86SJacky Bai 1587*fcd41e86SJacky Bai /** 1588*fcd41e86SJacky Bai * upwr_rx() - unqueues a received message from the reception queue. 1589*fcd41e86SJacky Bai * @msg: pointer to the message destination buffer. 1590*fcd41e86SJacky Bai * @size: pointer to variable to hold message size in 32-bit words. 1591*fcd41e86SJacky Bai * 1592*fcd41e86SJacky Bai * This is an auxiliary function used by the rest of the API calls. 1593*fcd41e86SJacky Bai * It is normally not called by the driver code, unless maybe for test purposes. 1594*fcd41e86SJacky Bai * 1595*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1596*fcd41e86SJacky Bai * Return: number of messages remaining in the reception queue, or 1597*fcd41e86SJacky Bai * -1 if the queue was already empty when upwr_rx was called, or 1598*fcd41e86SJacky Bai * -2 if any argument is invalid (like mu off-range) 1599*fcd41e86SJacky Bai */ 1600*fcd41e86SJacky Bai int upwr_rx(char *msg, unsigned int *size); 1601*fcd41e86SJacky Bai 1602*fcd41e86SJacky Bai /** 1603*fcd41e86SJacky Bai * upwr_rx_callback() - sets up a callback for a message receiving event. 1604*fcd41e86SJacky Bai * @callback: pointer to a function to be called when a message arrives; 1605*fcd41e86SJacky Bai * can be NULL, in which case no callback is done. 1606*fcd41e86SJacky Bai * 1607*fcd41e86SJacky Bai * This is an auxiliary function used by the rest of the API calls. 1608*fcd41e86SJacky Bai * It is normally not called by the driver code, unless maybe for test purposes. 1609*fcd41e86SJacky Bai * 1610*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1611*fcd41e86SJacky Bai * Return: 0 if ok; -2 if any argument is invalid (mu off-range). 1612*fcd41e86SJacky Bai */ 1613*fcd41e86SJacky Bai int upwr_rx_callback(UPWR_RX_CALLB_FUNC_T callback); 1614*fcd41e86SJacky Bai 1615*fcd41e86SJacky Bai /** 1616*fcd41e86SJacky Bai * msg_copy() - copies a message. 1617*fcd41e86SJacky Bai * @dest: pointer to the destination message. 1618*fcd41e86SJacky Bai * @src : pointer to the source message. 1619*fcd41e86SJacky Bai * @size: message size in words. 1620*fcd41e86SJacky Bai * 1621*fcd41e86SJacky Bai * This is an auxiliary function used by the rest of the API calls. 1622*fcd41e86SJacky Bai * It is normally not called by the driver code, unless maybe for test purposes. 1623*fcd41e86SJacky Bai * 1624*fcd41e86SJacky Bai * Context: no sleep, no locks taken/released. 1625*fcd41e86SJacky Bai * Return: none (void) 1626*fcd41e86SJacky Bai */ 1627*fcd41e86SJacky Bai void msg_copy(char *dest, char *src, unsigned int size); 1628*fcd41e86SJacky Bai 1629*fcd41e86SJacky Bai #endif /* UPWR_API_H */ 1630