1*936afd9fSDhruva Gole /* 2*936afd9fSDhruva Gole * Texas Instruments System Control Interface API 3*936afd9fSDhruva Gole * Based on Linux and U-Boot implementation 4*936afd9fSDhruva Gole * 5*936afd9fSDhruva Gole * Copyright (C) 2018-2025 Texas Instruments Incorporated - https://www.ti.com/ 6*936afd9fSDhruva Gole * 7*936afd9fSDhruva Gole * SPDX-License-Identifier: BSD-3-Clause 8*936afd9fSDhruva Gole */ 9*936afd9fSDhruva Gole 10*936afd9fSDhruva Gole #ifndef TI_SCI_H 11*936afd9fSDhruva Gole #define TI_SCI_H 12*936afd9fSDhruva Gole 13*936afd9fSDhruva Gole #include <stdint.h> 14*936afd9fSDhruva Gole #include <stdbool.h> 15*936afd9fSDhruva Gole 16*936afd9fSDhruva Gole /** 17*936afd9fSDhruva Gole * User exported structures. 18*936afd9fSDhruva Gole * 19*936afd9fSDhruva Gole * The structures in ti_sci_protocol.h are used by the internal drivers. 20*936afd9fSDhruva Gole * These are the structures that are exported for outside use and populated 21*936afd9fSDhruva Gole * by the internal drivers. 22*936afd9fSDhruva Gole * 23*936afd9fSDhruva Gole * struct ti_sci_msg_version - Structure containing version info 24*936afd9fSDhruva Gole * 25*936afd9fSDhruva Gole * @firmware_description: String describing the firmware 26*936afd9fSDhruva Gole * @firmware_revision: Firmware revision 27*936afd9fSDhruva Gole * @abi_major: Major version of the ABI that firmware supports 28*936afd9fSDhruva Gole * @abi_minor: Minor version of the ABI that firmware supports 29*936afd9fSDhruva Gole * @sub_version: Sub-version number of the firmware 30*936afd9fSDhruva Gole * @patch_version: Patch-version number of the firmware. 31*936afd9fSDhruva Gole */ 32*936afd9fSDhruva Gole struct ti_sci_msg_version { 33*936afd9fSDhruva Gole #define FIRMWARE_DESCRIPTION_LENGTH 32 34*936afd9fSDhruva Gole char firmware_description[FIRMWARE_DESCRIPTION_LENGTH]; 35*936afd9fSDhruva Gole uint16_t firmware_revision; 36*936afd9fSDhruva Gole uint8_t abi_major; 37*936afd9fSDhruva Gole uint8_t abi_minor; 38*936afd9fSDhruva Gole uint8_t sub_version; 39*936afd9fSDhruva Gole uint8_t patch_version; 40*936afd9fSDhruva Gole }; 41*936afd9fSDhruva Gole 42*936afd9fSDhruva Gole /** 43*936afd9fSDhruva Gole * General Message 44*936afd9fSDhruva Gole * 45*936afd9fSDhruva Gole * ti_sci_get_revision - Get the revision of the SCI entity 46*936afd9fSDhruva Gole * @version: Structure containing the version info 47*936afd9fSDhruva Gole * 48*936afd9fSDhruva Gole **/ 49*936afd9fSDhruva Gole int ti_sci_get_revision(struct ti_sci_msg_version *version); 50*936afd9fSDhruva Gole 51*936afd9fSDhruva Gole /** 52*936afd9fSDhruva Gole * Device control operations 53*936afd9fSDhruva Gole * 54*936afd9fSDhruva Gole * - ti_sci_device_get - command to request for device managed by TISCI 55*936afd9fSDhruva Gole * - ti_sci_device_get_exclusive - exclusively request a device 56*936afd9fSDhruva Gole * - ti_sci_device_idle - Command to idle a device managed by TISCI 57*936afd9fSDhruva Gole * - ti_sci_device_idle_exclusive - exclusively idle a device 58*936afd9fSDhruva Gole * - ti_sci_device_put - command to release a device managed by TISCI 59*936afd9fSDhruva Gole * - ti_sci_device_put_no_wait - release a device without waiting for response 60*936afd9fSDhruva Gole * - ti_sci_device_is_valid - Is the device valid 61*936afd9fSDhruva Gole * - ti_sci_device_get_clcnt - Get context loss counter 62*936afd9fSDhruva Gole * @count: Pointer to Context Loss counter to populate 63*936afd9fSDhruva Gole * - ti_sci_device_is_idle - Check if the device is requested to be idle 64*936afd9fSDhruva Gole * @r_state: true if requested to be idle 65*936afd9fSDhruva Gole * - ti_sci_device_is_stop - Check if the device is requested to be stopped 66*936afd9fSDhruva Gole * @r_state: true if requested to be stopped 67*936afd9fSDhruva Gole * @curr_state: true if currently stopped. 68*936afd9fSDhruva Gole * - ti_sci_device_is_on - Check if the device is requested to be ON 69*936afd9fSDhruva Gole * @r_state: true if requested to be ON 70*936afd9fSDhruva Gole * @curr_state: true if currently ON and active 71*936afd9fSDhruva Gole * - ti_sci_device_is_trans - Check if the device is currently transitioning 72*936afd9fSDhruva Gole * @curr_state: true if currently transitioning. 73*936afd9fSDhruva Gole * - ti_sci_device_set_resets - Command to set resets for 74*936afd9fSDhruva Gole * device managed by TISCI 75*936afd9fSDhruva Gole * @reset_state: Device specific reset bit field 76*936afd9fSDhruva Gole * - ti_sci_device_get_resets - Get reset state for device managed by TISCI 77*936afd9fSDhruva Gole * @reset_state: Pointer to reset state to populate 78*936afd9fSDhruva Gole * 79*936afd9fSDhruva Gole * NOTE: for all these functions, the following are generic in nature: 80*936afd9fSDhruva Gole * @id: Device Identifier 81*936afd9fSDhruva Gole * Returns 0 for successful request, else returns corresponding error message. 82*936afd9fSDhruva Gole * 83*936afd9fSDhruva Gole * Request for the device - NOTE: the client MUST maintain integrity of 84*936afd9fSDhruva Gole * usage count by balancing get_device with put_device. No refcounting is 85*936afd9fSDhruva Gole * managed by driver for that purpose. 86*936afd9fSDhruva Gole */ 87*936afd9fSDhruva Gole int ti_sci_device_get(uint32_t id); 88*936afd9fSDhruva Gole int ti_sci_device_get_exclusive(uint32_t id); 89*936afd9fSDhruva Gole int ti_sci_device_idle(uint32_t id); 90*936afd9fSDhruva Gole int ti_sci_device_idle_exclusive(uint32_t id); 91*936afd9fSDhruva Gole int ti_sci_device_put(uint32_t id); 92*936afd9fSDhruva Gole int ti_sci_device_put_no_wait(uint32_t id); 93*936afd9fSDhruva Gole int ti_sci_device_is_valid(uint32_t id); 94*936afd9fSDhruva Gole int ti_sci_device_get_clcnt(uint32_t id, uint32_t *count); 95*936afd9fSDhruva Gole int ti_sci_device_is_idle(uint32_t id, bool *r_state); 96*936afd9fSDhruva Gole int ti_sci_device_is_stop(uint32_t id, bool *r_state, bool *curr_state); 97*936afd9fSDhruva Gole int ti_sci_device_is_on(uint32_t id, bool *r_state, bool *curr_state); 98*936afd9fSDhruva Gole int ti_sci_device_is_trans(uint32_t id, bool *curr_state); 99*936afd9fSDhruva Gole int ti_sci_device_set_resets(uint32_t id, uint32_t reset_state); 100*936afd9fSDhruva Gole int ti_sci_device_get_resets(uint32_t id, uint32_t *reset_state); 101*936afd9fSDhruva Gole 102*936afd9fSDhruva Gole /** 103*936afd9fSDhruva Gole * Clock control operations 104*936afd9fSDhruva Gole * 105*936afd9fSDhruva Gole * - ti_sci_clock_get - Get control of a clock from TI SCI 106*936afd9fSDhruva Gole * @needs_ssc: 'true' iff Spread Spectrum clock is desired 107*936afd9fSDhruva Gole * @can_change_freq: 'true' iff frequency change is desired 108*936afd9fSDhruva Gole * @enable_input_term: 'true' iff input termination is desired 109*936afd9fSDhruva Gole * - ti_sci_clock_idle - Idle a clock which is in our control 110*936afd9fSDhruva Gole * - ti_sci_clock_put - Release a clock from our control 111*936afd9fSDhruva Gole * - ti_sci_clock_is_auto - Is the clock being auto managed 112*936afd9fSDhruva Gole * @req_state: state indicating if the clock is auto managed 113*936afd9fSDhruva Gole * - ti_sci_clock_is_on - Is the clock ON 114*936afd9fSDhruva Gole * @req_state: state indicating if the clock is managed by us and enabled 115*936afd9fSDhruva Gole * @curr_state: state indicating if the clock is ready for operation 116*936afd9fSDhruva Gole * - ti_sci_clock_is_off - Is the clock OFF 117*936afd9fSDhruva Gole * @req_state: state indicating if the clock is managed by us and disabled 118*936afd9fSDhruva Gole * @curr_state: state indicating if the clock is NOT ready for operation 119*936afd9fSDhruva Gole * - ti_sci_clock_set_parent - Set the clock source of a specific device clock 120*936afd9fSDhruva Gole * @parent_id: Parent clock identifier to set 121*936afd9fSDhruva Gole * - ti_sci_clock_get_parent - Get current parent clock source 122*936afd9fSDhruva Gole * @parent_id: Current clock parent 123*936afd9fSDhruva Gole * - ti_sci_clock_get_num_parents - Get num parents of the current clk source 124*936afd9fSDhruva Gole * @num_parents: Returns he number of parents to the current clock. 125*936afd9fSDhruva Gole * - ti_sci_clock_get_match_freq - Find a good match for frequency 126*936afd9fSDhruva Gole * @match_freq: Frequency match in Hz response. 127*936afd9fSDhruva Gole * - ti_sci_clock_set_freq - Set a frequency for clock 128*936afd9fSDhruva Gole * - ti_sci_clock_get_freq - Get current frequency 129*936afd9fSDhruva Gole * @freq: Currently frequency in Hz 130*936afd9fSDhruva Gole * 131*936afd9fSDhruva Gole * NOTE: for all these functions, the following are generic in nature: 132*936afd9fSDhruva Gole * @dev_id: Device identifier this request is for 133*936afd9fSDhruva Gole * @clk_id: Clock identifier for the device for this request. 134*936afd9fSDhruva Gole * Each device has its own set of clock inputs. This indexes 135*936afd9fSDhruva Gole * which clock input to modify. 136*936afd9fSDhruva Gole * @min_freq: The minimum allowable frequency in Hz. This is the minimum 137*936afd9fSDhruva Gole * allowable programmed frequency and does not account for clock 138*936afd9fSDhruva Gole * tolerances and jitter. 139*936afd9fSDhruva Gole * @target_freq: The target clock frequency in Hz. A frequency will be 140*936afd9fSDhruva Gole * processed as close to this target frequency as possible. 141*936afd9fSDhruva Gole * @max_freq: The maximum allowable frequency in Hz. This is the maximum 142*936afd9fSDhruva Gole * allowable programmed frequency and does not account for clock 143*936afd9fSDhruva Gole * tolerances and jitter. 144*936afd9fSDhruva Gole * Returns 0 for successful request, else returns corresponding error message. 145*936afd9fSDhruva Gole * 146*936afd9fSDhruva Gole * Request for the clock - NOTE: the client MUST maintain integrity of 147*936afd9fSDhruva Gole * usage count by balancing get_clock with put_clock. No refcounting is 148*936afd9fSDhruva Gole * managed by driver for that purpose. 149*936afd9fSDhruva Gole */ 150*936afd9fSDhruva Gole int ti_sci_clock_get(uint32_t dev_id, uint8_t clk_id, 151*936afd9fSDhruva Gole bool needs_ssc, bool can_change_freq, 152*936afd9fSDhruva Gole bool enable_input_term); 153*936afd9fSDhruva Gole int ti_sci_clock_idle(uint32_t dev_id, uint8_t clk_id); 154*936afd9fSDhruva Gole int ti_sci_clock_put(uint32_t dev_id, uint8_t clk_id); 155*936afd9fSDhruva Gole int ti_sci_clock_is_auto(uint32_t dev_id, uint8_t clk_id, 156*936afd9fSDhruva Gole bool *req_state); 157*936afd9fSDhruva Gole int ti_sci_clock_is_on(uint32_t dev_id, uint8_t clk_id, 158*936afd9fSDhruva Gole bool *req_state, bool *curr_state); 159*936afd9fSDhruva Gole int ti_sci_clock_is_off(uint32_t dev_id, uint8_t clk_id, 160*936afd9fSDhruva Gole bool *req_state, bool *curr_state); 161*936afd9fSDhruva Gole int ti_sci_clock_set_parent(uint32_t dev_id, uint8_t clk_id, 162*936afd9fSDhruva Gole uint8_t parent_id); 163*936afd9fSDhruva Gole int ti_sci_clock_get_parent(uint32_t dev_id, uint8_t clk_id, 164*936afd9fSDhruva Gole uint8_t *parent_id); 165*936afd9fSDhruva Gole int ti_sci_clock_get_num_parents(uint32_t dev_id, uint8_t clk_id, 166*936afd9fSDhruva Gole uint8_t *num_parents); 167*936afd9fSDhruva Gole int ti_sci_clock_get_match_freq(uint32_t dev_id, uint8_t clk_id, 168*936afd9fSDhruva Gole uint64_t min_freq, uint64_t target_freq, 169*936afd9fSDhruva Gole uint64_t max_freq, uint64_t *match_freq); 170*936afd9fSDhruva Gole int ti_sci_clock_set_freq(uint32_t dev_id, uint8_t clk_id, 171*936afd9fSDhruva Gole uint64_t min_freq, uint64_t target_freq, 172*936afd9fSDhruva Gole uint64_t max_freq); 173*936afd9fSDhruva Gole int ti_sci_clock_get_freq(uint32_t dev_id, uint8_t clk_id, uint64_t *freq); 174*936afd9fSDhruva Gole 175*936afd9fSDhruva Gole /** 176*936afd9fSDhruva Gole * Core control operations 177*936afd9fSDhruva Gole * 178*936afd9fSDhruva Gole * - ti_sci_core_reboot() - Command to request system reset 179*936afd9fSDhruva Gole * - ti_sci_query_fw_caps() - Get the FW/SoC capabilities 180*936afd9fSDhruva Gole * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability 181*936afd9fSDhruva Gole * 182*936afd9fSDhruva Gole * Return: 0 if all went well, else returns appropriate error value. 183*936afd9fSDhruva Gole */ 184*936afd9fSDhruva Gole int ti_sci_core_reboot(void); 185*936afd9fSDhruva Gole int ti_sci_query_fw_caps(uint64_t *fw_caps); 186*936afd9fSDhruva Gole 187*936afd9fSDhruva Gole /** 188*936afd9fSDhruva Gole * Processor control operations 189*936afd9fSDhruva Gole * 190*936afd9fSDhruva Gole * - ti_sci_proc_request - Command to request a physical processor control 191*936afd9fSDhruva Gole * - ti_sci_proc_release - Command to release a physical processor control 192*936afd9fSDhruva Gole * - ti_sci_proc_handover - Command to handover a physical processor control to 193*936afd9fSDhruva Gole * a host in the processor's access control list. 194*936afd9fSDhruva Gole * @host_id: Host ID to get the control of the processor 195*936afd9fSDhruva Gole * - ti_sci_proc_set_boot_cfg - Command to set the processor boot configuration flags 196*936afd9fSDhruva Gole * @config_flags_set: Configuration flags to be set 197*936afd9fSDhruva Gole * @config_flags_clear: Configuration flags to be cleared. 198*936afd9fSDhruva Gole * - ti_sci_proc_set_boot_ctrl - Command to set the processor boot control flags 199*936afd9fSDhruva Gole * @control_flags_set: Control flags to be set 200*936afd9fSDhruva Gole * @control_flags_clear: Control flags to be cleared 201*936afd9fSDhruva Gole * - ti_sci_proc_set_boot_ctrl_no_wait - Same as above without waiting for response 202*936afd9fSDhruva Gole * - ti_sci_proc_auth_boot_image - Command to authenticate and load the image 203*936afd9fSDhruva Gole * and then set the processor configuration flags. 204*936afd9fSDhruva Gole * @cert_addr: Memory address at which payload image certificate is located. 205*936afd9fSDhruva Gole * - ti_sci_proc_get_boot_status - Command to get the processor boot status 206*936afd9fSDhruva Gole * - ti_sci_proc_wait_boot_status - Command to wait for a processor boot status 207*936afd9fSDhruva Gole * - ti_sci_proc_wait_boot_status_no_wait - Same as above without waiting for response 208*936afd9fSDhruva Gole * 209*936afd9fSDhruva Gole * NOTE: for all these functions, the following are generic in nature: 210*936afd9fSDhruva Gole * @proc_id: Processor ID 211*936afd9fSDhruva Gole * Returns 0 for successful request, else returns corresponding error message. 212*936afd9fSDhruva Gole */ 213*936afd9fSDhruva Gole int ti_sci_proc_request(uint8_t proc_id); 214*936afd9fSDhruva Gole int ti_sci_proc_release(uint8_t proc_id); 215*936afd9fSDhruva Gole int ti_sci_proc_handover(uint8_t proc_id, uint8_t host_id); 216*936afd9fSDhruva Gole int ti_sci_proc_set_boot_cfg(uint8_t proc_id, uint64_t bootvector, 217*936afd9fSDhruva Gole uint32_t config_flags_set, 218*936afd9fSDhruva Gole uint32_t config_flags_clear); 219*936afd9fSDhruva Gole int ti_sci_proc_set_boot_ctrl(uint8_t proc_id, uint32_t control_flags_set, 220*936afd9fSDhruva Gole uint32_t control_flags_clear); 221*936afd9fSDhruva Gole int ti_sci_proc_set_boot_ctrl_no_wait(uint8_t proc_id, 222*936afd9fSDhruva Gole uint32_t control_flags_set, 223*936afd9fSDhruva Gole uint32_t control_flags_clear); 224*936afd9fSDhruva Gole int ti_sci_proc_auth_boot_image(uint8_t proc_id, uint64_t cert_addr); 225*936afd9fSDhruva Gole int ti_sci_proc_get_boot_status(uint8_t proc_id, uint64_t *bv, 226*936afd9fSDhruva Gole uint32_t *cfg_flags, 227*936afd9fSDhruva Gole uint32_t *ctrl_flags, 228*936afd9fSDhruva Gole uint32_t *sts_flags); 229*936afd9fSDhruva Gole int ti_sci_proc_wait_boot_status(uint8_t proc_id, uint8_t num_wait_iterations, 230*936afd9fSDhruva Gole uint8_t num_match_iterations, 231*936afd9fSDhruva Gole uint8_t delay_per_iteration_us, 232*936afd9fSDhruva Gole uint8_t delay_before_iterations_us, 233*936afd9fSDhruva Gole uint32_t status_flags_1_set_all_wait, 234*936afd9fSDhruva Gole uint32_t status_flags_1_set_any_wait, 235*936afd9fSDhruva Gole uint32_t status_flags_1_clr_all_wait, 236*936afd9fSDhruva Gole uint32_t status_flags_1_clr_any_wait); 237*936afd9fSDhruva Gole int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id, 238*936afd9fSDhruva Gole uint8_t num_wait_iterations, 239*936afd9fSDhruva Gole uint8_t num_match_iterations, 240*936afd9fSDhruva Gole uint8_t delay_per_iteration_us, 241*936afd9fSDhruva Gole uint8_t delay_before_iterations_us, 242*936afd9fSDhruva Gole uint32_t status_flags_1_set_all_wait, 243*936afd9fSDhruva Gole uint32_t status_flags_1_set_any_wait, 244*936afd9fSDhruva Gole uint32_t status_flags_1_clr_all_wait, 245*936afd9fSDhruva Gole uint32_t status_flags_1_clr_any_wait); 246*936afd9fSDhruva Gole 247*936afd9fSDhruva Gole /** 248*936afd9fSDhruva Gole * System Low Power Operations 249*936afd9fSDhruva Gole * 250*936afd9fSDhruva Gole * - ti_sci_enter_sleep - Command to initiate system transition into suspend. 251*936afd9fSDhruva Gole * @proc_id: Processor ID. 252*936afd9fSDhruva Gole * @mode: Low power mode to enter. 253*936afd9fSDhruva Gole * @core_resume_addr: Address that core should be resumed from 254*936afd9fSDhruva Gole * after low power transition. 255*936afd9fSDhruva Gole * - ti_sci_lpm_get_next_sys_mode - Get next LPM system mode 256*936afd9fSDhruva Gole * 257*936afd9fSDhruva Gole * @next_mode: pointer to a variable that will store the next mode 258*936afd9fSDhruva Gole * 259*936afd9fSDhruva Gole * Return: 0 if all goes well, else appropriate error message 260*936afd9fSDhruva Gole * 261*936afd9fSDhruva Gole * NOTE: for all these functions, the following are generic in nature: 262*936afd9fSDhruva Gole * Returns 0 for successful request, else returns corresponding error message. 263*936afd9fSDhruva Gole */ 264*936afd9fSDhruva Gole int ti_sci_enter_sleep(uint8_t proc_id, 265*936afd9fSDhruva Gole uint8_t mode, 266*936afd9fSDhruva Gole uint64_t core_resume_addr); 267*936afd9fSDhruva Gole int ti_sci_lpm_get_next_sys_mode(uint8_t *next_mode); 268*936afd9fSDhruva Gole 269*936afd9fSDhruva Gole #endif /* TI_SCI_H */ 270