Merge tag 'lsk-v4.4-16.06-android'
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rkwifi / bcmdhd / dhd_bus.h
1 /*
2  * Header file describing the internal (inter-module) DHD interfaces.
3  *
4  * Provides type definitions and function prototypes used to link the
5  * DHD OS, bus, and protocol modules.
6  *
7  * Copyright (C) 1999-2016, Broadcom Corporation
8  * 
9  *      Unless you and Broadcom execute a separate written software license
10  * agreement governing use of this software, this software is licensed to you
11  * under the terms of the GNU General Public License version 2 (the "GPL"),
12  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13  * following added to such license:
14  * 
15  *      As a special exception, the copyright holders of this software give you
16  * permission to link this software with independent modules, and to copy and
17  * distribute the resulting executable under terms of your choice, provided that
18  * you also meet, for each linked independent module, the terms and conditions of
19  * the license of that module.  An independent module is a module which is not
20  * derived from this software.  The special exception does not apply to any
21  * modifications of the software.
22  * 
23  *      Notwithstanding the above, under no circumstances may you combine this
24  * software in any way with any other Broadcom software provided under a license
25  * other than the GPL, without Broadcom's express prior written consent.
26  *
27  *
28  * <<Broadcom-WL-IPTag/Open:>>
29  *
30  * $Id: dhd_bus.h 602721 2015-11-27 10:32:48Z $
31  */
32
33 #ifndef _dhd_bus_h_
34 #define _dhd_bus_h_
35
36 /*
37  * Exported from dhd bus module (dhd_usb, dhd_sdio)
38  */
39
40 /* Indicate (dis)interest in finding dongles. */
41 extern int dhd_bus_register(void);
42 extern void dhd_bus_unregister(void);
43
44 /* Download firmware image and nvram image */
45 extern int dhd_bus_download_firmware(struct dhd_bus *bus, osl_t *osh,
46         char *fw_path, char *nv_path, char *conf_path);
47
48 /* Stop bus module: clear pending frames, disable data flow */
49 extern void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex);
50
51 /* Initialize bus module: prepare for communication w/dongle */
52 extern int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex);
53
54 /* Get the Bus Idle Time */
55 extern void dhd_bus_getidletime(dhd_pub_t *dhdp, int *idletime);
56
57 /* Set the Bus Idle Time */
58 extern void dhd_bus_setidletime(dhd_pub_t *dhdp, int idle_time);
59
60 /* Send a data frame to the dongle.  Callee disposes of txp. */
61 #ifdef BCMPCIE
62 extern int dhd_bus_txdata(struct dhd_bus *bus, void *txp, uint8 ifidx);
63 #else
64 extern int dhd_bus_txdata(struct dhd_bus *bus, void *txp);
65 #endif
66
67
68 /* Send/receive a control message to/from the dongle.
69  * Expects caller to enforce a single outstanding transaction.
70  */
71 extern int dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen);
72 extern int dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen);
73
74 /* Watchdog timer function */
75 extern bool dhd_bus_watchdog(dhd_pub_t *dhd);
76
77 extern int dhd_bus_oob_intr_register(dhd_pub_t *dhdp);
78 extern void dhd_bus_oob_intr_unregister(dhd_pub_t *dhdp);
79 extern void dhd_bus_oob_intr_set(dhd_pub_t *dhdp, bool enable);
80 extern void dhd_bus_dev_pm_stay_awake(dhd_pub_t *dhdpub);
81 extern void dhd_bus_dev_pm_relax(dhd_pub_t *dhdpub);
82 extern bool dhd_bus_dev_pm_enabled(dhd_pub_t *dhdpub);
83
84 #if defined(DHD_DEBUG)
85 /* Device console input function */
86 extern int dhd_bus_console_in(dhd_pub_t *dhd, uchar *msg, uint msglen);
87 #endif /* defined(DHD_DEBUG) */
88
89 /* Deferred processing for the bus, return TRUE requests reschedule */
90 extern bool dhd_bus_dpc(struct dhd_bus *bus);
91 extern void dhd_bus_isr(bool * InterruptRecognized, bool * QueueMiniportHandleInterrupt, void *arg);
92
93
94 /* Check for and handle local prot-specific iovar commands */
95 extern int dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
96                             void *params, int plen, void *arg, int len, bool set);
97
98 /* Add bus dump output to a buffer */
99 extern void dhd_bus_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
100
101 /* Clear any bus counters */
102 extern void dhd_bus_clearcounts(dhd_pub_t *dhdp);
103
104 /* return the dongle chipid */
105 extern uint dhd_bus_chip(struct dhd_bus *bus);
106
107 /* return the dongle chiprev */
108 extern uint dhd_bus_chiprev(struct dhd_bus *bus);
109
110 /* Set user-specified nvram parameters. */
111 extern void dhd_bus_set_nvram_params(struct dhd_bus * bus, const char *nvram_params);
112
113 extern void *dhd_bus_pub(struct dhd_bus *bus);
114 extern void *dhd_bus_txq(struct dhd_bus *bus);
115 extern void *dhd_bus_sih(struct dhd_bus *bus);
116 extern uint dhd_bus_hdrlen(struct dhd_bus *bus);
117 #ifdef BCMSDIO
118 extern void dhd_bus_set_dotxinrx(struct dhd_bus *bus, bool val);
119 /* return sdio io status */
120 extern uint8 dhd_bus_is_ioready(struct dhd_bus *bus);
121 #else
122 #define dhd_bus_set_dotxinrx(a, b) do {} while (0)
123 #endif
124
125 #define DHD_SET_BUS_STATE_DOWN(_bus)  do { \
126         (_bus)->dhd->busstate = DHD_BUS_DOWN; \
127 } while (0)
128
129 /* Register a dummy SDIO client driver in order to be notified of new SDIO device */
130 extern int dhd_bus_reg_sdio_notify(void* semaphore);
131 extern void dhd_bus_unreg_sdio_notify(void);
132 extern void dhd_txglom_enable(dhd_pub_t *dhdp, bool enable);
133 extern int dhd_bus_get_ids(struct dhd_bus *bus, uint32 *bus_type, uint32 *bus_num,
134         uint32 *slot_num);
135
136 #ifdef BCMPCIE
137 enum {
138         /* Scratch buffer confiuguration update */
139         D2H_DMA_SCRATCH_BUF,
140         D2H_DMA_SCRATCH_BUF_LEN,
141
142         /* DMA Indices array buffers for: H2D WR and RD, and D2H WR and RD */
143         H2D_DMA_INDX_WR_BUF, /* update H2D WR dma indices buf base addr to dongle */
144         H2D_DMA_INDX_RD_BUF, /* update H2D RD dma indices buf base addr to dongle */
145         D2H_DMA_INDX_WR_BUF, /* update D2H WR dma indices buf base addr to dongle */
146         D2H_DMA_INDX_RD_BUF, /* update D2H RD dma indices buf base addr to dongle */
147
148         /* DHD sets/gets WR or RD index, in host's H2D and D2H DMA indices buffer */
149         H2D_DMA_INDX_WR_UPD, /* update H2D WR index in H2D WR dma indices buf */
150         H2D_DMA_INDX_RD_UPD, /* update H2D RD index in H2D RD dma indices buf */
151         D2H_DMA_INDX_WR_UPD, /* update D2H WR index in D2H WR dma indices buf */
152         D2H_DMA_INDX_RD_UPD, /* update D2H RD index in D2H RD dma indices buf */
153
154         /* H2D and D2H Mailbox data update */
155         H2D_MB_DATA,
156         D2H_MB_DATA,
157
158         /* (Common) MsgBuf Ring configuration update */
159         RING_BUF_ADDR,       /* update ring base address to dongle */
160         RING_ITEM_LEN,       /* update ring item size to dongle */
161         RING_MAX_ITEMS,      /* update ring max items to dongle */
162
163         /* Update of WR or RD index, for a MsgBuf Ring */
164         RING_RD_UPD,         /* update ring read index from/to dongle */
165         RING_WR_UPD,         /* update ring write index from/to dongle */
166
167         TOTAL_LFRAG_PACKET_CNT,
168         MAX_HOST_RXBUFS
169 };
170
171 typedef void (*dhd_mb_ring_t) (struct dhd_bus *, uint32);
172 extern void dhd_bus_cmn_writeshared(struct dhd_bus *bus, void * data, uint32 len, uint8 type,
173         uint16 ringid);
174 extern void dhd_bus_ringbell(struct dhd_bus *bus, uint32 value);
175 extern void dhd_bus_cmn_readshared(struct dhd_bus *bus, void* data, uint8 type, uint16 ringid);
176 extern uint32 dhd_bus_get_sharedflags(struct dhd_bus *bus);
177 extern void dhd_bus_rx_frame(struct dhd_bus *bus, void* pkt, int ifidx, uint pkt_count);
178 extern void dhd_bus_start_queue(struct dhd_bus *bus);
179 extern void dhd_bus_stop_queue(struct dhd_bus *bus);
180
181 extern dhd_mb_ring_t dhd_bus_get_mbintr_fn(struct dhd_bus *bus);
182 extern void dhd_bus_write_flow_ring_states(struct dhd_bus *bus,
183         void * data, uint16 flowid);
184 extern void dhd_bus_read_flow_ring_states(struct dhd_bus *bus,
185         void * data, uint8 flowid);
186 extern int dhd_bus_flow_ring_create_request(struct dhd_bus *bus, void *flow_ring_node);
187 extern void dhd_bus_clean_flow_ring(struct dhd_bus *bus, void *flow_ring_node);
188 extern void dhd_bus_flow_ring_create_response(struct dhd_bus *bus, uint16 flow_id, int32 status);
189 extern int dhd_bus_flow_ring_delete_request(struct dhd_bus *bus, void *flow_ring_node);
190 extern void dhd_bus_flow_ring_delete_response(struct dhd_bus *bus, uint16 flowid, uint32 status);
191 extern int dhd_bus_flow_ring_flush_request(struct dhd_bus *bus, void *flow_ring_node);
192 extern void dhd_bus_flow_ring_flush_response(struct dhd_bus *bus, uint16 flowid, uint32 status);
193 extern uint32 dhd_bus_max_h2d_queues(struct dhd_bus *bus);
194 extern int dhd_bus_schedule_queue(struct dhd_bus *bus, uint16 flow_id, bool txs);
195 extern void dhd_bus_set_linkdown(dhd_pub_t *dhdp, bool val);
196
197
198 extern int dhdpcie_bus_clock_start(struct dhd_bus *bus);
199 extern int dhdpcie_bus_clock_stop(struct dhd_bus *bus);
200 extern int dhdpcie_bus_enable_device(struct dhd_bus *bus);
201 extern int dhdpcie_bus_disable_device(struct dhd_bus *bus);
202 extern int dhdpcie_bus_alloc_resource(struct dhd_bus *bus);
203 extern void dhdpcie_bus_free_resource(struct dhd_bus *bus);
204 extern bool dhdpcie_bus_dongle_attach(struct dhd_bus *bus);
205 extern int dhd_bus_release_dongle(struct dhd_bus *bus);
206 extern int dhd_bus_request_irq(struct dhd_bus *bus);
207
208
209 #ifdef DHD_FW_COREDUMP
210 extern int dhd_bus_mem_dump(dhd_pub_t *dhd);
211 #endif /* DHD_FW_COREDUMP */
212
213 #endif /* BCMPCIE */
214 #endif /* _dhd_bus_h_ */