Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / k2 / Magpie_api.h
1 /*
2  * @File: Magpie_api.h
3  * 
4  * @Abstract: Magpie FW api
5  * 
6  * @Notes:
7  * 
8  * Copyright (c) 2008 Atheros Communications Inc.
9  * All rights reserved.
10  *
11  */
12
13 #ifndef _MAGPIE_API_H
14 #define _MAGPIE_API_H
15
16 #include <sys_cfg.h>
17 #include "cmnos_api.h"
18 #include "vbuf_api.h"
19 #include "vdesc_api.h"
20 #include "usbfifo_api.h"
21 #include "hif_api.h"
22 #include "htc_api.h"
23 #include "wmi_svc_api.h"
24 #include "buf_pool_api.h"
25 #include "dma_engine_api.h"
26 #include "dma_lib.h"
27 #if defined(PROJECT_K2)
28 #include "sflash_api.h"
29 #endif
30
31 #define A_INDIR(sym)   _A_MAGPIE_INDIRECTION_TABLE->sym
32
33 #if SYSTEM_MODULE_DBG
34 /* debug Support */
35 #define DBG_MODULE_INSTALL()            cmnos_dbg_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dbg)
36 #define A_DBG_INIT()                    A_INDIR(dbg._dbg_init())
37 #define A_DBG_TASK()                    A_INDIR(dbg._dbg_task())
38 #else
39 #define DBG_MODULE_INSTALL()
40 #define A_DBG_INIT()
41 #define A_DBG_TASK()
42 #endif
43
44 /* Serial Flash support */
45 #if SYSTEM_MODULE_SFLASH
46 #define SFLASH_MODULE_INSTALL()                 cmnos_sflash_module_install(&_A_MAGPIE_INDIRECTION_TABLE->sflash)
47 #define A_SFLASH_INIT()                         A_INDIR(sflash._sflash_init())
48 #define A_SFLASH_ERASE(erase_type, addr)        A_INDIR(sflash._sflash_erase(erase_type, addr))
49 #define A_SFLASH_PROG(addr, len, buf)           A_INDIR(sflash._sflash_program(addr, len, buf))
50 #define A_SFLASH_READ(fast, addr, len, buf)     A_INDIR(sflash._sflash_read(fast, addr, len, buf))
51 #define A_SFLASH_RDSR()                         A_INDIR(sflash._sflash_rdsr())
52 #else
53 #define SFLASH_MODULE_INSTALL()
54 #define A_SFLASH_INIT()
55 #define A_SFLASH_ERASE(erase_type, addr)
56 #define A_SFLASH_PROG(addr, len, buf)
57 #define A_SFLASH_READ(fast, addr, len, buf)
58 #define A_SFLASH_RDSR()
59 #endif
60
61 /* DMA Engine Interface */
62 #define DMA_ENGINE_MODULE_INSTALL()                 dma_engine_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_engine);
63 #define DMA_Engine_init()                           A_INDIR(dma_engine._init())
64 #define DMA_Engine_config_rx_queue(q, nDesc, size)  A_INDIR(dma_engine._config_rx_queue(q, nDesc, size))
65 #define DMA_Engine_xmit_buf(q, buf)                 A_INDIR(dma_engine._xmit_buf(q, buf))
66 #define DMA_Engine_flush_xmit(q)                    A_INDIR(dma_engine._flush_xmit(q))
67 #define DMA_Engine_reap_recv_buf(q)                 A_INDIR(dma_engine._reap_recv_buf(q))
68 #define DMA_Engine_return_recv_buf(q,buf)           A_INDIR(dma_engine._return_recv_buf(q, buf))
69 #define DMA_Engine_reap_xmited_buf(q)               A_INDIR(dma_engine._reap_xmited_buf(q))
70 #define DMA_Engine_swap_data(desc)                  A_INDIR(dma_engine._swap_data(desc))
71 #define DMA_Engine_init_rx_queue(q)                 A_INDIR(dma_engine._init_rx_queue(q))
72 #define DMA_Engine_init_tx_queue(q)                 A_INDIR(dma_engine._init_tx_queue(q))
73 #define DMA_Engine_has_compl_packets(q)             A_INDIR(dma_engine._has_compl_packets(q))
74 #define DMA_Engine_desc_dump(q)                     A_INDIR(dma_engine._desc_dump(q))
75 #define DMA_Engine_get_packet(q)                    A_INDIR(dma_engine._get_packet(q))
76 #define DMA_Engine_reclaim_packet(q,desc)           A_INDIR(dma_engine._reclaim_packet(q,desc))
77 #define DMA_Engine_put_packet(q,desc)               A_INDIR(dma_engine._put_packet(q,desc))
78
79 /*DMA Library support for GMAC & PCI(E)*/
80 #define DMA_LIB_MODULE_INSTALL()                    dma_lib_module_install(&_A_MAGPIE_INDIRECTION_TABLE->dma_lib)
81 #define dma_lib_tx_init(eng_no, if_type)            A_INDIR(dma_lib.tx_init(eng_no, if_type))
82 #define dma_lib_rx_init(eng_no, if_type)            A_INDIR(dma_lib.rx_init(eng_no, if_type))
83 #define dma_lib_rx_config(eng_no, desc, gran)       A_INDIR(dma_lib.rx_config(eng_no, desc, gran))
84 #define dma_lib_tx_start(eng_no)                    A_INDIR(dma_lib.tx_start(eng_no)) 
85 #define dma_lib_rx_start(eng_no)                    A_INDIR(dma_lib.rx_start(eng_no)) 
86 #define dma_lib_intr_status(if_type)                A_INDIR(dma_lib.intr_status(if_type))
87 #define dma_lib_hard_xmit(eng_no, buf)              A_INDIR(dma_lib.hard_xmit(eng_no, buf))
88 #define dma_lib_flush_xmit(eng_no)                  A_INDIR(dma_lib.flush_xmit(eng_no))
89 #define dma_lib_xmit_done(eng_no)                   A_INDIR(dma_lib.xmit_done(eng_no))
90 #define dma_lib_reap_xmitted(eng_no)                A_INDIR(dma_lib.reap_xmitted(eng_no))
91 #define dma_lib_reap_recv(eng_no)                   A_INDIR(dma_lib.reap_recv(eng_no))
92 #define dma_lib_return_recv(eng_no, buf)            A_INDIR(dma_lib.return_recv(eng_no, buf))
93 #define dma_lib_recv_pkt(eng_no)                    A_INDIR(dma_lib.recv_pkt(eng_no))
94
95 /* HIF support */
96 #define HIF_MODULE_INSTALL()                        hif_module_install(&_A_MAGPIE_INDIRECTION_TABLE->hif)
97 #define HIF_init(pConfig)                           A_INDIR(hif._init(pConfig))
98 #define HIF_shutdown(h)                             A_INDIR(hif._shutdown(h))
99 #define HIF_register_callback(h, pConfig)           A_INDIR(hif._register_callback(h, pConfig))
100 #define HIF_start(h)                                A_INDIR(hif._start(h))  
101 #define HIF_config_pipe(h, pipe, desc_list)         A_INDIR(hif._config_pipe(h, pipe, desc_list)) 
102 #define HIF_send_buffer(h, pipe, buf)               A_INDIR(hif._send_buffer(h, pipe, buf)) 
103 #define HIF_return_recv_buf(h, pipe, buf)           A_INDIR(hif._return_recv_buf(h, pipe, buf)) 
104 #define HIF_isr_handler(h)                          A_INDIR(hif._isr_handler(h)) 
105 #define HIF_is_pipe_supported(h, pipe)              A_INDIR(hif._is_pipe_supported(h, pipe))
106 #define HIF_get_max_msg_len(h, pipe)                A_INDIR(hif._get_max_msg_len(h, pipe))
107 #define HIF_get_reserved_headroom(h)                A_INDIR(hif._get_reserved_headroom(h))
108 #define HIF_get_default_pipe(h,u,d)                 A_INDIR(hif._get_default_pipe(h,u,d))
109
110 /* VBUF APIs */
111 #define VBUF_MODULE_INSTALL()                       vbuf_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vbuf)
112 #define VBUF_init(nBuf)                             A_INDIR(vbuf._init(nBuf))
113 #define VBUF_alloc_vbuf()                           A_INDIR(vbuf._alloc_vbuf())
114 #define VBUF_free_vbuf(buf)                         A_INDIR(vbuf._free_vbuf(buf))
115
116 /* VDESC APIs */
117 #define VDESC_MODULE_INSTALL()                      vdesc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->vdesc)
118 #define VDESC_init(nDesc)                           A_INDIR(vdesc._init(nDesc))
119 #define VDESC_alloc_vdesc()                         A_INDIR(vdesc._alloc_vdesc())
120 #define VDESC_get_hw_desc(desc)                     A_INDIR(vdesc._get_hw_desc(desc))
121 #define VDESC_swap_vdesc(dst, src)                  A_INDIR(vdesc._swap_vdesc(dst, src))
122
123 #define HTC_MODULE_INSTALL()                        htc_module_install(&_A_MAGPIE_INDIRECTION_TABLE->htc)
124 #define HTC_init(SetupComplete, pConfig)            A_INDIR(htc._HTC_Init(SetupComplete, pConfig))
125 #define HTC_Shutdown(h)                             A_INDIR(htc._HTC_Shutdown(h))
126 #define HTC_RegisterService(h, s)                   A_INDIR(htc._HTC_RegisterService(h, s))
127 #define HTC_Ready(h)                                A_INDIR(htc._HTC_Ready(h))
128 #define HTC_SendMsg(h, endpt, buf)                  A_INDIR(htc._HTC_SendMsg(h, endpt, buf))
129 #define HTC_ReturnBuffers(h, endpt, buf)            A_INDIR(htc._HTC_ReturnBuffers(h, endpt, buf))
130 #define HTC_ReturnBuffersList(h, endpt, hd)         A_INDIR(htc._HTC_ReturnBuffersList(h, endpt, hd))
131 #define HTC_GetReservedHeadroom(h)                  A_INDIR(htc._HTC_GetReservedHeadroom(h))
132
133 #define HTC_NotifyTargetInserted(h)
134 #define HTC_NotifyTargetDetached(h)                   
135
136 /* WMI SVC module */
137 #define WMI_SERVICE_MODULE_INSTALL()                WMI_service_module_install(&_A_MAGPIE_INDIRECTION_TABLE->wmi_svc_api)
138 #define WMI_Init(pCfg)                              A_INDIR(wmi_svc_api._WMI_Init(pCfg))
139 #define WMI_RegisterDispatchTable(h,pT)             A_INDIR(wmi_svc_api._WMI_RegisterDispatchTable(h, pT))
140 #define WMI_AllocEvent(h,ec,len)                    A_INDIR(wmi_svc_api._WMI_AllocEvent(h, ec, len))
141 #define WMI_SendEvent(h,ev,id,seq,len)              A_INDIR(wmi_svc_api._WMI_SendEvent(h, ev, id, seq, len))
142 #define WMI_GetPendingEventsCount()                 A_INDIR(wmi_svc_api._WMI_GetPendingEventsCount())
143 #define WMI_GetControlEp()                          A_INDIR(wmi_svc_api._WMI_GetControlEp())
144 #define WMI_SendCompleteHandler(ep, buf)            A_INDIR(wmi_svc_api._WMI_SendCompleteHandler(ep, buf))
145 #define WMI_Shutdown(h)                             A_INDIR(wmi_svc_api._WMI_Shutdown(h))
146
147 /* USB FIFO module */
148 #define USBFIFO_MODULE_INSTALL()                    usbfifo_module_install(&_A_MAGPIE_INDIRECTION_TABLE->usbfifo_api)
149 #define USBFIFO_init(pConfig)                       A_INDIR(usbfifo_api._init(pConfig))
150 #define USBFIFO_enable_event_isr()                  A_INDIR(usbfifo_api._enable_event_isr())
151
152 /* BUF pool module */
153 #define BUF_POOL_MODULE_INSTALL()                       buf_pool_module_install(&_A_MAGPIE_INDIRECTION_TABLE->buf_pool)
154 #define BUF_Pool_init(h)                                A_INDIR(buf_pool._init(h))
155 #define BUF_Pool_shutdown(h)                            A_INDIR(buf_pool._shutdown(h))
156 #define BUF_Pool_create_pool(h, id, nItems, nSize)      A_INDIR(buf_pool._create_pool(h, id, nItems, nSize))
157 #define BUF_Pool_alloc_buf(h, id, reserve)              A_INDIR(buf_pool._alloc_buf(h, id, reserve))
158 #define BUF_Pool_alloc_buf_align(h, id, reserve,align)  A_INDIR(buf_pool._alloc_buf_align(h, id, reserve,align))
159 #define BUF_Pool_free_buf(h, id, buf)                   A_INDIR(buf_pool._free_buf(h, id, buf))
160
161 /*
162  * This defines the layout of the indirection table, which
163  * is used to access exported APIs of various modules.  The
164  * layout is shared across ROM and RAM code.  RAM code may
165  * call into ROM and ROM code may call into RAM.  Because
166  * of the latter, existing offsets must not change for the
167  * lifetime of a revision of ROM; but new members may be
168  * added at the end.
169  */
170 typedef struct _A_magpie_indirection_table {
171         _A_cmnos_indirection_table_t        cmnos;
172         struct dbg_api                      dbg;
173         struct sflash_api                   sflash;
174         struct hif_api                      hif;
175         struct htc_apis                     htc;
176         WMI_SVC_APIS                        wmi_svc_api;     
177         struct usbfifo_api                  usbfifo_api;
178         struct buf_pool_api                 buf_pool;
179         struct vbuf_api                     vbuf;
180         struct vdesc_api                    vdesc;
181         struct allocram_api                 allocram;
182         struct dma_engine_api               dma_engine;
183         struct dma_lib_api                  dma_lib;
184 } _A_magpie_indirection_table_t;
185
186 extern _A_magpie_indirection_table_t _indir_tbl;
187 #define _A_MAGPIE_INDIRECTION_TABLE_SIZE sizeof(_A_magpie_indirection_table_t)
188 #if defined(__mips__)
189 #define _A_MAGPIE_INDIRECTION_TABLE ((_A_magpie_indirection_table_t *)0x700)
190 #else
191 #define _A_MAGPIE_INDIRECTION_TABLE (&_indir_tbl)
192 #endif
193
194 #endif