1
2
3
4
5
6
7
8
9
10
11#ifndef __TISCI_PROTOCOL_H
12#define __TISCI_PROTOCOL_H
13
14
15
16
17
18
19
20
21
22
23#include <linux/bitops.h>
24struct ti_sci_version_info {
25 u8 abi_major;
26 u8 abi_minor;
27 u16 firmware_revision;
28 char firmware_description[32];
29};
30
31struct ti_sci_handle;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50struct ti_sci_board_ops {
51 int (*board_config)(const struct ti_sci_handle *handle,
52 u64 addr, u32 size);
53 int (*board_config_rm)(const struct ti_sci_handle *handle,
54 u64 addr, u32 size);
55 int (*board_config_security)(const struct ti_sci_handle *handle,
56 u64 addr, u32 size);
57 int (*board_config_pm)(const struct ti_sci_handle *handle,
58 u64 addr, u32 size);
59};
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122struct ti_sci_dev_ops {
123 int (*get_device)(const struct ti_sci_handle *handle, u32 id);
124 int (*get_device_exclusive)(const struct ti_sci_handle *handle, u32 id);
125 int (*idle_device)(const struct ti_sci_handle *handle, u32 id);
126 int (*idle_device_exclusive)(const struct ti_sci_handle *handle,
127 u32 id);
128 int (*put_device)(const struct ti_sci_handle *handle, u32 id);
129 int (*is_valid)(const struct ti_sci_handle *handle, u32 id);
130 int (*get_context_loss_count)(const struct ti_sci_handle *handle,
131 u32 id, u32 *count);
132 int (*is_idle)(const struct ti_sci_handle *handle, u32 id,
133 bool *requested_state);
134 int (*is_stop)(const struct ti_sci_handle *handle, u32 id,
135 bool *req_state, bool *current_state);
136 int (*is_on)(const struct ti_sci_handle *handle, u32 id,
137 bool *req_state, bool *current_state);
138 int (*is_transitioning)(const struct ti_sci_handle *handle, u32 id,
139 bool *current_state);
140 int (*set_device_resets)(const struct ti_sci_handle *handle, u32 id,
141 u32 reset_state);
142 int (*get_device_resets)(const struct ti_sci_handle *handle, u32 id,
143 u32 *reset_state);
144 int (*release_exclusive_devices)(const struct ti_sci_handle *handle);
145};
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196struct ti_sci_clk_ops {
197 int (*get_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid,
198 bool needs_ssc, bool can_change_freq,
199 bool enable_input_term);
200 int (*idle_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid);
201 int (*put_clock)(const struct ti_sci_handle *handle, u32 did, u8 cid);
202 int (*is_auto)(const struct ti_sci_handle *handle, u32 did, u8 cid,
203 bool *req_state);
204 int (*is_on)(const struct ti_sci_handle *handle, u32 did, u8 cid,
205 bool *req_state, bool *current_state);
206 int (*is_off)(const struct ti_sci_handle *handle, u32 did, u8 cid,
207 bool *req_state, bool *current_state);
208 int (*set_parent)(const struct ti_sci_handle *handle, u32 did, u8 cid,
209 u8 parent_id);
210 int (*get_parent)(const struct ti_sci_handle *handle, u32 did, u8 cid,
211 u8 *parent_id);
212 int (*get_num_parents)(const struct ti_sci_handle *handle, u32 did,
213 u8 cid, u8 *num_parents);
214 int (*get_best_match_freq)(const struct ti_sci_handle *handle, u32 did,
215 u8 cid, u64 min_freq, u64 target_freq,
216 u64 max_freq, u64 *match_freq);
217 int (*set_freq)(const struct ti_sci_handle *handle, u32 did, u8 cid,
218 u64 min_freq, u64 target_freq, u64 max_freq);
219 int (*get_freq)(const struct ti_sci_handle *handle, u32 did, u8 cid,
220 u64 *current_freq);
221};
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240struct ti_sci_rm_core_ops {
241 int (*get_range)(const struct ti_sci_handle *handle, u32 dev_id,
242 u8 subtype, u16 *range_start, u16 *range_num);
243 int (*get_range_from_shost)(const struct ti_sci_handle *handle,
244 u32 dev_id, u8 subtype, u8 s_host,
245 u16 *range_start, u16 *range_num);
246};
247
248
249
250
251
252
253
254
255
256struct ti_sci_core_ops {
257 int (*reboot_device)(const struct ti_sci_handle *handle);
258 int (*query_msmc)(const struct ti_sci_handle *handle,
259 u64 *msmc_start, u64 *msmc_end);
260};
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283struct ti_sci_proc_ops {
284 int (*proc_request)(const struct ti_sci_handle *handle, u8 pid);
285 int (*proc_release)(const struct ti_sci_handle *handle, u8 pid);
286 int (*proc_handover)(const struct ti_sci_handle *handle, u8 pid,
287 u8 hid);
288 int (*set_proc_boot_cfg)(const struct ti_sci_handle *handle, u8 pid,
289 u64 bv, u32 cfg_set, u32 cfg_clr);
290 int (*set_proc_boot_ctrl)(const struct ti_sci_handle *handle, u8 pid,
291 u32 ctrl_set, u32 ctrl_clr);
292 int (*proc_auth_boot_image)(const struct ti_sci_handle *handle,
293 u64 *image_addr, u32 *image_size);
294 int (*get_proc_boot_status)(const struct ti_sci_handle *handle, u8 pid,
295 u64 *bv, u32 *cfg_flags, u32 *ctrl_flags,
296 u32 *sts_flags);
297 int (*proc_shutdown_no_wait)(const struct ti_sci_handle *handle,
298 u8 pid);
299};
300
301#define TI_SCI_RING_MODE_RING (0)
302#define TI_SCI_RING_MODE_MESSAGE (1)
303#define TI_SCI_RING_MODE_CREDENTIALS (2)
304#define TI_SCI_RING_MODE_QM (3)
305
306#define TI_SCI_MSG_UNUSED_SECONDARY_HOST TI_SCI_RM_NULL_U8
307
308
309#define TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID BIT(0)
310
311#define TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID BIT(1)
312
313#define TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID BIT(2)
314
315#define TI_SCI_MSG_VALUE_RM_RING_MODE_VALID BIT(3)
316
317#define TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID BIT(4)
318
319#define TI_SCI_MSG_VALUE_RM_RING_ORDER_ID_VALID BIT(5)
320
321#define TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER \
322 (TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID | \
323 TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID | \
324 TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID | \
325 TI_SCI_MSG_VALUE_RM_RING_MODE_VALID | \
326 TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID)
327
328
329
330
331
332struct ti_sci_rm_ringacc_ops {
333 int (*config)(const struct ti_sci_handle *handle,
334 u32 valid_params, u16 nav_id, u16 index,
335 u32 addr_lo, u32 addr_hi, u32 count, u8 mode,
336 u8 size, u8 order_id
337 );
338};
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353struct ti_sci_rm_psil_ops {
354 int (*pair)(const struct ti_sci_handle *handle, u32 nav_id,
355 u32 src_thread, u32 dst_thread);
356 int (*unpair)(const struct ti_sci_handle *handle, u32 nav_id,
357 u32 src_thread, u32 dst_thread);
358};
359
360
361#define TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR 2
362#define TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR_SB 3
363#define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_PBRR 10
364#define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_PBVR 11
365#define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_BCOPY_PBRR 12
366#define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_BCOPY_PBVR 13
367
368
369#define TI_SCI_RM_UDMAP_ATYPE_PHYS 0
370#define TI_SCI_RM_UDMAP_ATYPE_INTERMEDIATE 1
371#define TI_SCI_RM_UDMAP_ATYPE_VIRTUAL 2
372
373
374#define TI_SCI_RM_UDMAP_SCHED_PRIOR_HIGH 0
375#define TI_SCI_RM_UDMAP_SCHED_PRIOR_MEDHIGH 1
376#define TI_SCI_RM_UDMAP_SCHED_PRIOR_MEDLOW 2
377#define TI_SCI_RM_UDMAP_SCHED_PRIOR_LOW 3
378
379#define TI_SCI_RM_UDMAP_RX_FLOW_DESC_HOST 0
380#define TI_SCI_RM_UDMAP_RX_FLOW_DESC_MONO 2
381
382
383#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID BIT(0)
384#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID BIT(1)
385#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID BIT(2)
386#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID BIT(3)
387#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID BIT(4)
388#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_PRIORITY_VALID BIT(5)
389#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_QOS_VALID BIT(6)
390#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_ORDER_ID_VALID BIT(7)
391#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_SCHED_PRIORITY_VALID BIT(8)
392
393
394
395
396
397
398
399struct ti_sci_msg_rm_udmap_tx_ch_cfg {
400 u32 valid_params;
401#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_EINFO_VALID BIT(9)
402#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_PSWORDS_VALID BIT(10)
403#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID BIT(11)
404#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_CREDIT_COUNT_VALID BIT(12)
405#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FDEPTH_VALID BIT(13)
406 u16 nav_id;
407 u16 index;
408 u8 tx_pause_on_err;
409 u8 tx_filt_einfo;
410 u8 tx_filt_pswords;
411 u8 tx_atype;
412 u8 tx_chan_type;
413 u8 tx_supr_tdpkt;
414 u16 tx_fetch_size;
415 u8 tx_credit_count;
416 u16 txcq_qnum;
417 u8 tx_priority;
418 u8 tx_qos;
419 u8 tx_orderid;
420 u16 fdepth;
421 u8 tx_sched_priority;
422};
423
424
425
426
427
428
429
430struct ti_sci_msg_rm_udmap_rx_ch_cfg {
431 u32 valid_params;
432#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID BIT(9)
433#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID BIT(10)
434#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_SHORT_VALID BIT(11)
435#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_LONG_VALID BIT(12)
436 u16 nav_id;
437 u16 index;
438 u16 rx_fetch_size;
439 u16 rxcq_qnum;
440 u8 rx_priority;
441 u8 rx_qos;
442 u8 rx_orderid;
443 u8 rx_sched_priority;
444 u16 flowid_start;
445 u16 flowid_cnt;
446 u8 rx_pause_on_err;
447 u8 rx_atype;
448 u8 rx_chan_type;
449 u8 rx_ignore_short;
450 u8 rx_ignore_long;
451};
452
453
454
455
456
457
458
459struct ti_sci_msg_rm_udmap_flow_cfg {
460 u32 valid_params;
461#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_EINFO_PRESENT_VALID BIT(0)
462#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_PSINFO_PRESENT_VALID BIT(1)
463#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_ERROR_HANDLING_VALID BIT(2)
464#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DESC_TYPE_VALID BIT(3)
465#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SOP_OFFSET_VALID BIT(4)
466#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_QNUM_VALID BIT(5)
467#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_HI_VALID BIT(6)
468#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_LO_VALID BIT(7)
469#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_HI_VALID BIT(8)
470#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_LO_VALID BIT(9)
471#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_HI_SEL_VALID BIT(10)
472#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_LO_SEL_VALID BIT(11)
473#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_HI_SEL_VALID BIT(12)
474#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_LO_SEL_VALID BIT(13)
475#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ0_SZ0_QNUM_VALID BIT(14)
476#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ1_QNUM_VALID BIT(15)
477#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ2_QNUM_VALID BIT(16)
478#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ3_QNUM_VALID BIT(17)
479#define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_PS_LOCATION_VALID BIT(18)
480 u16 nav_id;
481 u16 flow_index;
482 u8 rx_einfo_present;
483 u8 rx_psinfo_present;
484 u8 rx_error_handling;
485 u8 rx_desc_type;
486 u16 rx_sop_offset;
487 u16 rx_dest_qnum;
488 u8 rx_src_tag_hi;
489 u8 rx_src_tag_lo;
490 u8 rx_dest_tag_hi;
491 u8 rx_dest_tag_lo;
492 u8 rx_src_tag_hi_sel;
493 u8 rx_src_tag_lo_sel;
494 u8 rx_dest_tag_hi_sel;
495 u8 rx_dest_tag_lo_sel;
496 u16 rx_fdq0_sz0_qnum;
497 u16 rx_fdq1_qnum;
498 u16 rx_fdq2_qnum;
499 u16 rx_fdq3_qnum;
500 u8 rx_ps_location;
501};
502
503
504
505
506
507
508
509struct ti_sci_rm_udmap_ops {
510 int (*tx_ch_cfg)(const struct ti_sci_handle *handle,
511 const struct ti_sci_msg_rm_udmap_tx_ch_cfg *params);
512 int (*rx_ch_cfg)(const struct ti_sci_handle *handle,
513 const struct ti_sci_msg_rm_udmap_rx_ch_cfg *params);
514 int (*rx_flow_cfg)(
515 const struct ti_sci_handle *handle,
516 const struct ti_sci_msg_rm_udmap_flow_cfg *params);
517};
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535struct ti_sci_msg_fwl_region {
536 u16 fwl_id;
537 u16 region;
538 u32 n_permission_regs;
539 u32 control;
540 u32 permissions[3];
541 u64 start_address;
542 u64 end_address;
543} __packed;
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561struct ti_sci_msg_fwl_owner {
562 u16 fwl_id;
563 u16 region;
564 u8 owner_index;
565 u8 owner_privid;
566 u16 owner_permission_bits;
567} __packed;
568
569
570
571
572
573
574
575struct ti_sci_fwl_ops {
576 int (*set_fwl_region)(const struct ti_sci_handle *handle, const struct ti_sci_msg_fwl_region *region);
577 int (*get_fwl_region)(const struct ti_sci_handle *handle, struct ti_sci_msg_fwl_region *region);
578 int (*change_fwl_owner)(const struct ti_sci_handle *handle, struct ti_sci_msg_fwl_owner *owner);
579};
580
581
582
583
584
585
586
587
588
589
590
591struct ti_sci_ops {
592 struct ti_sci_board_ops board_ops;
593 struct ti_sci_dev_ops dev_ops;
594 struct ti_sci_clk_ops clk_ops;
595 struct ti_sci_core_ops core_ops;
596 struct ti_sci_proc_ops proc_ops;
597 struct ti_sci_rm_core_ops rm_core_ops;
598 struct ti_sci_rm_ringacc_ops rm_ring_ops;
599 struct ti_sci_rm_psil_ops rm_psil_ops;
600 struct ti_sci_rm_udmap_ops rm_udmap_ops;
601 struct ti_sci_fwl_ops fwl_ops;
602};
603
604
605
606
607
608
609struct ti_sci_handle {
610 struct ti_sci_ops ops;
611 struct ti_sci_version_info version;
612};
613
614#define TI_SCI_RESOURCE_NULL 0xffff
615
616
617
618
619
620
621
622struct ti_sci_resource_desc {
623 u16 start;
624 u16 num;
625 unsigned long *res_map;
626};
627
628
629
630
631
632
633
634struct ti_sci_resource {
635 u16 sets;
636 struct ti_sci_resource_desc *desc;
637};
638
639#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL)
640
641const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct udevice *dev);
642const struct ti_sci_handle *ti_sci_get_handle(struct udevice *dev);
643const struct ti_sci_handle *ti_sci_get_by_phandle(struct udevice *dev,
644 const char *property);
645u16 ti_sci_get_free_resource(struct ti_sci_resource *res);
646void ti_sci_release_resource(struct ti_sci_resource *res, u16 id);
647struct ti_sci_resource *
648devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
649 struct udevice *dev, u32 dev_id, char *of_prop);
650
651#else
652
653static inline
654const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct udevice *dev)
655{
656 return ERR_PTR(-EINVAL);
657}
658
659static inline const struct ti_sci_handle *ti_sci_get_handle(struct udevice *dev)
660{
661 return ERR_PTR(-EINVAL);
662}
663
664static inline
665const struct ti_sci_handle *ti_sci_get_by_phandle(struct udevice *dev,
666 const char *property)
667{
668 return ERR_PTR(-EINVAL);
669}
670
671static inline u16 ti_sci_get_free_resource(struct ti_sci_resource *res)
672{
673 return TI_SCI_RESOURCE_NULL;
674}
675
676static inline void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)
677{
678}
679
680static inline struct ti_sci_resource *
681devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
682 struct udevice *dev, u32 dev_id, char *of_prop)
683{
684 return ERR_PTR(-EINVAL);
685}
686#endif
687
688#endif
689