Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.0-rc2 241 lines 9.8 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Texas Instruments System Control Interface Protocol 4 * 5 * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ 6 * Nishanth Menon 7 */ 8 9#ifndef __TISCI_PROTOCOL_H 10#define __TISCI_PROTOCOL_H 11 12/** 13 * struct ti_sci_version_info - version information structure 14 * @abi_major: Major ABI version. Change here implies risk of backward 15 * compatibility break. 16 * @abi_minor: Minor ABI version. Change here implies new feature addition, 17 * or compatible change in ABI. 18 * @firmware_revision: Firmware revision (not usually used). 19 * @firmware_description: Firmware description (not usually used). 20 */ 21struct ti_sci_version_info { 22 u8 abi_major; 23 u8 abi_minor; 24 u16 firmware_revision; 25 char firmware_description[32]; 26}; 27 28struct ti_sci_handle; 29 30/** 31 * struct ti_sci_core_ops - SoC Core Operations 32 * @reboot_device: Reboot the SoC 33 * Returns 0 for successful request(ideally should never return), 34 * else returns corresponding error value. 35 */ 36struct ti_sci_core_ops { 37 int (*reboot_device)(const struct ti_sci_handle *handle); 38}; 39 40/** 41 * struct ti_sci_dev_ops - Device control operations 42 * @get_device: Command to request for device managed by TISCI 43 * Returns 0 for successful exclusive request, else returns 44 * corresponding error message. 45 * @idle_device: Command to idle a device managed by TISCI 46 * Returns 0 for successful exclusive request, else returns 47 * corresponding error message. 48 * @put_device: Command to release a device managed by TISCI 49 * Returns 0 for successful release, else returns corresponding 50 * error message. 51 * @is_valid: Check if the device ID is a valid ID. 52 * Returns 0 if the ID is valid, else returns corresponding error. 53 * @get_context_loss_count: Command to retrieve context loss counter - this 54 * increments every time the device looses context. Overflow 55 * is possible. 56 * - count: pointer to u32 which will retrieve counter 57 * Returns 0 for successful information request and count has 58 * proper data, else returns corresponding error message. 59 * @is_idle: Reports back about device idle state 60 * - req_state: Returns requested idle state 61 * Returns 0 for successful information request and req_state and 62 * current_state has proper data, else returns corresponding error 63 * message. 64 * @is_stop: Reports back about device stop state 65 * - req_state: Returns requested stop state 66 * - current_state: Returns current stop state 67 * Returns 0 for successful information request and req_state and 68 * current_state has proper data, else returns corresponding error 69 * message. 70 * @is_on: Reports back about device ON(or active) state 71 * - req_state: Returns requested ON state 72 * - current_state: Returns current ON state 73 * Returns 0 for successful information request and req_state and 74 * current_state has proper data, else returns corresponding error 75 * message. 76 * @is_transitioning: Reports back if the device is in the middle of transition 77 * of state. 78 * -current_state: Returns 'true' if currently transitioning. 79 * @set_device_resets: Command to configure resets for device managed by TISCI. 80 * -reset_state: Device specific reset bit field 81 * Returns 0 for successful request, else returns 82 * corresponding error message. 83 * @get_device_resets: Command to read state of resets for device managed 84 * by TISCI. 85 * -reset_state: pointer to u32 which will retrieve resets 86 * Returns 0 for successful request, else returns 87 * corresponding error message. 88 * 89 * NOTE: for all these functions, the following parameters are generic in 90 * nature: 91 * -handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle 92 * -id: Device Identifier 93 * 94 * Request for the device - NOTE: the client MUST maintain integrity of 95 * usage count by balancing get_device with put_device. No refcounting is 96 * managed by driver for that purpose. 97 */ 98struct ti_sci_dev_ops { 99 int (*get_device)(const struct ti_sci_handle *handle, u32 id); 100 int (*idle_device)(const struct ti_sci_handle *handle, u32 id); 101 int (*put_device)(const struct ti_sci_handle *handle, u32 id); 102 int (*is_valid)(const struct ti_sci_handle *handle, u32 id); 103 int (*get_context_loss_count)(const struct ti_sci_handle *handle, 104 u32 id, u32 *count); 105 int (*is_idle)(const struct ti_sci_handle *handle, u32 id, 106 bool *requested_state); 107 int (*is_stop)(const struct ti_sci_handle *handle, u32 id, 108 bool *req_state, bool *current_state); 109 int (*is_on)(const struct ti_sci_handle *handle, u32 id, 110 bool *req_state, bool *current_state); 111 int (*is_transitioning)(const struct ti_sci_handle *handle, u32 id, 112 bool *current_state); 113 int (*set_device_resets)(const struct ti_sci_handle *handle, u32 id, 114 u32 reset_state); 115 int (*get_device_resets)(const struct ti_sci_handle *handle, u32 id, 116 u32 *reset_state); 117}; 118 119/** 120 * struct ti_sci_clk_ops - Clock control operations 121 * @get_clock: Request for activation of clock and manage by processor 122 * - needs_ssc: 'true' if Spread Spectrum clock is desired. 123 * - can_change_freq: 'true' if frequency change is desired. 124 * - enable_input_term: 'true' if input termination is desired. 125 * @idle_clock: Request for Idling a clock managed by processor 126 * @put_clock: Release the clock to be auto managed by TISCI 127 * @is_auto: Is the clock being auto managed 128 * - req_state: state indicating if the clock is auto managed 129 * @is_on: Is the clock ON 130 * - req_state: if the clock is requested to be forced ON 131 * - current_state: if the clock is currently ON 132 * @is_off: Is the clock OFF 133 * - req_state: if the clock is requested to be forced OFF 134 * - current_state: if the clock is currently Gated 135 * @set_parent: Set the clock source of a specific device clock 136 * - parent_id: Parent clock identifier to set. 137 * @get_parent: Get the current clock source of a specific device clock 138 * - parent_id: Parent clock identifier which is the parent. 139 * @get_num_parents: Get the number of parents of the current clock source 140 * - num_parents: returns the number of parent clocks. 141 * @get_best_match_freq: Find a best matching frequency for a frequency 142 * range. 143 * - match_freq: Best matching frequency in Hz. 144 * @set_freq: Set the Clock frequency 145 * @get_freq: Get the Clock frequency 146 * - current_freq: Frequency in Hz that the clock is at. 147 * 148 * NOTE: for all these functions, the following parameters are generic in 149 * nature: 150 * -handle: Pointer to TISCI handle as retrieved by *ti_sci_get_handle 151 * -did: Device identifier this request is for 152 * -cid: Clock identifier for the device for this request. 153 * Each device has it's own set of clock inputs. This indexes 154 * which clock input to modify. 155 * -min_freq: The minimum allowable frequency in Hz. This is the minimum 156 * allowable programmed frequency and does not account for clock 157 * tolerances and jitter. 158 * -target_freq: The target clock frequency in Hz. A frequency will be 159 * processed as close to this target frequency as possible. 160 * -max_freq: The maximum allowable frequency in Hz. This is the maximum 161 * allowable programmed frequency and does not account for clock 162 * tolerances and jitter. 163 * 164 * Request for the clock - NOTE: the client MUST maintain integrity of 165 * usage count by balancing get_clock with put_clock. No refcounting is 166 * managed by driver for that purpose. 167 */ 168struct ti_sci_clk_ops { 169 int (*get_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid, 170 bool needs_ssc, bool can_change_freq, 171 bool enable_input_term); 172 int (*idle_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid); 173 int (*put_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid); 174 int (*is_auto)(const struct ti_sci_handle *handle, u32 did, u8 cid, 175 bool *req_state); 176 int (*is_on)(const struct ti_sci_handle *handle, u32 did, u8 cid, 177 bool *req_state, bool *current_state); 178 int (*is_off)(const struct ti_sci_handle *handle, u32 did, u8 cid, 179 bool *req_state, bool *current_state); 180 int (*set_parent)(const struct ti_sci_handle *handle, u32 did, u8 cid, 181 u8 parent_id); 182 int (*get_parent)(const struct ti_sci_handle *handle, u32 did, u8 cid, 183 u8 *parent_id); 184 int (*get_num_parents)(const struct ti_sci_handle *handle, u32 did, 185 u8 cid, u8 *num_parents); 186 int (*get_best_match_freq)(const struct ti_sci_handle *handle, u32 did, 187 u8 cid, u64 min_freq, u64 target_freq, 188 u64 max_freq, u64 *match_freq); 189 int (*set_freq)(const struct ti_sci_handle *handle, u32 did, u8 cid, 190 u64 min_freq, u64 target_freq, u64 max_freq); 191 int (*get_freq)(const struct ti_sci_handle *handle, u32 did, u8 cid, 192 u64 *current_freq); 193}; 194 195/** 196 * struct ti_sci_ops - Function support for TI SCI 197 * @dev_ops: Device specific operations 198 * @clk_ops: Clock specific operations 199 */ 200struct ti_sci_ops { 201 struct ti_sci_core_ops core_ops; 202 struct ti_sci_dev_ops dev_ops; 203 struct ti_sci_clk_ops clk_ops; 204}; 205 206/** 207 * struct ti_sci_handle - Handle returned to TI SCI clients for usage. 208 * @version: structure containing version information 209 * @ops: operations that are made available to TI SCI clients 210 */ 211struct ti_sci_handle { 212 struct ti_sci_version_info version; 213 struct ti_sci_ops ops; 214}; 215 216#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL) 217const struct ti_sci_handle *ti_sci_get_handle(struct device *dev); 218int ti_sci_put_handle(const struct ti_sci_handle *handle); 219const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev); 220 221#else /* CONFIG_TI_SCI_PROTOCOL */ 222 223static inline const struct ti_sci_handle *ti_sci_get_handle(struct device *dev) 224{ 225 return ERR_PTR(-EINVAL); 226} 227 228static inline int ti_sci_put_handle(const struct ti_sci_handle *handle) 229{ 230 return -EINVAL; 231} 232 233static inline 234const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev) 235{ 236 return ERR_PTR(-EINVAL); 237} 238 239#endif /* CONFIG_TI_SCI_PROTOCOL */ 240 241#endif /* __TISCI_PROTOCOL_H */