2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
38 * @Abstract: Magpie FW api
49 #include "cmnos_api.h"
51 #include "vdesc_api.h"
52 #include "usbfifo_api.h"
55 #include "wmi_svc_api.h"
56 #include "buf_pool_api.h"
57 #include "dma_engine_api.h"
59 #if defined(PROJECT_K2)
60 #include "sflash_api.h"
63 #define A_INDIR(sym) _A_MAGPIE_INDIRECTION_TABLE->sym
67 #define DBG_MODULE_INSTALL() cmnos_dbg_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dbg)
68 #define A_DBG_INIT() A_INDIR(dbg._dbg_init())
69 #define A_DBG_TASK() A_INDIR(dbg._dbg_task())
71 #define DBG_MODULE_INSTALL()
76 /* Serial Flash support */
77 #if SYSTEM_MODULE_SFLASH
78 #define SFLASH_MODULE_INSTALL() cmnos_sflash_module_install(&_A_MAGPIE_INDIRECTION_TABLE->sflash)
79 #define A_SFLASH_INIT() A_INDIR(sflash._sflash_init())
80 #define A_SFLASH_ERASE(erase_type, addr) A_INDIR(sflash._sflash_erase(erase_type, addr))
81 #define A_SFLASH_PROG(addr, len, buf) A_INDIR(sflash._sflash_program(addr, len, buf))
82 #define A_SFLASH_READ(fast, addr, len, buf) A_INDIR(sflash._sflash_read(fast, addr, len, buf))
83 #define A_SFLASH_RDSR() A_INDIR(sflash._sflash_rdsr())
85 #define SFLASH_MODULE_INSTALL()
86 #define A_SFLASH_INIT()
87 #define A_SFLASH_ERASE(erase_type, addr)
88 #define A_SFLASH_PROG(addr, len, buf)
89 #define A_SFLASH_READ(fast, addr, len, buf)
90 #define A_SFLASH_RDSR()
93 /* DMA Engine Interface */
94 #define DMA_ENGINE_MODULE_INSTALL() dma_engine_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_engine);
95 #define DMA_Engine_init() A_INDIR(dma_engine._init())
96 #define DMA_Engine_config_rx_queue(q, nDesc, size) A_INDIR(dma_engine._config_rx_queue(q, nDesc, size))
97 #define DMA_Engine_xmit_buf(q, buf) A_INDIR(dma_engine._xmit_buf(q, buf))
98 #define DMA_Engine_flush_xmit(q) A_INDIR(dma_engine._flush_xmit(q))
99 #define DMA_Engine_reap_recv_buf(q) A_INDIR(dma_engine._reap_recv_buf(q))
100 #define DMA_Engine_return_recv_buf(q,buf) A_INDIR(dma_engine._return_recv_buf(q, buf))
101 #define DMA_Engine_reap_xmited_buf(q) A_INDIR(dma_engine._reap_xmited_buf(q))
102 #define DMA_Engine_swap_data(desc) A_INDIR(dma_engine._swap_data(desc))
103 #define DMA_Engine_init_rx_queue(q) A_INDIR(dma_engine._init_rx_queue(q))
104 #define DMA_Engine_init_tx_queue(q) A_INDIR(dma_engine._init_tx_queue(q))
105 #define DMA_Engine_has_compl_packets(q) A_INDIR(dma_engine._has_compl_packets(q))
106 #define DMA_Engine_desc_dump(q) A_INDIR(dma_engine._desc_dump(q))
107 #define DMA_Engine_get_packet(q) A_INDIR(dma_engine._get_packet(q))
108 #define DMA_Engine_reclaim_packet(q,desc) A_INDIR(dma_engine._reclaim_packet(q,desc))
109 #define DMA_Engine_put_packet(q,desc) A_INDIR(dma_engine._put_packet(q,desc))
111 /*DMA Library support for GMAC & PCI(E)*/
112 #define DMA_LIB_MODULE_INSTALL() dma_lib_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_lib)
113 #define dma_lib_tx_init(eng_no, if_type) A_INDIR(dma_lib.tx_init(eng_no, if_type))
114 #define dma_lib_rx_init(eng_no, if_type) A_INDIR(dma_lib.rx_init(eng_no, if_type))
115 #define dma_lib_rx_config(eng_no, desc, gran) A_INDIR(dma_lib.rx_config(eng_no, desc, gran))
116 #define dma_lib_tx_start(eng_no) A_INDIR(dma_lib.tx_start(eng_no))
117 #define dma_lib_rx_start(eng_no) A_INDIR(dma_lib.rx_start(eng_no))
118 #define dma_lib_intr_status(if_type) A_INDIR(dma_lib.intr_status(if_type))
119 #define dma_lib_hard_xmit(eng_no, buf) A_INDIR(dma_lib.hard_xmit(eng_no, buf))
120 #define dma_lib_flush_xmit(eng_no) A_INDIR(dma_lib.flush_xmit(eng_no))
121 #define dma_lib_xmit_done(eng_no) A_INDIR(dma_lib.xmit_done(eng_no))
122 #define dma_lib_reap_xmitted(eng_no) A_INDIR(dma_lib.reap_xmitted(eng_no))
123 #define dma_lib_reap_recv(eng_no) A_INDIR(dma_lib.reap_recv(eng_no))
124 #define dma_lib_return_recv(eng_no, buf) A_INDIR(dma_lib.return_recv(eng_no, buf))
125 #define dma_lib_recv_pkt(eng_no) A_INDIR(dma_lib.recv_pkt(eng_no))
128 #define HIF_MODULE_INSTALL() hif_module_install(&_A_MAGPIE_INDIRECTION_TABLE->hif)
129 #define HIF_init(pConfig) A_INDIR(hif._init(pConfig))
130 #define HIF_shutdown(h) A_INDIR(hif._shutdown(h))
131 #define HIF_register_callback(h, pConfig) A_INDIR(hif._register_callback(h, pConfig))
132 #define HIF_start(h) A_INDIR(hif._start(h))
133 #define HIF_config_pipe(h, pipe, desc_list) A_INDIR(hif._config_pipe(h, pipe, desc_list))
134 #define HIF_send_buffer(h, pipe, buf) A_INDIR(hif._send_buffer(h, pipe, buf))
135 #define HIF_return_recv_buf(h, pipe, buf) A_INDIR(hif._return_recv_buf(h, pipe, buf))
136 #define HIF_isr_handler(h) A_INDIR(hif._isr_handler(h))
137 #define HIF_is_pipe_supported(h, pipe) A_INDIR(hif._is_pipe_supported(h, pipe))
138 #define HIF_get_max_msg_len(h, pipe) A_INDIR(hif._get_max_msg_len(h, pipe))
139 #define HIF_get_reserved_headroom(h) A_INDIR(hif._get_reserved_headroom(h))
140 #define HIF_get_default_pipe(h,u,d) A_INDIR(hif._get_default_pipe(h,u,d))
143 #define VBUF_MODULE_INSTALL() vbuf_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vbuf)
144 #define VBUF_init(nBuf) A_INDIR(vbuf._init(nBuf))
145 #define VBUF_alloc_vbuf() A_INDIR(vbuf._alloc_vbuf())
146 #define VBUF_free_vbuf(buf) A_INDIR(vbuf._free_vbuf(buf))
149 #define VDESC_MODULE_INSTALL() vdesc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vdesc)
150 #define VDESC_init(nDesc) A_INDIR(vdesc._init(nDesc))
151 #define VDESC_alloc_vdesc() A_INDIR(vdesc._alloc_vdesc())
152 #define VDESC_get_hw_desc(desc) A_INDIR(vdesc._get_hw_desc(desc))
153 #define VDESC_swap_vdesc(dst, src) A_INDIR(vdesc._swap_vdesc(dst, src))
155 #define HTC_MODULE_INSTALL() htc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->htc)
156 #define HTC_init(SetupComplete, pConfig) A_INDIR(htc._HTC_Init(SetupComplete, pConfig))
157 #define HTC_Shutdown(h) A_INDIR(htc._HTC_Shutdown(h))
158 #define HTC_RegisterService(h, s) A_INDIR(htc._HTC_RegisterService(h, s))
159 #define HTC_Ready(h) A_INDIR(htc._HTC_Ready(h))
160 #define HTC_SendMsg(h, endpt, buf) A_INDIR(htc._HTC_SendMsg(h, endpt, buf))
161 #define HTC_ReturnBuffers(h, endpt, buf) A_INDIR(htc._HTC_ReturnBuffers(h, endpt, buf))
162 #define HTC_ReturnBuffersList(h, endpt, hd) A_INDIR(htc._HTC_ReturnBuffersList(h, endpt, hd))
163 #define HTC_GetReservedHeadroom(h) A_INDIR(htc._HTC_GetReservedHeadroom(h))
165 #define HTC_NotifyTargetInserted(h)
166 #define HTC_NotifyTargetDetached(h)
169 #define WMI_SERVICE_MODULE_INSTALL() WMI_service_module_install(&_A_MAGPIE_INDIRECTION_TABLE->wmi_svc_api)
170 #define WMI_Init(pCfg) A_INDIR(wmi_svc_api._WMI_Init(pCfg))
171 #define WMI_RegisterDispatchTable(h,pT) A_INDIR(wmi_svc_api._WMI_RegisterDispatchTable(h, pT))
172 #define WMI_AllocEvent(h,ec,len) A_INDIR(wmi_svc_api._WMI_AllocEvent(h, ec, len))
173 #define WMI_SendEvent(h,ev,id,seq,len) A_INDIR(wmi_svc_api._WMI_SendEvent(h, ev, id, seq, len))
174 #define WMI_GetPendingEventsCount() A_INDIR(wmi_svc_api._WMI_GetPendingEventsCount())
175 #define WMI_GetControlEp() A_INDIR(wmi_svc_api._WMI_GetControlEp())
176 #define WMI_SendCompleteHandler(ep, buf) A_INDIR(wmi_svc_api._WMI_SendCompleteHandler(ep, buf))
177 #define WMI_Shutdown(h) A_INDIR(wmi_svc_api._WMI_Shutdown(h))
179 /* USB FIFO module */
180 #define USBFIFO_MODULE_INSTALL() usbfifo_module_install(&_A_MAGPIE_INDIRECTION_TABLE->usbfifo_api)
181 #define USBFIFO_init(pConfig) A_INDIR(usbfifo_api._init(pConfig))
182 #define USBFIFO_enable_event_isr() A_INDIR(usbfifo_api._enable_event_isr())
184 /* BUF pool module */
185 #define BUF_POOL_MODULE_INSTALL() buf_pool_module_install(&_A_MAGPIE_INDIRECTION_TABLE->buf_pool)
186 #define BUF_Pool_init(h) A_INDIR(buf_pool._init(h))
187 #define BUF_Pool_shutdown(h) A_INDIR(buf_pool._shutdown(h))
188 #define BUF_Pool_create_pool(h, id, nItems, nSize) A_INDIR(buf_pool._create_pool(h, id, nItems, nSize))
189 #define BUF_Pool_alloc_buf(h, id, reserve) A_INDIR(buf_pool._alloc_buf(h, id, reserve))
190 #define BUF_Pool_alloc_buf_align(h, id, reserve,align) A_INDIR(buf_pool._alloc_buf_align(h, id, reserve,align))
191 #define BUF_Pool_free_buf(h, id, buf) A_INDIR(buf_pool._free_buf(h, id, buf))
194 * This defines the layout of the indirection table, which
195 * is used to access exported APIs of various modules. The
196 * layout is shared across ROM and RAM code. RAM code may
197 * call into ROM and ROM code may call into RAM. Because
198 * of the latter, existing offsets must not change for the
199 * lifetime of a revision of ROM; but new members may be
202 typedef struct _A_magpie_indirection_table {
203 _A_cmnos_indirection_table_t cmnos;
205 struct sflash_api sflash;
208 WMI_SVC_APIS wmi_svc_api;
209 struct usbfifo_api usbfifo_api;
210 struct buf_pool_api buf_pool;
211 struct vbuf_api vbuf;
212 struct vdesc_api vdesc;
213 struct allocram_api allocram;
214 struct dma_engine_api dma_engine;
215 struct dma_lib_api dma_lib;
216 } _A_magpie_indirection_table_t;
218 extern _A_magpie_indirection_table_t _indir_tbl;
219 #define _A_MAGPIE_INDIRECTION_TABLE_SIZE sizeof(_A_magpie_indirection_table_t)
220 #if defined(__mips__)
221 #define _A_MAGPIE_INDIRECTION_TABLE ((_A_magpie_indirection_table_t *)0x700)
223 #define _A_MAGPIE_INDIRECTION_TABLE (&_indir_tbl)