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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BRCMF_BUS_H_
|
|
|
|
#define _BRCMF_BUS_H_
|
|
|
|
|
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 */
|
|
|
|
BRCMF_BUS_LOAD, /* Download access only (CPU reset) */
|
|
|
|
BRCMF_BUS_DATA /* Ready for frame transfers */
|
|
|
|
};
|
|
|
|
|
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).
|
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
|
|
|
int (*init)(struct device *dev);
|
|
|
|
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);
|
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.
|
|
|
|
* @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.
|
|
|
|
* @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;
|
2012-02-10 04:09:02 +08:00
|
|
|
} bus_priv;
|
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;
|
2011-12-17 10:37:13 +08:00
|
|
|
|
2012-12-05 22:25:54 +08:00
|
|
|
struct brcmf_bus_ops *ops;
|
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 int brcmf_bus_init(struct brcmf_bus *bus)
|
|
|
|
{
|
|
|
|
return bus->ops->init(bus->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
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
|
|
|
|
2013-09-24 02:37:59 +08:00
|
|
|
int brcmf_bus_start(struct device *dev);
|
2013-11-29 18:48:15 +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
|
|
|
|
2011-10-05 19:19:03 +08:00
|
|
|
#endif /* _BRCMF_BUS_H_ */
|