blob: 91f8645731dc868641e4bbebd1cf452704df39ef [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 *
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 *
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 *
19 * - ti_sci_device_set_state - Set device state helper
20 * @flags: flags to setup for the device
21 * @state: State to move the device to
22 * - ti_sci_device_get_state - Get device state helper
23 * @clcnt: Pointer to Context Loss Count
24 * @resets: pointer to resets
25 * @p_state: pointer to p_state
26 * @c_state: pointer to c_state
27 * - ti_sci_device_get - command to request for device managed by TISCI
28 * - ti_sci_device_idle - Command to idle a device managed by TISCI
29 * - ti_sci_device_put - command to release a device managed by TISCI
30 * - ti_sci_device_is_valid - Is the device valid
31 * - ti_sci_device_get_clcnt - Get context loss counter
32 * @count: Pointer to Context Loss counter to populate
33 * - ti_sci_device_is_idle - Check if the device is requested to be idle
34 * @r_state: true if requested to be idle
35 * - ti_sci_device_is_stop - Check if the device is requested to be stopped
36 * @r_state: true if requested to be stopped
37 * @curr_state: true if currently stopped.
38 * - ti_sci_device_is_on - Check if the device is requested to be ON
39 * @r_state: true if requested to be ON
40 * @curr_state: true if currently ON and active
41 * - ti_sci_device_is_trans - Check if the device is currently transitioning
42 * @curr_state: true if currently transitioning.
43 * - ti_sci_device_set_resets - Command to set resets for
44 * device managed by TISCI
45 * @reset_state: Device specific reset bit field
46 * - ti_sci_device_get_resets - Get reset state for device managed by TISCI
47 * @reset_state: Pointer to reset state to populate
48 *
49 * NOTE: for all these functions, the following are generic in nature:
50 * @id: Device Identifier
51 * Returns 0 for successful request, else returns corresponding error message.
52 *
53 * Request for the device - NOTE: the client MUST maintain integrity of
54 * usage count by balancing get_device with put_device. No refcounting is
55 * managed by driver for that purpose.
56 */
57int ti_sci_device_set_state(uint32_t id, uint32_t flags, uint8_t state);
58int ti_sci_device_get_state(uint32_t id, uint32_t *clcnt, uint32_t *resets,
59 uint8_t *p_state, uint8_t *c_state);
60int ti_sci_device_get(uint32_t id);
61int ti_sci_device_idle(uint32_t id);
62int ti_sci_device_put(uint32_t id);
63int ti_sci_device_is_valid(uint32_t id);
64int ti_sci_device_get_clcnt(uint32_t id, uint32_t *count);
65int ti_sci_device_is_idle(uint32_t id, bool *r_state);
66int ti_sci_device_is_stop(uint32_t id, bool *r_state, bool *curr_state);
67int ti_sci_device_is_on(uint32_t id, bool *r_state, bool *curr_state);
68int ti_sci_device_is_trans(uint32_t id, bool *curr_state);
69int ti_sci_device_set_resets(uint32_t id, uint32_t reset_state);
70int ti_sci_device_get_resets(uint32_t id, uint32_t *reset_state);
71
Andrew F. Davisa513b2a2018-05-04 19:06:09 +000072/**
Andrew F. Davisdc08adf2018-05-04 19:06:11 +000073 * Clock control operations
74 *
75 * - ti_sci_clock_set_state - Set clock state helper
76 * @flags: Header flags as needed
77 * @state: State to request for the clock.
78 * - ti_sci_clock_get_state - Get clock state helper
79 * @programmed_state: State requested for clock to move to
80 * @current_state: State that the clock is currently in
81 * - ti_sci_clock_get - Get control of a clock from TI SCI
82 * @needs_ssc: 'true' iff Spread Spectrum clock is desired
83 * @can_change_freq: 'true' iff frequency change is desired
84 * @enable_input_term: 'true' iff input termination is desired
85 * - ti_sci_clock_idle - Idle a clock which is in our control
86 * - ti_sci_clock_put - Release a clock from our control
87 * - ti_sci_clock_is_auto - Is the clock being auto managed
88 * @req_state: state indicating if the clock is auto managed
89 * - ti_sci_clock_is_on - Is the clock ON
90 * @req_state: state indicating if the clock is managed by us and enabled
91 * @curr_state: state indicating if the clock is ready for operation
92 * - ti_sci_clock_is_off - Is the clock OFF
93 * @req_state: state indicating if the clock is managed by us and disabled
94 * @curr_state: state indicating if the clock is NOT ready for operation
95 * - ti_sci_clock_set_parent - Set the clock source of a specific device clock
96 * @parent_id: Parent clock identifier to set
97 * - ti_sci_clock_get_parent - Get current parent clock source
98 * @parent_id: Current clock parent
99 * - ti_sci_clock_get_num_parents - Get num parents of the current clk source
100 * @num_parents: Returns he number of parents to the current clock.
101 * - ti_sci_clock_get_match_freq - Find a good match for frequency
102 * @match_freq: Frequency match in Hz response.
103 * - ti_sci_clock_set_freq - Set a frequency for clock
104 * - ti_sci_clock_get_freq - Get current frequency
105 * @freq: Currently frequency in Hz
106 *
107 * NOTE: for all these functions, the following are generic in nature:
108 * @dev_id: Device identifier this request is for
109 * @clk_id: Clock identifier for the device for this request.
110 * Each device has its own set of clock inputs. This indexes
111 * which clock input to modify.
112 * @min_freq: The minimum allowable frequency in Hz. This is the minimum
113 * allowable programmed frequency and does not account for clock
114 * tolerances and jitter.
115 * @target_freq: The target clock frequency in Hz. A frequency will be
116 * processed as close to this target frequency as possible.
117 * @max_freq: The maximum allowable frequency in Hz. This is the maximum
118 * allowable programmed frequency and does not account for clock
119 * tolerances and jitter.
120 * Returns 0 for successful request, else returns corresponding error message.
121 *
122 * Request for the clock - NOTE: the client MUST maintain integrity of
123 * usage count by balancing get_clock with put_clock. No refcounting is
124 * managed by driver for that purpose.
125 */
126int ti_sci_clock_set_state(uint32_t dev_id, uint8_t clk_id,
127 uint32_t flags, uint8_t state);
128int ti_sci_clock_get_state(uint32_t dev_id, uint8_t clk_id,
129 uint8_t *programmed_state, uint8_t *current_state);
130int ti_sci_clock_get(uint32_t dev_id, uint8_t clk_id,
131 bool needs_ssc, bool can_change_freq,
132 bool enable_input_term);
133int ti_sci_clock_idle(uint32_t dev_id, uint8_t clk_id);
134int ti_sci_clock_put(uint32_t dev_id, uint8_t clk_id);
135int ti_sci_clock_is_auto(uint32_t dev_id, uint8_t clk_id,
136 bool *req_state);
137int ti_sci_clock_is_on(uint32_t dev_id, uint8_t clk_id,
138 bool *req_state, bool *curr_state);
139int ti_sci_clock_is_off(uint32_t dev_id, uint8_t clk_id,
140 bool *req_state, bool *curr_state);
141int ti_sci_clock_set_parent(uint32_t dev_id, uint8_t clk_id,
142 uint8_t parent_id);
143int ti_sci_clock_get_parent(uint32_t dev_id, uint8_t clk_id,
144 uint8_t *parent_id);
145int ti_sci_clock_get_num_parents(uint32_t dev_id, uint8_t clk_id,
146 uint8_t *num_parents);
147int ti_sci_clock_get_match_freq(uint32_t dev_id, uint8_t clk_id,
148 uint64_t min_freq, uint64_t target_freq,
149 uint64_t max_freq, uint64_t *match_freq);
150int ti_sci_clock_set_freq(uint32_t dev_id, uint8_t clk_id,
151 uint64_t min_freq, uint64_t target_freq,
152 uint64_t max_freq);
153int ti_sci_clock_get_freq(uint32_t dev_id, uint8_t clk_id, uint64_t *freq);
154
155/**
Andrew F. Davis0d449302018-05-04 19:06:12 +0000156 * Core control operations
157 *
158 * - ti_sci_core_reboot() - Command to request system reset
159 *
160 * Return: 0 if all went well, else returns appropriate error value.
161 */
162int ti_sci_core_reboot(void);
163
164/**
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000165 * Processor control operations
166 *
167 * - ti_sci_proc_request - Command to request a physical processor control
168 * - ti_sci_proc_release - Command to release a physical processor control
169 * - ti_sci_proc_handover - Command to handover a physical processor control to
170 * a host in the processor's access control list.
171 * @host_id: Host ID to get the control of the processor
172 * - ti_sci_proc_set_boot_cfg - Command to set the processor boot configuration flags
173 * @config_flags_set: Configuration flags to be set
174 * @config_flags_clear: Configuration flags to be cleared.
175 * - ti_sci_proc_set_boot_ctrl - Command to set the processor boot control flags
176 * @control_flags_set: Control flags to be set
177 * @control_flags_clear: Control flags to be cleared
178 * - ti_sci_proc_auth_boot_image - Command to authenticate and load the image
179 * and then set the processor configuration flags.
180 * @cert_addr: Memory address at which payload image certificate is located.
181 * - ti_sci_proc_get_boot_status - Command to get the processor boot status
Andrew F. Davisb62cc1e2018-12-18 13:21:12 -0600182 * - ti_sci_proc_wait_boot_status - Command to wait for a processor boot status
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000183 *
184 * NOTE: for all these functions, the following are generic in nature:
185 * @proc_id: Processor ID
186 * Returns 0 for successful request, else returns corresponding error message.
187 */
188int ti_sci_proc_request(uint8_t proc_id);
189int ti_sci_proc_release(uint8_t proc_id);
190int ti_sci_proc_handover(uint8_t proc_id, uint8_t host_id);
191int ti_sci_proc_set_boot_cfg(uint8_t proc_id, uint64_t bootvector,
192 uint32_t config_flags_set,
193 uint32_t config_flags_clear);
194int ti_sci_proc_set_boot_ctrl(uint8_t proc_id, uint32_t control_flags_set,
195 uint32_t control_flags_clear);
196int ti_sci_proc_auth_boot_image(uint8_t proc_id, uint64_t cert_addr);
197int ti_sci_proc_get_boot_status(uint8_t proc_id, uint64_t *bv,
198 uint32_t *cfg_flags,
199 uint32_t *ctrl_flags,
200 uint32_t *sts_flags);
Andrew F. Davisb62cc1e2018-12-18 13:21:12 -0600201int ti_sci_proc_wait_boot_status(uint8_t proc_id, uint8_t num_wait_iterations,
202 uint8_t num_match_iterations,
203 uint8_t delay_per_iteration_us,
204 uint8_t delay_before_iterations_us,
205 uint32_t status_flags_1_set_all_wait,
206 uint32_t status_flags_1_set_any_wait,
207 uint32_t status_flags_1_clr_all_wait,
208 uint32_t status_flags_1_clr_any_wait);
Andrew F. Davisd92fdfb2018-05-04 19:06:13 +0000209
210/**
Andrew F. Davisa513b2a2018-05-04 19:06:09 +0000211 * ti_sci_init() - Basic initialization
212 *
213 * Return: 0 if all goes good, else appropriate error message.
214 */
215int ti_sci_init(void);
216
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000217#endif /* TI_SCI_H */