Enable Bluetooth functionality for WCN3990
v7 cover Enable Bluetooth functionality for WCN3990
These patches enables Bluetooth functinalties for new Qualcomm Bluetooth chip wnc3990. As this is latest chip with new features, along with some common features to old chip "qcom,qca6174-bt". we have updated names of functions that are used for both the chips to keep this generic and would help in future when we would have new BT SoC.
The below are difference between new and old chips.
*Power:
*New chip: we use voltage regulators to turn on/off the chip and we
must send a command on Tx line to turn on/off the chip completely.
*Old chip: We turn on/off by setting a GPIO.
*Note: Turning on sequence differs between two chips.
*Firmware download:
Only firmware file name differ from New and Old chip.
So we reused some functions/structure/variables which are used for old chip to New chip by generic naming (may be future chips may use same functions).
* As we have multiple changes for functions names,we have tested these patches on both chips.
v7:
* Renamed all the possible function of ROME to generic.
* updated with review comments for hci_qca and btqca
* fixed kbuild errors.
* created wrapper functions for re-usable blocks.
v6:
* Hooked up qca_power to qca_serdev.
* renamed all the naming inconsistency functions with qca_*
* leveraged common code of ROME for wcn3990.
* created wrapper functions for re-usable blocks.
* updated function of _*regulator_enable and _*regualtor_disable.
* removed redundant comments and functions.
* add code to derive the firmware files based on ROM Version.
* created new patch for common function of ROME and wcn3990.
* enables Qualcomm chip to operate at 3.2Mbps.
* updated names of functions that are used for both the chips to keep this generic.
v5:
* updated with review comments for hci_qca and btqca
v4:
* rebased all changes on top of bluetooth-next.
* addressed review comments.
* New patch created for firmware download.
v3:
* Rebased all changes on top of bluetooth-next.
* dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
- added dt-binding snippet for bluetooth chip wcn3990.
* Bluetooth: Add support for wcn3990 soc.
- updated BT_INFO with bt_dev_info, where ever necessary.
v2:
* Add support for wcn3990:
These changes are aligned as per serdev frame work.
We implemented these changes on top of https://patchwork.kernel.org/patch/10316093/
As this patch enable serdev for one of the Qualcomm BT chip.
The changes in the patch include.
- Adding support to voting up/down regulators for WCN3990.
- Bluetooth firmware download for wcn3990.
* Add device tree bindings for Atheros chips:
These changes are on top of https://patchwork.kernel.org/patch/10316097/.
- Description of device tree bindings.
Balakrishna Godavarthi (8):
dt-bindings: net: bluetooth: Add device tree bindings for QTI chip
wcn3990
Bluetooth: btqca: Rename string ROME to QCA in logs.
Bluetooth: btqca: Rename ROME related functions to Generic functions
Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
Bluetooth: hci_qca: Enable 3.2 Mbps operating speed.
Bluetooth: btqca: Add wcn3990 firmware download support.
Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
.../bindings/net/qualcomm-bluetooth.txt | 31 +- drivers/bluetooth/btqca.c | 120 +++--- drivers/bluetooth/btqca.h | 24 +- drivers/bluetooth/hci_qca.c | 382 +++++++++++++++--- 4 files changed, 454 insertions(+), 103 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 1/8 dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
---
Changes in v7:
* no change.
Changes in v6:
* Changed the oper-speed to max-speed.
Changes in v5:
* Added entry for oper-speed and init-speed.
--- .../bindings/net/qualcomm-bluetooth.txt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +29 -2
@@ -10,12 +10,24 @@ device the slave device is attached to. Required properties: - compatible: should contain one of the following: * "qcom,qca6174-bt" + * "qcom,wcn3990-bt" Optional properties: - enable-gpios: gpio specifier used to enable chip - clocks: clock provided to the controller (SUSCLK_32KHZ) - -Example: + - 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. + - max-speed: operating speed of the chip. + +Examples: serial@7570000 { label = "BT-UART";
@@ -28,3 +40,18 @@ serial@7570000 { clocks = <&divclk4>; }; }; + +serial@898000 { + label = "BT-UART"; + status = "okay"; + + bluetooth: bt_wcn3990 { + compatible = "qcom,wcn3990-bt"; + vddio-supply = <&pm8998_s3>; + vddxtal-supply = <&pm8998_s5>; + vddcore-supply = <&pm8998_l7>; + vddpa-supply = <&pm8998_l17>; + vddldo-supply = <&pm8998_l25>; + max-speed = <3200000>; + }; +};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 2/8 Bluetooth: btqca: Rename string ROME to QCA in logs.
In reply to Balakrishna GodavarthiTo have generic text in bt_dev_info, bt_dev_err and bt_dev_dbg updated from ROME to QCA where ever possible. This avoids confusion to user, when using the future Qualcomm Bluetooth SoC's. Updated BT_DBG, BT_ERR and BT_INFO with bt_dev_dbg, bt_dev_err and bt_dev_info where ever applicable.
---
Changes in v7:
* initial patch.
* Updated the logs to generic.
--- drivers/bluetooth/btqca.c | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-)
drivers/bluetooth/btqca.c +27 -29
@@ -35,36 +35,35 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)char cmd;int err =0 ; -BT_DBG ("%s: ROME Patch Version Request" , hdev->name); +bt_dev_dbg (hdev,"QCA Version Request" ); 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); +bt_dev_err (hdev,"Reading QCA version information failed (%d)" , + err);return err; }if (skb->len !=sizeof (*edl) +sizeof (*ver)) { -BT_ERR ("%s: Version size mismatch len %d" , hdev->name, - skb->len); +bt_dev_err (hdev,"QCA Version size mismatch len %d" , skb->len); err = -EILSEQ ; goto out; } edl = (struct edl_event_hdr *)(skb->data);if (!edl) { -BT_ERR ("%s: TLV with no header" , hdev->name); +bt_dev_err (hdev,"QCA TLV with no header" ); 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); +bt_dev_err (hdev,"QCA Wrong packet received %d %d" , edl->cresp, + edl->rtype); err = -EIO ; goto out; }
@@ -76,7 +75,7 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)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 +/* QCA 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. */
@@ -94,12 +93,12 @@ static int rome_reset(struct hci_dev *hdev)struct sk_buff *skb;int err; -BT_DBG ("%s: ROME HCI_RESET" , hdev->name); +bt_dev_dbg (hdev,"QCA HCI_RESET" ); skb =__hci_cmd_sync (hdev,HCI_OP_RESET ,0 ,NULL ,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { err =PTR_ERR (skb); -BT_ERR ("%s: Reset failed (%d)" , hdev->name, err); +bt_dev_err (hdev,"QCA Reset failed (%d)" , err);return err; }
@@ -228,19 +227,19 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size, HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);if (IS_ERR (skb)) { err =PTR_ERR (skb); -BT_ERR ("%s: Failed to send TLV segment (%d)" , hdev->name, err); +bt_dev_err (hdev,"QCA Failed to send TLV segment (%d)" , err);return err; }if (skb->len !=sizeof (*edl) +sizeof (*tlv_resp)) { -BT_ERR ("%s: TLV response size mismatch" , hdev->name); +bt_dev_err (hdev,"QCA TLV response size mismatch" ); err = -EILSEQ ; goto out; } edl = (struct edl_event_hdr *)(skb->data);if (!edl) { -BT_ERR ("%s: TLV with no header" , hdev->name); +bt_dev_err (hdev,"TLV with no header" ); err = -EILSEQ ; goto out; }
@@ -249,8 +248,8 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,if (edl->cresp !=EDL_CMD_REQ_RES_EVT || edl->rtype !=EDL_TVL_DNLD_RES_EVT || tlv_resp->result !=0x00 ) { -BT_ERR ("%s: TLV with error stat 0x%x rtype 0x%x (0x%x)" , - hdev->name, edl->cresp, edl->rtype, tlv_resp->result); +bt_dev_err (hdev,"QCA TLV with error stat 0x%x rtype 0x%x (0x%x)" , + edl->cresp, edl->rtype, tlv_resp->result); err = -EIO ; }
@@ -267,12 +266,12 @@ static int rome_download_firmware(struct hci_dev *hdev,const u8 *segment;int ret, remain, i =0 ; -bt_dev_info (hdev,"ROME Downloading %s" , config->fwname); +bt_dev_info (hdev,"QCA Downloading %s" , 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); +bt_dev_err (hdev,"QCA Failed to request file: %s (%d)" , + config->fwname, ret);return ret; }
@@ -317,8 +316,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);if (IS_ERR (skb)) { err =PTR_ERR (skb); -BT_ERR ("%s: Change address command failed (%d)" , - hdev->name, err); +bt_dev_err (hdev,"QCA Change address command failed (%d)" , err);return err; }
@@ -334,18 +332,18 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)struct rome_config config;int err; -BT_DBG ("%s: ROME setup on UART" , hdev->name); +bt_dev_dbg (hdev,"QCA setup on UART" ); config.user_baud_rate = baudrate; -/* Get ROME version information */ +/* Get QCA version information */ err =rome_patch_ver_req (hdev, &rome_ver);if (err <0 || rome_ver ==0 ) { -BT_ERR ("%s: Failed to get version 0x%x" , hdev->name, err); +bt_dev_err (hdev,"QCA Failed to get version %d" , err);return err; } -bt_dev_info (hdev,"ROME controller version 0x%08x" , rome_ver); +bt_dev_info (hdev,"QCA controller version 0x%08x" , rome_ver);/* Download rampatch file */ config.type =TLV_TYPE_PATCH ;
@@ -353,7 +351,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) rome_ver); err =rome_download_firmware (hdev, &config);if (err <0 ) { -BT_ERR ("%s: Failed to download patch (%d)" , hdev->name, err); +bt_dev_err (hdev,"QCA Failed to download patch (%d)" , err);return err; }
@@ -363,18 +361,18 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) rome_ver); err =rome_download_firmware (hdev, &config);if (err <0 ) { -BT_ERR ("%s: Failed to download NVM (%d)" , hdev->name, err); +bt_dev_err (hdev,"QCA Failed to download NVM (%d)" , err);return err; }/* Perform HCI reset */ err =rome_reset (hdev);if (err <0 ) { -BT_ERR ("%s: Failed to run HCI_RESET (%d)" , hdev->name, err); +bt_dev_err (hdev,"QCA Failed to run HCI_RESET (%d)" , err);return err; } -bt_dev_info (hdev,"ROME setup on UART is completed" ); +bt_dev_info (hdev,"QCA setup on UART is completed" );return 0 ; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 3/8 Bluetooth: btqca: Rename ROME related functions to Generic functions
In reply to Balakrishna GodavarthiSome of the QCA BTSoC ROME functions, are used for different versions or different make of BTSoC's. Instead of duplicating the same functions for new chip, updating names of the functions that are used for both chip's to keep this generic and would help in future when we would have new BT SoC.
---
Changes in v7:
* updated the all the functions of ROME to generic.
Changes in v6:
* initial patch
* updated names of functions that are used for both the chips to keep this generic and would help in future when we would have new BT SoC.
--- drivers/bluetooth/btqca.c | 29 +++++++++++++++-------------- drivers/bluetooth/btqca.h | 12 +++++++++--- drivers/bluetooth/hci_qca.c | 2 +- 3 files changed, 25 insertions(+), 18 deletions(-)
drivers/bluetooth/btqca.c +15 -14
@@ -27,7 +27,7 @@#define VERSION "0.1" -static int rome_patch_ver_req (struct hci_dev *hdev,u32 *rome_version) +int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version) {struct sk_buff *skb;struct edl_event_hdr *edl;
@@ -79,7 +79,7 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)* 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 ) | + *soc_version = (le32_to_cpu (ver->soc_id) <<16 ) | (le16_to_cpu (ver->rome_ver) &0x0000ffff ); out:
@@ -87,8 +87,9 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)return err; } +EXPORT_SYMBOL_GPL (qca_read_soc_version); -static int rome_reset (struct hci_dev *hdev) +static int qca_send_reset (struct hci_dev *hdev) {struct sk_buff *skb;int err;
@@ -107,7 +108,7 @@ static int rome_reset(struct hci_dev *hdev)return 0 ; } -static void rome_tlv_check_data (struct rome_config *config, +static void qca_tlv_check_data (struct rome_config *config,const struct firmware *fw) {const u8 *data;
@@ -206,7 +207,7 @@ static void rome_tlv_check_data(struct rome_config *config, } } -static int rome_tlv_send_segment (struct hci_dev *hdev,int seg_size, +static int qca_tlv_send_segment (struct hci_dev *hdev,int seg_size,const u8 *data,enum rome_tlv_dnld_mode mode) {struct sk_buff *skb;
@@ -259,7 +260,7 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,return err; } -static int rome_download_firmware (struct hci_dev *hdev, +static int qca_download_firmware (struct hci_dev *hdev,struct rome_config *config) {const struct firmware *fw;
@@ -275,7 +276,7 @@ static int rome_download_firmware(struct hci_dev *hdev,return ret; } -rome_tlv_check_data (config, fw); +qca_tlv_check_data (config, fw); segment = fw->data; remain = fw->size;
@@ -289,7 +290,7 @@ static int rome_download_firmware(struct hci_dev *hdev,if (!remain || segsize <MAX_SIZE_PER_TLV_SEGMENT ) config->dnld_mode =ROME_SKIP_EVT_NONE ; - ret =rome_tlv_send_segment (hdev, segsize, segment, + ret =qca_tlv_send_segment (hdev, segsize, segment, config->dnld_mode);if (ret)break ;
@@ -326,7 +327,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome); -int qca_uart_setup_rome (struct hci_dev *hdev,uint8_t baudrate) +int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate) {u32 rome_ver =0 ;struct rome_config config;
@@ -337,7 +338,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate;/* Get QCA version information */ - err =rome_patch_ver_req (hdev, &rome_ver); + err =qca_read_soc_version (hdev, &rome_ver);if (err <0 || rome_ver ==0 ) {bt_dev_err (hdev,"QCA Failed to get version %d" , err);return err;
@@ -349,7 +350,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) config.type =TLV_TYPE_PATCH ;snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.bin" , rome_ver); - err =rome_download_firmware (hdev, &config); + err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download patch (%d)" , err);return err;
@@ -359,14 +360,14 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate) config.type =TLV_TYPE_NVM ;snprintf (config.fwname,sizeof (config.fwname),"qca/nvm_%08x.bin" , rome_ver); - err =rome_download_firmware (hdev, &config); + err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download NVM (%d)" , err);return err; }/* Perform HCI reset */ - err =rome_reset (hdev); + err =qca_send_reset (hdev);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to run HCI_RESET (%d)" , err);return err;
@@ -376,7 +377,7 @@ int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)return 0 ; } -EXPORT_SYMBOL_GPL (qca_uart_setup_rome); +EXPORT_SYMBOL_GPL (qca_uart_setup);MODULE_AUTHOR ("Ben Young Tae Kim <[email protected]>" );MODULE_DESCRIPTION ("Bluetooth support for Qualcomm Atheros family ver " VERSION );
drivers/bluetooth/btqca.h +9 -3
@@ -37,7 +37,7 @@#define EDL_TAG_ID_HCI (17)#define EDL_TAG_ID_DEEP_SLEEP (27) -enum qca_bardrate { +enum qca_baudrate {QCA_BAUDRATE_115200 =0 ,QCA_BAUDRATE_57600 ,QCA_BAUDRATE_38400 ,
@@ -127,7 +127,8 @@ struct tlv_type_hdr {#if IS_ENABLED (CONFIG_BT_QCA )int qca_set_bdaddr_rome (struct hci_dev *hdev,const bdaddr_t *bdaddr); -int qca_uart_setup_rome (struct hci_dev *hdev,uint8_t baudrate); +int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate); +int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version);#else
@@ -136,7 +137,12 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdadreturn -EOPNOTSUPP ; } -static inline int qca_uart_setup_rome (struct hci_dev *hdev,int speed) +static inline int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate) +{ +return -EOPNOTSUPP ; +} + +static inline int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version) {return -EOPNOTSUPP ; }
drivers/bluetooth/hci_qca.c +1 -1
@@ -966,7 +966,7 @@ static int qca_setup(struct hci_uart *hu) }/* Setup patch / NVM configurations */ - ret =qca_uart_setup_rome (hdev, qca_baudrate); + ret =qca_uart_setup (hdev, qca_baudrate);if (!ret) {set_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);qca_debugfs_init (hdev);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 4/8 Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiRedefinition of qca_uart_setup will help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new arguments soc_type and soc_ver to the functions.
These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.soc_type holds the Bluetooth chip connected to APPS processor. soc_ver holds the Bluetooth chip version.
---
Changes in v7:
* initial patch
* redefined qca_uart_setup function to generic.
--- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-)
drivers/bluetooth/btqca.c +12 -11
@@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome); -int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate) +int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate,uint8_t soc_type, +u32 soc_ver) { -u32 rome_ver =0 ;struct rome_config config;int err;
@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); } -bt_dev_info (hdev,"QCA controller version 0x%08x" , rome_ver); -/* Download rampatch file */ config.type =TLV_TYPE_PATCH ;snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.bin" , - rome_ver); + soc_ver); err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download patch (%d)" , err);
@@ -359,7 +360,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)/* Download NVM configuration */ config.type =TLV_TYPE_NVM ;snprintf (config.fwname,sizeof (config.fwname),"qca/nvm_%08x.bin" , - rome_ver); + soc_ver); err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download NVM (%d)" , err);
drivers/bluetooth/btqca.h +11 -2
@@ -124,10 +124,18 @@ struct tlv_type_hdr {__u8 data[0 ]; } __packed; +enum qca_btsoc_type { +QCA_INVALID =-1 , +QCA_AR3002 , +QCA_ROME , +QCA_WCN3990 +}; +#if IS_ENABLED (CONFIG_BT_QCA )int qca_set_bdaddr_rome (struct hci_dev *hdev,const bdaddr_t *bdaddr); -int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate); +int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate,uint8_t soc_type, +u32 soc_ver);int qca_read_soc_version (struct hci_dev *hdev,u32 *soc_version);#else
@@ -137,7 +145,8 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdadreturn -EOPNOTSUPP ; } -static inline int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate) +static inline int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate, +uint8_t soc_type,u32 soc_ver) {return -EOPNOTSUPP ; }
drivers/bluetooth/hci_qca.c +2 -1
@@ -929,6 +929,7 @@ static int qca_setup(struct hci_uart *hu)struct qca_data *qca = hu->priv;unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ;int ret; +int soc_ver =0 ;bt_dev_info (hdev,"ROME setup" );
@@ -966,7 +967,7 @@ static int qca_setup(struct hci_uart *hu) }/* Setup patch / NVM configurations */ - ret =qca_uart_setup (hdev, qca_baudrate); + ret =qca_uart_setup (hdev, qca_baudrate,QCA_ROME , soc_ver);if (!ret) {set_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);qca_debugfs_init (hdev);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 5/8 Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
In reply to Balakrishna GodavarthiIn qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.
---
Changes in v7:
* initial patch
* created wrapper functions for init and operating speeds.
--- drivers/bluetooth/hci_qca.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-)
drivers/bluetooth/hci_qca.c +45 -19
@@ -923,21 +923,10 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)hci_uart_set_baudrate (hu, speed); } -static int qca_setup (struct hci_uart *hu) +static void qca_set_init_speed (struct hci_uart *hu) { -struct hci_dev *hdev = hu->hdev; -struct qca_data *qca = hu->priv; -unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; -int ret; -int soc_ver =0 ; - -bt_dev_info (hdev,"ROME setup" ); - -/* Patch downloading has to be done without IBS mode */ -clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +unsigned int speed =0 ; -/* Setup initial baudrate */ - speed =0 ;if (hu->init_speed) speed = hu->init_speed;else if (hu->proto->init_speed)
@@ -945,27 +934,64 @@ static int qca_setup(struct hci_uart *hu)if (speed)host_set_baudrate (hu, speed); +} + +static int qca_get_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 ; -/* Setup user speed if needed */ - speed =0 ;if (hu->oper_speed) speed = hu->oper_speed;else if (hu->proto->oper_speed) speed = hu->proto->oper_speed; +return speed; +} + +static int qca_set_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 , qca_baudrate; +int ret =0 ; + + speed =qca_get_oper_speed (hu);if (speed) { qca_baudrate =qca_get_baudrate_value (speed); - -bt_dev_info (hdev,"Set UART speed to %d" , speed); - ret =qca_set_baudrate (hdev, qca_baudrate); +bt_dev_info (hu->hdev,"Set UART speed to %d" , speed); + ret =qca_set_baudrate (hu->hdev, qca_baudrate);if (ret) { -bt_dev_err (hdev,"Failed to change the baud rate (%d)" , +bt_dev_err (hu->hdev,"Failed to change the baud rate (%d)" , ret);return ret; }host_set_baudrate (hu, speed); } +return ret; +} + +static int qca_setup (struct hci_uart *hu) +{ +struct hci_dev *hdev = hu->hdev; +struct qca_data *qca = hu->priv; +unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; +int ret; +int soc_ver =0 ; + +bt_dev_info (hdev,"ROME setup" ); + +/* Patch downloading has to be done without IBS mode */ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); + +/* Setup initial baudrate */ +qca_set_init_speed (hu); +/* Setup user speed if needed */ + ret =qca_set_oper_speed (hu); +if (ret) +return ret; + speed =qca_get_oper_speed (hu); +if (speed) + qca_baudrate =qca_get_baudrate_value (speed); +/* Setup patch / NVM configurations */ ret =qca_uart_setup (hdev, qca_baudrate,QCA_ROME , soc_ver);if (!ret) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 6/8 Bluetooth: hci_qca: Enable 3.2 Mbps operating speed.
In reply to Balakrishna Godavarthi--- drivers/bluetooth/hci_qca.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +3 -1
@@ -872,6 +872,8 @@ static uint8_t qca_get_baudrate_value(int speed)return QCA_BAUDRATE_2000000 ;case 3000000 :return QCA_BAUDRATE_3000000 ; +case 3200000 : +return QCA_BAUDRATE_3200000 ;case 3500000 :return QCA_BAUDRATE_3500000 ;default :
@@ -886,7 +888,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)struct sk_buff *skb;u8 cmd[] = {0x01 ,0x48 ,0xFC ,0x01 ,0x00 }; -if (baudrate >QCA_BAUDRATE_3000000 ) +if (baudrate >QCA_BAUDRATE_3200000 )return -EINVAL ; cmd[4 ] = baudrate;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 7/8 Bluetooth: btqca: Add wcn3990 firmware download support.
In reply to Balakrishna GodavarthiThis patch enables the RAM and NV patch download for wcn3990.
---
Changes in v7:
* used redefined function qca_uart_setup for firmware download.
Changes in v6:
* add code to derive the firmware files based on ROM Version.
* created new patch for common function of ROME and wcn3990.
Changes in v5:
* moved changes related to hci_qca.
* addressed review comments.
Changes in v4:
* initial patch.
--- drivers/bluetooth/btqca.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/bluetooth/btqca.c +21 -5
@@ -332,6 +332,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, {struct rome_config config;int err; +u8 rom_ver;bt_dev_dbg (hdev,"QCA setup on UART" );
@@ -346,11 +347,21 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, }bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); } -/* Download rampatch file */ config.type =TLV_TYPE_PATCH ; -snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.bin" , - soc_ver); +if (soc_type ==QCA_WCN3990 ) { +/* Firmware files to download are based on ROM version. +* ROM version is derived from last two bytes of soc_ver. +*/ + rom_ver = ((soc_ver &0x00000f00 ) >>0x04 ) | + (soc_ver &0x0000000f ); +snprintf (config.fwname,sizeof (config.fwname), +"qca/crbtfw%02x.tlv" , rom_ver); + }else { +snprintf (config.fwname,sizeof (config.fwname), +"qca/rampatch_%08x.bin" , soc_ver); + } + err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download patch (%d)" , err);
@@ -359,8 +370,13 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type,/* Download NVM configuration */ config.type =TLV_TYPE_NVM ; -snprintf (config.fwname,sizeof (config.fwname),"qca/nvm_%08x.bin" , - soc_ver); +if (soc_type ==QCA_WCN3990 ) +snprintf (config.fwname,sizeof (config.fwname), +"qca/crnv%02x.bin" , rom_ver); +else +snprintf (config.fwname,sizeof (config.fwname), +"qca/nvm_%08x.bin" , soc_ver); + err =qca_download_firmware (hdev, &config);if (err <0 ) {bt_dev_err (hdev,"QCA Failed to download NVM (%d)" , err);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v7 8/8 Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Balakrishna GodavarthiAdd support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.
---
changes in v6:
* addressed review comments.
changes in v6:
* Hooked up qca_power to qca_serdev.
* renamed all the naming inconsistency functions with qca_*
* leveraged common code of ROME for wcn3990.
* created wrapper functions for re-usable blocks.
* updated function of _*regulator_enable and _*regualtor_disable.
* removed redundant comments and functions.
* addressed review comments.
Changes in v5:
* updated regulator vddpa min_uV to 1304000.
* addressed review comments.
Changes in v4:
* Segregated the changes of btqca from hci_qca
* rebased all changes on top of bluetooth-next.
* addressed review comments.
--- drivers/bluetooth/btqca.h | 3 + drivers/bluetooth/hci_qca.c | 327 ++++++++++++++++++++++++++++++++---- 2 files changed, 297 insertions(+), 33 deletions(-)
drivers/bluetooth/btqca.h +3 -0
@@ -37,6 +37,9 @@#define EDL_TAG_ID_HCI (17)#define EDL_TAG_ID_DEEP_SLEEP (27) +#define CHEROKEE_POWERON_PULSE 0xFC +#define CHEROKEE_POWEROFF_PULSE 0xC0 +enum qca_baudrate {QCA_BAUDRATE_115200 =0 ,QCA_BAUDRATE_57600 ,
drivers/bluetooth/hci_qca.c +294 -33
441 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
Rob Herring
maintainerRe: [PATCH v7 1/8] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
In reply to Balakrishna GodavarthiQuoted 1 line · Balakrishna Godavarthi
Signed-off-by Balakrishna Godavarthi <[email protected]>
Commit messag missing.
Please use get_maintainers.pl and send patches to the right lists. DT list in this case.
Quoted 26 lines
---
Changes in v7:
* no change.Changes in v6:
* Changed the oper-speed to max-speed.
Changes in v5:
* Added entry for oper-speed and init-speed.
--- .../bindings/net/qualcomm-bluetooth.txt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +1
-0@@ -10,12 +10,24 @@ device the slave device is attached to. Required properties: - compatible: should contain one of the following: * "qcom,qca6174-bt" + * "qcom,wcn3990-bt"
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt device the slave device is attached to. · line 22
Quoted 10 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +5
-2Optional properties: - enable-gpios: gpio specifier used to enable chip - clocks: clock provided to the controller (SUSCLK_32KHZ) - -Example: + - 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.
You need to be explicit as to which properties apply or don't apply to specific compatible strings.
Supplies should be based on inputs to the chip, so if 1 regulator supplies 2 inputs you still need both.
Quoted 12 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +8
-0+ - 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. + - max-speed: operating speed of the chip. + +Examples: serial@7570000 { label = "BT-UART";
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt serial@7570000 { · line 48
Quoted 9 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6
-0@@ -28,3 +40,18 @@ serial@7570000 { clocks = <&divclk4>; }; }; + +serial@898000 { + label = "BT-UART"; + status = "okay"; + + bluetooth: bt_wcn3990 {
Reverse these. The node name should be "bluetooth".
Quoted 13 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +9
-1+ compatible = "qcom,wcn3990-bt"; + vddio-supply = <&pm8998_s3>; + vddxtal-supply = <&pm8998_s5>; + vddcore-supply = <&pm8998_l7>; + vddpa-supply = <&pm8998_l17>; + vddldo-supply = <&pm8998_l25>; + max-speed = <3200000>; + }; +}; --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Balakrishna GodavarthiQuoting Balakrishna Godavarthi (2018-06-15 23:27:18)
Quoted 7 lines
drivers/bluetooth/hci_qca.c +0
-0@@ -1031,9 +1145,118 @@ static struct hci_uart_proto qca_proto =3D { .dequeue =3D qca_dequeue, };
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto =3D { · line 1156
Quoted 10 lines
drivers/bluetooth/hci_qca.c +8
-0= +static const struct qca_vreg_data qca_cherokee_data =3D { + .soc_type =3D QCA_WCN3990, + .vregs =3D (struct qca_vreg []) { + { "vddio", 1352000, 1352000, 0 }, + { "vddxtal", 1904000, 2040000, 0 }, + { "vddcore", 1800000, 1800000, 1 }, + { "vddpa", 1304000, 1304000, 1 }, + { "vddldo", 3000000, 3312000, 1 },
Load of 0 and 1 seems sort of odd. Are these made up to indicate "some load" vs. "no load"?
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1168
Quoted 13 lines
drivers/bluetooth/hci_qca.c +13
-0+ }, + .num_vregs =3D 5, +}; + +static int qca_enable_regulator (struct qca_vreg vregs, +struct regulator *regulator) +{ +int ret; + + ret =3D regulator_set_voltage(regulator, vregs.min_uV, + vregs.max_uV); +if (ret) + goto out;
Just return ret;
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1176
Quoted 8 lines
drivers/bluetooth/hci_qca.c +8
-0+ +if (vregs.load_uA) + ret =3D regulator_set_load(regulator, + vregs.load_uA); + +if (ret) + goto out; +
Same.
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1180
Quoted 4 lines
drivers/bluetooth/hci_qca.c +4
-0+ ret =3D regulator_enable(regulator); + +out: +return ret;
And make this return regulator_enable(regulator).
Quoted 3 lines
drivers/bluetooth/hci_qca.c +3
-0+ +} +
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
Hi Stephen,
Please find my comments inline.
Quoted 9 lines · Stephen Boyd
Quoting Balakrishna Godavarthi (2018-06-15 23:27:18)
Quoted 8 lines
drivers/bluetooth/hci_qca.c +0
-0@@ -1031,9 +1145,118 @@ static struct hci_uart_proto qca_proto = { .dequeue = qca_dequeue, };
Quoted 12 lines
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1155
Quoted 8 lines
drivers/bluetooth/hci_qca.c +8
-0+static const struct qca_vreg_data qca_cherokee_data = { + .soc_type =QCA_WCN3990 , + .vregs = (struct qca_vreg []) { + {"vddio" ,1352000 ,1352000 ,0 }, + {"vddxtal" ,1904000 ,2040000 ,0 }, + {"vddcore" ,1800000 ,1800000 ,1 }, + {"vddpa" ,1304000 ,1304000 ,1 }, + {"vddldo" ,3000000 ,3312000 ,1 },Load of 0 and 1 seems sort of odd. Are these made up to indicate "some load" vs. "no load"?
[Bala]: this value specifies the output load current required to turn on the wcn3990.
in struct defined vddio\vddxtal are smps, with fixed load.
regs from vddcore/vddpa/vddldo are programmable line regulators,
in which we need to set the basic load.
Quoted 7 lines
Quoted 7 lines
drivers/bluetooth/hci_qca.c +7
-0+ }, + .num_vregs = 5, +}; + +static int qca_enable_regulator (struct qca_vreg vregs, +struct regulator *regulator) +{
Quoted 8 lines
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1168
Quoted 6 lines
drivers/bluetooth/hci_qca.c +6
-0+int ret; + + ret =regulator_set_voltage (regulator, vregs.min_uV, + vregs.max_uV); +if (ret) + goto out;Just return ret;
[Bala]: will update.
Quoted 12 lines
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1176
Quoted 9 lines
drivers/bluetooth/hci_qca.c +8
-0+ +if (vregs.load_uA) + ret =regulator_set_load (regulator, + vregs.load_uA); + +if (ret) + goto out; +Same.
[Bala]: will update.
Quoted 7 lines
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1180
Quoted 4 lines
drivers/bluetooth/hci_qca.c +4
-0+ ret =regulator_enable (regulator); + +out: +return ret;And make this return
regulator_enable(regulator).
[Bala]: will update.
Quoted 3 lines
drivers/bluetooth/hci_qca.c static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) · line 990
Quoted 3 lines
drivers/bluetooth/hci_qca.c +3
-0+ +} +
Thanks for reviewing the patch.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 2/8] Bluetooth: btqca: Rename string ROME to QCA in logs.
In reply to Balakrishna GodavarthiQuoted 26 lines · Balakrishna Godavarthi
To have generic text in
bt_dev_info,bt_dev_errandbt_dev_dbgupdated from ROME to QCA where ever possible. This avoids confusion to user, when using the future Qualcomm Bluetooth SoC's. UpdatedBT_DBG,BT_ERRandBT_INFOwithbt_dev_dbg,bt_dev_errandbt_dev_infowhere ever applicable.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch.
* Updated the logs to generic.--- drivers/bluetooth/btqca.c | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-)drivers/bluetooth/btqca.c +1
-1@@ -35,36 +35,35 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)char cmd;int err =0 ; -BT_DBG ("%s: ROME Patch Version Request" , hdev->name); +bt_dev_dbg (hdev,"QCA Version Request" );
drivers/bluetooth/btqca.c static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version) · line 46
Quoted 10 lines
drivers/bluetooth/btqca.c +2
-2cmd =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); +bt_dev_err (hdev,"Reading QCA version information failed (%d)" , + err);
[Not really the scope of this patch/series, but an idea for a future improvement:
Some error messages put the error code inside parentheses, others put it after a colon. Would be good to unify this (my preference would be after the colon).]
Shouldn't this patch be squashed with "[3/8] Bluetooth: btqca: Rename ROME related functions to Generic functions"? It's a bit odd to do the renaming of the functions and log entries in two steps, even though the end result is the same.
What would make sense is to have a separate patch for BT_XYZ() to bt_dev_xyz(), though it's probably ok to do it in the patch that changes the log strings.
Re: [PATCH v7 3/8] Bluetooth: btqca: Rename ROME related functions to Generic functions
In reply to Balakrishna GodavarthiQuoted 12 lines · Balakrishna Godavarthi
Some of the QCA BTSoC ROME functions, are used for different versions or different make of BTSoC's. Instead of duplicating the same functions for new chip, updating names of the functions that are used for both chip's to keep this generic and would help in future when we would have new BT SoC.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* updated the all the functions of ROME to generic.
Quoted 7 lines
Changes in v6:
* initial patch
* updated names of functions that are used for both the chips to keep this generic and would help in future when we would have new BT SoC.---
As per my comment on "[2/8] Bluetooth: btqca: Rename string ROME to QCA in logs.", it would probably make sense to squash these two patches.
drivers/bluetooth/btqca.h line 43
Quoted 13 lines
drivers/bluetooth/btqca.h +1
-1@@ -37,7 +37,7 @@#define EDL_TAG_ID_HCI (17)#define EDL_TAG_ID_DEEP_SLEEP (27) -enum qca_bardrate { +enum qca_baudrate {QCA_BAUDRATE_115200 =0 ,QCA_BAUDRATE_57600 ,QCA_BAUDRATE_38400 ,
This is a bit sneaky, it is not related with the change nor mentioned in the commit message.
It is certainly a welcome change, but should be done in a separate patch (not necessarily in this series).
The fact that only the enum declaration needs to be fixed indicates that the enum isn't used for variables/paramters/return values of this type. Also beyond the scope of this series, but using the enum type instead of int types would be another possible future improvement.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiQuoted 27 lines · Balakrishna Godavarthi
Redefinition of
qca_uart_setupwill help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new argumentssoc_typeandsoc_verto the functions.These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.
soc_typeholds the Bluetooth chip connected to APPS processor.soc_verholds the Bluetooth chip version.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* redefinedqca_uart_setupfunction to generic.--- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-)drivers/bluetooth/btqca.c +0
-0
drivers/bluetooth/btqca.c int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) · line 330
Quoted 5 lines
drivers/bluetooth/btqca.c +1
-1@@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome); -int qca_uart_setup (struct hci_dev *hdev,uint8_t baudrate) +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type,
Use 'enum qca_btsoc_type' as type for 'soc_type'.
Quoted 14 lines
drivers/bluetooth/btqca.c +1
-5+ u32 soc_ver) { -u32 rome_ver =0 ;struct rome_config config;int err;@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err);
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 10 lines
drivers/bluetooth/btqca.c +8
-1-return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }
Why is this needed? A caller that passes in soc_ver = 0 could just call qca_read_soc_version() themselves.
Re: [PATCH v7 5/8] Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
In reply to Balakrishna GodavarthiQuoted 2 lines · Balakrishna Godavarthi
Subject: Bluetooth:
hci_qca: Defined wrapper functions for setting
UART speeds
s/Defined/Define/
or
s/Defined/Add/
Quoted 47 lines
In
qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* created wrapper functions for init and operating speeds.--- drivers/bluetooth/hci_qca.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-)drivers/bluetooth/hci_qca.c +2
-13@@ -923,21 +923,10 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)hci_uart_set_baudrate (hu, speed); } -static int qca_setup (struct hci_uart *hu) +static void qca_set_init_speed (struct hci_uart *hu) { -struct hci_dev *hdev = hu->hdev; -struct qca_data *qca = hu->priv; -unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; -int ret; -int soc_ver =0 ; - -bt_dev_info (hdev,"ROME setup" ); - -/* Patch downloading has to be done without IBS mode */ -clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +unsigned int speed =0 ; -/* Setup initial baudrate */ - speed =0 ;if (hu->init_speed) speed = hu->init_speed;else if (hu->proto->init_speed)
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 939
Quoted 6 lines
drivers/bluetooth/hci_qca.c +3
-0@@ -945,27 +934,64 @@ static int qca_setup(struct hci_uart *hu)if (speed)host_set_baudrate (hu, speed); +} + +static int qca_get_oper_speed (struct hci_uart *hu)
Return type should be unsigned int.
Quoted 6 lines
drivers/bluetooth/hci_qca.c +2
-2+{ +unsigned int speed =0 ; -/* Setup user speed if needed */ - speed =0 ;if (hu->oper_speed)
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 953
Quoted 10 lines
drivers/bluetooth/hci_qca.c +6
-0speed = hu->oper_speed; else if (hu->proto->oper_speed) speed = hu->proto->oper_speed; +return speed; +} + +static int qca_set_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 , qca_baudrate;
initialization is not needed.
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 957
Quoted 4 lines
drivers/bluetooth/hci_qca.c +3
-0+int ret =0 ; + + speed =qca_get_oper_speed (hu);if (speed) {
nit:
if (!speed) return 0;
Quoted 30 lines
drivers/bluetooth/hci_qca.c +18
-4qca_baudrate =qca_get_baudrate_value (speed); - -bt_dev_info (hdev,"Set UART speed to %d" , speed); - ret =qca_set_baudrate (hdev, qca_baudrate); +bt_dev_info (hu->hdev,"Set UART speed to %d" , speed); + ret =qca_set_baudrate (hu->hdev, qca_baudrate);if (ret) { -bt_dev_err (hdev,"Failed to change the baud rate (%d)" , +bt_dev_err (hu->hdev,"Failed to change the baud rate (%d)" , ret);return ret; }host_set_baudrate (hu, speed); } +return ret; +} + +static int qca_setup (struct hci_uart *hu) +{ +struct hci_dev *hdev = hu->hdev; +struct qca_data *qca = hu->priv; +unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; +int ret; +int soc_ver =0 ; + +bt_dev_info (hdev,"ROME setup" ); + +/* Patch downloading has to be done without IBS mode */ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 993
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+ +/* Setup initial baudrate */ +qca_set_init_speed (hu); +/* Setup user speed if needed */ + ret =qca_set_oper_speed (hu); +if (ret) +return ret; + speed =qca_get_oper_speed (hu); +if (speed) + qca_baudrate =qca_get_baudrate_value (speed);
nit: the sequence
qca_set_oper_speed()qca_get_oper_speed()
is slightly awkward to read. This could be avoided if the speed was passed as parameter, though I understand this isn't done for symmetry with qca_set_init_speed(). An alternative could be:
static int qca_set_speed(struct hci_uart *hu, unsigned int speed, enum
qca_speed_type speed_type)
{
unsigned int qca_baudrate;
if (speed_type == QCA_OPER_SPEED) {
qca_baudrate = qca_get_baudrate_value(speed);
bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
ret = qca_set_baudrate(hu->hdev, qca_baudrate);
if (ret) {
bt_dev_err(hu->hdev, "Failed to change the baud rate (%d)",
ret);
return ret;
}
}
host_set_baudrate(hu, speed);
/* If the order doesn't matter set the host baudrate first and
return if speed_type != QCA_OPER_SPEED */
return 0;
}static int qca_setup(struct hci_uart *hu)
{
...
speed = qca_get_init_speed(hu);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);
speed = qca_get_oper_speed(hu);
if (speed) {
qca_set_speed(hu, speed, QCA_OPER_SPEED);
qca_baudrate = qca_get_baudrate_value(speed);
}
...
}Just a suggestion, ok for me if you prefer to keep it as is.
Re: [PATCH v7 7/8] Bluetooth: btqca: Add wcn3990 firmware download support.
In reply to Balakrishna GodavarthiQuoted 36 lines · Balakrishna Godavarthi
This patch enables the RAM and NV patch download for wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* used redefined functionqca_uart_setupfor firmware download.Changes in v6:
* add code to derive the firmware files based on ROM Version.
* created new patch for common function of ROME and wcn3990.Changes in v5:
* moved changes related tohci_qca.
* addressed review comments.Changes in v4:
* initial patch.--- drivers/bluetooth/btqca.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)drivers/bluetooth/btqca.c +1
-0@@ -332,6 +332,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, {struct rome_config config;int err; +u8 rom_ver;bt_dev_dbg (hdev,"QCA setup on UART" );@@ -346,11 +347,21 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, }bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver);
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, · line 355
Quoted 10 lines
drivers/bluetooth/btqca.c +4
-3} -/* Download rampatch file */ config.type =TLV_TYPE_PATCH ; -snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.bin" , - soc_ver); +if (soc_type ==QCA_WCN3990 ) { +/* Firmware files to download are based on ROM version. +* ROM version is derived from last two bytes of soc_ver. +*/
nit: new line after '/*' (https://www.kernel.org/doc/html/v4.17/process/coding-style.html#commenting))
Marcel Holtmann
maintainerRe: [PATCH v7 7/8] Bluetooth: btqca: Add wcn3990 firmware download support.
Hi Matthias,
Quoted 33 lines
Quoted 33 lines
This patch enables the RAM and NV patch download for wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* used redefined functionqca_uart_setupfor firmware download.Changes in v6:
* add code to derive the firmware files based on ROM Version.
* created new patch for common function of ROME and wcn3990.Changes in v5:
* moved changes related tohci_qca.
* addressed review comments.Changes in v4:
* initial patch.
---drivers/bluetooth/btqca.c| 26 +++++++++++++++++++++-----1 file changed, 21 insertions(+), 5 deletions(-)drivers/bluetooth/btqca.c +1
-0@@ -332,6 +332,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, {struct rome_config config;int err; +u8 rom_ver;bt_dev_dbg (hdev,"QCA setup on UART" );
Quoted 15 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, · line 355
Quoted 13 lines
drivers/bluetooth/btqca.c +4
-3@@ -346,11 +347,21 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, }bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); } -/* Download rampatch file */ config.type =TLV_TYPE_PATCH ; -snprintf (config.fwname,sizeof (config.fwname),"qca/rampatch_%08x.bin" , - soc_ver); +if (soc_type ==QCA_WCN3990 ) { +/* Firmware files to download are based on ROM version. +* ROM version is derived from last two bytes of soc_ver. +*/ nit: new line after '/*' (https://www.kernel.org/doc/html/v4.17/process/coding-style.html#commenting))
actually not in the networking code. It has special commenting rules ;)
Regards
Marcel
Re: [PATCH v7 2/8] Bluetooth: btqca: Rename string ROME to QCA in logs.
In reply to Matthias KaehlckeHi Matthias,
Please find my comments inline.
Quoted 44 lines · Matthias Kaehlcke
Quoted 29 lines · Balakrishna Godavarthi
To have generic text in
bt_dev_info,bt_dev_errandbt_dev_dbgupdated from ROME to QCA where ever possible. This avoids confusion to user, when using the future Qualcomm Bluetooth SoC's. UpdatedBT_DBG,BT_ERRandBT_INFOwithbt_dev_dbg,bt_dev_errandbt_dev_infowhere ever applicable.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch.
* Updated the logs to generic.--- drivers/bluetooth/btqca.c | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-)drivers/bluetooth/btqca.c +1
-1@@ -35,36 +35,35 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)char cmd;int err =0 ; -BT_DBG ("%s: ROME Patch Version Request" , hdev->name); +bt_dev_dbg (hdev,"QCA Version Request" );drivers/bluetooth/btqca.c static int rome_patch_ver_req(struct hci_dev · line 48
Quoted 10 lines
drivers/bluetooth/btqca.c +2
-2cmd =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); +bt_dev_err (hdev,"Reading QCA version information failed (%d)" , + err);[Not really the scope of this patch/series, but an idea for a future improvement:
Quoted 4 lines
Some error messages put the error code inside parentheses, others put it after a colon. Would be good to unify this (my preference would be after the colon).]
[Bala]: will update.
Quoted 8 lines
Shouldn't this patch be squashed with "[3/8] Bluetooth: btqca: Rename ROME related functions to Generic functions"? It's a bit odd to do the renaming of the functions and log entries in two steps, even though the end result is the same.
What would make sense is to have a separate patch for
BT_XYZ()tobt_dev_xyz(), though it's probably ok to do it in the patch that changes the log strings.
[Bala]: to make review easy, i have segregated into two patches. will squash this into [3/8] patch.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 3/8] Bluetooth: btqca: Rename ROME related functions to Generic functions
In reply to Matthias KaehlckeHi Matthias,
Quoted 19 lines · Matthias Kaehlcke
Quoted 18 lines · Balakrishna Godavarthi
Some of the QCA BTSoC ROME functions, are used for different versions or different make of BTSoC's. Instead of duplicating the same functions for new chip, updating names of the functions that are used for both chip's to keep this generic and would help in future when we would have new BT SoC.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* updated the all the functions of ROME to generic.Changes in v6:
* initial patch
* updated names of functions that are used for both the chips to keep this generic and would help in future when we would have new BT SoC.
Quoted 6 lines
Quoted 1 line
---
As per my comment on "[2/8] Bluetooth: btqca: Rename string ROME to QCA in logs.", it would probably make sense to squash these two patches.
[Bala]: will squash [2/8] and [3/8] patches into one.
Quoted 17 lines
drivers/bluetooth/btqca.h line 43
Quoted 13 lines
drivers/bluetooth/btqca.h +1
-1@@ -37,7 +37,7 @@#define EDL_TAG_ID_HCI (17)#define EDL_TAG_ID_DEEP_SLEEP (27) -enum qca_bardrate { +enum qca_baudrate {QCA_BAUDRATE_115200 =0 ,QCA_BAUDRATE_57600 ,QCA_BAUDRATE_38400 ,This is a bit sneaky, it is not related with the change nor mentioned in the commit message.
Quoted 7 lines
It is certainly a welcome change, but should be done in a separate patch (not necessarily in this series).
The fact that only the enum declaration needs to be fixed indicates that the enum isn't used for variables/paramters/return values of this type. Also beyond the scope of this series, but using the enum type instead of int types would be another possible future improvement.
[Bala]: while reviewing the code, i found this. will leave it for now.
once this series of patches are done. will send this change in
different series.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Matthias KaehlckeHi Matthias,
Please find my comments inline.
Quoted 32 lines · Matthias Kaehlcke
Quoted 31 lines · Balakrishna Godavarthi
Redefinition of
qca_uart_setupwill help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new argumentssoc_typeandsoc_verto the functions.These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.
soc_typeholds the Bluetooth chip connected to APPS processor.soc_verholds the Bluetooth chip version.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* redefinedqca_uart_setupfunction to generic.--- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-)drivers/bluetooth/btqca.c +0
-0@@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome);
Quoted 6 lines
drivers/bluetooth/btqca.c int qca_set_bdaddr_rome(struct hci_dev *hdev, · line 332
Quoted 3 lines
drivers/bluetooth/btqca.c +1
-1-int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type,Use 'enum
qca_btsoc_type' as type for 'soc_type'.
[Bala]: will update.
Quoted 20 lines
Quoted 20 lines
drivers/bluetooth/btqca.c +1
-1+ u32 soc_ver) { -u32 rome_ver =0 ;struct rome_config config;drivers/bluetooth/btqca.c +4
-5int err;@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) {
Quoted 8 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 5 lines
drivers/bluetooth/btqca.c +4
-0+bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.
[Bala]: hci_qca support two chip one ROME (already up-streamed) and other wcn3990.
there setup sequence differs.
wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (calls qca_uart_setup)
ROME:
1. set baudrate to 3.0 mbps
2. calls qca_uart_setup to read soc version and download
firmware.
so to make use of existing function qca_setup_uart(). passingsoc_ver as argument.
if soc_ver is zero, then read soc version (i.e. for ROME chip).
Pls let me know, if you have any queries.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 5/8] Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
In reply to Matthias KaehlckeHI Matthias,
Please find my comments in line.
Quoted 10 lines · Matthias Kaehlcke
Quoted 2 lines · Balakrishna Godavarthi
Subject: Bluetooth:
hci_qca: Defined wrapper functions for setting
UART speedss/Defined/Define/
or
s/Defined/Add/
[Bala]: will update the text.
Quoted 50 lines
Quoted 50 lines
In
qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* created wrapper functions for init and operating speeds.--- drivers/bluetooth/hci_qca.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-)drivers/bluetooth/hci_qca.c +2
-13@@ -923,21 +923,10 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)hci_uart_set_baudrate (hu ,speed ); } -static int qca_setup (struct hci_uart *hu) +static void qca_set_init_speed (struct hci_uart *hu) { -struct hci_dev *hdev = hu->hdev; -struct qca_data *qca = hu->priv; -unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; -int ret; -int soc_ver =0 ; - -bt_dev_info (hdev,"ROME setup" ); - -/* Patch downloading has to be done without IBS mode */ -clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +unsigned int speed =0 ; -/* Setup initial baudrate */ - speed =0 ;if (hu->init_speed) speed = hu->init_speed;drivers/bluetooth/hci_qca.c +0
-0else if (hu->proto->init_speed)@@ -945,27 +934,64 @@ static int qca_setup(struct hci_uart *hu)
Quoted 8 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 939
Quoted 5 lines
drivers/bluetooth/hci_qca.c +3
-0if (speed)host_set_baudrate (hu, speed); +} + +static int qca_get_oper_speed (struct hci_uart *hu)Return type should be unsigned int.
[Bala]: will update
Quoted 10 lines
Quoted 10 lines
drivers/bluetooth/hci_qca.c +2
-2+{ +unsigned int speed =0 ; -/* Setup user speed if needed */ - speed =0 ;if (hu->oper_speed) speed = hu->oper_speed;else if (hu->proto->oper_speed) speed = hu->proto->oper_speed;
Quoted 9 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 953
Quoted 6 lines
drivers/bluetooth/hci_qca.c +6
-0+return speed; +} + +static int qca_set_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 , qca_baudrate;initialization is not needed.
[Bala]: will update
Quoted 10 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 957
Quoted 4 lines
drivers/bluetooth/hci_qca.c +3
-0+int ret =0 ; + + speed =qca_get_oper_speed (hu);if (speed) {nit:
if (!speed) return 0;
[Bala]: will update.
Quoted 89 lines
Quoted 30 lines
drivers/bluetooth/hci_qca.c +18
-4qca_baudrate =qca_get_baudrate_value (speed); - -bt_dev_info (hdev,"Set UART speed to %d" , speed); - ret =qca_set_baudrate (hdev, qca_baudrate); +bt_dev_info (hu->hdev,"Set UART speed to %d" , speed); + ret =qca_set_baudrate (hu->hdev, qca_baudrate);if (ret) { -bt_dev_err (hdev,"Failed to change the baud rate (%d)" , +bt_dev_err (hu->hdev,"Failed to change the baud rate (%d)" , ret);return ret; }host_set_baudrate (hu, speed); } +return ret; +} + +static int qca_setup (struct hci_uart *hu) +{ +struct hci_dev *hdev = hu->hdev; +struct qca_data *qca = hu->priv; +unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; +int ret; +int soc_ver =0 ; + +bt_dev_info (hdev,"ROME setup" ); + +/* Patch downloading has to be done without IBS mode */ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 993
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+ +/* Setup initial baudrate */ +qca_set_init_speed (hu); +/* Setup user speed if needed */ + ret =qca_set_oper_speed (hu); +if (ret) +return ret; + speed =qca_get_oper_speed (hu); +if (speed) + qca_baudrate =qca_get_baudrate_value (speed);nit: the sequence
qca_set_oper_speed()qca_get_oper_speed()is slightly awkward to read. This could be avoided if the speed was passed as parameter, though I understand this isn't done for symmetry with
qca_set_init_speed(). An alternative could be:static int qca_set_speed(struct
hci_uart*hu, unsigned int speed, enum
qca_speed_typespeed_type){ unsigned int qca_baudrate; if (speed_type == QCA_OPER_SPEED) { qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) { bt_dev_err(hu->hdev, "Failed to change the baud rate (%d)", ret); return ret; } } host_set_baudrate(hu, speed); /* If the order doesn't matter set the host baudrate first and return if speed_type != QCA_OPER_SPEED */ return 0; }static int
qca_setup(struct hci_uart *hu){ ... speed = qca_get_init_speed(hu); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); speed = qca_get_oper_speed(hu); if (speed) { qca_set_speed(hu, speed, QCA_OPER_SPEED); qca_baudrate = qca_get_baudrate_value(speed); } ... }
Quoted 1 line
Just a suggestion, ok for me if you prefer to keep it as is.
[Bala]: will study and update the same.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiQuoted 88 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 32 lines · Matthias Kaehlcke
Quoted 31 lines · Balakrishna Godavarthi
Redefinition of
qca_uart_setupwill help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new argumentssoc_typeandsoc_verto the functions.These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.
soc_typeholds the Bluetooth chip connected to APPS processor.soc_verholds the Bluetooth chip version.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* redefinedqca_uart_setupfunction to generic.--- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-)drivers/bluetooth/btqca.c +0
-0@@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome);Quoted 6 lines
drivers/bluetooth/btqca.c int qca_set_bdaddr_rome(struct hci_dev *hdev, · line 332
Quoted 3 lines
drivers/bluetooth/btqca.c +1
-1-int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type,Use 'enum
qca_btsoc_type' as type for 'soc_type'.[Bala]: will update.
Quoted 20 lines
Quoted 20 lines
drivers/bluetooth/btqca.c +1
-1+ u32 soc_ver) { -u32 rome_ver =0 ;struct rome_config config;drivers/bluetooth/btqca.c +4
-5int err;@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) {Quoted 8 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 5 lines
drivers/bluetooth/btqca.c +4
-0+bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download firmware.
Quoted 5 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
I concede that having two "if (qcadev->btsoc_type == XYZ)" branches in qca_setup() is kinda ugly, but I think it's still better than the conditional call of qca_read_soc_version() in qca_uart_setup().
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Balakrishna GodavarthiQuoted 18 lines · Balakrishna Godavarthi
Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c +1
-0@@ -402,6 +441,7 @@ static int qca_open(struct hci_uart *hu) {struct qca_serdev *qcadev;struct qca_data *qca; +int ret =0 ;BT_DBG ("hu %p qca_open" , hu);
drivers/bluetooth/hci_qca.c static int qca_open(struct hci_uart *hu) · line 509
Quoted 8 lines
drivers/bluetooth/hci_qca.c +4
-1@@ -463,13 +503,19 @@ static int qca_open(struct hci_uart *hu)serdev_device_open (hu->serdev); qcadev =serdev_device_get_drvdata (hu->serdev); -gpiod_set_value_cansleep (qcadev->bt_en,1 ); +if (qcadev->btsoc_type ==QCA_WCN3990 ) { + hu->init_speed = qcadev->init_speed; + hu->oper_speed = qcadev->oper_speed; + ret =qca_btsoc_power_setup (hu, true);
Better do this before starting the timers, otherwise you need to take care of stopping them in case of failure.
If qca_btsoc_power_setup() fails you also have to free 'qca->workqueue' and 'qca'.
drivers/bluetooth/hci_qca.c static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) · line 987
Quoted 11 lines
drivers/bluetooth/hci_qca.c +11
-0+static int qca_send_vendor_cmd (struct hci_dev *hdev,u8 cmd) +{ +struct hci_uart *hu =hci_get_drvdata (hdev); +struct qca_data *qca = hu->priv; +struct sk_buff *skb; + +bt_dev_dbg (hdev,"sending command %02x to SoC" , cmd); + + skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); +if (!skb) { +bt_dev_err (hdev,"Failed to allocate memory for skb packet" );
I was told that custom OOM messages should not be used, since the mm code will complain loudly in this case.
drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1049
Quoted 1 line
drivers/bluetooth/hci_qca.c +1
-0+static int qca_btsoc_shutdown (struct hci_uart *hu)
The return value is not evaluated by the only caller, so this should probably be void.
Quoted 28 lines
drivers/bluetooth/hci_qca.c +13
-3static int qca_setup (struct hci_uart *hu) {struct hci_dev *hdev = hu->hdev;struct qca_data *qca = hu->priv; +struct qca_serdev *qcadev;unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ;int ret;int soc_ver =0 ; -bt_dev_info (hdev,"ROME setup" ); + qcadev =serdev_device_get_drvdata (hu->serdev);/* Patch downloading has to be done without IBS mode */ clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); - -/* Setup initial baudrate */ qca_set_init_speed (hu); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) { +bt_dev_dbg (hdev,"setting up wcn3990" ); +hci_uart_set_flow_control (hu, true); + ret =qca_send_vendor_cmd (hdev,CHEROKEE_POWERON_PULSE ); +if (ret) { +bt_dev_err (hdev,"failed to send power on command" ); +return ret; + } +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev);
drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1092
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } +msleep (100 ); +qca_set_init_speed (hu); +hci_uart_set_flow_control (hu, false); + ret =qca_read_soc_version (hdev, &soc_ver); +if (ret <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"Failed to get version %d" , ret);
serdev_device_close() ?
Also applies to other error paths in this function.
Quoted 9 lines
static int
qca_serdev_probe(struct serdev_device *serdev){drivers/bluetooth/hci_qca.c +1
-0struct qca_serdev *qcadev; +const struct qca_vreg_data *data;int err; qcadev =devm_kzalloc (&serdev->dev,sizeof (*qcadev),GFP_KERNEL );@@ -1041,47 +1264,85 @@ static int qca_serdev_probe(struct serdev_device *serdev)return -ENOMEM ;
drivers/bluetooth/hci_qca.c static int qca_serdev_probe(struct serdev_device *serdev) · line 1274
Quoted 10 lines
drivers/bluetooth/hci_qca.c +7
-0qcadev->serdev_hu.serdev = serdev; + data =of_device_get_match_data (&serdev->dev); +if (data && data->soc_type ==QCA_WCN3990 ) + qcadev->btsoc_type =QCA_WCN3990 ; +else + qcadev->btsoc_type =QCA_ROME ; +serdev_device_set_drvdata (serdev, qcadev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) {
nit: the double "if (soc_type == QCA_WCN3990)" is a bit odd. Consider changing this condition to "if (data && data->soc_type == QCA_WCN3990)" and assign qcadev->btsoc_type in the corresponding branch.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Matthias KaehlckeHi Matthias,
Quoted 95 lines · Matthias Kaehlcke
Quoted 94 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 32 lines · Matthias Kaehlcke
Quoted 31 lines · Balakrishna Godavarthi
Redefinition of
qca_uart_setupwill help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new argumentssoc_typeandsoc_verto the functions.These arguments will help to decide type of firmware files to be loaded into Bluetooth chip.
soc_typeholds the Bluetooth chip connected to APPS processor.soc_verholds the Bluetooth chip version.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* redefinedqca_uart_setupfunction to generic.--- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-)drivers/bluetooth/btqca.c +0
-0@@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) }EXPORT_SYMBOL_GPL (qca_set_bdaddr_rome);Quoted 6 lines
drivers/bluetooth/btqca.c int qca_set_bdaddr_rome(struct hci_dev *hdev, · line 332
Quoted 3 lines
drivers/bluetooth/btqca.c +1
-1-int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type,Use 'enum
qca_btsoc_type' as type for 'soc_type'.[Bala]: will update.
Quoted 20 lines
Quoted 20 lines
drivers/bluetooth/btqca.c +1
-1+ u32 soc_ver) { -u32 rome_ver =0 ;struct rome_config config;drivers/bluetooth/btqca.c +4
-5int err;@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) {Quoted 8 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 5 lines
drivers/bluetooth/btqca.c +4
-0+bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).
Quoted 8 lines
Quoted 1 line
Pls let me know, if you have any queries.
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
[Bala]: yes we can read SoC version after setting operating baud rate. an advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting operating
baudrate,it will helps us to understand whether the soc is responding to any commands in default baud rate
before setting operating speed.
Quoted 6 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().
[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 1/8] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
In reply to Rob HerringHi Rob,
please find my comments inline.
Quoted 6 lines · Rob Herring
Quoted 1 line · Balakrishna Godavarthi
Signed-off-by Balakrishna Godavarthi <[email protected]>Commit messag missing.
[Bala]: my bad, i some how missed. will update.
Quoted 3 lines
Please use get_maintainers.pl and send patches to the right lists. DT list in this case.
[Bala]: will find the correct POC.
Quoted 27 lines
Quoted 27 lines
---
Changes in v7:
* no change.Changes in v6:
* Changed the oper-speed to max-speed.
Changes in v5:
* Added entry for oper-speed and init-speed.
--- .../bindings/net/qualcomm-bluetooth.txt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +1
-0@@ -10,12 +10,24 @@ device the slave device is attached to. Required properties: - compatible: should contain one of the following: * "qcom,qca6174-bt" + * "qcom,wcn3990-bt"
Quoted 16 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +3
-2Optional properties: - enable-gpios: gpio specifier used to enable chip - clocks: clock provided to the controller (SUSCLK_32KHZ) - -Example: + - vddpa-supply: Bluetooth VDD PA regulator handle + - vddio-supply: Bluetooth VDD IO regulator handle + - vddldo-supply: Bluetooth VDD LDO regulator handle. Kept underQuoted 4 lines
optional
+ parameters as some of the chipsets doesn't require
ldo or
+ it may use from same vddio.You need to be explicit as to which properties apply or don't apply to specific compatible strings.
[Bala]: will update.
Quoted 3 lines
Supplies should be based on inputs to the chip, so if 1 regulator supplies 2 inputs you still need both.
[Bala]: sorry i did't get you, all these regulators are single output line regulators.
i.e. <supply-name>- supply, need single regulator input as a
handle.
and these line regulators generate fixed voltage output.
please let me know, if i have cleared your query
Quoted 11 lines
Quoted 11 lines
+ - 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
andDocumentation/devicetree/bindings/net/qualcomm-bluetooth.txt +4
-0+ shares a common gpio to bring chip out of reset. + - max-speed: operating speed of the chip. + +Examples:
Quoted 28 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt serial@7570000 { · line 48
Quoted 12 lines
serial@7570000 { label = "BT-UART";Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +6
-0@@ -28,3 +40,18 @@ serial@7570000 { clocks = <&divclk4>; }; }; + +serial@898000 { + label = "BT-UART"; + status = "okay"; + + bluetooth: bt_wcn3990 {Reverse these. The node name should be "bluetooth".
Quoted 13 lines
Documentation/devicetree/bindings/net/qualcomm-bluetooth.txt +9
-1+ compatible = "qcom,wcn3990-bt"; + vddio-supply = <&pm8998_s3>; + vddxtal-supply = <&pm8998_s5>; + vddcore-supply = <&pm8998_l7>; + vddpa-supply = <&pm8998_l17>; + vddldo-supply = <&pm8998_l25>; + max-speed = <3200000>; + }; +}; --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Thanks for reviewing, will send a incremental patch.
Signature · 2 lines
Regards Balakrishna.
Rob Herring
maintainerRe: [PATCH v7 1/8] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
Quoted 10 lines · Balakrishna Godavarthi
Hi Rob,
please find my comments inline.
Quoted 5 lines · Rob Herring
Quoted 2 lines · Balakrishna Godavarthi
Signed-off-by Balakrishna Godavarthi <[email protected]>
[...]
Quoted 19 lines
Quoted 10 lines
Quoted 8 lines
-Example:
+ - 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.Quoted 3 lines
You need to be explicit as to which properties apply or don't apply to specific compatible strings.
[Bala]: will update.
Quoted 3 lines
Supplies should be based on inputs to the chip, so if 1 regulator supplies 2 inputs you still need both.
Quoted 6 lines
[Bala]: sorry i did't get you, all these regulators are single output line regulators.
i.e. <supply-name>- supply, need single regulator input as a
handle.
and these line regulators generate fixed voltage output. please let me know, if i have cleared your query
I was referring to "it may use from same vddio". If you mean vddldo is left disconnected, then omitting the property is fine. If you mean vddio and vddldo are connected to the same regulator, then you should have both properties in the binding.
Rob
Re: [PATCH v7 1/8] dt-bindings: net: bluetooth: Add device tree bindings for QTI chip wcn3990
Hi Rob,
Quoted 42 lines · Rob Herring
Quoted 10 lines · Balakrishna Godavarthi
Hi Rob,
please find my comments inline.
Quoted 5 lines · Rob Herring
Quoted 2 lines · Balakrishna Godavarthi
Signed-off-by Balakrishna Godavarthi <[email protected]>[...]
Quoted 20 lines
Quoted 11 lines
Quoted 9 lines
-Example:
+ - 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.Quoted 3 lines
You need to be explicit as to which properties apply or don't apply to specific compatible strings.
[Bala]: will update.
Quoted 3 lines
Supplies should be based on inputs to the chip, so if 1 regulator supplies 2 inputs you still need both.
Quoted 6 lines
[Bala]: sorry i did't get you, all these regulators are single output line regulators.
i.e. <supply-name>- supply, need single regulator input as a
handle.
and these line regulators generate fixed voltage output. please let me know, if i have cleared your query
Quoted 6 lines
I was referring to "it may use from same vddio". If you mean vddldo is left disconnected, then omitting the property is fine. If you mean vddio and vddldo are connected to the same regulator, then you should have both properties in the binding.
Rob
may be pharse is confusing, will correct the text. we require both vregs to turn on wcn3990.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 5/8] Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
In reply to Balakrishna GodavarthiHi Matthias,
Quoted 197 lines · Balakrishna Godavarthi
HI Matthias,
Please find my comments in line.
Quoted 10 lines · Matthias Kaehlcke
Quoted 2 lines · Balakrishna Godavarthi
Subject: Bluetooth:
hci_qca: Defined wrapper functions for setting
UART speedss/Defined/Define/
or
s/Defined/Add/
[Bala]: will update the text.
Quoted 50 lines
Quoted 50 lines
In
qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* created wrapper functions for init and operating speeds.--- drivers/bluetooth/hci_qca.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-)drivers/bluetooth/hci_qca.c +2
-13@@ -923,21 +923,10 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)hci_uart_set_baudrate (hu ,speed ); } -static int qca_setup (struct hci_uart *hu) +static void qca_set_init_speed (struct hci_uart *hu) { -struct hci_dev *hdev = hu->hdev; -struct qca_data *qca = hu->priv; -unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; -int ret; -int soc_ver =0 ; - -bt_dev_info (hdev,"ROME setup" ); - -/* Patch downloading has to be done without IBS mode */ -clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +unsigned int speed =0 ; -/* Setup initial baudrate */ - speed =0 ;if (hu->init_speed) speed = hu->init_speed;drivers/bluetooth/hci_qca.c +0
-0else if (hu->proto->init_speed)@@ -945,27 +934,64 @@ static int qca_setup(struct hci_uart *hu)Quoted 8 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 939
Quoted 5 lines
drivers/bluetooth/hci_qca.c +3
-0if (speed)host_set_baudrate (hu, speed); +} + +static int qca_get_oper_speed (struct hci_uart *hu)Return type should be unsigned int.
[Bala]: will update
Quoted 10 lines
Quoted 10 lines
drivers/bluetooth/hci_qca.c +2
-2+{ +unsigned int speed =0 ; -/* Setup user speed if needed */ - speed =0 ;if (hu->oper_speed) speed = hu->oper_speed;else if (hu->proto->oper_speed) speed = hu->proto->oper_speed;Quoted 9 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 953
Quoted 6 lines
drivers/bluetooth/hci_qca.c +6
-0+return speed; +} + +static int qca_set_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 , qca_baudrate;initialization is not needed.
[Bala]: will update
Quoted 10 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 957
Quoted 4 lines
drivers/bluetooth/hci_qca.c +3
-0+int ret =0 ; + + speed =qca_get_oper_speed (hu);if (speed) {nit:
if (!speed) return 0;[Bala]: will update.
Quoted 89 lines
Quoted 30 lines
drivers/bluetooth/hci_qca.c +18
-4qca_baudrate =qca_get_baudrate_value (speed); - -bt_dev_info (hdev,"Set UART speed to %d" , speed); - ret =qca_set_baudrate (hdev, qca_baudrate); +bt_dev_info (hu->hdev,"Set UART speed to %d" , speed); + ret =qca_set_baudrate (hu->hdev, qca_baudrate);if (ret) { -bt_dev_err (hdev,"Failed to change the baud rate (%d)" , +bt_dev_err (hu->hdev,"Failed to change the baud rate (%d)" , ret);return ret; }host_set_baudrate (hu, speed); } +return ret; +} + +static int qca_setup (struct hci_uart *hu) +{ +struct hci_dev *hdev = hu->hdev; +struct qca_data *qca = hu->priv; +unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; +int ret; +int soc_ver =0 ; + +bt_dev_info (hdev,"ROME setup" ); + +/* Patch downloading has to be done without IBS mode */ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 993
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+ +/* Setup initial baudrate */ +qca_set_init_speed (hu); +/* Setup user speed if needed */ + ret =qca_set_oper_speed (hu); +if (ret) +return ret; + speed =qca_get_oper_speed (hu); +if (speed) + qca_baudrate =qca_get_baudrate_value (speed);nit: the sequence
qca_set_oper_speed()qca_get_oper_speed()is slightly awkward to read. This could be avoided if the speed was passed as parameter, though I understand this isn't done for symmetry with
qca_set_init_speed(). An alternative could be:static int qca_set_speed(struct
hci_uart*hu, unsigned int speed, enum
qca_speed_typespeed_type){ unsigned int qca_baudrate; if (speed_type == QCA_OPER_SPEED) { qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) { bt_dev_err(hu->hdev, "Failed to change the baud rate (%d)", ret); return ret; } } host_set_baudrate(hu, speed); /* If the order doesn't matter set the host baudrate first and return if speed_type != QCA_OPER_SPEED */ return 0; }static int
qca_setup(struct hci_uart *hu){ ... speed = qca_get_init_speed(hu); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); speed = qca_get_oper_speed(hu); if (speed) { qca_set_speed(hu, speed, QCA_OPER_SPEED); qca_baudrate = qca_get_baudrate_value(speed); } ... }
Quoted 3 lines
Quoted 1 line
Just a suggestion, ok for me if you prefer to keep it as is.
[Bala]: will study and update the same.
[Bala]: you are suggestion looks ok to me. i am thinking to optimize further.
static unsigned int qca_get_speed(struct hci_uart *hu,
enum qca_speed_type speed_type)
{
unsigned int speed = 0;
if (speed_type == QCA_INIT_SPEED) {
if (hu->init_speed)
speed = hu->init_speed;
else if (hu->proto->init_speed)
speed = hu->proto->init_speed;
} else {
if (hu->oper_speed)
speed = hu->oper_speed;
else if (hu->proto->oper_speed)
speed = hu->proto->oper_speed;
}
return speed;
}static int qca_set_speed(struct hci_uart *hu, unsigned int speed,
enum qca_speed_type speed_type)
{
unsigned int qca_baudrate;
int ret;
if (speed_type == QCA_OPER_SPEED) {
qca_baudrate = qca_get_baudrate_value(speed);
bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
ret = qca_set_baudrate(hu->hdev, qca_baudrate);
if (ret) {
bt_dev_err(hu->hdev, "Failed to change the
baudrate (%d)",
ret);
return ret;
}
}
host_set_baudrate(hu, speed);
return ret;
} static int qca_setup(struct hci_uart *hu)
{
...
/* Setup initial baudrate */
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);
/* Setup user speed if needed */
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (speed) {
ret = qca_set_speed(hu, speed, QCA_OPER_SPEED);
if (ret)
return ret;
qca_baudrate = qca_get_baudrate_value(speed);
}}
will have two functions,qca_set_speed(): for setting speedqca_get_speed(): to get the speed.
is this preferable?
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 5/8] Bluetooth: hci_qca: Defined wrapper functions for setting UART speeds
Hi Balakrishna,
Quoted 240 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 199 lines · Balakrishna Godavarthi
HI Matthias,
Please find my comments in line.
Quoted 11 lines · Matthias Kaehlcke
Quoted 2 lines · Balakrishna Godavarthi
Subject: Bluetooth:
hci_qca: Defined wrapper functions for setting
UART speedss/Defined/Define/
or
s/Defined/Add/
[Bala]: will update the text.
Quoted 51 lines
Quoted 51 lines
In
qca_setup, we set initial and operating speeds for Qualcomm Bluetooth SoC's. This block of code is common across different Qualcomm Bluetooth SoC's. Instead of duplicating the code, created a wrapper function to set the speeds. So that future coming SoC's can use these wrapper functions to set speeds.Signed-off-by Balakrishna Godavarthi <[email protected]>---
Changes in v7:
* initial patch
* created wrapper functions for init and operating speeds.--- drivers/bluetooth/hci_qca.c | 64 ++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-)drivers/bluetooth/hci_qca.c +2
-13@@ -923,21 +923,10 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)hci_uart_set_baudrate (hu, speed); } -static int qca_setup (struct hci_uart *hu) +static void qca_set_init_speed (struct hci_uart *hu) { -struct hci_dev *hdev = hu->hdev; -struct qca_data *qca = hu->priv; -unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; -int ret; -int soc_ver =0 ; - -bt_dev_info (hdev,"ROME setup" ); - -/* Patch downloading has to be done without IBS mode */ -clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); +unsigned int speed =0 ; -/* Setup initial baudrate */ - speed =0 ;if (hu->init_speed) speed = hu->init_speed;drivers/bluetooth/hci_qca.c +0
-0else if (hu->proto->init_speed)@@ -945,27 +934,64 @@ static int qca_setup(struct hci_uart *hu)Quoted 8 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 939
Quoted 5 lines
drivers/bluetooth/hci_qca.c +3
-0if (speed)host_set_baudrate (hu, speed); +} + +static int qca_get_oper_speed (struct hci_uart *hu)Return type should be unsigned int.
[Bala]: will update
Quoted 10 lines
Quoted 10 lines
drivers/bluetooth/hci_qca.c +2
-2+{ +unsigned int speed =0 ; -/* Setup user speed if needed */ - speed =0 ;if (hu->oper_speed) speed = hu->oper_speed;else if (hu->proto->oper_speed) speed = hu->proto->oper_speed;Quoted 9 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 953
Quoted 6 lines
drivers/bluetooth/hci_qca.c +6
-0+return speed; +} + +static int qca_set_oper_speed (struct hci_uart *hu) +{ +unsigned int speed =0 , qca_baudrate;initialization is not needed.
[Bala]: will update
Quoted 10 lines
drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 957
Quoted 4 lines
drivers/bluetooth/hci_qca.c +3
-0+int ret =0 ; + + speed =qca_get_oper_speed (hu);if (speed) {nit:
if (!speed) return 0;[Bala]: will update.
Quoted 89 lines
Quoted 30 lines
drivers/bluetooth/hci_qca.c +18
-4qca_baudrate =qca_get_baudrate_value (speed); - -bt_dev_info (hdev,"Set UART speed to %d" , speed); - ret =qca_set_baudrate (hdev, qca_baudrate); +bt_dev_info (hu->hdev,"Set UART speed to %d" , speed); + ret =qca_set_baudrate (hu->hdev, qca_baudrate);if (ret) { -bt_dev_err (hdev,"Failed to change the baud rate (%d)" , +bt_dev_err (hu->hdev,"Failed to change the baud rate (%d)" , ret);return ret; }host_set_baudrate (hu, speed); } +return ret; +} + +static int qca_setup (struct hci_uart *hu) +{ +struct hci_dev *hdev = hu->hdev; +struct qca_data *qca = hu->priv; +unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ; +int ret; +int soc_ver =0 ; + +bt_dev_info (hdev,"ROME setup" ); + +/* Patch downloading has to be done without IBS mode */ +clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags);drivers/bluetooth/hci_qca.c static int qca_setup(struct hci_uart *hu) · line 993
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+ +/* Setup initial baudrate */ +qca_set_init_speed (hu); +/* Setup user speed if needed */ + ret =qca_set_oper_speed (hu); +if (ret) +return ret; + speed =qca_get_oper_speed (hu); +if (speed) + qca_baudrate =qca_get_baudrate_value (speed);nit: the sequence
qca_set_oper_speed()qca_get_oper_speed()is slightly awkward to read. This could be avoided if the speed was passed as parameter, though I understand this isn't done for symmetry with
qca_set_init_speed(). An alternative could be:static int qca_set_speed(struct
hci_uart*hu, unsigned int speed, enum
qca_speed_typespeed_type){ unsigned int qca_baudrate; if (speed_type == QCA_OPER_SPEED) { qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) { bt_dev_err(hu->hdev, "Failed to change the baud rate (%d)", ret); return ret; } } host_set_baudrate(hu, speed); /* If the order doesn't matter set the host baudrate first and return if speed_type != QCA_OPER_SPEED */ return 0; }static int
qca_setup(struct hci_uart *hu){ ... speed = qca_get_init_speed(hu); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); speed = qca_get_oper_speed(hu); if (speed) { qca_set_speed(hu, speed, QCA_OPER_SPEED); qca_baudrate = qca_get_baudrate_value(speed); } ... }Quoted 3 lines
Quoted 1 line
Just a suggestion, ok for me if you prefer to keep it as is.
[Bala]: will study and update the same.
[Bala]: you are suggestion looks ok to me. i am thinking to optimize further.
static unsigned int qca_get_speed(struct
hci_uart*hu,
enumqca_speed_typespeed_type){ unsigned int speed = 0; if (speed_type == QCA_INIT_SPEED) { if (hu->init_speed) speed = hu->init_speed; else if (hu->proto->init_speed) speed = hu->proto->init_speed; } else { if (hu->oper_speed) speed = hu->oper_speed; else if (hu->proto->oper_speed) speed = hu->proto->oper_speed; } return speed; }static int qca_set_speed(struct
hci_uart*hu, unsigned int speed,
enumqca_speed_typespeed_type){ unsigned int qca_baudrate; int ret; if (speed_type == QCA_OPER_SPEED) { qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) {
Quoted 8 lines
bt_dev_err(hu->hdev, "Failed to change the baudrate
(%d)",
ret);
return ret;
}
}
host_set_baudrate(hu, speed);nit: if the order doesn't matter consider setting the host baudrate first and return if 'speed_type != QCA_OPER_SPEED', which reduces the indentiation (just a minor not really important thing though).
I also see a point in not setting the host baudrate if the chip baudrate couldn't be set, so whatever ;-)
Quoted 22 lines
return ret; }static int
qca_setup(struct hci_uart *hu)
{
.../* Setup initial baudrate */ speed = qca_get_speed(hu, QCA_INIT_SPEED); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); /* Setup user speed if needed */ speed = qca_get_speed(hu, QCA_OPER_SPEED); if (speed) { ret = qca_set_speed(hu, speed, QCA_OPER_SPEED); if (ret) return ret; qca_baudrate = qca_get_baudrate_value(speed); }
Quoted 7 lines
}
will have two functions,
qca_set_speed(): for setting speedqca_get_speed(): to get the speed.is this preferable?
Looks good to me, thanks!
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiHi Balakrishna,
Quoted 64 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 53 lines · Matthias Kaehlcke
Quoted 45 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 16 lines · Matthias Kaehlcke
Quoted 14 lines · Balakrishna Godavarthi
drivers/bluetooth/btqca.c +4
-5@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) {Quoted 8 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 5 lines
drivers/bluetooth/btqca.c +4
-0+bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other
wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.Quoted 6 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
Quoted 7 lines
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
Quoted 7 lines
[Bala]: yes we can read SoC version after setting operating baud rate. an advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting operating
baudrate,it will helps us to understand whether the soc is responding to any commands in default baud rate
before setting operating speed.
Is the recommendation for Rome or wcn3990? I was referring to Rome and the current code sets the operating speed and then reads the SoC version (inside qca_uart_setup())
Quoted 8 lines
Quoted 5 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Since you mention if-else and flow control I'm not sure if you understood correctly what I suggested. My suggestion is to add something like this:
if (qcadev->btsoc_type == QCA_ROME) {
ret = qca_read_soc_version(hdev, &soc_ver);
if (ret < 0 || soc_ver == 0) {
// Note mka@: we might want to skip this log,
// qca_read_soc_version() already logs in all error paths
bt_dev_err(hdev, "Failed to get version %d", ret);
return ret;
}
}right here:
which is functionally equivalent to the current code.
You could even do the error check in the common code (just checking for 'soc_ver == 0', assuming that qca_read_soc_version() doesn't set it to something different in case of error).
Anyway, I won't insist if you prefer it as is and Marcel is ok with it.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
Hi Matthias,
Quoted 76 lines · Matthias Kaehlcke
Hi Balakrishna,
Quoted 64 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 53 lines · Matthias Kaehlcke
Quoted 45 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 16 lines · Matthias Kaehlcke
Quoted 14 lines · Balakrishna Godavarthi
drivers/bluetooth/btqca.c +4
-5@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; -/* Get QCA version information */ - err =qca_read_soc_version (hdev, &rome_ver); -if (err <0 || rome_ver ==0 ) { -bt_dev_err (hdev,"QCA Failed to get version %d" , err); -return err; +if (!soc_ver) { +/* Get QCA version information */ + err =qca_read_soc_version (hdev, &soc_ver); +if (err <0 || soc_ver ==0 ) {Quoted 8 lines
drivers/bluetooth/btqca.c int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) · line 348
Quoted 5 lines
drivers/bluetooth/btqca.c +4
-0+bt_dev_err (hdev,"QCA Failed to get version %d" , err); +return err; + } +bt_dev_info (hdev,"QCA controller version 0x%08x" , soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other
wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.Quoted 6 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
Quoted 7 lines
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
Quoted 8 lines
[Bala]: yes we can read SoC version after setting operating baud rate. an advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting
operating
baudrate,it will helps us to understand whether the soc is responding to any commands in default baud rate
before setting operating speed.
Quoted 4 lines
Is the recommendation for Rome or wcn3990? I was referring to Rome and the current code sets the operating speed and then reads the SoC version (inside
qca_uart_setup())
[Bala]: my statement is wrt to wcn3990. yes, ROME will set operating speed and read version.
Quoted 27 lines
Quoted 8 lines
Quoted 5 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Since you mention if-else and flow control I'm not sure if you understood correctly what I suggested. My suggestion is to add something like this:
if (qcadev->btsoc_type == QCA_ROME) { ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { // Note mka@: we might want to skip this log, // qca_read_soc_version() already logs in all error paths bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } }right here:
Quoted 7 lines
which is functionally equivalent to the current code.
You could even do the error check in the common code (just checking for '
soc_ver== 0', assuming thatqca_read_soc_version()doesn't set it to something different in case of error).Anyway, I won't insist if you prefer it as is and Marcel is ok with it.
[Bala]: thanks for clarifying my doubt, but if remove the qca_read_soc_version() from qca_uart_setup() and handle it qca_setup().
in that case, we will have common blocks of code, when we
integrate wcn3990 into existing qca_setup()
static int qca_setup(struct hci_uart *hu)
{
...
qcadev = serdev_device_get_drvdata(hu->serdev);
/* Patch downloading has to be done without IBS mode */
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
/* Setup initial baudrate */
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);
if (qcadev->btsoc_type == QCA_WCN3990) {
bt_dev_dbg(hdev, "setting up wcn3990");
hci_uart_set_flow_control(hu, true);
ret = qca_send_vendor_cmd(hdev,
QCA_WCN3990_POWERON_PULSE);
if (ret) {
bt_dev_err(hdev, "failed to send power on
command");
return ret;
}
serdev_device_close(hu->serdev);
ret = serdev_device_open(hu->serdev);
if (ret) {
bt_dev_err(hdev, "failed to open port");
return ret;
}
msleep(100);
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);
hci_uart_set_flow_control(hu, false);
} else {
bt_dev_info(hdev, "ROME setup");
/* Setup user speed if needed */
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (speed) {
ret = qca_set_speed(hu, speed, QCA_OPER_SPEED);
if (ret)
return ret;
qca_baudrate = qca_get_baudrate_value(speed);
}
}
ret = qca_read_soc_version(hdev, &soc_ver);
if (ret < 0 || soc_ver == 0) {
bt_dev_err(hdev, "Failed to get version %d", ret);
return ret;
}
bt_dev_info(hdev, "wcn3990 controller version 0x%08x", soc_ver);
if (qcadev->btsoc_type == QCA_WCN3990) {
hci_uart_set_flow_control(hu, true);
/* Setup user speed if needed */
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (speed) {
ret = qca_set_speed(hu, speed, QCA_OPER_SPEED);
if (ret)
return ret;
qca_baudrate = qca_get_baudrate_value(speed);
}
/* Setup patch / NVM configurations */
ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type,
soc_ver);
if (!ret) {
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
qca_debugfs_init(hdev);
} else if (ret == -ENOENT) {
/* No patch/nvm-config found, run with original
fw/config */
ret = 0;
} else if (ret == -EAGAIN) {
/*
...
}Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Matthias KaehlckeHi Matthias,
Quoted 31 lines · Matthias Kaehlcke
Quoted 18 lines · Balakrishna Godavarthi
Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c +1
-0@@ -402,6 +441,7 @@ static int qca_open(struct hci_uart *hu) {struct qca_serdev *qcadev;struct qca_data *qca; +int ret =0 ;BT_DBG ("hu %p qca_open" , hu);drivers/bluetooth/hci_qca.c static int qca_open(struct hci_uart *hu) · line 509
Quoted 8 lines
drivers/bluetooth/hci_qca.c +4
-1@@ -463,13 +503,19 @@ static int qca_open(struct hci_uart *hu)serdev_device_open (hu->serdev); qcadev =serdev_device_get_drvdata (hu->serdev); -gpiod_set_value_cansleep (qcadev->bt_en,1 ); +if (qcadev->btsoc_type ==QCA_WCN3990 ) { + hu->init_speed = qcadev->init_speed; + hu->oper_speed = qcadev->oper_speed; + ret =qca_btsoc_power_setup (hu, true);Better do this before starting the timers, otherwise you need to take care of stopping them in case of failure.
Quoted 3 lines
If
qca_btsoc_power_setup()fails you also have to free 'qca->workqueue' and 'qca'.
[Bala]: i missed this.will update
Quoted 15 lines
drivers/bluetooth/hci_qca.c static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) · line 987
Quoted 11 lines
drivers/bluetooth/hci_qca.c +11
-0+static int qca_send_vendor_cmd (struct hci_dev *hdev,u8 cmd) +{ +struct hci_uart *hu =hci_get_drvdata (hdev); +struct qca_data *qca = hu->priv; +struct sk_buff *skb; + +bt_dev_dbg (hdev,"sending command %02x to SoC" , cmd); + + skb =bt_skb_alloc (sizeof (cmd),GFP_KERNEL ); +if (!skb) { +bt_dev_err (hdev,"Failed to allocate memory for skb packet" );I was told that custom OOM messages should not be used, since the mm code will complain loudly in this case.
Quoted 5 lines
drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1049
Quoted 1 line
drivers/bluetooth/hci_qca.c +1
-0+static int qca_btsoc_shutdown (struct hci_uart *hu)The return value is not evaluated by the only caller, so this should probably be void.
[Bala]: will update
Quoted 41 lines
Quoted 28 lines
drivers/bluetooth/hci_qca.c +13
-3static int qca_setup (struct hci_uart *hu) {struct hci_dev *hdev = hu->hdev;struct qca_data *qca = hu->priv; +struct qca_serdev *qcadev;unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ;int ret;int soc_ver =0 ; -bt_dev_info (hdev,"ROME setup" ); + qcadev =serdev_device_get_drvdata (hu->serdev);/* Patch downloading has to be done without IBS mode */ clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); - -/* Setup initial baudrate */ qca_set_init_speed (hu); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) { +bt_dev_dbg (hdev,"setting up wcn3990" ); +hci_uart_set_flow_control (hu, true); + ret =qca_send_vendor_cmd (hdev,CHEROKEE_POWERON_PULSE ); +if (ret) { +bt_dev_err (hdev,"failed to send power on command" ); +return ret; + } +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev);drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1092
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } +msleep (100 ); +qca_set_init_speed (hu); +hci_uart_set_flow_control (hu, false); + ret =qca_read_soc_version (hdev, &soc_ver); +if (ret <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"Failed to get version %d" , ret);
serdev_device_close()?
Quoted 2 lines
Also applies to other error paths in this function.
[Bala]: sorry, i didn't get you.
Quoted 11 lines
Quoted 11 lines
static int
qca_serdev_probe(struct serdev_device *serdev){drivers/bluetooth/hci_qca.c +1
-0struct qca_serdev *qcadev; +const struct qca_vreg_data *data;int err; qcadev =devm_kzalloc (&serdev->dev,sizeof (*qcadev),GFP_KERNEL );@@ -1041,47 +1264,85 @@ static int qca_serdev_probe(struct serdev_device *serdev)return -ENOMEM ;
Quoted 13 lines
drivers/bluetooth/hci_qca.c static int qca_serdev_probe(struct serdev_device *serdev) · line 1274
Quoted 9 lines
drivers/bluetooth/hci_qca.c +7
-0qcadev->serdev_hu.serdev = serdev; + data =of_device_get_match_data (&serdev->dev); +if (data && data->soc_type ==QCA_WCN3990 ) + qcadev->btsoc_type =QCA_WCN3990 ; +else + qcadev->btsoc_type =QCA_ROME ; +serdev_device_set_drvdata (serdev, qcadev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) {nit: the double "if (
soc_type==QCA_WCN3990)" is a bit odd. Consider changing this condition to "if (data &&data->soc_type==QCA_WCN3990)" and assignqcadev->btsoc_typein the corresponding branch.
[bala]: will update.
I have idea of removing flow control from qca_setup() and use them in qca_set_speed() "i need to disable hardware flow control when sending change baudrate request to WCN3990. enabling it after setting host baudrate. this is only for wcn3990.
"
static int qca_set_speed(struct hci_uart *hu, unsigned int speed,
enum qca_speed_type speed_type, enum qca_btsoc_type soc_type)
{
unsigned int qca_baudrate;
int ret;
if (speed_type == QCA_INIT_SPEED)
goto change_host_baudrate;
if (soc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, true);
qca_baudrate = qca_get_baudrate_value(speed);
bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
ret = qca_set_baudrate(hu->hdev, qca_baudrate);
if (ret) {
bt_dev_err(hu->hdev, "Failed to change the baudrate
(%d)", ret);
return ret;
}change_host_baudrate:
host_set_baudrate(hu, speed);
if (soc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, false);
return ret;
}is it good idea?
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
Hi Balakrishna,
Quoted 55 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 52 lines · Matthias Kaehlcke
Quoted 38 lines · Balakrishna Godavarthi
Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c +13
-3static int qca_setup (struct hci_uart *hu) {struct hci_dev *hdev = hu->hdev;struct qca_data *qca = hu->priv; +struct qca_serdev *qcadev;unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ;int ret;int soc_ver =0 ; -bt_dev_info (hdev,"ROME setup" ); + qcadev =serdev_device_get_drvdata (hu->serdev);/* Patch downloading has to be done without IBS mode */ clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); - -/* Setup initial baudrate */ qca_set_init_speed (hu); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) { +bt_dev_dbg (hdev,"setting up wcn3990" ); +hci_uart_set_flow_control (hu, true); + ret =qca_send_vendor_cmd (hdev,CHEROKEE_POWERON_PULSE ); +if (ret) { +bt_dev_err (hdev,"failed to send power on command" ); +return ret; + } +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev);drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1092
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } +msleep (100 ); +qca_set_init_speed (hu); +hci_uart_set_flow_control (hu, false); + ret =qca_read_soc_version (hdev, &soc_ver); +if (ret <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"Failed to get version %d" , ret);
serdev_device_close()?
Quoted 3 lines
Quoted 2 lines
Also applies to other error paths in this function.
[Bala]: sorry, i didn't get you.
A few lines above serdev_device_open() is called, in the error paths the device should be closed.
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
static int
qca_serdev_probe(struct serdev_device *serdev){drivers/bluetooth/hci_qca.c +1
-0struct qca_serdev *qcadev; +const struct qca_vreg_data *data;int err; qcadev =devm_kzalloc (&serdev->dev,sizeof (*qcadev),GFP_KERNEL );@@ -1041,47 +1264,85 @@ static int qca_serdev_probe(struct serdev_device *serdev)return -ENOMEM ;Quoted 13 lines
drivers/bluetooth/hci_qca.c static int qca_serdev_probe(struct serdev_device *serdev) · line 1274
Quoted 9 lines
drivers/bluetooth/hci_qca.c +7
-0qcadev->serdev_hu.serdev = serdev; + data =of_device_get_match_data (&serdev->dev); +if (data && data->soc_type ==QCA_WCN3990 ) + qcadev->btsoc_type =QCA_WCN3990 ; +else + qcadev->btsoc_type =QCA_ROME ; +serdev_device_set_drvdata (serdev, qcadev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) {nit: the double "if (
soc_type==QCA_WCN3990)" is a bit odd. Consider changing this condition to "if (data &&data->soc_type==QCA_WCN3990)" and assignqcadev->btsoc_typein the corresponding branch.
Quoted 8 lines
[bala]: will update.
I have idea of removing flow control from
qca_setup()and use them inqca_set_speed()
"i need to disable hardware flow control when sending change baudrate request to WCN3990.
enabling it after setting host baudrate. this is only for wcn3990. "
I definitely think it's positive to hide the hci_uart_set_flow_control() call in qca_set_speed(). A few comments inline.
Quoted 4 lines
static int qca_set_speed(struct
hci_uart*hu, unsigned int speed,
enumqca_speed_typespeed_type, enumqca_btsoc_typesoc_type)
{
That's a lot of parameters, in particular 'soc_type' seems a bit off-topic in a function called qca_set_speed(). Passing struct qca_serdev instead of struct hci_uart would make the 'soc_type' parameter unnecessary.
Quoted 5 lines
unsigned int qca_baudrate;
int ret;
if (speed_type == QCA_INIT_SPEED)
goto change_host_baudrate;If the order of setting host and chip baudrate can't be changed I think it's preferable to set the init speed right here in the if branch instead of doing the goto. I earlier mentioned the short cut of a return (if possible) to save a level of indentation, but a goto IMO doesn't improve readability and it's the first level of indentation anyway.
Quoted 22 lines
if (soc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, true); qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) { bt_dev_err(hu->hdev, "Failed to change the baudrate (%d)", ret); return ret; }
change_host_baudrate:host_set_baudrate(hu, speed); if (soc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, false); return ret; }
Quoted 1 line
is it good idea?
In general I think it is.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiQuoted 123 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 78 lines · Matthias Kaehlcke
Hi Balakrishna,
Quoted 64 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 53 lines · Matthias Kaehlcke
Quoted 45 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 16 lines · Matthias Kaehlcke
Quoted 14 lines · Balakrishna Godavarthi
(quoted diff) +4
-5@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; - /* Get QCA version information */ - err = qca_read_soc_version(hdev, &rome_ver); - if (err < 0 || rome_ver == 0) { - bt_dev_err(hdev, "QCA Failed to get version %d", err); - return err; + if (!soc_ver) { + /* Get QCA version information */ + err = qca_read_soc_version(hdev, &soc_ver); + if (err < 0 || soc_ver == 0) {Quoted 8 lines
Review int qca_uart_setup(struct hci_dev *hdev, · line 349
Quoted 5 lines
(quoted diff) +4
-0+ bt_dev_err(hdev, "QCA Failed to get version %d", err); + return err; + } + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other
wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.Quoted 6 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
Quoted 7 lines
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
Quoted 10 lines
[Bala]: yes we can read SoC version after setting operating baud rate. an
advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting
operating
baudrate,it will helps us to understand whether the soc is responding to any
commands in default baud rate
before setting operating speed.Quoted 4 lines
Is the recommendation for Rome or wcn3990? I was referring to Rome and the current code sets the operating speed and then reads the SoC version (inside
qca_uart_setup())[Bala]: my statement is wrt to wcn3990. yes, ROME will set operating speed and read version.
Quoted 34 lines
Quoted 9 lines
Quoted 5 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Since you mention if-else and flow control I'm not sure if you understood correctly what I suggested. My suggestion is to add something like this:
if (qcadev->btsoc_type == QCA_ROME) { ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { // Note mka@: we might want to skip this log, // qca_read_soc_version() already logs in all error paths bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } }right here:
which is functionally equivalent to the current code.
You could even do the error check in the common code (just checking for '
soc_ver== 0', assuming thatqca_read_soc_version()doesn't set it to something different in case of error).
Quoted 6 lines
Quoted 1 line
Anyway, I won't insist if you prefer it as is and Marcel is ok with it.
[Bala]: thanks for clarifying my doubt, but if remove the
qca_read_soc_version()fromqca_uart_setup()and handle itqca_setup().
in that case, we will have common blocks of code, when we integrate
wcn3990 into existingqca_setup()
Excellent!
Quoted 6 lines
static int qca_setup(struct hci_uart *hu)
{
...
qcadev = serdev_device_get_drvdata(hu->serdev);Quoted 7 lines
/* Patch downloading has to be done without IBS mode */
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
/* Setup initial baudrate */
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);I said earlier that a _set_speed() followed by a _get_speed() is a bit odd, and that it would be better to get the speed first and pass it as a parameter. After looking again over the larger code I'm not convinced anymore this is such a good idea, since the above pattern is repeated multiple times, when it could be just:
qca_set_speed(hu, QCA_INIT_SPEED)
(+ error handling, which is also missing in the code above)
Just a thought, not asking you to change it back, do whatever seems best to you.
Quoted 24 lines
if (qcadev->btsoc_type == QCA_WCN3990) {
bt_dev_dbg(hdev, "setting up wcn3990");
hci_uart_set_flow_control(hu, true);
ret = qca_send_vendor_cmd(hdev, QCA_WCN3990_POWERON_PULSE);
if (ret) {
bt_dev_err(hdev, "failed to send power on command");
return ret;
}
serdev_device_close(hu->serdev);
ret = serdev_device_open(hu->serdev);
if (ret) {
bt_dev_err(hdev, "failed to open port");
return ret;
}
msleep(100);
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed)
qca_set_speed(hu, speed, QCA_INIT_SPEED);
hci_uart_set_flow_control(hu, false);
} else {
bt_dev_info(hdev, "ROME setup");Quoted 8 lines
/* Setup user speed if needed */
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (speed) {
ret = qca_set_speed(hu, speed, QCA_OPER_SPEED);
if (ret)
return ret;
qca_baudrate = qca_get_baudrate_value(speed);It seems setting 'qca_baudrate' could also be done in the common path. Would require an extra qca_get_speed(hu, QCA_OPER_SPEED) call, in exchange this would be done in a single place closer to where 'qca_baudrate' is actually used.
Actually as it is now 'qca_baudrate' could remain uninitialized for Rome if no operating speed is defined, which judging from qca_get_baudrate_value() should result in QCA_BAUDRATE_115200.
Quoted 29 lines
}
}
ret = qca_read_soc_version(hdev, &soc_ver);
if (ret < 0 || soc_ver == 0) {
bt_dev_err(hdev, "Failed to get version %d", ret);
return ret;
}
bt_dev_info(hdev, "wcn3990 controller version 0x%08x", soc_ver);
if (qcadev->btsoc_type == QCA_WCN3990) {
hci_uart_set_flow_control(hu, true);
/* Setup user speed if needed */
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (speed) {
ret = qca_set_speed(hu, speed, QCA_OPER_SPEED);
if (ret)
return ret;
qca_baudrate = qca_get_baudrate_value(speed);
}
/* Setup patch / NVM configurations */
ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type,
soc_ver);
if (!ret) {
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);Quoted 8 lines
qca_debugfs_init(hdev);
} else if (ret == -ENOENT) {
/* No patch/nvm-config found, run with original fw/config */
ret = 0;
} else if (ret == -EAGAIN) {
/*
...
}Overall looks good and should still become a bit more compact if the handling of flow control is done in _set_speed() as you suggested in "[PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990"
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Balakrishna GodavarthiQuoting Balakrishna Godavarthi (2018-06-18 10:07:31)
Quoted 33 lines
Hi Stephen,
=Please find my comments inline.
=Quoted 18 lines · Stephen Boyd
Quoting Balakrishna Godavarthi (2018-06-15 23:27:18)
Quoted 9 lines
drivers/bluetooth/hci_qca.c +0
-0@@ -1031,9 +1145,118 @@ static struct hci_uart_proto qca_proto =3D { .dequeue =3D qca_dequeue, };=
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1155
Quoted 8 lines
drivers/bluetooth/hci_qca.c +8
-0+static const struct qca_vreg_data qca_cherokee_data =3D { + .soc_type =3D QCA_WCN3990, + .vregs =3D (struct qca_vreg []) { + { "vddio", 1352000, 1352000, 0 }, + { "vddxtal", 1904000, 2040000, 0 }, + { "vddcore", 1800000, 1800000, 1 }, + { "vddpa", 1304000, 1304000, 1 }, + { "vddldo", 3000000, 3312000, 1 },Quoted 5 lines
=
Load of 0 and 1 seems sort of odd. Are these made up to indicate "some load" vs. "no load"?
==
Quoted 7 lines
[Bala]: this value specifies the output load current required to turn on =
the wcn3990.
in struct defined vddio\vddxtal are smps, with fixed load. regs from vddcore/vddpa/vddldo are programmable line regulators, =in which we need to set the basic load.
I got that part, but a load of 1 still seems like a nonsensical value. Is it to workaround some issue with the regulator driver?
It's also pretty weird to be setting regulator voltages here in the driver. Typically that's configured on the board and then the DT has the right voltage already. The only case when the voltage may need to be set by the driver is if the hardware can dynamically scale the voltage for things like DVFS. It looks like here that the voltage is always fixed, so probably we don't need to have any sort of voltage setting in this driver and can rely on the DTS file to get things right.
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Matthias KaehlckeHi Matthias,
Quoted 58 lines · Matthias Kaehlcke
Hi Balakrishna,
Quoted 55 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 52 lines · Matthias Kaehlcke
Quoted 38 lines · Balakrishna Godavarthi
Add support to set voltage/current of various regulators to power up/down Bluetooth chip wcn3990.
Signed-off-by Balakrishna Godavarthi <[email protected]>---
drivers/bluetooth/hci_qca.c +13
-3static int qca_setup (struct hci_uart *hu) {struct hci_dev *hdev = hu->hdev;struct qca_data *qca = hu->priv; +struct qca_serdev *qcadev;unsigned int speed, qca_baudrate =QCA_BAUDRATE_115200 ;int ret;int soc_ver =0 ; -bt_dev_info (hdev,"ROME setup" ); + qcadev =serdev_device_get_drvdata (hu->serdev);/* Patch downloading has to be done without IBS mode */ clear_bit (STATE_IN_BAND_SLEEP_ENABLED , &qca->flags); - -/* Setup initial baudrate */ qca_set_init_speed (hu); + +if (qcadev->btsoc_type ==QCA_WCN3990 ) { +bt_dev_dbg (hdev,"setting up wcn3990" ); +hci_uart_set_flow_control (hu, true); + ret =qca_send_vendor_cmd (hdev,CHEROKEE_POWERON_PULSE ); +if (ret) { +bt_dev_err (hdev,"failed to send power on command" ); +return ret; + } +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev);drivers/bluetooth/hci_qca.c static int qca_set_oper_speed(struct hci_uart *hu) · line 1092
Quoted 10 lines
drivers/bluetooth/hci_qca.c +10
-0+if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } +msleep (100 ); +qca_set_init_speed (hu); +hci_uart_set_flow_control (hu, false); + ret =qca_read_soc_version (hdev, &soc_ver); +if (ret <0 || soc_ver ==0 ) { +bt_dev_err (hdev,"Failed to get version %d" , ret);
serdev_device_close()?
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Also applies to other error paths in this function.
[Bala]: sorry, i didn't get you.
A few lines above
serdev_device_open()is called, in the error paths the device should be closed.
[Bala]: i don't think closing of port is required.
qca_send_vendor_cmd() fails if skb_alloc() fails. that is not
linked with serdev_close().
we need to close the port, if we have issues from reading or
writing into the port.
pls correct me if i am wrong.
Quoted 44 lines
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
static int
qca_serdev_probe(struct serdev_device *serdev){drivers/bluetooth/hci_qca.c +1
-0struct qca_serdev *qcadev; +const struct qca_vreg_data *data;int err; qcadev =devm_kzalloc (&serdev->dev,sizeof (*qcadev),GFP_KERNEL );@@ -1041,47 +1264,85 @@ static int qca_serdev_probe(struct serdev_device *serdev)return -ENOMEM ;Quoted 13 lines
drivers/bluetooth/hci_qca.c static int qca_serdev_probe(struct serdev_device *serdev) · line 1274
Quoted 9 lines
drivers/bluetooth/hci_qca.c +7
-0qcadev->serdev_hu.serdev = serdev; + data =of_device_get_match_data (&serdev->dev); +if (data && data->soc_type ==QCA_WCN3990 ) + qcadev->btsoc_type =QCA_WCN3990 ; +else + qcadev->btsoc_type =QCA_ROME ; +serdev_device_set_drvdata (serdev, qcadev); +if (qcadev->btsoc_type ==QCA_WCN3990 ) {nit: the double "if (
soc_type==QCA_WCN3990)" is a bit odd. Consider changing this condition to "if (data &&data->soc_type==QCA_WCN3990)" and assignqcadev->btsoc_typein the corresponding branch.Quoted 8 lines
[bala]: will update.
I have idea of removing flow control from
qca_setup()and use them inqca_set_speed()
"i need to disable hardware flow control when sending change baudrate request to WCN3990.
enabling it after setting host baudrate. this is only for wcn3990. "I definitely think it's positive to hide the
hci_uart_set_flow_control()call inqca_set_speed(). A few comments inline.Quoted 4 lines
static int qca_set_speed(struct
hci_uart*hu, unsigned int speed,
enumqca_speed_typespeed_type, enumqca_btsoc_typesoc_type)
{
Quoted 5 lines
That's a lot of parameters, in particular '
soc_type' seems a bit off-topic in a function calledqca_set_speed(). Passing structqca_serdevinstead of structhci_uartwould make the 'soc_type' parameter unnecessary.
[Bala]: will update.
Quoted 6 lines
Quoted 5 lines
unsigned int qca_baudrate; int ret; if (speed_type == QCA_INIT_SPEED) goto change_host_baudrate;
Quoted 7 lines
If the order of setting host and chip baudrate can't be changed I think it's preferable to set the init speed right here in the if branch instead of doing the goto. I earlier mentioned the short cut of a return (if possible) to save a level of indentation, but a goto IMO doesn't improve readability and it's the first level of indentation anyway.
[Bala]: will update.
Quoted 26 lines
Quoted 23 lines
if (soc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, true); qca_baudrate = qca_get_baudrate_value(speed); bt_dev_info(hu->hdev, "Set UART speed to %d", speed); ret = qca_set_baudrate(hu->hdev, qca_baudrate); if (ret) { bt_dev_err(hu->hdev, "Failed to change the baudrate (%d)", ret); return ret; }
change_host_baudrate:host_set_baudrate(hu, speed); if (soc_type == QCA_WCN3990) hci_uart_set_flow_control(hu, false); return ret; }Quoted 1 line
is it good idea?
In general I think it is.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Matthias KaehlckeHi Matthias,
Quoted 247 lines · Matthias Kaehlcke
Quoted 123 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 78 lines · Matthias Kaehlcke
Hi Balakrishna,
Quoted 64 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 53 lines · Matthias Kaehlcke
Quoted 45 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 16 lines · Matthias Kaehlcke
Quoted 14 lines · Balakrishna Godavarthi
(quoted diff) +4
-5@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; - /* Get QCA version information */ - err = qca_read_soc_version(hdev, &rome_ver); - if (err < 0 || rome_ver == 0) { - bt_dev_err(hdev, "QCA Failed to get version %d", err); - return err; + if (!soc_ver) { + /* Get QCA version information */ + err = qca_read_soc_version(hdev, &soc_ver); + if (err < 0 || soc_ver == 0) {Quoted 8 lines
Review int qca_uart_setup(struct hci_dev *hdev, · line 349
Quoted 5 lines
(quoted diff) +4
-0+ bt_dev_err(hdev, "QCA Failed to get version %d", err); + return err; + } + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other
wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.Quoted 6 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
Quoted 7 lines
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
Quoted 10 lines
[Bala]: yes we can read SoC version after setting operating baud rate. an
advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting
operating
baudrate,it will helps us to understand whether the soc is responding to any
commands in default baud rate
before setting operating speed.Quoted 4 lines
Is the recommendation for Rome or wcn3990? I was referring to Rome and the current code sets the operating speed and then reads the SoC version (inside
qca_uart_setup())[Bala]: my statement is wrt to wcn3990. yes, ROME will set operating speed and read version.
Quoted 34 lines
Quoted 9 lines
Quoted 5 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Since you mention if-else and flow control I'm not sure if you understood correctly what I suggested. My suggestion is to add something like this:
if (qcadev->btsoc_type == QCA_ROME) { ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { // Note mka@: we might want to skip this log, // qca_read_soc_version() already logs in all error paths bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } }right here:
which is functionally equivalent to the current code.
You could even do the error check in the common code (just checking for '
soc_ver== 0', assuming thatqca_read_soc_version()doesn't set it to something different in case of error).Quoted 7 lines
Quoted 1 line
Anyway, I won't insist if you prefer it as is and Marcel is ok with it.
[Bala]: thanks for clarifying my doubt, but if remove the
qca_read_soc_version()fromqca_uart_setup()and handle itqca_setup().
in that case, we will have common blocks of code, when we
integrate
wcn3990 into existingqca_setup()Excellent!
Quoted 6 lines
static int qca_setup(struct hci_uart *hu) { ... qcadev = serdev_device_get_drvdata(hu->serdev);Quoted 7 lines
/* Patch downloading has to be done without IBS mode */ clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); /* Setup initial baudrate */ speed = qca_get_speed(hu, QCA_INIT_SPEED); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED);I said earlier that a
_set_speed()followed by a_get_speed()is a bit odd, and that it would be better to get the speed first and pass it as a parameter. After looking again over the larger code I'm not convinced anymore this is such a good idea, since the above pattern is repeated multiple times, when it could be just:
qca_set_speed(hu, QCA_INIT_SPEED)(+ error handling, which is also missing in the code above)
Just a thought, not asking you to change it back, do whatever seems best to you.
Quoted 27 lines
if (qcadev->btsoc_type == QCA_WCN3990) { bt_dev_dbg(hdev, "setting up wcn3990"); hci_uart_set_flow_control(hu, true); ret = qca_send_vendor_cmd(hdev, QCA_WCN3990_POWERON_PULSE); if (ret) { bt_dev_err(hdev, "failed to send power on command"); return ret; } serdev_device_close(hu->serdev); ret = serdev_device_open(hu->serdev); if (ret) { bt_dev_err(hdev, "failed to open port"); return ret; } msleep(100); speed = qca_get_speed(hu, QCA_INIT_SPEED); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); hci_uart_set_flow_control(hu, false); } else { bt_dev_info(hdev, "ROME setup"); /* Setup user speed if needed */Quoted 8 lines
speed = qca_get_speed(hu, QCA_OPER_SPEED); if (speed) { ret = qca_set_speed(hu, speed, QCA_OPER_SPEED); if (ret) return ret; qca_baudrate = qca_get_baudrate_value(speed);It seems setting '
qca_baudrate' could also be done in the common path. Would require an extraqca_get_speed(hu, QCA_OPER_SPEED)call, in exchange this would be done in a single place closer to where 'qca_baudrate' is actually used.Actually as it is now '
qca_baudrate' could remain uninitialized for Rome if no operating speed is defined, which judging fromqca_get_baudrate_value()should result inQCA_BAUDRATE_115200.Quoted 32 lines
} } ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } bt_dev_info(hdev, "wcn3990 controller version 0x%08x",
soc_ver);if (qcadev->btsoc_type == QCA_WCN3990) { hci_uart_set_flow_control(hu, true); /* Setup user speed if needed */ speed = qca_get_speed(hu, QCA_OPER_SPEED); if (speed) { ret = qca_set_speed(hu, speed, QCA_OPER_SPEED); if (ret) return ret; qca_baudrate = qca_get_baudrate_value(speed); } /* Setup patch / NVM configurations */ ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type, soc_ver); if (!ret) { set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); qca_debugfs_init(hdev);Quoted 8 lines
} else if (ret == -ENOENT) { /* No patch/nvm-config found, run with original fw/config */ ret = 0; } else if (ret == -EAGAIN) { /* ... }
Quoted 4 lines
Overall looks good and should still become a bit more compact if the handling of flow control is done in
_set_speed()as you suggested in "[PATCH v7 8/8] Bluetooth:hci_qca: Add support for Qualcomm Bluetooth chip wcn3990"
[Bala}: to over come calling qca_get_speed() for qca_baudrate.
i prefer passing qca_baudrate as pointer argument toqca_set_speed().
that will actually helps to lower function calls. intern
increase the speed of execution too.
code snippet after integrating wcn3990:
static int qca_set_speed(struct hci_uart *hu, unsigned int*qca_baudrate,
enum qca_speed_type speed_type)
{
struct qca_serdev *qcadev;
unsigned int speed;
int ret;
if (speed_type == QCA_INIT_SPEED) {
speed = qca_get_speed(hu, QCA_INIT_SPEED);
if (speed) {
host_set_baudrate(hu, speed);
*qca_baudrate = qca_get_baudrate_value(speed);
} else {
bt_dev_err(hu->hdev, "Init speed should be non
zero");
}
return 0;
}
speed = qca_get_speed(hu, QCA_OPER_SPEED);
if (!speed) {
bt_dev_err(hu->hdev, "operating speed should be non
zero");
return 0;
}
qcadev = serdev_device_get_drvdata(hu->serdev);
/* Disabling hardware flow control is preferred while
* sending change baud rate command to SoC.
*/
if (qcadev->btsoc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, true);
*qca_baudrate = qca_get_baudrate_value(speed);
bt_dev_info(hu->hdev, "Set UART speed to %d", speed);
ret = qca_set_baudrate(hu->hdev, *qca_baudrate);
if (ret) {
bt_dev_err(hu->hdev, "Failed to change the baudrate
(%d)", ret);
return ret;
}
host_set_baudrate(hu, speed);
if (qcadev->btsoc_type == QCA_WCN3990)
hci_uart_set_flow_control(hu, false);
return 0;
}static int qca_setup(struct hci_uart *hu)
{
....
qcadev = serdev_device_get_drvdata(hu->serdev);
/* Patch downloading has to be done without IBS mode */
clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
/* Setup initial baudrate */
qca_set_speed(hu, &qca_baudrate, QCA_INIT_SPEED);
if (qcadev->btsoc_type == QCA_WCN3990) {
bt_dev_dbg(hdev, "setting up wcn3990");
hci_uart_set_flow_control(hu, true);
ret = qca_send_vendor_cmd(hdev,
QCA_WCN3990_POWERON_PULSE);
if (ret)
return ret;
serdev_device_close(hu->serdev);
ret = serdev_device_open(hu->serdev);
if (ret) {
bt_dev_err(hdev, "failed to open port");
return ret;
}
msleep(100);
/* Setup initial baudrate */
qca_set_speed(hu, &qca_baudrate, QCA_INIT_SPEED);
hci_uart_set_flow_control(hu, false);
ret = qca_read_soc_version(hdev, &soc_ver);
if (ret < 0 || soc_ver == 0) {
bt_dev_err(hdev, "Failed to get version %d",
ret);
return ret;
}
bt_dev_info(hdev, "wcn3990 controller version 0x%08x",
soc_ver);
} else {
bt_dev_info(hdev, "ROME setup");
}
/* Setup user speed if needed */
ret = qca_set_speed(hu, &qca_baudrate, QCA_OPER_SPEED);
if (ret)
return ret;
/* Setup patch / NVM configurations */
ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type,
soc_ver);
if (!ret) {
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
qca_debugfs_init(hdev);
} else if (ret == -ENOENT) {
/* No patch/nvm-config found, run with original
fw/config */
ret = 0;
} else if (ret == -EAGAIN) {
/*
* Userspace firmware loader will return -EAGAIN in case
no
* patch/nvm-config is found, so run with original
fw/config.
*/
ret = 0;
}
/* Setup bdaddr */
hu->hdev->set_bdaddr = qca_set_bdaddr_rome;
return ret;}
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 8/8] Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990
In reply to Stephen BoydHi Stephen,
Quoted 35 lines · Stephen Boyd
Quoting Balakrishna Godavarthi (2018-06-18 10:07:31)
Quoted 27 lines
Hi Stephen,
Please find my comments inline.
Quoted 9 lines · Stephen Boyd
Quoting Balakrishna Godavarthi (2018-06-15 23:27:18)
Quoted 8 lines
drivers/bluetooth/hci_qca.c +0
-0@@ -1031,9 +1145,118 @@ static struct hci_uart_proto qca_proto = { .dequeue = qca_dequeue, };Quoted 12 lines
drivers/bluetooth/hci_qca.c static struct hci_uart_proto qca_proto = { · line 1155
Quoted 8 lines
drivers/bluetooth/hci_qca.c +8
-0+static const struct qca_vreg_data qca_cherokee_data = { + .soc_type =QCA_WCN3990 , + .vregs = (struct qca_vreg []) { + {"vddio" ,1352000 ,1352000 ,0 }, + {"vddxtal" ,1904000 ,2040000 ,0 }, + {"vddcore" ,1800000 ,1800000 ,1 }, + {"vddpa" ,1304000 ,1304000 ,1 }, + {"vddldo" ,3000000 ,3312000 ,1 },Load of 0 and 1 seems sort of odd. Are these made up to indicate "some load" vs. "no load"?
Quoted 6 lines
[Bala]: this value specifies the output load current required to turn on the wcn3990.
in struct defined vddio\vddxtal are smps, with fixed load. regs from vddcore/vddpa/vddldo are programmable line
regulators,
in which we need to set the basic load.
Quoted 3 lines
I got that part, but a load of 1 still seems like a nonsensical value. Is it to workaround some issue with the regulator driver?
[Bala]: i don't think, it is issue with regulator driver.
Quoted 7 lines
It's also pretty weird to be setting regulator voltages here in the driver. Typically that's configured on the board and then the DT has the right voltage already. The only case when the voltage may need to be set by the driver is if the hardware can dynamically scale the voltage for things like DVFS. It looks like here that the voltage is always fixed, so probably we don't need to have any sort of voltage setting in this driver and can rely on the DTS file to get things right.
[Bala]: voltage required by wcn3990 are fixed. now i am using a programmable line regulators.
in future, if i have an platform where we have a variable
voltage regulators used. i.e. an voltage can be scaled to the required voltage to wcn3990.
in that case, we explicitly restrict the regulator output
voltage to wcn3990 standards.
let us take an example. i am using an programmable regulator,
with varying output voltage ranges from 1v to 5v.
but from wcn3990 we require an voltage 3.3v. while enabling the
regulators.. so that output of regulator will be 3.3v fixed.
one more case, every time when we have platform change.. we need
to ensure that regulators voltage level should be matching with wcn3990.
instead we expect platform vendor to do all these. i want to
restrict the voltages in driver itself.
please let me know, if cleared your query.
Signature · 2 lines
Regards Balakrishna.
Re: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
In reply to Balakrishna GodavarthiQuoted 257 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 249 lines · Matthias Kaehlcke
Quoted 124 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 78 lines · Matthias Kaehlcke
Hi Balakrishna,
Quoted 64 lines · Balakrishna Godavarthi
Hi Matthias,
Quoted 53 lines · Matthias Kaehlcke
Quoted 45 lines · Balakrishna Godavarthi
Hi Matthias,
Please find my comments inline.
Quoted 16 lines · Matthias Kaehlcke
Quoted 14 lines · Balakrishna Godavarthi
(quoted diff) +4
-5@@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; - /* Get QCA version information */ - err = qca_read_soc_version(hdev, &rome_ver); - if (err < 0 || rome_ver == 0) { - bt_dev_err(hdev, "QCA Failed to get version %d", err); - return err; + if (!soc_ver) { + /* Get QCA version information */ + err = qca_read_soc_version(hdev, &soc_ver); + if (err < 0 || soc_ver == 0) {Quoted 8 lines
Review int qca_uart_setup(struct hci_dev *hdev, · line 349
Quoted 5 lines
(quoted diff) +4
-0+ bt_dev_err(hdev, "QCA Failed to get version %d", err); + return err; + } + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); }Why is this needed? A caller that passes in
soc_ver= 0 could just callqca_read_soc_version()themselves.[Bala]:
hci_qcasupport two chip one ROME (already up-streamed) and other
wcn3990.
there setup sequence differs.wcn3900:
1. set baudrate to 115200
2. read soc version
3. set baudarte to 3.2Mbps
4. download firmware. (callsqca_uart_setup)ROME:
1. set baudrate to 3.0 mbps
2. callsqca_uart_setupto read soc version and download
firmware.Quoted 6 lines
so to make use of existing function
qca_setup_uart(). passingsoc_ver
as argument.
ifsoc_veris zero, then read soc version (i.e. for ROME chip).Pls let me know, if you have any queries.
Quoted 7 lines
I don't really understand this argumentation. Let's look at the code at the end of this series, where both Rome and wcn3900 are supported:
The version could be read (for Rome only) after setting the operating speed:
Quoted 10 lines
[Bala]: yes we can read SoC version after setting operating baud rate. an
advice from SoC vendor that, read SoC version before setting operating speed.
one advantage from reading SoC version before setting
operating
baudrate,it will helps us to understand whether the soc is responding to any
commands in default baud rate
before setting operating speed.Quoted 4 lines
Is the recommendation for Rome or wcn3990? I was referring to Rome and the current code sets the operating speed and then reads the SoC version (inside
qca_uart_setup())[Bala]: my statement is wrt to wcn3990. yes, ROME will set operating speed
and read version.Quoted 34 lines
Quoted 9 lines
Quoted 5 lines
I concede that having two "if (
qcadev->btsoc_type== XYZ)" branches inqca_setup()is kinda ugly, but I think it's still better than the conditional call ofqca_read_soc_version()inqca_uart_setup().[Bala]: we require an if-else block for soc type.As wcn3900 support hardware flow control where as ROME is not supporting hardware flow control.
Since you mention if-else and flow control I'm not sure if you understood correctly what I suggested. My suggestion is to add something like this:
if (qcadev->btsoc_type == QCA_ROME) { ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { // Note mka@: we might want to skip this log, // qca_read_soc_version() already logs in all error paths bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } }right here:
which is functionally equivalent to the current code.
You could even do the error check in the common code (just checking for '
soc_ver== 0', assuming thatqca_read_soc_version()doesn't set it to something different in case of error).Quoted 8 lines
Quoted 1 line
Anyway, I won't insist if you prefer it as is and Marcel is ok with it.
[Bala]: thanks for clarifying my doubt, but if remove the
qca_read_soc_version()fromqca_uart_setup()and handle itqca_setup().
in that case, we will have common blocks of code, when we
integrate
wcn3990 into existingqca_setup()Excellent!
Quoted 6 lines
static int qca_setup(struct hci_uart *hu) { ... qcadev = serdev_device_get_drvdata(hu->serdev);Quoted 7 lines
/* Patch downloading has to be done without IBS mode */ clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); /* Setup initial baudrate */ speed = qca_get_speed(hu, QCA_INIT_SPEED); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED);I said earlier that a
_set_speed()followed by a_get_speed()is a bit odd, and that it would be better to get the speed first and pass it as a parameter. After looking again over the larger code I'm not convinced anymore this is such a good idea, since the above pattern is repeated multiple times, when it could be just:
qca_set_speed(hu, QCA_INIT_SPEED)(+ error handling, which is also missing in the code above)
Just a thought, not asking you to change it back, do whatever seems best to you.
Quoted 27 lines
if (qcadev->btsoc_type == QCA_WCN3990) { bt_dev_dbg(hdev, "setting up wcn3990"); hci_uart_set_flow_control(hu, true); ret = qca_send_vendor_cmd(hdev, QCA_WCN3990_POWERON_PULSE); if (ret) { bt_dev_err(hdev, "failed to send power on command"); return ret; } serdev_device_close(hu->serdev); ret = serdev_device_open(hu->serdev); if (ret) { bt_dev_err(hdev, "failed to open port"); return ret; } msleep(100); speed = qca_get_speed(hu, QCA_INIT_SPEED); if (speed) qca_set_speed(hu, speed, QCA_INIT_SPEED); hci_uart_set_flow_control(hu, false); } else { bt_dev_info(hdev, "ROME setup"); /* Setup user speed if needed */Quoted 8 lines
speed = qca_get_speed(hu, QCA_OPER_SPEED); if (speed) { ret = qca_set_speed(hu, speed, QCA_OPER_SPEED); if (ret) return ret; qca_baudrate = qca_get_baudrate_value(speed);It seems setting '
qca_baudrate' could also be done in the common path. Would require an extraqca_get_speed(hu, QCA_OPER_SPEED)call, in exchange this would be done in a single place closer to where 'qca_baudrate' is actually used.Actually as it is now '
qca_baudrate' could remain uninitialized for Rome if no operating speed is defined, which judging fromqca_get_baudrate_value()should result inQCA_BAUDRATE_115200.Quoted 32 lines
} } ret = qca_read_soc_version(hdev, &soc_ver); if (ret < 0 || soc_ver == 0) { bt_dev_err(hdev, "Failed to get version %d", ret); return ret; } bt_dev_info(hdev, "wcn3990 controller version 0x%08x",
soc_ver);if (qcadev->btsoc_type == QCA_WCN3990) { hci_uart_set_flow_control(hu, true); /* Setup user speed if needed */ speed = qca_get_speed(hu, QCA_OPER_SPEED); if (speed) { ret = qca_set_speed(hu, speed, QCA_OPER_SPEED); if (ret) return ret; qca_baudrate = qca_get_baudrate_value(speed); } /* Setup patch / NVM configurations */ ret = qca_uart_setup(hdev, qca_baudrate, qcadev->btsoc_type, soc_ver); if (!ret) { set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); qca_debugfs_init(hdev);Quoted 8 lines
} else if (ret == -ENOENT) { /* No patch/nvm-config found, run with original fw/config */ ret = 0; } else if (ret == -EAGAIN) { /* ... }Quoted 4 lines
Overall looks good and should still become a bit more compact if the handling of flow control is done in
_set_speed()as you suggested in "[PATCH v7 8/8] Bluetooth:hci_qca: Add support for Qualcomm Bluetooth chip wcn3990"
Quoted 5 lines
[Bala}: to over come calling
qca_get_speed()forqca_baudrate.
i prefer passingqca_baudrateas pointer argument toqca_set_speed().
that will actually helps to lower function calls. intern increase
the speed of execution too.
I argued earlier against something similar, where speed was a pointer that was set inside _set_speed(). IMO this interface is unintuitive and makes the code harder to read, even if it saves a function call. The optimization isn't really an important factor here, _get_speed() is cheap and it isn't called in a hot code path.
It's also an option to add an enum qca_speed_type parameter to qca_get_baudrate_value() and hide the _get_speed() call there.