Skip to content

Commit aadebac

Browse files
bgodavarholtmann
authored andcommitted
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 <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent ba493d4 commit aadebac

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

drivers/bluetooth/btqca.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,13 @@ int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
8181
*/
8282
*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
8383
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
84+
if (*soc_version == 0)
85+
err = -EILSEQ;
8486

8587
out:
8688
kfree_skb(skb);
89+
if (err)
90+
bt_dev_err(hdev, "QCA Failed to get version (%d)", err);
8791

8892
return err;
8993
}
@@ -327,29 +331,20 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
327331
}
328332
EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
329333

330-
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
334+
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
335+
enum qca_btsoc_type soc_type, u32 soc_ver)
331336
{
332-
u32 rome_ver = 0;
333337
struct rome_config config;
334338
int err;
335339

336340
bt_dev_dbg(hdev, "QCA setup on UART");
337341

338342
config.user_baud_rate = baudrate;
339343

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-
349344
/* Download rampatch file */
350345
config.type = TLV_TYPE_PATCH;
351346
snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
352-
rome_ver);
347+
soc_ver);
353348
err = qca_download_firmware(hdev, &config);
354349
if (err < 0) {
355350
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)
359354
/* Download NVM configuration */
360355
config.type = TLV_TYPE_NVM;
361356
snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
362-
rome_ver);
357+
soc_ver);
363358
err = qca_download_firmware(hdev, &config);
364359
if (err < 0) {
365360
bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);

drivers/bluetooth/btqca.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,18 @@ struct tlv_type_hdr {
124124
__u8 data[0];
125125
} __packed;
126126

127+
enum qca_btsoc_type {
128+
QCA_INVALID = -1,
129+
QCA_AR3002,
130+
QCA_ROME,
131+
QCA_WCN3990
132+
};
133+
127134
#if IS_ENABLED(CONFIG_BT_QCA)
128135

129136
int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
130-
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate);
137+
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
138+
enum qca_btsoc_type soc_type, u32 soc_ver);
131139
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
132140

133141
#else
@@ -137,7 +145,8 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad
137145
return -EOPNOTSUPP;
138146
}
139147

140-
static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
148+
static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
149+
enum qca_btsoc_type soc_type, u32 soc_ver)
141150
{
142151
return -EOPNOTSUPP;
143152
}

drivers/bluetooth/hci_qca.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ static int qca_setup(struct hci_uart *hu)
929929
struct qca_data *qca = hu->priv;
930930
unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200;
931931
int ret;
932+
int soc_ver = 0;
932933

933934
bt_dev_info(hdev, "ROME setup");
934935

@@ -965,8 +966,15 @@ static int qca_setup(struct hci_uart *hu)
965966
host_set_baudrate(hu, speed);
966967
}
967968

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+
968976
/* Setup patch / NVM configurations */
969-
ret = qca_uart_setup(hdev, qca_baudrate);
977+
ret = qca_uart_setup(hdev, qca_baudrate, QCA_ROME, soc_ver);
970978
if (!ret) {
971979
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
972980
qca_debugfs_init(hdev);

0 commit comments

Comments
 (0)