Enable Bluetooth functionality for WCN3990
cover Enable Bluetooth functionality for WCN3990
These patches enable Bluetooth functionality for WCN3990 by
- adding support for voting of voltage regulators for WCN3990 attached to MSM
- Bluetooth firmware download support for WCN3990
- description of device tree bindings
Balakrishna Godavarthi (1):
Bluetooth: Added support for wcn3990 soc.
Rupesh Tatiya (2):
Bluetooth: Add device tree bindings for Atheros chips Add support to power Bluetooth QCA chips attached to MSM
.../devicetree/bindings/bluetooth/btqca_power.txt | 30 ++ drivers/bluetooth/Makefile | 5 +- drivers/bluetooth/btqca.c | 393 ++++++++++++++++----- drivers/bluetooth/btqca.h | 46 ++- drivers/bluetooth/btqca_power.c | 177 ++++++++++ drivers/bluetooth/btqca_power.h | 71 ++++ drivers/bluetooth/hci_qca.c | 324 ++++++++++++++--- include/net/bluetooth/hci_core.h | 3 +- net/bluetooth/hci_core.c | 2 +- net/bluetooth/hci_request.c | 23 ++ net/bluetooth/hci_request.h | 2 + 11 files changed, 942 insertions(+), 134 deletions(-) create mode 100644 Documentation/devicetree/bindings/bluetooth/btqca_power.txt create mode 100644 drivers/bluetooth/btqca_power.c create mode 100644 drivers/bluetooth/btqca_power.h
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 1/3 Bluetooth: Add device tree bindings for Atheros chips
From: Rupesh Tatiya <[email protected]>
--- .../devicetree/bindings/bluetooth/btqca_power.txt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/devicetree/bindings/bluetooth/btqca_power.txt
Documentation/devicetree/bindings/bluetooth/btqca_power.txt new file +30 -0
@@ -0,0 +1,30 @@ +* Bluetooth Controller +Bluetooth controller communicates with the Bluetooth Host using HCI Transport layer. +HCI Transport layer can be based on UART or USB serial communication protocol. + +Required properties: + - compatible: Should be set to one of the following: + qca,ar3002 + qca,qca6174 + qca,wcn3990 + +Optional properties: + - vddpa-supply: Bluetooth VDD PA regulator handle + - vddio-supply: Bluetooth VDD IO regulator handle + - vddldo-supply: Bluetooth VDD LDO regulator handle. Kept under optional parameters + as some of the chipsets doesn't require ldo or it may use from same vddio. + - vddxtal-supply: Bluetooth VDD XTAL regulator handle + - vddcore-supply: Bluetooth VDD CORE regulator handle + - vddpwd-supply: Chip power down gpio is required when bluetooth module + and other modules like wifi co-exist in a singe chip and shares a + common gpio to bring chip out of reset. + +Example: + bt-ar3002 { + compatible = "qca,ar3002"; + vddio-supply = <&pm8941_s3>; + vddpa-supply = <&pm8941_l19>; + vddxtal-supply = <&pm8994_l30>; + vddcore-supply = <&pm8994_s3>; + vddpwd-supply = <&ath_chip_pwd_l>; +};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/3 Add support to power Bluetooth QCA chips attached to MSM
In reply to Balakrishna GodavarthiFrom: Rupesh Tatiya <[email protected]>
Add support to set voltage/current of various regulators to power up/down BT QCA chips attached to MSM.
--- drivers/bluetooth/Makefile | 5 +- drivers/bluetooth/btqca_power.c | 177 ++++++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btqca_power.h | 71 ++++++++++++++++ 3 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 drivers/bluetooth/btqca_power.c create mode 100644 drivers/bluetooth/btqca_power.h
drivers/bluetooth/Makefile +3 -2
@@ -24,8 +24,9 @@ obj-$(CONFIG_BT_WILINK) += btwilink.o obj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o obj-$(CONFIG_BT_BCM) += btbcm.o obj-$(CONFIG_BT_RTL) += btrtl.o -obj-$(CONFIG_BT_QCA) += btqca.o - +obj-$(CONFIG_BT_QCA) += btqca_uart.o +btqca_uart-$(CONFIG_BT_QCA) += btqca.o +btqca_uart-$(CONFIG_BT_QCA) += btqca_power.o obj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o btmrvl-y := btmrvl_main.o
drivers/bluetooth/btqca_power.c new file +177 -0
177 lines not on this page · raw message
drivers/bluetooth/btqca_power.h new file +71 -0
71 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 3/3 Bluetooth: Added support for wcn3990 soc.
In reply to Balakrishna GodavarthiAdded firmware download support for QCA chip wcn3990.
--- drivers/bluetooth/btqca.c | 393 +++++++++++++++++++++++++++++++-------- drivers/bluetooth/btqca.h | 46 ++++- drivers/bluetooth/hci_qca.c | 324 +++++++++++++++++++++++++++----- include/net/bluetooth/hci_core.h | 3 +- net/bluetooth/hci_core.c | 2 +- net/bluetooth/hci_request.c | 23 +++ net/bluetooth/hci_request.h | 2 + 7 files changed, 661 insertions(+), 132 deletions(-)
drivers/bluetooth/btqca.c +313 -80
@@ -1,7 +1,7 @@/* * Bluetooth supports for Qualcomm Atheros chips * -* Copyright (c) 2015 The Linux Foundation. All rights reserved. +* Copyright (c) 2015, 2018 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2
@@ -19,82 +19,18 @@*/ #include <linux/module.h> #include <linux/firmware.h> -#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/hci_core.h> -#include "btqca.h" #define VERSION "0.1" -static int rome_patch_ver_req (struct hci_dev *hdev,u32 *rome_version) -{ -struct sk_buff *skb; -struct edl_event_hdr *edl; -struct rome_version *ver; -char cmd; -int err =0 ; - -BT_DBG ("%s: ROME Patch Version Request" , hdev->name); - - cmd =EDL_PATCH_VER_REQ_CMD ; - skb =__hci_cmd_sync_ev (hdev,EDL_PATCH_CMD_OPCODE ,EDL_PATCH_CMD_LEN , - &cmd,HCI_VENDOR_PKT ,HCI_INIT_TIMEOUT ); -if (IS_ERR (skb)) { - err =PTR_ERR (skb); -BT_ERR ("%s: Failed to read version of ROME (%d)" , hdev->name, - err); -return err; - } - -if (skb->len !=sizeof (*edl) +sizeof (*ver)) { -BT_ERR ("%s: Version size mismatch len %d" , hdev->name, - skb->len); - err = -EILSEQ ; - goto out; - } - - edl = (struct edl_event_hdr *)(skb->data); -if (!edl) { -BT_ERR ("%s: TLV with no header" , hdev->name); - err = -EILSEQ ; - goto out; - } - -if (edl->cresp !=EDL_CMD_REQ_RES_EVT || - edl->rtype !=EDL_APP_VER_RES_EVT ) { -BT_ERR ("%s: Wrong packet received %d %d" , hdev->name, - edl->cresp, edl->rtype); - err = -EIO ; - goto out; - } - - ver = (struct rome_version *)(edl->data); - -BT_DBG ("%s: Product:0x%08x" , hdev->name,le32_to_cpu (ver->product_id)); -BT_DBG ("%s: Patch :0x%08x" , hdev->name,le16_to_cpu (ver->patch_ver)); -BT_DBG ("%s: ROM :0x%08x" , hdev->name,le16_to_cpu (ver->rome_ver)); -BT_DBG ("%s: SOC :0x%08x" , hdev->name,le32_to_cpu (ver->soc_id)); - -/* ROME chipset version can be decided by patch and SoC -* version, combination with upper 2 bytes from SoC -* and lower 2 bytes from patch will be used. -*/ - *rome_version = (le32_to_cpu (ver->soc_id) <<16 ) | - (le16_to_cpu (ver->rome_ver) &0x0000ffff ); - -out: -kfree_skb (skb); - -return err; -} - -static int rome_reset (struct hci_dev *hdev) +static int qca_btsoc_reset (struct hci_dev *hdev) {struct sk_buff *skb;int err; -BT_DBG ("%s: ROME HCI_RESET" , hdev->name); +BT_DBG ("%s: ROME/wcn3990 HCI_RESET" , hdev->name); skb =__hci_cmd_sync (hdev,HCI_OP_RESET ,0 ,NULL ,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) {
@@ -108,7 +44,7 @@ static int rome_reset(struct hci_dev *hdev)return 0 ; } -static void rome_tlv_check_data (struct rome_config *config, +static void rome_tlv_check_data (struct qca_config *config,const struct firmware *fw) {const u8 *data;
@@ -194,8 +130,121 @@ static void rome_tlv_check_data(struct rome_config *config, } } -static int rome_tlv_send_segment (struct hci_dev *hdev,int idx,int seg_size, -const u8 *data) +static void cherokee_tlv_check_data (struct qca_config *config, +const struct firmware *fw,bool *dwnd_flag) +{ +const u8 *data; +u32 type_len; +u16 tag_id, tag_len; +int idx, length; +struct tlv_type_hdr *tlv; +struct cherokee_tlv_type_patch *tlv_patch; +struct tlv_type_nvm *tlv_nvm; + + tlv = (struct tlv_type_hdr *)fw->data; + + type_len =le32_to_cpu (tlv->type_len); + length = (type_len >>8 ) &0x00ffffff ; + +BT_DBG ("TLV Type\t\t : 0x%x" , type_len &0x000000ff ); +BT_DBG ("Length\t\t : %d bytes" , length); + +switch (config->type) { +case TLV_TYPE_PATCH : + tlv_patch = (struct tlv_type_patch *)tlv->data; +BT_DBG ("Total Length\t\t : %d bytes" , +le32_to_cpu (tlv_patch->total_size)); +BT_DBG ("Patch Data Length\t : %d bytes" , +le32_to_cpu (tlv_patch->data_length)); +BT_DBG ("Signing Format Version : 0x%x" , + tlv_patch->format_version); +BT_DBG ("Signature Algorithm\t : 0x%x" , + tlv_patch->signature); +BT_DBG ("Download flag\t : 0x%x" , + tlv_patch->dwnd_cfg); +BT_DBG ("Reserved\t\t : 0x%x" , +le16_to_cpu (tlv_patch->reserved1)); +BT_DBG ("Product ID\t\t : 0x%04x" , +le16_to_cpu (tlv_patch->product_id)); +BT_DBG ("Rom Build Version\t : 0x%04x" , +le16_to_cpu (tlv_patch->rom_build)); +BT_DBG ("Patch Version\t\t : 0x%04x" , +le16_to_cpu (tlv_patch->patch_version)); +BT_DBG ("Reserved\t\t : 0x%x" , +le16_to_cpu (tlv_patch->reserved2)); +BT_DBG ("Patch Entry Address\t : 0x%x" , +le32_to_cpu (tlv_patch->entry)); +/* If the download flag is 0x03, don't wait +* for response from soc,i.e. 1 to n-1 +* segment download. +*/ +if (tlv_patch->dwnd_cfg ==0x03 ) + *dwnd_flag = false; +else + *dwnd_flag = true; +break ; + +case TLV_TYPE_NVM : + idx =0 ; + data = tlv->data; +while (idx < length) { + tlv_nvm = (struct tlv_type_nvm *)(data + idx); + tag_id =le16_to_cpu (tlv_nvm->tag_id); + tag_len =le16_to_cpu (tlv_nvm->tag_len); + +/* Update NVM tags as needed */ +switch (tag_id) { +case EDL_TAG_ID_HCI : +/* HCI transport layer parameters +* enabling software inband sleep +* onto controller side. +*/ + tlv_nvm->data[0 ] |=0x80 ; + +/* UART Baud Rate */ + tlv_nvm->data[2 ] = config->user_baud_rate; +break ; +case EDL_TAG_ID_DEEP_SLEEP : +/* Sleep enable mask +* enabling deep sleep feature on controller. +*/ + tlv_nvm->data[0 ] |=0x01 ; +break ; + } + + idx += (sizeof (u16) +sizeof (u16) +8 + tag_len); + } +break ; +default : +BT_ERR ("Unknown TLV type %d" , config->type); +break ; + } +} + +static int cherokee_tlv_send_segment (struct hci_dev *hdev,int idx, +int seg_size,const u8 *data) +{ +u8 cmd[MAX_SIZE_PER_TLV_SEGMENT +2 ]; +int err =0 ; + +BT_DBG ("%s: Download segment #%d size %d" , hdev->name, idx, seg_size); + + cmd[0 ] =EDL_PATCH_TLV_REQ_CMD ; + cmd[1 ] = seg_size; +memcpy (cmd +2 , data, seg_size); + + err =__hci_cmd_no_event (hdev,EDL_PATCH_CMD_OPCODE , seg_size +2 , + cmd); +if (err <0 ) { +BT_ERR ("%s: Failed to send TLV segment (%d)" , hdev->name, err); +return err; + } + +return err; +} + +static int qca_btsoc_tlv_send_segment (struct hci_dev *hdev,int idx, +int seg_size,const u8 *data) {struct sk_buff *skb;struct edl_event_hdr *edl;
@@ -264,16 +313,56 @@ static int rome_tlv_download_request(struct hci_dev *hdev, data = fw->data;for (i =0 ; i < total_segment; i++) { buffer = data + i *MAX_SIZE_PER_TLV_SEGMENT ; - ret =rome_tlv_send_segment (hdev, i,MAX_SIZE_PER_TLV_SEGMENT , - buffer); + ret =qca_btsoc_tlv_send_segment (hdev, i, +MAX_SIZE_PER_TLV_SEGMENT , buffer);if (ret <0 )return -EIO ; }if (remain_size) { buffer = data + total_segment *MAX_SIZE_PER_TLV_SEGMENT ; - ret =rome_tlv_send_segment (hdev, total_segment, remain_size, - buffer); + ret =qca_btsoc_tlv_send_segment (hdev, total_segment, + remain_size, buffer); +if (ret <0 ) +return -EIO ; + } + +return 0 ; +} +static int cherokee_tlv_download_request (struct hci_dev *hdev, +const struct firmware *fw) +{ +const u8 *buffer, *data; +int total_segment, remain_size; +int ret, i; + +if (!fw || !fw->data) +return -EINVAL ; + + total_segment = fw->size /MAX_SIZE_PER_TLV_SEGMENT ; + remain_size = fw->size %MAX_SIZE_PER_TLV_SEGMENT ; + +BT_DBG ("%s: Total segment num %d remain size %d total size %zu" , + hdev->name, total_segment, remain_size, fw->size); + + data = fw->data; +for (i =0 ; i < total_segment; i++) { + buffer = data + i *MAX_SIZE_PER_TLV_SEGMENT ; +/* Read response from soc for last segment sent */ +if (!remain_size && ((i+1 ) == total_segment)) + ret =qca_btsoc_tlv_send_segment (hdev, i, +MAX_SIZE_PER_TLV_SEGMENT , buffer); +else + ret =cherokee_tlv_send_segment (hdev, i, +MAX_SIZE_PER_TLV_SEGMENT , buffer); +if (ret <0 ) +return -EIO ; + } + +if (remain_size) { + buffer = data + total_segment *MAX_SIZE_PER_TLV_SEGMENT ; + ret =qca_btsoc_tlv_send_segment (hdev, total_segment, + remain_size, buffer);if (ret <0 )return -EIO ; }
@@ -282,7 +371,7 @@ static int rome_tlv_download_request(struct hci_dev *hdev, }static int rome_download_firmware (struct hci_dev *hdev, -struct rome_config *config) +struct qca_config *config) {const struct firmware *fw;int ret;
@@ -309,7 +398,46 @@ static int rome_download_firmware(struct hci_dev *hdev,return ret; } -int qca_set_bdaddr_rome (struct hci_dev *hdev,const bdaddr_t *bdaddr) +static int cherokee_download_firmware (struct hci_dev *hdev, +struct qca_config *config) +{ +const struct firmware *fw; +bool dwnd_flag = true; +int ret; + +BT_INFO ("%s: wcn3990 Downloading %s" , hdev->name, config->fwname); + + ret =request_firmware (&fw, config->fwname, &hdev->dev); +if (ret) { +BT_ERR ("%s: Failed to request file: %s (%d)" , hdev->name, + config->fwname, ret); +return ret; + } + +cherokee_tlv_check_data (config, fw, &dwnd_flag); +/* check whether the download flag is set.if bit is enabled +* terminate the ram patch download. As we are not supporting, +* receiving of response from soc for every segment sent. +* We look for response from soc for last segment. +*/ +if (dwnd_flag == true && config->type ==TLV_TYPE_PATCH ) { +BT_ERR ("%s: btsoc download flag enabled" , hdev->name); +return -EOPNOTSUPP ; + } + + ret =cherokee_tlv_download_request (hdev, fw); +if (ret) { +BT_ERR ("%s: Failed to download file: %s (%d)" , hdev->name, + config->fwname, ret); + } + +release_firmware (fw); + +return ret; +} + + +int qca_btsoc_set_bdaddr (struct hci_dev *hdev,const bdaddr_t *bdaddr) {struct sk_buff *skb;u8 cmd[9 ];
@@ -332,12 +460,12 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)return 0 ; } -EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome); +EXPORT_SYMBOL_GPL (qca_btsoc_set_bdaddr);int qca_uart_setup_rome (struct hci_dev *hdev,uint8_t baudrate) {u32 rome_ver =0 ; -struct rome_config config; +struct qca_config config;int err;BT_DBG ("%s: ROME setup on UART" , hdev->name);
@@ -345,7 +473,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate;/* Get ROME version information */ - err =rome_patch_ver_req (hdev, &rome_ver); + err =qca_btsoc_patch_ver_req (hdev, &rome_ver);if (err <0 || rome_ver ==0 ) {BT_ERR ("%s: Failed to get version 0x%x" , hdev->name, err);return err;
@@ -374,7 +502,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) }/* Perform HCI reset */ - err =rome_reset (hdev); + err =qca_btsoc_reset (hdev);if (err <0 ) {BT_ERR ("%s: Failed to run HCI_RESET (%d)" , hdev->name, err);return err;
@@ -386,6 +514,111 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) }EXPORT_SYMBOL_GPL (qca_uart_setup_rome); +int qca_btsoc_patch_ver_req (struct hci_dev *hdev,u32 *soc_version) +{ +struct sk_buff *skb; +struct edl_event_hdr *edl; +struct qca_btsoc_version *ver; +char cmd; +int err =0 ; + +BT_DBG ("%s: BTSOC Patch Version Request" , hdev->name); + + cmd =EDL_PATCH_VER_REQ_CMD ; + skb =__hci_cmd_sync_ev (hdev,EDL_PATCH_CMD_OPCODE ,EDL_PATCH_CMD_LEN , + &cmd,HCI_VENDOR_PKT ,HCI_INIT_TIMEOUT ); +if (IS_ERR (skb)) { + err =PTR_ERR (skb); +BT_ERR ("%s: Failed to read version of ROME (%d)" , hdev->name, + err); +return err; + } + +if (skb->len !=sizeof (*edl) +sizeof (*ver)) { +BT_ERR ("%s: Version size mismatch len %d" , hdev->name, + skb->len); + err = -EILSEQ ; + goto out; + } + + edl = (struct edl_event_hdr *)(skb->data); +if (!edl) { +BT_ERR ("%s: TLV with no header" , hdev->name); + err = -EILSEQ ; + goto out; + } + +if (edl->cresp !=EDL_CMD_REQ_RES_EVT || + edl->rtype !=EDL_APP_VER_RES_EVT ) { +BT_ERR ("%s: Wrong packet received %d %d" , hdev->name, + edl->cresp, edl->rtype); + err = -EIO ; + goto out; + } + + ver = (struct qca_btsoc_version *)(edl->data); + +BT_DBG ("%s: Product:0x%08x" , hdev->name,le32_to_cpu (ver->product_id)); +BT_DBG ("%s: Patch :0x%08x" , hdev->name,le16_to_cpu (ver->patch_ver)); +BT_DBG ("%s: ROM :0x%08x" , hdev->name,le16_to_cpu (ver->btsoc_ver)); +BT_DBG ("%s: SOC :0x%08x" , hdev->name,le32_to_cpu (ver->soc_id)); + +/* BTSOC chipset version can be decided by patch and SoC +* version, combination with upper 2 bytes from SoC +* and lower 2 bytes from patch will be used. +*/ + *soc_version = (le32_to_cpu (ver->soc_id) <<16 ) | + (le16_to_cpu (ver->btsoc_ver) &0x0000ffff ); + +out: +kfree_skb (skb); + +return err; +} +EXPORT_SYMBOL_GPL (qca_btsoc_patch_ver_req); + +int qca_uart_setup_cherokee (struct hci_dev *hdev,uint8_t baudrate, +u32 *cherokee_ver) +{ +struct qca_config config; +int err; + +BT_DBG ("%s: wcn3990 setup on UART" , hdev->name); + config.user_baud_rate = baudrate; + +/* Download rampatch file */ + config.type =TLV_TYPE_PATCH ; +snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.tlv" , + *cherokee_ver); + err =cherokee_download_firmware (hdev, &config); +if (err <0 ) { +BT_ERR ("%s: Failed to download patch (%d)" , hdev->name, err); +return err; + } + +/* Download NVM configuration */ + config.type =TLV_TYPE_NVM ; +snprintf (config.fwname,sizeof (config.fwname),"qca/nvm_%08x.bin" , + *cherokee_ver); + err =cherokee_download_firmware (hdev, &config); +if (err <0 ) { +BT_ERR ("%s: Failed to download NVM (%d)" , hdev->name, err); +return err; + } + +/* Perform HCI reset */ + err =qca_btsoc_reset (hdev); +if (err <0 ) { +BT_ERR ("%s: Failed to run HCI_RESET (%d)" , hdev->name, err); +return err; + } + +BT_INFO ("%s: wcn3990 setup on UART is completed" , hdev->name); + +return 0 ; +} +EXPORT_SYMBOL_GPL (qca_uart_setup_cherokee); +MODULE_AUTHOR ("Ben Young Tae Kim <[email protected]>" );MODULE_DESCRIPTION ("Bluetooth support for Qualcomm Atheros family ver " VERSION );MODULE_VERSION (VERSION );
drivers/bluetooth/btqca.h +40 -6
95 lines not on this page · raw message
drivers/bluetooth/hci_qca.c +280 -44
380 lines not on this page · raw message
include/net/bluetooth/hci_core.h +2 -1
@@ -1418,7 +1418,8 @@ struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, const void *param, u32 timeout);struct sk_buff *__hci_cmd_sync_ev (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param,u8 event,u32 timeout); - +int __hci_cmd_no_event (struct hci_dev *hdev,u16 opcode,u32 plen, +const void *param);int hci_send_cmd (struct hci_dev *hdev,__u16 opcode,__u32 plen,const void *param);void hci_send_acl (struct hci_chan *chan,struct sk_buff *skb,__u16 flags);
net/bluetooth/hci_core.c +1 -1
@@ -3370,7 +3370,7 @@ int hci_unregister_cb(struct hci_cb *cb) }EXPORT_SYMBOL (hci_unregister_cb); -static void hci_send_frame (struct hci_dev *hdev,struct sk_buff *skb) +void hci_send_frame (struct hci_dev *hdev,struct sk_buff *skb) {int err;
net/bluetooth/hci_request.c +23 -0
@@ -114,6 +114,29 @@ void hci_req_sync_cancel(struct hci_dev *hdev, int err) } } +/* Queue a frame to an asynchronous transfer to btdevice, +* with out any event from btdevice. +*/ +int __hci_cmd_no_event (struct hci_dev *hdev,u16 opcode,u32 plen, +const void *param) +{ +struct sk_buff *skb; + +BT_DBG ("%s opcode 0x%4.4x plen %d" , hdev->name, opcode, plen); + + skb =hci_prepare_cmd (hdev, opcode, plen, param); +if (!skb) { +BT_ERR ("%s no memory for command (opcode 0x%4.4x)" , + hdev->name, opcode); +return -ENOMEM ; + } + +hci_send_frame (hdev, skb); + +return 0 ; +} +EXPORT_SYMBOL (__hci_cmd_no_event); +struct sk_buff *__hci_cmd_sync_ev (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param,u8 event,u32 timeout) {
net/bluetooth/hci_request.h +2 -0
@@ -128,3 +128,5 @@ static inline u16 eir_append_le16(u8 *eir, u16 eir_len, u8 type, u16 data)return eir_len; } + +void hci_send_frame (struct hci_dev *hdev,struct sk_buff *skb);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Marcel Holtmann
maintainerRe: [PATCH 2/3] Add support to power Bluetooth QCA chips attached to MSM
In reply to Balakrishna GodavarthiHi Balakrishna,
Quoted 123 lines
Add support to set voltage/current of various regulators to power up/down BT QCA chips attached to MSM.
Change-Id I3600dd7bc97c753bc9cf7f8ac39d7b90bc21c67dSigned-off-by Rupesh Tatiya <[email protected]>---
drivers/bluetooth/Makefile | 5 +- drivers/bluetooth/btqca_power.c | 177 ++++++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btqca_power.h | 71 ++++++++++++++++ 3 files changed, 251 insertions(+), 2 deletions(-)create mode 100644
drivers/bluetooth/btqca_power.ccreate mode 100644drivers/bluetooth/btqca_power.hdrivers/bluetooth/Makefile +0
-0@@ -24,8 +24,9 @@ obj-$(CONFIG_BT_WILINK) += btwilink.oobj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o
obj-$(CONFIG_BT_RTL) += btrtl.odrivers/bluetooth/Makefile +3
-2-obj-$(CONFIG_BT_QCA) += btqca.o - +obj-$(CONFIG_BT_QCA) += btqca_uart.o +btqca_uart-$(CONFIG_BT_QCA) += btqca.o +btqca_uart-$(CONFIG_BT_QCA) += btqca_power.oobj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o
btmrvl-y := btmrvl_main.o
drivers/bluetooth/btqca_power.c new file +88
-0@@ -0,0 +1,177 @@ +/* Copyright (c) 2009-2010, 2013-2018 The Linux Foundation. +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +/* +* Bluetooth Power Switch Module +* controls power to external Bluetooth device +* with interface to power management device +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/of_device.h> +#include <net/bluetooth/bluetooth.h> + +#include "btqca_power.h" + +static struct btqca_power *qca; + +static const struct btqca_vreg_data cherokee_data = { + .soc_type =BTQCA_CHEROKEE , + .vregs = (struct btqca_vreg []) { + {"vddio" ,1352000 ,1352000 ,0 }, + {"vddxtal" ,1904000 ,2040000 ,0 }, + {"vddcore" ,1800000 ,1800000 ,1 }, + {"vddpa" ,130400 ,1304000 ,1 }, + {"vddldo" ,3000000 ,3312000 ,1 }, + {"vddpwd" ,3312000 ,3600000 ,0 }, + }, + .num_vregs =6 , +}; + +static const struct of_device_id btqca_power_match_table[] = { + { .compatible ="qca,wcn3990" , .data = &cherokee_data}, + {} +}; + +int btqca_get_soc_type (enum btqca_soc_t *type) +{ +if (!qca || !qca->vreg_data) +return -EINVAL ; + + *type = qca->vreg_data->soc_type; +return 0 ; +} +EXPORT_SYMBOL_GPL (btqca_get_soc_type); + +int btqca_power_setup (int on) +{ +int ret =0 ; +int i; +struct btqca_vreg *vregs; + +if (!qca || !qca->vreg_data || !qca->vreg_bulk) +return -EINVAL ; + vregs = qca->vreg_data->vregs; + +BT_DBG ("on: %d" , on); + +if (on) { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_set_voltage (qca->vreg_bulk[i].consumer, + vregs[i].min_v, + vregs[i].max_v); + +if (vregs[i].load_ua) +regulator_set_load (qca->vreg_bulk[i].consumer, + vregs[i].load_ua); + +regulator_enable (qca->vreg_bulk[i].consumer); + } + }else { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_disable (qca->vreg_bulk[i].consumer); +
drivers/bluetooth/btqca_power.c line 98
Quoted 10 lines
drivers/bluetooth/btqca_power.c new file +10
-0+regulator_set_voltage (qca->vreg_bulk[i].consumer, +0 , vregs[i].max_v); + +regulator_set_load (qca->vreg_bulk[i].consumer,0 ); + } + } + +return ret; +} +EXPORT_SYMBOL_GPL (btqca_power_setup);
I do not get why this is a separate module and totally disconnected from the Bluetooth driver. We have pending patches for using serdev for the hci_qca.c and it seems that should be all build together. I am not really keen on adding platform device and platform data here. So frankly I am missing the big picture on how this is suppose to work. We are driving towards serdev and thus a clean support for UART based devices. This seems to be doing something else.
Regards
Marcel
Marcel Holtmann
maintainerRe: [PATCH 1/3] Bluetooth: Add device tree bindings for Atheros chips
In reply to Balakrishna GodavarthiHi Balakrishan,
Quoted 33 lines
Change-Id Ie62e3b90b6226019142206c8d44712a6c8550ef2Signed-off-by Rupesh Tatiya <[email protected]>---
.../devicetree/bindings/bluetooth/btqca_power.txt| 30 ++++++++++++++++++++++1 file changed, 30 insertions(+)create mode 100644
Documentation/devicetree/bindings/bluetooth/btqca_power.txtDocumentation/devicetree/bindings/bluetooth/btqca_power.txt new file +20
-0@@ -0,0 +1,30 @@ +* Bluetooth Controller +Bluetooth controller communicates with the Bluetooth Host using HCI Transport layer. +HCI Transport layer can be based on UART or USB serial communication protocol. + +Required properties: + - compatible: Should be set to one of the following: + qca,ar3002 + qca,qca6174 + qca,wcn3990 + +Optional properties: + - vddpa-supply: Bluetooth VDD PA regulator handle + - vddio-supply: Bluetooth VDD IO regulator handle + - vddldo-supply: Bluetooth VDD LDO regulator handle. Kept under optional parameters + as some of the chipsets doesn't require ldo or it may use from same vddio. + - vddxtal-supply: Bluetooth VDD XTAL regulator handle + - vddcore-supply: Bluetooth VDD CORE regulator handle + - vddpwd-supply: Chip power down gpio is required when bluetooth module + and other modules like wifi co-exist in a singe chip and shares a + common gpio to bring chip out of reset.
Documentation/devicetree/bindings/bluetooth/btqca_power.txt line 30
Quoted 10 lines
Documentation/devicetree/bindings/bluetooth/btqca_power.txt new file +10
-0+ +Example: + bt-ar3002 { + compatible = "qca,ar3002"; + vddio-supply = <&pm8941_s3>; + vddpa-supply = <&pm8941_l19>; + vddxtal-supply = <&pm8994_l30>; + vddcore-supply = <&pm8994_s3>; + vddpwd-supply = <&ath_chip_pwd_l>; +};
so I do not get this. I assumed we want to tie these to the UART and the Bluetooth serdev slave on top of that UART. Doing them as random platform device is pointless to me.
Regards
Marcel
Re: [PATCH 2/3] Add support to power Bluetooth QCA chips attached to MSM
In reply to Marcel HoltmannHi Marcel,
Quoted 146 lines · Marcel Holtmann
Hi Balakrishna,
Quoted 125 lines
Add support to set voltage/current of various regulators to power up/down BT QCA chips attached to MSM.
Change-Id I3600dd7bc97c753bc9cf7f8ac39d7b90bc21c67dSigned-off-by Rupesh Tatiya <[email protected]>---
drivers/bluetooth/Makefile| 5 +-drivers/bluetooth/btqca_power.c| 177
++++++++++++++++++++++++++++++++++++++++drivers/bluetooth/btqca_power.h| 71 ++++++++++++++++3 files changed, 251 insertions(+), 2 deletions(-)create mode 100644
drivers/bluetooth/btqca_power.ccreate mode 100644drivers/bluetooth/btqca_power.hdrivers/bluetooth/Makefile +0
-0@@ -24,8 +24,9 @@ obj-$(CONFIG_BT_WILINK) += btwilink.oobj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o
obj-$(CONFIG_BT_RTL) += btrtl.odrivers/bluetooth/Makefile +3
-2-obj-$(CONFIG_BT_QCA) += btqca.o - +obj-$(CONFIG_BT_QCA) += btqca_uart.o +btqca_uart-$(CONFIG_BT_QCA) += btqca.o +btqca_uart-$(CONFIG_BT_QCA) += btqca_power.oobj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o
btmrvl-y := btmrvl_main.o
drivers/bluetooth/btqca_power.c new file +4
-0@@ -0,0 +1,177 @@ +/* Copyright (c) 2009-2010, 2013-2018 The Linux Foundation. +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */drivers/bluetooth/btqca_power.c new file +76
-0+/* +* Bluetooth Power Switch Module +* controls power to external Bluetooth device +* with interface to power management device +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/of_device.h> +#include <net/bluetooth/bluetooth.h> + +#include "btqca_power.h" + +static struct btqca_power *qca; + +static const struct btqca_vreg_data cherokee_data = { + .soc_type =BTQCA_CHEROKEE , + .vregs = (struct btqca_vreg []) { + {"vddio" ,1352000 ,1352000 ,0 }, + {"vddxtal" ,1904000 ,2040000 ,0 }, + {"vddcore" ,1800000 ,1800000 ,1 }, + {"vddpa" ,130400 ,1304000 ,1 }, + {"vddldo" ,3000000 ,3312000 ,1 }, + {"vddpwd" ,3312000 ,3600000 ,0 }, + }, + .num_vregs =6 , +}; + +static const struct of_device_id btqca_power_match_table[] = { + { .compatible ="qca,wcn3990" , .data = &cherokee_data}, + {} +}; + +int btqca_get_soc_type (enum btqca_soc_t *type) +{ +if (!qca || !qca->vreg_data) +return -EINVAL ; + + *type = qca->vreg_data->soc_type; +return 0 ; +} +EXPORT_SYMBOL_GPL (btqca_get_soc_type); + +int btqca_power_setup (int on) +{ +int ret =0 ; +int i; +struct btqca_vreg *vregs; + +if (!qca || !qca->vreg_data || !qca->vreg_bulk) +return -EINVAL ; + vregs = qca->vreg_data->vregs; + +BT_DBG ("on: %d" , on); + +if (on) { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_set_voltage (qca->vreg_bulk[i].consumer, + vregs[i].min_v, + vregs[i].max_v); + +if (vregs[i].load_ua) +regulator_set_load (qca->vreg_bulk[i].consumer, + vregs[i].load_ua); + +regulator_enable (qca->vreg_bulk[i].consumer); + } + }else { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_disable (qca->vreg_bulk[i].consumer); +drivers/bluetooth/btqca_power.c line 98
Quoted 10 lines
drivers/bluetooth/btqca_power.c new file +10
-0+regulator_set_voltage (qca->vreg_bulk[i].consumer, +0 , vregs[i].max_v); + +regulator_set_load (qca->vreg_bulk[i].consumer,0 ); + } + } + +return ret; +} +EXPORT_SYMBOL_GPL (btqca_power_setup);I do not get why this is a separate module and totally disconnected from the Bluetooth driver. We have pending patches for using serdev for the
hci_qca.cand it seems that should be all build together. I am not really keen on adding platform device and platform data here. So frankly I am missing the big picture on how this is suppose to work. We are driving towards serdev and thus a clean support for UART based devices. This seems to be doing something else.
Quoted 3 lines
Regards
Marcel
These patches are for older design based on line discipline and hciattach/btattach. I was unaware of the serdev side of changes. We will rewrite these changes on top of serdev patches for hci_qca.c
In the bigger picture, this change contains code to power on/off WCN3990. Across different host MSMs and PMICs, the regulators that need to be voted are different. So we add these changes into device tree. The on/off API is called from hci_qca.c. (HCIDEVUP -> qca_setup -> btacq_power_setup). In serdev design, we will read these regulators as a part of probe & still vote them in context of HCIDEVUP/HCIDEVDOWN.
One minor issue I have with serdev is, it seems to be aligned with BlueZ architecture. There are other protocol stacks which are completely written in userspace & do not have any protocol layers (and line discipline in old design) in kernel (e.g. Fluoride in Android). Even for such cases, the sequence to turn WCN3990 on/off does not change. In such case, we expose a char device or sysfs entry to userspace & perform voting through ioctl calls. This code can not be reused in such cases. Hypothetically, voting code can be added to something like tty_serdev (parallel to n_tty line discipline) for non-BlueZ cases.
But serdev seems to link voting code to tty clients (hci_serdev or tty_serdev) when client really does not have any relation to it (at least in case of WCN3990). I would be very happy to get my understanding corrected if there are any mistakes and hear your thoughts on this.
Best Regards,
Rupesh
Marcel Holtmann
maintainerRe: [PATCH 2/3] Add support to power Bluetooth QCA chips attached to MSM
Hi Rupesh,
Quoted 144 lines
Quoted 131 lines
Quoted 120 lines
Add support to set voltage/current of various regulators to power up/down BT QCA chips attached to MSM.
Change-Id I3600dd7bc97c753bc9cf7f8ac39d7b90bc21c67dSigned-off-by Rupesh Tatiya <[email protected]>---
drivers/bluetooth/Makefile | 5 +- drivers/bluetooth/btqca_power.c | 177 ++++++++++++++++++++++++++++++++++++++++ drivers/bluetooth/btqca_power.h | 71 ++++++++++++++++ 3 files changed, 251 insertions(+), 2 deletions(-)create mode 100644
drivers/bluetooth/btqca_power.ccreate mode 100644drivers/bluetooth/btqca_power.hdrivers/bluetooth/Makefile +0
-0@@ -24,8 +24,9 @@ obj-$(CONFIG_BT_WILINK) += btwilink.oobj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o
obj-$(CONFIG_BT_RTL) += btrtl.odrivers/bluetooth/Makefile +3
-2-obj-$(CONFIG_BT_QCA) += btqca.o - +obj-$(CONFIG_BT_QCA) += btqca_uart.o +btqca_uart-$(CONFIG_BT_QCA) += btqca.o +btqca_uart-$(CONFIG_BT_QCA) += btqca_power.oobj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o
btmrvl-y := btmrvl_main.odrivers/bluetooth/btqca_power.c new file +88
-0@@ -0,0 +1,177 @@ +/* Copyright (c) 2009-2010, 2013-2018 The Linux Foundation. +* All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +/* +* Bluetooth Power Switch Module +* controls power to external Bluetooth device +* with interface to power management device +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include <linux/regulator/consumer.h> +#include <linux/of_device.h> +#include <net/bluetooth/bluetooth.h> + +#include "btqca_power.h" + +static struct btqca_power *qca; + +static const struct btqca_vreg_data cherokee_data = { + .soc_type =BTQCA_CHEROKEE , + .vregs = (struct btqca_vreg []) { + {"vddio" ,1352000 ,1352000 ,0 }, + {"vddxtal" ,1904000 ,2040000 ,0 }, + {"vddcore" ,1800000 ,1800000 ,1 }, + {"vddpa" ,130400 ,1304000 ,1 }, + {"vddldo" ,3000000 ,3312000 ,1 }, + {"vddpwd" ,3312000 ,3600000 ,0 }, + }, + .num_vregs =6 , +}; + +static const struct of_device_id btqca_power_match_table[] = { + { .compatible ="qca,wcn3990" , .data = &cherokee_data}, + {} +}; + +int btqca_get_soc_type (enum btqca_soc_t *type) +{ +if (!qca || !qca->vreg_data) +return -EINVAL ; + + *type = qca->vreg_data->soc_type; +return 0 ; +} +EXPORT_SYMBOL_GPL (btqca_get_soc_type); + +int btqca_power_setup (int on) +{ +int ret =0 ; +int i; +struct btqca_vreg *vregs; + +if (!qca || !qca->vreg_data || !qca->vreg_bulk) +return -EINVAL ; + vregs = qca->vreg_data->vregs; + +BT_DBG ("on: %d" , on); + +if (on) { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_set_voltage (qca->vreg_bulk[i].consumer, + vregs[i].min_v, + vregs[i].max_v); + +if (vregs[i].load_ua) +regulator_set_load (qca->vreg_bulk[i].consumer, + vregs[i].load_ua); + +regulator_enable (qca->vreg_bulk[i].consumer); + } + }else { +for (i =0 ; i < qca->vreg_data->num_vregs; i++) { +regulator_disable (qca->vreg_bulk[i].consumer); +drivers/bluetooth/btqca_power.c line 98
Quoted 10 lines
drivers/bluetooth/btqca_power.c new file +10
-0+regulator_set_voltage (qca->vreg_bulk[i].consumer, +0 , vregs[i].max_v); + +regulator_set_load (qca->vreg_bulk[i].consumer,0 ); + } + } + +return ret; +} +EXPORT_SYMBOL_GPL (btqca_power_setup);I do not get why this is a separate module and totally disconnected
Quoted 8 lines
from the Bluetooth driver. We have pending patches for using serdev for the
hci_qca.cand it seems that should be all build together. I am not really keen on adding platform device and platform data here. So frankly I am missing the big picture on how this is suppose to work. We are driving towards serdev and thus a clean support for UART based devices. This seems to be doing something else.
Regards
MarcelThese patches are for older design based on line discipline and hciattach/btattach. I was unaware of the serdev side of changes. We will rewrite these changes on top of serdev patches for
hci_qca.c
Quoted 6 lines
In the bigger picture, this change contains code to power on/off WCN3990. Across different host MSMs and PMICs, the regulators that need to be voted are different. So we add these changes into device tree. The on/off API is called from
hci_qca.c. (HCIDEVUP ->qca_setup->btacq_power_setup). In serdev design, we will read these regulators as a part of probe & still vote them in context of HCIDEVUP/HCIDEVDOWN.
the power control really needs to happen in open/close callbacks. Doing them in setup is a bit too late. We expect the transport to be ready since setup is allowed to execute HCI commands.
Quoted 8 lines
One minor issue I have with serdev is, it seems to be aligned with BlueZ architecture. There are other protocol stacks which are completely written in userspace & do not have any protocol layers (and line discipline in old design) in kernel (e.g. Fluoride in Android). Even for such cases, the sequence to turn WCN3990 on/off does not change. In such case, we expose a char device or sysfs entry to userspace & perform voting through ioctl calls. This code can not be reused in such cases. Hypothetically, voting code can be added to something like
tty_serdev(parallel ton_ttyline discipline) for non-BlueZ cases.
Just use HCI_CHANNEL_USER. It will give you raw HCI access. There is a driver for that in Android as well. It will then work with any hardware and the power control is correctly done by the kernel.
Quoted 4 lines
But serdev seems to link voting code to tty clients (
hci_serdevortty_serdev) when client really does not have any relation to it (at least in case of WCN3990). I would be very happy to get my understanding corrected if there are any mistakes and hear your thoughts on this.
Don’t get this. If you run Bluetooth, that means any opening of the TTY is done to run Bluetooth.
Regards
Marcel