Vitaly Andrianov | 06c6ea7 | 2014-04-01 15:01:12 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Multicore Navigator definitions |
| 3 | * |
| 4 | * (C) Copyright 2012-2014 |
| 5 | * Texas Instruments Incorporated, <www.ti.com> |
| 6 | * |
| 7 | * SPDX-License-Identifier: GPL-2.0+ |
| 8 | */ |
| 9 | |
| 10 | #ifndef _KEYSTONE_NAV_H_ |
| 11 | #define _KEYSTONE_NAV_H_ |
| 12 | |
| 13 | #include <asm/arch/hardware.h> |
| 14 | #include <asm/io.h> |
| 15 | |
| 16 | enum soc_type_t { |
| 17 | k2hk |
| 18 | }; |
| 19 | |
| 20 | #define QM_OK 0 |
| 21 | #define QM_ERR -1 |
| 22 | #define QM_DESC_TYPE_HOST 0 |
| 23 | #define QM_DESC_PSINFO_IN_DESCR 0 |
| 24 | #define QM_DESC_DEFAULT_DESCINFO (QM_DESC_TYPE_HOST << 30) | \ |
| 25 | (QM_DESC_PSINFO_IN_DESCR << 22) |
| 26 | |
| 27 | /* Packet Info */ |
| 28 | #define QM_DESC_PINFO_EPIB 1 |
| 29 | #define QM_DESC_PINFO_RETURN_OWN 1 |
| 30 | #define QM_DESC_DEFAULT_PINFO (QM_DESC_PINFO_EPIB << 31) | \ |
| 31 | (QM_DESC_PINFO_RETURN_OWN << 15) |
| 32 | |
| 33 | struct qm_cfg_reg { |
| 34 | u32 revision; |
| 35 | u32 __pad1; |
| 36 | u32 divert; |
| 37 | u32 link_ram_base0; |
| 38 | u32 link_ram_size0; |
| 39 | u32 link_ram_base1; |
| 40 | u32 link_ram_size1; |
| 41 | u32 link_ram_base2; |
| 42 | u32 starvation[0]; |
| 43 | }; |
| 44 | |
| 45 | struct descr_mem_setup_reg { |
| 46 | u32 base_addr; |
| 47 | u32 start_idx; |
| 48 | u32 desc_reg_size; |
| 49 | u32 _res0; |
| 50 | }; |
| 51 | |
| 52 | struct qm_reg_queue { |
| 53 | u32 entry_count; |
| 54 | u32 byte_count; |
| 55 | u32 packet_size; |
| 56 | u32 ptr_size_thresh; |
| 57 | }; |
| 58 | |
| 59 | struct qm_config { |
| 60 | /* QM module addresses */ |
| 61 | u32 stat_cfg; /* status and config */ |
| 62 | struct qm_reg_queue *queue; /* management region */ |
| 63 | u32 mngr_vbusm; /* management region (VBUSM) */ |
| 64 | u32 i_lram; /* internal linking RAM */ |
| 65 | struct qm_reg_queue *proxy; |
| 66 | u32 status_ram; |
| 67 | struct qm_cfg_reg *mngr_cfg; |
| 68 | /* Queue manager config region */ |
| 69 | u32 intd_cfg; /* QMSS INTD config region */ |
| 70 | struct descr_mem_setup_reg *desc_mem; |
| 71 | /* descritor memory setup region*/ |
| 72 | u32 region_num; |
| 73 | u32 pdsp_cmd; /* PDSP1 command interface */ |
| 74 | u32 pdsp_ctl; /* PDSP1 control registers */ |
| 75 | u32 pdsp_iram; |
| 76 | /* QM configuration parameters */ |
| 77 | |
| 78 | u32 qpool_num; /* */ |
| 79 | }; |
| 80 | |
| 81 | struct qm_host_desc { |
| 82 | u32 desc_info; |
| 83 | u32 tag_info; |
| 84 | u32 packet_info; |
| 85 | u32 buff_len; |
| 86 | u32 buff_ptr; |
| 87 | u32 next_bdptr; |
| 88 | u32 orig_buff_len; |
| 89 | u32 orig_buff_ptr; |
| 90 | u32 timestamp; |
| 91 | u32 swinfo[3]; |
| 92 | u32 ps_data[20]; |
| 93 | }; |
| 94 | |
| 95 | #define HDESC_NUM 256 |
| 96 | |
| 97 | int qm_init(void); |
| 98 | void qm_close(void); |
| 99 | void qm_push(struct qm_host_desc *hd, u32 qnum); |
| 100 | struct qm_host_desc *qm_pop(u32 qnum); |
| 101 | |
| 102 | void qm_buff_push(struct qm_host_desc *hd, u32 qnum, |
| 103 | void *buff_ptr, u32 buff_len); |
| 104 | |
| 105 | struct qm_host_desc *qm_pop_from_free_pool(void); |
| 106 | void queue_close(u32 qnum); |
| 107 | |
| 108 | /* |
| 109 | * DMA API |
| 110 | */ |
| 111 | #define CPDMA_REG_VAL_MAKE_RX_FLOW_A(einfo, psinfo, rxerr, desc, \ |
| 112 | psloc, sopoff, qmgr, qnum) \ |
| 113 | (((einfo & 1) << 30) | \ |
| 114 | ((psinfo & 1) << 29) | \ |
| 115 | ((rxerr & 1) << 28) | \ |
| 116 | ((desc & 3) << 26) | \ |
| 117 | ((psloc & 1) << 25) | \ |
| 118 | ((sopoff & 0x1ff) << 16) | \ |
| 119 | ((qmgr & 3) << 12) | \ |
| 120 | ((qnum & 0xfff) << 0)) |
| 121 | |
| 122 | #define CPDMA_REG_VAL_MAKE_RX_FLOW_D(fd0qm, fd0qnum, fd1qm, fd1qnum) \ |
| 123 | (((fd0qm & 3) << 28) | \ |
| 124 | ((fd0qnum & 0xfff) << 16) | \ |
| 125 | ((fd1qm & 3) << 12) | \ |
| 126 | ((fd1qnum & 0xfff) << 0)) |
| 127 | |
| 128 | #define CPDMA_CHAN_A_ENABLE ((u32)1 << 31) |
| 129 | #define CPDMA_CHAN_A_TDOWN (1 << 30) |
| 130 | #define TDOWN_TIMEOUT_COUNT 100 |
| 131 | |
| 132 | struct global_ctl_regs { |
| 133 | u32 revision; |
| 134 | u32 perf_control; |
| 135 | u32 emulation_control; |
| 136 | u32 priority_control; |
| 137 | u32 qm_base_addr[4]; |
| 138 | }; |
| 139 | |
| 140 | struct tx_chan_regs { |
| 141 | u32 cfg_a; |
| 142 | u32 cfg_b; |
| 143 | u32 res[6]; |
| 144 | }; |
| 145 | |
| 146 | struct rx_chan_regs { |
| 147 | u32 cfg_a; |
| 148 | u32 res[7]; |
| 149 | }; |
| 150 | |
| 151 | struct rx_flow_regs { |
| 152 | u32 control; |
| 153 | u32 tags; |
| 154 | u32 tag_sel; |
| 155 | u32 fdq_sel[2]; |
| 156 | u32 thresh[3]; |
| 157 | }; |
| 158 | |
| 159 | struct pktdma_cfg { |
| 160 | struct global_ctl_regs *global; |
| 161 | struct tx_chan_regs *tx_ch; |
| 162 | u32 tx_ch_num; |
| 163 | struct rx_chan_regs *rx_ch; |
| 164 | u32 rx_ch_num; |
| 165 | u32 *tx_sched; |
| 166 | struct rx_flow_regs *rx_flows; |
| 167 | u32 rx_flow_num; |
| 168 | |
| 169 | u32 rx_free_q; |
| 170 | u32 rx_rcv_q; |
| 171 | u32 tx_snd_q; |
| 172 | |
| 173 | u32 rx_flow; /* flow that is used for RX */ |
| 174 | }; |
| 175 | |
| 176 | /* |
| 177 | * packet dma user allocates memory for rx buffers |
| 178 | * and describe it in the following structure |
| 179 | */ |
| 180 | struct rx_buff_desc { |
| 181 | u8 *buff_ptr; |
| 182 | u32 num_buffs; |
| 183 | u32 buff_len; |
| 184 | u32 rx_flow; |
| 185 | }; |
| 186 | |
| 187 | int netcp_close(void); |
| 188 | int netcp_init(struct rx_buff_desc *rx_buffers); |
| 189 | int netcp_send(u32 *pkt, int num_bytes, u32 swinfo2); |
| 190 | void *netcp_recv(u32 **pkt, int *num_bytes); |
| 191 | void netcp_release_rxhd(void *hd); |
| 192 | |
| 193 | #endif /* _KEYSTONE_NAV_H_ */ |