0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __TISCI_PROTOCOL_H
0010 #define __TISCI_PROTOCOL_H
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 struct ti_sci_version_info {
0022 u8 abi_major;
0023 u8 abi_minor;
0024 u16 firmware_revision;
0025 char firmware_description[32];
0026 };
0027
0028 struct ti_sci_handle;
0029
0030
0031
0032
0033
0034
0035
0036 struct ti_sci_core_ops {
0037 int (*reboot_device)(const struct ti_sci_handle *handle);
0038 };
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 struct ti_sci_dev_ops {
0099 int (*get_device)(const struct ti_sci_handle *handle, u32 id);
0100 int (*get_device_exclusive)(const struct ti_sci_handle *handle, u32 id);
0101 int (*idle_device)(const struct ti_sci_handle *handle, u32 id);
0102 int (*idle_device_exclusive)(const struct ti_sci_handle *handle,
0103 u32 id);
0104 int (*put_device)(const struct ti_sci_handle *handle, u32 id);
0105 int (*is_valid)(const struct ti_sci_handle *handle, u32 id);
0106 int (*get_context_loss_count)(const struct ti_sci_handle *handle,
0107 u32 id, u32 *count);
0108 int (*is_idle)(const struct ti_sci_handle *handle, u32 id,
0109 bool *requested_state);
0110 int (*is_stop)(const struct ti_sci_handle *handle, u32 id,
0111 bool *req_state, bool *current_state);
0112 int (*is_on)(const struct ti_sci_handle *handle, u32 id,
0113 bool *req_state, bool *current_state);
0114 int (*is_transitioning)(const struct ti_sci_handle *handle, u32 id,
0115 bool *current_state);
0116 int (*set_device_resets)(const struct ti_sci_handle *handle, u32 id,
0117 u32 reset_state);
0118 int (*get_device_resets)(const struct ti_sci_handle *handle, u32 id,
0119 u32 *reset_state);
0120 };
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171 struct ti_sci_clk_ops {
0172 int (*get_clock)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0173 bool needs_ssc, bool can_change_freq,
0174 bool enable_input_term);
0175 int (*idle_clock)(const struct ti_sci_handle *handle, u32 did, u32 cid);
0176 int (*put_clock)(const struct ti_sci_handle *handle, u32 did, u32 cid);
0177 int (*is_auto)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0178 bool *req_state);
0179 int (*is_on)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0180 bool *req_state, bool *current_state);
0181 int (*is_off)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0182 bool *req_state, bool *current_state);
0183 int (*set_parent)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0184 u32 parent_id);
0185 int (*get_parent)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0186 u32 *parent_id);
0187 int (*get_num_parents)(const struct ti_sci_handle *handle, u32 did,
0188 u32 cid, u32 *num_parents);
0189 int (*get_best_match_freq)(const struct ti_sci_handle *handle, u32 did,
0190 u32 cid, u64 min_freq, u64 target_freq,
0191 u64 max_freq, u64 *match_freq);
0192 int (*set_freq)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0193 u64 min_freq, u64 target_freq, u64 max_freq);
0194 int (*get_freq)(const struct ti_sci_handle *handle, u32 did, u32 cid,
0195 u64 *current_freq);
0196 };
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206 struct ti_sci_resource_desc {
0207 u16 start;
0208 u16 num;
0209 u16 start_sec;
0210 u16 num_sec;
0211 unsigned long *res_map;
0212 };
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 struct ti_sci_rm_core_ops {
0232 int (*get_range)(const struct ti_sci_handle *handle, u32 dev_id,
0233 u8 subtype, struct ti_sci_resource_desc *desc);
0234 int (*get_range_from_shost)(const struct ti_sci_handle *handle,
0235 u32 dev_id, u8 subtype, u8 s_host,
0236 struct ti_sci_resource_desc *desc);
0237 };
0238
0239 #define TI_SCI_RESASG_SUBTYPE_IR_OUTPUT 0
0240 #define TI_SCI_RESASG_SUBTYPE_IA_VINT 0xa
0241 #define TI_SCI_RESASG_SUBTYPE_GLOBAL_EVENT_SEVT 0xd
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253 struct ti_sci_rm_irq_ops {
0254 int (*set_irq)(const struct ti_sci_handle *handle, u16 src_id,
0255 u16 src_index, u16 dst_id, u16 dst_host_irq);
0256 int (*set_event_map)(const struct ti_sci_handle *handle, u16 src_id,
0257 u16 src_index, u16 ia_id, u16 vint,
0258 u16 global_event, u8 vint_status_bit);
0259 int (*free_irq)(const struct ti_sci_handle *handle, u16 src_id,
0260 u16 src_index, u16 dst_id, u16 dst_host_irq);
0261 int (*free_event_map)(const struct ti_sci_handle *handle, u16 src_id,
0262 u16 src_index, u16 ia_id, u16 vint,
0263 u16 global_event, u8 vint_status_bit);
0264 };
0265
0266
0267 #define TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID BIT(0)
0268
0269 #define TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID BIT(1)
0270
0271 #define TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID BIT(2)
0272
0273 #define TI_SCI_MSG_VALUE_RM_RING_MODE_VALID BIT(3)
0274
0275 #define TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID BIT(4)
0276
0277 #define TI_SCI_MSG_VALUE_RM_RING_ORDER_ID_VALID BIT(5)
0278
0279 #define TI_SCI_MSG_VALUE_RM_RING_VIRTID_VALID BIT(6)
0280
0281 #define TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID BIT(7)
0282
0283 #define TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER \
0284 (TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID | \
0285 TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID | \
0286 TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID | \
0287 TI_SCI_MSG_VALUE_RM_RING_MODE_VALID | \
0288 TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID | \
0289 TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID)
0290
0291
0292
0293
0294
0295
0296
0297 struct ti_sci_msg_rm_ring_cfg {
0298 u32 valid_params;
0299 u16 nav_id;
0300 u16 index;
0301 u32 addr_lo;
0302 u32 addr_hi;
0303 u32 count;
0304 u8 mode;
0305 u8 size;
0306 u8 order_id;
0307 u16 virtid;
0308 u8 asel;
0309 };
0310
0311
0312
0313
0314
0315 struct ti_sci_rm_ringacc_ops {
0316 int (*set_cfg)(const struct ti_sci_handle *handle,
0317 const struct ti_sci_msg_rm_ring_cfg *params);
0318 };
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333 struct ti_sci_rm_psil_ops {
0334 int (*pair)(const struct ti_sci_handle *handle, u32 nav_id,
0335 u32 src_thread, u32 dst_thread);
0336 int (*unpair)(const struct ti_sci_handle *handle, u32 nav_id,
0337 u32 src_thread, u32 dst_thread);
0338 };
0339
0340
0341 #define TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR 2
0342 #define TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR_SB 3
0343 #define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_PBRR 10
0344 #define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_PBVR 11
0345 #define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_BCOPY_PBRR 12
0346 #define TI_SCI_RM_UDMAP_CHAN_TYPE_3RDP_BCOPY_PBVR 13
0347
0348 #define TI_SCI_RM_UDMAP_RX_FLOW_DESC_HOST 0
0349 #define TI_SCI_RM_UDMAP_RX_FLOW_DESC_MONO 2
0350
0351 #define TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_64_BYTES 1
0352 #define TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_128_BYTES 2
0353 #define TI_SCI_RM_UDMAP_CHAN_BURST_SIZE_256_BYTES 3
0354
0355 #define TI_SCI_RM_BCDMA_EXTENDED_CH_TYPE_TCHAN 0
0356 #define TI_SCI_RM_BCDMA_EXTENDED_CH_TYPE_BCHAN 1
0357
0358
0359 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_PAUSE_ON_ERR_VALID BIT(0)
0360 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID BIT(1)
0361 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID BIT(2)
0362 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID BIT(3)
0363 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID BIT(4)
0364 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_PRIORITY_VALID BIT(5)
0365 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_QOS_VALID BIT(6)
0366 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_ORDER_ID_VALID BIT(7)
0367 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_SCHED_PRIORITY_VALID BIT(8)
0368 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_BURST_SIZE_VALID BIT(14)
0369
0370
0371
0372
0373
0374
0375
0376 struct ti_sci_msg_rm_udmap_tx_ch_cfg {
0377 u32 valid_params;
0378 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_EINFO_VALID BIT(9)
0379 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FILT_PSWORDS_VALID BIT(10)
0380 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID BIT(11)
0381 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_CREDIT_COUNT_VALID BIT(12)
0382 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FDEPTH_VALID BIT(13)
0383 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_TDTYPE_VALID BIT(15)
0384 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_EXTENDED_CH_TYPE_VALID BIT(16)
0385 u16 nav_id;
0386 u16 index;
0387 u8 tx_pause_on_err;
0388 u8 tx_filt_einfo;
0389 u8 tx_filt_pswords;
0390 u8 tx_atype;
0391 u8 tx_chan_type;
0392 u8 tx_supr_tdpkt;
0393 u16 tx_fetch_size;
0394 u8 tx_credit_count;
0395 u16 txcq_qnum;
0396 u8 tx_priority;
0397 u8 tx_qos;
0398 u8 tx_orderid;
0399 u16 fdepth;
0400 u8 tx_sched_priority;
0401 u8 tx_burst_size;
0402 u8 tx_tdtype;
0403 u8 extended_ch_type;
0404 };
0405
0406
0407
0408
0409
0410
0411
0412 struct ti_sci_msg_rm_udmap_rx_ch_cfg {
0413 u32 valid_params;
0414 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID BIT(9)
0415 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID BIT(10)
0416 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_SHORT_VALID BIT(11)
0417 #define TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_IGNORE_LONG_VALID BIT(12)
0418 u16 nav_id;
0419 u16 index;
0420 u16 rx_fetch_size;
0421 u16 rxcq_qnum;
0422 u8 rx_priority;
0423 u8 rx_qos;
0424 u8 rx_orderid;
0425 u8 rx_sched_priority;
0426 u16 flowid_start;
0427 u16 flowid_cnt;
0428 u8 rx_pause_on_err;
0429 u8 rx_atype;
0430 u8 rx_chan_type;
0431 u8 rx_ignore_short;
0432 u8 rx_ignore_long;
0433 u8 rx_burst_size;
0434 };
0435
0436
0437
0438
0439
0440
0441
0442 struct ti_sci_msg_rm_udmap_flow_cfg {
0443 u32 valid_params;
0444 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_EINFO_PRESENT_VALID BIT(0)
0445 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_PSINFO_PRESENT_VALID BIT(1)
0446 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_ERROR_HANDLING_VALID BIT(2)
0447 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DESC_TYPE_VALID BIT(3)
0448 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SOP_OFFSET_VALID BIT(4)
0449 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_QNUM_VALID BIT(5)
0450 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_HI_VALID BIT(6)
0451 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_LO_VALID BIT(7)
0452 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_HI_VALID BIT(8)
0453 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_LO_VALID BIT(9)
0454 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_HI_SEL_VALID BIT(10)
0455 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_SRC_TAG_LO_SEL_VALID BIT(11)
0456 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_HI_SEL_VALID BIT(12)
0457 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_DEST_TAG_LO_SEL_VALID BIT(13)
0458 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ0_SZ0_QNUM_VALID BIT(14)
0459 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ1_QNUM_VALID BIT(15)
0460 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ2_QNUM_VALID BIT(16)
0461 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_FDQ3_QNUM_VALID BIT(17)
0462 #define TI_SCI_MSG_VALUE_RM_UDMAP_FLOW_PS_LOCATION_VALID BIT(18)
0463 u16 nav_id;
0464 u16 flow_index;
0465 u8 rx_einfo_present;
0466 u8 rx_psinfo_present;
0467 u8 rx_error_handling;
0468 u8 rx_desc_type;
0469 u16 rx_sop_offset;
0470 u16 rx_dest_qnum;
0471 u8 rx_src_tag_hi;
0472 u8 rx_src_tag_lo;
0473 u8 rx_dest_tag_hi;
0474 u8 rx_dest_tag_lo;
0475 u8 rx_src_tag_hi_sel;
0476 u8 rx_src_tag_lo_sel;
0477 u8 rx_dest_tag_hi_sel;
0478 u8 rx_dest_tag_lo_sel;
0479 u16 rx_fdq0_sz0_qnum;
0480 u16 rx_fdq1_qnum;
0481 u16 rx_fdq2_qnum;
0482 u16 rx_fdq3_qnum;
0483 u8 rx_ps_location;
0484 };
0485
0486
0487
0488
0489
0490
0491
0492 struct ti_sci_rm_udmap_ops {
0493 int (*tx_ch_cfg)(const struct ti_sci_handle *handle,
0494 const struct ti_sci_msg_rm_udmap_tx_ch_cfg *params);
0495 int (*rx_ch_cfg)(const struct ti_sci_handle *handle,
0496 const struct ti_sci_msg_rm_udmap_rx_ch_cfg *params);
0497 int (*rx_flow_cfg)(const struct ti_sci_handle *handle,
0498 const struct ti_sci_msg_rm_udmap_flow_cfg *params);
0499 };
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517 struct ti_sci_proc_ops {
0518 int (*request)(const struct ti_sci_handle *handle, u8 pid);
0519 int (*release)(const struct ti_sci_handle *handle, u8 pid);
0520 int (*handover)(const struct ti_sci_handle *handle, u8 pid, u8 hid);
0521 int (*set_config)(const struct ti_sci_handle *handle, u8 pid,
0522 u64 boot_vector, u32 cfg_set, u32 cfg_clr);
0523 int (*set_control)(const struct ti_sci_handle *handle, u8 pid,
0524 u32 ctrl_set, u32 ctrl_clr);
0525 int (*get_status)(const struct ti_sci_handle *handle, u8 pid,
0526 u64 *boot_vector, u32 *cfg_flags, u32 *ctrl_flags,
0527 u32 *status_flags);
0528 };
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538 struct ti_sci_ops {
0539 struct ti_sci_core_ops core_ops;
0540 struct ti_sci_dev_ops dev_ops;
0541 struct ti_sci_clk_ops clk_ops;
0542 struct ti_sci_rm_core_ops rm_core_ops;
0543 struct ti_sci_rm_irq_ops rm_irq_ops;
0544 struct ti_sci_rm_ringacc_ops rm_ring_ops;
0545 struct ti_sci_rm_psil_ops rm_psil_ops;
0546 struct ti_sci_rm_udmap_ops rm_udmap_ops;
0547 struct ti_sci_proc_ops proc_ops;
0548 };
0549
0550
0551
0552
0553
0554
0555 struct ti_sci_handle {
0556 struct ti_sci_version_info version;
0557 struct ti_sci_ops ops;
0558 };
0559
0560 #define TI_SCI_RESOURCE_NULL 0xffff
0561
0562
0563
0564
0565
0566
0567
0568
0569 struct ti_sci_resource {
0570 u16 sets;
0571 raw_spinlock_t lock;
0572 struct ti_sci_resource_desc *desc;
0573 };
0574
0575 #if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL)
0576 const struct ti_sci_handle *ti_sci_get_handle(struct device *dev);
0577 int ti_sci_put_handle(const struct ti_sci_handle *handle);
0578 const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev);
0579 const struct ti_sci_handle *ti_sci_get_by_phandle(struct device_node *np,
0580 const char *property);
0581 const struct ti_sci_handle *devm_ti_sci_get_by_phandle(struct device *dev,
0582 const char *property);
0583 u16 ti_sci_get_free_resource(struct ti_sci_resource *res);
0584 void ti_sci_release_resource(struct ti_sci_resource *res, u16 id);
0585 u32 ti_sci_get_num_resources(struct ti_sci_resource *res);
0586 struct ti_sci_resource *
0587 devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
0588 struct device *dev, u32 dev_id, char *of_prop);
0589 struct ti_sci_resource *
0590 devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
0591 u32 dev_id, u32 sub_type);
0592
0593 #else
0594
0595 static inline const struct ti_sci_handle *ti_sci_get_handle(struct device *dev)
0596 {
0597 return ERR_PTR(-EINVAL);
0598 }
0599
0600 static inline int ti_sci_put_handle(const struct ti_sci_handle *handle)
0601 {
0602 return -EINVAL;
0603 }
0604
0605 static inline
0606 const struct ti_sci_handle *devm_ti_sci_get_handle(struct device *dev)
0607 {
0608 return ERR_PTR(-EINVAL);
0609 }
0610
0611 static inline
0612 const struct ti_sci_handle *ti_sci_get_by_phandle(struct device_node *np,
0613 const char *property)
0614 {
0615 return ERR_PTR(-EINVAL);
0616 }
0617
0618 static inline
0619 const struct ti_sci_handle *devm_ti_sci_get_by_phandle(struct device *dev,
0620 const char *property)
0621 {
0622 return ERR_PTR(-EINVAL);
0623 }
0624
0625 static inline u16 ti_sci_get_free_resource(struct ti_sci_resource *res)
0626 {
0627 return TI_SCI_RESOURCE_NULL;
0628 }
0629
0630 static inline void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)
0631 {
0632 }
0633
0634 static inline u32 ti_sci_get_num_resources(struct ti_sci_resource *res)
0635 {
0636 return 0;
0637 }
0638
0639 static inline struct ti_sci_resource *
0640 devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
0641 struct device *dev, u32 dev_id, char *of_prop)
0642 {
0643 return ERR_PTR(-EINVAL);
0644 }
0645
0646 static inline struct ti_sci_resource *
0647 devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
0648 u32 dev_id, u32 sub_type)
0649 {
0650 return ERR_PTR(-EINVAL);
0651 }
0652 #endif
0653
0654 #endif