aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBalakrishna Godavarthi <bgodavar@codeaurora.org>2018-08-03 08:16:28 -0400
committerMarcel Holtmann <marcel@holtmann.org>2018-08-03 08:44:06 -0400
commitaadebac4639d84ee51a12f2a1706fea1e4760b81 (patch)
treeab3d8140bce8bdd12c66bdf348ecc090e24ea880
parentba493d4fbcb84bd14842c61cc077ffb5b3f7ecb1 (diff)
Bluetooth: btqca: Redefine qca_uart_setup() to generic function.
Redefinition 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. Signed-off-by: Balakrishna Godavarthi <bgodavar@codeaurora.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--drivers/bluetooth/btqca.c21
-rw-r--r--drivers/bluetooth/btqca.h13
-rw-r--r--drivers/bluetooth/hci_qca.c10
3 files changed, 28 insertions, 16 deletions
diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c
index c5cf9cab438a..479179c54dcf 100644
--- a/drivers/bluetooth/btqca.c
+++ b/drivers/bluetooth/btqca.c
@@ -81,9 +81,13 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
81 */ 81 */
82 *soc_version = (le32_to_cpu(ver->soc_id) << 16) | 82 *soc_version = (le32_to_cpu(ver->soc_id) << 16) |
83 (le16_to_cpu(ver->rome_ver) & 0x0000ffff); 83 (le16_to_cpu(ver->rome_ver) & 0x0000ffff);
84 if (*soc_version == 0)
85 err = -EILSEQ;
84 86
85out: 87out:
86 kfree_skb(skb); 88 kfree_skb(skb);
89 if (err)
90 bt_dev_err(hdev, "QCA Failed to get version (%d)", err);
87 91
88 return err; 92 return err;
89} 93}
@@ -327,9 +331,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
327} 331}
328EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); 332EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
329 333
330int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) 334int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
335 enum qca_btsoc_type soc_type, u32 soc_ver)
331{ 336{
332 u32 rome_ver = 0;
333 struct rome_config config; 337 struct rome_config config;
334 int err; 338 int err;
335 339
@@ -337,19 +341,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
337 341
338 config.user_baud_rate = baudrate; 342 config.user_baud_rate = baudrate;
339 343
340 /* Get QCA version information */
341 err = qca_read_soc_version(hdev, &rome_ver);
342 if (err < 0 || rome_ver == 0) {
343 bt_dev_err(hdev, "QCA Failed to get version %d", err);
344 return err;
345 }
346
347 bt_dev_info(hdev, "QCA controller version 0x%08x", rome_ver);
348
349 /* Download rampatch file */ 344 /* Download rampatch file */
350 config.type = TLV_TYPE_PATCH; 345 config.type = TLV_TYPE_PATCH;
351 snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin", 346 snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
352 rome_ver); 347 soc_ver);
353 err = qca_download_firmware(hdev, &config); 348 err = qca_download_firmware(hdev, &config);
354 if (err < 0) { 349 if (err < 0) {
355 bt_dev_err(hdev, "QCA Failed to download patch (%d)", err); 350 bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
@@ -359,7 +354,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
359 /* Download NVM configuration */ 354 /* Download NVM configuration */
360 config.type = TLV_TYPE_NVM; 355 config.type = TLV_TYPE_NVM;
361 snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin", 356 snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
362 rome_ver); 357 soc_ver);
363 err = qca_download_firmware(hdev, &config); 358 err = qca_download_firmware(hdev, &config);
364 if (err < 0) { 359 if (err < 0) {
365 bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err); 360 bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h
index 5c9851b11838..a9c2779f3e07 100644
--- a/drivers/bluetooth/btqca.h
+++ b/drivers/bluetooth/btqca.h
@@ -124,10 +124,18 @@ struct tlv_type_hdr {
124 __u8 data[0]; 124 __u8 data[0];
125} __packed; 125} __packed;
126 126
127enum qca_btsoc_type {
128 QCA_INVALID = -1,
129 QCA_AR3002,
130 QCA_ROME,
131 QCA_WCN3990
132};
133
127#if IS_ENABLED(CONFIG_BT_QCA) 134#if IS_ENABLED(CONFIG_BT_QCA)
128 135
129int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); 136int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
130int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate); 137int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
138 enum qca_btsoc_type soc_type, u32 soc_ver);
131int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version); 139int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
132 140
133#else 141#else
@@ -137,7 +145,8 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad
137 return -EOPNOTSUPP; 145 return -EOPNOTSUPP;
138} 146}
139 147
140static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) 148static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
149 enum qca_btsoc_type soc_type, u32 soc_ver)
141{ 150{
142 return -EOPNOTSUPP; 151 return -EOPNOTSUPP;
143} 152}
diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 59d9953011a5..6bc8cfb982a9 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -929,6 +929,7 @@ static int qca_setup(struct hci_uart *hu)
929 struct qca_data *qca = hu->priv; 929 struct qca_data *qca = hu->priv;
930 unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200; 930 unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
931 int ret; 931 int ret;
932 int soc_ver = 0;
932 933
933 bt_dev_info(hdev, "ROME setup"); 934 bt_dev_info(hdev, "ROME setup");
934 935
@@ -965,8 +966,15 @@ static int qca_setup(struct hci_uart *hu)
965 host_set_baudrate(hu, speed); 966 host_set_baudrate(hu, speed);
966 } 967 }
967 968
969 /* Get QCA version information */
970 ret = qca_read_soc_version(hdev, &soc_ver);
971 if (ret)
972 return ret;
973
974 bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver);
975
968 /* Setup patch / NVM configurations */ 976 /* Setup patch / NVM configurations */
969 ret = qca_uart_setup(hdev, qca_baudrate); 977 ret = qca_uart_setup(hdev, qca_baudrate, QCA_ROME, soc_ver);
970 if (!ret) { 978 if (!ret) {
971 set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); 979 set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
972 qca_debugfs_init(hdev); 980 qca_debugfs_init(hdev);