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 #if MAGPIE_ENABLE_WLAN == 0
57 static WMI_DISPATCH_ENTRY Magpie_Sys_DispatchEntries[] =
59 {dispatch_magpie_sys_cmds, WMI_ECHO_CMDID, 0},
60 {dispatch_magpie_sys_cmds, WMI_ACCESS_MEMORY_CMDID, 0}
63 static WMI_DECLARE_DISPATCH_TABLE(Magpie_Sys_Commands_Tbl, Magpie_Sys_DispatchEntries);
66 htc_handle_t htc_handle;
68 extern void HTC_Loopback_Init(htc_handle_t handle);
69 extern void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id,
70 A_UINT16 SeqNo, A_UINT8 *buffer, int Length);
72 static void handle_echo_command(void *pContext, A_UINT16 SeqNo,
73 A_UINT8 *buffer, int Length)
75 _wmi_cmd_rsp(pContext, WMI_ECHO_CMDID, SeqNo, buffer, Length);
78 static void dispatch_magpie_sys_cmds(void *pContext, A_UINT16 Command,
79 A_UINT16 SeqNo, A_UINT8 *buffer, int Length)
84 handle_echo_command(pContext, SeqNo, buffer, Length);
87 case WMI_ACCESS_MEMORY_CMDID:
92 void _wmi_cmd_rsp(void *pContext, WMI_COMMAND_ID cmd_id, A_UINT16 SeqNo,
93 A_UINT8 *buffer, int Length)
95 adf_nbuf_t netbuf = ADF_NBUF_NULL;
98 netbuf = WMI_AllocEvent(pContext, WMI_EVT_CLASS_CMD_REPLY, sizeof(WMI_CMD_HDR) + Length);
100 if (netbuf == ADF_NBUF_NULL) {
101 adf_os_print("%s: buffer allocation for event_id %x failed!\n", __FUNCTION__, cmd_id);
106 if (Length != 0 && buffer != NULL) {
107 pData = (A_UINT8 *)adf_nbuf_put_tail(netbuf, Length);
108 adf_os_mem_copy(pData, buffer, Length);
111 WMI_SendEvent(pContext, netbuf, cmd_id, SeqNo, Length);
115 void Magpie_init(void)
117 A_PRINTF("[+++Magpie_init]\n\r");
119 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_BUF_NUM);
120 VBUF_init(MAX_BUF_NUM);
122 A_PRINTF("[+++VBUF_init(%d)]\n\r", MAX_DESC_NUM);
123 VDESC_init(MAX_DESC_NUM);
125 #if MAGPIE_ENABLE_WLAN == 0
126 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
127 hif_handle = HIF_init(0);
129 #if ZM_FM_LOOPBACK == 1
130 HIF_config_pipe(hif_handle, HIF_USB_PIPE_TX, 5);
131 HIF_config_pipe(hif_handle, HIF_USB_PIPE_COMMAND, 2);
133 #if SYSTEM_MODULE_HP_EP5
134 HIF_config_pipe(hif_handle, HIF_USB_PIPE_HP_TX, 3);
136 #if SYSTEM_MODULE_HP_EP6
137 HIF_config_pipe(hif_handle, HIF_USB_PIPE_MP_TX, 3);
140 A_PRINTF("[+++HIF_init(0)]\n\r");
142 HIF_start(hif_handle);
144 #else /* ZM_FM_LOOPBACK == 0 */
146 htcConf.CreditSize = 320;
147 htcConf.CreditNumber = 10;
149 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_INTERRUPT; // Target -> Host
150 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_COMMAND; // Host -> Target
152 htcConf.ControlDownLinkPipeID = HIF_USB_PIPE_RX;
153 htcConf.ControlUpLinkPipeID = HIF_USB_PIPE_TX;
155 htcConf.HIFHandle = hif_handle;
156 htcConf.OSHandle = 0; // not used
157 htcConf.PoolHandle = pool_handle;
159 htc_handle = HTC_init(htc_setup_comp, &htcConf);
160 // Initialize HTC services
161 HTC_Loopback_Init(htc_handle);
163 adf_os_mem_zero(&wmiConfig, sizeof(WMI_SVC_CONFIG));
164 wmiConfig.HtcHandle = htc_handle;
165 wmiConfig.PoolHandle = pool_handle;
166 wmiConfig.MaxCmdReplyEvts = 1;
167 wmiConfig.MaxEventEvts = 1;
169 wmi_handle = WMI_Init(&wmiConfig);
170 Magpie_Sys_Commands_Tbl.pContext = wmi_handle;
171 WMI_RegisterDispatchTable(Magpie_Sys_Commands_Tbl.pContext, &Magpie_Sys_Commands_Tbl);
173 #endif/* ZM_FM_LOOPBACK == 0 */
174 #endif /* MAGPIE_ENABLE_WLAN */
177 #endif /* #if MAGPIE==1 */
179 #endif /* #if defined(_RAM_) */