blob: c702a711f15883de7c2145206f484509bcf9d336 [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 *
Dave Gerlach7a94ce82021-11-30 15:35:08 -06005 * Copyright (C) 2018-2022 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/**
17 * Device control operations
18 *
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000019 * - ti_sci_device_get - command to request for device managed by TISCI
Andrew F. Davisfbe6c062019-02-11 12:58:32 -060020 * - ti_sci_device_get_exclusive - exclusively request a device
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000021 * - ti_sci_device_idle - Command to idle a device managed by TISCI
Andrew F. Davisfbe6c062019-02-11 12:58:32 -060022 * - ti_sci_device_idle_exclusive - exclusively idle a device
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000023 * - ti_sci_device_put - command to release a device managed by TISCI
Andrew F. Davisa29578d2019-02-11 14:18:53 -060024 * - ti_sci_device_put_no_wait - release a device without waiting for response
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000025 * - ti_sci_device_is_valid - Is the device valid
26 * - ti_sci_device_get_clcnt - Get context loss counter
27 * @count: Pointer to Context Loss counter to populate
28 * - ti_sci_device_is_idle - Check if the device is requested to be idle
29 * @r_state: true if requested to be idle
30 * - ti_sci_device_is_stop - Check if the device is requested to be stopped
31 * @r_state: true if requested to be stopped
32 * @curr_state: true if currently stopped.
33 * - ti_sci_device_is_on - Check if the device is requested to be ON
34 * @r_state: true if requested to be ON
35 * @curr_state: true if currently ON and active
36 * - ti_sci_device_is_trans - Check if the device is currently transitioning
37 * @curr_state: true if currently transitioning.
38 * - ti_sci_device_set_resets - Command to set resets for
39 * device managed by TISCI
40 * @reset_state: Device specific reset bit field
41 * - ti_sci_device_get_resets - Get reset state for device managed by TISCI
42 * @reset_state: Pointer to reset state to populate
43 *
44 * NOTE: for all these functions, the following are generic in nature:
45 * @id: Device Identifier
46 * Returns 0 for successful request, else returns corresponding error message.
47 *
48 * Request for the device - NOTE: the client MUST maintain integrity of
49 * usage count by balancing get_device with put_device. No refcounting is
50 * managed by driver for that purpose.
51 */
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000052int ti_sci_device_get(uint32_t id);
Andrew F. Davisfbe6c062019-02-11 12:58:32 -060053int ti_sci_device_get_exclusive(uint32_t id);
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000054int ti_sci_device_idle(uint32_t id);
Andrew F. Davisfbe6c062019-02-11 12:58:32 -060055int ti_sci_device_idle_exclusive(uint32_t id);
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000056int ti_sci_device_put(uint32_t id);
Andrew F. Davisa29578d2019-02-11 14:18:53 -060057int ti_sci_device_put_no_wait(uint32_t id);
Andrew F. Davis4f2a0552018-05-04 19:06:10 +000058int ti_sci_device_is_valid(uint32_t id);
59int ti_sci_device_get_clcnt(uint32_t id, uint32_t *count);
60int ti_sci_device_is_idle(uint32_t id, bool *r_state);
61int ti_sci_device_is_stop(uint32_t id, bool *r_state, bool *curr_state);
62int ti_sci_device_is_on(uint32_t id, bool *r_state, bool *curr_state);
63int ti_sci_device_is_trans(uint32_t id, bool *curr_state);
64int ti_sci_device_set_resets(uint32_t id, uint32_t reset_state);
65int ti_sci_device_get_resets(uint32_t id, uint32_t *reset_state);
66
Andrew F. Davisa513b2a2018-05-04 19:06:09 +000067/**
Andrew F. Davisdc08adf2018-05-04 19:06:11 +000068 * Clock control operations
69 *
Andrew F. Davisdc08adf2018-05-04 19:06:11 +000070 * - ti_sci_clock_get - Get control of a clock from TI SCI
71 * @needs_ssc: 'true' iff Spread Spectrum clock is desired
72 * @can_change_freq: 'true' iff frequency change is desired
73 * @enable_input_term: 'true' iff input termination is desired
74 * - ti_sci_clock_idle - Idle a clock which is in our control
75 * - ti_sci_clock_put - Release a clock from our control
76 * - ti_sci_clock_is_auto - Is the clock being auto managed
77 * @req_state: state indicating if the clock is auto managed
78 * - ti_sci_clock_is_on - Is the clock ON
79 * @req_state: state indicating if the clock is managed by us and enabled
80 * @curr_state: state indicating if the clock is ready for operation
81 * - ti_sci_clock_is_off - Is the clock OFF
82 * @req_state: state indicating if the clock is managed by us and disabled
83 * @curr_state: state indicating if the clock is NOT ready for operation
84 * - ti_sci_clock_set_parent - Set the clock source of a specific device clock
85 * @parent_id: Parent clock identifier to set
86 * - ti_sci_clock_get_parent - Get current parent clock source
87 * @parent_id: Current clock parent
88 * - ti_sci_clock_get_num_parents - Get num parents of the current clk source
89 * @num_parents: Returns he number of parents to the current clock.
90 * - ti_sci_clock_get_match_freq - Find a good match for frequency
91 * @match_freq: Frequency match in Hz response.
92 * - ti_sci_clock_set_freq - Set a frequency for clock
93 * - ti_sci_clock_get_freq - Get current frequency
94 * @freq: Currently frequency in Hz
95 *
96 * NOTE: for all these functions, the following are generic in nature:
97 * @dev_id: Device identifier this request is for
98 * @clk_id: Clock identifier for the device for this request.
99 * Each device has its own set of clock inputs. This indexes
100 * which clock input to modify.
101 * @min_freq: The minimum allowable frequency in Hz. This is the minimum
102 * allowable programmed frequency and does not account for clock
103 * tolerances and jitter.
104 * @target_freq: The target clock frequency in Hz. A frequency will be
105 * processed as close to this target frequency as possible.
106 * @max_freq: The maximum allowable frequency in Hz. This is the maximum
107 * allowable programmed frequency and does not account for clock
108 * tolerances and jitter.
109 * Returns 0 for successful request, else returns corresponding error message.
110 *
111 * Request for the clock - NOTE: the client MUST maintain integrity of
112 * usage count by balancing get_clock with put_clock. No refcounting is
113 * managed by driver for that purpose.
114 */
Andrew F. Davisdc08adf2018-05-04 19:06:11 +0000115int ti_sci_clock_get(uint32_t dev_id, uint8_t clk_id,
116 bool needs_ssc, bool can_change_freq,
117 bool enable_input_term);
118int ti_sci_clock_idle(uint32_t dev_id, uint8_t clk_id);
119int ti_sci_clock_put(uint32_t dev_id, uint8_t clk_id);
120int ti_sci_clock_is_auto(uint32_t dev_id, uint8_t clk_id,
121 bool *req_state);
122int ti_sci_clock_is_on(uint32_t dev_id, uint8_t clk_id,
123 bool *req_state, bool *curr_state);
124int ti_sci_clock_is_off(uint32_t dev_id, uint8_t clk_id,
125 bool *req_state, bool *curr_state);
126int ti_sci_clock_set_parent(uint32_t dev_id, uint8_t clk_id,
127 uint8_t parent_id);
128int ti_sci_clock_get_parent(uint32_t dev_id, uint8_t clk_id,
129 uint8_t *parent_id);
130int ti_sci_clock_get_num_parents(uint32_t dev_id, uint8_t clk_id,
131 uint8_t *num_parents);
132int ti_sci_clock_get_match_freq(uint32_t dev_id, uint8_t clk_id,
133 uint64_t min_freq, uint64_t target_freq,
134 uint64_t max_freq, uint64_t *match_freq);
135int ti_sci_clock_set_freq(uint32_t dev_id, uint8_t clk_id,
136 uint64_t min_freq, uint64_t target_freq,
137 uint64_t max_freq);
138int ti_sci_clock_get_freq(uint32_t dev_id, uint8_t clk_id, uint64_t *freq);
139
140/**
Andrew F. Davis0d449302018-05-04 19:06:12 +0000141 * Core control operations
142 *
143 * - ti_sci_core_reboot() - Command to request system reset
Andrew Davis10d67f92023-06-26 12:49:17 -0500144 * - ti_sci_query_fw_caps() - Get the FW/SoC capabilities
145 * @fw_caps: Each bit in fw_caps indicating one FW/SOC capability
Andrew F. Davis0d449302018-05-04 19:06:12 +0000146 *
147 * Return: 0 if all went well, else returns appropriate error value.
148 */
149int ti_sci_core_reboot(void);
Andrew Davis10d67f92023-06-26 12:49:17 -0500150int ti_sci_query_fw_caps(uint64_t *fw_caps);
Andrew F. Davis0d449302018-05-04 19:06:12 +0000151
152/**
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000153 * Processor control operations
154 *
155 * - ti_sci_proc_request - Command to request a physical processor control
156 * - ti_sci_proc_release - Command to release a physical processor control
157 * - ti_sci_proc_handover - Command to handover a physical processor control to
158 * a host in the processor's access control list.
159 * @host_id: Host ID to get the control of the processor
160 * - ti_sci_proc_set_boot_cfg - Command to set the processor boot configuration flags
161 * @config_flags_set: Configuration flags to be set
162 * @config_flags_clear: Configuration flags to be cleared.
163 * - ti_sci_proc_set_boot_ctrl - Command to set the processor boot control flags
164 * @control_flags_set: Control flags to be set
165 * @control_flags_clear: Control flags to be cleared
Andrew F. Davisa29578d2019-02-11 14:18:53 -0600166 * - ti_sci_proc_set_boot_ctrl_no_wait - Same as above without waiting for response
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000167 * - ti_sci_proc_auth_boot_image - Command to authenticate and load the image
168 * and then set the processor configuration flags.
169 * @cert_addr: Memory address at which payload image certificate is located.
170 * - ti_sci_proc_get_boot_status - Command to get the processor boot status
Andrew F. Davisb62cc1e2018-12-18 13:21:12 -0600171 * - ti_sci_proc_wait_boot_status - Command to wait for a processor boot status
Andrew F. Davisa29578d2019-02-11 14:18:53 -0600172 * - ti_sci_proc_wait_boot_status_no_wait - Same as above without waiting for response
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000173 *
174 * NOTE: for all these functions, the following are generic in nature:
175 * @proc_id: Processor ID
176 * Returns 0 for successful request, else returns corresponding error message.
177 */
178int ti_sci_proc_request(uint8_t proc_id);
179int ti_sci_proc_release(uint8_t proc_id);
180int ti_sci_proc_handover(uint8_t proc_id, uint8_t host_id);
181int ti_sci_proc_set_boot_cfg(uint8_t proc_id, uint64_t bootvector,
182 uint32_t config_flags_set,
183 uint32_t config_flags_clear);
184int ti_sci_proc_set_boot_ctrl(uint8_t proc_id, uint32_t control_flags_set,
185 uint32_t control_flags_clear);
Andrew F. Davisa29578d2019-02-11 14:18:53 -0600186int ti_sci_proc_set_boot_ctrl_no_wait(uint8_t proc_id,
187 uint32_t control_flags_set,
188 uint32_t control_flags_clear);
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000189int ti_sci_proc_auth_boot_image(uint8_t proc_id, uint64_t cert_addr);
190int ti_sci_proc_get_boot_status(uint8_t proc_id, uint64_t *bv,
191 uint32_t *cfg_flags,
192 uint32_t *ctrl_flags,
193 uint32_t *sts_flags);
Andrew F. Davisb62cc1e2018-12-18 13:21:12 -0600194int ti_sci_proc_wait_boot_status(uint8_t proc_id, uint8_t num_wait_iterations,
195 uint8_t num_match_iterations,
196 uint8_t delay_per_iteration_us,
197 uint8_t delay_before_iterations_us,
198 uint32_t status_flags_1_set_all_wait,
199 uint32_t status_flags_1_set_any_wait,
200 uint32_t status_flags_1_clr_all_wait,
201 uint32_t status_flags_1_clr_any_wait);
Andrew F. Davisa29578d2019-02-11 14:18:53 -0600202int ti_sci_proc_wait_boot_status_no_wait(uint8_t proc_id,
203 uint8_t num_wait_iterations,
204 uint8_t num_match_iterations,
205 uint8_t delay_per_iteration_us,
206 uint8_t delay_before_iterations_us,
207 uint32_t status_flags_1_set_all_wait,
208 uint32_t status_flags_1_set_any_wait,
209 uint32_t status_flags_1_clr_all_wait,
210 uint32_t status_flags_1_clr_any_wait);
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000211
212/**
Dave Gerlach7a94ce82021-11-30 15:35:08 -0600213 * System Low Power Operations
214 *
215 * - ti_sci_enter_sleep - Command to initiate system transition into suspend.
216 * @proc_id: Processor ID.
217 * @mode: Low power mode to enter.
218 * @core_resume_addr: Address that core should be resumed from
219 * after low power transition.
220 *
221 * NOTE: for all these functions, the following are generic in nature:
222 * Returns 0 for successful request, else returns corresponding error message.
223 */
224int ti_sci_enter_sleep(uint8_t proc_id,
225 uint8_t mode,
226 uint64_t core_resume_addr);
227
228/**
Andrew F. Davisa513b2a2018-05-04 19:06:09 +0000229 * ti_sci_init() - Basic initialization
230 *
231 * Return: 0 if all goes good, else appropriate error message.
232 */
233int ti_sci_init(void);
234
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000235#endif /* TI_SCI_H */