Setting up repository
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / rompatch / HIF_usb_patch.c
1 /*\r
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted (subject to the limitations in the\r
7  * disclaimer below) provided that the following conditions are met:\r
8  *\r
9  *  * Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  *  * Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the\r
15  *    distribution.\r
16  *\r
17  *  * Neither the name of Qualcomm Atheros nor the names of its\r
18  *    contributors may be used to endorse or promote products derived\r
19  *    from this software without specific prior written permission.\r
20  *\r
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE\r
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT\r
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED\r
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\r
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\r
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\r
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
34  */\r
35 #include "sys_cfg.h"\r
36 #include "dt_defs.h"\r
37 #include "reg_defs.h"\r
38 \r
39 #include <osapi.h>\r
40 #include <hif_api.h>\r
41 #include <Magpie_api.h>\r
42 #include <vdesc_api.h>\r
43 #include <adf_os_mem.h> \r
44 #include <adf_os_io.h>\r
45 \r
46 #include "hif_usb.h"\r
47 \r
48 /*\r
49  * -- support more than 64 bytes command on ep4 -- \r
50  */\r
51 int _HIFusb_get_max_msg_len_patch(hif_handle_t handle, int pipe)\r
52 {\r
53     switch(pipe) {\r
54         case HIF_USB_PIPE_INTERRUPT:\r
55         case HIF_USB_PIPE_COMMAND:\r
56             return 512;\r
57             \r
58         default:\r
59             return 1600;\r
60     }\r
61 }\r
62 \r
63 /*\r
64  * -- move the usb_task to here --\r
65  */\r
66 void _HIFusb_isr_handler_patch(hif_handle_t h)\r
67 {\r
68     A_USB_FW_TASK();\r
69 \r
70     _HIFusb_isr_handler();\r
71 }\r
72 \r
73 \r
74 /*\r
75  * -- reset usb dma --\r
76  *\r
77  * - make sure DMA_START bit0 is zero\r
78  * - update DMA_START bit4 to 1\r
79  * - update DESC_START_ADDR\r
80  * - update DMA_START bit 0\r
81  */\r
82 void _HIFusb_start_patch(hif_handle_t handle) \r
83 {\r
84     MAGPIE_REG_USB_TX0_DMA_START = 0x0;\r
85     MAGPIE_REG_USB_RX0_DMA_START = 0x0;\r
86     MAGPIE_REG_USB_RX1_DMA_START = 0x0;\r
87     MAGPIE_REG_USB_RX2_DMA_START = 0x0;\r
88     \r
89     while( 1 )\r
90     {\r
91         if(!MAGPIE_REG_USB_TX0_DMA_START &&\r
92            !MAGPIE_REG_USB_RX0_DMA_START &&\r
93            !MAGPIE_REG_USB_RX1_DMA_START &&\r
94            !MAGPIE_REG_USB_RX2_DMA_START )\r
95         {\r
96             MAGPIE_REG_USB_TX0_DMA_START = MAGPIE_REG_USB_TX0_DMA_START|BIT4; \r
97             MAGPIE_REG_USB_RX0_DMA_START = MAGPIE_REG_USB_RX0_DMA_START|BIT4;\r
98             MAGPIE_REG_USB_RX1_DMA_START = MAGPIE_REG_USB_RX1_DMA_START|BIT4;\r
99             MAGPIE_REG_USB_RX2_DMA_START = MAGPIE_REG_USB_RX2_DMA_START|BIT4;\r
100             break;\r
101         }\r
102     }\r
103     _HIFusb_start();\r
104 }\r