2009-06-03 04:29:35 +07: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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2009-06-03 04:29:35 +07: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 */
|
2015-01-07 12:36:55 +07:00
|
|
|
#define WAIT_UNTIL_HS_STATE_CHANGED msecs_to_jiffies(5000)
|
2009-06-03 04:29:35 +07:00
|
|
|
/* Time to wait for command response in millisecond */
|
2015-01-07 12:36:55 +07:00
|
|
|
#define WAIT_UNTIL_CMD_RESP msecs_to_jiffies(5000)
|
2009-06-03 04:29:35 +07:00
|
|
|
|
2014-11-24 17:40:53 +07:00
|
|
|
enum rdwr_status {
|
|
|
|
RDWR_STATUS_SUCCESS = 0,
|
|
|
|
RDWR_STATUS_FAILURE = 1,
|
|
|
|
RDWR_STATUS_DONE = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FW_DUMP_MAX_NAME_LEN 8
|
|
|
|
#define FW_DUMP_HOST_READY 0xEE
|
|
|
|
#define FW_DUMP_DONE 0xFF
|
|
|
|
#define FW_DUMP_READ_DONE 0xFE
|
|
|
|
|
|
|
|
struct memory_type_mapping {
|
|
|
|
u8 mem_name[FW_DUMP_MAX_NAME_LEN];
|
|
|
|
u8 *mem_ptr;
|
|
|
|
u32 mem_size;
|
|
|
|
u8 done_flag;
|
|
|
|
};
|
|
|
|
|
2009-06-03 04:29:35 +07:00
|
|
|
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-04 05:37:37 +07:00
|
|
|
u8 dev_type;
|
|
|
|
|
2009-06-03 04:29:35 +07: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-29 04:54:39 +07:00
|
|
|
void *hw_regs_buf;
|
|
|
|
u8 *hw_regs;
|
2009-06-03 04:29:35 +07: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;
|
2014-07-02 04:00:14 +07:00
|
|
|
wait_queue_head_t event_hs_wait_q;
|
2009-06-03 04:29:35 +07:00
|
|
|
u8 cmd_complete;
|
2012-04-26 01:43:54 +07:00
|
|
|
bool is_suspended;
|
2016-01-06 21:34:38 +07:00
|
|
|
bool is_suspending;
|
2009-06-03 04:29:35 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct btmrvl_private {
|
|
|
|
struct btmrvl_device btmrvl_dev;
|
|
|
|
struct btmrvl_adapter *adapter;
|
|
|
|
struct btmrvl_thread main_thread;
|
2015-07-23 17:38:47 +07:00
|
|
|
int (*hw_host_to_card)(struct btmrvl_private *priv,
|
2009-06-03 04:29:35 +07:00
|
|
|
u8 *payload, u16 nb);
|
2015-07-23 17:38:47 +07:00
|
|
|
int (*hw_wakeup_firmware)(struct btmrvl_private *priv);
|
|
|
|
int (*hw_process_int_status)(struct btmrvl_private *priv);
|
2014-11-24 17:40:53 +07:00
|
|
|
void (*firmware_dump)(struct btmrvl_private *priv);
|
2009-06-03 04:29:35 +07:00
|
|
|
spinlock_t driver_lock; /* spinlock used by driver */
|
2009-06-03 04:29:37 +07:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void *debugfs_data;
|
|
|
|
#endif
|
2015-01-01 15:13:41 +07:00
|
|
|
bool surprise_removed;
|
2009-06-03 04:29:35 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MRVL_VENDOR_PKT 0xFE
|
|
|
|
|
2013-11-01 05:08:31 +07:00
|
|
|
/* Vendor specific Bluetooth commands */
|
2014-04-01 04:41:44 +07:00
|
|
|
#define BT_CMD_PSCAN_WIN_REPORT_ENABLE 0xFC03
|
2015-02-10 20:49:41 +07:00
|
|
|
#define BT_CMD_ROUTE_SCO_TO_HOST 0xFC1D
|
2014-07-19 04:47:07 +07:00
|
|
|
#define BT_CMD_SET_BDADDR 0xFC22
|
2013-11-01 05:08:31 +07:00
|
|
|
#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-03 04:29:35 +07:00
|
|
|
|
2010-03-04 05:37:35 +07:00
|
|
|
/* Sub-commands: Module Bringup/Shutdown Request/Response */
|
2009-06-03 04:29:35 +07:00
|
|
|
#define MODULE_BRINGUP_REQ 0xF1
|
2010-03-04 05:37:35 +07:00
|
|
|
#define MODULE_BROUGHT_UP 0x00
|
|
|
|
#define MODULE_ALREADY_UP 0x0C
|
|
|
|
|
2009-06-03 04:29:35 +07:00
|
|
|
#define MODULE_SHUTDOWN_REQ 0xF2
|
|
|
|
|
2013-11-01 05:08:31 +07: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-03 04:29:35 +07: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-02 05:28:25 +07:00
|
|
|
#define BT_CAL_HDR_LEN 4
|
2013-10-02 02:19:15 +07:00
|
|
|
#define BT_CAL_DATA_SIZE 28
|
|
|
|
|
2009-06-03 04:29:35 +07:00
|
|
|
struct btmrvl_event {
|
|
|
|
u8 ec; /* event counter */
|
|
|
|
u8 length;
|
|
|
|
u8 data[4];
|
2010-07-19 23:54:05 +07:00
|
|
|
} __packed;
|
2009-06-03 04:29:35 +07:00
|
|
|
|
|
|
|
/* Prototype of global function */
|
|
|
|
|
2010-03-04 05:37:36 +07:00
|
|
|
int btmrvl_register_hdev(struct btmrvl_private *priv);
|
2009-06-03 04:29:35 +07: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 17:35:44 +07:00
|
|
|
bool btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb);
|
2009-06-03 04:29:35 +07:00
|
|
|
int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);
|
|
|
|
|
2014-04-16 03:00:00 +07:00
|
|
|
int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, u8 subcmd);
|
2014-07-02 20:45:39 +07:00
|
|
|
int btmrvl_pscan_window_reporting(struct btmrvl_private *priv, u8 subcmd);
|
2012-04-25 06:31:40 +07:00
|
|
|
int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv);
|
2009-10-01 01:18:30 +07:00
|
|
|
int btmrvl_enable_ps(struct btmrvl_private *priv);
|
2009-06-03 04:29:35 +07:00
|
|
|
int btmrvl_prepare_command(struct btmrvl_private *priv);
|
2012-04-26 01:43:54 +07:00
|
|
|
int btmrvl_enable_hs(struct btmrvl_private *priv);
|
2014-11-24 17:40:53 +07:00
|
|
|
void btmrvl_firmware_dump(struct btmrvl_private *priv);
|
2009-06-03 04:29:35 +07:00
|
|
|
|
2009-06-03 04:29:37 +07:00
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void btmrvl_debugfs_init(struct hci_dev *hdev);
|
|
|
|
void btmrvl_debugfs_remove(struct hci_dev *hdev);
|
|
|
|
#endif
|