2009-06-02 15:29:35 -06:00
|
|
|
/*
|
|
|
|
* Marvell Bluetooth driver: global definitions & declarations
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, Marvell International Ltd.
|
|
|
|
*
|
|
|
|
* This software file (the "File") is distributed by Marvell International
|
|
|
|
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
|
|
|
|
* (the "License"). You may use, redistribute and/or modify this File in
|
|
|
|
* accordance with the terms and conditions of the License, a copy of which
|
|
|
|
* is available by writing to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
|
|
|
|
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
|
|
|
|
* this warranty disclaimer.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/bitops.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2009-06-02 15:29:35 -06:00
|
|
|
#include <net/bluetooth/bluetooth.h>
|
|
|
|
|
|
|
|
#define BTM_HEADER_LEN 4
|
|
|
|
#define BTM_UPLD_SIZE 2312
|
|
|
|
|
|
|
|
/* Time to wait until Host Sleep state change in millisecond */
|
|
|
|
#define WAIT_UNTIL_HS_STATE_CHANGED 5000
|
|
|
|
/* Time to wait for command response in millisecond */
|
|
|
|
#define WAIT_UNTIL_CMD_RESP 5000
|
|
|
|
|
|
|
|
struct btmrvl_thread {
|
|
|
|
struct task_struct *task;
|
|
|
|
wait_queue_head_t wait_q;
|
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btmrvl_device {
|
|
|
|
void *card;
|
|
|
|
struct hci_dev *hcidev;
|
|
|
|
|
2010-03-03 15:37:37 -07:00
|
|
|
u8 dev_type;
|
|
|
|
|
2009-06-02 15:29:35 -06:00
|
|
|
u8 tx_dnld_rdy;
|
|
|
|
|
|
|
|
u8 psmode;
|
|
|
|
u8 pscmd;
|
|
|
|
u8 hsmode;
|
|
|
|
u8 hscmd;
|
|
|
|
|
|
|
|
/* Low byte is gap, high byte is GPIO */
|
|
|
|
u16 gpio_gap;
|
|
|
|
|
|
|
|
u8 hscfgcmd;
|
|
|
|
u8 sendcmdflag;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct btmrvl_adapter {
|
2014-03-28 15:54:39 -06:00
|
|
|
void *hw_regs_buf;
|
|
|
|
u8 *hw_regs;
|
2009-06-02 15:29:35 -06:00
|
|
|
u32 int_count;
|
|
|
|
struct sk_buff_head tx_queue;
|
|
|
|
u8 psmode;
|
|
|
|
u8 ps_state;
|
|
|
|
u8 hs_state;
|
|
|
|
u8 wakeup_tries;
|
|
|
|
wait_queue_head_t cmd_wait_q;
|
|
|
|
u8 cmd_complete;
|
2012-04-25 12:43:54 -06:00
|
|
|
bool is_suspended;
|
2009-06-02 15:29:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct btmrvl_private {
|
|
|
|
struct btmrvl_device btmrvl_dev;
|
|
|
|
struct btmrvl_adapter *adapter;
|
|
|
|
struct btmrvl_thread main_thread;
|
|
|
|
int (*hw_host_to_card) (struct btmrvl_private *priv,
|
|
|
|
u8 *payload, u16 nb);
|
|
|
|
int (*hw_wakeup_firmware) (struct btmrvl_private *priv);
|
2010-05-27 17:38:37 -06:00
|
|
|
int (*hw_process_int_status) (struct btmrvl_private *priv);
|
2009-06-02 15:29:35 -06:00
|
|
|
spinlock_t driver_lock; /* spinlock used by driver */
|
2009-06-02 15:29:37 -06:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void *debugfs_data;
|
|
|
|
#endif
|
2009-06-02 15:29:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MRVL_VENDOR_PKT 0xFE
|
|
|
|
|
2013-10-31 16:08:31 -06:00
|
|
|
/* Vendor specific Bluetooth commands */
|
|
|
|
#define BT_CMD_AUTO_SLEEP_MODE 0xFC23
|
|
|
|
#define BT_CMD_HOST_SLEEP_CONFIG 0xFC59
|
|
|
|
#define BT_CMD_HOST_SLEEP_ENABLE 0xFC5A
|
|
|
|
#define BT_CMD_MODULE_CFG_REQ 0xFC5B
|
|
|
|
#define BT_CMD_LOAD_CONFIG_DATA 0xFC61
|
2009-06-02 15:29:35 -06:00
|
|
|
|
2010-03-03 15:37:35 -07:00
|
|
|
/* Sub-commands: Module Bringup/Shutdown Request/Response */
|
2009-06-02 15:29:35 -06:00
|
|
|
#define MODULE_BRINGUP_REQ 0xF1
|
2010-03-03 15:37:35 -07:00
|
|
|
#define MODULE_BROUGHT_UP 0x00
|
|
|
|
#define MODULE_ALREADY_UP 0x0C
|
|
|
|
|
2009-06-02 15:29:35 -06:00
|
|
|
#define MODULE_SHUTDOWN_REQ 0xF2
|
|
|
|
|
2013-10-31 16:08:31 -06:00
|
|
|
/* Vendor specific Bluetooth events */
|
|
|
|
#define BT_EVENT_AUTO_SLEEP_MODE 0x23
|
|
|
|
#define BT_EVENT_HOST_SLEEP_CONFIG 0x59
|
|
|
|
#define BT_EVENT_HOST_SLEEP_ENABLE 0x5A
|
|
|
|
#define BT_EVENT_MODULE_CFG_REQ 0x5B
|
2009-06-02 15:29:35 -06:00
|
|
|
#define BT_EVENT_POWER_STATE 0x20
|
|
|
|
|
|
|
|
/* Bluetooth Power States */
|
|
|
|
#define BT_PS_ENABLE 0x02
|
|
|
|
#define BT_PS_DISABLE 0x03
|
|
|
|
#define BT_PS_SLEEP 0x01
|
|
|
|
|
|
|
|
/* Host Sleep states */
|
|
|
|
#define HS_ACTIVATED 0x01
|
|
|
|
#define HS_DEACTIVATED 0x00
|
|
|
|
|
|
|
|
/* Power Save modes */
|
|
|
|
#define PS_SLEEP 0x01
|
|
|
|
#define PS_AWAKE 0x00
|
|
|
|
|
2013-11-01 16:28:25 -06:00
|
|
|
#define BT_CAL_HDR_LEN 4
|
2013-10-01 13:19:15 -06:00
|
|
|
#define BT_CAL_DATA_SIZE 28
|
|
|
|
|
2009-06-02 15:29:35 -06:00
|
|
|
struct btmrvl_event {
|
|
|
|
u8 ec; /* event counter */
|
|
|
|
u8 length;
|
|
|
|
u8 data[4];
|
2010-07-19 10:54:05 -06:00
|
|
|
} __packed;
|
2009-06-02 15:29:35 -06:00
|
|
|
|
|
|
|
/* Prototype of global function */
|
|
|
|
|
2010-03-03 15:37:36 -07:00
|
|
|
int btmrvl_register_hdev(struct btmrvl_private *priv);
|
2009-06-02 15:29:35 -06:00
|
|
|
struct btmrvl_private *btmrvl_add_card(void *card);
|
|
|
|
int btmrvl_remove_card(struct btmrvl_private *priv);
|
|
|
|
|
|
|
|
void btmrvl_interrupt(struct btmrvl_private *priv);
|
|
|
|
|
2012-06-13 04:35:44 -06:00
|
|
|
bool btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb);
|
2009-06-02 15:29:35 -06:00
|
|
|
int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);
|
|
|
|
|
2014-04-15 14:00:00 -06:00
|
|
|
int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, u8 subcmd);
|
2012-04-24 17:31:40 -06:00
|
|
|
int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv);
|
2009-09-30 12:18:30 -06:00
|
|
|
int btmrvl_enable_ps(struct btmrvl_private *priv);
|
2009-06-02 15:29:35 -06:00
|
|
|
int btmrvl_prepare_command(struct btmrvl_private *priv);
|
2012-04-25 12:43:54 -06:00
|
|
|
int btmrvl_enable_hs(struct btmrvl_private *priv);
|
2009-06-02 15:29:35 -06:00
|
|
|
|
2009-06-02 15:29:37 -06:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void btmrvl_debugfs_init(struct hci_dev *hdev);
|
|
|
|
void btmrvl_debugfs_remove(struct hci_dev *hdev);
|
|
|
|
#endif
|