| 
									
										
										
										
											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_
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-13 22:20:29 +01:00
										 |  |  | #include "dhd_dbg.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | /* The level of bus communication with the dongle */ | 
					
						
							|  |  |  | enum brcmf_bus_state { | 
					
						
							| 
									
										
										
										
											2014-01-13 22:20:29 +01:00
										 |  |  | 	BRCMF_BUS_UNKNOWN,	/* Not determined yet */ | 
					
						
							|  |  |  | 	BRCMF_BUS_NOMEDIUM,	/* No medium access to dongle */ | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | 	BRCMF_BUS_DOWN,		/* Not ready for frame transfers */ | 
					
						
							|  |  |  | 	BRCMF_BUS_LOAD,		/* Download access only (CPU reset) */ | 
					
						
							|  |  |  | 	BRCMF_BUS_DATA		/* Ready for frame transfers */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-12 11:59:02 +01:00
										 |  |  | /* The level of bus communication with the dongle */ | 
					
						
							|  |  |  | enum brcmf_bus_protocol_type { | 
					
						
							|  |  |  | 	BRCMF_PROTO_BCDC, | 
					
						
							|  |  |  | 	BRCMF_PROTO_MSGBUF | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:15 +01:00
										 |  |  |  * @preinit: execute bus/device specific dongle init commands (optional). | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01:00
										 |  |  |  * @init: prepare for communication with dongle. | 
					
						
							|  |  |  |  * @stop: clear pending frames, disable data flow. | 
					
						
							| 
									
										
										
										
											2013-08-10 12:27:19 +02: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 15:25:54 +01:00
										 |  |  |  * @txctl: transmit a control request message to dongle. | 
					
						
							|  |  |  |  * @rxctl: receive a control response message from dongle. | 
					
						
							| 
									
										
										
										
											2013-04-03 12:40:38 +02:00
										 |  |  |  * @gettxq: obtain a reference of bus transmit queue (optional). | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This structure provides an abstract interface towards the | 
					
						
							|  |  |  |  * bus specific driver. For control messages to common driver | 
					
						
							| 
									
										
										
										
											2013-04-03 12:40:38 +02:00
										 |  |  |  * will assure there is only one active transaction. Unless | 
					
						
							|  |  |  |  * indicated otherwise these callbacks are mandatory. | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | struct brcmf_bus_ops { | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:15 +01:00
										 |  |  | 	int (*preinit)(struct device *dev); | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01: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 12:40:38 +02:00
										 |  |  | 	struct pktq * (*gettxq)(struct device *dev); | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * struct brcmf_bus - interface structure between common and bus layer | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @bus_priv: pointer to private bus device. | 
					
						
							| 
									
										
										
										
											2013-12-12 11:59:02 +01:00
										 |  |  |  * @proto_type: protocol type, bcdc or msgbuf | 
					
						
							| 
									
										
										
										
											2012-12-05 15:25:54 +01: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-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; | 
					
						
							| 
									
										
										
										
											2013-12-12 11:59:02 +01:00
										 |  |  | 	enum brcmf_bus_protocol_type proto_type; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2013-02-06 18:40:45 +01:00
										 |  |  | 	u32 chip; | 
					
						
							|  |  |  | 	u32 chiprev; | 
					
						
							| 
									
										
										
										
											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 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:15 +01: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 15:25:54 +01: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 12:40:38 +02: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-13 22:20:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static inline bool brcmf_bus_ready(struct brcmf_bus *bus) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return bus->state == BRCMF_BUS_LOAD || bus->state == BRCMF_BUS_DATA; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void brcmf_bus_change_state(struct brcmf_bus *bus, | 
					
						
							|  |  |  | 					  enum brcmf_bus_state new_state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* NOMEDIUM is permanent */ | 
					
						
							|  |  |  | 	if (bus->state == BRCMF_BUS_NOMEDIUM) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	brcmf_dbg(TRACE, "%d -> %d\n", bus->state, new_state); | 
					
						
							|  |  |  | 	bus->state = new_state; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * interface functions from common layer | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt, | 
					
						
							|  |  |  | 		      int prec); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Receive frame for delivery to OS.  Callee disposes of rxp. */ | 
					
						
							| 
									
										
										
										
											2013-10-07 15:40:44 -04:00
										 |  |  | void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Indication from bus module regarding presence/insertion of dongle. */ | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:14 +01:00
										 |  |  | int brcmf_attach(struct device *dev); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | /* Indication from bus module regarding removal/absence of dongle */ | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | void brcmf_detach(struct device *dev); | 
					
						
							| 
									
										
										
										
											2013-01-02 15:22:40 +01:00
										 |  |  | /* Indication from bus module that dongle should be reset */ | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | void brcmf_dev_reset(struct device *dev); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | /* Indication from bus module to change flow-control state */ | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | 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 */ | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | int brcmf_bus_start(struct device *dev); | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:15 +01:00
										 |  |  | s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, | 
					
						
							|  |  |  | 				u32 len); | 
					
						
							| 
									
										
										
										
											2013-11-29 11:48:14 +01:00
										 |  |  | void brcmf_bus_add_txhdrlen(struct device *dev, uint len); | 
					
						
							| 
									
										
										
										
											2011-12-16 18:37:13 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-09 21:09:03 +01:00
										 |  |  | #ifdef CONFIG_BRCMFMAC_SDIO
 | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | void brcmf_sdio_exit(void); | 
					
						
							|  |  |  | void brcmf_sdio_init(void); | 
					
						
							| 
									
										
										
										
											2013-10-01 17:06:14 -04:00
										 |  |  | void brcmf_sdio_register(void); | 
					
						
							| 
									
										
										
										
											2012-02-09 21:09:03 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-02-09 21:09:08 +01:00
										 |  |  | #ifdef CONFIG_BRCMFMAC_USB
 | 
					
						
							| 
									
										
										
										
											2013-09-23 11:37:59 -07:00
										 |  |  | void brcmf_usb_exit(void); | 
					
						
							| 
									
										
										
										
											2013-10-01 17:06:14 -04:00
										 |  |  | void brcmf_usb_register(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_ */
 |