2011-10-05 19:19:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010 Broadcom Corporation
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2014-10-28 21:56:14 +08:00
|
|
|
#ifndef BRCMFMAC_BUS_H
|
|
|
|
#define BRCMFMAC_BUS_H
|
2011-10-05 19:19:03 +08:00
|
|
|
|
2014-10-28 21:56:13 +08:00
|
|
|
#include "debug.h"
|
2014-01-14 05:20:29 +08:00
|
|
|
|
2014-07-30 19:20:03 +08:00
|
|
|
/* IDs of the 6 default common rings of msgbuf protocol */
|
|
|
|
#define BRCMF_H2D_MSGRING_CONTROL_SUBMIT 0
|
|
|
|
#define BRCMF_H2D_MSGRING_RXPOST_SUBMIT 1
|
|
|
|
#define BRCMF_D2H_MSGRING_CONTROL_COMPLETE 2
|
|
|
|
#define BRCMF_D2H_MSGRING_TX_COMPLETE 3
|
|
|
|
#define BRCMF_D2H_MSGRING_RX_COMPLETE 4
|
|
|
|
|
|
|
|
#define BRCMF_NROF_H2D_COMMON_MSGRINGS 2
|
|
|
|
#define BRCMF_NROF_D2H_COMMON_MSGRINGS 3
|
|
|
|
#define BRCMF_NROF_COMMON_MSGRINGS (BRCMF_NROF_H2D_COMMON_MSGRINGS + \
|
|
|
|
BRCMF_NROF_D2H_COMMON_MSGRINGS)
|
|
|
|
|
2011-12-17 10:37:13 +08:00
|
|
|
/* The level of bus communication with the dongle */
|
|
|
|
enum brcmf_bus_state {
|
|
|
|
BRCMF_BUS_DOWN, /* Not ready for frame transfers */
|
2015-01-26 03:31:35 +08:00
|
|
|
BRCMF_BUS_UP /* Ready for frame transfers */
|
2011-12-17 10:37:13 +08:00
|
|
|
};
|
|
|
|
|
2013-12-12 18:59:02 +08:00
|
|
|
/* The level of bus communication with the dongle */
|
|
|
|
enum brcmf_bus_protocol_type {
|
|
|
|
BRCMF_PROTO_BCDC,
|
|
|
|
BRCMF_PROTO_MSGBUF
|
|
|
|
};
|
|
|
|
|
2012-06-27 03:26:34 +08:00
|
|
|
struct brcmf_bus_dcmd {
|
|
|
|
char *name;
|
|
|
|
char *param;
|
|
|
|
int param_len;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
/**
|
|
|
|
* struct brcmf_bus_ops - bus callback operations.
|
|
|
|
*
|
2013-11-29 18:48:15 +08:00
|
|
|
* @preinit: execute bus/device specific dongle init commands (optional).
|
2012-12-05 22:25:54 +08:00
|
|
|
* @init: prepare for communication with dongle.
|
|
|
|
* @stop: clear pending frames, disable data flow.
|
2013-08-10 18:27:19 +08:00
|
|
|
* @txdata: send a data frame to the dongle. When the data
|
|
|
|
* has been transferred, the common driver must be
|
|
|
|
* notified using brcmf_txcomplete(). The common
|
|
|
|
* driver calls this function with interrupts
|
|
|
|
* disabled.
|
2012-12-05 22:25:54 +08:00
|
|
|
* @txctl: transmit a control request message to dongle.
|
|
|
|
* @rxctl: receive a control response message from dongle.
|
2013-04-03 18:40:38 +08:00
|
|
|
* @gettxq: obtain a reference of bus transmit queue (optional).
|
2014-09-30 16:23:18 +08:00
|
|
|
* @wowl_config: specify if dongle is configured for wowl when going to suspend
|
2012-12-05 22:25:54 +08:00
|
|
|
*
|
|
|
|
* This structure provides an abstract interface towards the
|
|
|
|
* bus specific driver. For control messages to common driver
|
2013-04-03 18:40:38 +08:00
|
|
|
* will assure there is only one active transaction. Unless
|
|
|
|
* indicated otherwise these callbacks are mandatory.
|
2012-12-05 22:25:54 +08:00
|
|
|
*/
|
|
|
|
struct brcmf_bus_ops {
|
2013-11-29 18:48:15 +08:00
|
|
|
int (*preinit)(struct device *dev);
|
2012-12-05 22:25:54 +08:00
|
|
|
void (*stop)(struct device *dev);
|
|
|
|
int (*txdata)(struct device *dev, struct sk_buff *skb);
|
|
|
|
int (*txctl)(struct device *dev, unsigned char *msg, uint len);
|
|
|
|
int (*rxctl)(struct device *dev, unsigned char *msg, uint len);
|
2013-04-03 18:40:38 +08:00
|
|
|
struct pktq * (*gettxq)(struct device *dev);
|
2014-09-30 16:23:18 +08:00
|
|
|
void (*wowl_config)(struct device *dev, bool enabled);
|
2012-12-05 22:25:54 +08:00
|
|
|
};
|
|
|
|
|
2014-07-30 19:20:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct brcmf_bus_msgbuf - bus ringbuf if in case of msgbuf.
|
|
|
|
*
|
|
|
|
* @commonrings: commonrings which are always there.
|
|
|
|
* @flowrings: commonrings which are dynamically created and destroyed for data.
|
|
|
|
* @rx_dataoffset: if set then all rx data has this this offset.
|
|
|
|
* @max_rxbufpost: maximum number of buffers to post for rx.
|
|
|
|
* @nrof_flowrings: number of flowrings.
|
|
|
|
*/
|
|
|
|
struct brcmf_bus_msgbuf {
|
|
|
|
struct brcmf_commonring *commonrings[BRCMF_NROF_COMMON_MSGRINGS];
|
|
|
|
struct brcmf_commonring **flowrings;
|
|
|
|
u32 rx_dataoffset;
|
|
|
|
u32 max_rxbufpost;
|
|
|
|
u32 nrof_flowrings;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
/**
|
|
|
|
* struct brcmf_bus - interface structure between common and bus layer
|
|
|
|
*
|
|
|
|
* @bus_priv: pointer to private bus device.
|
2013-12-12 18:59:02 +08:00
|
|
|
* @proto_type: protocol type, bcdc or msgbuf
|
2012-12-05 22:25:54 +08:00
|
|
|
* @dev: device pointer of bus device.
|
|
|
|
* @drvr: public driver information.
|
|
|
|
* @state: operational state of the bus interface.
|
|
|
|
* @maxctl: maximum size for rxctl request message.
|
|
|
|
* @tx_realloc: number of tx packets realloced for headroom.
|
|
|
|
* @dstats: dongle-based statistical data.
|
|
|
|
* @dcmd_list: bus/device specific dongle initialization commands.
|
2013-02-07 01:40:45 +08:00
|
|
|
* @chip: device identifier of the dongle chip.
|
2014-09-30 16:23:18 +08:00
|
|
|
* @wowl_supported: is wowl supported by bus driver.
|
2013-02-07 01:40:45 +08:00
|
|
|
* @chiprev: revision of the dongle chip.
|
2012-12-05 22:25:54 +08:00
|
|
|
*/
|
2011-12-17 10:37:13 +08:00
|
|
|
struct brcmf_bus {
|
2012-02-10 04:09:02 +08:00
|
|
|
union {
|
|
|
|
struct brcmf_sdio_dev *sdio;
|
2012-02-10 04:09:08 +08:00
|
|
|
struct brcmf_usbdev *usb;
|
2014-07-30 19:20:04 +08:00
|
|
|
struct brcmf_pciedev *pcie;
|
2012-02-10 04:09:02 +08:00
|
|
|
} bus_priv;
|
2013-12-12 18:59:02 +08:00
|
|
|
enum brcmf_bus_protocol_type proto_type;
|
2012-12-05 22:25:54 +08:00
|
|
|
struct device *dev;
|
|
|
|
struct brcmf_pub *drvr;
|
2011-12-17 10:37:13 +08:00
|
|
|
enum brcmf_bus_state state;
|
2012-12-05 22:25:54 +08:00
|
|
|
uint maxctl;
|
|
|
|
unsigned long tx_realloc;
|
2013-02-07 01:40:45 +08:00
|
|
|
u32 chip;
|
|
|
|
u32 chiprev;
|
2014-05-12 16:47:30 +08:00
|
|
|
bool always_use_fws_queue;
|
2014-09-30 16:23:18 +08:00
|
|
|
bool wowl_supported;
|
2011-12-17 10:37:13 +08:00
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
struct brcmf_bus_ops *ops;
|
2014-07-30 19:20:03 +08:00
|
|
|
struct brcmf_bus_msgbuf *msgbuf;
|
2011-12-17 10:37:13 +08:00
|
|
|
};
|
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
/*
|
|
|
|
* callback wrappers
|
|
|
|
*/
|
2013-11-29 18:48:15 +08:00
|
|
|
static inline int brcmf_bus_preinit(struct brcmf_bus *bus)
|
|
|
|
{
|
|
|
|
if (!bus->ops->preinit)
|
|
|
|
return 0;
|
|
|
|
return bus->ops->preinit(bus->dev);
|
|
|
|
}
|
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
static inline void brcmf_bus_stop(struct brcmf_bus *bus)
|
|
|
|
{
|
|
|
|
bus->ops->stop(bus->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return bus->ops->txdata(bus->dev, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
|
|
|
|
{
|
|
|
|
return bus->ops->txctl(bus->dev, msg, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
|
|
|
|
{
|
|
|
|
return bus->ops->rxctl(bus->dev, msg, len);
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:40:38 +08:00
|
|
|
static inline
|
|
|
|
struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus)
|
|
|
|
{
|
|
|
|
if (!bus->ops->gettxq)
|
|
|
|
return ERR_PTR(-ENOENT);
|
|
|
|
|
|
|
|
return bus->ops->gettxq(bus->dev);
|
|
|
|
}
|
2014-01-14 05:20:29 +08:00
|
|
|
|
2014-09-30 16:23:18 +08:00
|
|
|
static inline
|
|
|
|
void brcmf_bus_wowl_config(struct brcmf_bus *bus, bool enabled)
|
|
|
|
{
|
|
|
|
if (bus->ops->wowl_config)
|
|
|
|
bus->ops->wowl_config(bus->dev, enabled);
|
|
|
|
}
|
|
|
|
|
2011-12-17 10:37:13 +08:00
|
|
|
/*
|
|
|
|
* interface functions from common layer
|
|
|
|
*/
|
|
|
|
|
2013-09-24 02:37:59 +08:00
|
|
|
bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt,
|
|
|
|
int prec);
|
2011-12-17 10:37:13 +08:00
|
|
|
|
|
|
|
/* Receive frame for delivery to OS. Callee disposes of rxp. */
|
2013-10-08 03:40:44 +08:00
|
|
|
void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp);
|
2011-12-17 10:37:13 +08:00
|
|
|
|
|
|
|
/* Indication from bus module regarding presence/insertion of dongle. */
|
2013-11-29 18:48:14 +08:00
|
|
|
int brcmf_attach(struct device *dev);
|
2011-12-17 10:37:13 +08:00
|
|
|
/* Indication from bus module regarding removal/absence of dongle */
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_detach(struct device *dev);
|
2013-01-02 22:22:40 +08:00
|
|
|
/* Indication from bus module that dongle should be reset */
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_dev_reset(struct device *dev);
|
2011-12-17 10:37:13 +08:00
|
|
|
/* Indication from bus module to change flow-control state */
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_txflowblock(struct device *dev, bool state);
|
2011-12-17 10:37:13 +08:00
|
|
|
|
2013-03-03 19:45:29 +08:00
|
|
|
/* Notify the bus has transferred the tx packet to firmware */
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
|
2011-12-17 10:37:13 +08:00
|
|
|
|
2015-01-26 03:31:36 +08:00
|
|
|
/* Configure the "global" bus state used by upper layers */
|
|
|
|
void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
|
|
|
|
|
2013-09-24 02:37:59 +08:00
|
|
|
int brcmf_bus_start(struct device *dev);
|
2014-10-28 21:56:14 +08:00
|
|
|
s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len);
|
2013-11-29 18:48:14 +08:00
|
|
|
void brcmf_bus_add_txhdrlen(struct device *dev, uint len);
|
2011-12-17 10:37:13 +08:00
|
|
|
|
2012-02-10 04:09:03 +08:00
|
|
|
#ifdef CONFIG_BRCMFMAC_SDIO
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_sdio_exit(void);
|
|
|
|
void brcmf_sdio_init(void);
|
2013-10-02 05:06:14 +08:00
|
|
|
void brcmf_sdio_register(void);
|
2012-02-10 04:09:03 +08:00
|
|
|
#endif
|
2012-02-10 04:09:08 +08:00
|
|
|
#ifdef CONFIG_BRCMFMAC_USB
|
2013-09-24 02:37:59 +08:00
|
|
|
void brcmf_usb_exit(void);
|
2013-10-02 05:06:14 +08:00
|
|
|
void brcmf_usb_register(void);
|
2012-02-10 04:09:08 +08:00
|
|
|
#endif
|
2012-02-10 04:09:03 +08:00
|
|
|
|
2014-10-28 21:56:14 +08:00
|
|
|
#endif /* BRCMFMAC_BUS_H */
|