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