• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __OAL_SDIO_COMM_H__
20 #define __OAL_SDIO_COMM_H__
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif
27 
28 #undef CONFIG_SDIO_DEBUG
29 #define CONFIG_SDIO_FUNC_EXTEND
30 
31 #define CONFIG_SDIO_MSG_FLOWCTRL
32 #undef CONFIG_CREDIT_MSG_FLOW_CTRL_DEBUG
33 
34 #undef CONFIG_SDIO_REINIT_SUPPORT
35 
36 /* SDIO传输时,将所有的SG LIST 合并成一块完整的内存发送!
37    CONFIG_HISDIO_H2D_SCATT_LIST_ASSEMBLE在k3和3798平台打开,在3516 liteos和3516 linux关闭
38 */
39 /* 定义此宏表示打开arm to host 的消息回读ACK,
40   消息是从ARM发送至host,
41   必须读高字节才能产生ACK */
42 #define CONFIG_SDIO_D2H_MSG_ACK
43 
44 /* 定义此宏表示打开host to arm 的消息回读ACK,
45   消息是从Host发送至ARM,
46   必须读高字节才能产生ACK */
47 #undef CONFIG_SDIO_H2D_MSG_ACK
48 /* Device to host sdio message type */
49 typedef enum _sdio_d2h_msg_type_ {
50     D2H_MSG_WLAN_READY          = 0,
51     D2H_MSG_FLOWCTRL_UPDATE     = 1,    /* For the credit flow ctrl */
52     D2H_MSG_FLOWCTRL_OFF        = 2,    /* can't send data */
53     D2H_MSG_FLOWCTRL_ON         = 3,    /* can send data */
54     D2H_MSG_WAKEUP_SUCC         = 4,    /* Wakeup done */
55     D2H_MSG_ALLOW_SLEEP         = 5,    /* ALLOW Sleep */
56     D2H_MSG_DISALLOW_SLEEP      = 6,    /* DISALLOW Sleep */
57     D2H_MSG_DEVICE_PANIC        = 7,    /* arm abort */
58     D2H_MSG_POWEROFF_ACK        = 8,    /* Poweroff cmd ack */
59     D2H_MSG_OPEN_BCPU_ACK       = 9,    /* OPEN BCPU cmd ack */
60     D2H_MSG_CLOSE_BCPU_ACK      = 10,   /* CLOSE BCPU cmd ack */
61     D2H_MSG_CREDIT_UPDATE       = 11,   /* update high priority buffer credit value */
62     D2H_MSG_HIGH_PKT_LOSS       = 12,   /* high pri pkts loss count */
63     D2H_MSG_HALT_BCPU           = 13,   /* halt bcpu ack */
64     D2H_MSG_HEARTBEAT           = 14,   /* send heartbeat */
65 #ifdef _PRE_WLAN_FEATURE_WOW
66     D2H_MSG_WOW_WIFI_REDAY      = 15,   /* Device ready for Host sleep */
67 #endif
68     D2H_MSG_HOST_SLEEP_ACK      = 16,   /* host sleep ack */
69     D2H_MSG_BEFORE_DEV_SLEEP    = 17,   /* before device sleep msg */
70     D2H_MSG_DEV_WKUP            = 18,   /* device wkup msg */
71     D2H_MSG_HEART_BEAT_OPEN_ACK = 19,   /* open heart beat ack */
72     D2H_MSG_HEART_BEAT_CLOSE_ACK = 20,  /* close heart beat ack */
73 
74     D2H_MSG_COUNT               = 32    /* max support msg count */
75 } hi_sdio_d2h_msg_type_e;
76 
77 /* Host to device sdio message type */
78 typedef enum _sdio_h2d_msg_type_ {
79     H2D_MSG_FLOWCTRL_ON         = 0, /* can send data, force to open */
80     H2D_MSG_DEVICE_INFO_DUMP    = 1,
81     H2D_MSG_DEVICE_MEM_DUMP     = 2,
82     H2D_MSG_TEST                = 3,
83     H2D_MSG_PM_WLAN_OFF         = 4,
84     H2D_MSG_SLEEP_REQ           = 5,
85     H2D_MSG_PM_DEBUG            = 6,
86 
87     H2D_MSG_RESET_BCPU          = 7,
88     H2D_MSG_QUERY_RF_TEMP       = 8,
89 
90     H2D_MSG_HCC_SLAVE_THRUPUT_BYPASS = 9,
91     H2D_MSG_DEVICE_MEM_INFO          = 10,
92     H2D_MSG_STOP_SDIO_TEST      = 11,
93     H2D_MSG_PM_BCPU_OFF         = 12,
94 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION)
95     H2D_MSG_FORCESLP_REQ        = 13,
96 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION)
97     H2D_MSG_HALT_BCPU           = 13,
98 #endif
99 #ifdef _PRE_WLAN_FEATURE_WOW
100     H2D_MSG_WOW_WIFI_SUSPEND    = 14,
101     H2D_MSG_WOW_WIFI_RESUME     = 15,
102 #endif
103     H2D_MSG_HOST_SLEEP          = 16,
104     H2D_MSG_HOST_DISSLEEP       = 17,
105     H2D_MSG_HEART_BEAT_OPEN      = 18,
106     H2D_MSG_HEART_BEAT_CLOSE     = 19,
107 
108     H2D_MSG_COUNT               = 32 /* max support msg count */
109 } hi_sdio_h2d_msg_type_e;
110 
111 /* sdio flow control info, free cnt */
112 #define hisdio_short_pkt_set(reg, num)    do {(reg) = (((reg) & 0xFFFFFF00) | (((num) & 0xFF)));} while (0)
113 #define hisdio_large_pkt_set(reg, num)    do {(reg) = (((reg) & 0xFFFF00FF) | (((num) & 0xFF) << 8));} while (0)
114 #define hisdio_reserve_pkt_set(reg, num)  do {(reg) = (((reg) & 0xFF00FFFF) | (((num) & 0xFF) << 16));} while (0)
115 #define hisdio_comm_reg_seq_set(reg, num) do {(reg) = (((reg) & 0x00FFFFFF) | (((num) & 0xFF) << 24));} while (0)
116 
117 #define hisdio_short_pkt_get(reg)           ((reg) & 0xFF)
118 #define hisdio_large_pkt_get(reg)           (((reg) >> 8) & 0xFF)
119 #define hisdio_mgmt_pkt_get(reg)            (((reg) >> 16) & 0xFF)
120 #define hisdio_comm_reg_seq_pkt_get(reg)    (((reg) >> 24) & 0xFF)
121 
122 /* one size of data transfer block size, 64, 128, 256, 512, 1024 */
123 #define HISDIO_BLOCK_SIZE                   512
124 /* The max scatter buffers when host to device */
125 #define HISDIO_HOST2DEV_SCATT_MAX           64
126 #define HISDIO_HOST2DEV_SCATT_SIZE          64
127 
128 /* The max scatter buffers when device to host */
129 #define HISDIO_DEV2HOST_SCATT_MAX           64
130 #define HISDIO_DEV2HOST_SCATT_SIZE          64
131 
132 /* The max scatt num of rx and tx */
133 #define HISDIO_SCATT_MAX_NUM                HISDIO_DEV2HOST_SCATT_MAX
134 
135 /* 64B used to store the scatt info,1B means 1 pkt. */
136 #define HISDIO_H2D_SCATT_BUFFLEN_ALIGN_BITS 3
137 /* 1 << 5 */
138 /* Host to device's descr align length depends on the
139    CONFIG_HISDIO_H2D_SCATT_LIST_ASSEMBLE */
140 #ifdef CONFIG_HISDIO_H2D_SCATT_LIST_ASSEMBLE
141 #define HISDIO_H2D_SCATT_BUFFLEN_ALIGN      8
142 #else
143 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) // 为了保证liteos性能,长度设为8字节对齐
144 #define HISDIO_H2D_SCATT_BUFFLEN_ALIGN      8
145 #else
146 #define HISDIO_H2D_SCATT_BUFFLEN_ALIGN      32
147 #endif
148 #endif
149 
150 /* Device To Host,descr just request 4 bytes aligned,
151   but 10 bits round [0~1023], so we also aligned to 32 bytes */
152 #define HISDIO_D2H_SCATT_BUFFLEN_ALIGN_BITS 5
153 /* 1 << 5 */
154 #define HISDIO_D2H_SCATT_BUFFLEN_ALIGN      512
155 
156 #define HSDIO_HOST2DEV_PKTS_MAX_LEN         1544
157 #ifdef __cplusplus
158 #if __cplusplus
159 }
160 #endif
161 #endif
162 
163 #endif
164 
165