1c1b17487671cc9d79c539bc8e0fe2d62ee86aa1
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / inc / k2 / Magpie_api.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /*
36  * @File: Magpie_api.h
37  * 
38  * @Abstract: Magpie FW api
39  * 
40  * @Notes:
41  */
42
43 #ifndef _MAGPIE_API_H
44 #define _MAGPIE_API_H
45
46 #include <sys_cfg.h>
47 #include "cmnos_api.h"
48 #include "vbuf_api.h"
49 #include "vdesc_api.h"
50 #include "usbfifo_api.h"
51 #include "hif_api.h"
52 #include "htc_api.h"
53 #include "wmi_svc_api.h"
54 #include "buf_pool_api.h"
55 #include "dma_engine_api.h"
56 #include "dma_lib.h"
57 #if defined(PROJECT_K2)
58 #include "sflash_api.h"
59 #endif
60
61 #define A_INDIR(sym)   _A_MAGPIE_INDIRECTION_TABLE->sym
62
63 #if SYSTEM_MODULE_DBG
64 /* debug Support */
65 #define DBG_MODULE_INSTALL()            cmnos_dbg_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dbg)
66 #define A_DBG_INIT()                    A_INDIR(dbg._dbg_init())
67 #define A_DBG_TASK()                    A_INDIR(dbg._dbg_task())
68 #else
69 #define DBG_MODULE_INSTALL()
70 #define A_DBG_INIT()
71 #define A_DBG_TASK()
72 #endif
73
74 /* Serial Flash support */
75 #if SYSTEM_MODULE_SFLASH
76 #define SFLASH_MODULE_INSTALL()                 cmnos_sflash_module_install(&_A_MAGPIE_INDIRECTION_TABLE->sflash)
77 #define A_SFLASH_INIT()                         A_INDIR(sflash._sflash_init())
78 #define A_SFLASH_ERASE(erase_type, addr)        A_INDIR(sflash._sflash_erase(erase_type, addr))
79 #define A_SFLASH_PROG(addr, len, buf)           A_INDIR(sflash._sflash_program(addr, len, buf))
80 #define A_SFLASH_READ(fast, addr, len, buf)     A_INDIR(sflash._sflash_read(fast, addr, len, buf))
81 #define A_SFLASH_RDSR()                         A_INDIR(sflash._sflash_rdsr())
82 #else
83 #define SFLASH_MODULE_INSTALL()
84 #define A_SFLASH_INIT()
85 #define A_SFLASH_ERASE(erase_type, addr)
86 #define A_SFLASH_PROG(addr, len, buf)
87 #define A_SFLASH_READ(fast, addr, len, buf)
88 #define A_SFLASH_RDSR()
89 #endif
90
91 /* DMA Engine Interface */
92 #define DMA_ENGINE_MODULE_INSTALL()                 dma_engine_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_engine);
93 #define DMA_Engine_init()                           A_INDIR(dma_engine._init())
94 #define DMA_Engine_config_rx_queue(q, nDesc, size)  A_INDIR(dma_engine._config_rx_queue(q, nDesc, size))
95 #define DMA_Engine_xmit_buf(q, buf)                 A_INDIR(dma_engine._xmit_buf(q, buf))
96 #define DMA_Engine_flush_xmit(q)                    A_INDIR(dma_engine._flush_xmit(q))
97 #define DMA_Engine_reap_recv_buf(q)                 A_INDIR(dma_engine._reap_recv_buf(q))
98 #define DMA_Engine_return_recv_buf(q,buf)           A_INDIR(dma_engine._return_recv_buf(q, buf))
99 #define DMA_Engine_reap_xmited_buf(q)               A_INDIR(dma_engine._reap_xmited_buf(q))
100 #define DMA_Engine_swap_data(desc)                  A_INDIR(dma_engine._swap_data(desc))
101 #define DMA_Engine_init_rx_queue(q)                 A_INDIR(dma_engine._init_rx_queue(q))
102 #define DMA_Engine_init_tx_queue(q)                 A_INDIR(dma_engine._init_tx_queue(q))
103 #define DMA_Engine_has_compl_packets(q)             A_INDIR(dma_engine._has_compl_packets(q))
104 #define DMA_Engine_desc_dump(q)                     A_INDIR(dma_engine._desc_dump(q))
105 #define DMA_Engine_get_packet(q)                    A_INDIR(dma_engine._get_packet(q))
106 #define DMA_Engine_reclaim_packet(q,desc)           A_INDIR(dma_engine._reclaim_packet(q,desc))
107 #define DMA_Engine_put_packet(q,desc)               A_INDIR(dma_engine._put_packet(q,desc))
108
109 /*DMA Library support for GMAC & PCI(E)*/
110 #define DMA_LIB_MODULE_INSTALL()                    dma_lib_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_lib)
111 #define dma_lib_tx_init(eng_no, if_type)            A_INDIR(dma_lib.tx_init(eng_no, if_type))
112 #define dma_lib_rx_init(eng_no, if_type)            A_INDIR(dma_lib.rx_init(eng_no, if_type))
113 #define dma_lib_rx_config(eng_no, desc, gran)       A_INDIR(dma_lib.rx_config(eng_no, desc, gran))
114 #define dma_lib_tx_start(eng_no)                    A_INDIR(dma_lib.tx_start(eng_no)) 
115 #define dma_lib_rx_start(eng_no)                    A_INDIR(dma_lib.rx_start(eng_no)) 
116 #define dma_lib_intr_status(if_type)                A_INDIR(dma_lib.intr_status(if_type))
117 #define dma_lib_hard_xmit(eng_no, buf)              A_INDIR(dma_lib.hard_xmit(eng_no, buf))
118 #define dma_lib_flush_xmit(eng_no)                  A_INDIR(dma_lib.flush_xmit(eng_no))
119 #define dma_lib_xmit_done(eng_no)                   A_INDIR(dma_lib.xmit_done(eng_no))
120 #define dma_lib_reap_xmitted(eng_no)                A_INDIR(dma_lib.reap_xmitted(eng_no))
121 #define dma_lib_reap_recv(eng_no)                   A_INDIR(dma_lib.reap_recv(eng_no))
122 #define dma_lib_return_recv(eng_no, buf)            A_INDIR(dma_lib.return_recv(eng_no, buf))
123 #define dma_lib_recv_pkt(eng_no)                    A_INDIR(dma_lib.recv_pkt(eng_no))
124
125 /* HIF support */
126 #define HIF_MODULE_INSTALL()                        hif_module_install(&_A_MAGPIE_INDIRECTION_TABLE->hif)
127 #define HIF_init(pConfig)                           A_INDIR(hif._init(pConfig))
128 #define HIF_shutdown(h)                             A_INDIR(hif._shutdown(h))
129 #define HIF_register_callback(h, pConfig)           A_INDIR(hif._register_callback(h, pConfig))
130 #define HIF_start(h)                                A_INDIR(hif._start(h))  
131 #define HIF_config_pipe(h, pipe, desc_list)         A_INDIR(hif._config_pipe(h, pipe, desc_list)) 
132 #define HIF_send_buffer(h, pipe, buf)               A_INDIR(hif._send_buffer(h, pipe, buf)) 
133 #define HIF_return_recv_buf(h, pipe, buf)           A_INDIR(hif._return_recv_buf(h, pipe, buf)) 
134 #define HIF_isr_handler(h)                          A_INDIR(hif._isr_handler(h)) 
135 #define HIF_is_pipe_supported(h, pipe)              A_INDIR(hif._is_pipe_supported(h, pipe))
136 #define HIF_get_max_msg_len(h, pipe)                A_INDIR(hif._get_max_msg_len(h, pipe))
137 #define HIF_get_reserved_headroom(h)                A_INDIR(hif._get_reserved_headroom(h))
138 #define HIF_get_default_pipe(h,u,d)                 A_INDIR(hif._get_default_pipe(h,u,d))
139
140 /* VBUF APIs */
141 #define VBUF_MODULE_INSTALL()                       vbuf_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vbuf)
142 #define VBUF_init(nBuf)                             A_INDIR(vbuf._init(nBuf))
143 #define VBUF_alloc_vbuf()                           A_INDIR(vbuf._alloc_vbuf())
144 #define VBUF_free_vbuf(buf)                         A_INDIR(vbuf._free_vbuf(buf))
145
146 /* VDESC APIs */
147 #define VDESC_MODULE_INSTALL()                      vdesc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vdesc)
148 #define VDESC_init(nDesc)                           A_INDIR(vdesc._init(nDesc))
149 #define VDESC_alloc_vdesc()                         A_INDIR(vdesc._alloc_vdesc())
150 #define VDESC_get_hw_desc(desc)                     A_INDIR(vdesc._get_hw_desc(desc))
151 #define VDESC_swap_vdesc(dst, src)                  A_INDIR(vdesc._swap_vdesc(dst, src))
152
153 #define HTC_MODULE_INSTALL()                        htc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->htc)
154 #define HTC_init(SetupComplete, pConfig)            A_INDIR(htc._HTC_Init(SetupComplete, pConfig))
155 #define HTC_Shutdown(h)                             A_INDIR(htc._HTC_Shutdown(h))
156 #define HTC_RegisterService(h, s)                   A_INDIR(htc._HTC_RegisterService(h, s))
157 #define HTC_Ready(h)                                A_INDIR(htc._HTC_Ready(h))
158 #define HTC_SendMsg(h, endpt, buf)                  A_INDIR(htc._HTC_SendMsg(h, endpt, buf))
159 #define HTC_ReturnBuffers(h, endpt, buf)            A_INDIR(htc._HTC_ReturnBuffers(h, endpt, buf))
160 #define HTC_ReturnBuffersList(h, endpt, hd)         A_INDIR(htc._HTC_ReturnBuffersList(h, endpt, hd))
161 #define HTC_GetReservedHeadroom(h)                  A_INDIR(htc._HTC_GetReservedHeadroom(h))
162
163 #define HTC_NotifyTargetInserted(h)
164 #define HTC_NotifyTargetDetached(h)                   
165
166 /* WMI SVC module */
167 #define WMI_SERVICE_MODULE_INSTALL()                WMI_service_module_install(&_A_MAGPIE_INDIRECTION_TABLE->wmi_svc_api)
168 #define WMI_Init(pCfg)                              A_INDIR(wmi_svc_api._WMI_Init(pCfg))
169 #define WMI_RegisterDispatchTable(h,pT)             A_INDIR(wmi_svc_api._WMI_RegisterDispatchTable(h, pT))
170 #define WMI_AllocEvent(h,ec,len)                    A_INDIR(wmi_svc_api._WMI_AllocEvent(h, ec, len))
171 #define WMI_SendEvent(h,ev,id,seq,len)              A_INDIR(wmi_svc_api._WMI_SendEvent(h, ev, id, seq, len))
172 #define WMI_GetPendingEventsCount()                 A_INDIR(wmi_svc_api._WMI_GetPendingEventsCount())
173 #define WMI_GetControlEp()                          A_INDIR(wmi_svc_api._WMI_GetControlEp())
174 #define WMI_SendCompleteHandler(ep, buf)            A_INDIR(wmi_svc_api._WMI_SendCompleteHandler(ep, buf))
175 #define WMI_Shutdown(h)                             A_INDIR(wmi_svc_api._WMI_Shutdown(h))
176
177 /* USB FIFO module */
178 #define USBFIFO_MODULE_INSTALL()                    usbfifo_module_install(&_A_MAGPIE_INDIRECTION_TABLE->usbfifo_api)
179 #define USBFIFO_init(pConfig)                       A_INDIR(usbfifo_api._init(pConfig))
180 #define USBFIFO_enable_event_isr()                  A_INDIR(usbfifo_api._enable_event_isr())
181
182 /* BUF pool module */
183 #define BUF_POOL_MODULE_INSTALL()                       buf_pool_module_install(&_A_MAGPIE_INDIRECTION_TABLE->buf_pool)
184 #define BUF_Pool_init(h)                                A_INDIR(buf_pool._init(h))
185 #define BUF_Pool_shutdown(h)                            A_INDIR(buf_pool._shutdown(h))
186 #define BUF_Pool_create_pool(h, id, nItems, nSize)      A_INDIR(buf_pool._create_pool(h, id, nItems, nSize))
187 #define BUF_Pool_alloc_buf(h, id, reserve)              A_INDIR(buf_pool._alloc_buf(h, id, reserve))
188 #define BUF_Pool_alloc_buf_align(h, id, reserve,align)  A_INDIR(buf_pool._alloc_buf_align(h, id, reserve,align))
189 #define BUF_Pool_free_buf(h, id, buf)                   A_INDIR(buf_pool._free_buf(h, id, buf))
190
191 /*
192  * This defines the layout of the indirection table, which
193  * is used to access exported APIs of various modules.  The
194  * layout is shared across ROM and RAM code.  RAM code may
195  * call into ROM and ROM code may call into RAM.  Because
196  * of the latter, existing offsets must not change for the
197  * lifetime of a revision of ROM; but new members may be
198  * added at the end.
199  */
200 typedef struct _A_magpie_indirection_table {
201         _A_cmnos_indirection_table_t        cmnos;
202         struct dbg_api                      dbg;
203         struct sflash_api                   sflash;
204         struct hif_api                      hif;
205         struct htc_apis                     htc;
206         WMI_SVC_APIS                        wmi_svc_api;     
207         struct usbfifo_api                  usbfifo_api;
208         struct buf_pool_api                 buf_pool;
209         struct vbuf_api                     vbuf;
210         struct vdesc_api                    vdesc;
211         struct allocram_api                 allocram;
212         struct dma_engine_api               dma_engine;
213         struct dma_lib_api                  dma_lib;
214 } _A_magpie_indirection_table_t;
215
216 extern _A_magpie_indirection_table_t _indir_tbl;
217 #define _A_MAGPIE_INDIRECTION_TABLE_SIZE sizeof(_A_magpie_indirection_table_t)
218 #if defined(__mips__)
219 #define _A_MAGPIE_INDIRECTION_TABLE ((_A_magpie_indirection_table_t *)0x700)
220 #else
221 #define _A_MAGPIE_INDIRECTION_TABLE (&_indir_tbl)
222 #endif
223
224 #endif