diff options
author | Marc Yang <yangyang@marvell.com> | 2013-12-06 18:46:47 -0800 |
---|---|---|
committer | Bitan Biswas <bbiswas@nvidia.com> | 2013-12-20 02:38:00 -0800 |
commit | 055783c836c25e9600d7bfe461587da2513e4693 (patch) | |
tree | 4f25f1af3d7ed8c27a4611ecb065ef55012d9e18 /drivers/bluetooth | |
parent | 23705b359ecbd3a4c612f6c43021439120c4d905 (diff) |
net: wireless: Update SD8797/8897 WLAN/BT driver
Signed-off-by: Marc Yang <yangyang@marvell.com>
Update SD8797/8897 WLAN/BT driver to 457
Bug 1424794
Change-Id: Ib6484ce69ecbb385748cf1a045e67695005f7d8e
Signed-off-by: Manikanta <mmaddireddy@nvidia.com>
Reviewed-on: http://git-master/r/345281
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nagarjuna Kristam <nkristam@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_drv.h | 70 | ||||
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_init.c | 75 | ||||
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_main.c | 444 | ||||
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_proc.c | 16 | ||||
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_sdio.h | 89 | ||||
-rw-r--r-- | drivers/bluetooth/sd8797/bt/bt_sdiommc.c | 100 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_drv.h | 70 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_init.c | 75 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_main.c | 444 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_proc.c | 16 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_sdio.h | 41 | ||||
-rw-r--r-- | drivers/bluetooth/sd8897/bt/bt_sdiommc.c | 100 |
12 files changed, 972 insertions, 568 deletions
diff --git a/drivers/bluetooth/sd8797/bt/bt_drv.h b/drivers/bluetooth/sd8797/bt/bt_drv.h index 8e6f21f501cb..2a8f8f5fbcf3 100644 --- a/drivers/bluetooth/sd8797/bt/bt_drv.h +++ b/drivers/bluetooth/sd8797/bt/bt_drv.h @@ -96,11 +96,14 @@ extern u32 mbt_drvdbg; #ifdef DEBUG_LEVEL2 /** Print informative message */ -#define PRINTM_INFO(msg...) do {if (mbt_drvdbg & DBG_INFO) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_INFO(msg...) do {if (mbt_drvdbg & DBG_INFO) \ + printk(KERN_DEBUG msg); } while (0) /** Print warning message */ -#define PRINTM_WARN(msg...) do {if (mbt_drvdbg & DBG_WARN) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_WARN(msg...) do {if (mbt_drvdbg & DBG_WARN) \ + printk(KERN_DEBUG msg); } while (0) /** Print entry message */ -#define PRINTM_ENTRY(msg...) do {if (mbt_drvdbg & DBG_ENTRY) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_ENTRY(msg...) do {if (mbt_drvdbg & DBG_ENTRY) \ + printk(KERN_DEBUG msg); } while (0) #else /** Print informative message */ #define PRINTM_INFO(msg...) do {} while (0) @@ -111,24 +114,33 @@ extern u32 mbt_drvdbg; #endif /* DEBUG_LEVEL2 */ /** Print interrupt message */ -#define PRINTM_INTR(msg...) do {if (mbt_drvdbg & DBG_INTR) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_INTR(msg...) do {if (mbt_drvdbg & DBG_INTR) \ + printk(KERN_DEBUG msg); } while (0) /** Print event message */ -#define PRINTM_EVENT(msg...) do {if (mbt_drvdbg & DBG_EVENT) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_EVENT(msg...) do {if (mbt_drvdbg & DBG_EVENT) \ + printk(KERN_DEBUG msg); } while (0) /** Print command message */ -#define PRINTM_CMD(msg...) do {if (mbt_drvdbg & DBG_CMD) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_CMD(msg...) do {if (mbt_drvdbg & DBG_CMD) \ + printk(KERN_DEBUG msg); } while (0) /** Print data message */ -#define PRINTM_DATA(msg...) do {if (mbt_drvdbg & DBG_DATA) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_DATA(msg...) do {if (mbt_drvdbg & DBG_DATA) \ + printk(KERN_DEBUG msg); } while (0) /** Print error message */ -#define PRINTM_ERROR(msg...) do {if (mbt_drvdbg & DBG_ERROR) printk(KERN_ERR msg); } while (0) +#define PRINTM_ERROR(msg...) do {if (mbt_drvdbg & DBG_ERROR) \ + printk(KERN_ERR msg); } while (0) /** Print fatal message */ -#define PRINTM_FATAL(msg...) do {if (mbt_drvdbg & DBG_FATAL) printk(KERN_ERR msg); } while (0) +#define PRINTM_FATAL(msg...) do {if (mbt_drvdbg & DBG_FATAL) \ + printk(KERN_ERR msg); } while (0) /** Print message */ -#define PRINTM_MSG(msg...) do {if (mbt_drvdbg & DBG_MSG) printk(KERN_ALERT msg); } while (0) +#define PRINTM_MSG(msg...) do {if (mbt_drvdbg & DBG_MSG) \ + printk(KERN_ALERT msg); } while (0) /** Print data dump message */ -#define PRINTM_DAT_D(msg...) do {if (mbt_drvdbg & DBG_DAT_D) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_DAT_D(msg...) do {if (mbt_drvdbg & DBG_DAT_D) \ + printk(KERN_DEBUG msg); } while (0) /** Print data dump message */ -#define PRINTM_CMD_D(msg...) do {if (mbt_drvdbg & DBG_CMD_D) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_CMD_D(msg...) do {if (mbt_drvdbg & DBG_CMD_D) \ + printk(KERN_DEBUG msg); } while (0) /** Print message with required level */ #define PRINTM(level, msg...) PRINTM_##level(msg) @@ -164,28 +176,30 @@ hexdump(char *prompt, u8 * buf, int len) } /** Debug hexdump of debug data */ -#define DBG_HEXDUMP_DAT_D(x, y, z) do {if (mbt_drvdbg & DBG_DAT_D) hexdump(x, y, z); } while (0) +#define DBG_HEXDUMP_DAT_D(x, y, z) do {if (mbt_drvdbg & DBG_DAT_D) \ + hexdump(x, y, z); } while (0) /** Debug hexdump of debug command */ -#define DBG_HEXDUMP_CMD_D(x, y, z) do {if (mbt_drvdbg & DBG_CMD_D) hexdump(x, y, z); } while (0) +#define DBG_HEXDUMP_CMD_D(x, y, z) do {if (mbt_drvdbg & DBG_CMD_D) \ + hexdump(x, y, z); } while (0) /** Debug hexdump */ #define DBG_HEXDUMP(level, x, y, z) DBG_HEXDUMP_##level(x, y, z) /** Mark entry point */ -#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __FUNCTION__, \ +#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __func__, \ __FILE__, __LINE__) /** Mark exit point */ -#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __FUNCTION__, \ +#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __func__, \ __FILE__, __LINE__) #else /** Do nothing */ -#define PRINTM(level, msg...) do {} while (0); +#define PRINTM(level, msg...) do {} while (0) /** Do nothing */ -#define DBG_HEXDUMP(level, x, y, z) do {} while (0); +#define DBG_HEXDUMP(level, x, y, z) do {} while (0) /** Do nothing */ -#define ENTER() do {} while (0); +#define ENTER() do {} while (0) /** Do nothing */ -#define LEAVE() do {} while (0); +#define LEAVE() do {} while (0) #endif /* DEBUG_LEVEL1 */ /** Bluetooth upload size */ @@ -278,7 +292,7 @@ os_sched_timeout(u32 millisec) #endif #ifndef __ATTRIB_PACK__ -#define __ATTRIB_PACK__ __attribute__ ((packed)) +#define __ATTRIB_PACK__ __attribute__((packed)) #endif /** Data structure for the Marvell Bluetooth device */ @@ -453,9 +467,11 @@ typedef struct _bt_private { } bt_private, *pbt_private; /** Disable interrupt */ -#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, priv->driver_flags) +#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, \ + priv->driver_flags) /** Enable interrupt */ -#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, priv->driver_flags) +#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, \ + priv->driver_flags) #ifndef HCI_BT_AMP /** BT_AMP flag for device type */ @@ -586,7 +602,7 @@ typedef struct _BT_CMD { /** Length */ u8 length; /** Data */ - u8 data[32]; + u8 data[128]; } __ATTRIB_PACK__ BT_CMD; typedef struct _BT_EVENT { @@ -671,6 +687,8 @@ int sd_download_firmware_w_helper(bt_private * priv); #define BT_CMD_CSU_WRITE_REG 0x66 /** Bluetooth command : Load calibrate data */ #define BT_CMD_LOAD_CONFIG_DATA 0x61 +/** Bluetooth command : Load calibrate ext data */ +#define BT_CMD_LOAD_CONFIG_DATA_EXT 0x60 /** Bluetooth command : BLE deepsleep */ #define BT_CMD_BLE_DEEP_SLEEP 0x8b @@ -705,8 +723,12 @@ int bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value); int bt_init_config(bt_private * priv, char *cfg_file); /** This function load the calibrate data */ int bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac); +/** This function load the calibrate ext data */ +int bt_load_cal_data_ext(bt_private * priv, u8 * config_data, u32 cfg_data_len); /** BT set user defined calibration data */ int bt_cal_config(bt_private * priv, char *cfg_file, char *mac); +/** BT set user defined calibration ext data */ +int bt_cal_config_ext(bt_private * priv, char *cfg_file); int bt_init_mac_address(bt_private * priv, char *mac); typedef struct _BT_HCI_CMD { diff --git a/drivers/bluetooth/sd8797/bt/bt_init.c b/drivers/bluetooth/sd8797/bt/bt_init.c index 55481d520a3d..13d7ed300974 100644 --- a/drivers/bluetooth/sd8797/bt/bt_init.c +++ b/drivers/bluetooth/sd8797/bt/bt_init.c @@ -200,10 +200,11 @@ bt_atoi(int *data, char *a) * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int -bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) +bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 * dst_size) { const u8 *ptr; u8 *dptr; + u32 count = 0; int ret = BT_STATUS_FAILURE; ENTER(); @@ -217,12 +218,13 @@ bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) } if (isxdigit(*ptr)) { - if ((dptr - dst) >= dst_size) { + if ((dptr - dst) >= *dst_size) { PRINTM(ERROR, "cal_file size too big!!!\n"); goto done; } *dptr++ = bt_atox(ptr); ptr += 2; + count++; } else { ptr++; } @@ -232,6 +234,7 @@ bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) goto done; } + *dst_size = count; ret = BT_STATUS_SUCCESS; done: LEAVE(); @@ -497,11 +500,13 @@ bt_process_cal_cfg(bt_private * priv, u8 * data, u32 size, char *mac) u8 bt_mac[ETH_ALEN]; u8 cal_data[32]; u8 *mac_data = NULL; + u32 cal_data_len; int ret = BT_STATUS_FAILURE; memset(bt_mac, 0, sizeof(bt_mac)); + cal_data_len = sizeof(cal_data); if (BT_STATUS_SUCCESS != - bt_parse_cal_cfg(data, size, cal_data, sizeof(cal_data))) { + bt_parse_cal_cfg(data, size, cal_data, &cal_data_len)) { goto done; } if (mac != NULL) { @@ -523,6 +528,39 @@ done: } /** + * @brief BT process calibration EXT data + * + * @param priv a pointer to bt_private structure + * @param data a pointer to cal data + * @param size cal data size + * @param mac mac address buf + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_process_cal_cfg_ext(bt_private * priv, u8 * data, u32 size) +{ + u8 cal_data[128]; + u32 cal_data_len; + int ret = BT_STATUS_FAILURE; + + cal_data_len = sizeof(cal_data); + if (BT_STATUS_SUCCESS != + bt_parse_cal_cfg(data, size, cal_data, &cal_data_len)) { + goto done; + } + if (BT_STATUS_SUCCESS != + bt_load_cal_data_ext(priv, cal_data, cal_data_len)) { + PRINTM(FATAL, "BT: Fail to load calibrate data\n"); + goto done; + } + ret = BT_STATUS_SUCCESS; + +done: + LEAVE(); + return ret; +} + +/** * @brief BT process calibration file * * @param priv a pointer to bt_private structure @@ -555,6 +593,37 @@ done: } /** + * @brief BT process calibration EXT file + * + * @param priv a pointer to bt_private structure + * @param cal_file calibration file name + * @param mac mac address buf + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_cal_config_ext(bt_private * priv, char *cal_file) +{ + const struct firmware *cfg = NULL; + int ret = BT_STATUS_SUCCESS; + + ENTER(); + if ((request_firmware(&cfg, cal_file, priv->hotplug_device)) < 0) { + PRINTM(FATAL, "BT: request_firmware() %s failed\n", cal_file); + ret = BT_STATUS_FAILURE; + goto done; + } + if (cfg) + ret = bt_process_cal_cfg_ext(priv, (u8 *) cfg->data, cfg->size); + else + ret = BT_STATUS_FAILURE; +done: + if (cfg) + release_firmware(cfg); + LEAVE(); + return ret; +} + +/** * @brief BT init mac address from bt_mac parametre when insmod * * @param priv a pointer to bt_private structure diff --git a/drivers/bluetooth/sd8797/bt/bt_main.c b/drivers/bluetooth/sd8797/bt/bt_main.c index 9b5d808d837c..04ec9a69ae4f 100644 --- a/drivers/bluetooth/sd8797/bt/bt_main.c +++ b/drivers/bluetooth/sd8797/bt/bt_main.c @@ -37,6 +37,8 @@ #include <linux/platform_device.h> #include <linux/wlan_plat.h> +#include <linux/interrupt.h> + #include "bt_drv.h" #include "mbt_char.h" #include "bt_sdio.h" @@ -90,6 +92,8 @@ static int psmode = 1; static char *init_cfg; /** Calibration config file (MAC address, init powe etc.) */ static char *cal_cfg; +/** Calibration config file EXT */ +static char *cal_cfg_ext; /** Init MAC address */ static char *bt_mac; @@ -115,7 +119,13 @@ static int minicard_pwrup = 1; /** Pointer to struct with control hooks */ static struct wifi_platform_data *bt_control_data; +#define IORESOURCE_NAME "mrvl_bt_irq" +#define DRIVER_NAME "bt hostwake" + void mdev_poweroff(struct m_dev *m_dev); +static struct resource *bt_irqres; +static int irq_registered; +static void bt_register_hostwake_irq(void *handle); /** * @brief Alloc bt device @@ -258,6 +268,7 @@ check_evtpkt(bt_private * priv, struct sk_buff *skb) case BT_CMD_CONFIG_MAC_ADDR: case BT_CMD_CSU_WRITE_REG: case BT_CMD_LOAD_CONFIG_DATA: + case BT_CMD_LOAD_CONFIG_DATA_EXT: case BT_CMD_AUTO_SLEEP_MODE: case BT_CMD_HOST_SLEEP_CONFIG: case BT_CMD_SDIO_PULL_CFG_REQ: @@ -330,19 +341,19 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) { u8 ret = BT_STATUS_SUCCESS; struct m_dev *m_dev = &(priv->bt_dev.m_dev[BT_SEQ]); - BT_EVENT *pEvent; + BT_EVENT *pevent; ENTER(); - pEvent = (BT_EVENT *) skb->data; - if (pEvent->EC != 0xff) { - PRINTM(CMD, "BT: Not Marvell Event=0x%x\n", pEvent->EC); + pevent = (BT_EVENT *) skb->data; + if (pevent->EC != 0xff) { + PRINTM(CMD, "BT: Not Marvell Event=0x%x\n", pevent->EC); ret = BT_STATUS_FAILURE; goto exit; } - switch (pEvent->data[0]) { + switch (pevent->data[0]) { case BT_CMD_AUTO_SLEEP_MODE: - if (pEvent->data[2] == BT_STATUS_SUCCESS) { - if (pEvent->data[1] == BT_PS_ENABLE) + if (pevent->data[2] == BT_STATUS_SUCCESS) { + if (pevent->data[1] == BT_PS_ENABLE) priv->adapter->psmode = 1; else priv->adapter->psmode = 0; @@ -355,16 +366,16 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; case BT_CMD_HOST_SLEEP_CONFIG: - if (pEvent->data[3] == BT_STATUS_SUCCESS) { + if (pevent->data[3] == BT_STATUS_SUCCESS) { PRINTM(CMD, "BT: %s: gpio=0x%x, gap=0x%x\n", - m_dev->name, pEvent->data[1], pEvent->data[2]); + m_dev->name, pevent->data[1], pevent->data[2]); } else { PRINTM(CMD, "BT: %s: HSCFG Command Fail\n", m_dev->name); } break; case BT_CMD_HOST_SLEEP_ENABLE: - if (pEvent->data[1] == BT_STATUS_SUCCESS) { + if (pevent->data[1] == BT_STATUS_SUCCESS) { priv->adapter->hs_state = HS_ACTIVATED; if (priv->adapter->suspend_fail == FALSE) { #ifdef SDIO_SUSPEND_RESUME @@ -388,45 +399,44 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) break; case BT_CMD_MODULE_CFG_REQ: if ((priv->bt_dev.sendcmdflag == TRUE) && - ((pEvent->data[1] == MODULE_BRINGUP_REQ) - || (pEvent->data[1] == MODULE_SHUTDOWN_REQ))) { - if (pEvent->data[1] == MODULE_BRINGUP_REQ) { + ((pevent->data[1] == MODULE_BRINGUP_REQ) + || (pevent->data[1] == MODULE_SHUTDOWN_REQ))) { + if (pevent->data[1] == MODULE_BRINGUP_REQ) { PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, - (pEvent->data[2] && (pEvent->data[2] != + (pevent->data[2] && (pevent->data[2] != MODULE_CFG_RESP_ALREADY_UP)) ? "Bring up Fail" : "Bring up success"); - priv->bt_dev.devType = pEvent->data[3]; + priv->bt_dev.devType = pevent->data[3]; PRINTM(CMD, "devType:%s\n", - (pEvent->data[3] == + (pevent->data[3] == DEV_TYPE_AMP) ? "AMP controller" : "BR/EDR controller"); - priv->bt_dev.devFeature = pEvent->data[4]; + priv->bt_dev.devFeature = pevent->data[4]; PRINTM(CMD, "devFeature: %s, %s, %s, %s, %s\n", - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BT) ? "BT Feature" : "No BT Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BTAMP) ? "BTAMP Feature" : "No BTAMP Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BLE) ? "BLE Feature" : "No BLE Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_FM) ? "FM Feature" : "No FM Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_NFC) ? "NFC Feature" : "No NFC Feature")); } - if (pEvent->data[1] == MODULE_SHUTDOWN_REQ) { + if (pevent->data[1] == MODULE_SHUTDOWN_REQ) { PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, - (pEvent-> - data[2]) ? "Shut down Fail" : - "Shut down success"); + (pevent->data[2]) ? "Shut down Fail" + : "Shut down success"); } - if (pEvent->data[2]) { + if (pevent->data[2]) { priv->bt_dev.sendcmdflag = FALSE; priv->adapter->cmd_complete = TRUE; wake_up_interruptible(&priv->adapter-> @@ -438,14 +448,14 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; case BT_EVENT_POWER_STATE: - if (pEvent->data[1] == BT_PS_SLEEP) + if (pevent->data[1] == BT_PS_SLEEP) priv->adapter->ps_state = PS_SLEEP; PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, (priv->adapter->ps_state) ? "PS_SLEEP" : "PS_AWAKE"); break; case BT_CMD_SDIO_PULL_CFG_REQ: - if (pEvent->data[pEvent->length - 1] == BT_STATUS_SUCCESS) + if (pevent->data[pevent->length - 1] == BT_STATUS_SUCCESS) PRINTM(CMD, "BT: %s: SDIO pull configuration success\n", m_dev->name); @@ -456,7 +466,7 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; default: - PRINTM(CMD, "BT: Unknown Event=%d %s\n", pEvent->data[0], + PRINTM(CMD, "BT: Unknown Event=%d %s\n", pevent->data[0], m_dev->name); ret = BT_STATUS_FAILURE; break; @@ -509,14 +519,14 @@ bt_cmd_timeout_func(bt_adapter * adapter, u16 cmd) * * @param priv A pointer to bt_private structure * - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int bt_send_reset_command(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -524,10 +534,10 @@ bt_send_reset_command(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (RESET_OGF << 10) | BT_CMD_RESET; - pCmd->length = 0x00; - pCmd->cmd_type = 0x00; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (RESET_OGF << 10) | BT_CMD_RESET; + pcmd->length = 0x00; + pcmd->cmd_type = 0x00; bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; skb_put(skb, 3); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -535,7 +545,7 @@ bt_send_reset_command(bt_private * priv) priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_RESET; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "Queue Reset Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue Reset Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -570,7 +580,7 @@ bt_send_module_cfg_cmd(bt_private * priv, int subcmd) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -578,18 +588,18 @@ bt_send_module_cfg_cmd(bt_private * priv, int subcmd) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_MODULE_CFG_REQ; - pCmd->length = 1; - pCmd->data[0] = subcmd; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_MODULE_CFG_REQ; + pcmd->length = 1; + pcmd->data[0] = subcmd; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_MODULE_CFG_REQ; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "Queue module cfg Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue module cfg Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); /* On some Android platforms certain delay is needed for HCI daemon to @@ -624,7 +634,7 @@ bt_enable_ps(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -632,25 +642,25 @@ bt_enable_ps(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_AUTO_SLEEP_MODE; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_AUTO_SLEEP_MODE; if (priv->bt_dev.psmode) - pCmd->data[0] = BT_PS_ENABLE; + pcmd->data[0] = BT_PS_ENABLE; else - pCmd->data[0] = BT_PS_DISABLE; + pcmd->data[0] = BT_PS_DISABLE; if (priv->bt_dev.idle_timeout) { - pCmd->length = 3; - pCmd->data[1] = (u8) (priv->bt_dev.idle_timeout & 0x00ff); - pCmd->data[2] = (priv->bt_dev.idle_timeout & 0xff00) >> 8; + pcmd->length = 3; + pcmd->data[1] = (u8) (priv->bt_dev.idle_timeout & 0x00ff); + pcmd->data[2] = (priv->bt_dev.idle_timeout & 0xff00) >> 8; } else { - pCmd->length = 1; + pcmd->length = 1; } bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); - PRINTM(CMD, "Queue PSMODE Command(0x%x):%d\n", pCmd->ocf_ogf, - pCmd->data[0]); + PRINTM(CMD, "Queue PSMODE Command(0x%x):%d\n", pcmd->ocf_ogf, + pcmd->data[0]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_AUTO_SLEEP_MODE; priv->adapter->cmd_complete = FALSE; @@ -678,7 +688,7 @@ bt_send_hscfg_cmd(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -686,17 +696,17 @@ bt_send_hscfg_cmd(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_CONFIG; - pCmd->length = 2; - pCmd->data[0] = (priv->bt_dev.gpio_gap & 0xff00) >> 8; - pCmd->data[1] = (u8) (priv->bt_dev.gpio_gap & 0x00ff); + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_CONFIG; + pcmd->length = 2; + pcmd->data[0] = (priv->bt_dev.gpio_gap & 0xff00) >> 8; + pcmd->data[1] = (u8) (priv->bt_dev.gpio_gap & 0x00ff); bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); PRINTM(CMD, "Queue HSCFG Command(0x%x),gpio=0x%x,gap=0x%x\n", - pCmd->ocf_ogf, pCmd->data[0], pCmd->data[1]); + pcmd->ocf_ogf, pcmd->data[0], pcmd->data[1]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_HOST_SLEEP_CONFIG; priv->adapter->cmd_complete = FALSE; @@ -724,7 +734,7 @@ bt_send_sdio_pull_ctrl_cmd(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -732,21 +742,21 @@ bt_send_sdio_pull_ctrl_cmd(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_SDIO_PULL_CFG_REQ; - pCmd->length = 4; - pCmd->data[0] = (priv->bt_dev.sdio_pull_cfg & 0x000000ff); - pCmd->data[1] = (priv->bt_dev.sdio_pull_cfg & 0x0000ff00) >> 8; - pCmd->data[2] = (priv->bt_dev.sdio_pull_cfg & 0x00ff0000) >> 16; - pCmd->data[3] = (priv->bt_dev.sdio_pull_cfg & 0xff000000) >> 24; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_SDIO_PULL_CFG_REQ; + pcmd->length = 4; + pcmd->data[0] = (priv->bt_dev.sdio_pull_cfg & 0x000000ff); + pcmd->data[1] = (priv->bt_dev.sdio_pull_cfg & 0x0000ff00) >> 8; + pcmd->data[2] = (priv->bt_dev.sdio_pull_cfg & 0x00ff0000) >> 16; + pcmd->data[3] = (priv->bt_dev.sdio_pull_cfg & 0xff000000) >> 24; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); PRINTM(CMD, "Queue SDIO PULL CFG Command(0x%x), PullUp=0x%x%x,PullDown=0x%x%x\n", - pCmd->ocf_ogf, pCmd->data[1], pCmd->data[0], - pCmd->data[3], pCmd->data[2]); + pcmd->ocf_ogf, pcmd->data[1], pcmd->data[0], + pcmd->data[3], pcmd->data[2]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_SDIO_PULL_CFG_REQ; priv->adapter->cmd_complete = FALSE; @@ -778,7 +788,7 @@ fm_set_intr_mask(bt_private * priv, u32 mask) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); @@ -787,14 +797,14 @@ fm_set_intr_mask(bt_private * priv, u32 mask) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | FM_CMD; - pCmd->length = 0x05; - pCmd->data[0] = FM_SET_INTR_MASK; - memcpy(&pCmd->data[1], &mask, sizeof(mask)); + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | FM_CMD; + pcmd->length = 0x05; + pcmd->data[0] = FM_SET_INTR_MASK; + memcpy(&pcmd->data[1], &mask, sizeof(mask)); PRINTM(CMD, "FM set intr mask=0x%x\n", mask); bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[FM_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; @@ -825,7 +835,7 @@ bt_enable_hs(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -834,16 +844,16 @@ bt_enable_hs(bt_private * priv) goto exit; } priv->adapter->suspend_fail = FALSE; - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE; - pCmd->length = 0; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE; + pcmd->length = 0; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_HOST_SLEEP_ENABLE; - PRINTM(CMD, "Queue hs enable Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue hs enable Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->hs_state, @@ -886,7 +896,7 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_BLE_CMD *pCmd; + BT_BLE_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_BLE_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -894,10 +904,10 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_BLE_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_BLE_DEEP_SLEEP; - pCmd->length = 1; - pCmd->deepsleep = mode; + pcmd = (BT_BLE_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_BLE_DEEP_SLEEP; + pcmd->length = 1; + pcmd->deepsleep = mode; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_BLE_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -905,7 +915,7 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_BLE_DEEP_SLEEP; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "BT: Set BLE deepsleep = %d (0x%x)\n", mode, pCmd->ocf_ogf); + PRINTM(CMD, "BT: Set BLE deepsleep = %d (0x%x)\n", mode, pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -931,7 +941,7 @@ bt_get_fw_version(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -939,10 +949,10 @@ bt_get_fw_version(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_GET_FW_VERSION; - pCmd->length = 0x01; - pCmd->cmd_type = 0x00; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_GET_FW_VERSION; + pcmd->length = 0x01; + pcmd->cmd_type = 0x00; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, 4); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -976,7 +986,7 @@ bt_set_mac_address(bt_private * priv, u8 * mac) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; int i = 0; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); @@ -985,13 +995,13 @@ bt_set_mac_address(bt_private * priv, u8 * mac) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CONFIG_MAC_ADDR; - pCmd->length = 8; - pCmd->cmd_type = MRVL_VENDOR_PKT; - pCmd->cmd_len = 6; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CONFIG_MAC_ADDR; + pcmd->length = 8; + pcmd->cmd_type = MRVL_VENDOR_PKT; + pcmd->cmd_len = 6; for (i = 0; i < 6; i++) - pCmd->data[i] = mac[5 - i]; + pcmd->data[i] = mac[5 - i]; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_HCI_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -1000,7 +1010,7 @@ bt_set_mac_address(bt_private * priv, u8 * mac) priv->bt_dev.send_cmd_ocf = BT_CMD_CONFIG_MAC_ADDR; priv->adapter->cmd_complete = FALSE; PRINTM(CMD, "BT: Set mac addr " MACSTR " (0x%x)\n", MAC2STR(mac), - pCmd->ocf_ogf); + pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -1028,7 +1038,7 @@ bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; int i = 0; /* u8 config_data[28] = {0x37 0x01 0x1c 0x00 0xFF 0xFF 0xFF 0xFF 0x01 0x7f 0x04 0x02 0x00 0x00 0xBA 0xCE 0xC0 0xC6 0x2D 0x00 0x00 0x00 @@ -1041,31 +1051,30 @@ bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA; - pCmd->length = 0x20; - pCmd->data[0] = 0x00; - pCmd->data[1] = 0x00; - pCmd->data[2] = 0x00; - pCmd->data[3] = 0x1C; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA; + pcmd->length = 0x20; + pcmd->data[0] = 0x00; + pcmd->data[1] = 0x00; + pcmd->data[2] = 0x00; + pcmd->data[3] = 0x1C; /* swip cal-data byte */ - for (i = 4; i < 32; i++) { - pCmd->data[i] = config_data[(i / 4) * 8 - 1 - i]; - } + for (i = 4; i < 32; i++) + pcmd->data[i] = config_data[(i / 4) * 8 - 1 - i]; if (mac != NULL) { - pCmd->data[2] = 0x01; /* skip checksum */ + pcmd->data[2] = 0x01; /* skip checksum */ for (i = 24; i < 30; i++) - pCmd->data[i] = mac[29 - i]; + pcmd->data[i] = mac[29 - i]; } bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_LOAD_CONFIG_DATA; priv->adapter->cmd_complete = FALSE; - DBG_HEXDUMP(DAT_D, "calirate data: ", pCmd->data, 32); + DBG_HEXDUMP(DAT_D, "calirate data: ", pcmd->data, 32); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -1080,6 +1089,56 @@ exit: } /** + * @brief This function load the calibrate EXT data + * + * @param priv A pointer to bt_private structure + * @param config_data A pointer to calibrate data + * @param mac A pointer to mac address + * + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_load_cal_data_ext(bt_private * priv, u8 * config_data, u32 cfg_data_len) +{ + struct sk_buff *skb = NULL; + u8 ret = BT_STATUS_SUCCESS; + BT_CMD *pcmd; + + ENTER(); + skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); + if (skb == NULL) { + PRINTM(WARN, "No free skb\n"); + ret = BT_STATUS_FAILURE; + goto exit; + } + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA_EXT; + pcmd->length = cfg_data_len; + + memcpy(pcmd->data, config_data, cfg_data_len); + bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); + skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); + skb_queue_head(&priv->adapter->tx_queue, skb); + priv->bt_dev.sendcmdflag = TRUE; + priv->bt_dev.send_cmd_ocf = BT_CMD_LOAD_CONFIG_DATA_EXT; + priv->adapter->cmd_complete = FALSE; + + DBG_HEXDUMP(DAT_D, "calirate ext data", pcmd->data, pcmd->length); + wake_up_interruptible(&priv->MainThread.waitQ); + if (!os_wait_interruptible_timeout + (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, + WAIT_UNTIL_CMD_RESP)) { + ret = BT_STATUS_FAILURE; + PRINTM(ERROR, "BT: Load calibrate ext data: timeout:\n"); + bt_cmd_timeout_func(priv->adapter, BT_CMD_LOAD_CONFIG_DATA_EXT); + } +exit: + LEAVE(); + return ret; +} + +/** * @brief This function writes value to CSU registers * * @param priv A pointer to bt_private structure @@ -1093,7 +1152,7 @@ bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CSU_CMD *pCmd; + BT_CSU_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CSU_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -1101,16 +1160,16 @@ bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CSU_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CSU_WRITE_REG; - pCmd->length = 7; - pCmd->type = type; - pCmd->offset[0] = (offset & 0x000000ff); - pCmd->offset[1] = (offset & 0x0000ff00) >> 8; - pCmd->offset[2] = (offset & 0x00ff0000) >> 16; - pCmd->offset[3] = (offset & 0xff000000) >> 24; - pCmd->value[0] = (value & 0x00ff); - pCmd->value[1] = (value & 0xff00) >> 8; + pcmd = (BT_CSU_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CSU_WRITE_REG; + pcmd->length = 7; + pcmd->type = type; + pcmd->offset[0] = (offset & 0x000000ff); + pcmd->offset[1] = (offset & 0x0000ff00) >> 8; + pcmd->offset[2] = (offset & 0x00ff0000) >> 16; + pcmd->offset[3] = (offset & 0xff000000) >> 24; + pcmd->value[0] = (value & 0x00ff); + pcmd->value[1] = (value & 0xff00) >> 8; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_CSU_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -1201,7 +1260,7 @@ bt_prepare_command(bt_private * priv) * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int -SendSinglePacket(bt_private * priv, struct sk_buff *skb) +send_single_packet(bt_private * priv, struct sk_buff *skb) { int ret; ENTER(); @@ -1301,11 +1360,11 @@ done: void bt_free_adapter(bt_private * priv) { - bt_adapter *Adapter = priv->adapter; + bt_adapter *adapter = priv->adapter; ENTER(); skb_queue_purge(&priv->adapter->tx_queue); /* Free the adapter object itself */ - kfree(Adapter); + kfree(adapter); priv->adapter = NULL; LEAVE(); @@ -1385,7 +1444,7 @@ mdev_send_frame(struct m_dev *m_dev, struct sk_buff *skb) priv->debug_device_pending = 1; priv->debug_ocf_ogf[0] = skb->data[0]; priv->debug_ocf_ogf[1] = skb->data[1]; - PRINTM(CMD, "debug_ocf_ogf[0]=0x%x debug_ocf_ogf[1]=0x%x \n", + PRINTM(CMD, "debug_ocf_ogf[0]=0x%x debug_ocf_ogf[1]=0x%x\n", priv->debug_ocf_ogf[0], priv->debug_ocf_ogf[1]); } @@ -1542,7 +1601,7 @@ bt_service_main_thread(void *data) { bt_thread *thread = data; bt_private *priv = thread->priv; - bt_adapter *Adapter = priv->adapter; + bt_adapter *adapter = priv->adapter; wait_queue_t wait; struct sk_buff *skb; ENTER(); @@ -1562,17 +1621,17 @@ bt_service_main_thread(void *data) } OS_SET_THREAD_STATE(TASK_RUNNING); remove_wait_queue(&thread->waitQ, &wait); - if (kthread_should_stop() || Adapter->SurpriseRemoved) { + if (kthread_should_stop() || adapter->SurpriseRemoved) { PRINTM(INFO, "main-thread: break from main thread: " "SurpriseRemoved=0x%x\n", - Adapter->SurpriseRemoved); + adapter->SurpriseRemoved); break; } PRINTM(INFO, "Main: Thread waking up...\n"); if (priv->adapter->IntCounter) { OS_INT_DISABLE; - Adapter->IntCounter = 0; + adapter->IntCounter = 0; OS_INT_RESTORE; sbi_get_int_status(priv); } else if ((priv->adapter->ps_state == PS_SLEEP) && @@ -1587,7 +1646,7 @@ bt_service_main_thread(void *data) if (!skb_queue_empty(&priv->adapter->tx_queue)) { skb = skb_dequeue(&priv->adapter->tx_queue); if (skb) { - if (SendSinglePacket(priv, skb)) + if (send_single_packet(priv, skb)) ((struct m_dev *)skb->dev)-> stat.err_tx++; else @@ -1766,7 +1825,8 @@ sbi_register_conf_dpc(bt_private * priv) } } #ifdef SDIO_SUSPEND_RESUME - priv->bt_dev.gpio_gap = 0xffff; + + priv->bt_dev.gpio_gap = 0x0464; ret = bt_send_hscfg_cmd(priv); if (ret < 0) { PRINTM(FATAL, "Send HSCFG failed!\n"); @@ -1781,7 +1841,7 @@ sbi_register_conf_dpc(bt_private * priv) priv->bt_dev.m_dev[BT_SEQ].dev_type = BT_AMP_TYPE; } /* block all the packet from bluez */ - if (init_cfg || cal_cfg || bt_mac) + if (init_cfg || cal_cfg || bt_mac || cal_cfg_ext) priv->adapter->tx_lock = TRUE; if (mbt_dev) { @@ -2052,11 +2112,30 @@ sbi_register_conf_dpc(bt_private * priv) goto done; } } - if (init_cfg || cal_cfg || bt_mac) { + if (cal_cfg_ext) { + if (BT_STATUS_SUCCESS != bt_cal_config_ext(priv, cal_cfg_ext)) { + PRINTM(FATAL, "BT: Set cal ext data failed\n"); + if (mbt_dev) { + m_dev = &(priv->bt_dev.m_dev[BT_SEQ]); + /** unregister m_dev to char_dev */ + m_dev->close(m_dev); + for (i = 0; i < 3; i++) + kfree_skb(mbt_dev->reassembly[i]); + /** unregister m_dev to char_dev */ + chardev_cleanup_one(m_dev, chardev_class); + free_m_dev(m_dev); + } + ret = BT_STATUS_FAILURE; + goto done; + } + } + if (init_cfg || cal_cfg || bt_mac || cal_cfg_ext) { priv->adapter->tx_lock = FALSE; bt_restore_tx_queue(priv); } + bt_register_hostwake_irq(NULL); + /* Get FW version */ bt_get_fw_version(priv); snprintf(priv->adapter->drv_ver, MAX_VER_STR_LEN, @@ -2255,7 +2334,7 @@ bt_remove_card(void *card) static int bt_set_carddetect(int on) { - PRINTM(MSG, "%s = %d\n", __FUNCTION__, on); + PRINTM(MSG, "%s = %d\n", __func__, on); if (bt_control_data && bt_control_data->set_carddetect) bt_control_data->set_carddetect(on); @@ -2271,7 +2350,7 @@ bt_set_carddetect(int on) static int bt_set_power(int on, unsigned long msec) { - PRINTM(MSG, "%s = %d\n", __FUNCTION__, on); + PRINTM(MSG, "%s = %d\n", __func__, on); if (bt_control_data && bt_control_data->set_power) bt_control_data->set_power(on); @@ -2280,6 +2359,45 @@ bt_set_power(int on, unsigned long msec) return 0; } +static irqreturn_t +bt_hostwake_isr(int irq, void *dev_id) +{ + PRINTM(INTR, "Recv hostwake isr\n"); + return IRQ_HANDLED; +} + +void +bt_enable_hostwake_irq(int flag) +{ + if (bt_irqres && irq_registered) { + PRINTM(INTR, "enable_hostwake_irq=%d\n", flag); + if (flag) { + enable_irq(bt_irqres->start); + enable_irq_wake(bt_irqres->start); + } else { + disable_irq_wake(bt_irqres->start); + disable_irq(bt_irqres->start); + } + } +} + +static void +bt_register_hostwake_irq(void *handle) +{ + if (bt_irqres && !irq_registered) { + irq_registered = + request_irq(bt_irqres->start, bt_hostwake_isr, + bt_irqres->flags, DRIVER_NAME, handle); + if (irq_registered < 0) + PRINTM(ERROR, "Couldn't acquire BT_HOST_WAKE IRQ\n"); + else { + irq_registered = 1; + enable_irq_wake(bt_irqres->start); + bt_enable_hostwake_irq(FALSE); + } + } +} + void mdev_poweroff(struct m_dev *m_dev) { @@ -2307,9 +2425,14 @@ bt_probe(struct platform_device *pdev) ENTER(); - bt_control_data = bt_ctrl; - bt_set_power(1, 0); /* Power On */ - bt_set_carddetect(1); /* CardDetect (0->1) */ + bt_irqres = platform_get_resource_byname(pdev, + IORESOURCE_IRQ, + IORESOURCE_NAME); + if (minicard_pwrup) { + bt_control_data = bt_ctrl; + bt_set_power(1, 0); /* Power On */ + bt_set_carddetect(1); /* CardDetect (0->1) */ + } LEAVE(); return 0; @@ -2329,9 +2452,16 @@ bt_remove(struct platform_device *pdev) ENTER(); - bt_control_data = bt_ctrl; - bt_set_power(0, 0); /* Power Off */ - bt_set_carddetect(0); /* CardDetect (1->0) */ + if (bt_irqres && irq_registered) { + PRINTM(MSG, "Free hostwake IRQ wakeup\n"); + free_irq(bt_irqres->start, NULL); + irq_registered = 0; + } + if (minicard_pwrup) { + bt_control_data = bt_ctrl; + bt_set_power(0, 0); /* Power Off */ + bt_set_carddetect(0); /* CardDetect (1->0) */ + } LEAVE(); return 0; @@ -2357,8 +2487,7 @@ bt_add_dev(void) ENTER(); - if (minicard_pwrup) - ret = platform_driver_register(&bt_device); + ret = platform_driver_register(&bt_device); LEAVE(); return ret; @@ -2374,8 +2503,7 @@ bt_del_dev(void) { ENTER(); - if (minicard_pwrup) - platform_driver_unregister(&bt_device); + platform_driver_unregister(&bt_device); LEAVE(); } @@ -2461,6 +2589,8 @@ module_param(init_cfg, charp, 0); MODULE_PARM_DESC(init_cfg, "BT init config file name"); module_param(cal_cfg, charp, 0); MODULE_PARM_DESC(cal_cfg, "BT calibrate file name"); +module_param(cal_cfg_ext, charp, 0); +MODULE_PARM_DESC(cal_cfg_ext, "BT calibrate ext file name"); module_param(bt_mac, charp, 0); MODULE_PARM_DESC(bt_mac, "BT init mac address"); module_param(minicard_pwrup, int, 0); diff --git a/drivers/bluetooth/sd8797/bt/bt_proc.c b/drivers/bluetooth/sd8797/bt/bt_proc.c index 74007eb7bd1f..ad9a6e9cd23d 100644 --- a/drivers/bluetooth/sd8797/bt/bt_proc.c +++ b/drivers/bluetooth/sd8797/bt/bt_proc.c @@ -71,12 +71,12 @@ struct proc_data { /** Device size */ #define item_dev_size(n) (sizeof((bt_dev_t *)0)->n) /** Device address */ -#define item_dev_addr(n) ((t_ptr) & ((bt_dev_t *)0)->n) +#define item_dev_addr(n) ((t_ptr) &((bt_dev_t *)0)->n) /** Adapter size */ #define item_adapter_size(n) (sizeof((bt_adapter *)0)->n) /** Adapter address */ -#define item_adapter_addr(n) ((t_ptr) & ((bt_adapter *)0)->n) +#define item_adapter_addr(n) ((t_ptr) &((bt_adapter *)0)->n) static struct item_data config_items[] = { #ifdef DEBUG_LEVEL1 @@ -233,23 +233,19 @@ parse_cmd52_string(const char __user * buffer, size_t len, /* Get func */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *func = string_to_number(pos); - } /* Get reg */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *reg = string_to_number(pos); - } /* Get val (optional) */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *val = string_to_number(pos); - } - if (string) - kfree(string); + kfree(string); LEAVE(); return ret; } diff --git a/drivers/bluetooth/sd8797/bt/bt_sdio.h b/drivers/bluetooth/sd8797/bt/bt_sdio.h index 2c542d58b49f..541d5f4b81e4 100644 --- a/drivers/bluetooth/sd8797/bt/bt_sdio.h +++ b/drivers/bluetooth/sd8797/bt/bt_sdio.h @@ -27,7 +27,7 @@ /** IRQ return type */ typedef irqreturn_t IRQ_RET_TYPE; /** IRQ return */ -#define IRQ_RET return IRQ_HANDLED +#define IRQ_RET (return IRQ_HANDLED) /** ISR notifier function */ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, struct pt_regs * reg); @@ -60,7 +60,7 @@ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, /** Host Control Registers : Configuration */ #define CONFIGURATION_REG 0x00 /** Host Control Registers : Host without Command 53 finish host*/ -#define HOST_TO_CARD_EVENT (0x1U << 3) +#define HOST_TO_CARD_EVENT (0x1U << 3) /** Host Control Registers : Host without Command 53 finish host */ #define HOST_WO_CMD53_FINISH_HOST (0x1U << 2) /** Host Control Registers : Host power up */ @@ -97,80 +97,80 @@ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, /** Host Control Registers : Upload CRC error */ #define UP_LD_CRC_ERR (0x1U << 2) /** Host Control Registers : Upload restart */ -#define UP_LD_RESTART (0x1U << 1) +#define UP_LD_RESTART (0x1U << 1) /** Host Control Registers : Download restart */ -#define DN_LD_RESTART (0x1U << 0) +#define DN_LD_RESTART (0x1U << 0) /* Card Control Registers */ /** Card Control Registers : Read SQ base address A0 register */ -#define SQ_READ_BASE_ADDRESS_A0_REG 0x40 +#define SQ_READ_BASE_ADDRESS_A0_REG 0x40 /** Card Control Registers : Read SQ base address A1 register */ -#define SQ_READ_BASE_ADDRESS_A1_REG 0x41 +#define SQ_READ_BASE_ADDRESS_A1_REG 0x41 /** Card Control Registers : Read SQ base address A2 register */ -#define SQ_READ_BASE_ADDRESS_A2_REG 0x42 +#define SQ_READ_BASE_ADDRESS_A2_REG 0x42 /** Card Control Registers : Read SQ base address A3 register */ -#define SQ_READ_BASE_ADDRESS_A3_REG 0x43 +#define SQ_READ_BASE_ADDRESS_A3_REG 0x43 /** Card Control Registers : Read SQ base address B0 register */ -#define SQ_READ_BASE_ADDRESS_B0_REG 0x44 +#define SQ_READ_BASE_ADDRESS_B0_REG 0x44 /** Card Control Registers : Read SQ base address B1 register */ -#define SQ_READ_BASE_ADDRESS_B1_REG 0x45 +#define SQ_READ_BASE_ADDRESS_B1_REG 0x45 /** Card Control Registers : Read SQ base address B2 register */ -#define SQ_READ_BASE_ADDRESS_B2_REG 0x46 +#define SQ_READ_BASE_ADDRESS_B2_REG 0x46 /** Card Control Registers : Read SQ base address B3 register */ -#define SQ_READ_BASE_ADDRESS_B3_REG 0x47 +#define SQ_READ_BASE_ADDRESS_B3_REG 0x47 /** Card Control Registers : Card status register */ -#define CARD_STATUS_REG 0x30 +#define CARD_STATUS_REG 0x30 /** Card Control Registers : Card I/O ready */ -#define CARD_IO_READY (0x1U << 3) +#define CARD_IO_READY (0x1U << 3) /** Card Control Registers : CIS card ready */ -#define CIS_CARD_RDY (0x1U << 2) +#define CIS_CARD_RDY (0x1U << 2) /** Card Control Registers : Upload card ready */ -#define UP_LD_CARD_RDY (0x1U << 1) +#define UP_LD_CARD_RDY (0x1U << 1) /** Card Control Registers : Download card ready */ -#define DN_LD_CARD_RDY (0x1U << 0) +#define DN_LD_CARD_RDY (0x1U << 0) /** Card Control Registers : Host interrupt mask register */ -#define HOST_INTERRUPT_MASK_REG 0x34 +#define HOST_INTERRUPT_MASK_REG 0x34 /** Card Control Registers : Host power interrupt mask */ -#define HOST_POWER_INT_MASK (0x1U << 3) +#define HOST_POWER_INT_MASK (0x1U << 3) /** Card Control Registers : Abort card interrupt mask */ -#define ABORT_CARD_INT_MASK (0x1U << 2) +#define ABORT_CARD_INT_MASK (0x1U << 2) /** Card Control Registers : Upload card interrupt mask */ -#define UP_LD_CARD_INT_MASK (0x1U << 1) +#define UP_LD_CARD_INT_MASK (0x1U << 1) /** Card Control Registers : Download card interrupt mask */ -#define DN_LD_CARD_INT_MASK (0x1U << 0) +#define DN_LD_CARD_INT_MASK (0x1U << 0) /** Card Control Registers : Card interrupt status register */ -#define CARD_INTERRUPT_STATUS_REG 0x38 +#define CARD_INTERRUPT_STATUS_REG 0x38 /** Card Control Registers : Power up interrupt */ -#define POWER_UP_INT (0x1U << 4) +#define POWER_UP_INT (0x1U << 4) /** Card Control Registers : Power down interrupt */ -#define POWER_DOWN_INT (0x1U << 3) +#define POWER_DOWN_INT (0x1U << 3) /** Card Control Registers : Card interrupt RSR register */ -#define CARD_INTERRUPT_RSR_REG 0x3c +#define CARD_INTERRUPT_RSR_REG 0x3c /** Card Control Registers : Power up RSR */ -#define POWER_UP_RSR (0x1U << 4) +#define POWER_UP_RSR (0x1U << 4) /** Card Control Registers : Power down RSR */ -#define POWER_DOWN_RSR (0x1U << 3) +#define POWER_DOWN_RSR (0x1U << 3) /** Card Control Registers : Debug 0 register */ -#define DEBUG_0_REG 0x70 +#define DEBUG_0_REG 0x70 /** Card Control Registers : SD test BUS 0 */ -#define SD_TESTBUS0 (0x1U) +#define SD_TESTBUS0 (0x1U) /** Card Control Registers : Debug 1 register */ -#define DEBUG_1_REG 0x71 +#define DEBUG_1_REG 0x71 /** Card Control Registers : SD test BUS 1 */ -#define SD_TESTBUS1 (0x1U) +#define SD_TESTBUS1 (0x1U) /** Card Control Registers : Debug 2 register */ -#define DEBUG_2_REG 0x72 +#define DEBUG_2_REG 0x72 /** Card Control Registers : SD test BUS 2 */ -#define SD_TESTBUS2 (0x1U) +#define SD_TESTBUS2 (0x1U) /** Card Control Registers : Debug 3 register */ -#define DEBUG_3_REG 0x73 +#define DEBUG_3_REG 0x73 /** Card Control Registers : SD test BUS 3 */ -#define SD_TESTBUS3 (0x1U) +#define SD_TESTBUS3 (0x1U) /** Host Control Registers : I/O port 0 */ #define IO_PORT_0_REG 0x78 @@ -188,24 +188,24 @@ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, /** Rx unit register */ #define CARD_RX_UNIT_REG 0x63 /** Card Control Registers : Miscellaneous Configuration Register */ -#define CARD_MISC_CFG_REG 0x6C +#define CARD_MISC_CFG_REG 0x6C /** Misc. Config Register : Auto Re-enable interrupts */ #define AUTO_RE_ENABLE_INT (0x1U << 4) /** Card Control Registers : Card OCR 0 register */ -#define CARD_OCR_0_REG 0x68 +#define CARD_OCR_0_REG 0x68 /** Card Control Registers : Card OCR 1 register */ -#define CARD_OCR_1_REG 0x69 +#define CARD_OCR_1_REG 0x69 /** Card Control Registers : Card OCR 3 register */ -#define CARD_OCR_3_REG 0x6A +#define CARD_OCR_3_REG 0x6A /** Card Control Registers : Card config register */ -#define CARD_CONFIG_REG 0x6B +#define CARD_CONFIG_REG 0x6B /** Card Control Registers : Card revision register */ -#define CARD_REVISION_REG 0x5c +#define CARD_REVISION_REG 0x5c /** Card Control Registers : Command 53 finish G BUS */ -#define CMD53_FINISH_GBUS (0x1U << 1) +#define CMD53_FINISH_GBUS (0x1U << 1) /** Card Control Registers : SD negative edge */ -#define SD_NEG_EDGE (0x1U << 0) +#define SD_NEG_EDGE (0x1U << 0) /* Special registers in function 0 of the SDxx card */ /** Special register in function 0 of the SDxxx card : Scratch 0 */ @@ -244,6 +244,7 @@ struct sdio_mmc_card { int sd_read_cmd52_val(bt_private * priv); /** This function updates card reg based on the Cmd52 value in dev structure */ int sd_write_cmd52_val(bt_private * priv, int func, int reg, int val); +void bt_enable_hostwake_irq(int flag); #ifdef SDIO_SUSPEND_RESUME #ifdef MMC_PM_KEEP_POWER diff --git a/drivers/bluetooth/sd8797/bt/bt_sdiommc.c b/drivers/bluetooth/sd8797/bt/bt_sdiommc.c index 10bda897c177..3fdd23a6486c 100644 --- a/drivers/bluetooth/sd8797/bt/bt_sdiommc.c +++ b/drivers/bluetooth/sd8797/bt/bt_sdiommc.c @@ -71,7 +71,7 @@ extern int mbt_pm_keep_power; * @brief This function gets rx_unit value * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sd_get_rx_unit(bt_private * priv) @@ -95,7 +95,7 @@ sd_get_rx_unit(bt_private * priv) * * @param priv A pointer to bt_private structure * @param dat A pointer to keep returned data - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_read_firmware_status(bt_private * priv, u16 * dat) @@ -130,7 +130,7 @@ sd_read_firmware_status(bt_private * priv, u16 * dat) * * @param priv A pointer to bt_private structure * @param dat A pointer to keep returned data - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ static int sd_read_rx_len(bt_private * priv, u16 * dat) @@ -154,7 +154,7 @@ sd_read_rx_len(bt_private * priv, u16 * dat) * * @param priv A pointer to bt_private structure * @param mask the interrupt mask - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_enable_host_int_mask(bt_private * priv, u8 mask) @@ -178,7 +178,7 @@ sd_enable_host_int_mask(bt_private * priv, u8 mask) * * @param priv A pointer to bt_private structure * @param mask the interrupt mask - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ static int sd_disable_host_int_mask(bt_private * priv, u8 mask) @@ -210,9 +210,9 @@ done: /** * @brief This function polls the card status register * - * @param priv A pointer to bt_private structure - * @param bits the bit mask - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @param priv A pointer to bt_private structure + * @param bits the bit mask + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_poll_card_status(bt_private * priv, u8 bits) @@ -245,8 +245,8 @@ sd_poll_card_status(bt_private * priv, u8 bits) /** * @brief This function reads updates the Cmd52 value in dev structure * - * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or other error no. + * @param priv A pointer to bt_private structure + * @return BT_STATUS_SUCCESS or other error no. */ int sd_read_cmd52_val(bt_private * priv) @@ -279,11 +279,11 @@ sd_read_cmd52_val(bt_private * priv) /** * @brief This function updates card reg based on the Cmd52 value in dev structure * - * @param priv A pointer to bt_private structure - * @param func Stores func variable - * @param reg Stores reg variable - * @param val Stores val variable - * @return BT_STATUS_SUCCESS or other error no. + * @param priv A pointer to bt_private structure + * @param func Stores func variable + * @param reg Stores reg variable + * @param val Stores val variable + * @return BT_STATUS_SUCCESS or other error no. */ int sd_write_cmd52_val(bt_private * priv, int func, int reg, int val) @@ -323,8 +323,8 @@ done: * @brief This function probes the card * * @param func A pointer to sdio_func structure. - * @param id A pointer to structure sdio_device_id - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @param id A pointer to structure sdio_device_id + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ static int sd_probe_card(struct sdio_func *func, const struct sdio_device_id *id) @@ -412,7 +412,7 @@ sd_verify_fw_download(bt_private * priv, int pollnum) * @brief Transfers firmware to card * * @param priv A Pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ static int sd_init_fw_dpc(bt_private * priv) @@ -432,9 +432,6 @@ sd_init_fw_dpc(bt_private * priv) int tx_blocks = 0; int i = 0; int tries = 0; -#ifdef FW_DOWNLOAD_SPEED - u32 tv1, tv2; -#endif ENTER(); firmware = (u8 *) priv->firmware->data; @@ -442,10 +439,6 @@ sd_init_fw_dpc(bt_private * priv) PRINTM(INFO, "BT: Downloading FW image (%d bytes)\n", firmwarelen); -#ifdef FW_DOWNLOAD_SPEED - tv1 = get_utimeofday(); -#endif - tmpfwbufsz = BT_UPLD_SIZE + DMA_ALIGNMENT; tmpfwbuf = kmalloc(tmpfwbufsz, GFP_KERNEL); if (!tmpfwbuf) { @@ -566,18 +559,7 @@ sd_init_fw_dpc(bt_private * priv) ret = BT_STATUS_SUCCESS; done: -#ifdef FW_DOWNLOAD_SPEED - tv2 = get_utimeofday(); - PRINTM(INFO, "FW: %d.%03d.%03d ", tv1 / 1000000, - (tv1 % 1000000) / 1000, tv1 % 1000); - PRINTM(INFO, " -> %d.%03d.%03d ", tv2 / 1000000, - (tv2 % 1000000) / 1000, tv2 % 1000); - tv2 -= tv1; - PRINTM(INFO, " == %d.%03d.%03d\n", tv2 / 1000000, - (tv2 % 1000000) / 1000, tv2 % 1000); -#endif - if (tmpfwbuf) - kfree(tmpfwbuf); + kfree(tmpfwbuf); LEAVE(); return ret; } @@ -682,9 +664,8 @@ done: /* Stop the thread servicing the interrupts */ priv->adapter->SurpriseRemoved = TRUE; wake_up_interruptible(&priv->MainThread.waitQ); - while (priv->MainThread.pid) { + while (priv->MainThread.pid) os_sched_timeout(1); - } if (m_dev_bt->dev_pointer) { if (m_dev_bt->spec_type == IANYWHERE_SPEC) free_m_dev(m_dev_bt); @@ -720,8 +701,8 @@ sd_request_fw_callback(const struct firmware *firmware, void *context) /** * @brief This function downloads firmware image to the card. * - * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @param priv A pointer to bt_private structure + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sd_download_firmware_w_helper(bt_private * priv) @@ -769,7 +750,7 @@ sd_download_firmware_w_helper(bt_private * priv) * @brief This function reads data from the card. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_card_to_host(bt_private * priv) @@ -1073,7 +1054,7 @@ sd_interrupt(struct sdio_func *func) if (!card || !card->priv) { PRINTM(INFO, "BT: %s: sbi_interrupt(%p) card or priv is NULL, card=%p\n", - __FUNCTION__, func, card); + __func__, func, card); LEAVE(); return; } @@ -1152,7 +1133,7 @@ bt_is_suspended(bt_private * priv) /** @brief This function handles client driver suspend * * @param dev A pointer to device structure - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ int bt_sdio_suspend(struct device *dev) @@ -1206,6 +1187,9 @@ bt_sdio_suspend(struct device *dev) skb_queue_purge(&priv->adapter->tx_queue); priv->adapter->is_suspended = TRUE; + + bt_enable_hostwake_irq(TRUE); + LEAVE(); /* We will keep the power when hs enabled successfully */ if ((mbt_pm_keep_power) && (priv->adapter->hs_state == HS_ACTIVATED)) { @@ -1228,7 +1212,7 @@ bt_sdio_suspend(struct device *dev) /** @brief This function handles client driver resume * * @param dev A pointer to device structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int bt_sdio_resume(struct device *dev) @@ -1241,6 +1225,7 @@ bt_sdio_resume(struct device *dev) ENTER(); if (func) { + bt_enable_hostwake_irq(FALSE); pm_flags = sdio_get_host_pm_caps(func); PRINTM(CMD, "BT: %s: resume: PM flags = 0x%x\n", sdio_func_id(func), pm_flags); @@ -1312,7 +1297,7 @@ sbi_register(void) ENTER(); if (sdio_register_driver(&sdio_bt) != 0) { - PRINTM(FATAL, "BT: SD Driver Registration Failed \n"); + PRINTM(FATAL, "BT: SD Driver Registration Failed\n"); LEAVE(); return NULL; } else @@ -1325,7 +1310,7 @@ sbi_register(void) /** * @brief This function de-registers the bt module in bus driver. * - * @return N/A + * @return N/A */ void sbi_unregister(void) @@ -1340,7 +1325,7 @@ sbi_unregister(void) * @brief This function registers the device. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_register_dev(bt_private * priv) @@ -1375,8 +1360,7 @@ sbi_register_dev(bt_private * priv) } ret = sdio_set_block_size(card->func, SD_BLOCK_SIZE); if (ret) { - PRINTM(FATAL, ": %s: cannot set SDIO block size\n", - __FUNCTION__); + PRINTM(FATAL, ": %s: cannot set SDIO block size\n", __func__); goto release_irq; } @@ -1454,7 +1438,7 @@ failed: * @brief This function de-registers the device. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int sbi_unregister_dev(bt_private * priv) @@ -1479,7 +1463,7 @@ sbi_unregister_dev(bt_private * priv) * @brief This function enables the host interrupts. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sd_enable_host_int(bt_private * priv) @@ -1506,7 +1490,7 @@ sd_enable_host_int(bt_private * priv) * @brief This function disables the host interrupts. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sd_disable_host_int(bt_private * priv) @@ -1533,8 +1517,8 @@ sd_disable_host_int(bt_private * priv) * * @param priv A pointer to bt_private structure * @param payload A pointer to the data/cmd buffer - * @param nb Length of data/cmd - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @param nb Length of data/cmd + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_host_to_card(bt_private * priv, u8 * payload, u16 nb) @@ -1609,7 +1593,7 @@ exit: * @brief This function downloads firmware * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_download_fw(bt_private * priv) @@ -1699,7 +1683,7 @@ err_register: * @brief This function checks the interrupt status and handle it accordingly. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int sbi_get_int_status(bt_private * priv) @@ -1738,7 +1722,7 @@ sbi_get_int_status(bt_private * priv) * @brief This function wakeup firmware * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sbi_wakeup_firmware(bt_private * priv) diff --git a/drivers/bluetooth/sd8897/bt/bt_drv.h b/drivers/bluetooth/sd8897/bt/bt_drv.h index 8e6f21f501cb..2a8f8f5fbcf3 100644 --- a/drivers/bluetooth/sd8897/bt/bt_drv.h +++ b/drivers/bluetooth/sd8897/bt/bt_drv.h @@ -96,11 +96,14 @@ extern u32 mbt_drvdbg; #ifdef DEBUG_LEVEL2 /** Print informative message */ -#define PRINTM_INFO(msg...) do {if (mbt_drvdbg & DBG_INFO) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_INFO(msg...) do {if (mbt_drvdbg & DBG_INFO) \ + printk(KERN_DEBUG msg); } while (0) /** Print warning message */ -#define PRINTM_WARN(msg...) do {if (mbt_drvdbg & DBG_WARN) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_WARN(msg...) do {if (mbt_drvdbg & DBG_WARN) \ + printk(KERN_DEBUG msg); } while (0) /** Print entry message */ -#define PRINTM_ENTRY(msg...) do {if (mbt_drvdbg & DBG_ENTRY) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_ENTRY(msg...) do {if (mbt_drvdbg & DBG_ENTRY) \ + printk(KERN_DEBUG msg); } while (0) #else /** Print informative message */ #define PRINTM_INFO(msg...) do {} while (0) @@ -111,24 +114,33 @@ extern u32 mbt_drvdbg; #endif /* DEBUG_LEVEL2 */ /** Print interrupt message */ -#define PRINTM_INTR(msg...) do {if (mbt_drvdbg & DBG_INTR) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_INTR(msg...) do {if (mbt_drvdbg & DBG_INTR) \ + printk(KERN_DEBUG msg); } while (0) /** Print event message */ -#define PRINTM_EVENT(msg...) do {if (mbt_drvdbg & DBG_EVENT) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_EVENT(msg...) do {if (mbt_drvdbg & DBG_EVENT) \ + printk(KERN_DEBUG msg); } while (0) /** Print command message */ -#define PRINTM_CMD(msg...) do {if (mbt_drvdbg & DBG_CMD) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_CMD(msg...) do {if (mbt_drvdbg & DBG_CMD) \ + printk(KERN_DEBUG msg); } while (0) /** Print data message */ -#define PRINTM_DATA(msg...) do {if (mbt_drvdbg & DBG_DATA) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_DATA(msg...) do {if (mbt_drvdbg & DBG_DATA) \ + printk(KERN_DEBUG msg); } while (0) /** Print error message */ -#define PRINTM_ERROR(msg...) do {if (mbt_drvdbg & DBG_ERROR) printk(KERN_ERR msg); } while (0) +#define PRINTM_ERROR(msg...) do {if (mbt_drvdbg & DBG_ERROR) \ + printk(KERN_ERR msg); } while (0) /** Print fatal message */ -#define PRINTM_FATAL(msg...) do {if (mbt_drvdbg & DBG_FATAL) printk(KERN_ERR msg); } while (0) +#define PRINTM_FATAL(msg...) do {if (mbt_drvdbg & DBG_FATAL) \ + printk(KERN_ERR msg); } while (0) /** Print message */ -#define PRINTM_MSG(msg...) do {if (mbt_drvdbg & DBG_MSG) printk(KERN_ALERT msg); } while (0) +#define PRINTM_MSG(msg...) do {if (mbt_drvdbg & DBG_MSG) \ + printk(KERN_ALERT msg); } while (0) /** Print data dump message */ -#define PRINTM_DAT_D(msg...) do {if (mbt_drvdbg & DBG_DAT_D) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_DAT_D(msg...) do {if (mbt_drvdbg & DBG_DAT_D) \ + printk(KERN_DEBUG msg); } while (0) /** Print data dump message */ -#define PRINTM_CMD_D(msg...) do {if (mbt_drvdbg & DBG_CMD_D) printk(KERN_DEBUG msg); } while (0) +#define PRINTM_CMD_D(msg...) do {if (mbt_drvdbg & DBG_CMD_D) \ + printk(KERN_DEBUG msg); } while (0) /** Print message with required level */ #define PRINTM(level, msg...) PRINTM_##level(msg) @@ -164,28 +176,30 @@ hexdump(char *prompt, u8 * buf, int len) } /** Debug hexdump of debug data */ -#define DBG_HEXDUMP_DAT_D(x, y, z) do {if (mbt_drvdbg & DBG_DAT_D) hexdump(x, y, z); } while (0) +#define DBG_HEXDUMP_DAT_D(x, y, z) do {if (mbt_drvdbg & DBG_DAT_D) \ + hexdump(x, y, z); } while (0) /** Debug hexdump of debug command */ -#define DBG_HEXDUMP_CMD_D(x, y, z) do {if (mbt_drvdbg & DBG_CMD_D) hexdump(x, y, z); } while (0) +#define DBG_HEXDUMP_CMD_D(x, y, z) do {if (mbt_drvdbg & DBG_CMD_D) \ + hexdump(x, y, z); } while (0) /** Debug hexdump */ #define DBG_HEXDUMP(level, x, y, z) DBG_HEXDUMP_##level(x, y, z) /** Mark entry point */ -#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __FUNCTION__, \ +#define ENTER() PRINTM(ENTRY, "Enter: %s, %s:%i\n", __func__, \ __FILE__, __LINE__) /** Mark exit point */ -#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __FUNCTION__, \ +#define LEAVE() PRINTM(ENTRY, "Leave: %s, %s:%i\n", __func__, \ __FILE__, __LINE__) #else /** Do nothing */ -#define PRINTM(level, msg...) do {} while (0); +#define PRINTM(level, msg...) do {} while (0) /** Do nothing */ -#define DBG_HEXDUMP(level, x, y, z) do {} while (0); +#define DBG_HEXDUMP(level, x, y, z) do {} while (0) /** Do nothing */ -#define ENTER() do {} while (0); +#define ENTER() do {} while (0) /** Do nothing */ -#define LEAVE() do {} while (0); +#define LEAVE() do {} while (0) #endif /* DEBUG_LEVEL1 */ /** Bluetooth upload size */ @@ -278,7 +292,7 @@ os_sched_timeout(u32 millisec) #endif #ifndef __ATTRIB_PACK__ -#define __ATTRIB_PACK__ __attribute__ ((packed)) +#define __ATTRIB_PACK__ __attribute__((packed)) #endif /** Data structure for the Marvell Bluetooth device */ @@ -453,9 +467,11 @@ typedef struct _bt_private { } bt_private, *pbt_private; /** Disable interrupt */ -#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, priv->driver_flags) +#define OS_INT_DISABLE spin_lock_irqsave(&priv->driver_lock, \ + priv->driver_flags) /** Enable interrupt */ -#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, priv->driver_flags) +#define OS_INT_RESTORE spin_unlock_irqrestore(&priv->driver_lock, \ + priv->driver_flags) #ifndef HCI_BT_AMP /** BT_AMP flag for device type */ @@ -586,7 +602,7 @@ typedef struct _BT_CMD { /** Length */ u8 length; /** Data */ - u8 data[32]; + u8 data[128]; } __ATTRIB_PACK__ BT_CMD; typedef struct _BT_EVENT { @@ -671,6 +687,8 @@ int sd_download_firmware_w_helper(bt_private * priv); #define BT_CMD_CSU_WRITE_REG 0x66 /** Bluetooth command : Load calibrate data */ #define BT_CMD_LOAD_CONFIG_DATA 0x61 +/** Bluetooth command : Load calibrate ext data */ +#define BT_CMD_LOAD_CONFIG_DATA_EXT 0x60 /** Bluetooth command : BLE deepsleep */ #define BT_CMD_BLE_DEEP_SLEEP 0x8b @@ -705,8 +723,12 @@ int bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value); int bt_init_config(bt_private * priv, char *cfg_file); /** This function load the calibrate data */ int bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac); +/** This function load the calibrate ext data */ +int bt_load_cal_data_ext(bt_private * priv, u8 * config_data, u32 cfg_data_len); /** BT set user defined calibration data */ int bt_cal_config(bt_private * priv, char *cfg_file, char *mac); +/** BT set user defined calibration ext data */ +int bt_cal_config_ext(bt_private * priv, char *cfg_file); int bt_init_mac_address(bt_private * priv, char *mac); typedef struct _BT_HCI_CMD { diff --git a/drivers/bluetooth/sd8897/bt/bt_init.c b/drivers/bluetooth/sd8897/bt/bt_init.c index 55481d520a3d..13d7ed300974 100644 --- a/drivers/bluetooth/sd8897/bt/bt_init.c +++ b/drivers/bluetooth/sd8897/bt/bt_init.c @@ -200,10 +200,11 @@ bt_atoi(int *data, char *a) * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int -bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) +bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 * dst_size) { const u8 *ptr; u8 *dptr; + u32 count = 0; int ret = BT_STATUS_FAILURE; ENTER(); @@ -217,12 +218,13 @@ bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) } if (isxdigit(*ptr)) { - if ((dptr - dst) >= dst_size) { + if ((dptr - dst) >= *dst_size) { PRINTM(ERROR, "cal_file size too big!!!\n"); goto done; } *dptr++ = bt_atox(ptr); ptr += 2; + count++; } else { ptr++; } @@ -232,6 +234,7 @@ bt_parse_cal_cfg(const u8 * src, u32 len, u8 * dst, u32 dst_size) goto done; } + *dst_size = count; ret = BT_STATUS_SUCCESS; done: LEAVE(); @@ -497,11 +500,13 @@ bt_process_cal_cfg(bt_private * priv, u8 * data, u32 size, char *mac) u8 bt_mac[ETH_ALEN]; u8 cal_data[32]; u8 *mac_data = NULL; + u32 cal_data_len; int ret = BT_STATUS_FAILURE; memset(bt_mac, 0, sizeof(bt_mac)); + cal_data_len = sizeof(cal_data); if (BT_STATUS_SUCCESS != - bt_parse_cal_cfg(data, size, cal_data, sizeof(cal_data))) { + bt_parse_cal_cfg(data, size, cal_data, &cal_data_len)) { goto done; } if (mac != NULL) { @@ -523,6 +528,39 @@ done: } /** + * @brief BT process calibration EXT data + * + * @param priv a pointer to bt_private structure + * @param data a pointer to cal data + * @param size cal data size + * @param mac mac address buf + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_process_cal_cfg_ext(bt_private * priv, u8 * data, u32 size) +{ + u8 cal_data[128]; + u32 cal_data_len; + int ret = BT_STATUS_FAILURE; + + cal_data_len = sizeof(cal_data); + if (BT_STATUS_SUCCESS != + bt_parse_cal_cfg(data, size, cal_data, &cal_data_len)) { + goto done; + } + if (BT_STATUS_SUCCESS != + bt_load_cal_data_ext(priv, cal_data, cal_data_len)) { + PRINTM(FATAL, "BT: Fail to load calibrate data\n"); + goto done; + } + ret = BT_STATUS_SUCCESS; + +done: + LEAVE(); + return ret; +} + +/** * @brief BT process calibration file * * @param priv a pointer to bt_private structure @@ -555,6 +593,37 @@ done: } /** + * @brief BT process calibration EXT file + * + * @param priv a pointer to bt_private structure + * @param cal_file calibration file name + * @param mac mac address buf + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_cal_config_ext(bt_private * priv, char *cal_file) +{ + const struct firmware *cfg = NULL; + int ret = BT_STATUS_SUCCESS; + + ENTER(); + if ((request_firmware(&cfg, cal_file, priv->hotplug_device)) < 0) { + PRINTM(FATAL, "BT: request_firmware() %s failed\n", cal_file); + ret = BT_STATUS_FAILURE; + goto done; + } + if (cfg) + ret = bt_process_cal_cfg_ext(priv, (u8 *) cfg->data, cfg->size); + else + ret = BT_STATUS_FAILURE; +done: + if (cfg) + release_firmware(cfg); + LEAVE(); + return ret; +} + +/** * @brief BT init mac address from bt_mac parametre when insmod * * @param priv a pointer to bt_private structure diff --git a/drivers/bluetooth/sd8897/bt/bt_main.c b/drivers/bluetooth/sd8897/bt/bt_main.c index 3707d8d86b41..7e79962de61a 100644 --- a/drivers/bluetooth/sd8897/bt/bt_main.c +++ b/drivers/bluetooth/sd8897/bt/bt_main.c @@ -37,6 +37,8 @@ #include <linux/platform_device.h> #include <linux/wlan_plat.h> +#include <linux/interrupt.h> + #include "bt_drv.h" #include "mbt_char.h" #include "bt_sdio.h" @@ -90,6 +92,8 @@ static int psmode = 1; static char *init_cfg; /** Calibration config file (MAC address, init powe etc.) */ static char *cal_cfg; +/** Calibration config file EXT */ +static char *cal_cfg_ext; /** Init MAC address */ static char *bt_mac; @@ -115,7 +119,13 @@ static int minicard_pwrup = 1; /** Pointer to struct with control hooks */ static struct wifi_platform_data *bt_control_data; +#define IORESOURCE_NAME "mrvl_bt_irq" +#define DRIVER_NAME "bt hostwake" + void mdev_poweroff(struct m_dev *m_dev); +static struct resource *bt_irqres; +static int irq_registered; +static void bt_register_hostwake_irq(void *handle); /** * @brief Alloc bt device @@ -258,6 +268,7 @@ check_evtpkt(bt_private * priv, struct sk_buff *skb) case BT_CMD_CONFIG_MAC_ADDR: case BT_CMD_CSU_WRITE_REG: case BT_CMD_LOAD_CONFIG_DATA: + case BT_CMD_LOAD_CONFIG_DATA_EXT: case BT_CMD_AUTO_SLEEP_MODE: case BT_CMD_HOST_SLEEP_CONFIG: case BT_CMD_SDIO_PULL_CFG_REQ: @@ -330,19 +341,19 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) { u8 ret = BT_STATUS_SUCCESS; struct m_dev *m_dev = &(priv->bt_dev.m_dev[BT_SEQ]); - BT_EVENT *pEvent; + BT_EVENT *pevent; ENTER(); - pEvent = (BT_EVENT *) skb->data; - if (pEvent->EC != 0xff) { - PRINTM(CMD, "BT: Not Marvell Event=0x%x\n", pEvent->EC); + pevent = (BT_EVENT *) skb->data; + if (pevent->EC != 0xff) { + PRINTM(CMD, "BT: Not Marvell Event=0x%x\n", pevent->EC); ret = BT_STATUS_FAILURE; goto exit; } - switch (pEvent->data[0]) { + switch (pevent->data[0]) { case BT_CMD_AUTO_SLEEP_MODE: - if (pEvent->data[2] == BT_STATUS_SUCCESS) { - if (pEvent->data[1] == BT_PS_ENABLE) + if (pevent->data[2] == BT_STATUS_SUCCESS) { + if (pevent->data[1] == BT_PS_ENABLE) priv->adapter->psmode = 1; else priv->adapter->psmode = 0; @@ -355,16 +366,16 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; case BT_CMD_HOST_SLEEP_CONFIG: - if (pEvent->data[3] == BT_STATUS_SUCCESS) { + if (pevent->data[3] == BT_STATUS_SUCCESS) { PRINTM(CMD, "BT: %s: gpio=0x%x, gap=0x%x\n", - m_dev->name, pEvent->data[1], pEvent->data[2]); + m_dev->name, pevent->data[1], pevent->data[2]); } else { PRINTM(CMD, "BT: %s: HSCFG Command Fail\n", m_dev->name); } break; case BT_CMD_HOST_SLEEP_ENABLE: - if (pEvent->data[1] == BT_STATUS_SUCCESS) { + if (pevent->data[1] == BT_STATUS_SUCCESS) { priv->adapter->hs_state = HS_ACTIVATED; if (priv->adapter->suspend_fail == FALSE) { #ifdef SDIO_SUSPEND_RESUME @@ -388,45 +399,44 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) break; case BT_CMD_MODULE_CFG_REQ: if ((priv->bt_dev.sendcmdflag == TRUE) && - ((pEvent->data[1] == MODULE_BRINGUP_REQ) - || (pEvent->data[1] == MODULE_SHUTDOWN_REQ))) { - if (pEvent->data[1] == MODULE_BRINGUP_REQ) { + ((pevent->data[1] == MODULE_BRINGUP_REQ) + || (pevent->data[1] == MODULE_SHUTDOWN_REQ))) { + if (pevent->data[1] == MODULE_BRINGUP_REQ) { PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, - (pEvent->data[2] && (pEvent->data[2] != + (pevent->data[2] && (pevent->data[2] != MODULE_CFG_RESP_ALREADY_UP)) ? "Bring up Fail" : "Bring up success"); - priv->bt_dev.devType = pEvent->data[3]; + priv->bt_dev.devType = pevent->data[3]; PRINTM(CMD, "devType:%s\n", - (pEvent->data[3] == + (pevent->data[3] == DEV_TYPE_AMP) ? "AMP controller" : "BR/EDR controller"); - priv->bt_dev.devFeature = pEvent->data[4]; + priv->bt_dev.devFeature = pevent->data[4]; PRINTM(CMD, "devFeature: %s, %s, %s, %s, %s\n", - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BT) ? "BT Feature" : "No BT Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BTAMP) ? "BTAMP Feature" : "No BTAMP Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_BLE) ? "BLE Feature" : "No BLE Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_FM) ? "FM Feature" : "No FM Feature"), - ((pEvent-> + ((pevent-> data[4] & DEV_FEATURE_NFC) ? "NFC Feature" : "No NFC Feature")); } - if (pEvent->data[1] == MODULE_SHUTDOWN_REQ) { + if (pevent->data[1] == MODULE_SHUTDOWN_REQ) { PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, - (pEvent-> - data[2]) ? "Shut down Fail" : - "Shut down success"); + (pevent->data[2]) ? "Shut down Fail" + : "Shut down success"); } - if (pEvent->data[2]) { + if (pevent->data[2]) { priv->bt_dev.sendcmdflag = FALSE; priv->adapter->cmd_complete = TRUE; wake_up_interruptible(&priv->adapter-> @@ -438,14 +448,14 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; case BT_EVENT_POWER_STATE: - if (pEvent->data[1] == BT_PS_SLEEP) + if (pevent->data[1] == BT_PS_SLEEP) priv->adapter->ps_state = PS_SLEEP; PRINTM(CMD, "BT: EVENT %s:%s\n", m_dev->name, (priv->adapter->ps_state) ? "PS_SLEEP" : "PS_AWAKE"); break; case BT_CMD_SDIO_PULL_CFG_REQ: - if (pEvent->data[pEvent->length - 1] == BT_STATUS_SUCCESS) + if (pevent->data[pevent->length - 1] == BT_STATUS_SUCCESS) PRINTM(CMD, "BT: %s: SDIO pull configuration success\n", m_dev->name); @@ -456,7 +466,7 @@ bt_process_event(bt_private * priv, struct sk_buff *skb) } break; default: - PRINTM(CMD, "BT: Unknown Event=%d %s\n", pEvent->data[0], + PRINTM(CMD, "BT: Unknown Event=%d %s\n", pevent->data[0], m_dev->name); ret = BT_STATUS_FAILURE; break; @@ -509,14 +519,14 @@ bt_cmd_timeout_func(bt_adapter * adapter, u16 cmd) * * @param priv A pointer to bt_private structure * - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int bt_send_reset_command(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -524,10 +534,10 @@ bt_send_reset_command(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (RESET_OGF << 10) | BT_CMD_RESET; - pCmd->length = 0x00; - pCmd->cmd_type = 0x00; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (RESET_OGF << 10) | BT_CMD_RESET; + pcmd->length = 0x00; + pcmd->cmd_type = 0x00; bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; skb_put(skb, 3); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -535,7 +545,7 @@ bt_send_reset_command(bt_private * priv) priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_RESET; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "Queue Reset Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue Reset Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -570,7 +580,7 @@ bt_send_module_cfg_cmd(bt_private * priv, int subcmd) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -578,18 +588,18 @@ bt_send_module_cfg_cmd(bt_private * priv, int subcmd) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_MODULE_CFG_REQ; - pCmd->length = 1; - pCmd->data[0] = subcmd; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_MODULE_CFG_REQ; + pcmd->length = 1; + pcmd->data[0] = subcmd; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_MODULE_CFG_REQ; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "Queue module cfg Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue module cfg Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); /* On some Android platforms certain delay is needed for HCI daemon to @@ -624,7 +634,7 @@ bt_enable_ps(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -632,25 +642,25 @@ bt_enable_ps(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_AUTO_SLEEP_MODE; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_AUTO_SLEEP_MODE; if (priv->bt_dev.psmode) - pCmd->data[0] = BT_PS_ENABLE; + pcmd->data[0] = BT_PS_ENABLE; else - pCmd->data[0] = BT_PS_DISABLE; + pcmd->data[0] = BT_PS_DISABLE; if (priv->bt_dev.idle_timeout) { - pCmd->length = 3; - pCmd->data[1] = (u8) (priv->bt_dev.idle_timeout & 0x00ff); - pCmd->data[2] = (priv->bt_dev.idle_timeout & 0xff00) >> 8; + pcmd->length = 3; + pcmd->data[1] = (u8) (priv->bt_dev.idle_timeout & 0x00ff); + pcmd->data[2] = (priv->bt_dev.idle_timeout & 0xff00) >> 8; } else { - pCmd->length = 1; + pcmd->length = 1; } bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); - PRINTM(CMD, "Queue PSMODE Command(0x%x):%d\n", pCmd->ocf_ogf, - pCmd->data[0]); + PRINTM(CMD, "Queue PSMODE Command(0x%x):%d\n", pcmd->ocf_ogf, + pcmd->data[0]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_AUTO_SLEEP_MODE; priv->adapter->cmd_complete = FALSE; @@ -678,7 +688,7 @@ bt_send_hscfg_cmd(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -686,17 +696,17 @@ bt_send_hscfg_cmd(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_CONFIG; - pCmd->length = 2; - pCmd->data[0] = (priv->bt_dev.gpio_gap & 0xff00) >> 8; - pCmd->data[1] = (u8) (priv->bt_dev.gpio_gap & 0x00ff); + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_CONFIG; + pcmd->length = 2; + pcmd->data[0] = (priv->bt_dev.gpio_gap & 0xff00) >> 8; + pcmd->data[1] = (u8) (priv->bt_dev.gpio_gap & 0x00ff); bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); PRINTM(CMD, "Queue HSCFG Command(0x%x),gpio=0x%x,gap=0x%x\n", - pCmd->ocf_ogf, pCmd->data[0], pCmd->data[1]); + pcmd->ocf_ogf, pcmd->data[0], pcmd->data[1]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_HOST_SLEEP_CONFIG; priv->adapter->cmd_complete = FALSE; @@ -724,7 +734,7 @@ bt_send_sdio_pull_ctrl_cmd(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -732,21 +742,21 @@ bt_send_sdio_pull_ctrl_cmd(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_SDIO_PULL_CFG_REQ; - pCmd->length = 4; - pCmd->data[0] = (priv->bt_dev.sdio_pull_cfg & 0x000000ff); - pCmd->data[1] = (priv->bt_dev.sdio_pull_cfg & 0x0000ff00) >> 8; - pCmd->data[2] = (priv->bt_dev.sdio_pull_cfg & 0x00ff0000) >> 16; - pCmd->data[3] = (priv->bt_dev.sdio_pull_cfg & 0xff000000) >> 24; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_SDIO_PULL_CFG_REQ; + pcmd->length = 4; + pcmd->data[0] = (priv->bt_dev.sdio_pull_cfg & 0x000000ff); + pcmd->data[1] = (priv->bt_dev.sdio_pull_cfg & 0x0000ff00) >> 8; + pcmd->data[2] = (priv->bt_dev.sdio_pull_cfg & 0x00ff0000) >> 16; + pcmd->data[3] = (priv->bt_dev.sdio_pull_cfg & 0xff000000) >> 24; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); PRINTM(CMD, "Queue SDIO PULL CFG Command(0x%x), PullUp=0x%x%x,PullDown=0x%x%x\n", - pCmd->ocf_ogf, pCmd->data[1], pCmd->data[0], - pCmd->data[3], pCmd->data[2]); + pcmd->ocf_ogf, pcmd->data[1], pcmd->data[0], + pcmd->data[3], pcmd->data[2]); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_SDIO_PULL_CFG_REQ; priv->adapter->cmd_complete = FALSE; @@ -778,7 +788,7 @@ fm_set_intr_mask(bt_private * priv, u32 mask) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); @@ -787,14 +797,14 @@ fm_set_intr_mask(bt_private * priv, u32 mask) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | FM_CMD; - pCmd->length = 0x05; - pCmd->data[0] = FM_SET_INTR_MASK; - memcpy(&pCmd->data[1], &mask, sizeof(mask)); + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | FM_CMD; + pcmd->length = 0x05; + pcmd->data[0] = FM_SET_INTR_MASK; + memcpy(&pcmd->data[1], &mask, sizeof(mask)); PRINTM(CMD, "FM set intr mask=0x%x\n", mask); bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[FM_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; @@ -825,7 +835,7 @@ bt_enable_hs(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -834,16 +844,16 @@ bt_enable_hs(bt_private * priv) goto exit; } priv->adapter->suspend_fail = FALSE; - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE; - pCmd->length = 0; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE; + pcmd->length = 0; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_HOST_SLEEP_ENABLE; - PRINTM(CMD, "Queue hs enable Command(0x%x)\n", pCmd->ocf_ogf); + PRINTM(CMD, "Queue hs enable Command(0x%x)\n", pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->hs_state, @@ -886,7 +896,7 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_BLE_CMD *pCmd; + BT_BLE_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_BLE_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -894,10 +904,10 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_BLE_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_BLE_DEEP_SLEEP; - pCmd->length = 1; - pCmd->deepsleep = mode; + pcmd = (BT_BLE_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_BLE_DEEP_SLEEP; + pcmd->length = 1; + pcmd->deepsleep = mode; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_BLE_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -905,7 +915,7 @@ bt_set_ble_deepsleep(bt_private * priv, int mode) priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_BLE_DEEP_SLEEP; priv->adapter->cmd_complete = FALSE; - PRINTM(CMD, "BT: Set BLE deepsleep = %d (0x%x)\n", mode, pCmd->ocf_ogf); + PRINTM(CMD, "BT: Set BLE deepsleep = %d (0x%x)\n", mode, pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -931,7 +941,7 @@ bt_get_fw_version(bt_private * priv) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -939,10 +949,10 @@ bt_get_fw_version(bt_private * priv) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_GET_FW_VERSION; - pCmd->length = 0x01; - pCmd->cmd_type = 0x00; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_GET_FW_VERSION; + pcmd->length = 0x01; + pcmd->cmd_type = 0x00; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, 4); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -976,7 +986,7 @@ bt_set_mac_address(bt_private * priv, u8 * mac) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_HCI_CMD *pCmd; + BT_HCI_CMD *pcmd; int i = 0; ENTER(); skb = bt_skb_alloc(sizeof(BT_HCI_CMD), GFP_ATOMIC); @@ -985,13 +995,13 @@ bt_set_mac_address(bt_private * priv, u8 * mac) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_HCI_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CONFIG_MAC_ADDR; - pCmd->length = 8; - pCmd->cmd_type = MRVL_VENDOR_PKT; - pCmd->cmd_len = 6; + pcmd = (BT_HCI_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CONFIG_MAC_ADDR; + pcmd->length = 8; + pcmd->cmd_type = MRVL_VENDOR_PKT; + pcmd->cmd_len = 6; for (i = 0; i < 6; i++) - pCmd->data[i] = mac[5 - i]; + pcmd->data[i] = mac[5 - i]; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_HCI_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -1000,7 +1010,7 @@ bt_set_mac_address(bt_private * priv, u8 * mac) priv->bt_dev.send_cmd_ocf = BT_CMD_CONFIG_MAC_ADDR; priv->adapter->cmd_complete = FALSE; PRINTM(CMD, "BT: Set mac addr " MACSTR " (0x%x)\n", MAC2STR(mac), - pCmd->ocf_ogf); + pcmd->ocf_ogf); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -1028,7 +1038,7 @@ bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CMD *pCmd; + BT_CMD *pcmd; int i = 0; /* u8 config_data[28] = {0x37 0x01 0x1c 0x00 0xFF 0xFF 0xFF 0xFF 0x01 0x7f 0x04 0x02 0x00 0x00 0xBA 0xCE 0xC0 0xC6 0x2D 0x00 0x00 0x00 @@ -1041,31 +1051,30 @@ bt_load_cal_data(bt_private * priv, u8 * config_data, u8 * mac) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA; - pCmd->length = 0x20; - pCmd->data[0] = 0x00; - pCmd->data[1] = 0x00; - pCmd->data[2] = 0x00; - pCmd->data[3] = 0x1C; + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA; + pcmd->length = 0x20; + pcmd->data[0] = 0x00; + pcmd->data[1] = 0x00; + pcmd->data[2] = 0x00; + pcmd->data[3] = 0x1C; /* swip cal-data byte */ - for (i = 4; i < 32; i++) { - pCmd->data[i] = config_data[(i / 4) * 8 - 1 - i]; - } + for (i = 4; i < 32; i++) + pcmd->data[i] = config_data[(i / 4) * 8 - 1 - i]; if (mac != NULL) { - pCmd->data[2] = 0x01; /* skip checksum */ + pcmd->data[2] = 0x01; /* skip checksum */ for (i = 24; i < 30; i++) - pCmd->data[i] = mac[29 - i]; + pcmd->data[i] = mac[29 - i]; } bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; - skb_put(skb, BT_CMD_HEADER_SIZE + pCmd->length); + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); skb_queue_head(&priv->adapter->tx_queue, skb); priv->bt_dev.sendcmdflag = TRUE; priv->bt_dev.send_cmd_ocf = BT_CMD_LOAD_CONFIG_DATA; priv->adapter->cmd_complete = FALSE; - DBG_HEXDUMP(DAT_D, "calirate data: ", pCmd->data, 32); + DBG_HEXDUMP(DAT_D, "calirate data: ", pcmd->data, 32); wake_up_interruptible(&priv->MainThread.waitQ); if (!os_wait_interruptible_timeout (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, @@ -1080,6 +1089,56 @@ exit: } /** + * @brief This function load the calibrate EXT data + * + * @param priv A pointer to bt_private structure + * @param config_data A pointer to calibrate data + * @param mac A pointer to mac address + * + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + */ +int +bt_load_cal_data_ext(bt_private * priv, u8 * config_data, u32 cfg_data_len) +{ + struct sk_buff *skb = NULL; + u8 ret = BT_STATUS_SUCCESS; + BT_CMD *pcmd; + + ENTER(); + skb = bt_skb_alloc(sizeof(BT_CMD), GFP_ATOMIC); + if (skb == NULL) { + PRINTM(WARN, "No free skb\n"); + ret = BT_STATUS_FAILURE; + goto exit; + } + pcmd = (BT_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_LOAD_CONFIG_DATA_EXT; + pcmd->length = cfg_data_len; + + memcpy(pcmd->data, config_data, cfg_data_len); + bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; + skb_put(skb, BT_CMD_HEADER_SIZE + pcmd->length); + skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); + skb_queue_head(&priv->adapter->tx_queue, skb); + priv->bt_dev.sendcmdflag = TRUE; + priv->bt_dev.send_cmd_ocf = BT_CMD_LOAD_CONFIG_DATA_EXT; + priv->adapter->cmd_complete = FALSE; + + DBG_HEXDUMP(DAT_D, "calirate ext data", pcmd->data, pcmd->length); + wake_up_interruptible(&priv->MainThread.waitQ); + if (!os_wait_interruptible_timeout + (priv->adapter->cmd_wait_q, priv->adapter->cmd_complete, + WAIT_UNTIL_CMD_RESP)) { + ret = BT_STATUS_FAILURE; + PRINTM(ERROR, "BT: Load calibrate ext data: timeout:\n"); + bt_cmd_timeout_func(priv->adapter, BT_CMD_LOAD_CONFIG_DATA_EXT); + } +exit: + LEAVE(); + return ret; +} + +/** * @brief This function writes value to CSU registers * * @param priv A pointer to bt_private structure @@ -1093,7 +1152,7 @@ bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value) { struct sk_buff *skb = NULL; u8 ret = BT_STATUS_SUCCESS; - BT_CSU_CMD *pCmd; + BT_CSU_CMD *pcmd; ENTER(); skb = bt_skb_alloc(sizeof(BT_CSU_CMD), GFP_ATOMIC); if (skb == NULL) { @@ -1101,16 +1160,16 @@ bt_write_reg(bt_private * priv, u8 type, u32 offset, u16 value) ret = BT_STATUS_FAILURE; goto exit; } - pCmd = (BT_CSU_CMD *) skb->data; - pCmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CSU_WRITE_REG; - pCmd->length = 7; - pCmd->type = type; - pCmd->offset[0] = (offset & 0x000000ff); - pCmd->offset[1] = (offset & 0x0000ff00) >> 8; - pCmd->offset[2] = (offset & 0x00ff0000) >> 16; - pCmd->offset[3] = (offset & 0xff000000) >> 24; - pCmd->value[0] = (value & 0x00ff); - pCmd->value[1] = (value & 0xff00) >> 8; + pcmd = (BT_CSU_CMD *) skb->data; + pcmd->ocf_ogf = (VENDOR_OGF << 10) | BT_CMD_CSU_WRITE_REG; + pcmd->length = 7; + pcmd->type = type; + pcmd->offset[0] = (offset & 0x000000ff); + pcmd->offset[1] = (offset & 0x0000ff00) >> 8; + pcmd->offset[2] = (offset & 0x00ff0000) >> 16; + pcmd->offset[3] = (offset & 0xff000000) >> 24; + pcmd->value[0] = (value & 0x00ff); + pcmd->value[1] = (value & 0xff00) >> 8; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; skb_put(skb, sizeof(BT_CSU_CMD)); skb->dev = (void *)(&(priv->bt_dev.m_dev[BT_SEQ])); @@ -1201,7 +1260,7 @@ bt_prepare_command(bt_private * priv) * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int -SendSinglePacket(bt_private * priv, struct sk_buff *skb) +send_single_packet(bt_private * priv, struct sk_buff *skb) { int ret; ENTER(); @@ -1301,11 +1360,11 @@ done: void bt_free_adapter(bt_private * priv) { - bt_adapter *Adapter = priv->adapter; + bt_adapter *adapter = priv->adapter; ENTER(); skb_queue_purge(&priv->adapter->tx_queue); /* Free the adapter object itself */ - kfree(Adapter); + kfree(adapter); priv->adapter = NULL; LEAVE(); @@ -1385,7 +1444,7 @@ mdev_send_frame(struct m_dev *m_dev, struct sk_buff *skb) priv->debug_device_pending = 1; priv->debug_ocf_ogf[0] = skb->data[0]; priv->debug_ocf_ogf[1] = skb->data[1]; - PRINTM(CMD, "debug_ocf_ogf[0]=0x%x debug_ocf_ogf[1]=0x%x \n", + PRINTM(CMD, "debug_ocf_ogf[0]=0x%x debug_ocf_ogf[1]=0x%x\n", priv->debug_ocf_ogf[0], priv->debug_ocf_ogf[1]); } @@ -1542,7 +1601,7 @@ bt_service_main_thread(void *data) { bt_thread *thread = data; bt_private *priv = thread->priv; - bt_adapter *Adapter = priv->adapter; + bt_adapter *adapter = priv->adapter; wait_queue_t wait; struct sk_buff *skb; ENTER(); @@ -1562,17 +1621,17 @@ bt_service_main_thread(void *data) } OS_SET_THREAD_STATE(TASK_RUNNING); remove_wait_queue(&thread->waitQ, &wait); - if (kthread_should_stop() || Adapter->SurpriseRemoved) { + if (kthread_should_stop() || adapter->SurpriseRemoved) { PRINTM(INFO, "main-thread: break from main thread: " "SurpriseRemoved=0x%x\n", - Adapter->SurpriseRemoved); + adapter->SurpriseRemoved); break; } PRINTM(INFO, "Main: Thread waking up...\n"); if (priv->adapter->IntCounter) { OS_INT_DISABLE; - Adapter->IntCounter = 0; + adapter->IntCounter = 0; OS_INT_RESTORE; sbi_get_int_status(priv); } else if ((priv->adapter->ps_state == PS_SLEEP) && @@ -1587,7 +1646,7 @@ bt_service_main_thread(void *data) if (!skb_queue_empty(&priv->adapter->tx_queue)) { skb = skb_dequeue(&priv->adapter->tx_queue); if (skb) { - if (SendSinglePacket(priv, skb)) + if (send_single_packet(priv, skb)) ((struct m_dev *)skb->dev)-> stat.err_tx++; else @@ -1766,7 +1825,8 @@ sbi_register_conf_dpc(bt_private * priv) } } #ifdef SDIO_SUSPEND_RESUME - priv->bt_dev.gpio_gap = 0xffff; + + priv->bt_dev.gpio_gap = 0x0464; ret = bt_send_hscfg_cmd(priv); if (ret < 0) { PRINTM(FATAL, "Send HSCFG failed!\n"); @@ -1781,7 +1841,7 @@ sbi_register_conf_dpc(bt_private * priv) priv->bt_dev.m_dev[BT_SEQ].dev_type = BT_AMP_TYPE; } /* block all the packet from bluez */ - if (init_cfg || cal_cfg || bt_mac) + if (init_cfg || cal_cfg || bt_mac || cal_cfg_ext) priv->adapter->tx_lock = TRUE; if (mbt_dev) { @@ -2052,11 +2112,30 @@ sbi_register_conf_dpc(bt_private * priv) goto done; } } - if (init_cfg || cal_cfg || bt_mac) { + if (cal_cfg_ext) { + if (BT_STATUS_SUCCESS != bt_cal_config_ext(priv, cal_cfg_ext)) { + PRINTM(FATAL, "BT: Set cal ext data failed\n"); + if (mbt_dev) { + m_dev = &(priv->bt_dev.m_dev[BT_SEQ]); + /** unregister m_dev to char_dev */ + m_dev->close(m_dev); + for (i = 0; i < 3; i++) + kfree_skb(mbt_dev->reassembly[i]); + /** unregister m_dev to char_dev */ + chardev_cleanup_one(m_dev, chardev_class); + free_m_dev(m_dev); + } + ret = BT_STATUS_FAILURE; + goto done; + } + } + if (init_cfg || cal_cfg || bt_mac || cal_cfg_ext) { priv->adapter->tx_lock = FALSE; bt_restore_tx_queue(priv); } + bt_register_hostwake_irq(NULL); + /* Get FW version */ bt_get_fw_version(priv); snprintf(priv->adapter->drv_ver, MAX_VER_STR_LEN, @@ -2255,7 +2334,7 @@ bt_remove_card(void *card) static int bt_set_carddetect(int on) { - PRINTM(MSG, "%s = %d\n", __FUNCTION__, on); + PRINTM(MSG, "%s = %d\n", __func__, on); if (bt_control_data && bt_control_data->set_carddetect) bt_control_data->set_carddetect(on); @@ -2271,7 +2350,7 @@ bt_set_carddetect(int on) static int bt_set_power(int on, unsigned long msec) { - PRINTM(MSG, "%s = %d\n", __FUNCTION__, on); + PRINTM(MSG, "%s = %d\n", __func__, on); if (bt_control_data && bt_control_data->set_power) bt_control_data->set_power(on); @@ -2280,6 +2359,45 @@ bt_set_power(int on, unsigned long msec) return 0; } +static irqreturn_t +bt_hostwake_isr(int irq, void *dev_id) +{ + PRINTM(INTR, "Recv hostwake isr\n"); + return IRQ_HANDLED; +} + +void +bt_enable_hostwake_irq(int flag) +{ + if (bt_irqres && irq_registered) { + PRINTM(INTR, "enable_hostwake_irq=%d\n", flag); + if (flag) { + enable_irq(bt_irqres->start); + enable_irq_wake(bt_irqres->start); + } else { + disable_irq_wake(bt_irqres->start); + disable_irq(bt_irqres->start); + } + } +} + +static void +bt_register_hostwake_irq(void *handle) +{ + if (bt_irqres && !irq_registered) { + irq_registered = + request_irq(bt_irqres->start, bt_hostwake_isr, + bt_irqres->flags, DRIVER_NAME, handle); + if (irq_registered < 0) + PRINTM(ERROR, "Couldn't acquire BT_HOST_WAKE IRQ\n"); + else { + irq_registered = 1; + enable_irq_wake(bt_irqres->start); + bt_enable_hostwake_irq(FALSE); + } + } +} + void mdev_poweroff(struct m_dev *m_dev) { @@ -2307,9 +2425,14 @@ bt_probe(struct platform_device *pdev) ENTER(); - bt_control_data = bt_ctrl; - bt_set_power(1, 0); /* Power On */ - bt_set_carddetect(1); /* CardDetect (0->1) */ + bt_irqres = platform_get_resource_byname(pdev, + IORESOURCE_IRQ, + IORESOURCE_NAME); + if (minicard_pwrup) { + bt_control_data = bt_ctrl; + bt_set_power(1, 0); /* Power On */ + bt_set_carddetect(1); /* CardDetect (0->1) */ + } LEAVE(); return 0; @@ -2329,9 +2452,16 @@ bt_remove(struct platform_device *pdev) ENTER(); - bt_control_data = bt_ctrl; - bt_set_power(0, 0); /* Power Off */ - bt_set_carddetect(0); /* CardDetect (1->0) */ + if (bt_irqres && irq_registered) { + PRINTM(MSG, "Free hostwake IRQ wakeup\n"); + free_irq(bt_irqres->start, NULL); + irq_registered = 0; + } + if (minicard_pwrup) { + bt_control_data = bt_ctrl; + bt_set_power(0, 0); /* Power Off */ + bt_set_carddetect(0); /* CardDetect (1->0) */ + } LEAVE(); return 0; @@ -2357,8 +2487,7 @@ bt_add_dev(void) ENTER(); - if (minicard_pwrup) - ret = platform_driver_register(&bt_device); + ret = platform_driver_register(&bt_device); LEAVE(); return ret; @@ -2374,8 +2503,7 @@ bt_del_dev(void) { ENTER(); - if (minicard_pwrup) - platform_driver_unregister(&bt_device); + platform_driver_unregister(&bt_device); LEAVE(); } @@ -2461,6 +2589,8 @@ module_param(init_cfg, charp, 0); MODULE_PARM_DESC(init_cfg, "BT init config file name"); module_param(cal_cfg, charp, 0); MODULE_PARM_DESC(cal_cfg, "BT calibrate file name"); +module_param(cal_cfg_ext, charp, 0); +MODULE_PARM_DESC(cal_cfg_ext, "BT calibrate ext file name"); module_param(bt_mac, charp, 0); MODULE_PARM_DESC(bt_mac, "BT init mac address"); module_param(minicard_pwrup, int, 0); diff --git a/drivers/bluetooth/sd8897/bt/bt_proc.c b/drivers/bluetooth/sd8897/bt/bt_proc.c index 74007eb7bd1f..ad9a6e9cd23d 100644 --- a/drivers/bluetooth/sd8897/bt/bt_proc.c +++ b/drivers/bluetooth/sd8897/bt/bt_proc.c @@ -71,12 +71,12 @@ struct proc_data { /** Device size */ #define item_dev_size(n) (sizeof((bt_dev_t *)0)->n) /** Device address */ -#define item_dev_addr(n) ((t_ptr) & ((bt_dev_t *)0)->n) +#define item_dev_addr(n) ((t_ptr) &((bt_dev_t *)0)->n) /** Adapter size */ #define item_adapter_size(n) (sizeof((bt_adapter *)0)->n) /** Adapter address */ -#define item_adapter_addr(n) ((t_ptr) & ((bt_adapter *)0)->n) +#define item_adapter_addr(n) ((t_ptr) &((bt_adapter *)0)->n) static struct item_data config_items[] = { #ifdef DEBUG_LEVEL1 @@ -233,23 +233,19 @@ parse_cmd52_string(const char __user * buffer, size_t len, /* Get func */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *func = string_to_number(pos); - } /* Get reg */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *reg = string_to_number(pos); - } /* Get val (optional) */ pos = strsep(&string, " \t"); - if (pos) { + if (pos) *val = string_to_number(pos); - } - if (string) - kfree(string); + kfree(string); LEAVE(); return ret; } diff --git a/drivers/bluetooth/sd8897/bt/bt_sdio.h b/drivers/bluetooth/sd8897/bt/bt_sdio.h index c2dca34809b1..e2227794e087 100644 --- a/drivers/bluetooth/sd8897/bt/bt_sdio.h +++ b/drivers/bluetooth/sd8897/bt/bt_sdio.h @@ -27,7 +27,7 @@ /** IRQ return type */ typedef irqreturn_t IRQ_RET_TYPE; /** IRQ return */ -#define IRQ_RET return IRQ_HANDLED +#define IRQ_RET (return IRQ_HANDLED) /** ISR notifier function */ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, struct pt_regs * reg); @@ -60,7 +60,7 @@ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, /** Host Control Registers : Configuration */ #define CONFIGURATION_REG 0x00 /** Host Control Registers : Host without Command 53 finish host*/ -#define HOST_TO_CARD_EVENT (0x1U << 3) +#define HOST_TO_CARD_EVENT (0x1U << 3) /** Host Control Registers : Host without Command 53 finish host */ #define HOST_WO_CMD53_FINISH_HOST (0x1U << 2) /** Host Control Registers : Host power up */ @@ -113,50 +113,50 @@ typedef IRQ_RET_TYPE(*isr_notifier_fn_t) (s32 irq, void *dev_id, #define DN_LD_CARD_RDY (0x1U << 0) /** Card Control Registers : Host interrupt mask register */ -#define HOST_INTERRUPT_MASK_REG 0x54 +#define HOST_INTERRUPT_MASK_REG 0x54 /** Card Control Registers : Host power interrupt mask */ #define HOST_POWER_INT_MASK (0x1U << 3) /** Card Control Registers : Abort card interrupt mask */ #define ABORT_CARD_INT_MASK (0x1U << 2) /** Card Control Registers : Upload card interrupt mask */ -#define UP_LD_CARD_INT_MASK (0x1U << 1) +#define UP_LD_CARD_INT_MASK (0x1U << 1) /** Card Control Registers : Download card interrupt mask */ -#define DN_LD_CARD_INT_MASK (0x1U << 0) +#define DN_LD_CARD_INT_MASK (0x1U << 0) /** Card Control Registers : Card interrupt status register */ -#define CARD_INTERRUPT_STATUS_REG 0x58 +#define CARD_INTERRUPT_STATUS_REG 0x58 /** Card Control Registers : Power up interrupt */ -#define POWER_UP_INT (0x1U << 4) +#define POWER_UP_INT (0x1U << 4) /** Card Control Registers : Power down interrupt */ -#define POWER_DOWN_INT (0x1U << 3) +#define POWER_DOWN_INT (0x1U << 3) /** Card Control Registers : Card interrupt RSR register */ -#define CARD_INTERRUPT_RSR_REG 0x5c +#define CARD_INTERRUPT_RSR_REG 0x5c /** Card Control Registers : Power up RSR */ -#define POWER_UP_RSR (0x1U << 4) +#define POWER_UP_RSR (0x1U << 4) /** Card Control Registers : Power down RSR */ -#define POWER_DOWN_RSR (0x1U << 3) +#define POWER_DOWN_RSR (0x1U << 3) /* Card Control Registers */ /** Card Control Registers : Read SQ base address A0 register */ -#define SQ_READ_BASE_ADDRESS_A0_REG 0x60 +#define SQ_READ_BASE_ADDRESS_A0_REG 0x60 /** Card Control Registers : Read SQ base address A1 register */ -#define SQ_READ_BASE_ADDRESS_A1_REG 0x61 +#define SQ_READ_BASE_ADDRESS_A1_REG 0x61 /** Card Control Registers : Read SQ base address A2 register */ -#define SQ_READ_BASE_ADDRESS_A2_REG 0x62 +#define SQ_READ_BASE_ADDRESS_A2_REG 0x62 /** Card Control Registers : Read SQ base address A3 register */ -#define SQ_READ_BASE_ADDRESS_A3_REG 0x63 +#define SQ_READ_BASE_ADDRESS_A3_REG 0x63 /** Card Control Registers : Write SQ base address A0 register */ -#define SQ_WRITE_BASE_ADDRESS_A0_REG 0x64 +#define SQ_WRITE_BASE_ADDRESS_A0_REG 0x64 /** Card Control Registers : Write SQ base address A1 register */ -#define SQ_WRITE_BASE_ADDRESS_A1_REG 0x65 +#define SQ_WRITE_BASE_ADDRESS_A1_REG 0x65 /** Card Control Registers : Write SQ base address A2 register */ -#define SQ_WRITE_BASE_ADDRESS_A2_REG 0x66 +#define SQ_WRITE_BASE_ADDRESS_A2_REG 0x66 /** Card Control Registers : Write SQ base address A3 register */ -#define SQ_WRITE_BASE_ADDRESS_A3_REG 0x67 +#define SQ_WRITE_BASE_ADDRESS_A3_REG 0x67 /** Card Control Registers : Card revision register */ -#define CARD_REVISION_REG 0xBC +#define CARD_REVISION_REG 0xBC /** Firmware status 0 register (SCRATCH0_0) */ #define CARD_FW_STATUS0_REG 0xC0 @@ -224,6 +224,7 @@ struct sdio_mmc_card { int sd_read_cmd52_val(bt_private * priv); /** This function updates card reg based on the Cmd52 value in dev structure */ int sd_write_cmd52_val(bt_private * priv, int func, int reg, int val); +void bt_enable_hostwake_irq(int flag); #ifdef SDIO_SUSPEND_RESUME #ifdef MMC_PM_KEEP_POWER diff --git a/drivers/bluetooth/sd8897/bt/bt_sdiommc.c b/drivers/bluetooth/sd8897/bt/bt_sdiommc.c index 44c7f253b957..0d9f82eb3db2 100644 --- a/drivers/bluetooth/sd8897/bt/bt_sdiommc.c +++ b/drivers/bluetooth/sd8897/bt/bt_sdiommc.c @@ -70,7 +70,7 @@ extern int mbt_pm_keep_power; * @brief This function gets rx_unit value * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sd_get_rx_unit(bt_private * priv) @@ -94,7 +94,7 @@ sd_get_rx_unit(bt_private * priv) * * @param priv A pointer to bt_private structure * @param dat A pointer to keep returned data - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_read_firmware_status(bt_private * priv, u16 * dat) @@ -129,7 +129,7 @@ sd_read_firmware_status(bt_private * priv, u16 * dat) * * @param priv A pointer to bt_private structure * @param dat A pointer to keep returned data - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ static int sd_read_rx_len(bt_private * priv, u16 * dat) @@ -153,7 +153,7 @@ sd_read_rx_len(bt_private * priv, u16 * dat) * * @param priv A pointer to bt_private structure * @param mask the interrupt mask - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_enable_host_int_mask(bt_private * priv, u8 mask) @@ -177,7 +177,7 @@ sd_enable_host_int_mask(bt_private * priv, u8 mask) * * @param priv A pointer to bt_private structure * @param mask the interrupt mask - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ static int sd_disable_host_int_mask(bt_private * priv, u8 mask) @@ -209,9 +209,9 @@ done: /** * @brief This function polls the card status register * - * @param priv A pointer to bt_private structure - * @param bits the bit mask - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @param priv A pointer to bt_private structure + * @param bits the bit mask + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_poll_card_status(bt_private * priv, u8 bits) @@ -244,8 +244,8 @@ sd_poll_card_status(bt_private * priv, u8 bits) /** * @brief This function reads updates the Cmd52 value in dev structure * - * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or other error no. + * @param priv A pointer to bt_private structure + * @return BT_STATUS_SUCCESS or other error no. */ int sd_read_cmd52_val(bt_private * priv) @@ -278,11 +278,11 @@ sd_read_cmd52_val(bt_private * priv) /** * @brief This function updates card reg based on the Cmd52 value in dev structure * - * @param priv A pointer to bt_private structure - * @param func Stores func variable - * @param reg Stores reg variable - * @param val Stores val variable - * @return BT_STATUS_SUCCESS or other error no. + * @param priv A pointer to bt_private structure + * @param func Stores func variable + * @param reg Stores reg variable + * @param val Stores val variable + * @return BT_STATUS_SUCCESS or other error no. */ int sd_write_cmd52_val(bt_private * priv, int func, int reg, int val) @@ -322,8 +322,8 @@ done: * @brief This function probes the card * * @param func A pointer to sdio_func structure. - * @param id A pointer to structure sdio_device_id - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @param id A pointer to structure sdio_device_id + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ static int sd_probe_card(struct sdio_func *func, const struct sdio_device_id *id) @@ -411,7 +411,7 @@ sd_verify_fw_download(bt_private * priv, int pollnum) * @brief Transfers firmware to card * * @param priv A Pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ static int sd_init_fw_dpc(bt_private * priv) @@ -431,9 +431,6 @@ sd_init_fw_dpc(bt_private * priv) int tx_blocks = 0; int i = 0; int tries = 0; -#ifdef FW_DOWNLOAD_SPEED - u32 tv1, tv2; -#endif ENTER(); firmware = (u8 *) priv->firmware->data; @@ -441,10 +438,6 @@ sd_init_fw_dpc(bt_private * priv) PRINTM(INFO, "BT: Downloading FW image (%d bytes)\n", firmwarelen); -#ifdef FW_DOWNLOAD_SPEED - tv1 = get_utimeofday(); -#endif - tmpfwbufsz = BT_UPLD_SIZE + DMA_ALIGNMENT; tmpfwbuf = kmalloc(tmpfwbufsz, GFP_KERNEL); if (!tmpfwbuf) { @@ -565,18 +558,7 @@ sd_init_fw_dpc(bt_private * priv) ret = BT_STATUS_SUCCESS; done: -#ifdef FW_DOWNLOAD_SPEED - tv2 = get_utimeofday(); - PRINTM(INFO, "FW: %d.%03d.%03d ", tv1 / 1000000, - (tv1 % 1000000) / 1000, tv1 % 1000); - PRINTM(INFO, " -> %d.%03d.%03d ", tv2 / 1000000, - (tv2 % 1000000) / 1000, tv2 % 1000); - tv2 -= tv1; - PRINTM(INFO, " == %d.%03d.%03d\n", tv2 / 1000000, - (tv2 % 1000000) / 1000, tv2 % 1000); -#endif - if (tmpfwbuf) - kfree(tmpfwbuf); + kfree(tmpfwbuf); LEAVE(); return ret; } @@ -681,9 +663,8 @@ done: /* Stop the thread servicing the interrupts */ priv->adapter->SurpriseRemoved = TRUE; wake_up_interruptible(&priv->MainThread.waitQ); - while (priv->MainThread.pid) { + while (priv->MainThread.pid) os_sched_timeout(1); - } if (m_dev_bt->dev_pointer) { if (m_dev_bt->spec_type == IANYWHERE_SPEC) free_m_dev(m_dev_bt); @@ -719,8 +700,8 @@ sd_request_fw_callback(const struct firmware *firmware, void *context) /** * @brief This function downloads firmware image to the card. * - * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @param priv A pointer to bt_private structure + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sd_download_firmware_w_helper(bt_private * priv) @@ -768,7 +749,7 @@ sd_download_firmware_w_helper(bt_private * priv) * @brief This function reads data from the card. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ static int sd_card_to_host(bt_private * priv) @@ -1072,7 +1053,7 @@ sd_interrupt(struct sdio_func *func) if (!card || !card->priv) { PRINTM(INFO, "BT: %s: sbi_interrupt(%p) card or priv is NULL, card=%p\n", - __FUNCTION__, func, card); + __func__, func, card); LEAVE(); return; } @@ -1160,7 +1141,7 @@ bt_is_suspended(bt_private * priv) /** @brief This function handles client driver suspend * * @param dev A pointer to device structure - * @return BT_STATUS_SUCCESS or other error no. + * @return BT_STATUS_SUCCESS or other error no. */ int bt_sdio_suspend(struct device *dev) @@ -1214,6 +1195,9 @@ bt_sdio_suspend(struct device *dev) skb_queue_purge(&priv->adapter->tx_queue); priv->adapter->is_suspended = TRUE; + + bt_enable_hostwake_irq(TRUE); + LEAVE(); /* We will keep the power when hs enabled successfully */ if ((mbt_pm_keep_power) && (priv->adapter->hs_state == HS_ACTIVATED)) { @@ -1236,7 +1220,7 @@ bt_sdio_suspend(struct device *dev) /** @brief This function handles client driver resume * * @param dev A pointer to device structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int bt_sdio_resume(struct device *dev) @@ -1249,6 +1233,7 @@ bt_sdio_resume(struct device *dev) ENTER(); if (func) { + bt_enable_hostwake_irq(FALSE); pm_flags = sdio_get_host_pm_caps(func); PRINTM(CMD, "BT: %s: resume: PM flags = 0x%x\n", sdio_func_id(func), pm_flags); @@ -1320,7 +1305,7 @@ sbi_register(void) ENTER(); if (sdio_register_driver(&sdio_bt) != 0) { - PRINTM(FATAL, "BT: SD Driver Registration Failed \n"); + PRINTM(FATAL, "BT: SD Driver Registration Failed\n"); LEAVE(); return NULL; } else @@ -1333,7 +1318,7 @@ sbi_register(void) /** * @brief This function de-registers the bt module in bus driver. * - * @return N/A + * @return N/A */ void sbi_unregister(void) @@ -1348,7 +1333,7 @@ sbi_unregister(void) * @brief This function registers the device. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_register_dev(bt_private * priv) @@ -1383,8 +1368,7 @@ sbi_register_dev(bt_private * priv) } ret = sdio_set_block_size(card->func, SD_BLOCK_SIZE); if (ret) { - PRINTM(FATAL, ": %s: cannot set SDIO block size\n", - __FUNCTION__); + PRINTM(FATAL, ": %s: cannot set SDIO block size\n", __func__); goto release_irq; } @@ -1462,7 +1446,7 @@ failed: * @brief This function de-registers the device. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int sbi_unregister_dev(bt_private * priv) @@ -1487,7 +1471,7 @@ sbi_unregister_dev(bt_private * priv) * @brief This function enables the host interrupts. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sd_enable_host_int(bt_private * priv) @@ -1514,7 +1498,7 @@ sd_enable_host_int(bt_private * priv) * @brief This function disables the host interrupts. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sd_disable_host_int(bt_private * priv) @@ -1541,8 +1525,8 @@ sd_disable_host_int(bt_private * priv) * * @param priv A pointer to bt_private structure * @param payload A pointer to the data/cmd buffer - * @param nb Length of data/cmd - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @param nb Length of data/cmd + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_host_to_card(bt_private * priv, u8 * payload, u16 nb) @@ -1617,7 +1601,7 @@ exit: * @brief This function downloads firmware * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE + * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int sbi_download_fw(bt_private * priv) @@ -1707,7 +1691,7 @@ err_register: * @brief This function checks the interrupt status and handle it accordingly. * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS + * @return BT_STATUS_SUCCESS */ int sbi_get_int_status(bt_private * priv) @@ -1746,7 +1730,7 @@ sbi_get_int_status(bt_private * priv) * @brief This function wakeup firmware * * @param priv A pointer to bt_private structure - * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. + * @return BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no. */ int sbi_wakeup_firmware(bt_private * priv) |