2011-10-05 13:19:03 +02: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-16 18: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-26 21:26:34 +02:00
struct brcmf_bus_dcmd {
char * name ;
char * param ;
int param_len ;
struct list_head list ;
} ;
2012-12-05 15:25:54 +01:00
/**
* struct brcmf_bus_ops - bus callback operations .
*
* @ init : prepare for communication with dongle .
* @ stop : clear pending frames , disable data flow .
* @ txdata : send a data frame to the dongle ( callee disposes skb ) .
* @ txctl : transmit a control request message to dongle .
* @ rxctl : receive a control response message from dongle .
*
* This structure provides an abstract interface towards the
* bus specific driver . For control messages to common driver
* will assure there is only one active transaction .
*/
struct brcmf_bus_ops {
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 ) ;
} ;
/**
* 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 .
* @ align : alignment requirement for the bus .
* @ dcmd_list : bus / device specific dongle initialization commands .
2013-02-06 18:40:45 +01:00
* @ chip : device identifier of the dongle chip .
* @ chiprev : revision of the dongle chip .
2012-12-05 15:25:54 +01:00
*/
2011-12-16 18:37:13 -08:00
struct brcmf_bus {
2012-02-09 21:09:02 +01:00
union {
struct brcmf_sdio_dev * sdio ;
2012-02-09 21:09:08 +01:00
struct brcmf_usbdev * usb ;
2012-02-09 21:09:02 +01:00
} bus_priv ;
2012-12-05 15:25:54 +01:00
struct device * dev ;
struct brcmf_pub * drvr ;
2011-12-16 18:37:13 -08:00
enum brcmf_bus_state state ;
2012-12-05 15:25:54 +01:00
uint maxctl ;
unsigned long tx_realloc ;
u8 align ;
2013-02-06 18:40:45 +01:00
u32 chip ;
u32 chiprev ;
2012-06-26 21:26:34 +02:00
struct list_head dcmd_list ;
2011-12-16 18:37:13 -08:00
2012-12-05 15:25:54 +01:00
struct brcmf_bus_ops * ops ;
2011-12-16 18:37:13 -08:00
} ;
2012-12-05 15:25:54 +01:00
/*
* callback wrappers
*/
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 ) ;
}
2011-12-16 18:37:13 -08:00
/*
* interface functions from common layer
*/
extern bool brcmf_c_prec_enq ( struct device * dev , struct pktq * q ,
struct sk_buff * pkt , int prec ) ;
/* Receive frame for delivery to OS. Callee disposes of rxp. */
2013-01-02 15:22:43 +01:00
extern void brcmf_rx_frames ( struct device * dev , struct sk_buff_head * rxlist ) ;
2011-12-16 18:37:13 -08:00
/* Indication from bus module regarding presence/insertion of dongle. */
extern int brcmf_attach ( uint bus_hdrlen , struct device * dev ) ;
/* Indication from bus module regarding removal/absence of dongle */
extern void brcmf_detach ( struct device * dev ) ;
2013-01-02 15:22:40 +01:00
/* Indication from bus module that dongle should be reset */
extern void brcmf_dev_reset ( struct device * dev ) ;
2011-12-16 18:37:13 -08:00
/* Indication from bus module to change flow-control state */
2012-09-11 21:18:46 +02:00
extern void brcmf_txflowblock ( struct device * dev , bool state ) ;
2011-12-16 18:37:13 -08:00
2013-03-03 12:45:29 +01:00
/* Notify the bus has transferred the tx packet to firmware */
2011-12-16 18:37:13 -08:00
extern void brcmf_txcomplete ( struct device * dev , struct sk_buff * txp ,
bool success ) ;
extern int brcmf_bus_start ( struct device * dev ) ;
2012-02-09 21:09:03 +01:00
# ifdef CONFIG_BRCMFMAC_SDIO
extern void brcmf_sdio_exit ( void ) ;
2012-03-02 22:55:48 +01:00
extern void brcmf_sdio_init ( void ) ;
2012-02-09 21:09:03 +01:00
# endif
2012-02-09 21:09:08 +01:00
# ifdef CONFIG_BRCMFMAC_USB
extern void brcmf_usb_exit ( void ) ;
2012-03-02 22:55:48 +01:00
extern void brcmf_usb_init ( void ) ;
2012-02-09 21:09:08 +01:00
# endif
2012-02-09 21:09:03 +01:00
2011-10-05 13:19:03 +02:00
# endif /* _BRCMF_BUS_H_ */