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.
40 #include "athos_api.h"
42 #include "adf_os_mem.h"
48 void htc_setup_comp(void)
52 /* target WMI command related globals */
53 static void dispatch_magpie_sys_cmds(void *pContext, A_UINT16 Command,
54 A_UINT16 SeqNo, A_UINT8 *buffer, int Length);
56 static WMI_DISPATCH_ENTRY Magpie_Sys_DispatchEntries[] =
58 {dispatch_magpie_sys_cmds, WMI_ECHO_CMDID, 0},
59 {dispatch_magpie_sys_cmds, WMI_ACCESS_MEMORY_CMDID, 0}
62 static WMI_DECLARE_DISPATCH_TABLE(Magpie_Sys_Commands_Tbl, Magpie_Sys_DispatchEntries);
64 htc_handle_t htc_handle;
66 extern void HTC_Loopback_Init(htc_handle_t handle);
67 extern void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id,
68 A_UINT16 SeqNo, A_UINT8 *buffer, int Length);
70 static void handle_echo_command(void *pContext, A_UINT16 SeqNo,
71 A_UINT8 *buffer, int Length)
73 _wmi_cmd_rsp(pContext, WMI_ECHO_CMDID, SeqNo, buffer, Length);
76 static void dispatch_magpie_sys_cmds(void *pContext, A_UINT16 Command,
77 A_UINT16 SeqNo, A_UINT8 *buffer, int Length)
82 handle_echo_command(pContext, SeqNo, buffer, Length);
85 case WMI_ACCESS_MEMORY_CMDID:
90 void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id, A_UINT16 SeqNo,
91 A_UINT8 *buffer, int Length)
93 adf_nbuf_t netbuf = ADF_NBUF_NULL;
96 netbuf = WMI_AllocEvent(pContext, WMI_EVT_CLASS_CMD_REPLY, sizeof(WMI_CMD_HDR) + Length);
98 if (netbuf == ADF_NBUF_NULL) {
99 adf_os_print("%s: buffer allocation for event_id %x failed!\n", __FUNCTION__, cmd_id);
104 if (Length != 0 && buffer != NULL) {
105 pData = (A_UINT8 *)adf_nbuf_put_tail(netbuf, Length);
106 adf_os_mem_copy(pData, buffer, Length);
109 WMI_SendEvent(pContext, netbuf, cmd_id, SeqNo, Length);
113 void Magpie_init(void)
115 A_PRINTF("[+++Magpie_init]\n\r");
117 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_BUF_NUM);
118 VBUF_init(MAX_BUF_NUM);
120 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_DESC_NUM);
121 VDESC_init(MAX_DESC_NUM);
123 #if MAGPIE_ENABLE_WLAN == 0
124 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
125 hif_handle = HIF_init(0);
127 #if ZM_FM_LOOPBACK == 1
128 HIF_config_pipe(hif_handle, HIF_USB_PIPE_TX, 5);
129 HIF_config_pipe(hif_handle, HIF_USB_PIPE_COMMAND, 2);
131 #if SYSTEM_MODULE_HP_EP5
132 HIF_config_pipe(hif_handle, HIF_USB_PIPE_HP_TX, 3);
134 #if SYSTEM_MODULE_HP_EP6
135 HIF_config_pipe(hif_handle, HIF_USB_PIPE_MP_TX, 3);
138 A_PRINTF("[+++HIF_init(0)]\n\r");
140 HIF_start(hif_handle);
142 #else /* ZM_FM_LOOPBACK == 0 */
144 htcConf.CreditSize = 320;
145 htcConf.CreditNumber = 10;
147 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_INTERRUPT; // Target -> Host
148 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_COMMAND; // Host -> Target
150 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_RX;
151 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_TX;
153 htcConf.HIFHandle = hif_handle;
154 htcConf.OSHandle = 0; // not used
155 htcConf.PoolHandle = pool_handle;
157 htc_handle = HTC_init(htc_setup_comp, &htcConf);
158 // Initialize HTC services
159 HTC_Loopback_Init(htc_handle);
161 adf_os_mem_zero(&wmiConfig, sizeof(WMI_SVC_CONFIG));
162 wmiConfig.HtcHandle = htc_handle;
163 wmiConfig.PoolHandle = pool_handle;
164 wmiConfig.MaxCmdReplyEvts = 1;
165 wmiConfig.MaxEventEvts = 1;
167 wmi_handle = WMI_Init(&wmiConfig);
168 Magpie_Sys_Commands_Tbl.pContext = wmi_handle;
169 WMI_RegisterDispatchTable(Magpie_Sys_Commands_Tbl.pContext, &Magpie_Sys_Commands_Tbl);
171 #endif/* ZM_FM_LOOPBACK == 0 */
172 #endif /* MAGPIE_ENABLE_WLAN */
175 #endif /* #if MAGPIE==1 */
177 #endif /* #if defined(_RAM_) */