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