2 * Header file describing the internal (inter-module) DHD interfaces.
4 * Provides type definitions and function prototypes used to link the
5 * DHD OS, bus, and protocol modules.
7 * Copyright (C) 1999-2016, Broadcom Corporation
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:
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.
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.
28 * <<Broadcom-WL-IPTag/Open:>>
30 * $Id: dhd_bus.h 602721 2015-11-27 10:32:48Z $
37 * Exported from dhd bus module (dhd_usb, dhd_sdio)
40 /* Indicate (dis)interest in finding dongles. */
41 extern int dhd_bus_register(void);
42 extern void dhd_bus_unregister(void);
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);
48 /* Stop bus module: clear pending frames, disable data flow */
49 extern void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex);
51 /* Initialize bus module: prepare for communication w/dongle */
52 extern int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex);
54 /* Get the Bus Idle Time */
55 extern void dhd_bus_getidletime(dhd_pub_t *dhdp, int *idletime);
57 /* Set the Bus Idle Time */
58 extern void dhd_bus_setidletime(dhd_pub_t *dhdp, int idle_time);
60 /* Send a data frame to the dongle. Callee disposes of txp. */
62 extern int dhd_bus_txdata(struct dhd_bus *bus, void *txp, uint8 ifidx);
64 extern int dhd_bus_txdata(struct dhd_bus *bus, void *txp);
68 /* Send/receive a control message to/from the dongle.
69 * Expects caller to enforce a single outstanding transaction.
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);
74 /* Watchdog timer function */
75 extern bool dhd_bus_watchdog(dhd_pub_t *dhd);
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);
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) */
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);
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);
98 /* Add bus dump output to a buffer */
99 extern void dhd_bus_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
101 /* Clear any bus counters */
102 extern void dhd_bus_clearcounts(dhd_pub_t *dhdp);
104 /* return the dongle chipid */
105 extern uint dhd_bus_chip(struct dhd_bus *bus);
107 /* return the dongle chiprev */
108 extern uint dhd_bus_chiprev(struct dhd_bus *bus);
110 /* Set user-specified nvram parameters. */
111 extern void dhd_bus_set_nvram_params(struct dhd_bus * bus, const char *nvram_params);
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);
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);
122 #define dhd_bus_set_dotxinrx(a, b) do {} while (0)
125 #define DHD_SET_BUS_STATE_DOWN(_bus) do { \
126 (_bus)->dhd->busstate = DHD_BUS_DOWN; \
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,
138 /* Scratch buffer confiuguration update */
140 D2H_DMA_SCRATCH_BUF_LEN,
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 */
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 */
154 /* H2D and D2H Mailbox data update */
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 */
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 */
167 TOTAL_LFRAG_PACKET_CNT,
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,
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);
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);
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);
209 #ifdef DHD_FW_COREDUMP
210 extern int dhd_bus_mem_dump(dhd_pub_t *dhd);
211 #endif /* DHD_FW_COREDUMP */
214 #endif /* _dhd_bus_h_ */