1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 3 #ifndef __LINUX_HTE_H 4 #define __LINUX_HTE_H 5 6 #include <linux/errno.h> 7 8 struct hte_chip; 9 struct hte_device; 10 struct of_phandle_args; 11 12 /** 13 * enum hte_edge - HTE line edge flags. 14 * 15 * @HTE_EDGE_NO_SETUP: No edge setup. In this 16 * for example during request irq call. 17 * @HTE_RISING_EDGE_TS: Rising edge. 18 * @HTE_FALLING_EDGE_TS: Falling edge. 19 * 20 */ 21 enum hte_edge { 22 HTE_EDGE_NO_SETUP = 1U << 0, 23 HTE_RISING_EDGE_TS = 1U << 1, 24 HTE_FALLING_EDGE_TS = 1U << 2, 25 }; 26 27 /** 28 * enum hte_return - HTE subsystem return valu 29 * 30 * @HTE_CB_HANDLED: The consumer handled the d 31 * @HTE_RUN_SECOND_CB: The consumer needs furt 32 * HTE subsystem calls secondary callback prov 33 * is allowed to sleep. 34 */ 35 enum hte_return { 36 HTE_CB_HANDLED, 37 HTE_RUN_SECOND_CB, 38 }; 39 40 /** 41 * struct hte_ts_data - HTE timestamp data. 42 * 43 * @tsc: Timestamp value. 44 * @seq: Sequence counter of the timestamps. 45 * @raw_level: Level of the line at the timest 46 * -1 otherwise. 47 */ 48 struct hte_ts_data { 49 u64 tsc; 50 u64 seq; 51 int raw_level; 52 }; 53 54 /** 55 * struct hte_clk_info - Clock source info tha 56 * 57 * @hz: Supported clock rate in HZ, for exampl 58 * @type: Supported clock type. 59 */ 60 struct hte_clk_info { 61 u64 hz; 62 clockid_t type; 63 }; 64 65 /** 66 * typedef hte_ts_cb_t - HTE timestamp data pr 67 * 68 * The callback is used to push timestamp data 69 * not allowed to sleep. 70 * 71 * @ts: HW timestamp data. 72 * @data: Client supplied data. 73 */ 74 typedef enum hte_return (*hte_ts_cb_t)(struct 75 76 /** 77 * typedef hte_ts_sec_cb_t - HTE timestamp dat 78 * 79 * This is used when the client needs further 80 * allowed to sleep. 81 * 82 * @data: Client supplied data. 83 * 84 */ 85 typedef enum hte_return (*hte_ts_sec_cb_t)(voi 86 87 /** 88 * struct hte_line_attr - Line attributes. 89 * 90 * @line_id: The logical ID understood by the 91 * @line_data: Line data related to line_id. 92 * @edge_flags: Edge setup flags. 93 * @name: Descriptive name of the entity that 94 * hardware timestamping. If null, HTE core wi 95 * 96 */ 97 struct hte_line_attr { 98 u32 line_id; 99 void *line_data; 100 unsigned long edge_flags; 101 const char *name; 102 }; 103 104 /** 105 * struct hte_ts_desc - HTE timestamp descript 106 * 107 * This structure is a communication token bet 108 * and subsystem to providers. 109 * 110 * @attr: The line attributes. 111 * @hte_data: Subsystem's private data, set by 112 */ 113 struct hte_ts_desc { 114 struct hte_line_attr attr; 115 void *hte_data; 116 }; 117 118 /** 119 * struct hte_ops - HTE operations set by prov 120 * 121 * @request: Hook for requesting a HTE timesta 122 * non-zero for failures. 123 * @release: Hook for releasing a HTE timestam 124 * non-zero for failures. 125 * @enable: Hook to enable the specified times 126 * non-zero for failures. 127 * @disable: Hook to disable specified timesta 128 * non-zero for failures. 129 * @get_clk_src_info: Hook to get the clock in 130 * to timestamp. Returns 0 for success and neg 131 * success HTE subsystem fills up provided str 132 * 133 * xlated_id parameter is used to communicate 134 * providers and is translated by the provider 135 */ 136 struct hte_ops { 137 int (*request)(struct hte_chip *chip, 138 u32 xlated_id); 139 int (*release)(struct hte_chip *chip, 140 u32 xlated_id); 141 int (*enable)(struct hte_chip *chip, u 142 int (*disable)(struct hte_chip *chip, 143 int (*get_clk_src_info)(struct hte_chi 144 struct hte_clk 145 }; 146 147 /** 148 * struct hte_chip - Abstract HTE chip. 149 * 150 * @name: functional name of the HTE IP block. 151 * @dev: device providing the HTE. 152 * @ops: callbacks for this HTE. 153 * @nlines: number of lines/signals supported 154 * @xlate_of: Callback which translates consum 155 * physical ids, return 0 for the success and 156 * It stores (between 0 to @nlines) in xlated_ 157 * @xlate_plat: Same as above but for the cons 158 * @match_from_linedata: Match HTE device usin 159 * @of_hte_n_cells: Number of cells used to fo 160 * @gdev: HTE subsystem abstract device, inter 161 * @data: chip specific private data. 162 */ 163 struct hte_chip { 164 const char *name; 165 struct device *dev; 166 const struct hte_ops *ops; 167 u32 nlines; 168 int (*xlate_of)(struct hte_chip *gc, 169 const struct of_phandl 170 struct hte_ts_desc *de 171 int (*xlate_plat)(struct hte_chip *gc, 172 u32 *xlated_id); 173 bool (*match_from_linedata)(const stru 174 const stru 175 u8 of_hte_n_cells; 176 177 struct hte_device *gdev; 178 void *data; 179 }; 180 181 #if IS_ENABLED(CONFIG_HTE) 182 /* HTE APIs for the providers */ 183 int devm_hte_register_chip(struct hte_chip *ch 184 int hte_push_ts_ns(const struct hte_chip *chip 185 struct hte_ts_data *data); 186 187 /* HTE APIs for the consumers */ 188 int hte_init_line_attr(struct hte_ts_desc *des 189 unsigned long edge_flag 190 void *data); 191 int hte_ts_get(struct device *dev, struct hte_ 192 int hte_ts_put(struct hte_ts_desc *desc); 193 int hte_request_ts_ns(struct hte_ts_desc *desc 194 hte_ts_sec_cb_t tcb, voi 195 int devm_hte_request_ts_ns(struct device *dev, 196 hte_ts_cb_t cb, hte 197 int of_hte_req_count(struct device *dev); 198 int hte_enable_ts(struct hte_ts_desc *desc); 199 int hte_disable_ts(struct hte_ts_desc *desc); 200 int hte_get_clk_src_info(const struct hte_ts_d 201 struct hte_clk_info * 202 203 #else /* !CONFIG_HTE */ 204 static inline int devm_hte_register_chip(struc 205 { 206 return -EOPNOTSUPP; 207 } 208 209 static inline int hte_push_ts_ns(const struct 210 u32 xlated_id 211 const struct 212 { 213 return -EOPNOTSUPP; 214 } 215 216 static inline int hte_init_line_attr(struct ht 217 unsigned 218 const cha 219 { 220 return -EOPNOTSUPP; 221 } 222 223 static inline int hte_ts_get(struct device *de 224 int index) 225 { 226 return -EOPNOTSUPP; 227 } 228 229 static inline int hte_ts_put(struct hte_ts_des 230 { 231 return -EOPNOTSUPP; 232 } 233 234 static inline int hte_request_ts_ns(struct hte 235 hte_ts_sec 236 { 237 return -EOPNOTSUPP; 238 } 239 240 static inline int devm_hte_request_ts_ns(struc 241 struc 242 hte_t 243 hte_t 244 void 245 { 246 return -EOPNOTSUPP; 247 } 248 249 static inline int of_hte_req_count(struct devi 250 { 251 return -EOPNOTSUPP; 252 } 253 254 static inline int hte_enable_ts(struct hte_ts_ 255 { 256 return -EOPNOTSUPP; 257 } 258 259 static inline int hte_disable_ts(struct hte_ts 260 { 261 return -EOPNOTSUPP; 262 } 263 264 static inline int hte_get_clk_src_info(const s 265 struct 266 { 267 return -EOPNOTSUPP; 268 } 269 #endif /* !CONFIG_HTE */ 270 271 #endif 272
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.